From 180d2570244bfec59dbae12f56c4d34fad3f304b Mon Sep 17 00:00:00 2001 From: Kam Date: Thu, 13 Mar 2025 17:14:45 -0400 Subject: [PATCH] Proper Reformating --- src/main/java/foxz/command/CmdClone.java | 288 +- src/main/java/foxz/command/CmdConfig.java | 264 +- src/main/java/foxz/command/CmdDialog.java | 87 +- src/main/java/foxz/command/CmdFaction.java | 58 +- src/main/java/foxz/command/CmdNoppes.java | 342 +-- src/main/java/foxz/command/CmdNpc.java | 151 +- src/main/java/foxz/command/CmdQuest.java | 108 +- src/main/java/foxz/command/CmdScript.java | 16 +- src/main/java/foxz/command/CommandNoppes.java | 4 +- .../java/foxz/command/ScriptedCommand.java | 7 +- .../commandhelper/AbstractCommandHelper.java | 114 +- .../java/foxz/commandhelper/ChMcLogger.java | 8 +- .../foxz/commandhelper/CommandHelper.java | 8 +- .../commandhelper/permissions/OpOnly.java | 6 +- .../commandhelper/permissions/ParamCheck.java | 6 +- .../commandhelper/permissions/PlayerOnly.java | 1 - src/main/java/foxz/utils/Market.java | 98 +- src/main/java/foxz/utils/Utils.java | 18 +- .../java/kamkeel/npcs/CustomAttributes.java | 4 +- .../java/kamkeel/npcs/addon/AddonManager.java | 4 +- .../java/kamkeel/npcs/addon/DBCAddon.java | 24 +- .../java/kamkeel/npcs/addon/GeckoAddon.java | 5 +- .../kamkeel/npcs/addon/client/DBCClient.java | 21 +- .../npcs/addon/client/GeckoAddonClient.java | 24 +- .../npcs/command/AnimationCommand.java | 64 +- .../npcs/command/AttributeCommand.java | 68 +- .../kamkeel/npcs/command/CloneCommand.java | 182 +- .../kamkeel/npcs/command/CommandKamkeel.java | 68 +- .../npcs/command/CommandKamkeelBase.java | 162 +- .../kamkeel/npcs/command/ConfigCommand.java | 380 ++- .../npcs/command/DialogCategoryCommand.java | 70 +- .../kamkeel/npcs/command/DialogCommand.java | 135 +- .../kamkeel/npcs/command/EffectCommand.java | 8 +- .../kamkeel/npcs/command/FactionCommand.java | 95 +- .../kamkeel/npcs/command/HelpCommand.java | 104 +- .../java/kamkeel/npcs/command/NpcCommand.java | 339 ++- .../kamkeel/npcs/command/OverlayCommand.java | 91 +- .../npcs/command/QuestCategoryCommand.java | 120 +- .../kamkeel/npcs/command/QuestCommand.java | 285 +- .../kamkeel/npcs/command/ScriptCommand.java | 46 +- .../kamkeel/npcs/command/SlayCommand.java | 197 +- .../command/profile/CommandHelpProfile.java | 31 +- .../npcs/command/profile/CommandProfile.java | 213 +- .../command/profile/CommandProfileAdmin.java | 76 +- .../command/profile/CommandProfileBase.java | 160 +- .../command/profile/CommandProfileChange.java | 14 +- .../command/profile/CommandProfileCreate.java | 12 +- .../command/profile/CommandProfileList.java | 12 +- .../command/profile/CommandProfileRegion.java | 34 +- .../command/profile/CommandProfileRemove.java | 14 +- .../command/profile/CommandProfileRename.java | 20 +- .../npcs/controllers/AttributeController.java | 6 +- .../npcs/controllers/ProfileController.java | 88 +- .../npcs/controllers/SyncController.java | 132 +- .../data/attribute/ICustomAttribute.java | 2 + .../RequirementCheckerRegistry.java | 1 + .../types/QuestActiveRequirement.java | 8 +- .../types/QuestCompletedRequirement.java | 8 +- .../tracker/AttributeRecalcEvent.java | 3 +- .../tracker/PlayerAttributeTracker.java | 17 +- .../tracker/PlayerEquipmentTracker.java | 2 +- .../controllers/data/profile/CNPCData.java | 7 +- .../data/profile/IProfileData.java | 5 +- .../controllers/data/profile/Profile.java | 12 +- .../data/profile/ProfileInfoEntry.java | 22 +- .../kamkeel/npcs/developer/Developer.java | 14 +- .../kamkeel/npcs/network/AbstractPacket.java | 7 +- .../npcs/network/LargeAbstractPacket.java | 7 +- .../kamkeel/npcs/network/PacketChannel.java | 2 +- .../kamkeel/npcs/network/PacketClient.java | 2 +- .../kamkeel/npcs/network/PacketHandler.java | 26 +- .../java/kamkeel/npcs/network/PacketUtil.java | 12 +- .../packets/data/ConfigCommandPacket.java | 2 +- .../network/packets/data/LoginPacket.java | 4 +- .../data/OverlayQuestTrackingPacket.java | 4 +- .../network/packets/data/ParticlePacket.java | 2 +- .../packets/data/PlayerDataInfoPacket.java | 4 +- .../packets/data/gui/GuiOpenBookPacket.java | 2 +- .../packets/data/large/ScrollListPacket.java | 2 +- .../packets/data/large/SyncEffectPacket.java | 6 +- .../packets/data/large/SyncPacket.java | 3 +- .../packets/player/BankActionPacket.java | 6 +- .../packets/player/CheckPlayerValue.java | 2 +- .../packets/player/CompanionActionPacket.java | 4 +- .../packets/player/DialogSelectPacket.java | 3 +- .../network/packets/player/GetNPCRole.java | 2 +- .../packets/player/InputDevicePacket.java | 8 +- .../packets/player/MailActionPacket.java | 29 +- .../packets/player/SaveSignPacket.java | 2 +- .../packets/player/ScreenSizePacket.java | 4 +- .../customgui/CustomGuiButtonPacket.java | 1 - .../customgui/CustomGuiClosePacket.java | 1 - .../customgui/CustomGuiUnfocusedPacket.java | 4 +- .../customgui/CustomScrollClickPacket.java | 4 +- .../player/profile/ProfileChangePacket.java | 5 +- .../player/profile/ProfileCreatePacket.java | 8 +- .../player/profile/ProfileGetInfoPacket.java | 22 +- .../player/profile/ProfileGetPacket.java | 10 +- .../player/profile/ProfileRemovePacket.java | 5 +- .../player/profile/ProfileRenamePacket.java | 7 +- .../packets/request/GuiRequestPacket.java | 3 +- .../packets/request/MailOpenSetupPacket.java | 3 +- .../packets/request/MerchantUpdatePacket.java | 5 +- .../network/packets/request/MountPacket.java | 8 +- .../packets/request/TileEntityGetPacket.java | 3 +- .../packets/request/TileEntitySavePacket.java | 3 +- .../request/TraderMarketSavePacket.java | 9 +- .../request/animation/AnimationGetPacket.java | 4 +- .../animation/AnimationRemovePacket.java | 5 +- .../animation/AnimationSavePacket.java | 4 +- .../animation/AnimationsGetPacket.java | 6 +- .../request/bank/BankRemovePacket.java | 3 +- .../request/clone/CloneAllTagsPacket.java | 8 +- .../clone/CloneAllTagsShortPacket.java | 8 +- .../request/clone/CloneListPacket.java | 9 +- .../request/clone/ClonePreSavePacket.java | 5 +- .../request/clone/CloneRemovePacket.java | 9 +- .../request/clone/CloneSavePacket.java | 7 +- .../request/clone/CloneTagListPacket.java | 3 +- .../request/clone/MobSpawnerPacket.java | 8 +- .../packets/request/clone/SpawnMobPacket.java | 11 +- .../dialog/DialogCategoriesGetPacket.java | 6 +- .../dialog/DialogCategoryGetPacket.java | 3 +- .../request/dialog/DialogGetPacket.java | 9 +- .../request/dialog/DialogNpcGetPacket.java | 6 +- .../request/dialog/DialogNpcRemovePacket.java | 3 +- .../request/dialog/DialogRemovePacket.java | 11 +- .../request/dialog/DialogsGetPacket.java | 12 +- .../request/effects/EffectRemovePacket.java | 3 +- .../request/effects/EffectSavePacket.java | 7 +- .../request/effects/EffectsGetPacket.java | 3 +- .../request/faction/FactionGetPacket.java | 5 +- .../request/faction/FactionsGetPacket.java | 6 +- .../feather/DimensionTeleportPacket.java | 13 +- .../request/item/ColorBrushPacket.java | 7 +- .../packets/request/item/ColorSetPacket.java | 9 +- .../packets/request/item/HammerPacket.java | 14 +- .../packets/request/jobs/JobGetPacket.java | 16 +- .../packets/request/jobs/JobSavePacket.java | 7 +- .../request/jobs/JobSpawnerAddPacket.java | 15 +- .../request/jobs/JobSpawnerRemovePacket.java | 5 +- .../request/linked/LinkedGetAllPacket.java | 12 +- .../request/linked/LinkedGetPacket.java | 7 +- .../request/linked/LinkedItemBuildPacket.java | 7 +- .../linked/LinkedItemRemovePacket.java | 3 +- .../request/linked/LinkedItemSavePacket.java | 7 +- .../request/linked/LinkedNPCAddPacket.java | 3 +- .../request/linked/LinkedNPCRemovePacket.java | 3 +- .../request/linked/LinkedSetPacket.java | 3 +- .../request/magic/MagicCycleRemovePacket.java | 8 +- .../request/magic/MagicCycleSavePacket.java | 10 +- .../request/magic/MagicGetAllPacket.java | 14 +- .../packets/request/magic/MagicGetPacket.java | 9 +- .../request/magic/MagicNpcGetPacket.java | 9 +- .../request/magic/MagicNpcSavePacket.java | 7 +- .../request/magic/MagicRemovePacket.java | 8 +- .../request/magic/MagicSavePacket.java | 10 +- .../request/mainmenu/MainmenuAIGetPacket.java | 6 +- .../mainmenu/MainmenuAISavePacket.java | 3 +- .../mainmenu/MainmenuAdvancedGetPacket.java | 6 +- .../MainmenuAdvancedMarkDataPacket.java | 3 +- .../mainmenu/MainmenuAdvancedSavePacket.java | 3 +- .../mainmenu/MainmenuDisplaySavePacket.java | 3 +- .../mainmenu/MainmenuInvGetPacket.java | 6 +- .../mainmenu/MainmenuInvSavePacket.java | 3 +- .../mainmenu/MainmenuStatsGetPacket.java | 6 +- .../mainmenu/MainmenuStatsSavePacket.java | 3 +- .../naturalspawns/NaturalSpawnGetPacket.java | 3 +- .../NaturalSpawnRemovePacket.java | 3 +- .../naturalspawns/NaturalSpawnSavePacket.java | 3 +- .../request/npc/ModelDataSavePacket.java | 7 +- .../packets/request/npc/NpcDeletePacket.java | 3 +- .../request/npc/RemoteDeletePacket.java | 3 +- .../request/npc/RemoteMainMenuPacket.java | 10 +- .../request/npc/RemoteResetPacket.java | 5 +- .../request/npc/RemoteTpToNpcPacket.java | 6 +- .../request/party/PartyInfoPacket.java | 2 +- .../request/pather/MovingPathGetPacket.java | 6 +- .../request/pather/MovingPathSavePacket.java | 2 +- .../PlayerDataDeleteInfoPacket.java | 3 +- .../playerdata/PlayerDataGetInfoPacket.java | 3 +- .../playerdata/PlayerDataGetNamesPacket.java | 5 +- .../playerdata/PlayerDataRemovePacket.java | 17 +- .../playerdata/PlayerDataSaveInfoPacket.java | 3 +- .../quest/QuestCategoriesGetPacket.java | 6 +- .../request/quest/QuestCategoryGetPacket.java | 3 +- .../quest/QuestCategoryRemovePacket.java | 3 +- .../quest/QuestDialogGetTitlePacket.java | 3 +- .../packets/request/quest/QuestGetPacket.java | 9 +- .../request/quest/QuestOpenGuiPacket.java | 3 +- .../request/quest/QuestRemovePacket.java | 14 +- .../request/quest/QuestsGetPacket.java | 12 +- .../request/recipe/RecipeGetPacket.java | 5 +- .../request/recipe/RecipeRemovePacket.java | 5 +- .../request/recipe/RecipeSavePacket.java | 5 +- .../request/recipe/RecipesGetPacket.java | 3 +- .../role/RoleCompanionUpdatePacket.java | 7 +- .../packets/request/role/RoleGetPacket.java | 8 +- .../packets/request/role/RoleSavePacket.java | 3 +- .../request/script/BlockScriptPacket.java | 14 +- .../request/script/EffectScriptPacket.java | 14 +- .../request/script/EventScriptPacket.java | 16 +- .../request/script/ForgeScriptPacket.java | 12 +- .../request/script/GlobalNPCScriptPacket.java | 14 +- .../request/script/NPCScriptPacket.java | 16 +- .../request/script/PlayerScriptPacket.java | 12 +- .../request/script/ScriptInfoPacket.java | 10 +- .../script/item/ItemScriptErrorPacket.java | 9 +- .../request/script/item/ItemScriptPacket.java | 10 +- .../script/item/LinkedItemScriptPacket.java | 14 +- .../packets/request/tags/TagGetPacket.java | 3 +- .../packets/request/tags/TagRemovePacket.java | 3 +- .../packets/request/tags/TagSetPacket.java | 3 +- .../request/tags/TagsNpcGetPacket.java | 3 +- .../request/transform/TransformGetPacket.java | 6 +- .../transform/TransformLoadPacket.java | 5 +- .../transform/TransformSavePacket.java | 3 +- .../TransportCategoriesGetPacket.java | 3 +- .../TransportCategoryRemovePacket.java | 3 +- .../transport/TransportSavePacket.java | 7 +- .../transport/TransportsGetPacket.java | 3 +- .../npcs/util/AttributeAttackUtil.java | 11 +- .../kamkeel/npcs/util/AttributeItemUtil.java | 19 +- .../java/kamkeel/npcs/util/ByteBufUtils.java | 52 +- .../java/kamkeel/npcs/util/ColorUtil.java | 32 +- .../gui/inventory/NPCGuiContainerHelper.java | 12 +- .../renderer/entity/NPCRendererHelper.java | 52 +- .../client/resources/NPCResourceHelper.java | 6 +- .../net/minecraft/entity/NPCEntityHelper.java | 14 +- .../java/nikedemos/markovnames/HashMap2D.java | 117 +- src/main/java/nikedemos/markovnames/Main.java | 85 +- .../markovnames/MarkovDictionary.java | 393 ++- .../markovnames/MarkovDictionarySPA.java | 46 +- .../generators/MarkovAncientGreek.java | 88 +- .../markovnames/generators/MarkovAztec.java | 39 +- .../generators/MarkovCustomNPCsClassic.java | 38 +- .../generators/MarkovGenerator.java | 63 +- .../generators/MarkovJapanese.java | 67 +- .../generators/MarkovOldNorse.java | 39 +- .../markovnames/generators/MarkovRoman.java | 91 +- .../markovnames/generators/MarkovSaami.java | 41 +- .../markovnames/generators/MarkovSlavic.java | 77 +- .../markovnames/generators/MarkovSpanish.java | 67 +- .../markovnames/generators/MarkovWelsh.java | 63 +- .../noppes/npcs/AnimationMixinFunctions.java | 87 +- src/main/java/noppes/npcs/CommonProxy.java | 195 +- .../java/noppes/npcs/CreativeTabNpcs.java | 26 +- src/main/java/noppes/npcs/CustomItems.java | 1330 ++++----- src/main/java/noppes/npcs/CustomNpcs.java | 20 +- .../noppes/npcs/CustomNpcsPermissions.java | 201 +- .../java/noppes/npcs/CustomTeleporter.java | 17 +- src/main/java/noppes/npcs/DataAI.java | 426 ++- src/main/java/noppes/npcs/DataAdvanced.java | 94 +- src/main/java/noppes/npcs/DataDisplay.java | 82 +- src/main/java/noppes/npcs/DataInventory.java | 607 ++--- src/main/java/noppes/npcs/DataStats.java | 208 +- src/main/java/noppes/npcs/EventHooks.java | 165 +- src/main/java/noppes/npcs/IChatMessages.java | 5 +- src/main/java/noppes/npcs/ICompatibilty.java | 8 +- src/main/java/noppes/npcs/LogWriter.java | 387 ++- src/main/java/noppes/npcs/NBTTags.java | 703 +++-- src/main/java/noppes/npcs/NPCLogLevel.java | 10 +- src/main/java/noppes/npcs/NPCSpawning.java | 107 +- .../java/noppes/npcs/NoppesStringUtils.java | 129 +- .../java/noppes/npcs/NoppesUtilPlayer.java | 925 ++++--- .../java/noppes/npcs/NoppesUtilServer.java | 1296 +++++---- .../java/noppes/npcs/NpcDamageSource.java | 15 +- .../noppes/npcs/NpcDamageSourceInderect.java | 15 +- .../java/noppes/npcs/NpcMiscInventory.java | 285 +- src/main/java/noppes/npcs/QuestLogData.java | 156 +- src/main/java/noppes/npcs/Resistances.java | 74 +- .../noppes/npcs/ScriptForgeEventHandler.java | 44 +- .../noppes/npcs/ScriptItemEventHandler.java | 100 +- .../noppes/npcs/ScriptPlayerEventHandler.java | 207 +- src/main/java/noppes/npcs/Server.java | 87 +- .../java/noppes/npcs/ServerEventsHandler.java | 516 ++-- .../java/noppes/npcs/ServerTickHandler.java | 76 +- src/main/java/noppes/npcs/TextBlock.java | 2 +- .../noppes/npcs/VersionCompatibility.java | 374 +-- .../java/noppes/npcs/ai/CombatHandler.java | 224 +- .../noppes/npcs/ai/EntityAIAmbushTarget.java | 134 +- .../noppes/npcs/ai/EntityAIAnimation.java | 69 +- .../noppes/npcs/ai/EntityAIAttackTarget.java | 103 +- .../noppes/npcs/ai/EntityAIAvoidTarget.java | 106 +- .../java/noppes/npcs/ai/EntityAIBustDoor.java | 33 +- .../noppes/npcs/ai/EntityAIDodgeShoot.java | 53 +- .../noppes/npcs/ai/EntityAIFindShade.java | 52 +- .../java/noppes/npcs/ai/EntityAIFollow.java | 65 +- src/main/java/noppes/npcs/ai/EntityAIJob.java | 54 +- .../java/noppes/npcs/ai/EntityAILook.java | 101 +- .../noppes/npcs/ai/EntityAIMoveIndoors.java | 79 +- .../noppes/npcs/ai/EntityAIMovingPath.java | 25 +- .../noppes/npcs/ai/EntityAIOrbitTarget.java | 106 +- .../java/noppes/npcs/ai/EntityAIPanic.java | 29 +- .../noppes/npcs/ai/EntityAIPounceTarget.java | 68 +- .../noppes/npcs/ai/EntityAIRangedAttack.java | 135 +- .../java/noppes/npcs/ai/EntityAIReturn.java | 209 +- .../java/noppes/npcs/ai/EntityAIRole.java | 51 +- .../npcs/ai/EntityAISprintToTarget.java | 27 +- .../noppes/npcs/ai/EntityAIStalkTarget.java | 266 +- .../noppes/npcs/ai/EntityAITransform.java | 31 +- .../java/noppes/npcs/ai/EntityAIWander.java | 113 +- .../noppes/npcs/ai/EntityAIWatchClosest.java | 53 +- .../java/noppes/npcs/ai/EntityAIWaterNav.java | 31 +- .../noppes/npcs/ai/EntityAIWorldLines.java | 6 +- .../noppes/npcs/ai/EntityAIZigZagTarget.java | 77 +- .../npcs/ai/RandomPositionGeneratorAlt.java | 78 +- .../npcs/ai/pathfinder/FlyPathFinder.java | 432 ++- .../npcs/ai/pathfinder/FlyingMoveHelper.java | 39 +- .../noppes/npcs/ai/pathfinder/NPCPath.java | 79 +- .../npcs/ai/pathfinder/NPCPathPoint.java | 101 +- .../noppes/npcs/ai/pathfinder/PathHeap.java | 78 +- .../ai/pathfinder/PathNavigateFlying.java | 414 ++- .../npcs/ai/pathfinder/PathNodeType.java | 11 +- .../npcs/ai/selector/NPCAttackSelector.java | 96 +- .../npcs/ai/selector/NPCInteractSelector.java | 28 +- .../npcs/ai/target/EntityAIClearTarget.java | 24 +- .../npcs/ai/target/EntityAIClosestTarget.java | 54 +- .../ai/target/EntityAIOwnerHurtByTarget.java | 23 +- .../ai/target/EntityAIOwnerHurtTarget.java | 31 +- .../java/noppes/npcs/blocks/BlockBanner.java | 144 +- .../java/noppes/npcs/blocks/BlockBarrel.java | 65 +- .../java/noppes/npcs/blocks/BlockBeam.java | 58 +- .../java/noppes/npcs/blocks/BlockBigSign.java | 124 +- .../java/noppes/npcs/blocks/BlockBlood.java | 76 +- .../java/noppes/npcs/blocks/BlockBook.java | 40 +- .../java/noppes/npcs/blocks/BlockBorder.java | 135 +- .../noppes/npcs/blocks/BlockCampfire.java | 119 +- .../java/noppes/npcs/blocks/BlockCandle.java | 234 +- .../npcs/blocks/BlockCarpentryBench.java | 54 +- .../java/noppes/npcs/blocks/BlockChair.java | 34 +- .../noppes/npcs/blocks/BlockCouchWood.java | 142 +- .../noppes/npcs/blocks/BlockCouchWool.java | 207 +- .../java/noppes/npcs/blocks/BlockCrate.java | 56 +- .../java/noppes/npcs/blocks/BlockCrystal.java | 47 +- .../java/noppes/npcs/blocks/BlockLantern.java | 117 +- .../noppes/npcs/blocks/BlockLightable.java | 21 +- .../java/noppes/npcs/blocks/BlockMailbox.java | 66 +- .../noppes/npcs/blocks/BlockNpcRedstone.java | 68 +- .../noppes/npcs/blocks/BlockPedestal.java | 122 +- .../noppes/npcs/blocks/BlockPlaceholder.java | 53 +- .../java/noppes/npcs/blocks/BlockRotated.java | 61 +- .../noppes/npcs/blocks/BlockScripted.java | 10 +- .../java/noppes/npcs/blocks/BlockShelf.java | 71 +- .../noppes/npcs/blocks/BlockShortLamp.java | 22 +- .../java/noppes/npcs/blocks/BlockSign.java | 57 +- .../java/noppes/npcs/blocks/BlockStool.java | 63 +- .../java/noppes/npcs/blocks/BlockTable.java | 22 +- .../noppes/npcs/blocks/BlockTallLamp.java | 141 +- .../noppes/npcs/blocks/BlockTombstone.java | 112 +- .../java/noppes/npcs/blocks/BlockTrigger.java | 28 +- .../noppes/npcs/blocks/BlockWallBanner.java | 110 +- .../noppes/npcs/blocks/BlockWaypoint.java | 51 +- .../noppes/npcs/blocks/BlockWeaponRack.java | 180 +- .../noppes/npcs/blocks/tiles/TileBanner.java | 30 +- .../noppes/npcs/blocks/tiles/TileBarrel.java | 11 +- .../noppes/npcs/blocks/tiles/TileBigSign.java | 54 +- .../npcs/blocks/tiles/TileBlockAnvil.java | 5 +- .../noppes/npcs/blocks/tiles/TileBook.java | 15 +- .../noppes/npcs/blocks/tiles/TileBorder.java | 140 +- .../npcs/blocks/tiles/TileCampfire.java | 25 +- .../noppes/npcs/blocks/tiles/TileChair.java | 10 +- .../npcs/blocks/tiles/TileColorable.java | 18 +- .../npcs/blocks/tiles/TileCouchWood.java | 14 +- .../npcs/blocks/tiles/TileCouchWool.java | 22 +- .../noppes/npcs/blocks/tiles/TileCrate.java | 12 +- .../noppes/npcs/blocks/tiles/TileLamp.java | 1 - .../noppes/npcs/blocks/tiles/TileMailbox.java | 4 +- .../npcs/blocks/tiles/TileNpcContainer.java | 183 +- .../npcs/blocks/tiles/TilePedestal.java | 42 +- .../npcs/blocks/tiles/TileRedstoneBlock.java | 231 +- .../npcs/blocks/tiles/TileScripted.java | 163 +- .../npcs/blocks/tiles/TileShortLamp.java | 2 +- .../noppes/npcs/blocks/tiles/TileSign.java | 12 +- .../noppes/npcs/blocks/tiles/TileTable.java | 1 - .../npcs/blocks/tiles/TileTallLamp.java | 6 +- .../npcs/blocks/tiles/TileTombstone.java | 4 +- .../noppes/npcs/blocks/tiles/TileVariant.java | 62 +- .../npcs/blocks/tiles/TileWallBanner.java | 8 +- .../npcs/blocks/tiles/TileWaypoint.java | 30 +- .../npcs/blocks/tiles/TileWeaponRack.java | 63 +- .../noppes/npcs/client/AnalyticsTracking.java | 81 +- .../noppes/npcs/client/AssetsBrowser.java | 257 +- .../npcs/client/ClientCacheHandler.java | 4 +- .../npcs/client/ClientEventHandler.java | 42 +- .../java/noppes/npcs/client/ClientProxy.java | 857 +++--- .../noppes/npcs/client/ClientTickHandler.java | 157 +- .../client/CustomNpcResourceListener.java | 121 +- .../java/noppes/npcs/client/EntityUtil.java | 140 +- .../noppes/npcs/client/ImageDownloadAlt.java | 100 +- .../npcs/client/MessageAchievement.java | 39 +- .../java/noppes/npcs/client/NoppesUtil.java | 293 +- .../npcs/client/RenderChatMessages.java | 115 +- .../noppes/npcs/client/TextBlockClient.java | 135 +- .../noppes/npcs/client/TranslateUtil.java | 84 +- .../noppes/npcs/client/VersionChecker.java | 47 +- .../controllers/ClientCloneController.java | 59 +- .../controllers/ClientTagMapController.java | 16 +- .../client/controllers/MusicController.java | 33 +- .../npcs/client/controllers/Preset.java | 330 +-- .../client/controllers/PresetController.java | 183 +- .../controllers/ScriptSoundController.java | 2 +- .../java/noppes/npcs/client/fx/CustomFX.java | 186 +- .../npcs/client/fx/EntityBigSmokeFX.java | 26 +- .../client/fx/EntityElementalStaffFX.java | 64 +- .../noppes/npcs/client/fx/EntityEnderFX.java | 55 +- .../npcs/client/fx/EntityRainbowFX.java | 45 +- .../npcs/client/gui/EventGuiScriptList.java | 36 +- .../npcs/client/gui/GuiBorderBlock.java | 87 +- .../npcs/client/gui/GuiMagicCycleMap.java | 19 +- .../npcs/client/gui/GuiMerchantAdd.java | 201 +- .../client/gui/GuiNPCFactionSelection.java | 116 +- .../npcs/client/gui/GuiNPCLinesEdit.java | 60 +- .../gui/GuiNPCTransportCategoryEdit.java | 65 +- .../npcs/client/gui/GuiNpcDimension.java | 97 +- .../npcs/client/gui/GuiNpcMobSpawner.java | 882 +++--- .../npcs/client/gui/GuiNpcMobSpawnerAdd.java | 282 +- .../client/gui/GuiNpcMobSpawnerMounter.java | 272 +- .../client/gui/GuiNpcMobSpawnerSelector.java | 194 +- .../noppes/npcs/client/gui/GuiNpcPather.java | 144 +- .../npcs/client/gui/GuiNpcRedstoneBlock.java | 189 +- .../npcs/client/gui/GuiNpcRemoteEditor.java | 149 +- .../client/gui/GuiNpcSelectionInterface.java | 156 +- .../npcs/client/gui/GuiNpcTextureCloaks.java | 63 +- .../client/gui/GuiNpcTextureOverlays.java | 61 +- .../npcs/client/gui/GuiNpcWaypoint.java | 66 +- .../noppes/npcs/client/gui/GuiScript.java | 430 ++- .../noppes/npcs/client/gui/GuiScriptList.java | 134 +- .../npcs/client/gui/SubGuiAnimationFrame.java | 2 +- .../client/gui/SubGuiAnimationOptions.java | 2 +- .../npcs/client/gui/SubGuiClonerNPCTags.java | 47 +- .../client/gui/SubGuiClonerQuickTags.java | 180 +- .../npcs/client/gui/SubGuiColorSelector.java | 171 +- .../npcs/client/gui/SubGuiCustomHitbox.java | 36 +- .../npcs/client/gui/SubGuiEditText.java | 65 +- .../npcs/client/gui/SubGuiEffectGeneral.java | 26 +- .../noppes/npcs/client/gui/SubGuiMagic.java | 93 +- .../npcs/client/gui/SubGuiMagicCycle.java | 71 +- .../client/gui/SubGuiMagicCycleViewer.java | 15 +- .../client/gui/SubGuiMailmanSendSetup.java | 129 +- .../client/gui/SubGuiNpcAvailability.java | 233 +- .../gui/SubGuiNpcAvailabilityDialog.java | 262 +- .../gui/SubGuiNpcAvailabilityQuest.java | 268 +- .../npcs/client/gui/SubGuiNpcBiomes.java | 119 +- .../npcs/client/gui/SubGuiNpcCommand.java | 60 +- .../npcs/client/gui/SubGuiNpcDialog.java | 277 +- .../client/gui/SubGuiNpcDialogOption.java | 151 +- .../client/gui/SubGuiNpcDialogOptions.java | 73 +- .../client/gui/SubGuiNpcDialogVisual.java | 43 +- .../npcs/client/gui/SubGuiNpcDimensions.java | 155 +- .../client/gui/SubGuiNpcFactionOptions.java | 162 +- .../client/gui/SubGuiNpcFactionPoints.java | 90 +- .../client/gui/SubGuiNpcMeleeProperties.java | 121 +- .../npcs/client/gui/SubGuiNpcMovement.java | 333 ++- .../noppes/npcs/client/gui/SubGuiNpcName.java | 89 +- .../client/gui/SubGuiNpcPartyOptions.java | 26 +- .../client/gui/SubGuiNpcProfileOptions.java | 30 +- .../npcs/client/gui/SubGuiNpcProjectiles.java | 204 +- .../npcs/client/gui/SubGuiNpcQuest.java | 332 ++- .../client/gui/SubGuiNpcRangeProperties.java | 145 +- .../gui/SubGuiNpcResistanceProperties.java | 102 +- .../npcs/client/gui/SubGuiNpcRespawn.java | 100 +- .../npcs/client/gui/SubGuiNpcTextArea.java | 104 +- .../noppes/npcs/client/gui/SubGuiNpcTint.java | 18 +- .../npcs/client/gui/SubGuiPlayerData.java | 22 +- .../client/gui/SubGuiSpawningOptions.java | 2 +- .../gui/advanced/GuiNPCAdvancedLinkedNpc.java | 60 +- .../gui/advanced/GuiNPCDialogNpcOptions.java | 106 +- .../gui/advanced/GuiNPCFactionSetup.java | 94 +- .../client/gui/advanced/GuiNPCLinesMenu.java | 56 +- .../npcs/client/gui/advanced/GuiNPCMagic.java | 6 +- .../npcs/client/gui/advanced/GuiNPCMarks.java | 100 +- .../client/gui/advanced/GuiNPCNightSetup.java | 93 +- .../client/gui/advanced/GuiNPCSoundsMenu.java | 82 +- .../client/gui/advanced/GuiNPCTagSetup.java | 199 +- .../npcs/client/gui/custom/GuiCustom.java | 356 +-- .../custom/components/CustomGuiButton.java | 84 +- .../gui/custom/components/CustomGuiLabel.java | 277 +- .../gui/custom/components/CustomGuiLine.java | 24 +- .../components/CustomGuiScrollComponent.java | 26 +- .../gui/custom/components/CustomGuiSlot.java | 6 +- .../custom/components/CustomGuiTextField.java | 10 +- .../components/CustomGuiTexturedRect.java | 2 +- .../gui/customoverlay/OverlayCustom.java | 22 +- .../components/CustomOverlayLabel.java | 267 +- .../components/CustomOverlayLine.java | 56 +- .../components/CustomOverlayTexturedRect.java | 52 +- .../gui/global/GuiNPCEditAnimation.java | 74 +- .../gui/global/GuiNPCManageAnimations.java | 103 +- .../client/gui/global/GuiNPCManageBanks.java | 342 ++- .../gui/global/GuiNPCManageDialogs.java | 616 +++-- .../gui/global/GuiNPCManageEffects.java | 3 +- .../gui/global/GuiNPCManageFactions.java | 130 +- .../client/gui/global/GuiNPCManageLinked.java | 181 +- .../client/gui/global/GuiNPCManageQuest.java | 8 +- .../client/gui/global/GuiNPCManageTags.java | 304 ++- .../gui/global/GuiNPCManageTransporters.java | 160 +- .../client/gui/global/GuiNpcManageMagic.java | 51 +- .../gui/global/GuiNpcManagePlayerData.java | 12 +- .../gui/global/GuiNpcManageRecipes.java | 273 +- .../gui/global/GuiNpcNaturalSpawns.java | 457 ++-- .../client/gui/global/GuiNpcQuestReward.java | 65 +- .../npcs/client/gui/hud/ClientHudManager.java | 7 +- .../client/gui/hud/CompassHudComponent.java | 48 +- .../npcs/client/gui/hud/GuiHudEditor.java | 52 +- .../npcs/client/gui/hud/HudComponent.java | 3 +- .../gui/hud/QuestTrackingComponent.java | 53 +- .../client/gui/item/GuiNpcPaintbrush.java | 4 +- .../client/gui/item/SubGuiLinkedItem.java | 79 +- .../gui/mainmenu/GuiNPCGlobalMainMenu.java | 18 +- .../npcs/client/gui/mainmenu/GuiNPCInv.java | 137 +- .../npcs/client/gui/mainmenu/GuiNpcAI.java | 285 +- .../client/gui/mainmenu/GuiNpcAdvanced.java | 209 +- .../client/gui/mainmenu/GuiNpcDisplay.java | 162 +- .../npcs/client/gui/mainmenu/GuiNpcStats.java | 225 +- .../client/gui/model/GuiCreationScreen.java | 622 +++-- .../client/gui/model/GuiEntitySelection.java | 147 +- .../npcs/client/gui/model/GuiModelArms.java | 101 +- .../npcs/client/gui/model/GuiModelBody.java | 396 +-- .../npcs/client/gui/model/GuiModelColor.java | 145 +- .../npcs/client/gui/model/GuiModelHead.java | 328 +-- .../npcs/client/gui/model/GuiModelLegs.java | 201 +- .../npcs/client/gui/model/GuiModelRotate.java | 333 ++- .../npcs/client/gui/model/GuiModelScale.java | 253 +- .../npcs/client/gui/model/GuiPresetSave.java | 65 +- .../client/gui/model/GuiPresetSelection.java | 158 +- .../client/gui/player/GuiAnvilRecipes.java | 57 +- .../npcs/client/gui/player/GuiBigSign.java | 25 +- .../npcs/client/gui/player/GuiBook.java | 260 +- .../npcs/client/gui/player/GuiCrate.java | 14 +- .../client/gui/player/GuiDialogImage.java | 38 +- .../client/gui/player/GuiDialogInteract.java | 1032 +++---- .../npcs/client/gui/player/GuiMailbox.java | 201 +- .../client/gui/player/GuiMailmanWrite.java | 309 +-- .../client/gui/player/GuiNPCBankChest.java | 178 +- .../npcs/client/gui/player/GuiNPCTrader.java | 179 +- .../gui/player/GuiNpcCarpentryBench.java | 40 +- .../client/gui/player/GuiNpcFollower.java | 125 +- .../client/gui/player/GuiNpcFollowerHire.java | 91 +- .../client/gui/player/GuiQuestCompletion.java | 79 +- .../npcs/client/gui/player/GuiRecipes.java | 139 +- .../gui/player/GuiTransportSelection.java | 77 +- .../player/companion/GuiNpcCompanionInv.java | 136 +- .../companion/GuiNpcCompanionStats.java | 244 +- .../companion/GuiNpcCompanionTalents.java | 273 +- .../player/inventory/GuiCNPCInventory.java | 19 +- .../gui/player/inventory/GuiFaction.java | 233 +- .../client/gui/player/inventory/GuiParty.java | 43 +- .../gui/player/inventory/GuiProfiles.java | 98 +- .../gui/player/inventory/GuiQuestLog.java | 244 +- .../gui/player/inventory/GuiSettings.java | 82 +- .../gui/questtypes/GuiNpcQuestTypeDialog.java | 138 +- .../gui/questtypes/GuiNpcQuestTypeItem.java | 64 +- .../gui/questtypes/GuiNpcQuestTypeKill.java | 202 +- .../questtypes/GuiNpcQuestTypeLocation.java | 83 +- .../gui/questtypes/GuiNpcQuestTypeManual.java | 119 +- .../client/gui/roles/GuiNpcBankSetup.java | 87 +- .../npcs/client/gui/roles/GuiNpcBard.java | 93 +- .../client/gui/roles/GuiNpcCompanion.java | 149 +- .../client/gui/roles/GuiNpcConversation.java | 184 +- .../client/gui/roles/GuiNpcFollowerJob.java | 50 +- .../client/gui/roles/GuiNpcFollowerSetup.java | 109 +- .../npcs/client/gui/roles/GuiNpcGuard.java | 200 +- .../npcs/client/gui/roles/GuiNpcHealer.java | 37 +- .../client/gui/roles/GuiNpcItemGiver.java | 101 +- .../npcs/client/gui/roles/GuiNpcSpawner.java | 344 ++- .../client/gui/roles/GuiNpcTraderSetup.java | 95 +- .../client/gui/roles/GuiNpcTransporter.java | 97 +- .../gui/roles/SubGuiNpcConversationLine.java | 42 +- .../client/gui/script/EventGuiScriptList.java | 24 +- .../client/gui/script/GuiNPCEventScripts.java | 2 +- .../client/gui/script/GuiScriptAllNPCs.java | 2 +- .../client/gui/script/GuiScriptBlock.java | 1 - .../client/gui/script/GuiScriptEffect.java | 38 +- .../client/gui/script/GuiScriptForge.java | 10 +- .../client/gui/script/GuiScriptGlobal.java | 7 +- .../client/gui/script/GuiScriptInterface.java | 143 +- .../npcs/client/gui/script/GuiScriptItem.java | 15 +- .../gui/script/GuiScriptLinkedItem.java | 36 +- .../client/gui/script/GuiScriptPlayers.java | 4 +- .../client/gui/select/GuiDialogSelection.java | 170 +- .../client/gui/select/GuiQuestSelection.java | 178 +- .../client/gui/select/GuiSoundSelection.java | 36 +- .../gui/select/GuiTextureSelection.java | 161 +- .../gui/util/GuiButtonBiDirectional.java | 91 +- .../client/gui/util/GuiButtonNextPage.java | 17 +- .../gui/util/GuiContainerNPCInterface.java | 427 +-- .../gui/util/GuiContainerNPCInterface2.java | 69 +- .../npcs/client/gui/util/GuiCustomScroll.java | 357 ++- .../gui/util/GuiCustomScrollCloner.java | 44 +- .../npcs/client/gui/util/GuiDiagram.java | 165 +- .../npcs/client/gui/util/GuiEffectBar.java | 4 +- .../npcs/client/gui/util/GuiHoverText.java | 52 +- .../client/gui/util/GuiMenuSideButton.java | 65 +- .../client/gui/util/GuiMenuTopButton.java | 84 +- .../client/gui/util/GuiMenuTopIconButton.java | 106 +- .../client/gui/util/GuiModelInterface.java | 2 +- .../client/gui/util/GuiModelInterface2.java | 131 +- .../npcs/client/gui/util/GuiNPCInterface.java | 6 +- .../client/gui/util/GuiNPCInterface2.java | 49 +- .../client/gui/util/GuiNPCStringSlot.java | 83 +- .../client/gui/util/GuiNpcButtonYesNo.java | 24 +- .../npcs/client/gui/util/GuiNpcLabel.java | 47 +- .../npcs/client/gui/util/GuiNpcSlider.java | 146 +- .../npcs/client/gui/util/GuiNpcTextArea.java | 442 ++- .../client/gui/util/GuiScriptTextArea.java | 250 +- .../client/gui/util/GuiSelectionListener.java | 2 +- .../client/gui/util/GuiTexturedButton.java | 101 +- .../npcs/client/gui/util/GuiToggleButton.java | 2 +- .../npcs/client/gui/util/IButtonListener.java | 2 +- .../gui/util/ICustomScrollListener.java | 6 +- .../npcs/client/gui/util/IGuiClose.java | 2 +- .../noppes/npcs/client/gui/util/IGuiData.java | 2 +- .../npcs/client/gui/util/IGuiError.java | 2 +- .../client/gui/util/IJTextAreaListener.java | 2 +- .../npcs/client/gui/util/IPartyData.java | 2 +- .../npcs/client/gui/util/IPlayerDataInfo.java | 5 + .../npcs/client/gui/util/IScrollData.java | 5 +- .../npcs/client/gui/util/ISliderListener.java | 12 +- .../npcs/client/gui/util/ISubGuiListener.java | 2 +- .../client/gui/util/ITextfieldListener.java | 3 +- .../client/gui/util/ITopButtonListener.java | 2 +- .../npcs/client/gui/util/SubGuiInterface.java | 59 +- .../gui/util/SubGuiNpcCooldownPicker.java | 26 +- .../npcs/client/gui/util/TextContainer.java | 62 +- .../noppes/npcs/client/model/ModelMPM.java | 1598 ++++++----- .../npcs/client/model/ModelNPCGolem.java | 117 +- .../npcs/client/model/ModelNPCMale.java | 159 +- .../npcs/client/model/ModelNpcCrystal.java | 24 +- .../npcs/client/model/ModelNpcDragon.java | 187 +- .../npcs/client/model/ModelNpcSlime.java | 47 +- .../noppes/npcs/client/model/ModelPony.java | 331 +-- .../npcs/client/model/ModelPonyArmor.java | 119 +- .../npcs/client/model/ModelSkirtArmor.java | 68 +- .../client/model/animation/AniCrawling.java | 28 +- .../npcs/client/model/animation/AniHug.java | 4 +- .../npcs/client/model/blocks/ModelAnvil.java | 26 +- .../npcs/client/model/blocks/ModelBeam.java | 38 +- .../client/model/blocks/ModelBigSign.java | 8 +- .../client/model/blocks/ModelCampfire.java | 181 +- .../model/blocks/ModelCarpentryBench.java | 136 +- .../npcs/client/model/blocks/ModelCrate.java | 260 +- .../npcs/client/model/blocks/ModelInk.java | 80 +- .../client/model/blocks/ModelLongCrate.java | 112 +- .../client/model/blocks/ModelMailbox.java | 42 +- .../client/model/blocks/ModelMailboxWow.java | 64 +- .../client/model/blocks/ModelPedestal.java | 36 +- .../npcs/client/model/blocks/ModelShelf.java | 88 +- .../npcs/client/model/blocks/ModelSign.java | 69 +- .../npcs/client/model/blocks/ModelStool.java | 25 +- .../npcs/client/model/blocks/ModelTable.java | 10 +- .../client/model/blocks/ModelTombstone1.java | 72 +- .../client/model/blocks/ModelTombstone2.java | 42 +- .../client/model/blocks/ModelTombstone3.java | 104 +- .../client/model/blocks/ModelWeaponRack.java | 232 +- .../model/blocks/banner/ModelBannerFloor.java | 102 +- .../model/blocks/banner/ModelBannerWall.java | 21 +- .../model/blocks/barrel/ModelBarrel.java | 108 +- .../blocks/campfire/ModelCampfireCoals.java | 34 +- .../blocks/campfire/ModelCampfireStone.java | 82 +- .../model/blocks/candle/ModelCandle.java | 76 +- .../blocks/candle/ModelCandleCeiling.java | 224 +- .../model/blocks/candle/ModelCandleWall.java | 100 +- .../client/model/blocks/chair/ModelChair.java | 56 +- .../model/blocks/chair/ModelChairSpoof.java | 56 +- .../model/blocks/couch/ModelCouchCorner.java | 3 +- .../model/blocks/couch/ModelCouchMiddle.java | 3 +- .../model/blocks/couch/ModelCouchSingle.java | 3 +- .../model/blocks/lamp/ModelShortLamp.java | 113 +- .../model/blocks/lamp/ModelTallLamp.java | 113 +- .../model/blocks/lantern/LanternCeiling.java | 68 +- .../model/blocks/lantern/LanternFloor.java | 50 +- .../model/blocks/lantern/LanternWall.java | 78 +- .../model/blocks/legacy/ModelLegacyAnvil.java | 126 +- .../blocks/legacy/ModelLegacyBanner.java | 109 +- .../blocks/legacy/ModelLegacyBannerFlag.java | 41 +- .../blocks/legacy/ModelLegacyBarrel.java | 146 +- .../blocks/legacy/ModelLegacyBarrelLid.java | 44 +- .../blocks/legacy/ModelLegacyCandle.java | 84 +- .../legacy/ModelLegacyCandleCeiling.java | 226 +- .../blocks/legacy/ModelLegacyCandleWall.java | 126 +- .../legacy/ModelLegacyCarpentryBench.java | 172 +- .../blocks/legacy/ModelLegacyCeiling.java | 196 +- .../model/blocks/legacy/ModelLegacyChair.java | 168 +- .../blocks/legacy/ModelLegacyLantern.java | 84 +- .../blocks/legacy/ModelLegacyMailboxUS.java | 148 +- .../blocks/legacy/ModelLegacyPedestal.java | 50 +- .../model/blocks/legacy/ModelLegacyStool.java | 124 +- .../model/blocks/legacy/ModelLegacyTable.java | 74 +- .../blocks/legacy/ModelLegacyTallLamp.java | 84 +- .../blocks/legacy/ModelLegacyTallLampTop.java | 60 +- .../model/blocks/legacy/ModelLegacyWall.java | 106 +- .../blocks/legacy/ModelLegacyWallBanner.java | 74 +- .../legacy/ModelLegacyWallBannerFlag.java | 28 +- .../legacy/couch/ModelCouchWoodLeft.java | 218 +- .../legacy/couch/ModelCouchWoodMiddle.java | 174 +- .../legacy/couch/ModelCouchWoodRight.java | 204 +- .../legacy/couch/ModelCouchWoodSingle.java | 244 +- .../legacy/couch/ModelLegacyCouchCorner.java | 112 +- .../couch/ModelLegacyCouchCornerWool.java | 62 +- .../legacy/couch/ModelLegacyCouchLeft.java | 92 +- .../couch/ModelLegacyCouchLeftWool.java | 42 +- .../legacy/couch/ModelLegacyCouchMiddle.java | 75 +- .../couch/ModelLegacyCouchMiddleWool.java | 41 +- .../legacy/couch/ModelLegacyCouchRight.java | 100 +- .../couch/ModelLegacyCouchRightWool.java | 46 +- .../npcs/client/model/part/ModelBeard.java | 62 +- .../npcs/client/model/part/ModelBodywear.java | 90 +- .../npcs/client/model/part/ModelBreasts.java | 180 +- .../npcs/client/model/part/ModelClaws.java | 58 +- .../npcs/client/model/part/ModelDuckBeak.java | 125 +- .../npcs/client/model/part/ModelEars.java | 107 +- .../npcs/client/model/part/ModelFin.java | 48 +- .../npcs/client/model/part/ModelHair.java | 79 +- .../npcs/client/model/part/ModelHeadwear.java | 170 +- .../npcs/client/model/part/ModelHorns.java | 68 +- .../npcs/client/model/part/ModelLegs.java | 383 ++- .../npcs/client/model/part/ModelLimbWear.java | 216 +- .../npcs/client/model/part/ModelMohawk.java | 46 +- .../npcs/client/model/part/ModelSkirt.java | 99 +- .../npcs/client/model/part/ModelSnout.java | 122 +- .../npcs/client/model/part/ModelTail.java | 188 +- .../npcs/client/model/part/ModelWings.java | 82 +- .../model/part/horns/ModelAntennasBack.java | 74 +- .../model/part/horns/ModelAntennasFront.java | 68 +- .../model/part/horns/ModelAntlerHorns.java | 140 +- .../model/part/horns/ModelBullHorns.java | 98 +- .../model/part/legs/ModelDigitigradeLegs.java | 175 +- .../model/part/legs/ModelMermaidLegs.java | 89 +- .../model/part/legs/ModelMermaidLegs2.java | 181 +- .../client/model/part/legs/ModelNagaLegs.java | 327 ++- .../model/part/tails/ModelCanineTail.java | 94 +- .../model/part/tails/ModelDragonTail.java | 157 +- .../model/part/tails/ModelFeatherTail.java | 10 +- .../model/part/tails/ModelMonkeyTail.java | 424 +-- .../model/part/tails/ModelRodentTail.java | 46 +- .../model/part/tails/ModelSquirrelTail.java | 98 +- .../client/model/part/tails/ModelTailFin.java | 76 +- .../client/model/util/Model2DRenderer.java | 123 +- .../client/model/util/ModelPartInterface.java | 99 +- .../npcs/client/model/util/ModelPlane.java | 50 +- .../client/model/util/ModelPlaneRenderer.java | 44 +- .../model/util/ModelRenderPassHelper.java | 18 +- .../client/model/util/ModelScaleRenderer.java | 37 +- .../client/renderer/EnumPlanePosition.java | 2 +- .../renderer/ImageBufferDownloadAlt.java | 16 +- .../npcs/client/renderer/ImageData.java | 12 +- .../npcs/client/renderer/MarkRenderer.java | 61 +- .../npcs/client/renderer/NpcItemRenderer.java | 160 +- .../npcs/client/renderer/RenderCNPCHand.java | 52 +- .../client/renderer/RenderCNPCPlayer.java | 150 +- .../npcs/client/renderer/RenderCustomNpc.java | 185 +- .../client/renderer/RenderNPCHumanMale.java | 237 +- .../client/renderer/RenderNPCInterface.java | 740 +++--- .../npcs/client/renderer/RenderNPCPony.java | 208 +- .../client/renderer/RenderNpcCrystal.java | 13 +- .../npcs/client/renderer/RenderNpcDragon.java | 17 +- .../npcs/client/renderer/RenderNpcSlime.java | 29 +- .../client/renderer/RenderProjectile.java | 274 +- .../renderer/blocks/BlockBannerRenderer.java | 123 +- .../renderer/blocks/BlockBarrelRenderer.java | 88 +- .../renderer/blocks/BlockBeamRenderer.java | 59 +- .../renderer/blocks/BlockBigSignRenderer.java | 149 +- .../renderer/blocks/BlockBloodRenderer.java | 64 +- .../renderer/blocks/BlockBookRenderer.java | 67 +- .../renderer/blocks/BlockBorderRenderer.java | 66 +- .../blocks/BlockCampfireRenderer.java | 56 +- .../renderer/blocks/BlockCandleRenderer.java | 90 +- .../blocks/BlockCarpentryBenchRenderer.java | 90 +- .../renderer/blocks/BlockChairRenderer.java | 84 +- .../blocks/BlockCouchWoodRenderer.java | 63 +- .../blocks/BlockCouchWoolRenderer.java | 120 +- .../renderer/blocks/BlockCrateRenderer.java | 45 +- .../renderer/blocks/BlockLanternRenderer.java | 87 +- .../renderer/blocks/BlockMailboxRenderer.java | 91 +- .../blocks/BlockPedestalRenderer.java | 114 +- .../blocks/BlockRendererInterface.java | 110 +- .../blocks/BlockScriptedRenderer.java | 9 +- .../renderer/blocks/BlockShelfRenderer.java | 86 +- .../blocks/BlockShortLampRenderer.java | 35 +- .../renderer/blocks/BlockSignRenderer.java | 87 +- .../renderer/blocks/BlockStoolRenderer.java | 84 +- .../renderer/blocks/BlockTableRenderer.java | 73 +- .../blocks/BlockTallLampRenderer.java | 67 +- .../blocks/BlockTombstoneRenderer.java | 142 +- .../blocks/BlockWallBannerRenderer.java | 89 +- .../blocks/BlockWeaponRackRenderer.java | 114 +- .../renderer/items/ItemBannerRenderer.java | 7 +- .../items/ItemBannerWallRenderer.java | 7 +- .../renderer/items/ItemCouchWoolRenderer.java | 4 +- .../renderer/items/ItemCustomRenderer.java | 460 ++-- .../renderer/items/ItemShortLampRenderer.java | 2 +- .../renderer/items/ItemTallLampRenderer.java | 6 +- .../renderer/items/ItemToolRenderer.java | 237 +- .../noppes/npcs/compat/PixelmonHelper.java | 499 ++-- .../java/noppes/npcs/config/ConfigClient.java | 29 +- .../java/noppes/npcs/config/ConfigDebug.java | 38 +- .../java/noppes/npcs/config/ConfigItem.java | 26 +- .../java/noppes/npcs/config/ConfigMain.java | 31 +- .../java/noppes/npcs/config/ConfigMixin.java | 19 +- .../java/noppes/npcs/config/ConfigScript.java | 53 +- .../java/noppes/npcs/config/GlyphCache.java | 256 +- .../noppes/npcs/config/LoadConfiguration.java | 5 +- .../java/noppes/npcs/config/StringCache.java | 1037 ++++---- .../noppes/npcs/config/legacy/ConfigProp.java | 4 +- .../npcs/config/legacy/LegacyConfig.java | 30 +- .../npcs/config/legacy/LegacyLoader.java | 246 +- .../java/noppes/npcs/constants/AiMutex.java | 6 +- .../noppes/npcs/constants/EnumAnimation.java | 30 +- .../npcs/constants/EnumAnimationPart.java | 23 +- .../constants/EnumAvailabilityDialog.java | 2 +- .../constants/EnumAvailabilityFaction.java | 2 +- .../EnumAvailabilityFactionType.java | 2 +- .../npcs/constants/EnumAvailabilityQuest.java | 2 +- .../npcs/constants/EnumBannerVariant.java | 2 +- .../npcs/constants/EnumBardInstrument.java | 2 +- .../npcs/constants/EnumCombatPolicy.java | 31 +- .../npcs/constants/EnumCompanionJobs.java | 2 +- .../npcs/constants/EnumCompanionStage.java | 29 +- .../npcs/constants/EnumCompanionTalent.java | 15 +- .../noppes/npcs/constants/EnumDayTime.java | 2 +- .../npcs/constants/EnumDiagramLayout.java | 11 +- .../noppes/npcs/constants/EnumGuiType.java | 108 +- .../noppes/npcs/constants/EnumJobType.java | 2 +- .../noppes/npcs/constants/EnumMovingType.java | 32 +- .../noppes/npcs/constants/EnumNavType.java | 36 +- .../npcs/constants/EnumNpcToolMaterial.java | 29 +- .../noppes/npcs/constants/EnumOptionType.java | 2 +- .../npcs/constants/EnumParticleType.java | 31 +- .../npcs/constants/EnumPartyExchange.java | 27 +- .../npcs/constants/EnumPartyObjectives.java | 23 +- .../npcs/constants/EnumPartyRequirements.java | 27 +- .../noppes/npcs/constants/EnumPlayerData.java | 2 +- .../noppes/npcs/constants/EnumPotionType.java | 2 +- .../npcs/constants/EnumProfileSync.java | 23 +- .../npcs/constants/EnumQuestCompletion.java | 2 +- .../npcs/constants/EnumQuestRepeat.java | 2 +- .../noppes/npcs/constants/EnumQuestType.java | 2 +- .../noppes/npcs/constants/EnumScriptType.java | 192 +- .../npcs/constants/EnumStandingType.java | 2 +- .../npcs/constants/EnumTextureType.java | 9 +- .../java/noppes/npcs/constants/MarkType.java | 14 +- .../npcs/containers/ContainerAnvilRepair.java | 12 +- .../containers/ContainerCarpentryBench.java | 110 +- .../npcs/containers/ContainerCrate.java | 59 +- .../npcs/containers/ContainerCustomGui.java | 22 +- .../npcs/containers/ContainerEmpty.java | 10 +- .../noppes/npcs/containers/ContainerMail.java | 89 +- .../npcs/containers/ContainerManageBanks.java | 71 +- .../containers/ContainerManageRecipes.java | 91 +- .../npcs/containers/ContainerMerchantAdd.java | 93 +- .../containers/ContainerNPCBankInterface.java | 126 +- .../containers/ContainerNPCBankLarge.java | 24 +- .../containers/ContainerNPCBankSmall.java | 18 +- .../containers/ContainerNPCBankUnlock.java | 10 +- .../containers/ContainerNPCBankUpgrade.java | 28 +- .../containers/ContainerNPCCompanion.java | 56 +- .../npcs/containers/ContainerNPCFollower.java | 39 +- .../containers/ContainerNPCFollowerHire.java | 53 +- .../containers/ContainerNPCFollowerSetup.java | 82 +- .../npcs/containers/ContainerNPCInv.java | 34 +- .../npcs/containers/ContainerNPCTrader.java | 150 +- .../containers/ContainerNPCTraderSetup.java | 51 +- .../containers/ContainerNpcInterface.java | 41 +- .../containers/ContainerNpcItemGiver.java | 38 +- .../containers/ContainerNpcQuestReward.java | 43 +- .../containers/ContainerNpcQuestTypeItem.java | 43 +- .../noppes/npcs/containers/InventoryNPC.java | 106 +- .../npcs/containers/InventoryNpcTrader.java | 98 +- .../npcs/containers/SlotCompanionArmor.java | 40 +- .../npcs/containers/SlotCompanionWeapon.java | 20 +- .../noppes/npcs/containers/SlotNPCArmor.java | 26 +- .../npcs/containers/SlotNpcBankCurrency.java | 28 +- .../containers/SlotNpcMercenaryCurrency.java | 32 +- .../npcs/containers/SlotNpcTraderItems.java | 32 +- .../noppes/npcs/containers/SlotValid.java | 24 +- .../npcs/controllers/AnimationController.java | 114 +- .../npcs/controllers/BankController.java | 247 +- .../npcs/controllers/ChunkController.java | 132 +- .../controllers/CustomEffectController.java | 11 +- .../npcs/controllers/CustomGuiController.java | 26 +- .../npcs/controllers/DialogController.java | 513 ++-- .../npcs/controllers/FactionController.java | 374 +-- .../controllers/GlobalDataController.java | 76 +- .../controllers/LinkedItemController.java | 83 +- .../npcs/controllers/LinkedNpcController.java | 309 +-- .../npcs/controllers/MagicController.java | 26 +- .../npcs/controllers/PartyController.java | 94 +- .../controllers/PlayerDataController.java | 984 ++++--- .../controllers/PlayerQuestController.java | 219 +- .../npcs/controllers/QuestController.java | 395 ++- .../npcs/controllers/RecipeController.java | 417 ++- .../npcs/controllers/ScriptContainer.java | 65 +- .../npcs/controllers/ScriptController.java | 485 ++-- .../npcs/controllers/ScriptEntityData.java | 29 +- .../controllers/ServerCloneController.java | 557 ++-- .../controllers/ServerTagMapController.java | 131 +- .../npcs/controllers/SpawnController.java | 339 ++- .../npcs/controllers/TagController.java | 366 ++- .../npcs/controllers/TransportController.java | 478 ++-- .../npcs/controllers/data/Animation.java | 24 +- .../npcs/controllers/data/AnimationData.java | 12 +- .../npcs/controllers/data/Availability.java | 665 ++--- .../noppes/npcs/controllers/data/Bank.java | 91 +- .../npcs/controllers/data/BankData.java | 162 +- .../npcs/controllers/data/CustomEffect.java | 6 +- .../npcs/controllers/data/DataScript.java | 461 ++-- .../npcs/controllers/data/DataTransform.java | 353 +-- .../noppes/npcs/controllers/data/Dialog.java | 978 +++---- .../npcs/controllers/data/DialogCategory.java | 73 +- .../npcs/controllers/data/DialogOption.java | 98 +- .../npcs/controllers/data/EffectScript.java | 15 +- .../noppes/npcs/controllers/data/Faction.java | 273 +- .../npcs/controllers/data/FactionOptions.java | 102 +- .../controllers/data/ForgeDataScript.java | 10 +- .../noppes/npcs/controllers/data/Frame.java | 34 +- .../npcs/controllers/data/FramePart.java | 390 +-- .../controllers/data/GlobalNPCDataScript.java | 73 +- .../npcs/controllers/data/HitboxData.java | 12 +- .../controllers/data/IScriptBlockHandler.java | 2 +- .../npcs/controllers/data/InnDoorData.java | 6 +- .../noppes/npcs/controllers/data/Line.java | 109 +- .../noppes/npcs/controllers/data/Lines.java | 112 +- .../npcs/controllers/data/LinkedItem.java | 6 +- .../controllers/data/LinkedItemScript.java | 14 +- .../noppes/npcs/controllers/data/Magic.java | 15 +- .../npcs/controllers/data/MagicCycle.java | 4 +- .../npcs/controllers/data/MagicData.java | 2 +- .../npcs/controllers/data/MarkData.java | 124 +- .../noppes/npcs/controllers/data/Party.java | 49 +- .../npcs/controllers/data/PartyOptions.java | 211 +- .../npcs/controllers/data/PlayerBankData.java | 90 +- .../npcs/controllers/data/PlayerData.java | 423 ++- .../controllers/data/PlayerDataScript.java | 75 +- .../controllers/data/PlayerDialogData.java | 67 +- .../npcs/controllers/data/PlayerEffect.java | 4 +- .../controllers/data/PlayerEffectData.java | 2 +- .../controllers/data/PlayerFactionData.java | 151 +- .../controllers/data/PlayerItemGiverData.java | 84 +- .../npcs/controllers/data/PlayerMail.java | 369 ++- .../npcs/controllers/data/PlayerMailData.java | 152 +- .../controllers/data/PlayerQuestData.java | 351 ++- .../controllers/data/PlayerTransportData.java | 93 +- .../npcs/controllers/data/ProfileOptions.java | 81 +- .../noppes/npcs/controllers/data/Quest.java | 409 +-- .../npcs/controllers/data/QuestCategory.java | 37 +- .../npcs/controllers/data/QuestData.java | 37 +- .../npcs/controllers/data/RecipeAnvil.java | 10 +- .../controllers/data/RecipeCarpentry.java | 217 +- .../npcs/controllers/data/RecipesDefault.java | 313 +-- .../npcs/controllers/data/SkinOverlay.java | 12 + .../npcs/controllers/data/SpawnData.java | 296 +-- .../noppes/npcs/controllers/data/Tag.java | 122 +- .../noppes/npcs/controllers/data/TagMap.java | 171 +- .../npcs/controllers/data/TintData.java | 8 +- .../controllers/data/TransportCategory.java | 148 +- .../controllers/data/TransportLocation.java | 164 +- .../npcs/enchants/EnchantConfusion.java | 30 +- .../noppes/npcs/enchants/EnchantDamage.java | 32 +- .../noppes/npcs/enchants/EnchantInfinite.java | 32 +- .../npcs/enchants/EnchantInterface.java | 81 +- .../noppes/npcs/enchants/EnchantPoison.java | 28 +- .../noppes/npcs/entity/EntityChairMount.java | 82 +- .../noppes/npcs/entity/EntityCustomNpc.java | 130 +- .../noppes/npcs/entity/EntityDialogNpc.java | 38 +- .../noppes/npcs/entity/EntityFakeLiving.java | 8 +- .../npcs/entity/EntityMagicProjectile.java | 44 +- .../noppes/npcs/entity/EntityNPCFlying.java | 19 +- .../noppes/npcs/entity/EntityNPCGolem.java | 58 +- .../npcs/entity/EntityNPCInterface.java | 4 +- .../noppes/npcs/entity/EntityNpcCrystal.java | 49 +- .../noppes/npcs/entity/EntityNpcDragon.java | 122 +- .../noppes/npcs/entity/EntityNpcPony.java | 43 +- .../noppes/npcs/entity/EntityNpcSlime.java | 63 +- .../noppes/npcs/entity/EntityProjectile.java | 1008 ++++--- .../npcs/entity/data/DataSkinOverlays.java | 12 +- .../noppes/npcs/entity/data/DataTimers.java | 48 +- .../noppes/npcs/entity/data/ModelData.java | 70 +- .../npcs/entity/data/ModelDataShared.java | 683 ++--- .../npcs/entity/data/ModelPartData.java | 115 +- .../noppes/npcs/entity/data/ModelRotate.java | 140 +- .../npcs/entity/data/ModelRotatePart.java | 74 +- .../noppes/npcs/entity/data/ModelScale.java | 2 +- .../npcs/entity/data/ModelScalePart.java | 72 +- .../npcs/entity/old/EntityNPCDwarfFemale.java | 38 +- .../npcs/entity/old/EntityNPCDwarfMale.java | 36 +- .../npcs/entity/old/EntityNPCElfFemale.java | 44 +- .../npcs/entity/old/EntityNPCElfMale.java | 44 +- .../npcs/entity/old/EntityNPCEnderman.java | 57 +- .../npcs/entity/old/EntityNPCFurryFemale.java | 52 +- .../npcs/entity/old/EntityNPCFurryMale.java | 41 +- .../npcs/entity/old/EntityNPCHumanFemale.java | 38 +- .../npcs/entity/old/EntityNPCHumanMale.java | 34 +- .../npcs/entity/old/EntityNPCOrcFemale.java | 42 +- .../npcs/entity/old/EntityNPCOrcMale.java | 40 +- .../npcs/entity/old/EntityNPCVillager.java | 30 +- .../npcs/entity/old/EntityNpcEnderchibi.java | 36 +- .../entity/old/EntityNpcMonsterFemale.java | 40 +- .../npcs/entity/old/EntityNpcMonsterMale.java | 28 +- .../npcs/entity/old/EntityNpcNagaFemale.java | 44 +- .../npcs/entity/old/EntityNpcNagaMale.java | 33 +- .../npcs/entity/old/EntityNpcSkeleton.java | 29 +- .../java/noppes/npcs/items/ItemBattleAxe.java | 14 +- .../noppes/npcs/items/ItemBroadSword.java | 16 +- .../java/noppes/npcs/items/ItemBullet.java | 22 +- src/main/java/noppes/npcs/items/ItemClaw.java | 18 +- .../java/noppes/npcs/items/ItemCrossbow.java | 137 +- .../noppes/npcs/items/ItemCustomizable.java | 37 +- .../java/noppes/npcs/items/ItemDagger.java | 14 +- .../noppes/npcs/items/ItemDaggerReversed.java | 26 +- .../noppes/npcs/items/ItemElementalStaff.java | 46 +- .../java/noppes/npcs/items/ItemExcalibur.java | 60 +- .../java/noppes/npcs/items/ItemGlaive.java | 14 +- src/main/java/noppes/npcs/items/ItemGun.java | 199 +- .../noppes/npcs/items/ItemGunChainsaw.java | 33 +- .../java/noppes/npcs/items/ItemKunai.java | 94 +- .../noppes/npcs/items/ItemKunaiReversed.java | 24 +- .../java/noppes/npcs/items/ItemLeafBlade.java | 14 +- .../java/noppes/npcs/items/ItemLinked.java | 8 +- .../java/noppes/npcs/items/ItemMoneyBag.java | 37 +- .../java/noppes/npcs/items/ItemMounter.java | 22 +- .../java/noppes/npcs/items/ItemMusic.java | 49 +- .../noppes/npcs/items/ItemMusicBanjo.java | 10 +- .../noppes/npcs/items/ItemMusicClarinet.java | 26 +- .../noppes/npcs/items/ItemMusicOracina.java | 30 +- .../noppes/npcs/items/ItemMusicViolin.java | 31 +- .../java/noppes/npcs/items/ItemMusket.java | 127 +- .../java/noppes/npcs/items/ItemNpcArmor.java | 36 +- .../npcs/items/ItemNpcArmorColorable.java | 94 +- .../java/noppes/npcs/items/ItemNpcBlock.java | 19 +- .../java/noppes/npcs/items/ItemNpcCloner.java | 24 +- .../noppes/npcs/items/ItemNpcColored.java | 8 +- .../noppes/npcs/items/ItemNpcInterface.java | 62 +- .../noppes/npcs/items/ItemNpcMovingPath.java | 83 +- .../noppes/npcs/items/ItemNpcScripter.java | 22 +- .../java/noppes/npcs/items/ItemNpcTool.java | 63 +- .../java/noppes/npcs/items/ItemNpcWand.java | 65 +- .../npcs/items/ItemNpcWeaponInterface.java | 35 +- src/main/java/noppes/npcs/items/ItemOrb.java | 30 +- .../noppes/npcs/items/ItemPlaceholder.java | 23 +- .../npcs/items/ItemRenderInterface.java | 2 +- .../noppes/npcs/items/ItemRotatedShield.java | 18 +- .../java/noppes/npcs/items/ItemScripted.java | 10 +- .../java/noppes/npcs/items/ItemScythe.java | 14 +- .../java/noppes/npcs/items/ItemShield.java | 39 +- .../java/noppes/npcs/items/ItemSkirt.java | 54 +- .../java/noppes/npcs/items/ItemSlingshot.java | 95 +- .../noppes/npcs/items/ItemSoulstoneEmpty.java | 144 +- .../npcs/items/ItemSoulstoneFilled.java | 133 +- .../java/noppes/npcs/items/ItemSpear.java | 16 +- .../java/noppes/npcs/items/ItemStaff.java | 314 +-- .../noppes/npcs/items/ItemTeleporter.java | 60 +- .../npcs/items/ItemThrowingShuriken.java | 23 +- .../noppes/npcs/items/ItemThrowingWeapon.java | 106 +- src/main/java/noppes/npcs/items/ItemWand.java | 26 +- .../java/noppes/npcs/items/ItemWarhammer.java | 14 +- .../noppes/npcs/items/MoneyBagContents.java | 88 +- .../npcs/mixin/CustomNPCsMixinPlugin.java | 6 +- .../npcs/mixin/MixinEntityRenderer.java | 5 +- .../noppes/npcs/mixin/MixinItemRenderer.java | 46 +- .../noppes/npcs/mixin/MixinItemStack.java | 3 +- .../noppes/npcs/mixin/MixinModelRenderer.java | 134 +- .../java/noppes/npcs/quests/QuestDialog.java | 364 ++- .../noppes/npcs/quests/QuestInterface.java | 37 +- .../java/noppes/npcs/quests/QuestItem.java | 443 +-- .../java/noppes/npcs/quests/QuestKill.java | 379 ++- .../noppes/npcs/quests/QuestLocation.java | 343 +-- .../java/noppes/npcs/quests/QuestManual.java | 205 +- src/main/java/noppes/npcs/roles/JobBard.java | 198 +- .../noppes/npcs/roles/JobChunkLoader.java | 134 +- .../noppes/npcs/roles/JobConversation.java | 397 +-- .../java/noppes/npcs/roles/JobFollower.java | 120 +- src/main/java/noppes/npcs/roles/JobGuard.java | 96 +- .../java/noppes/npcs/roles/JobHealer.java | 103 +- .../java/noppes/npcs/roles/JobInterface.java | 74 +- .../java/noppes/npcs/roles/JobItemGiver.java | 475 ++-- .../java/noppes/npcs/roles/JobSpawner.java | 757 +++--- src/main/java/noppes/npcs/roles/RoleBank.java | 56 +- .../java/noppes/npcs/roles/RoleCompanion.java | 1065 ++++---- .../java/noppes/npcs/roles/RoleFollower.java | 316 +-- .../java/noppes/npcs/roles/RoleInnkeeper.java | 86 +- .../java/noppes/npcs/roles/RoleInterface.java | 70 +- .../java/noppes/npcs/roles/RolePostman.java | 74 +- .../java/noppes/npcs/roles/RoleTrader.java | 148 +- .../noppes/npcs/roles/RoleTransporter.java | 165 +- .../npcs/roles/companion/CompanionFarmer.java | 41 +- .../roles/companion/CompanionFoodStats.java | 73 +- .../npcs/roles/companion/CompanionGuard.java | 56 +- .../companion/CompanionJobInterface.java | 19 +- .../npcs/roles/companion/CompanionTrader.java | 28 +- .../npcs/scripted/BlockScriptedWrapper.java | 117 +- .../java/noppes/npcs/scripted/NpcAPI.java | 144 +- .../java/noppes/npcs/scripted/ScreenSize.java | 4 +- .../noppes/npcs/scripted/ScriptBlock.java | 48 +- .../noppes/npcs/scripted/ScriptBlockPos.java | 10 +- .../noppes/npcs/scripted/ScriptContainer.java | 6 +- .../java/noppes/npcs/scripted/ScriptNbt.java | 42 +- .../noppes/npcs/scripted/ScriptParticle.java | 213 +- .../scripted/ScriptPixelmonPlayerData.java | 33 +- .../noppes/npcs/scripted/ScriptSound.java | 14 +- .../npcs/scripted/ScriptTileEntity.java | 25 +- .../noppes/npcs/scripted/ScriptWorld.java | 2368 ++++++++--------- .../scripted/constants/AnimationType.java | 12 +- .../npcs/scripted/constants/EntityType.java | 16 +- .../npcs/scripted/constants/JobType.java | 18 +- .../npcs/scripted/constants/RoleType.java | 14 +- .../npcs/scripted/entity/ScriptAnimal.java | 82 +- .../npcs/scripted/entity/ScriptDBCPlayer.java | 265 +- .../npcs/scripted/entity/ScriptEntity.java | 1665 ++++++------ .../scripted/entity/ScriptEntityItem.java | 4 +- .../npcs/scripted/entity/ScriptLiving.java | 275 +- .../scripted/entity/ScriptLivingBase.java | 592 ++--- .../npcs/scripted/entity/ScriptMonster.java | 24 +- .../npcs/scripted/entity/ScriptNpc.java | 2365 ++++++++-------- .../npcs/scripted/entity/ScriptPixelmon.java | 451 ++-- .../npcs/scripted/entity/ScriptPlayer.java | 1310 ++++----- .../scripted/entity/ScriptProjectile.java | 16 +- .../npcs/scripted/entity/ScriptVillager.java | 19 +- .../npcs/scripted/event/AnimationEvent.java | 2 +- .../npcs/scripted/event/BlockEvent.java | 37 +- .../npcs/scripted/event/CustomGuiEvent.java | 2 +- .../npcs/scripted/event/CustomNPCsEvent.java | 8 +- .../npcs/scripted/event/DialogEvent.java | 4 +- .../npcs/scripted/event/FactionEvent.java | 2 +- .../npcs/scripted/event/ForgeEvent.java | 2 +- .../noppes/npcs/scripted/event/ItemEvent.java | 10 +- .../noppes/npcs/scripted/event/NpcEvent.java | 62 +- .../npcs/scripted/event/PlayerEvent.java | 18 +- .../npcs/scripted/event/ProjectileEvent.java | 6 +- .../npcs/scripted/gui/ScriptGuiButton.java | 4 +- .../npcs/scripted/gui/ScriptGuiComponent.java | 10 +- .../npcs/scripted/gui/ScriptGuiLabel.java | 6 +- .../npcs/scripted/gui/ScriptGuiLine.java | 44 +- .../npcs/scripted/gui/ScriptGuiScroll.java | 4 +- .../npcs/scripted/item/ScriptCustomItem.java | 32 +- .../scripted/item/ScriptCustomizableItem.java | 14 +- .../npcs/scripted/item/ScriptItemBook.java | 10 +- .../npcs/scripted/item/ScriptItemStack.java | 646 ++--- .../npcs/scripted/item/ScriptLinkedItem.java | 7 +- .../npcs/scripted/overlay/ScriptOverlay.java | 36 +- .../overlay/ScriptOverlayComponent.java | 10 +- .../scripted/overlay/ScriptOverlayLabel.java | 6 +- .../scripted/overlay/ScriptOverlayLine.java | 44 +- .../npcs/scripted/roles/ScriptJobBard.java | 133 +- .../scripted/roles/ScriptJobConversation.java | 23 +- .../scripted/roles/ScriptJobFollower.java | 59 +- .../npcs/scripted/roles/ScriptJobGuard.java | 62 +- .../npcs/scripted/roles/ScriptJobHealer.java | 57 +- .../scripted/roles/ScriptJobInterface.java | 47 +- .../scripted/roles/ScriptJobItemGiver.java | 148 +- .../npcs/scripted/roles/ScriptJobSpawner.java | 138 +- .../npcs/scripted/roles/ScriptRoleBank.java | 14 +- .../scripted/roles/ScriptRoleCompanion.java | 14 +- .../scripted/roles/ScriptRoleFollower.java | 181 +- .../scripted/roles/ScriptRoleInterface.java | 32 +- .../scripted/roles/ScriptRoleMailman.java | 14 +- .../npcs/scripted/roles/ScriptRoleTrader.java | 199 +- .../scripted/roles/ScriptRoleTransporter.java | 54 +- .../scripted/scoreboard/ScriptScoreboard.java | 334 +-- .../scoreboard/ScriptScoreboardObjective.java | 88 +- .../scoreboard/ScriptScoreboardTeam.java | 175 +- .../java/noppes/npcs/util/CacheHashMap.java | 7 +- .../noppes/npcs/util/CustomNPCsThreader.java | 2 +- .../java/noppes/npcs/util/GameProfileAlt.java | 29 +- .../noppes/npcs/util/IProjectileCallback.java | 4 +- .../java/noppes/npcs/util/JsonException.java | 8 +- .../java/noppes/npcs/util/MillisTimer.java | 38 +- .../java/noppes/npcs/util/NBTJsonUtil.java | 523 ++-- src/main/java/noppes/npcs/util/ValueUtil.java | 74 +- src/main/java/noppes/npcs/util/Vec3NPC.java | 3 +- src/main/java/overview.html | 172 +- .../tconstruct/client/tabs/AbstractTab.java | 96 +- .../client/tabs/InventoryTabCustomNpc.java | 58 +- .../client/tabs/InventoryTabVanilla.java | 20 +- .../tconstruct/client/tabs/TabRegistry.java | 152 +- .../resources/assets/customnpcs/sounds.json | 418 ++- .../textures/items/npcEarthElement.png.mcmeta | 59 +- .../textures/items/npcIceSpell.png.mcmeta | 94 +- .../textures/items/npcNatureSpell.png.mcmeta | 4 +- 1179 files changed, 59847 insertions(+), 61583 deletions(-) diff --git a/src/main/java/foxz/command/CmdClone.java b/src/main/java/foxz/command/CmdClone.java index 9a6cd1923..f585c886c 100644 --- a/src/main/java/foxz/command/CmdClone.java +++ b/src/main/java/foxz/command/CmdClone.java @@ -21,8 +21,8 @@ import noppes.npcs.entity.EntityNPCInterface; import java.util.List; @Command( - name = "clone", - desc = "Clone operation (server side)" + name = "clone", + desc = "Clone operation (server side)" ) public class CmdClone extends ChMcLogger { @@ -31,17 +31,16 @@ public class CmdClone extends ChMcLogger { } @SubCommand( - desc = "Add NPC(s) to clone storage", - usage = " [clonedname]", - permissions = {OpOnly.class ,PlayerOnly.class, ParamCheck.class} + desc = "Add NPC(s) to clone storage", + usage = " [clonedname]", + permissions = {OpOnly.class, PlayerOnly.class, ParamCheck.class} ) public Boolean add(String[] args) { EntityPlayerMP player = (EntityPlayerMP) pcParam; int tab = 0; - try{ - tab = Integer.parseInt(args[1]); - } - catch(NumberFormatException ex){ + try { + tab = Integer.parseInt(args[1]); + } catch (NumberFormatException ex) { } List list = Utils.getNearbeEntityFromPlayer(EntityNPCInterface.class, player, 80); @@ -51,24 +50,23 @@ public class CmdClone extends ChMcLogger { if (args.length > 2) { name = args[2]; } - NBTTagCompound compound = new NBTTagCompound(); - if(!npc.writeToNBTOptional(compound)) - return false; - ServerCloneController.Instance.addClone(compound, name, tab); - return true; + NBTTagCompound compound = new NBTTagCompound(); + if (!npc.writeToNBTOptional(compound)) + return false; + ServerCloneController.Instance.addClone(compound, name, tab); + return true; } } return true; } - @SubCommand(desc = "List NPC from clone storage", usage = "", permissions={OpOnly.class ,ParamCheck.class}) + @SubCommand(desc = "List NPC from clone storage", usage = "", permissions = {OpOnly.class, ParamCheck.class}) public Boolean list(String[] args) { sendmessage("--- Stored NPCs --- (server side)"); int tab = 0; - try{ - tab = Integer.parseInt(args[0]); - } - catch(NumberFormatException ex){ + try { + tab = Integer.parseInt(args[0]); + } catch (NumberFormatException ex) { } for (String name : ServerCloneController.Instance.getClones(tab)) { @@ -78,205 +76,201 @@ public class CmdClone extends ChMcLogger { return true; } - @SubCommand(desc = "Remove NPC from clone storage", usage = " ", permissions={OpOnly.class ,ParamCheck.class}) + @SubCommand(desc = "Remove NPC from clone storage", usage = " ", permissions = {OpOnly.class, ParamCheck.class}) public Boolean del(String[] args) { String nametodel = args[0]; int tab = 0; - try{ - tab = Integer.parseInt(args[1]); - } - catch(NumberFormatException ex){ + try { + tab = Integer.parseInt(args[1]); + } catch (NumberFormatException ex) { } boolean deleted = false; - for(String name : ServerCloneController.Instance.getClones(tab)){ - if(nametodel.equalsIgnoreCase(name)){ - ServerCloneController.Instance.removeClone(name, tab); - deleted = true; - break; - } + for (String name : ServerCloneController.Instance.getClones(tab)) { + if (nametodel.equalsIgnoreCase(name)) { + ServerCloneController.Instance.removeClone(name, tab); + deleted = true; + break; + } } if (!ServerCloneController.Instance.removeClone(nametodel, tab)) { sendmessage(String.format("Npc '%s' wasn't found", nametodel)); return false; } - ; + ; return true; } @SubCommand( - desc = "Spawn cloned NPC", - usage = " [[world:]x,y,z]] [newname]", - permissions={OpOnly.class ,ParamCheck.class}) + desc = "Spawn cloned NPC", + usage = " [[world:]x,y,z]] [newname]", + permissions = {OpOnly.class, ParamCheck.class}) public boolean spawn(String[] args) { String name = args[0].replaceAll("%", " "); // if name of npc separed by space, user must use % in place of space int tab = 0; - try{ - tab = Integer.parseInt(args[1]); - } - catch(NumberFormatException ex){ + try { + tab = Integer.parseInt(args[1]); + } catch (NumberFormatException ex) { } - String newname=null; + String newname = null; NBTTagCompound compound = ServerCloneController.Instance.getCloneData(this.pcParam, name, tab); - if(compound == null){ - sendmessage("Unknown npc"); - return false; + if (compound == null) { + sendmessage("Unknown npc"); + return false; } World world = pcParam.getEntityWorld(); double posX = pcParam.getPlayerCoordinates().posX; double posY = pcParam.getPlayerCoordinates().posY; double posZ = pcParam.getPlayerCoordinates().posZ; - if(args.length > 2){ - String location = args[2]; - String[] par; - if (location.contains(":")){ - par = location.split(":"); - location = par[1]; - world = Utils.getWorld(par[0]); - if (world == null){ - sendmessage (String.format("'%s' is an unknown world",par[0])); - return false; - } - } + if (args.length > 2) { + String location = args[2]; + String[] par; + if (location.contains(":")) { + par = location.split(":"); + location = par[1]; + world = Utils.getWorld(par[0]); + if (world == null) { + sendmessage(String.format("'%s' is an unknown world", par[0])); + return false; + } + } - if (location.contains(",")){ - par = location.split(","); - if (par.length != 3){ - sendmessage("Location need be x,y,z"); - return false; - } - try{ - posX = CommandBase.func_110666_a(pcParam, posX, par[0]); - posY = CommandBase.func_110665_a(pcParam, posY, par[1].trim(), 0, 0); - posZ = CommandBase.func_110666_a(pcParam, posZ, par[2]); - } catch(NumberFormatException ex){ - sendmessage("Location should be in numbers"); - return false; - } - if (args.length > 3){ - newname = args[3]; - } - } else { - newname = location; - } + if (location.contains(",")) { + par = location.split(","); + if (par.length != 3) { + sendmessage("Location need be x,y,z"); + return false; + } + try { + posX = CommandBase.func_110666_a(pcParam, posX, par[0]); + posY = CommandBase.func_110665_a(pcParam, posY, par[1].trim(), 0, 0); + posZ = CommandBase.func_110666_a(pcParam, posZ, par[2]); + } catch (NumberFormatException ex) { + sendmessage("Location should be in numbers"); + return false; + } + if (args.length > 3) { + newname = args[3]; + } + } else { + newname = location; + } } - if (posX == 0 && posY == 0 && posZ == 0){//incase it was called from the console and not pos was given - sendmessage ("Location needed"); + if (posX == 0 && posY == 0 && posZ == 0) {//incase it was called from the console and not pos was given + sendmessage("Location needed"); return false; } Entity entity = EntityList.createEntityFromNBT(compound, world); entity.setPosition(posX + 0.5, posY + 1, posZ + 0.5); - if(entity instanceof EntityNPCInterface){ - EntityNPCInterface npc = (EntityNPCInterface) entity; - npc.ais.startPos = new int[]{MathHelper.floor_double(posX), MathHelper.floor_double(posY), MathHelper.floor_double(posZ)}; - if(newname != null && !newname.isEmpty()) - npc.display.name = newname.replaceAll("%", " "); // like name, newname must use % in place of space to keep a logical way + if (entity instanceof EntityNPCInterface) { + EntityNPCInterface npc = (EntityNPCInterface) entity; + npc.ais.startPos = new int[]{MathHelper.floor_double(posX), MathHelper.floor_double(posY), MathHelper.floor_double(posZ)}; + if (newname != null && !newname.isEmpty()) + npc.display.name = newname.replaceAll("%", " "); // like name, newname must use % in place of space to keep a logical way } world.spawnEntityInWorld(entity); return true; } @SubCommand( - desc = "Spawn cloned NPC", - usage = " [[world:]x,y,z]] [newname]", - permissions={OpOnly.class ,ParamCheck.class}) + desc = "Spawn cloned NPC", + usage = " [[world:]x,y,z]] [newname]", + permissions = {OpOnly.class, ParamCheck.class}) public boolean grid(String[] args) { String name = args[0].replaceAll("%", " "); // if name of npc separed by space, user must use % in place of space int tab = 0; - try{ - tab = Integer.parseInt(args[1]); - } - catch(NumberFormatException ex){ + try { + tab = Integer.parseInt(args[1]); + } catch (NumberFormatException ex) { } int width, height; - try{ - width = Integer.parseInt(args[2]); - height = Integer.parseInt(args[3]); - } - catch(NumberFormatException ex){ - sendmessage("lenght or width wasnt a number"); - return false; + try { + width = Integer.parseInt(args[2]); + height = Integer.parseInt(args[3]); + } catch (NumberFormatException ex) { + sendmessage("lenght or width wasnt a number"); + return false; } - String newname=null; + String newname = null; NBTTagCompound compound = ServerCloneController.Instance.getCloneData(this.pcParam, name, tab); - if(compound == null){ - sendmessage("Unknown npc"); - return false; + if (compound == null) { + sendmessage("Unknown npc"); + return false; } World world = pcParam.getEntityWorld(); double posX = pcParam.getPlayerCoordinates().posX; double posY = pcParam.getPlayerCoordinates().posY; double posZ = pcParam.getPlayerCoordinates().posZ; - if(args.length > 4){ - String location = args[4]; - String[] par; - if (location.contains(":")){ - par = location.split(":"); - location = par[1]; - world = Utils.getWorld(par[0]); - if (world == null){ - sendmessage (String.format("'%s' is an unknown world",par[0])); - return false; - } - } + if (args.length > 4) { + String location = args[4]; + String[] par; + if (location.contains(":")) { + par = location.split(":"); + location = par[1]; + world = Utils.getWorld(par[0]); + if (world == null) { + sendmessage(String.format("'%s' is an unknown world", par[0])); + return false; + } + } - if (location.contains(",")){ - par = location.split(","); - if (par.length != 3){ - sendmessage("Location need be x,y,z"); - return false; - } - try{ - posX = CommandBase.func_110666_a(pcParam, posX, par[0]); - posY = CommandBase.func_110665_a(pcParam, posY, par[1].trim(), 0, 0); - posZ = CommandBase.func_110666_a(pcParam, posZ, par[2]); - } catch(NumberFormatException ex){ - sendmessage("Location should be in numbers"); - return false; - } - if (args.length > 5){ - newname = args[5]; - } - } else { - newname = location; - } + if (location.contains(",")) { + par = location.split(","); + if (par.length != 3) { + sendmessage("Location need be x,y,z"); + return false; + } + try { + posX = CommandBase.func_110666_a(pcParam, posX, par[0]); + posY = CommandBase.func_110665_a(pcParam, posY, par[1].trim(), 0, 0); + posZ = CommandBase.func_110666_a(pcParam, posZ, par[2]); + } catch (NumberFormatException ex) { + sendmessage("Location should be in numbers"); + return false; + } + if (args.length > 5) { + newname = args[5]; + } + } else { + newname = location; + } } - if (posX == 0 && posY == 0 && posZ == 0){//incase it was called from the console and not pos was given - sendmessage ("Location needed"); + if (posX == 0 && posY == 0 && posZ == 0) {//incase it was called from the console and not pos was given + sendmessage("Location needed"); return false; } - for(int x = 0; x < width; x++){ - for(int z = 0; z < height; z++){ + for (int x = 0; x < width; x++) { + for (int z = 0; z < height; z++) { Entity entity = EntityList.createEntityFromNBT(compound, world); int xx = MathHelper.floor_double(posX) + x; int yy = Math.max(MathHelper.floor_double(posY) - 2, 1); int zz = MathHelper.floor_double(posZ) + z; - for(int y = 0; y < 10; y++){ - Block b = world.getBlock(xx, yy + y, zz); - Block b2 = world.getBlock(xx, yy + y + 1, zz); - if(b != null && (b2 == null || b2.getCollisionBoundingBoxFromPool(world, xx, yy + y + 1, zz) == null)){ - yy += y; - break; - } + for (int y = 0; y < 10; y++) { + Block b = world.getBlock(xx, yy + y, zz); + Block b2 = world.getBlock(xx, yy + y + 1, zz); + if (b != null && (b2 == null || b2.getCollisionBoundingBoxFromPool(world, xx, yy + y + 1, zz) == null)) { + yy += y; + break; + } } entity.setPosition(posX + 0.5 + x, yy + 1, posZ + 0.5 + z); - if(entity instanceof EntityNPCInterface){ - EntityNPCInterface npc = (EntityNPCInterface) entity; - npc.ais.startPos = new int[]{xx, yy, zz}; - if(newname != null && !newname.isEmpty()) - npc.display.name = newname.replaceAll("%", " "); // like name, newname must use % in place of space to keep a logical way + if (entity instanceof EntityNPCInterface) { + EntityNPCInterface npc = (EntityNPCInterface) entity; + npc.ais.startPos = new int[]{xx, yy, zz}; + if (newname != null && !newname.isEmpty()) + npc.display.name = newname.replaceAll("%", " "); // like name, newname must use % in place of space to keep a logical way } world.spawnEntityInWorld(entity); } diff --git a/src/main/java/foxz/command/CmdConfig.java b/src/main/java/foxz/command/CmdConfig.java index 081624148..4de68f19d 100644 --- a/src/main/java/foxz/command/CmdConfig.java +++ b/src/main/java/foxz/command/CmdConfig.java @@ -22,193 +22,185 @@ import java.util.Arrays; import java.util.Set; @Command( - name="config", - desc="Some config things you can set ", - usage="" + name = "config", + desc = "Some config things you can set ", + usage = "" ) public class CmdConfig extends ChMcLogger { public CmdConfig(Object sender) { - super (sender); + super(sender); } @SubCommand( - desc="Disable/Enable the natural leaves decay", - usage="", - permissions={OpOnly.class}, - hasEmptyCall = true + desc = "Disable/Enable the natural leaves decay", + usage = "", + permissions = {OpOnly.class}, + hasEmptyCall = true ) - public boolean leavesdecay(String[] args){ - if(args.length == 0){ - sendmessage("LeavesDecay: " + ConfigMain.LeavesDecayEnabled); - } - else{ - ConfigMain.LeavesDecayEnabled = Boolean.parseBoolean(args[0]); - ConfigMain.LeavesDecayEnabledProperty.set(ConfigMain.LeavesDecayEnabled); - if(ConfigMain.config.hasChanged()){ - ConfigMain.config.save(); - } + public boolean leavesdecay(String[] args) { + if (args.length == 0) { + sendmessage("LeavesDecay: " + ConfigMain.LeavesDecayEnabled); + } else { + ConfigMain.LeavesDecayEnabled = Boolean.parseBoolean(args[0]); + ConfigMain.LeavesDecayEnabledProperty.set(ConfigMain.LeavesDecayEnabled); + if (ConfigMain.config.hasChanged()) { + ConfigMain.config.save(); + } Set names = Block.blockRegistry.getKeys(); - for(String name : names){ - Block block = (Block) Block.blockRegistry.getObject(name); - if(block instanceof BlockLeavesBase){ - block.setTickRandomly(ConfigMain.LeavesDecayEnabled); - } + for (String name : names) { + Block block = (Block) Block.blockRegistry.getObject(name); + if (block instanceof BlockLeavesBase) { + block.setTickRandomly(ConfigMain.LeavesDecayEnabled); + } } sendmessage("LeavesDecay is now " + ConfigMain.LeavesDecayEnabled); - } + } return true; } @SubCommand( - desc="Disable/Enable the vines growing", - usage="", - permissions={OpOnly.class}, - hasEmptyCall = true + desc = "Disable/Enable the vines growing", + usage = "", + permissions = {OpOnly.class}, + hasEmptyCall = true ) - public boolean vinegrowth(String[] args){ - if(args.length == 0){ - sendmessage("VineGrowth: " + ConfigMain.VineGrowthEnabled); - } - else{ - ConfigMain.VineGrowthEnabled = Boolean.parseBoolean(args[0]); - ConfigMain.VineGrowthEnabledProperty.set(ConfigMain.VineGrowthEnabled); - if(ConfigMain.config.hasChanged()){ - ConfigMain.config.save(); - } + public boolean vinegrowth(String[] args) { + if (args.length == 0) { + sendmessage("VineGrowth: " + ConfigMain.VineGrowthEnabled); + } else { + ConfigMain.VineGrowthEnabled = Boolean.parseBoolean(args[0]); + ConfigMain.VineGrowthEnabledProperty.set(ConfigMain.VineGrowthEnabled); + if (ConfigMain.config.hasChanged()) { + ConfigMain.config.save(); + } Set names = Block.blockRegistry.getKeys(); - for(String name : names){ - Block block = (Block) Block.blockRegistry.getObject(name); - if(block instanceof BlockVine){ - block.setTickRandomly(ConfigMain.VineGrowthEnabled); - } + for (String name : names) { + Block block = (Block) Block.blockRegistry.getObject(name); + if (block instanceof BlockVine) { + block.setTickRandomly(ConfigMain.VineGrowthEnabled); + } } sendmessage("VineGrowth is now " + ConfigMain.VineGrowthEnabled); - } + } return true; } @SubCommand( - desc="Disable/Enable the ice melting", - usage="", - permissions={OpOnly.class}, - hasEmptyCall = true + desc = "Disable/Enable the ice melting", + usage = "", + permissions = {OpOnly.class}, + hasEmptyCall = true ) - public boolean icemelts(String[] args){ - if(args.length == 0){ - sendmessage("IceMelts: " + ConfigMain.IceMeltsEnabled); - } - else{ - ConfigMain.IceMeltsEnabled = Boolean.parseBoolean(args[0]); - ConfigMain.IceMeltsEnabledProperty.set(ConfigMain.IceMeltsEnabled); - if(ConfigMain.config.hasChanged()){ - ConfigMain.config.save(); - } + public boolean icemelts(String[] args) { + if (args.length == 0) { + sendmessage("IceMelts: " + ConfigMain.IceMeltsEnabled); + } else { + ConfigMain.IceMeltsEnabled = Boolean.parseBoolean(args[0]); + ConfigMain.IceMeltsEnabledProperty.set(ConfigMain.IceMeltsEnabled); + if (ConfigMain.config.hasChanged()) { + ConfigMain.config.save(); + } Set names = Block.blockRegistry.getKeys(); - for(String name : names){ - Block block = (Block) Block.blockRegistry.getObject(name); - if(block instanceof BlockIce){ - block.setTickRandomly(ConfigMain.IceMeltsEnabled); - } + for (String name : names) { + Block block = (Block) Block.blockRegistry.getObject(name); + if (block instanceof BlockIce) { + block.setTickRandomly(ConfigMain.IceMeltsEnabled); + } } sendmessage("IceMelts is now " + ConfigMain.IceMeltsEnabled); - } + } return true; } @SubCommand( - desc="Disable/Enable guns shooting", - usage="", - permissions={OpOnly.class}, - hasEmptyCall = true + desc = "Disable/Enable guns shooting", + usage = "", + permissions = {OpOnly.class}, + hasEmptyCall = true ) - public boolean guns(String[] args){ - if(args.length == 0){ - sendmessage("GunsEnabled: " + ConfigItem.GunsEnabled); - } - else{ - ConfigItem.GunsEnabled = Boolean.parseBoolean(args[0]); - ConfigItem.GunsEnabledProperty.set(ConfigItem.GunsEnabled); - if(ConfigMain.config.hasChanged()){ - ConfigMain.config.save(); - } + public boolean guns(String[] args) { + if (args.length == 0) { + sendmessage("GunsEnabled: " + ConfigItem.GunsEnabled); + } else { + ConfigItem.GunsEnabled = Boolean.parseBoolean(args[0]); + ConfigItem.GunsEnabledProperty.set(ConfigItem.GunsEnabled); + if (ConfigMain.config.hasChanged()) { + ConfigMain.config.save(); + } sendmessage("GunsEnabled is now " + ConfigItem.GunsEnabled); - } + } return true; } @SubCommand( - desc="Freezes/Unfreezes npcs", - usage="", - permissions={OpOnly.class}, - hasEmptyCall = true + desc = "Freezes/Unfreezes npcs", + usage = "", + permissions = {OpOnly.class}, + hasEmptyCall = true ) - public boolean freezenpcs(String[] args){ - if(args.length == 0){ - sendmessage("Frozen NPCs: " + CustomNpcs.FreezeNPCs); - } - else{ - CustomNpcs.FreezeNPCs = Boolean.parseBoolean(args[0]); + public boolean freezenpcs(String[] args) { + if (args.length == 0) { + sendmessage("Frozen NPCs: " + CustomNpcs.FreezeNPCs); + } else { + CustomNpcs.FreezeNPCs = Boolean.parseBoolean(args[0]); sendmessage("FrozenNPCs is now " + CustomNpcs.FreezeNPCs); - } + } return true; } @SubCommand( - desc="Set how many active chunkloaders you can have", - usage="", - permissions={OpOnly.class}, - hasEmptyCall = true + desc = "Set how many active chunkloaders you can have", + usage = "", + permissions = {OpOnly.class}, + hasEmptyCall = true ) - public boolean chunkloaders(String[] args){ - if(args.length == 0){ - sendmessage("ChunkLoaders: " + ChunkController.Instance.size() + "/" + ConfigMain.ChunkLoaders); - } - else{ - try{ - ConfigMain.ChunkLoaders = Integer.parseInt(args[0]); - } - catch(NumberFormatException ex){ - sendmessage("Didnt get a number"); - return false; - } + public boolean chunkloaders(String[] args) { + if (args.length == 0) { + sendmessage("ChunkLoaders: " + ChunkController.Instance.size() + "/" + ConfigMain.ChunkLoaders); + } else { + try { + ConfigMain.ChunkLoaders = Integer.parseInt(args[0]); + } catch (NumberFormatException ex) { + sendmessage("Didnt get a number"); + return false; + } - ConfigMain.ChunkLoadersProperty.set(ConfigMain.ChunkLoaders); - if(ConfigMain.config.hasChanged()){ - ConfigMain.config.save(); - } - int size = ChunkController.Instance.size(); - if(size > ConfigMain.ChunkLoaders){ - ChunkController.Instance.unload(size - ConfigMain.ChunkLoaders); - sendmessage(size - ConfigMain.ChunkLoaders + " chunksloaders unloaded"); - } - sendmessage("ChunkLoaders: " + ChunkController.Instance.size() + "/" + ConfigMain.ChunkLoaders); - } + ConfigMain.ChunkLoadersProperty.set(ConfigMain.ChunkLoaders); + if (ConfigMain.config.hasChanged()) { + ConfigMain.config.save(); + } + int size = ChunkController.Instance.size(); + if (size > ConfigMain.ChunkLoaders) { + ChunkController.Instance.unload(size - ConfigMain.ChunkLoaders); + sendmessage(size - ConfigMain.ChunkLoaders + " chunksloaders unloaded"); + } + sendmessage("ChunkLoaders: " + ChunkController.Instance.size() + "/" + ConfigMain.ChunkLoaders); + } return true; } @SubCommand( - desc="Get/Set font", - usage="[type] [size]", - permissions={PlayerOnly.class}, - hasEmptyCall = true + desc = "Get/Set font", + usage = "[type] [size]", + permissions = {PlayerOnly.class}, + hasEmptyCall = true ) - public void font(String[] args){ - int size = 18; - if(args.length > 1){ - try{ - size = Integer.parseInt(args[args.length - 1]); - args = Arrays.copyOfRange(args, 0, args.length - 1); - } - catch(Exception e){ + public void font(String[] args) { + int size = 18; + if (args.length > 1) { + try { + size = Integer.parseInt(args[args.length - 1]); + args = Arrays.copyOfRange(args, 0, args.length - 1); + } catch (Exception e) { - } - } - String font = ""; - for(int i = 0; i < args.length; i++){ - font += " " + args[i]; - } - PacketHandler.Instance.sendToPlayer(new ConfigCommandPacket(EnumConfigOperation.FONT, font.trim(), size), (EntityPlayerMP)this.pcParam); + } + } + String font = ""; + for (int i = 0; i < args.length; i++) { + font += " " + args[i]; + } + PacketHandler.Instance.sendToPlayer(new ConfigCommandPacket(EnumConfigOperation.FONT, font.trim(), size), (EntityPlayerMP) this.pcParam); } } diff --git a/src/main/java/foxz/command/CmdDialog.java b/src/main/java/foxz/command/CmdDialog.java index 3b6a3e857..2bb2d1da3 100644 --- a/src/main/java/foxz/command/CmdDialog.java +++ b/src/main/java/foxz/command/CmdDialog.java @@ -19,9 +19,9 @@ import noppes.npcs.entity.EntityDialogNpc; import java.util.List; @Command( - name="dialog", - desc="dialog operations", - usage="help" + name = "dialog", + desc = "dialog operations", + usage = "help" ) public class CmdDialog extends ChMcLogger { @@ -31,15 +31,15 @@ public class CmdDialog extends ChMcLogger { @SubCommand( - desc="force read", - usage=" ", - permissions={OpOnly.class, ParamCheck.class} + desc = "force read", + usage = " ", + permissions = {OpOnly.class, ParamCheck.class} ) - public boolean read(String args[]){ - String playername=args[0]; + public boolean read(String args[]) { + String playername = args[0]; int diagid; try { - diagid = Integer.parseInt(args[1]); + diagid = Integer.parseInt(args[1]); } catch (NumberFormatException ex) { sendmessage("DialogID must be an integer"); return false; @@ -49,24 +49,24 @@ public class CmdDialog extends ChMcLogger { sendmessage(String.format("Unknow player '%s'", playername)); return false; } - for(PlayerData playerdata : data){ - playerdata.dialogData.dialogsRead.add(diagid); - playerdata.save(); + for (PlayerData playerdata : data) { + playerdata.dialogData.dialogsRead.add(diagid); + playerdata.save(); playerdata.updateClient = true; } return true; } @SubCommand( - desc="force unread dialog", - usage=" ", - permissions={OpOnly.class, ParamCheck.class} + desc = "force unread dialog", + usage = " ", + permissions = {OpOnly.class, ParamCheck.class} ) - public boolean unread(String args[]){ - String playername=args[0]; + public boolean unread(String args[]) { + String playername = args[0]; int diagid; try { - diagid = Integer.parseInt(args[1]); + diagid = Integer.parseInt(args[1]); } catch (NumberFormatException ex) { sendmessage("DialogID must be an integer"); return false; @@ -76,56 +76,57 @@ public class CmdDialog extends ChMcLogger { sendmessage(String.format("Unknow player '%s'", playername)); return false; } - for(PlayerData playerdata : data){ - playerdata.dialogData.dialogsRead.remove(diagid); - playerdata.save(); + for (PlayerData playerdata : data) { + playerdata.dialogData.dialogsRead.remove(diagid); + playerdata.save(); playerdata.updateClient = true; } return true; } + @SubCommand( - desc="reload dialogs from disk", - permissions={OpOnly.class} + desc = "reload dialogs from disk", + permissions = {OpOnly.class} ) - public boolean reload(String args[]){ - new DialogController().load(); + public boolean reload(String args[]) { + new DialogController().load(); SyncController.syncAllDialogs(); - return true; + return true; } @SubCommand( - desc="show dialog", - usage=" ", - permissions={OpOnly.class} + desc = "show dialog", + usage = " ", + permissions = {OpOnly.class} ) - public void show(String args[]){ - EntityPlayer player = CommandBase.getPlayer(pcParam, args[0]); - if(player == null){ + public void show(String args[]) { + EntityPlayer player = CommandBase.getPlayer(pcParam, args[0]); + if (player == null) { sendmessage(String.format("Unknow player '%s'", args[0])); return; - } + } int diagid; try { - diagid = Integer.parseInt(args[1]); + diagid = Integer.parseInt(args[1]); } catch (NumberFormatException ex) { sendmessage("DialogID must be an integer: " + args[1]); return; } Dialog dialog = DialogController.Instance.dialogs.get(diagid); - if(dialog == null){ + if (dialog == null) { sendmessage("Unknown dialog id: " + args[1]); return; } - EntityDialogNpc npc = new EntityDialogNpc(this.pcParam.getEntityWorld()); - npc.display.name = args[2]; - EntityUtil.Copy(player, npc); - DialogOption option = new DialogOption(); - option.dialogId = diagid; - option.title = dialog.title; - npc.dialogs.put(0, option); - NoppesUtilServer.openDialog(player, npc, dialog, 0); + EntityDialogNpc npc = new EntityDialogNpc(this.pcParam.getEntityWorld()); + npc.display.name = args[2]; + EntityUtil.Copy(player, npc); + DialogOption option = new DialogOption(); + option.dialogId = diagid; + option.title = dialog.title; + npc.dialogs.put(0, option); + NoppesUtilServer.openDialog(player, npc, dialog, 0); } } diff --git a/src/main/java/foxz/command/CmdFaction.java b/src/main/java/foxz/command/CmdFaction.java index d141ca7e1..55a156993 100644 --- a/src/main/java/foxz/command/CmdFaction.java +++ b/src/main/java/foxz/command/CmdFaction.java @@ -12,8 +12,8 @@ import noppes.npcs.controllers.data.PlayerFactionData; import java.util.List; @Command( - name = "faction", - desc = "operations about relationship between player and faction" + name = "faction", + desc = "operations about relationship between player and faction" ) public class CmdFaction extends ChMcLogger { @@ -27,9 +27,9 @@ public class CmdFaction extends ChMcLogger { } @SubCommand( - desc = "Add points", - usage = "", - permissions={OpOnly.class, ParamCheck.class} + desc = "Add points", + usage = "", + permissions = {OpOnly.class, ParamCheck.class} ) public Boolean add(String[] args) { int points; @@ -41,8 +41,8 @@ public class CmdFaction extends ChMcLogger { } int factionid = this.selectedFaction.id; - for(PlayerData playerdata : data){ - PlayerFactionData playerfactiondata = playerdata.factionData; + for (PlayerData playerdata : data) { + PlayerFactionData playerfactiondata = playerdata.factionData; playerfactiondata.increasePoints(factionid, points, playerdata.player); playerdata.updateClient = true; } @@ -50,9 +50,9 @@ public class CmdFaction extends ChMcLogger { } @SubCommand( - desc = "Substract points", - usage = "", - permissions={OpOnly.class, ParamCheck.class} + desc = "Substract points", + usage = "", + permissions = {OpOnly.class, ParamCheck.class} ) public Boolean subtract(String[] args) { int points; @@ -63,8 +63,8 @@ public class CmdFaction extends ChMcLogger { return false; } int factionid = this.selectedFaction.id; - for(PlayerData playerdata : data){ - PlayerFactionData playerfactiondata = playerdata.factionData; + for (PlayerData playerdata : data) { + PlayerFactionData playerfactiondata = playerdata.factionData; playerfactiondata.increasePoints(factionid, -points, playerdata.player); playerdata.updateClient = true; } @@ -72,22 +72,22 @@ public class CmdFaction extends ChMcLogger { } @SubCommand( - desc = "Reset points to default", - usage = "", - permissions={OpOnly.class} + desc = "Reset points to default", + usage = "", + permissions = {OpOnly.class} ) public Boolean reset(String[] args) { - for(PlayerData playerdata : data){ - playerdata.factionData.factionData.put(this.selectedFaction.id, this.selectedFaction.defaultPoints); + for (PlayerData playerdata : data) { + playerdata.factionData.factionData.put(this.selectedFaction.id, this.selectedFaction.defaultPoints); playerdata.updateClient = true; } return true; } @SubCommand( - desc = "Set points", - usage = "", - permissions={OpOnly.class, ParamCheck.class} + desc = "Set points", + usage = "", + permissions = {OpOnly.class, ParamCheck.class} ) public Boolean set(String[] args) { int points; @@ -97,22 +97,22 @@ public class CmdFaction extends ChMcLogger { sendmessage("Must be an integer"); return false; } - for(PlayerData playerdata : data){ - PlayerFactionData playerfactiondata = playerdata.factionData; - playerfactiondata.factionData.put(this.selectedFaction.id,points); + for (PlayerData playerdata : data) { + PlayerFactionData playerfactiondata = playerdata.factionData; + playerfactiondata.factionData.put(this.selectedFaction.id, points); playerdata.updateClient = true; } return true; } @SubCommand( - desc="Drop relationship", - usage="", - permissions={OpOnly.class} + desc = "Drop relationship", + usage = "", + permissions = {OpOnly.class} ) - public Boolean drop(String[] args){ - for(PlayerData playerdata : data){ - playerdata.factionData.factionData.remove(this.selectedFaction.id); + public Boolean drop(String[] args) { + for (PlayerData playerdata : data) { + playerdata.factionData.factionData.remove(this.selectedFaction.id); playerdata.updateClient = true; } return true; diff --git a/src/main/java/foxz/command/CmdNoppes.java b/src/main/java/foxz/command/CmdNoppes.java index a078570f7..a60d1dd8f 100644 --- a/src/main/java/foxz/command/CmdNoppes.java +++ b/src/main/java/foxz/command/CmdNoppes.java @@ -30,194 +30,194 @@ import noppes.npcs.entity.EntityNPCInterface; import java.util.*; @Command( - name = "noppes", - desc = "noppes root command", - sub = {CmdClone.class, CmdScript.class, CmdQuest.class, CmdDialog.class, CmdConfig.class} + name = "noppes", + desc = "noppes root command", + sub = {CmdClone.class, CmdScript.class, CmdQuest.class, CmdDialog.class, CmdConfig.class} ) public class CmdNoppes extends ChMcLogger { - public CmdFaction cmdfaction = new CmdFaction(ctorParm); - public CmdNpc cmdnpc = new CmdNpc(ctorParm); - public static Map> SlayMap = new LinkedHashMap>(); + public CmdFaction cmdfaction = new CmdFaction(ctorParm); + public CmdNpc cmdnpc = new CmdNpc(ctorParm); + public static Map> SlayMap = new LinkedHashMap>(); - public CmdNoppes(Object sender) { - super(sender); + public CmdNoppes(Object sender) { + super(sender); - SlayMap.clear(); + SlayMap.clear(); - SlayMap.put("all", EntityLivingBase.class); - SlayMap.put("mobs", EntityMob.class); - SlayMap.put("animals", EntityAnimal.class); - SlayMap.put("items", EntityItem.class); - SlayMap.put("xporbs", EntityXPOrb.class); - SlayMap.put("npcs", EntityNPCInterface.class); + SlayMap.put("all", EntityLivingBase.class); + SlayMap.put("mobs", EntityMob.class); + SlayMap.put("animals", EntityAnimal.class); + SlayMap.put("items", EntityItem.class); + SlayMap.put("xporbs", EntityXPOrb.class); + SlayMap.put("npcs", EntityNPCInterface.class); - HashMap> list = new HashMap>(EntityList.stringToClassMapping); - for (String name : list.keySet()) { - Class cls = list.get(name); - if (EntityNPCInterface.class.isAssignableFrom(cls)) - continue; - if (!EntityLivingBase.class.isAssignableFrom(cls)) - continue; - SlayMap.put(name.toLowerCase(), list.get(name)); - } + HashMap> list = new HashMap>(EntityList.stringToClassMapping); + for (String name : list.keySet()) { + Class cls = list.get(name); + if (EntityNPCInterface.class.isAssignableFrom(cls)) + continue; + if (!EntityLivingBase.class.isAssignableFrom(cls)) + continue; + SlayMap.put(name.toLowerCase(), list.get(name)); + } - SlayMap.remove("monster"); - SlayMap.remove("mob"); - } + SlayMap.remove("monster"); + SlayMap.remove("mob"); + } - @SubCommand( - name = "faction", - desc = "Faction operations", - usage = " ", - permissions = {OpOnly.class, ParamCheck.class} - ) - public Boolean faction(String[] args) { - String playername = args[0]; - String factionname = args[1]; + @SubCommand( + name = "faction", + desc = "Faction operations", + usage = " ", + permissions = {OpOnly.class, ParamCheck.class} + ) + public Boolean faction(String[] args) { + String playername = args[0]; + String factionname = args[1]; - cmdfaction.data = getPlayersData(playername); - if (cmdfaction.data.isEmpty()) { - sendmessage(String.format("Unknow player '%s'", playername)); - return false; - } - try { - cmdfaction.selectedFaction = FactionController.getInstance().get(Integer.parseInt(factionname)); - } catch (NumberFormatException e) { - cmdfaction.selectedFaction = FactionController.getInstance().getFactionFromName(factionname); // get faction data - } - if (cmdfaction.selectedFaction == null) { - sendmessage(String.format("Unknow facion '%s", factionname)); - return false; - } - args = Arrays.copyOfRange(args, 2, args.length); - cmdfaction.processCommand(this.pcParam, args); + cmdfaction.data = getPlayersData(playername); + if (cmdfaction.data.isEmpty()) { + sendmessage(String.format("Unknow player '%s'", playername)); + return false; + } + try { + cmdfaction.selectedFaction = FactionController.getInstance().get(Integer.parseInt(factionname)); + } catch (NumberFormatException e) { + cmdfaction.selectedFaction = FactionController.getInstance().getFactionFromName(factionname); // get faction data + } + if (cmdfaction.selectedFaction == null) { + sendmessage(String.format("Unknow facion '%s", factionname)); + return false; + } + args = Arrays.copyOfRange(args, 2, args.length); + cmdfaction.processCommand(this.pcParam, args); - for (PlayerData playerdata : cmdfaction.data) { - playerdata.save(); - } - return true; - } + for (PlayerData playerdata : cmdfaction.data) { + playerdata.save(); + } + return true; + } - @SubCommand( - desc = "NPC manipulations", - usage = " ", - permissions = {OpOnly.class, ParamCheck.class} - ) - public boolean npc(String[] args) { - String npcname = args[0].replace("%", " "); - args = Arrays.copyOfRange(args, 1, args.length); - if (args[0].equalsIgnoreCase("create")) { - cmdnpc.processCommand(this.pcParam, new String[]{args[0], npcname}); - return true; - } - int x = pcParam.getPlayerCoordinates().posX; - int y = pcParam.getPlayerCoordinates().posY; - int z = pcParam.getPlayerCoordinates().posZ; - List list = getNearbeEntityFromPlayer(EntityNPCInterface.class, pcParam.getEntityWorld(), x, y, z, 80); - EntityNPCInterface closest = null; - for (EntityNPCInterface npc : list) { - String name = npc.display.name.replace(" ", "_"); - if (name.equalsIgnoreCase(npcname)) { - if (closest == null || closest.getDistanceSq(x, y, z) > npc.getDistanceSq(x, y, z)) - closest = npc; - } - } - if (closest != null) { - cmdnpc.selectedNpc = closest; - cmdnpc.processCommand(this.pcParam, args); - cmdnpc.selectedNpc = null; - } else - sendmessage(String.format("NPC '%s' was not found", npcname)); - return true; - } + @SubCommand( + desc = "NPC manipulations", + usage = " ", + permissions = {OpOnly.class, ParamCheck.class} + ) + public boolean npc(String[] args) { + String npcname = args[0].replace("%", " "); + args = Arrays.copyOfRange(args, 1, args.length); + if (args[0].equalsIgnoreCase("create")) { + cmdnpc.processCommand(this.pcParam, new String[]{args[0], npcname}); + return true; + } + int x = pcParam.getPlayerCoordinates().posX; + int y = pcParam.getPlayerCoordinates().posY; + int z = pcParam.getPlayerCoordinates().posZ; + List list = getNearbeEntityFromPlayer(EntityNPCInterface.class, pcParam.getEntityWorld(), x, y, z, 80); + EntityNPCInterface closest = null; + for (EntityNPCInterface npc : list) { + String name = npc.display.name.replace(" ", "_"); + if (name.equalsIgnoreCase(npcname)) { + if (closest == null || closest.getDistanceSq(x, y, z) > npc.getDistanceSq(x, y, z)) + closest = npc; + } + } + if (closest != null) { + cmdnpc.selectedNpc = closest; + cmdnpc.processCommand(this.pcParam, args); + cmdnpc.selectedNpc = null; + } else + sendmessage(String.format("NPC '%s' was not found", npcname)); + return true; + } - @SubCommand( - name = "slay", - desc = "Kills given entity within range. Also has all, mobs, animal options. Can have multiple types", - usage = ".. [range]", - permissions = {PlayerOnly.class, OpOnly.class, ParamCheck.class} - ) - public Boolean slay(String[] args) { - EntityPlayerMP player = (EntityPlayerMP) pcParam; - ArrayList> toDelete = new ArrayList>(); - boolean deleteNPCs = false; - for (String delete : args) { - delete = delete.toLowerCase(); - Class cls = SlayMap.get(delete); - if (cls != null) - toDelete.add(cls); - if (delete.equals("mobs")) { - toDelete.add(EntityGhast.class); - toDelete.add(EntityDragon.class); - } - if (delete.equals("npcs")) - deleteNPCs = true; - } - int count = 0; - int range = 120; - try { - range = Integer.parseInt(args[args.length - 1]); - } catch (NumberFormatException ex) { + @SubCommand( + name = "slay", + desc = "Kills given entity within range. Also has all, mobs, animal options. Can have multiple types", + usage = ".. [range]", + permissions = {PlayerOnly.class, OpOnly.class, ParamCheck.class} + ) + public Boolean slay(String[] args) { + EntityPlayerMP player = (EntityPlayerMP) pcParam; + ArrayList> toDelete = new ArrayList>(); + boolean deleteNPCs = false; + for (String delete : args) { + delete = delete.toLowerCase(); + Class cls = SlayMap.get(delete); + if (cls != null) + toDelete.add(cls); + if (delete.equals("mobs")) { + toDelete.add(EntityGhast.class); + toDelete.add(EntityDragon.class); + } + if (delete.equals("npcs")) + deleteNPCs = true; + } + int count = 0; + int range = 120; + try { + range = Integer.parseInt(args[args.length - 1]); + } catch (NumberFormatException ex) { - } - AxisAlignedBB box = player.boundingBox.expand(range, range, range); - List list = player.worldObj.getEntitiesWithinAABB(EntityLivingBase.class, box); + } + AxisAlignedBB box = player.boundingBox.expand(range, range, range); + List list = player.worldObj.getEntitiesWithinAABB(EntityLivingBase.class, box); - for (Entity entity : list) { - if (entity instanceof EntityPlayer) - continue; - if (entity instanceof EntityTameable && ((EntityTameable) entity).isTamed()) - continue; - if (entity instanceof EntityNPCInterface && !deleteNPCs) - continue; - if (delete(entity, toDelete)) - count++; - } - if (toDelete.contains(EntityXPOrb.class)) { - list = player.worldObj.getEntitiesWithinAABB(EntityXPOrb.class, box); - for (Entity entity : list) { - entity.isDead = true; - count++; - } - } - if (toDelete.contains(EntityItem.class)) { - list = player.worldObj.getEntitiesWithinAABB(EntityItem.class, box); - for (Entity entity : list) { - entity.isDead = true; - count++; - } - } + for (Entity entity : list) { + if (entity instanceof EntityPlayer) + continue; + if (entity instanceof EntityTameable && ((EntityTameable) entity).isTamed()) + continue; + if (entity instanceof EntityNPCInterface && !deleteNPCs) + continue; + if (delete(entity, toDelete)) + count++; + } + if (toDelete.contains(EntityXPOrb.class)) { + list = player.worldObj.getEntitiesWithinAABB(EntityXPOrb.class, box); + for (Entity entity : list) { + entity.isDead = true; + count++; + } + } + if (toDelete.contains(EntityItem.class)) { + list = player.worldObj.getEntitiesWithinAABB(EntityItem.class, box); + for (Entity entity : list) { + entity.isDead = true; + count++; + } + } - player.addChatMessage(new ChatComponentTranslation(count + " entities deleted")); - return true; - } + player.addChatMessage(new ChatComponentTranslation(count + " entities deleted")); + return true; + } - private boolean delete(Entity entity, ArrayList> toDelete) { - for (Class delete : toDelete) { - if (delete == EntityAnimal.class && (entity instanceof EntityHorse)) { - continue; - } - if (delete.isAssignableFrom(entity.getClass())) { - entity.isDead = true; - return true; - } - } - return false; - } + private boolean delete(Entity entity, ArrayList> toDelete) { + for (Class delete : toDelete) { + if (delete == EntityAnimal.class && (entity instanceof EntityHorse)) { + continue; + } + if (delete.isAssignableFrom(entity.getClass())) { + entity.isDead = true; + return true; + } + } + return false; + } - @Override - public List addTabCompletion(ICommandSender par1, String[] args) { - if (args[0].equalsIgnoreCase("slay")) { - return CommandBase.getListOfStringsMatchingLastWord(args, SlayMap.keySet().toArray(new String[SlayMap.size()])); - } - if (args[0].equalsIgnoreCase("npc") && args.length == 3) { - return cmdnpc.addTabCompletion(par1, Arrays.copyOfRange(args, 1, args.length)); - } - if (args[0].equalsIgnoreCase("faction") && args.length == 4) { - return CommandBase.getListOfStringsMatchingLastWord(args, new String[]{"add", "subtract", "set", "reset", "drop", "create"}); - } - return super.addTabCompletion(par1, args); - } + @Override + public List addTabCompletion(ICommandSender par1, String[] args) { + if (args[0].equalsIgnoreCase("slay")) { + return CommandBase.getListOfStringsMatchingLastWord(args, SlayMap.keySet().toArray(new String[SlayMap.size()])); + } + if (args[0].equalsIgnoreCase("npc") && args.length == 3) { + return cmdnpc.addTabCompletion(par1, Arrays.copyOfRange(args, 1, args.length)); + } + if (args[0].equalsIgnoreCase("faction") && args.length == 4) { + return CommandBase.getListOfStringsMatchingLastWord(args, new String[]{"add", "subtract", "set", "reset", "drop", "create"}); + } + return super.addTabCompletion(par1, args); + } } diff --git a/src/main/java/foxz/command/CmdNpc.java b/src/main/java/foxz/command/CmdNpc.java index aaec029a4..5bcbded53 100644 --- a/src/main/java/foxz/command/CmdNpc.java +++ b/src/main/java/foxz/command/CmdNpc.java @@ -22,29 +22,29 @@ import noppes.npcs.roles.RoleFollower; import java.util.List; @Command( - name="npc", - desc="NPC manipulation", - usage=" " + name = "npc", + desc = "NPC manipulation", + usage = " " ) public class CmdNpc extends ChMcLogger { CmdNpc(Object ctorParm) { - super (ctorParm); + super(ctorParm); } public EntityNPCInterface selectedNpc; @SubCommand( - desc="Set Home (respawn place)", - usage="" + desc = "Set Home (respawn place)", + usage = "" ) - public void home(String[] args){ + public void home(String[] args) { double posX = pcParam.getPlayerCoordinates().posX; double posY = pcParam.getPlayerCoordinates().posY; double posZ = pcParam.getPlayerCoordinates().posZ; - if(args.length == 3){ + if (args.length == 3) { posX = CommandBase.func_110666_a(pcParam, selectedNpc.posX, args[0]); posY = CommandBase.func_110665_a(pcParam, selectedNpc.posY, args[1].trim(), 0, 0); posZ = CommandBase.func_110666_a(pcParam, selectedNpc.posZ, args[2]); @@ -54,111 +54,110 @@ public class CmdNpc extends ChMcLogger { } @SubCommand( - desc="Set npc visibility", - usage="" + desc = "Set npc visibility", + usage = "" ) - public void visible(String[] args){ - if(args.length < 1) - return; - boolean bo = args[0].equalsIgnoreCase("true"); - boolean semi = args[0].equalsIgnoreCase("semi"); + public void visible(String[] args) { + if (args.length < 1) + return; + boolean bo = args[0].equalsIgnoreCase("true"); + boolean semi = args[0].equalsIgnoreCase("semi"); - int current = selectedNpc.display.visible; - if(semi) - selectedNpc.display.visible = 2; - else if(bo) - selectedNpc.display.visible = 0; - else - selectedNpc.display.visible = 1; + int current = selectedNpc.display.visible; + if (semi) + selectedNpc.display.visible = 2; + else if (bo) + selectedNpc.display.visible = 0; + else + selectedNpc.display.visible = 1; - if(current != selectedNpc.display.visible) - selectedNpc.updateClient = true; + if (current != selectedNpc.display.visible) + selectedNpc.updateClient = true; } @SubCommand( - desc="Delete an NPC", - usage="" + desc = "Delete an NPC", + usage = "" ) - public void delete(String[] args){ - selectedNpc.delete(); + public void delete(String[] args) { + selectedNpc.delete(); } @SubCommand( - desc="Owner", - usage="" + desc = "Owner", + usage = "" ) - public void owner(String[] args){ - if(args.length < 1){ - EntityPlayer player = null; - if(selectedNpc.roleInterface instanceof RoleFollower) - player = ((RoleFollower)selectedNpc.roleInterface).owner; + public void owner(String[] args) { + if (args.length < 1) { + EntityPlayer player = null; + if (selectedNpc.roleInterface instanceof RoleFollower) + player = ((RoleFollower) selectedNpc.roleInterface).owner; - if(selectedNpc.roleInterface instanceof RoleCompanion) - player = ((RoleCompanion)selectedNpc.roleInterface).owner; + if (selectedNpc.roleInterface instanceof RoleCompanion) + player = ((RoleCompanion) selectedNpc.roleInterface).owner; - if(player == null) - sendmessage("No owner"); - else - sendmessage("Owner is: " + player.getCommandSenderName()); - } - else{ - EntityPlayerMP player = CommandBase.getPlayer(pcParam, args[0]); - if(selectedNpc.roleInterface instanceof RoleFollower) - ((RoleFollower)selectedNpc.roleInterface).setOwner(player); + if (player == null) + sendmessage("No owner"); + else + sendmessage("Owner is: " + player.getCommandSenderName()); + } else { + EntityPlayerMP player = CommandBase.getPlayer(pcParam, args[0]); + if (selectedNpc.roleInterface instanceof RoleFollower) + ((RoleFollower) selectedNpc.roleInterface).setOwner(player); - if(selectedNpc.roleInterface instanceof RoleCompanion) - ((RoleCompanion)selectedNpc.roleInterface).setOwner(player); - } + if (selectedNpc.roleInterface instanceof RoleCompanion) + ((RoleCompanion) selectedNpc.roleInterface).setOwner(player); + } } @SubCommand( - desc="Set npc name", - usage="" + desc = "Set npc name", + usage = "" ) - public void name(String[] args){ - if(args.length < 1) - return; + public void name(String[] args) { + if (args.length < 1) + return; - String name = args[0]; - for(int i = 1; i < args.length; i++){ - name += " " + args[i]; - } + String name = args[0]; + for (int i = 1; i < args.length; i++) { + name += " " + args[i]; + } - if(!selectedNpc.display.name.equals(name)){ - selectedNpc.display.name = name; - selectedNpc.updateClient = true; - } + if (!selectedNpc.display.name.equals(name)) { + selectedNpc.display.name = name; + selectedNpc.updateClient = true; + } } @SubCommand( - desc = "Creates an NPC", - usage = "[name]", - permissions = {PlayerOnly.class, OpOnly.class} + desc = "Creates an NPC", + usage = "[name]", + permissions = {PlayerOnly.class, OpOnly.class} ) public void create(String[] args) { EntityPlayerMP player = (EntityPlayerMP) pcParam; World pw = player.getEntityWorld(); EntityCustomNpc npc = new EntityCustomNpc(pw); - if(args.length > 0) - npc.display.name = args[0]; + if (args.length > 0) + npc.display.name = args[0]; npc.setPositionAndRotation(player.posX, player.posY, player.posZ, player.cameraYaw, player.cameraPitch); - npc.ais.startPos = new int[]{MathHelper.floor_double(player.posX),MathHelper.floor_double(player.posY),MathHelper.floor_double(player.posZ)}; + npc.ais.startPos = new int[]{MathHelper.floor_double(player.posX), MathHelper.floor_double(player.posY), MathHelper.floor_double(player.posZ)}; pw.spawnEntityInWorld(npc); npc.setHealth(npc.getMaxHealth()); NoppesUtilServer.sendOpenGui(player, EnumGuiType.MainMenuDisplay, npc); } @Override - public List addTabCompletion(ICommandSender par1, String[] args) { - if(args.length == 2){ - return CommandBase.getListOfStringsMatchingLastWord(args, new String[]{"create", "home", "visible", "delete", "owner", "name"}); - } - if(args.length == 3 && args[1].equalsIgnoreCase("owner")){ - return CommandBase.getListOfStringsMatchingLastWord(args, MinecraftServer.getServer().getAllUsernames()); - } + public List addTabCompletion(ICommandSender par1, String[] args) { + if (args.length == 2) { + return CommandBase.getListOfStringsMatchingLastWord(args, new String[]{"create", "home", "visible", "delete", "owner", "name"}); + } + if (args.length == 3 && args[1].equalsIgnoreCase("owner")) { + return CommandBase.getListOfStringsMatchingLastWord(args, MinecraftServer.getServer().getAllUsernames()); + } - return super.addTabCompletion(par1, args); + return super.addTabCompletion(par1, args); } } diff --git a/src/main/java/foxz/command/CmdQuest.java b/src/main/java/foxz/command/CmdQuest.java index 78cce2830..5f7a7f1f4 100644 --- a/src/main/java/foxz/command/CmdQuest.java +++ b/src/main/java/foxz/command/CmdQuest.java @@ -17,26 +17,26 @@ import noppes.npcs.controllers.data.QuestData; import java.util.List; @Command( - name = "quest", - usage = "help", - desc = "Quest operations" + name = "quest", + usage = "help", + desc = "Quest operations" ) -public class CmdQuest extends ChMcLogger{ +public class CmdQuest extends ChMcLogger { public CmdQuest(Object sender) { super(sender); } @SubCommand( - desc = "Start a quest", - usage = " ", - permissions = {OpOnly.class, ParamCheck.class} + desc = "Start a quest", + usage = " ", + permissions = {OpOnly.class, ParamCheck.class} ) public Boolean start(String[] args) { - String playername=args[0]; + String playername = args[0]; int questid; try { - questid = Integer.parseInt(args[1]); + questid = Integer.parseInt(args[1]); } catch (NumberFormatException ex) { sendmessage("QuestID must be an integer"); return false; @@ -47,37 +47,36 @@ public class CmdQuest extends ChMcLogger{ return false; } Quest quest = QuestController.Instance.quests.get(questid); - if (quest == null){ + if (quest == null) { sendmessage("Unknown QuestID"); return false; } - for(PlayerData playerdata : data){ - if(playerdata.questData.activeQuests.containsKey(questid)) - continue; - QuestData questdata = new QuestData(quest); - playerdata.questData.activeQuests.put(questid, questdata); - playerdata.save(); - if(playerdata.player != null){ + for (PlayerData playerdata : data) { + if (playerdata.questData.activeQuests.containsKey(questid)) + continue; + QuestData questdata = new QuestData(quest); + playerdata.questData.activeQuests.put(questid, questdata); + playerdata.save(); + if (playerdata.player != null) { AchievementPacket.sendAchievement((EntityPlayerMP) playerdata.player, false, "quest.newquest", quest.title); ChatAlertPacket.sendChatAlert((EntityPlayerMP) playerdata.player, "quest.newquest", ": ", quest.title); - } + } playerdata.updateClient = true; } return true; } @SubCommand( - desc = "Finish a quest", - usage = " ", - permissions = {OpOnly.class, ParamCheck.class} + desc = "Finish a quest", + usage = " ", + permissions = {OpOnly.class, ParamCheck.class} ) - public Boolean finish(String args[]){ - String playername=args[0]; + public Boolean finish(String args[]) { + String playername = args[0]; int questid; try { - questid = Integer.parseInt(args[1]); - } - catch (NumberFormatException ex) { + questid = Integer.parseInt(args[1]); + } catch (NumberFormatException ex) { sendmessage("QuestID must be an integer"); return false; } @@ -88,28 +87,28 @@ public class CmdQuest extends ChMcLogger{ } Quest quest = QuestController.Instance.quests.get(questid); - if (quest == null){ + if (quest == null) { sendmessage("Unknown QuestID"); return false; } - for(PlayerData playerdata : data){ - playerdata.questData.finishedQuests.put(questid, System.currentTimeMillis()); - playerdata.save(); + for (PlayerData playerdata : data) { + playerdata.questData.finishedQuests.put(questid, System.currentTimeMillis()); + playerdata.save(); playerdata.updateClient = true; } return true; } @SubCommand( - desc = "Stop a started quest", - usage = " ", - permissions = {OpOnly.class, ParamCheck.class} + desc = "Stop a started quest", + usage = " ", + permissions = {OpOnly.class, ParamCheck.class} ) public Boolean stop(String[] args) { - String playername=args[0]; + String playername = args[0]; int questid; try { - questid = Integer.parseInt(args[1]); + questid = Integer.parseInt(args[1]); } catch (NumberFormatException ex) { sendmessage("QuestID must be an integer"); return false; @@ -120,28 +119,28 @@ public class CmdQuest extends ChMcLogger{ return false; } Quest quest = QuestController.Instance.quests.get(questid); - if (quest == null){ + if (quest == null) { sendmessage("Unknown QuestID"); return false; } - for(PlayerData playerdata : data){ - playerdata.questData.activeQuests.remove(questid); - playerdata.save(); + for (PlayerData playerdata : data) { + playerdata.questData.activeQuests.remove(questid); + playerdata.save(); playerdata.updateClient = true; } return true; } @SubCommand( - desc = "Removes a quest from finished and active quests", - usage = " ", - permissions = {OpOnly.class, ParamCheck.class} + desc = "Removes a quest from finished and active quests", + usage = " ", + permissions = {OpOnly.class, ParamCheck.class} ) public Boolean remove(String[] args) { - String playername=args[0]; + String playername = args[0]; int questid; try { - questid = Integer.parseInt(args[1]); + questid = Integer.parseInt(args[1]); } catch (NumberFormatException ex) { sendmessage("QuestID must be an integer"); return false; @@ -152,26 +151,27 @@ public class CmdQuest extends ChMcLogger{ return false; } Quest quest = QuestController.Instance.quests.get(questid); - if (quest == null){ + if (quest == null) { sendmessage("Unknown QuestID"); return false; } - for(PlayerData playerdata : data){ - playerdata.questData.activeQuests.remove(questid); - playerdata.questData.finishedQuests.remove(questid); - playerdata.save(); + for (PlayerData playerdata : data) { + playerdata.questData.activeQuests.remove(questid); + playerdata.questData.finishedQuests.remove(questid); + playerdata.save(); playerdata.updateClient = true; } return true; } + @SubCommand( - desc="reload quests from disk", - permissions={OpOnly.class} + desc = "reload quests from disk", + permissions = {OpOnly.class} ) - public boolean reload(String args[]){ - new QuestController().load(); + public boolean reload(String args[]) { + new QuestController().load(); SyncController.syncAllQuests(); - return true; + return true; } } diff --git a/src/main/java/foxz/command/CmdScript.java b/src/main/java/foxz/command/CmdScript.java index a7f587512..010e8d5c5 100644 --- a/src/main/java/foxz/command/CmdScript.java +++ b/src/main/java/foxz/command/CmdScript.java @@ -7,8 +7,8 @@ import foxz.commandhelper.permissions.OpOnly; import noppes.npcs.controllers.ScriptController; @Command( - name = "script", - desc = "Script operation" + name = "script", + desc = "Script operation" ) public class CmdScript extends ChMcLogger { @@ -17,14 +17,14 @@ public class CmdScript extends ChMcLogger { } @SubCommand( - desc = "Reload scripts and saved data from disks script folder.", - permissions={OpOnly.class} + desc = "Reload scripts and saved data from disks script folder.", + permissions = {OpOnly.class} ) public Boolean reload(String args[]) { - if(ScriptController.Instance.loadStoredData()) - sendmessage("Reload succesful"); - else - sendmessage("Failed reloading stored data"); + if (ScriptController.Instance.loadStoredData()) + sendmessage("Reload succesful"); + else + sendmessage("Failed reloading stored data"); return true; } } diff --git a/src/main/java/foxz/command/CommandNoppes.java b/src/main/java/foxz/command/CommandNoppes.java index 24ceb184a..8c051aa85 100644 --- a/src/main/java/foxz/command/CommandNoppes.java +++ b/src/main/java/foxz/command/CommandNoppes.java @@ -25,12 +25,12 @@ public class CommandNoppes extends CommandBase { } @Override - public List addTabCompletionOptions(ICommandSender par1, String[] par2){ + public List addTabCompletionOptions(ICommandSender par1, String[] par2) { return noppes.addTabCompletion(par1, par2); } @Override - public int getRequiredPermissionLevel(){ + public int getRequiredPermissionLevel() { return 2; } } diff --git a/src/main/java/foxz/command/ScriptedCommand.java b/src/main/java/foxz/command/ScriptedCommand.java index 221d3433d..b3b875d5e 100644 --- a/src/main/java/foxz/command/ScriptedCommand.java +++ b/src/main/java/foxz/command/ScriptedCommand.java @@ -51,12 +51,13 @@ public class ScriptedCommand extends CommandBase implements ICommand { public void processCommand(ICommandSender p_71515_1_, String[] p_71515_2_) { } - public int getRequiredPermissionLevel() - { + public int getRequiredPermissionLevel() { return this.permissionLevel; } - public int getPermissionLevel() { return this.getRequiredPermissionLevel(); } + public int getPermissionLevel() { + return this.getRequiredPermissionLevel(); + } public List getCommandAliases() { return this.aliases; diff --git a/src/main/java/foxz/commandhelper/AbstractCommandHelper.java b/src/main/java/foxz/commandhelper/AbstractCommandHelper.java index c66f8a988..cb86cff15 100644 --- a/src/main/java/foxz/commandhelper/AbstractCommandHelper.java +++ b/src/main/java/foxz/commandhelper/AbstractCommandHelper.java @@ -99,16 +99,17 @@ public abstract class AbstractCommandHelper extends CommandHelper { } } } + @Override - public List addTabCompletion(ICommandSender par1, String[] args) { + public List addTabCompletion(ICommandSender par1, String[] args) { String[] np = currentHelper.usage.split(" "); - if(np.length < args.length) - return null; + if (np.length < args.length) + return null; String parameter = np[args.length - 1]; - if(parameter.equals("")) + if (parameter.equals("")) return CommandBase.getListOfStringsMatchingLastWord(args, MinecraftServer.getServer().getAllUsernames()); - return null; + return null; } public Method method; @@ -144,7 +145,7 @@ public abstract class AbstractCommandHelper extends CommandHelper { args = Arrays.copyOfRange(args, 1, args.length); if ((cmd.equals("HELP") || args.length == 0) && doHelp(param, args, cmd)) { - return true; + return true; } CommandHelper ch = commands.get(cmd); @@ -157,8 +158,7 @@ public abstract class AbstractCommandHelper extends CommandHelper { f.parentCmdHelper = this; f.rootCmdHelper = this.rootCmdHelper; return f.processCommand(param, args); - } - else if (ch instanceof MethodSubCmd) { + } else if (ch instanceof MethodSubCmd) { MethodSubCmd m = (MethodSubCmd) ch; m.method.setAccessible(true); currentHelper = ch.commandHelper; @@ -174,72 +174,68 @@ public abstract class AbstractCommandHelper extends CommandHelper { Logger.getLogger(AbstractCommandHelper.class.getName()).log(Level.SEVERE, m.commandHelper.name, ex); } return true; - } - else + } else cmdError(cmd); return false; } - private boolean doHelp(ICommandSender param, String[] args, String cmd){ - boolean isHelp = cmd.equals("HELP"); - if(args.length > 0){ - cmd = args[0]; - } - CommandHelper ch = commands.get(cmd.toUpperCase()); - if(ch != null){ - if(ch.commandHelper.hasEmptyCall && !isHelp) - return false; - if(ch instanceof AbstractCommandHelper){ - ((AbstractCommandHelper)ch).pcParam = param; - ((AbstractCommandHelper)ch).allHelp(); - } - else if(ch instanceof MethodSubCmd && ((MethodSubCmd)ch).commandHelper.usage.isEmpty()) - return false; - else - help(ch.commandHelper.name, ch.commandHelper.desc, ch.commandHelper.usage); - } - else - allHelp(); + private boolean doHelp(ICommandSender param, String[] args, String cmd) { + boolean isHelp = cmd.equals("HELP"); + if (args.length > 0) { + cmd = args[0]; + } + CommandHelper ch = commands.get(cmd.toUpperCase()); + if (ch != null) { + if (ch.commandHelper.hasEmptyCall && !isHelp) + return false; + if (ch instanceof AbstractCommandHelper) { + ((AbstractCommandHelper) ch).pcParam = param; + ((AbstractCommandHelper) ch).allHelp(); + } else if (ch instanceof MethodSubCmd && ((MethodSubCmd) ch).commandHelper.usage.isEmpty()) + return false; + else + help(ch.commandHelper.name, ch.commandHelper.desc, ch.commandHelper.usage); + } else + allHelp(); return true; } @Override - public List addTabCompletion(ICommandSender par1, String[] args) { - if(args.length <= 1){ - List list = new ArrayList(); - for(String command : commands.keySet()) - list.add(command.toLowerCase()); - list.add("help"); - return CommandBase.getListOfStringsMatchingLastWord(args, list.toArray(new String[list.size()])); - } + public List addTabCompletion(ICommandSender par1, String[] args) { + if (args.length <= 1) { + List list = new ArrayList(); + for (String command : commands.keySet()) + list.add(command.toLowerCase()); + list.add("help"); + return CommandBase.getListOfStringsMatchingLastWord(args, list.toArray(new String[list.size()])); + } CommandHelper ch = commands.get(args[0].toUpperCase()); - if(ch == null) - return null; + if (ch == null) + return null; args = Arrays.copyOfRange(args, 1, args.length); currentHelper = ch.commandHelper; - return ch.addTabCompletion(par1, args); - } + return ch.addTabCompletion(par1, args); + } - public List getPlayersData(String username){ - ArrayList list = new ArrayList(); - EntityPlayerMP[] players = PlayerSelector.matchPlayers(pcParam, username); - if(players == null || players.length == 0){ - PlayerData data = PlayerDataController.Instance.getDataFromUsername(username); - if(data != null) - list.add(data); - } - else{ - for(EntityPlayer player : players){ - list.add(PlayerDataController.Instance.getPlayerData(player)); + public List getPlayersData(String username) { + ArrayList list = new ArrayList(); + EntityPlayerMP[] players = PlayerSelector.matchPlayers(pcParam, username); + if (players == null || players.length == 0) { + PlayerData data = PlayerDataController.Instance.getDataFromUsername(username); + if (data != null) + list.add(data); + } else { + for (EntityPlayer player : players) { + list.add(PlayerDataController.Instance.getPlayerData(player)); } - } + } - return list; + return list; } public List getNearbeEntityFromPlayer(Class cls, World world, int x, int y, int z, int range) { - AxisAlignedBB bb = AxisAlignedBB.getBoundingBox(x, y, z, x + 1, y + 1, z + 1).expand(range, range, range); - List list = world.getEntitiesWithinAABB(cls, bb); - return list; - } + AxisAlignedBB bb = AxisAlignedBB.getBoundingBox(x, y, z, x + 1, y + 1, z + 1).expand(range, range, range); + List list = world.getEntitiesWithinAABB(cls, bb); + return list; + } } diff --git a/src/main/java/foxz/commandhelper/ChMcLogger.java b/src/main/java/foxz/commandhelper/ChMcLogger.java index 60f8f6bce..2a51149a7 100644 --- a/src/main/java/foxz/commandhelper/ChMcLogger.java +++ b/src/main/java/foxz/commandhelper/ChMcLogger.java @@ -16,10 +16,10 @@ public class ChMcLogger extends AbstractCommandHelper { @Override public void help(String cmd, String desc, String usa) { - if(usa.isEmpty()) - sendmessage(String.format("%s = %s", cmd, desc)); - else - sendmessage(String.format("%s %s = %s", cmd, usa, desc)); + if (usa.isEmpty()) + sendmessage(String.format("%s = %s", cmd, desc)); + else + sendmessage(String.format("%s %s = %s", cmd, usa, desc)); } @Override diff --git a/src/main/java/foxz/commandhelper/CommandHelper.java b/src/main/java/foxz/commandhelper/CommandHelper.java index 97a3ecc0c..d2262fb59 100644 --- a/src/main/java/foxz/commandhelper/CommandHelper.java +++ b/src/main/java/foxz/commandhelper/CommandHelper.java @@ -13,8 +13,10 @@ public abstract class CommandHelper { public String desc; public boolean hasEmptyCall; } + public Helper commandHelper = new Helper(); - public List addTabCompletion(ICommandSender par1, String[] args) { - return null; - } + + public List addTabCompletion(ICommandSender par1, String[] args) { + return null; + } } diff --git a/src/main/java/foxz/commandhelper/permissions/OpOnly.java b/src/main/java/foxz/commandhelper/permissions/OpOnly.java index 04e6b5ac7..84d37e438 100644 --- a/src/main/java/foxz/commandhelper/permissions/OpOnly.java +++ b/src/main/java/foxz/commandhelper/permissions/OpOnly.java @@ -13,9 +13,9 @@ public class OpOnly extends AbstractPermission { @Override public boolean delegate(AbstractCommandHelper parent, String[] args) { - if(!(parent.pcParam instanceof EntityPlayer)) - return true; - return MinecraftServer.getServer().getConfigurationManager().func_152596_g(((EntityPlayer)parent.pcParam).getGameProfile()); + if (!(parent.pcParam instanceof EntityPlayer)) + return true; + return MinecraftServer.getServer().getConfigurationManager().func_152596_g(((EntityPlayer) parent.pcParam).getGameProfile()); } } diff --git a/src/main/java/foxz/commandhelper/permissions/ParamCheck.java b/src/main/java/foxz/commandhelper/permissions/ParamCheck.java index 4189b5748..df7309dda 100644 --- a/src/main/java/foxz/commandhelper/permissions/ParamCheck.java +++ b/src/main/java/foxz/commandhelper/permissions/ParamCheck.java @@ -15,9 +15,9 @@ public class ParamCheck extends AbstractPermission { public boolean delegate(AbstractCommandHelper parent, String[] args) { String[] np = parent.currentHelper.usage.split(" "); int countRequired = 0; - for(String command : np){ - if(command.startsWith("<")) - countRequired++; + for (String command : np) { + if (command.startsWith("<")) + countRequired++; } if (args.length < countRequired) { err = np[args.length] + " missing"; diff --git a/src/main/java/foxz/commandhelper/permissions/PlayerOnly.java b/src/main/java/foxz/commandhelper/permissions/PlayerOnly.java index 47c992ad3..85348b76f 100644 --- a/src/main/java/foxz/commandhelper/permissions/PlayerOnly.java +++ b/src/main/java/foxz/commandhelper/permissions/PlayerOnly.java @@ -9,7 +9,6 @@ import foxz.commandhelper.AbstractCommandHelper; import net.minecraft.entity.player.EntityPlayer; /** - * * @author foxz */ public class PlayerOnly extends AbstractPermission { diff --git a/src/main/java/foxz/utils/Market.java b/src/main/java/foxz/utils/Market.java index 461cc9a1c..03c0898c8 100644 --- a/src/main/java/foxz/utils/Market.java +++ b/src/main/java/foxz/utils/Market.java @@ -25,13 +25,13 @@ public class Market { private static final CacheHashMap marketCache = new CacheHashMap<>(5 * 60 * 1000, 1 * 60 * 1000); public static void save(RoleTrader r, String name) { - if(name.isEmpty()) + if (name.isEmpty()) return; NBTTagCompound roleCompound = r.writeNBT(new NBTTagCompound()); roleCompound.setString("SaveName", name); putMarketCache(name, roleCompound); - if(r.recordHistory) + if (r.recordHistory) return; saveFile(roleCompound); @@ -43,12 +43,12 @@ public class Market { File file1 = getFile(name); customNPCThread.execute(() -> { try { - if(ConfigMain.MarketDatFormat){ + if (ConfigMain.MarketDatFormat) { CompressedStreamTools.writeCompressed(compound, new FileOutputStream(file)); } else { NBTJsonUtil.SaveFile(file, compound); } - if(file1.exists()){ + if (file1.exists()) { file1.delete(); } file.renameTo(file1); @@ -58,9 +58,9 @@ public class Market { }); } - public static void getMarket(RoleTrader role, String name){ + public static void getMarket(RoleTrader role, String name) { NBTTagCompound data = getMarketCache(name); - if(data != null){ + if (data != null) { role.readNBT(data); return; } @@ -84,56 +84,53 @@ public class Market { } - static public void load(RoleTrader role, String name){ - if(role.npc.worldObj.isRemote) + static public void load(RoleTrader role, String name) { + if (role.npc.worldObj.isRemote) return; File file = getFile(name); - if(!file.exists()) + if (!file.exists()) return; try { - if(ConfigMain.MarketDatFormat){ + if (ConfigMain.MarketDatFormat) { NBTTagCompound compound = NBTJsonUtil.loadNBTData(file); role.readNBT(compound); - } - else { + } else { role.readNBT(NBTJsonUtil.LoadFile(file)); } } catch (Exception e) { } } - public static File getMarketDir(){ - try{ - File file = new File(CustomNpcs.getWorldSaveDirectory(),"markets"); - if(!file.exists()) + public static File getMarketDir() { + try { + File file = new File(CustomNpcs.getWorldSaveDirectory(), "markets"); + if (!file.exists()) file.mkdir(); return file; - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); return null; } } - public static File getNewMarketDir(){ - try{ - File file = new File(CustomNpcs.getWorldSaveDirectory(),"markets_new"); - if(file.exists()){ + public static File getNewMarketDir() { + try { + File file = new File(CustomNpcs.getWorldSaveDirectory(), "markets_new"); + if (file.exists()) { return null; } file.mkdir(); return file; - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); return null; } } - private static File getFile(String name){ + private static File getFile(String name) { String filename = name.toLowerCase(); - if(ConfigMain.MarketDatFormat){ + if (ConfigMain.MarketDatFormat) { filename += ".dat"; } else { filename += ".json"; @@ -143,27 +140,26 @@ public class Market { } static public void setMarket(EntityNPCInterface npc, String marketName) { - if(marketName.isEmpty()) + if (marketName.isEmpty()) return; - if(!getFile(marketName).exists()) + if (!getFile(marketName).exists()) Market.save((RoleTrader) npc.roleInterface, marketName); Market.getMarket((RoleTrader) npc.roleInterface, marketName); } - public static void convertMarketFiles(final EntityPlayerMP sender, final boolean type){ + public static void convertMarketFiles(final EntityPlayerMP sender, final boolean type) { ExecutorService executor = Executors.newSingleThreadExecutor(); executor.execute(() -> { String fileType; - if(type){ + if (type) { fileType = ".dat"; - } - else { + } else { fileType = ".json"; } - if(sender != null){ + if (sender != null) { LogWriter.info("Market Conversion queued by " + sender.getCommandSenderName()); sender.addChatMessage(new ChatComponentText("Market Conversion to " + fileType + " format")); } @@ -171,58 +167,58 @@ public class Market { File dir = getMarketDir(); LogWriter.info("Converting Market to " + fileType + " format"); File[] files = dir.listFiles(); // Get an array of all files in the directory - if(files != null){ + if (files != null) { int length = files.length; - if(length != 0){ - if(length > 100){ + if (length != 0) { + if (length > 100) { LogWriter.info("Found " + length + " Market files... This may take a few minutes"); } int tenPercent = (int) ((double) length * 0.1); int progress = 0; File saveDir = getNewMarketDir(); - if(saveDir == null){ - if(sender != null){ + if (saveDir == null) { + if (sender != null) { sender.addChatMessage(new ChatComponentText("markets_new folder already exists please delete it or rename it")); } LogWriter.error("markets_new folder already exists please delete it or rename it"); return; } // Load the files in parallel using a stream - for(int i = 0; i < length; i++){ + for (int i = 0; i < length; i++) { File file = files[i]; - if(file.isDirectory() || (!file.getName().endsWith(".json") && !file.getName().endsWith(".dat"))) + if (file.isDirectory() || (!file.getName().endsWith(".json") && !file.getName().endsWith(".dat"))) continue; try { String filename = "error"; boolean valid = false; NBTTagCompound compound = new NBTTagCompound(); - if(type){ - if(file.getName().endsWith(".json")){ + if (type) { + if (file.getName().endsWith(".json")) { compound = NBTJsonUtil.LoadFile(file); - if(compound.hasKey("PlayerName")) { + if (compound.hasKey("PlayerName")) { filename = file.getName().substring(0, file.getName().length() - 5); valid = true; } } } else { - if(file.getName().endsWith(".dat")){ + if (file.getName().endsWith(".dat")) { compound = NBTJsonUtil.loadNBTData(file); - if(compound.hasKey("PlayerName")){ + if (compound.hasKey("PlayerName")) { filename = file.getName().substring(0, file.getName().length() - 4); valid = true; } } } - if(valid){ + if (valid) { try { File newFile = new File(saveDir, filename + "_new" + fileType); File oldFile = new File(saveDir, filename + fileType); - if(type){ + if (type) { CompressedStreamTools.writeCompressed(compound, new FileOutputStream(newFile)); } else { NBTJsonUtil.SaveFile(newFile, compound); } - if(oldFile.exists()){ + if (oldFile.exists()) { oldFile.delete(); } newFile.renameTo(oldFile); @@ -233,8 +229,8 @@ public class Market { } catch (Exception e) { LogWriter.error("Error loading: " + file.getAbsolutePath(), e); } - if(tenPercent != 0 ){ - if(progress != 100){ + if (tenPercent != 0) { + if (progress != 100) { if (i % tenPercent == 0) { progress += 10; LogWriter.info("Converting Market: Progress: " + progress + "%"); @@ -244,7 +240,7 @@ public class Market { } } } - if(sender != null){ + if (sender != null) { sender.addChatMessage(new ChatComponentText("Market Conversion complete")); } LogWriter.info("Market Converted - Please rename the markets_new folder to markets and restart"); diff --git a/src/main/java/foxz/utils/Utils.java b/src/main/java/foxz/utils/Utils.java index 25549d3bc..932af117c 100644 --- a/src/main/java/foxz/utils/Utils.java +++ b/src/main/java/foxz/utils/Utils.java @@ -11,23 +11,23 @@ import java.util.List; public class Utils { - static public List getNearbeEntityFromPlayer(Class cls,EntityPlayerMP player, int dis) { + static public List getNearbeEntityFromPlayer(Class cls, EntityPlayerMP player, int dis) { AxisAlignedBB range = player.boundingBox.expand(dis, dis, dis); List list = player.worldObj.getEntitiesWithinAABB(cls, range); return list; } - static public EntityPlayer getOnlinePlayer(String playername){ + static public EntityPlayer getOnlinePlayer(String playername) { return MinecraftServer.getServer().getConfigurationManager().func_152612_a(playername); } - static public World getWorld(String t){ - WorldServer[] ws=MinecraftServer.getServer().worldServers; - for (WorldServer w:ws){ - if (w!=null){ - if ((w.provider.dimensionId + "").equalsIgnoreCase(t)){ - return w; - } + static public World getWorld(String t) { + WorldServer[] ws = MinecraftServer.getServer().worldServers; + for (WorldServer w : ws) { + if (w != null) { + if ((w.provider.dimensionId + "").equalsIgnoreCase(t)) { + return w; + } } } return null; diff --git a/src/main/java/kamkeel/npcs/CustomAttributes.java b/src/main/java/kamkeel/npcs/CustomAttributes.java index 58aa51cac..2caeee338 100644 --- a/src/main/java/kamkeel/npcs/CustomAttributes.java +++ b/src/main/java/kamkeel/npcs/CustomAttributes.java @@ -3,9 +3,9 @@ package kamkeel.npcs; import kamkeel.npcs.controllers.AttributeController; import kamkeel.npcs.controllers.data.attribute.AttributeDefinition; import kamkeel.npcs.controllers.data.attribute.AttributeValueType; +import kamkeel.npcs.controllers.data.attribute.requirement.RequirementCheckerRegistry; import kamkeel.npcs.controllers.data.attribute.requirement.types.QuestActiveRequirement; import kamkeel.npcs.controllers.data.attribute.requirement.types.QuestCompletedRequirement; -import kamkeel.npcs.controllers.data.attribute.requirement.RequirementCheckerRegistry; /** * ModAttributes registers the core attributes (both non–magic and magic–based). @@ -38,7 +38,7 @@ public class CustomAttributes { public static AttributeDefinition MAGIC_DEFENSE; public static AttributeDefinition MAGIC_RESISTANCE; - public CustomAttributes(){ + public CustomAttributes() { HEALTH = AttributeController.registerAttribute(HEALTH_KEY, "Health", 'c', AttributeValueType.FLAT, AttributeDefinition.AttributeSection.BASE); MAIN_ATTACK = AttributeController.registerAttribute(MAIN_ATTACK_KEY, "Main Attack Damage", '4', AttributeValueType.FLAT, AttributeDefinition.AttributeSection.BASE); diff --git a/src/main/java/kamkeel/npcs/addon/AddonManager.java b/src/main/java/kamkeel/npcs/addon/AddonManager.java index 24b58dc3e..35c237c1e 100644 --- a/src/main/java/kamkeel/npcs/addon/AddonManager.java +++ b/src/main/java/kamkeel/npcs/addon/AddonManager.java @@ -9,12 +9,12 @@ public class AddonManager { // Manager class to easily disable mixin manipulated // addons for debugging and testing - public AddonManager(){ + public AddonManager() { Instance = this; load(); } - public void load(){ + public void load() { // Gecko Addon Initialization new GeckoAddon(); new GeckoAddonClient(); diff --git a/src/main/java/kamkeel/npcs/addon/DBCAddon.java b/src/main/java/kamkeel/npcs/addon/DBCAddon.java index 4e4ff5371..ff290e9d2 100644 --- a/src/main/java/kamkeel/npcs/addon/DBCAddon.java +++ b/src/main/java/kamkeel/npcs/addon/DBCAddon.java @@ -18,7 +18,7 @@ public class DBCAddon { * The Addon Mod will replace all blank functions within * this class to change the ongoing code. */ - public DBCAddon(){ + public DBCAddon() { instance = this; } @@ -26,21 +26,29 @@ public class DBCAddon { return Loader.isModLoaded("npcdbc"); } - public void dbcCopyData(EntityLivingBase copied, EntityLivingBase entity){} + public void dbcCopyData(EntityLivingBase copied, EntityLivingBase entity) { + } // AI / STATS - public boolean canDBCAttack(EntityNPCInterface npc, float attackStrength, Entity receiver){ + public boolean canDBCAttack(EntityNPCInterface npc, float attackStrength, Entity receiver) { return false; } - public void doDBCDamage(EntityNPCInterface npc, float attackStrength, Entity receiver){} - public boolean isKO(EntityNPCInterface npc, EntityPlayer player){ + + public void doDBCDamage(EntityNPCInterface npc, float attackStrength, Entity receiver) { + } + + public boolean isKO(EntityNPCInterface npc, EntityPlayer player) { return false; } // PlayerData NBT - public void writeToNBT(PlayerData playerData, NBTTagCompound nbtTagCompound){} - public void readFromNBT(PlayerData playerData, NBTTagCompound nbtTagCompound){} + public void writeToNBT(PlayerData playerData, NBTTagCompound nbtTagCompound) { + } + + public void readFromNBT(PlayerData playerData, NBTTagCompound nbtTagCompound) { + } // Client Sync - public void syncPlayer(EntityPlayerMP playerMP){} + public void syncPlayer(EntityPlayerMP playerMP) { + } } diff --git a/src/main/java/kamkeel/npcs/addon/GeckoAddon.java b/src/main/java/kamkeel/npcs/addon/GeckoAddon.java index ee0f72141..8fa2742ba 100644 --- a/src/main/java/kamkeel/npcs/addon/GeckoAddon.java +++ b/src/main/java/kamkeel/npcs/addon/GeckoAddon.java @@ -11,10 +11,11 @@ public class GeckoAddon { * The Addon Mod will replace all blank functions within * this class to change the ongoing code. */ - public GeckoAddon(){ + public GeckoAddon() { instance = this; } - public void geckoCopyData(EntityLivingBase copied, EntityLivingBase entity){} + public void geckoCopyData(EntityLivingBase copied, EntityLivingBase entity) { + } } diff --git a/src/main/java/kamkeel/npcs/addon/client/DBCClient.java b/src/main/java/kamkeel/npcs/addon/client/DBCClient.java index 9f839936b..4bb807010 100644 --- a/src/main/java/kamkeel/npcs/addon/client/DBCClient.java +++ b/src/main/java/kamkeel/npcs/addon/client/DBCClient.java @@ -17,20 +17,29 @@ public class DBCClient { * The fewer classes modified by mixins the safer. * These are for mixins affecting only client-side classes. */ - public DBCClient(){ + public DBCClient() { Instance = this; } // Stat Buttons - public void showDBCStatButtons(GuiNpcStats stats, EntityLivingBase entity){} - public void showDBCStatActionPerformed(GuiNpcStats stats, GuiNpcButton btn){} + public void showDBCStatButtons(GuiNpcStats stats, EntityLivingBase entity) { + } + + public void showDBCStatActionPerformed(GuiNpcStats stats, GuiNpcButton btn) { + } // Render Auras - public void renderDBCAuras(EntityNPCInterface npcInterface){} + public void renderDBCAuras(EntityNPCInterface npcInterface) { + } // Manage Custom Forms - public GuiNPCInterface2 manageCustomForms(EntityNPCInterface npcInterface){ return null; } + public GuiNPCInterface2 manageCustomForms(EntityNPCInterface npcInterface) { + return null; + } + // Manage Custom Forms - public GuiNPCInterface2 manageCustomAuras(EntityNPCInterface npcInterface){ return null; } + public GuiNPCInterface2 manageCustomAuras(EntityNPCInterface npcInterface) { + return null; + } } diff --git a/src/main/java/kamkeel/npcs/addon/client/GeckoAddonClient.java b/src/main/java/kamkeel/npcs/addon/client/GeckoAddonClient.java index f014b07ad..dfb126fcd 100644 --- a/src/main/java/kamkeel/npcs/addon/client/GeckoAddonClient.java +++ b/src/main/java/kamkeel/npcs/addon/client/GeckoAddonClient.java @@ -19,19 +19,29 @@ public class GeckoAddonClient { * The fewer classes modified by mixins the safer. * These are for mixins affecting only client-side classes. */ - public GeckoAddonClient(){ + public GeckoAddonClient() { Instance = this; } // Creation Screen Mixins - public void showGeckoButtons(GuiCreationScreen creationScreen, EntityLivingBase entity){} - public void geckoGuiCreationScreenActionPerformed(GuiCreationScreen creationScreen, GuiNpcButton btn){} + public void showGeckoButtons(GuiCreationScreen creationScreen, EntityLivingBase entity) { + } + + public void geckoGuiCreationScreenActionPerformed(GuiCreationScreen creationScreen, GuiNpcButton btn) { + } // Npc Display Mixins - public void geckoNpcDisplayInitGui(GuiNPCInterface2 guiNPCInterface){} - public void geckoNpcDisplayActionPerformed(GuiNPCInterface2 guiNPCInterface, GuiNpcButton btn){} + public void geckoNpcDisplayInitGui(GuiNPCInterface2 guiNPCInterface) { + } + + public void geckoNpcDisplayActionPerformed(GuiNPCInterface2 guiNPCInterface, GuiNpcButton btn) { + } // Render Npc Mixins - public boolean isGeckoModel(ModelBase mainModel){ return false;} - public void geckoRenderModel(ModelMPM mainModel, EntityNPCInterface npc, float rotationYaw, float renderPartialTicks) {} + public boolean isGeckoModel(ModelBase mainModel) { + return false; + } + + public void geckoRenderModel(ModelMPM mainModel, EntityNPCInterface npc, float rotationYaw, float renderPartialTicks) { + } } diff --git a/src/main/java/kamkeel/npcs/command/AnimationCommand.java b/src/main/java/kamkeel/npcs/command/AnimationCommand.java index e8388e802..99d3ba554 100644 --- a/src/main/java/kamkeel/npcs/command/AnimationCommand.java +++ b/src/main/java/kamkeel/npcs/command/AnimationCommand.java @@ -14,22 +14,22 @@ import static kamkeel.npcs.util.ColorUtil.sendResult; public class AnimationCommand extends CommandKamkeelBase { - @Override - public String getCommandName() { - return "animation"; - } + @Override + public String getCommandName() { + return "animation"; + } - @Override - public String getDescription() { - return "Animation operations"; - } + @Override + public String getDescription() { + return "Animation operations"; + } @SubCommand( - desc = "set an animation to a player", - usage = " " + desc = "set an animation to a player", + usage = " " ) - public void set(ICommandSender sender, String args[]) throws CommandException{ - String playername=args[0]; + public void set(ICommandSender sender, String args[]) throws CommandException { + String playername = args[0]; int animationId; try { animationId = Integer.parseInt(args[1]); @@ -44,12 +44,12 @@ public class AnimationCommand extends CommandKamkeelBase { } IAnimation animation = AnimationController.getInstance().get(animationId); - if(animation == null){ + if (animation == null) { sendError(sender, "No Animation ID found: " + animationId); return; } - for(PlayerData playerdata : data){ + for (PlayerData playerdata : data) { playerdata.animationData.setEnabled(false); playerdata.animationData.setAnimation(animation); playerdata.animationData.updateClient(); @@ -60,18 +60,18 @@ public class AnimationCommand extends CommandKamkeelBase { } @SubCommand( - desc = "clear an animation from a player", - usage = "" + desc = "clear an animation from a player", + usage = "" ) - public void clear(ICommandSender sender, String args[]) throws CommandException{ - String playername=args[0]; + public void clear(ICommandSender sender, String args[]) throws CommandException { + String playername = args[0]; List data = PlayerDataController.Instance.getPlayersData(sender, playername); if (data.isEmpty()) { sendError(sender, "Unknown player: " + playername); return; } - for(PlayerData playerdata : data){ + for (PlayerData playerdata : data) { playerdata.animationData.setEnabled(false); playerdata.animationData.setAnimation(null); playerdata.animationData.updateClient(); @@ -82,19 +82,19 @@ public class AnimationCommand extends CommandKamkeelBase { } @SubCommand( - desc = "enable an animation on a player", - usage = "" + desc = "enable an animation on a player", + usage = "" ) - public void enable(ICommandSender sender, String args[]) throws CommandException{ - String playername=args[0]; + public void enable(ICommandSender sender, String args[]) throws CommandException { + String playername = args[0]; List data = PlayerDataController.Instance.getPlayersData(sender, playername); if (data.isEmpty()) { sendError(sender, "Unknown player: " + playername); return; } - for(PlayerData playerdata : data){ - if(playerdata.animationData.getAnimation() == null){ + for (PlayerData playerdata : data) { + if (playerdata.animationData.getAnimation() == null) { sendError(sender, String.format("Player '\u00A7b%s\u00A74' does not have an animation set", playerdata.playername)); return; } @@ -108,19 +108,19 @@ public class AnimationCommand extends CommandKamkeelBase { } @SubCommand( - desc = "disable an animation on a player", - usage = "" + desc = "disable an animation on a player", + usage = "" ) - public void disable(ICommandSender sender, String args[]) throws CommandException{ - String playername=args[0]; + public void disable(ICommandSender sender, String args[]) throws CommandException { + String playername = args[0]; List data = PlayerDataController.Instance.getPlayersData(sender, playername); if (data.isEmpty()) { sendError(sender, "Unknown player: " + playername); return; } - for(PlayerData playerdata : data){ - if(playerdata.animationData.getAnimation() == null){ + for (PlayerData playerdata : data) { + if (playerdata.animationData.getAnimation() == null) { sendError(sender, String.format("Player '\u00A7b%s\u00A74' does not have an animation set", playerdata.playername)); return; } @@ -134,7 +134,7 @@ public class AnimationCommand extends CommandKamkeelBase { } @SubCommand( - desc = "reload animations" + desc = "reload animations" ) public void reload(ICommandSender sender, String args[]) { AnimationController.Instance.load(); diff --git a/src/main/java/kamkeel/npcs/command/AttributeCommand.java b/src/main/java/kamkeel/npcs/command/AttributeCommand.java index 5a964db85..1fe62ca6e 100644 --- a/src/main/java/kamkeel/npcs/command/AttributeCommand.java +++ b/src/main/java/kamkeel/npcs/command/AttributeCommand.java @@ -1,20 +1,20 @@ package kamkeel.npcs.command; +import kamkeel.npcs.controllers.AttributeController; +import kamkeel.npcs.controllers.data.attribute.AttributeDefinition; +import kamkeel.npcs.controllers.data.attribute.AttributeValueType; +import kamkeel.npcs.util.AttributeItemUtil; +import net.minecraft.command.CommandException; +import net.minecraft.command.ICommandSender; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import noppes.npcs.controllers.MagicController; + import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; import java.util.List; -import net.minecraft.command.CommandException; -import net.minecraft.command.ICommandSender; -import net.minecraft.item.ItemStack; -import net.minecraft.entity.player.EntityPlayer; -import kamkeel.npcs.controllers.AttributeController; -import kamkeel.npcs.controllers.data.attribute.AttributeDefinition; -import kamkeel.npcs.controllers.data.attribute.AttributeValueType; -import kamkeel.npcs.util.AttributeItemUtil; -import noppes.npcs.controllers.MagicController; - import static kamkeel.npcs.util.ColorUtil.sendError; import static kamkeel.npcs.util.ColorUtil.sendResult; @@ -38,7 +38,7 @@ public class AttributeCommand extends CommandKamkeelBase { public void list(ICommandSender sender, String[] args) throws CommandException { // Get all registered attributes. List defs = new ArrayList(AttributeController.getAllAttributes()); - if(defs.isEmpty()){ + if (defs.isEmpty()) { sendError(sender, "No attributes found."); return; } @@ -52,18 +52,18 @@ public class AttributeCommand extends CommandKamkeelBase { // Determine which page to show. int page = 1; - if(args.length > 0) { + if (args.length > 0) { try { page = Integer.parseInt(args[0]); - } catch(NumberFormatException e) { + } catch (NumberFormatException e) { // If parsing fails, default to page 1. } } int perPage = 10; int total = defs.size(); - int totalPages = (int)Math.ceil(total / (double) perPage); - if(page < 1) page = 1; - if(page > totalPages) page = totalPages; + int totalPages = (int) Math.ceil(total / (double) perPage); + if (page < 1) page = 1; + if (page > totalPages) page = totalPages; int startIndex = (page - 1) * perPage; int endIndex = Math.min(startIndex + perPage, total); @@ -85,28 +85,28 @@ public class AttributeCommand extends CommandKamkeelBase { desc = "Applies an attribute to your held item. For magic attributes, provide a magicID." ) public void apply(ICommandSender sender, String[] args) throws CommandException { - if(!(sender instanceof EntityPlayer)){ + if (!(sender instanceof EntityPlayer)) { sendError(sender, "Only players can use this command."); return; } - EntityPlayer player = (EntityPlayer)sender; + EntityPlayer player = (EntityPlayer) sender; ItemStack held = player.getHeldItem(); - if(held == null){ + if (held == null) { sendError(sender, "You are not holding an item."); return; } String attrKey = args[0]; AttributeDefinition def = AttributeController.getAttribute(attrKey); - if(def == null){ + if (def == null) { sendError(sender, "Unknown attribute: " + attrKey); return; } // Check if this is a magic attribute. - if(def.getValueType() == AttributeValueType.MAGIC) { - if(args.length < 3){ + if (def.getValueType() == AttributeValueType.MAGIC) { + if (args.length < 3) { sendError(sender, "Usage for magic attribute: apply "); return; } @@ -115,12 +115,12 @@ public class AttributeCommand extends CommandKamkeelBase { try { value = Float.parseFloat(args[1]); magicId = Integer.parseInt(args[2]); - } catch(NumberFormatException e) { + } catch (NumberFormatException e) { sendError(sender, "Invalid number format for magicID or value."); return; } - if(MagicController.getInstance().getMagic(magicId) == null){ + if (MagicController.getInstance().getMagic(magicId) == null) { sendError(sender, "No Magic Found for Magic ID %d", magicId); return; } @@ -128,14 +128,14 @@ public class AttributeCommand extends CommandKamkeelBase { AttributeItemUtil.writeMagicAttribute(held, attrKey, magicId, value); sendResult(sender, "Applied magic attribute " + attrKey + " with magicID " + magicId + " and value " + value + " to held item."); } else { - if(args.length < 2){ + if (args.length < 2) { sendError(sender, "Usage: "); return; } float value; try { value = Float.parseFloat(args[1]); - } catch(NumberFormatException e) { + } catch (NumberFormatException e) { sendError(sender, "Invalid number format for value."); return; } @@ -150,38 +150,38 @@ public class AttributeCommand extends CommandKamkeelBase { desc = "Removes an attribute from your held item. For magic attributes, provide a magicID." ) public void remove(ICommandSender sender, String[] args) throws CommandException { - if(!(sender instanceof EntityPlayer)){ + if (!(sender instanceof EntityPlayer)) { sendError(sender, "Only players can use this command."); return; } - EntityPlayer player = (EntityPlayer)sender; + EntityPlayer player = (EntityPlayer) sender; ItemStack held = player.getHeldItem(); - if(held == null){ + if (held == null) { sendError(sender, "You are not holding an item."); return; } String attrKey = args[0]; AttributeDefinition def = AttributeController.getAttribute(attrKey); - if(def == null){ + if (def == null) { sendError(sender, "Unknown attribute: " + attrKey); return; } - if(def.getValueType() == AttributeValueType.MAGIC) { - if(args.length < 2){ + if (def.getValueType() == AttributeValueType.MAGIC) { + if (args.length < 2) { sendError(sender, "Usage for magic attribute: remove "); return; } int magicId; try { magicId = Integer.parseInt(args[1]); - } catch(NumberFormatException e) { + } catch (NumberFormatException e) { sendError(sender, "Invalid magicID format."); return; } - if(MagicController.getInstance().getMagic(magicId) == null){ + if (MagicController.getInstance().getMagic(magicId) == null) { sendError(sender, "No Magic Found for Magic ID %d", magicId); return; } diff --git a/src/main/java/kamkeel/npcs/command/CloneCommand.java b/src/main/java/kamkeel/npcs/command/CloneCommand.java index 3ce2f02b8..ac3d29606 100644 --- a/src/main/java/kamkeel/npcs/command/CloneCommand.java +++ b/src/main/java/kamkeel/npcs/command/CloneCommand.java @@ -21,31 +21,30 @@ import static kamkeel.npcs.util.ColorUtil.*; public class CloneCommand extends CommandKamkeelBase { - @Override - public String getCommandName() { - return "clone"; - } + @Override + public String getCommandName() { + return "clone"; + } - @Override - public String getDescription() { - return "Clone operation (server side)"; - } + @Override + public String getDescription() { + return "Clone operation (server side)"; + } @SubCommand( - desc = "Add NPC(s) to clone storage", - usage = " [clonedname]", - permission = 4 + desc = "Add NPC(s) to clone storage", + usage = " [clonedname]", + permission = 4 ) public void add(ICommandSender sender, String[] args) { int tab = 0; - try{ - tab = Integer.parseInt(args[1]); - if(tab < 0 || tab > 15){ + try { + tab = Integer.parseInt(args[1]); + if (tab < 0 || tab > 15) { sendError(sender, "Tab must be within 1-15"); return; } - } - catch(NumberFormatException ex){ + } catch (NumberFormatException ex) { sendError(sender, String.format("Tab is not a number: %s", args[1])); return; } @@ -60,31 +59,30 @@ public class CloneCommand extends CommandKamkeelBase { if (args.length > 2) { name = args[2]; } - NBTTagCompound compound = new NBTTagCompound(); - if(!npc.writeToNBTOptional(compound)) - return; - ServerCloneController.Instance.addClone(compound, name, tab); + NBTTagCompound compound = new NBTTagCompound(); + if (!npc.writeToNBTOptional(compound)) + return; + ServerCloneController.Instance.addClone(compound, name, tab); sendResult(sender, String.format("Added NPC \u00A7e%s\u00A77 to Tab \u00A7b%d\u00A77", name, tab)); } } } @SubCommand( - desc = "List NPC from clone storage", - usage = "", - permission = 2 + desc = "List NPC from clone storage", + usage = "", + permission = 2 ) public void list(ICommandSender sender, String[] args) { sendMessage(sender, "--- Stored NPCs --- (server side)"); int tab = 0; - try{ + try { tab = Integer.parseInt(args[1]); - if(tab < 0 || tab > 15){ + if (tab < 0 || tab > 15) { sendError(sender, "Tab must be within 1-15"); return; } - } - catch(NumberFormatException ex){ + } catch (NumberFormatException ex) { sendError(sender, String.format("Tab is not a number: %s", args[1])); return; } @@ -96,32 +94,31 @@ public class CloneCommand extends CommandKamkeelBase { } @SubCommand( - desc = "Remove NPC from clone storage", - usage = " ", - permission = 4 + desc = "Remove NPC from clone storage", + usage = " ", + permission = 4 ) public void del(ICommandSender sender, String[] args) throws CommandException { String nametodel = args[0]; int tab = 0; - try{ + try { tab = Integer.parseInt(args[1]); - if(tab < 0 || tab > 15){ + if (tab < 0 || tab > 15) { sendError(sender, String.format("Tab must be within 1-15")); return; } - } - catch(NumberFormatException ex){ + } catch (NumberFormatException ex) { sendError(sender, String.format("Tab is not a number: %s", args[1])); return; } boolean deleted = false; - for(String name : ServerCloneController.Instance.getClones(tab)){ - if(nametodel.equalsIgnoreCase(name)){ - ServerCloneController.Instance.removeClone(name, tab); - deleted = true; - break; - } + for (String name : ServerCloneController.Instance.getClones(tab)) { + if (nametodel.equalsIgnoreCase(name)) { + ServerCloneController.Instance.removeClone(name, tab); + deleted = true; + break; + } } if (!ServerCloneController.Instance.removeClone(nametodel, tab)) { sendError(sender, String.format("NPC '%s' was not found", nametodel)); @@ -131,28 +128,27 @@ public class CloneCommand extends CommandKamkeelBase { } @SubCommand( - desc = "Spawn cloned NPC", - usage = " [[world:]x,y,z]] [newname]", - permission = 2 + desc = "Spawn cloned NPC", + usage = " [[world:]x,y,z]] [newname]", + permission = 2 ) public void spawn(ICommandSender sender, String[] args) throws CommandException { String name = args[0].replaceAll("%", " "); // if name of npc separed by space, user must use % in place of space int tab = 0; - try{ + try { tab = Integer.parseInt(args[1]); - if(tab < 0 || tab > 15){ + if (tab < 0 || tab > 15) { sendError(sender, String.format("Tab must be within 1-15")); return; } - } - catch(NumberFormatException ex){ + } catch (NumberFormatException ex) { sendError(sender, String.format("Tab is not a number: %s", args[1])); return; } - String newname=null; + String newname = null; NBTTagCompound compound = ServerCloneController.Instance.getCloneData(sender, name, tab); - if(compound == null){ + if (compound == null) { sendError(sender, "Unknown npc"); return; } @@ -161,34 +157,34 @@ public class CloneCommand extends CommandKamkeelBase { double posY = sender.getPlayerCoordinates().posY; double posZ = sender.getPlayerCoordinates().posZ; - if(args.length > 2){ + if (args.length > 2) { String location = args[2]; String[] par; - if (location.contains(":")){ + if (location.contains(":")) { par = location.split(":"); location = par[1]; world = Utils.getWorld(par[0]); - if (world == null){ + if (world == null) { sendError(sender, String.format("'%s' is an unknown world", par[0])); return; } } - if (location.contains(",")){ + if (location.contains(",")) { par = location.split(","); - if (par.length != 3){ + if (par.length != 3) { sendError(sender, "Location need be x,y,z"); return; } - try{ + try { posX = func_110666_a(sender, posX, par[0]); posY = func_110665_a(sender, posY, par[1].trim(), 0, 0); posZ = func_110666_a(sender, posZ, par[2]); - } catch(NumberFormatException ex){ + } catch (NumberFormatException ex) { sendError(sender, "Location should be in numbers"); return; } - if (args.length > 3){ + if (args.length > 3) { newname = args[3]; } } else { @@ -196,56 +192,54 @@ public class CloneCommand extends CommandKamkeelBase { } } - if (posX == 0 && posY == 0 && posZ == 0){//incase it was called from the console and not pos was given + if (posX == 0 && posY == 0 && posZ == 0) {//incase it was called from the console and not pos was given sendError(sender, "Location needed"); return; } Entity entity = EntityList.createEntityFromNBT(compound, world); entity.setPosition(posX + 0.5, posY + 1, posZ + 0.5); - if(entity instanceof EntityNPCInterface){ + if (entity instanceof EntityNPCInterface) { EntityNPCInterface npc = (EntityNPCInterface) entity; npc.ais.startPos = new int[]{MathHelper.floor_double(posX), MathHelper.floor_double(posY), MathHelper.floor_double(posZ)}; - if(newname != null && !newname.isEmpty()) + if (newname != null && !newname.isEmpty()) npc.display.name = newname.replaceAll("%", " "); // like name, newname must use % in place of space to keep a logical way } world.spawnEntityInWorld(entity); } @SubCommand( - desc = "Spawn cloned NPC", - usage = " [[world:]x,y,z]] [newname]", - permission = 2 + desc = "Spawn cloned NPC", + usage = " [[world:]x,y,z]] [newname]", + permission = 2 ) public void grid(ICommandSender sender, String[] args) throws CommandException { String name = args[0].replaceAll("%", " "); // if name of npc separed by space, user must use % in place of space int tab = 0; - try{ + try { tab = Integer.parseInt(args[1]); - if(tab < 0 || tab > 15){ + if (tab < 0 || tab > 15) { sendError(sender, String.format("Tab must be within 1-15")); return; } - } - catch(NumberFormatException ex){ + } catch (NumberFormatException ex) { sendError(sender, String.format("Tab is not a number: %s", args[1])); return; } int width, height; - try{ + try { width = Integer.parseInt(args[2]); height = Integer.parseInt(args[3]); - } - catch(NumberFormatException ex){ + } catch (NumberFormatException ex) { sendError(sender, "length or width was not a number"); return; } - String newname=null; + String newname = null; NBTTagCompound compound = ServerCloneController.Instance.getCloneData(sender, name, tab); - if(compound == null){ + if (compound == null) { sendError(sender, "Unknown npc"); return; } @@ -254,33 +248,33 @@ public class CloneCommand extends CommandKamkeelBase { double posY = sender.getPlayerCoordinates().posY; double posZ = sender.getPlayerCoordinates().posZ; - if(args.length > 4){ + if (args.length > 4) { String location = args[4]; String[] par; - if (location.contains(":")){ + if (location.contains(":")) { par = location.split(":"); location = par[1]; world = Utils.getWorld(par[0]); - if (world == null){ + if (world == null) { sendError(sender, String.format("'%s' is an unknown world", par[0])); } } - if (location.contains(",")){ + if (location.contains(",")) { par = location.split(","); - if (par.length != 3){ + if (par.length != 3) { sendError(sender, "Location need be x,y,z"); return; } - try{ + try { posX = func_110666_a(sender, posX, par[0]); posY = func_110665_a(sender, posY, par[1].trim(), 0, 0); posZ = func_110666_a(sender, posZ, par[2]); - } catch(NumberFormatException ex){ + } catch (NumberFormatException ex) { sendError(sender, "Location should be in numbers"); return; } - if (args.length > 5){ + if (args.length > 5) { newname = args[5]; } } else { @@ -288,31 +282,31 @@ public class CloneCommand extends CommandKamkeelBase { } } - if (posX == 0 && posY == 0 && posZ == 0){//incase it was called from the console and not pos was given + if (posX == 0 && posY == 0 && posZ == 0) {//incase it was called from the console and not pos was given sendError(sender, "Location needed"); return; } - for(int x = 0; x < width; x++){ - for(int z = 0; z < height; z++){ + for (int x = 0; x < width; x++) { + for (int z = 0; z < height; z++) { Entity entity = EntityList.createEntityFromNBT(compound, world); int xx = MathHelper.floor_double(posX) + x; int yy = Math.max(MathHelper.floor_double(posY) - 2, 1); int zz = MathHelper.floor_double(posZ) + z; - for(int y = 0; y < 10; y++){ + for (int y = 0; y < 10; y++) { Block b = world.getBlock(xx, yy + y, zz); Block b2 = world.getBlock(xx, yy + y + 1, zz); - if(b != null && (b2 == null || b2.getCollisionBoundingBoxFromPool(world, xx, yy + y + 1, zz) == null)){ + if (b != null && (b2 == null || b2.getCollisionBoundingBoxFromPool(world, xx, yy + y + 1, zz) == null)) { yy += y; break; } } entity.setPosition(posX + 0.5 + x, yy + 1, posZ + 0.5 + z); - if(entity instanceof EntityNPCInterface){ + if (entity instanceof EntityNPCInterface) { EntityNPCInterface npc = (EntityNPCInterface) entity; npc.ais.startPos = new int[]{xx, yy, zz}; - if(newname != null && !newname.isEmpty()) + if (newname != null && !newname.isEmpty()) npc.display.name = newname.replaceAll("%", " "); // like name, newname must use % in place of space to keep a logical way } world.spawnEntityInWorld(entity); @@ -321,13 +315,13 @@ public class CloneCommand extends CommandKamkeelBase { return; } - public World getWorld(String t){ - WorldServer[] ws=MinecraftServer.getServer().worldServers; - for (WorldServer w:ws){ - if (w!=null){ - if ((w.provider.dimensionId + "").equalsIgnoreCase(t)){ - return w; - } + public World getWorld(String t) { + WorldServer[] ws = MinecraftServer.getServer().worldServers; + for (WorldServer w : ws) { + if (w != null) { + if ((w.provider.dimensionId + "").equalsIgnoreCase(t)) { + return w; + } } } return null; diff --git a/src/main/java/kamkeel/npcs/command/CommandKamkeel.java b/src/main/java/kamkeel/npcs/command/CommandKamkeel.java index 4e0b26afd..306176669 100644 --- a/src/main/java/kamkeel/npcs/command/CommandKamkeel.java +++ b/src/main/java/kamkeel/npcs/command/CommandKamkeel.java @@ -1,5 +1,7 @@ package kamkeel.npcs.command; +import kamkeel.npcs.controllers.AttributeController; +import kamkeel.npcs.controllers.data.attribute.AttributeDefinition; import kamkeel.npcs.controllers.data.attribute.requirement.RequirementCheckerRegistry; import net.minecraft.command.CommandBase; import net.minecraft.command.CommandException; @@ -7,8 +9,6 @@ import net.minecraft.command.ICommandSender; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.server.MinecraftServer; import noppes.npcs.CustomNpcsPermissions; -import kamkeel.npcs.controllers.AttributeController; -import kamkeel.npcs.controllers.data.attribute.AttributeDefinition; import noppes.npcs.config.ConfigMain; import noppes.npcs.scripted.CustomNPCsException; @@ -17,13 +17,13 @@ import java.util.*; import static kamkeel.npcs.command.EffectCommand.getSortedEffectNames; -public class CommandKamkeel extends CommandBase{ +public class CommandKamkeel extends CommandBase { public Map map = new HashMap(); public HelpCommand help = new HelpCommand(this); public String[] alias = {"kam"}; - public CommandKamkeel(){ + public CommandKamkeel() { registerCommand(help); registerCommand(new ScriptCommand()); registerCommand(new SlayCommand()); @@ -39,13 +39,13 @@ public class CommandKamkeel extends CommandBase{ registerCommand(new OverlayCommand()); registerCommand(new CommandCommand()); registerCommand(new EffectCommand()); - if(ConfigMain.AttributesEnabled) + if (ConfigMain.AttributesEnabled) registerCommand(new AttributeCommand()); } - public void registerCommand(CommandKamkeelBase command){ + public void registerCommand(CommandKamkeelBase command) { String name = command.getCommandName().toLowerCase(); - if(map.containsKey(name)) + if (map.containsKey(name)) throw new CustomNPCsException("Already a subcommand with the name: " + name); map.put(name, command); } @@ -56,8 +56,7 @@ public class CommandKamkeel extends CommandBase{ } @Override - public List getCommandAliases() - { + public List getCommandAliases() { return Arrays.asList(alias); } @@ -68,25 +67,25 @@ public class CommandKamkeel extends CommandBase{ @Override public void processCommand(ICommandSender sender, String[] args) throws CommandException { - if(args.length == 0){ + if (args.length == 0) { help.processCommand(sender, args); return; } CommandKamkeelBase command = getCommand(args); - if(command == null) + if (command == null) throw new CommandException("Unknown command " + args[0]); args = Arrays.copyOfRange(args, 1, args.length); - if(command.subcommands.isEmpty() || !command.runSubCommands()){ - if(!canSendCommand(sender, command)) + if (command.subcommands.isEmpty() || !command.runSubCommands()) { + if (!canSendCommand(sender, command)) throw new CommandException("You are not allowed to use this command: " + command); command.canRun(sender, command.getUsage(), args); command.processCommand(sender, args); return; } - if(args.length == 0){ + if (args.length == 0) { help.processCommand(sender, new String[]{command.getCommandName()}); return; } @@ -95,28 +94,27 @@ public class CommandKamkeel extends CommandBase{ } @Override - public List addTabCompletionOptions(ICommandSender sender, String[] args){ - if(args.length == 1) + public List addTabCompletionOptions(ICommandSender sender, String[] args) { + if (args.length == 1) return CommandBase.getListOfStringsMatchingLastWord(args, map.keySet().toArray(new String[map.size()])); CommandKamkeelBase command = getCommand(args); - if(command == null) + if (command == null) return null; - if(args.length == 2 && command.runSubCommands()) + if (args.length == 2 && command.runSubCommands()) return CommandBase.getListOfStringsMatchingLastWord(args, command.subcommands.keySet().toArray(new String[command.subcommands.keySet().size()])); String[] useArgs = command.getUsage().split(" "); - if(command.runSubCommands()) { + if (command.runSubCommands()) { Method m = command.subcommands.get(args[1].toLowerCase()); - if(m != null) { + if (m != null) { useArgs = m.getAnnotation(CommandKamkeelBase.SubCommand.class).usage().split(" "); } } - if(args.length <= useArgs.length + 2) { - if(args.length - 3 >= 0){ + if (args.length <= useArgs.length + 2) { + if (args.length - 3 >= 0) { String usage = useArgs[args.length - 3]; - if(usage.equals("") || usage.equals("[player]")) { + if (usage.equals("") || usage.equals("[player]")) { return CommandBase.getListOfStringsMatchingLastWord(args, MinecraftServer.getServer().getAllUsernames()); - } - else if(usage.equals("")) { + } else if (usage.equals("")) { List keys = new ArrayList<>(); for (AttributeDefinition def : AttributeController.getAllAttributes()) { keys.add(def.getKey()); @@ -125,7 +123,7 @@ public class CommandKamkeel extends CommandBase{ } else if (usage.equals("")) { List keys = new ArrayList<>(RequirementCheckerRegistry.getAllKeys()); return CommandBase.getListOfStringsMatchingLastWord(args, keys.toArray(new String[keys.size()])); - } else if(usage.equals("")){ + } else if (usage.equals("")) { List keys = getSortedEffectNames(); return CommandBase.getListOfStringsMatchingLastWord(args, keys.toArray(new String[keys.size()])); } @@ -134,35 +132,35 @@ public class CommandKamkeel extends CommandBase{ return command.addTabCompletionOptions(sender, Arrays.copyOfRange(args, 1, args.length)); } - public CommandKamkeelBase getCommand(String[] args){ - if(args.length == 0) + public CommandKamkeelBase getCommand(String[] args) { + if (args.length == 0) return null; return map.get(args[0].toLowerCase()); } @Override - public int getRequiredPermissionLevel(){ + public int getRequiredPermissionLevel() { return 2; } - public static String getCommandPermission(String command){ + public static String getCommandPermission(String command) { return "cnpc.kamkeel." + command.toLowerCase(); } - public static String getUniversalPermission(){ + public static String getUniversalPermission() { return "cnpc.kamkeel.*"; } - public static boolean canSendCommand(ICommandSender sender, CommandKamkeelBase command){ - if(sender.canCommandSenderUseCommand(command.getRequiredPermissionLevel(), getUniversalPermission())){ + public static boolean canSendCommand(ICommandSender sender, CommandKamkeelBase command) { + if (sender.canCommandSenderUseCommand(command.getRequiredPermissionLevel(), getUniversalPermission())) { return true; } - if(sender.canCommandSenderUseCommand(command.getRequiredPermissionLevel(), getCommandPermission(command.getCommandName()))){ + if (sender.canCommandSenderUseCommand(command.getRequiredPermissionLevel(), getCommandPermission(command.getCommandName()))) { return true; } - if(sender instanceof EntityPlayer){ + if (sender instanceof EntityPlayer) { return CustomNpcsPermissions.hasCustomPermission((EntityPlayer) sender, getCommandPermission(command.getCommandName())); } diff --git a/src/main/java/kamkeel/npcs/command/CommandKamkeelBase.java b/src/main/java/kamkeel/npcs/command/CommandKamkeelBase.java index cc874f392..af2366f89 100644 --- a/src/main/java/kamkeel/npcs/command/CommandKamkeelBase.java +++ b/src/main/java/kamkeel/npcs/command/CommandKamkeelBase.java @@ -16,10 +16,10 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -public abstract class CommandKamkeelBase extends CommandBase{ - public Map subcommands = new HashMap(); +public abstract class CommandKamkeelBase extends CommandBase { + public Map subcommands = new HashMap(); - public CommandKamkeelBase(){ + public CommandKamkeelBase() { for (Method m : this.getClass().getDeclaredMethods()) { SubCommand sc = m.getAnnotation(SubCommand.class); if (sc != null) { @@ -29,107 +29,107 @@ public abstract class CommandKamkeelBase extends CommandBase{ subcommands.put(name.toLowerCase(), m); } } - } + } - @Override - public void processCommand(ICommandSender sender, String[] args) throws CommandException { + @Override + public void processCommand(ICommandSender sender, String[] args) throws CommandException { - } + } - @Override - public String getCommandUsage(ICommandSender sender) { - return getDescription(); - } + @Override + public String getCommandUsage(ICommandSender sender) { + return getDescription(); + } - public abstract String getDescription(); + public abstract String getDescription(); - /** - * @return Should return a string in the format of [arg4] where <> is a required parameter and [] optional - */ - public String getUsage(){ - return ""; - } + /** + * @return Should return a string in the format of [arg4] where <> is a required parameter and [] optional + */ + public String getUsage() { + return ""; + } - public boolean runSubCommands(){ - return !subcommands.isEmpty(); - } + public boolean runSubCommands() { + return !subcommands.isEmpty(); + } - @Retention(value = RetentionPolicy.RUNTIME) - @Target(ElementType.METHOD) - public @interface SubCommand { + @Retention(value = RetentionPolicy.RUNTIME) + @Target(ElementType.METHOD) + public @interface SubCommand { - String name() default ""; + String name() default ""; - /** - * @return Should return a string in the format of [arg4] where <> is a required parameter and [] optional - */ - String usage() default ""; + /** + * @return Should return a string in the format of [arg4] where <> is a required parameter and [] optional + */ + String usage() default ""; - String desc(); + String desc(); - int permission() default 2; - } + int permission() default 2; + } - public void processSubCommand(ICommandSender sender, String command, String[] args) throws CommandException { - Method m = subcommands.get(command.toLowerCase()); - if(m == null) - throw new CommandException("Unknown subcommand " + command); + public void processSubCommand(ICommandSender sender, String command, String[] args) throws CommandException { + Method m = subcommands.get(command.toLowerCase()); + if (m == null) + throw new CommandException("Unknown subcommand " + command); - SubCommand sc = m.getAnnotation(SubCommand.class); - if(!canSendCommand(sender, sc, command)) - throw new CommandException("You are not allowed to use this command: " + command); + SubCommand sc = m.getAnnotation(SubCommand.class); + if (!canSendCommand(sender, sc, command)) + throw new CommandException("You are not allowed to use this command: " + command); - canRun(sender, sc.usage(), args); - try { - m.invoke(this, sender, args); - } catch (Exception e) { - e.printStackTrace(); - } - } + canRun(sender, sc.usage(), args); + try { + m.invoke(this, sender, args); + } catch (Exception e) { + e.printStackTrace(); + } + } - public void canRun(ICommandSender sender, String usage, String[] args) throws CommandException{ - String[] np = usage.split(" "); - List required = new ArrayList(); - for(int i = 0; i < np.length; i++){ - String command = np[i]; - if(command.startsWith("<")){ - required.add(command); - } - if(command.equals("") && args.length > i){ - CommandBase.getPlayer(sender, args[i]); //throws PlayerNotFoundException if no player is found - } + public void canRun(ICommandSender sender, String usage, String[] args) throws CommandException { + String[] np = usage.split(" "); + List required = new ArrayList(); + for (int i = 0; i < np.length; i++) { + String command = np[i]; + if (command.startsWith("<")) { + required.add(command); + } + if (command.equals("") && args.length > i) { + CommandBase.getPlayer(sender, args[i]); //throws PlayerNotFoundException if no player is found + } - } - if (args.length < required.size()) { - throw new CommandException("Missing parameter: " + required.get(args.length)); - } - } + } + if (args.length < required.size()) { + throw new CommandException("Missing parameter: " + required.get(args.length)); + } + } - public int getRequiredPermissionLevel(){ + public int getRequiredPermissionLevel() { return 2; } - public String getSubCommandPermission(String subCommand){ - return "cnpc.kamkeel." + getCommandName().toLowerCase() + "." + subCommand.toLowerCase(); - } + public String getSubCommandPermission(String subCommand) { + return "cnpc.kamkeel." + getCommandName().toLowerCase() + "." + subCommand.toLowerCase(); + } - public String getSubUniversalPermission(){ - return "cnpc.kamkeel." + getCommandName().toLowerCase() + "*"; - } + public String getSubUniversalPermission() { + return "cnpc.kamkeel." + getCommandName().toLowerCase() + "*"; + } - public boolean canSendCommand(ICommandSender sender, SubCommand command, String subCommand){ - if(sender.canCommandSenderUseCommand(command.permission(), getSubUniversalPermission())){ - return true; - } + public boolean canSendCommand(ICommandSender sender, SubCommand command, String subCommand) { + if (sender.canCommandSenderUseCommand(command.permission(), getSubUniversalPermission())) { + return true; + } - if(sender.canCommandSenderUseCommand(command.permission(), getSubCommandPermission(subCommand))){ - return true; - } + if (sender.canCommandSenderUseCommand(command.permission(), getSubCommandPermission(subCommand))) { + return true; + } - if(sender instanceof EntityPlayer){ - return CustomNpcsPermissions.hasCustomPermission((EntityPlayer) sender, getSubCommandPermission(subCommand)); - } + if (sender instanceof EntityPlayer) { + return CustomNpcsPermissions.hasCustomPermission((EntityPlayer) sender, getSubCommandPermission(subCommand)); + } - return false; - } + return false; + } } diff --git a/src/main/java/kamkeel/npcs/command/ConfigCommand.java b/src/main/java/kamkeel/npcs/command/ConfigCommand.java index c7eb467e6..16a8a51cd 100644 --- a/src/main/java/kamkeel/npcs/command/ConfigCommand.java +++ b/src/main/java/kamkeel/npcs/command/ConfigCommand.java @@ -27,245 +27,232 @@ import static kamkeel.npcs.util.ColorUtil.sendResult; public class ConfigCommand extends CommandKamkeelBase { - @Override - public String getCommandName() { - return "config"; - } + @Override + public String getCommandName() { + return "config"; + } - @Override - public String getDescription() { - return "Some config things you can set"; - } + @Override + public String getDescription() { + return "Some config things you can set"; + } @SubCommand( - desc = "Disable/Enable the natural leaves decay", - usage = "[true/false]", - permission = 4 + desc = "Disable/Enable the natural leaves decay", + usage = "[true/false]", + permission = 4 ) - public void leavesdecay(ICommandSender sender, String[] args){ - if(args.length == 0){ - sendResult(sender, "LeavesDecay: \u00A7c" + ConfigMain.LeavesDecayEnabled); - } - else{ - ConfigMain.LeavesDecayEnabled = Boolean.parseBoolean(args[0]); - ConfigMain.LeavesDecayEnabledProperty.set(ConfigMain.LeavesDecayEnabled); - if(ConfigMain.config.hasChanged()){ - ConfigMain.config.save(); - } + public void leavesdecay(ICommandSender sender, String[] args) { + if (args.length == 0) { + sendResult(sender, "LeavesDecay: \u00A7c" + ConfigMain.LeavesDecayEnabled); + } else { + ConfigMain.LeavesDecayEnabled = Boolean.parseBoolean(args[0]); + ConfigMain.LeavesDecayEnabledProperty.set(ConfigMain.LeavesDecayEnabled); + if (ConfigMain.config.hasChanged()) { + ConfigMain.config.save(); + } Set names = Block.blockRegistry.getKeys(); - for(ResourceLocation name : names){ - Block block = (Block) Block.blockRegistry.getObject(name); - if(block instanceof BlockLeavesBase){ - block.setTickRandomly(ConfigMain.LeavesDecayEnabled); - } + for (ResourceLocation name : names) { + Block block = (Block) Block.blockRegistry.getObject(name); + if (block instanceof BlockLeavesBase) { + block.setTickRandomly(ConfigMain.LeavesDecayEnabled); + } } sendResult(sender, "LeavesDecay is now \u00A7c" + ConfigMain.LeavesDecayEnabled); - } + } } @SubCommand( - desc = "Disable/Enable the vines growing", - usage = "[true/false]", - permission = 4 + desc = "Disable/Enable the vines growing", + usage = "[true/false]", + permission = 4 ) - public void vinegrowth(ICommandSender sender, String[] args){ - if(args.length == 0){ - sendResult(sender, "VineGrowth: \u00A7c" + ConfigMain.VineGrowthEnabled); - } - else{ - ConfigMain.VineGrowthEnabled = Boolean.parseBoolean(args[0]); - ConfigMain.VineGrowthEnabledProperty.set(ConfigMain.VineGrowthEnabled); - if(ConfigMain.config.hasChanged()){ - ConfigMain.config.save(); - } + public void vinegrowth(ICommandSender sender, String[] args) { + if (args.length == 0) { + sendResult(sender, "VineGrowth: \u00A7c" + ConfigMain.VineGrowthEnabled); + } else { + ConfigMain.VineGrowthEnabled = Boolean.parseBoolean(args[0]); + ConfigMain.VineGrowthEnabledProperty.set(ConfigMain.VineGrowthEnabled); + if (ConfigMain.config.hasChanged()) { + ConfigMain.config.save(); + } Set names = Block.blockRegistry.getKeys(); - for(ResourceLocation name : names){ - Block block = (Block) Block.blockRegistry.getObject(name); - if(block instanceof BlockVine){ - block.setTickRandomly(ConfigMain.VineGrowthEnabled); - } + for (ResourceLocation name : names) { + Block block = (Block) Block.blockRegistry.getObject(name); + if (block instanceof BlockVine) { + block.setTickRandomly(ConfigMain.VineGrowthEnabled); + } } sendResult(sender, "VineGrowth is now \u00A7c" + ConfigMain.VineGrowthEnabled); - } + } } @SubCommand( - desc = "Disable/Enable the ice melting", - usage = "[true/false]", - permission = 4 + desc = "Disable/Enable the ice melting", + usage = "[true/false]", + permission = 4 ) - public void icemelts(ICommandSender sender, String[] args){ - if(args.length == 0){ - sendResult(sender, "IceMelts: \u00A7c" + ConfigMain.IceMeltsEnabled); - } - else{ - ConfigMain.IceMeltsEnabled = Boolean.parseBoolean(args[0]); - ConfigMain.IceMeltsEnabledProperty.set(ConfigMain.IceMeltsEnabled); - if(ConfigMain.config.hasChanged()){ - ConfigMain.config.save(); - } + public void icemelts(ICommandSender sender, String[] args) { + if (args.length == 0) { + sendResult(sender, "IceMelts: \u00A7c" + ConfigMain.IceMeltsEnabled); + } else { + ConfigMain.IceMeltsEnabled = Boolean.parseBoolean(args[0]); + ConfigMain.IceMeltsEnabledProperty.set(ConfigMain.IceMeltsEnabled); + if (ConfigMain.config.hasChanged()) { + ConfigMain.config.save(); + } Set names = Block.blockRegistry.getKeys(); - for(ResourceLocation name : names){ - Block block = (Block) Block.blockRegistry.getObject(name); - if(block instanceof BlockIce){ - block.setTickRandomly(ConfigMain.IceMeltsEnabled); - } + for (ResourceLocation name : names) { + Block block = (Block) Block.blockRegistry.getObject(name); + if (block instanceof BlockIce) { + block.setTickRandomly(ConfigMain.IceMeltsEnabled); + } } sendResult(sender, "IceMelts is now \u00A7c" + ConfigMain.IceMeltsEnabled); - } + } } @SubCommand( - desc = "Disable/Enable guns shooting", - usage = "[true/false]", - permission = 4 + desc = "Disable/Enable guns shooting", + usage = "[true/false]", + permission = 4 ) - public void guns(ICommandSender sender, String[] args){ - if(args.length == 0){ - sendResult(sender, "GunsEnabled: \u00A7c" + ConfigItem.GunsEnabled); - } - else{ - ConfigItem.GunsEnabled = Boolean.parseBoolean(args[0]); - ConfigItem.GunsEnabledProperty.set(ConfigItem.GunsEnabled); - if(ConfigMain.config.hasChanged()){ - ConfigMain.config.save(); - } + public void guns(ICommandSender sender, String[] args) { + if (args.length == 0) { + sendResult(sender, "GunsEnabled: \u00A7c" + ConfigItem.GunsEnabled); + } else { + ConfigItem.GunsEnabled = Boolean.parseBoolean(args[0]); + ConfigItem.GunsEnabledProperty.set(ConfigItem.GunsEnabled); + if (ConfigMain.config.hasChanged()) { + ConfigMain.config.save(); + } sendResult(sender, "GunsEnabled is now \u00A7c" + ConfigItem.GunsEnabled); - } + } } @SubCommand( - desc = "Freezes/Unfreezes npcs", - usage = "[true/false]", - permission = 4 + desc = "Freezes/Unfreezes npcs", + usage = "[true/false]", + permission = 4 ) - public void freezenpcs(ICommandSender sender, String[] args){ - if(args.length == 0){ - sendResult(sender, "Frozen NPCs: \u00A7c" + CustomNpcs.FreezeNPCs); - } - else{ - CustomNpcs.FreezeNPCs = Boolean.parseBoolean(args[0]); + public void freezenpcs(ICommandSender sender, String[] args) { + if (args.length == 0) { + sendResult(sender, "Frozen NPCs: \u00A7c" + CustomNpcs.FreezeNPCs); + } else { + CustomNpcs.FreezeNPCs = Boolean.parseBoolean(args[0]); sendResult(sender, "FrozenNPCs is now \u00A7c" + CustomNpcs.FreezeNPCs); - } + } } @SubCommand( - desc = "Set number of active chunkloaders", - usage = "", - permission = 4 + desc = "Set number of active chunkloaders", + usage = "", + permission = 4 ) - public void chunkloaders(ICommandSender sender, String[] args) throws CommandException{ - if(args.length == 0){ - sendResult(sender, "ChunkLoaders: \u00A7c" + ChunkController.Instance.size() + "\u00A77/\u00A7c" + ConfigMain.ChunkLoaders); - } - else{ - try{ - ConfigMain.ChunkLoaders = Integer.parseInt(args[0]); - } - catch(NumberFormatException ex){ - sendError(sender, "Did not get a number: " + args[0]); - return; - } - ConfigMain.ChunkLoadersProperty.set(ConfigMain.ChunkLoaders); - if(ConfigMain.config.hasChanged()){ - ConfigMain.config.save(); - } + public void chunkloaders(ICommandSender sender, String[] args) throws CommandException { + if (args.length == 0) { + sendResult(sender, "ChunkLoaders: \u00A7c" + ChunkController.Instance.size() + "\u00A77/\u00A7c" + ConfigMain.ChunkLoaders); + } else { + try { + ConfigMain.ChunkLoaders = Integer.parseInt(args[0]); + } catch (NumberFormatException ex) { + sendError(sender, "Did not get a number: " + args[0]); + return; + } + ConfigMain.ChunkLoadersProperty.set(ConfigMain.ChunkLoaders); + if (ConfigMain.config.hasChanged()) { + ConfigMain.config.save(); + } - int size = ChunkController.Instance.size(); - if(size > ConfigMain.ChunkLoaders){ - ChunkController.Instance.unload(size - ConfigMain.ChunkLoaders); - sendResult(sender, size - ConfigMain.ChunkLoaders + " chunksloaders unloaded"); - } - sendResult(sender, "ChunkLoaders: \u00A7c" + ChunkController.Instance.size() + "\u00A77/\u00A7c" + ConfigMain.ChunkLoaders); - } + int size = ChunkController.Instance.size(); + if (size > ConfigMain.ChunkLoaders) { + ChunkController.Instance.unload(size - ConfigMain.ChunkLoaders); + sendResult(sender, size - ConfigMain.ChunkLoaders + " chunksloaders unloaded"); + } + sendResult(sender, "ChunkLoaders: \u00A7c" + ChunkController.Instance.size() + "\u00A77/\u00A7c" + ConfigMain.ChunkLoaders); + } } - @SubCommand( - desc = "Generate PlayerData to JSON/DAT", - usage = "[fileType] [convert]", - permission = 4 - ) - public void playerdata(ICommandSender sender, String[] args) throws CommandException{ - String fileType; - if(ConfigMain.DatFormat){ - fileType = "DAT"; - } - else { - fileType = "JSON"; - } - if(args.length == 0){ - sendResult(sender, "PlayerData Filetype: \u00A7c" + fileType); - } - else if(args.length == 1){ - sendResult(sender, "Please write the word 'convert' at the end to confirm. \u00A7c convert"); - } - else{ - if(args.length != 2){ - sendError(sender, "Two many arguments"); - return; - } - String formatType = args[0].toLowerCase(); - if(!formatType.equals("dat") && !formatType.equals("json")){ - sendError(sender, "Invalid Format Type - Please use dat or json"); - return; - } - - String convert = args[1].toLowerCase(); - if(!convert.equals("convert")){ - sendError(sender, "Please enter the word 'convert' at the end"); - return; - } - - boolean convertToDat = formatType.equals("dat"); - EntityPlayerMP send = null; - if(sender instanceof EntityPlayerMP){ - send = (EntityPlayerMP) sender; - } - - sendResult(sender, "Started Conversion Process for PlayerData"); - PlayerDataController.Instance.convertPlayerFiles(send, convertToDat); - } - } - @SubCommand( - desc = "Generate Market to JSON/DAT", + desc = "Generate PlayerData to JSON/DAT", usage = "[fileType] [convert]", permission = 4 ) - public void market(ICommandSender sender, String[] args) throws CommandException{ + public void playerdata(ICommandSender sender, String[] args) throws CommandException { String fileType; - if(ConfigMain.MarketDatFormat){ + if (ConfigMain.DatFormat) { fileType = "DAT"; - } - else { + } else { fileType = "JSON"; } - if(args.length == 0){ - sendResult(sender, "Market Filetype: \u00A7c" + fileType); - } - else if(args.length == 1){ + if (args.length == 0) { + sendResult(sender, "PlayerData Filetype: \u00A7c" + fileType); + } else if (args.length == 1) { sendResult(sender, "Please write the word 'convert' at the end to confirm. \u00A7c convert"); - } - else{ - if(args.length != 2){ + } else { + if (args.length != 2) { sendError(sender, "Two many arguments"); return; } String formatType = args[0].toLowerCase(); - if(!formatType.equals("dat") && !formatType.equals("json")){ + if (!formatType.equals("dat") && !formatType.equals("json")) { sendError(sender, "Invalid Format Type - Please use dat or json"); return; } String convert = args[1].toLowerCase(); - if(!convert.equals("convert")){ + if (!convert.equals("convert")) { sendError(sender, "Please enter the word 'convert' at the end"); return; } boolean convertToDat = formatType.equals("dat"); EntityPlayerMP send = null; - if(sender instanceof EntityPlayerMP){ + if (sender instanceof EntityPlayerMP) { + send = (EntityPlayerMP) sender; + } + + sendResult(sender, "Started Conversion Process for PlayerData"); + PlayerDataController.Instance.convertPlayerFiles(send, convertToDat); + } + } + + @SubCommand( + desc = "Generate Market to JSON/DAT", + usage = "[fileType] [convert]", + permission = 4 + ) + public void market(ICommandSender sender, String[] args) throws CommandException { + String fileType; + if (ConfigMain.MarketDatFormat) { + fileType = "DAT"; + } else { + fileType = "JSON"; + } + if (args.length == 0) { + sendResult(sender, "Market Filetype: \u00A7c" + fileType); + } else if (args.length == 1) { + sendResult(sender, "Please write the word 'convert' at the end to confirm. \u00A7c convert"); + } else { + if (args.length != 2) { + sendError(sender, "Two many arguments"); + return; + } + String formatType = args[0].toLowerCase(); + if (!formatType.equals("dat") && !formatType.equals("json")) { + sendError(sender, "Invalid Format Type - Please use dat or json"); + return; + } + + String convert = args[1].toLowerCase(); + if (!convert.equals("convert")) { + sendError(sender, "Please enter the word 'convert' at the end"); + return; + } + + boolean convertToDat = formatType.equals("dat"); + EntityPlayerMP send = null; + if (sender instanceof EntityPlayerMP) { send = (EntityPlayerMP) sender; } @@ -275,28 +262,27 @@ public class ConfigCommand extends CommandKamkeelBase { } @SubCommand( - desc = "Get/Set font", - usage = "[type] [size]", - permission = 4 + desc = "Get/Set font", + usage = "[type] [size]", + permission = 4 ) - public void font(ICommandSender sender, String[] args){ - if(!(sender instanceof EntityPlayerMP)) - return; - int size = 18; - if(args.length > 1){ - try{ - size = Integer.parseInt(args[args.length - 1]); - args = Arrays.copyOfRange(args, 0, args.length - 1); - } - catch(Exception e){ + public void font(ICommandSender sender, String[] args) { + if (!(sender instanceof EntityPlayerMP)) + return; + int size = 18; + if (args.length > 1) { + try { + size = Integer.parseInt(args[args.length - 1]); + args = Arrays.copyOfRange(args, 0, args.length - 1); + } catch (Exception e) { - } - } - String font = ""; - for(int i = 0; i < args.length; i++){ - font += " " + args[i]; - } - PacketHandler.Instance.sendToPlayer(new ConfigCommandPacket(EnumConfigOperation.FONT, font.trim(), size), (EntityPlayerMP)sender); + } + } + String font = ""; + for (int i = 0; i < args.length; i++) { + font += " " + args[i]; + } + PacketHandler.Instance.sendToPlayer(new ConfigCommandPacket(EnumConfigOperation.FONT, font.trim(), size), (EntityPlayerMP) sender); } } diff --git a/src/main/java/kamkeel/npcs/command/DialogCategoryCommand.java b/src/main/java/kamkeel/npcs/command/DialogCategoryCommand.java index cf1424386..9f39ac06c 100644 --- a/src/main/java/kamkeel/npcs/command/DialogCategoryCommand.java +++ b/src/main/java/kamkeel/npcs/command/DialogCategoryCommand.java @@ -16,22 +16,22 @@ import static kamkeel.npcs.util.ColorUtil.sendResult; public class DialogCategoryCommand extends CommandKamkeelBase { - @Override - public String getCommandName() { - return "dialogcat"; - } + @Override + public String getCommandName() { + return "dialogcat"; + } - @Override - public String getDescription() { - return "Dialog Category operations"; - } + @Override + public String getDescription() { + return "Dialog Category operations"; + } @SubCommand( - desc = "Find dialog category id number by its name", - usage = "" + desc = "Find dialog category id number by its name", + usage = "" ) public void id(ICommandSender sender, String args[]) throws CommandException { - if(args.length == 0){ + if (args.length == 0) { sendError(sender, "Please provide a name for the dialog category"); return; } @@ -39,48 +39,47 @@ public class DialogCategoryCommand extends CommandKamkeelBase { String catName = String.join(" ", args).toLowerCase(); final Collection dialogCats = DialogController.Instance.categories.values(); int count = 0; - for(DialogCategory cat : dialogCats){ - if(cat.getName().toLowerCase().contains(catName)){ + for (DialogCategory cat : dialogCats) { + if (cat.getName().toLowerCase().contains(catName)) { sendResult(sender, String.format("Dialog Cat \u00A7e%d\u00A77 - \u00A7c'%s'", cat.id, cat.getName())); count++; } } - if(count == 0){ + if (count == 0) { sendResult(sender, String.format("No Dialog Cat found with name: \u00A7c'%s'", catName)); } } @SubCommand( - desc = "Read a dialog category for a player", - usage = " " + desc = "Read a dialog category for a player", + usage = " " ) - public void read(ICommandSender sender, String args[]) throws CommandException{ - String playername=args[0]; + public void read(ICommandSender sender, String args[]) throws CommandException { + String playername = args[0]; int dialogCatId; try { - dialogCatId = Integer.parseInt(args[1]); - } - catch (NumberFormatException ex) { - sendError(sender, "DialogCatID must be an integer: " + args[1]); + dialogCatId = Integer.parseInt(args[1]); + } catch (NumberFormatException ex) { + sendError(sender, "DialogCatID must be an integer: " + args[1]); return; } List data = PlayerDataController.Instance.getPlayersData(sender, playername); if (data.isEmpty()) { - sendError(sender, String.format("Unknown player '%s'", playername)); + sendError(sender, String.format("Unknown player '%s'", playername)); return; } DialogCategory dialogCategory = DialogController.Instance.categories.get(dialogCatId); - if (dialogCategory == null){ - sendError(sender, "Unknown DialogCatID: " + dialogCatId); + if (dialogCategory == null) { + sendError(sender, "Unknown DialogCatID: " + dialogCatId); return; } int count = 0; - for(PlayerData playerdata : data){ - for(Dialog dialog : dialogCategory.dialogs.values()){ + for (PlayerData playerdata : data) { + for (Dialog dialog : dialogCategory.dialogs.values()) { playerdata.dialogData.dialogsRead.add(dialog.id); count++; } @@ -94,16 +93,15 @@ public class DialogCategoryCommand extends CommandKamkeelBase { @SubCommand( - desc = "Unread a dialog category for a player", - usage = " " + desc = "Unread a dialog category for a player", + usage = " " ) - public void unread(ICommandSender sender, String args[]) throws CommandException{ - String playername=args[0]; + public void unread(ICommandSender sender, String args[]) throws CommandException { + String playername = args[0]; int dialogCatId; try { dialogCatId = Integer.parseInt(args[1]); - } - catch (NumberFormatException ex) { + } catch (NumberFormatException ex) { sendError(sender, "DialogCatID must be an integer: " + args[1]); return; } @@ -115,14 +113,14 @@ public class DialogCategoryCommand extends CommandKamkeelBase { } DialogCategory dialogCategory = DialogController.Instance.categories.get(dialogCatId); - if (dialogCategory == null){ + if (dialogCategory == null) { sendError(sender, "Unknown DialogCatID: " + dialogCatId); return; } int count = 0; - for(PlayerData playerdata : data){ - for(Dialog dialog : dialogCategory.dialogs.values()){ + for (PlayerData playerdata : data) { + for (Dialog dialog : dialogCategory.dialogs.values()) { playerdata.dialogData.dialogsRead.remove(dialog.id); count++; } diff --git a/src/main/java/kamkeel/npcs/command/DialogCommand.java b/src/main/java/kamkeel/npcs/command/DialogCommand.java index d3953bad3..2392859a4 100644 --- a/src/main/java/kamkeel/npcs/command/DialogCommand.java +++ b/src/main/java/kamkeel/npcs/command/DialogCommand.java @@ -25,25 +25,25 @@ import static kamkeel.npcs.util.ColorUtil.sendResult; public class DialogCommand extends CommandKamkeelBase { - @Override - public String getCommandName() { - return "dialog"; - } + @Override + public String getCommandName() { + return "dialog"; + } - @Override - public String getDescription() { - return "Dialog operations"; - } + @Override + public String getDescription() { + return "Dialog operations"; + } @SubCommand( - desc = "force read", - usage = " " + desc = "force read", + usage = " " ) - public void read(ICommandSender sender, String args[]) throws CommandException{ - String playername=args[0]; + public void read(ICommandSender sender, String args[]) throws CommandException { + String playername = args[0]; int diagid; try { - diagid = Integer.parseInt(args[1]); + diagid = Integer.parseInt(args[1]); } catch (NumberFormatException ex) { sendError(sender, "DialogID must be an integer: " + args[1]); return; @@ -53,8 +53,8 @@ public class DialogCommand extends CommandKamkeelBase { sendError(sender, "Unknown player: " + playername); return; } - for(PlayerData playerdata : data){ - playerdata.dialogData.dialogsRead.add(diagid); + for (PlayerData playerdata : data) { + playerdata.dialogData.dialogsRead.add(diagid); playerdata.save(); playerdata.updateClient = true; sendResult(sender, String.format("Forced Read for Dialog \u00A7e%d\u00A77 for Player '\u00A7b%s\u00A77'", diagid, playerdata.playername)); @@ -62,14 +62,14 @@ public class DialogCommand extends CommandKamkeelBase { } @SubCommand( - desc = "force unread dialog", - usage = " " + desc = "force unread dialog", + usage = " " ) - public void unread(ICommandSender sender, String args[]) throws CommandException{ - String playername=args[0]; + public void unread(ICommandSender sender, String args[]) throws CommandException { + String playername = args[0]; int diagid; try { - diagid = Integer.parseInt(args[1]); + diagid = Integer.parseInt(args[1]); } catch (NumberFormatException ex) { sendError(sender, "DialogID must be an integer: " + args[1]); return; @@ -79,64 +79,65 @@ public class DialogCommand extends CommandKamkeelBase { sendError(sender, "Unknown player: " + playername); return; } - for(PlayerData playerdata : data){ - playerdata.dialogData.dialogsRead.remove(diagid); + for (PlayerData playerdata : data) { + playerdata.dialogData.dialogsRead.remove(diagid); playerdata.save(); playerdata.updateClient = true; sendResult(sender, String.format("Forced Unread for Dialog \u00A7e%d\u00A77 for Player '\u00A7b%s\u00A77'", diagid, playerdata.playername)); } } + @SubCommand( - desc="reload dialogs from disk", - permission = 4 + desc = "reload dialogs from disk", + permission = 4 ) - public void reload(ICommandSender sender, String args[]){ - new DialogController().load(); + public void reload(ICommandSender sender, String args[]) { + new DialogController().load(); SyncController.syncAllDialogs(); sendResult(sender, "Dialogs Reloaded"); } @SubCommand( - desc="show dialog", - usage=" " + desc = "show dialog", + usage = " " ) - public void show(ICommandSender sender, String args[]) throws CommandException{ - EntityPlayer player = CommandBase.getPlayer(sender, args[0]); - if(player == null){ + public void show(ICommandSender sender, String args[]) throws CommandException { + EntityPlayer player = CommandBase.getPlayer(sender, args[0]); + if (player == null) { sendError(sender, "Unknown player: " + args[0]); return; - } + } int diagid; try { - diagid = Integer.parseInt(args[1]); + diagid = Integer.parseInt(args[1]); } catch (NumberFormatException ex) { sendError(sender, "DialogID must be an integer: " + args[1]); return; } Dialog dialog = DialogController.Instance.dialogs.get(diagid); - if(dialog == null){ + if (dialog == null) { sendError(sender, "Unknown dialog id: " + args[1]); return; } - EntityDialogNpc npc = new EntityDialogNpc(sender.getEntityWorld()); - npc.display.setName(args[2]); - EntityUtil.Copy(player, npc); - DialogOption option = new DialogOption(); - option.dialogId = diagid; - option.title = dialog.title; - npc.dialogs.put(0, option); - NoppesUtilServer.openDialog(player, npc, dialog, 0); + EntityDialogNpc npc = new EntityDialogNpc(sender.getEntityWorld()); + npc.display.setName(args[2]); + EntityUtil.Copy(player, npc); + DialogOption option = new DialogOption(); + option.dialogId = diagid; + option.title = dialog.title; + npc.dialogs.put(0, option); + NoppesUtilServer.openDialog(player, npc, dialog, 0); sendResult(sender, String.format("Displayed Dialog \u00A7e%d\u00A77 to Player '\u00A7b%s\u00A77'", diagid, player.getCommandSenderName())); } @SubCommand( - desc = "Find dialog id number by its name", - usage = "" + desc = "Find dialog id number by its name", + usage = "" ) public void id(ICommandSender sender, String args[]) throws CommandException { - if(args.length == 0){ + if (args.length == 0) { sendError(sender, "Please provide a name for the dialog"); return; } @@ -144,23 +145,23 @@ public class DialogCommand extends CommandKamkeelBase { String dialogName = String.join(" ", args).toLowerCase(); final Collection quests = DialogController.Instance.dialogs.values(); int count = 0; - for(Dialog dialog : quests){ - if(dialog.getName().toLowerCase().contains(dialogName)){ + for (Dialog dialog : quests) { + if (dialog.getName().toLowerCase().contains(dialogName)) { sendResult(sender, String.format("Dialog \u00A7e%d\u00A77 - \u00A7c'%s'", dialog.id, dialog.getName())); count++; } } - if(count == 0){ + if (count == 0) { sendResult(sender, String.format("No Dialog found with name: \u00A7c'%s'", dialogName)); } } @SubCommand( - desc = "List a dialogs availability options", - usage = "" + desc = "List a dialogs availability options", + usage = "" ) public void availability(ICommandSender sender, String args[]) throws CommandException { - if(args.length == 0){ + if (args.length == 0) { sendError(sender, "Please provide an id for the dialog"); return; } @@ -173,56 +174,56 @@ public class DialogCommand extends CommandKamkeelBase { return; } Dialog dialog = DialogController.Instance.dialogs.get(diagid); - if(dialog == null){ + if (dialog == null) { sendError(sender, "Unknown dialog id: " + args[0]); return; } Availability avail = dialog.availability; - if(avail != null){ + if (avail != null) { sendResult(sender, String.format("Availability Options for Dialog: \u00A7c%d", dialog.id)); sendResult(sender, "--------------------"); boolean diagFound = false; - if(avail.dialogId != -1 && avail.dialogAvailable != EnumAvailabilityDialog.Always){ + if (avail.dialogId != -1 && avail.dialogAvailable != EnumAvailabilityDialog.Always) { sendResult(sender, String.format("%s Dialog: \u00A7c%d", avail.dialogAvailable.toString(), avail.dialogId)); diagFound = true; } - if(avail.dialog2Id != -1 && avail.dialog2Available != EnumAvailabilityDialog.Always){ + if (avail.dialog2Id != -1 && avail.dialog2Available != EnumAvailabilityDialog.Always) { sendResult(sender, String.format("%s Dialog: \u00A7c%d", avail.dialog2Available.toString(), avail.dialog2Id)); diagFound = true; } - if(avail.dialog3Id != -1 && avail.dialog3Available != EnumAvailabilityDialog.Always){ + if (avail.dialog3Id != -1 && avail.dialog3Available != EnumAvailabilityDialog.Always) { sendResult(sender, String.format("%s Dialog: \u00A7c%d", avail.dialog3Available.toString(), avail.dialog3Id)); diagFound = true; } - if(avail.dialog4Id != -1 && avail.dialog4Available != EnumAvailabilityDialog.Always){ + if (avail.dialog4Id != -1 && avail.dialog4Available != EnumAvailabilityDialog.Always) { sendResult(sender, String.format("%s Dialog: \u00A7c%d", avail.dialog4Available.toString(), avail.dialog4Id)); diagFound = true; } - if(!diagFound){ + if (!diagFound) { sendResult(sender, "No Dialog Availability Options"); } sendResult(sender, "--------------------"); boolean questFound = false; - if(avail.questId != -1 && avail.questAvailable != EnumAvailabilityQuest.Always){ + if (avail.questId != -1 && avail.questAvailable != EnumAvailabilityQuest.Always) { sendResult(sender, String.format("%s Quest: \u00A7c%d", avail.questAvailable.toString(), avail.questId)); questFound = true; } - if(avail.quest2Id != -1 && avail.quest2Available != EnumAvailabilityQuest.Always){ + if (avail.quest2Id != -1 && avail.quest2Available != EnumAvailabilityQuest.Always) { sendResult(sender, String.format("%s Quest: \u00A7c%d", avail.quest2Available.toString(), avail.quest2Id)); questFound = true; } - if(avail.quest3Id != -1 && avail.quest3Available != EnumAvailabilityQuest.Always){ + if (avail.quest3Id != -1 && avail.quest3Available != EnumAvailabilityQuest.Always) { sendResult(sender, String.format("%s Quest: \u00A7c%d", avail.quest3Available.toString(), avail.quest3Id)); questFound = true; } - if(avail.quest4Id != -1 && avail.quest4Available != EnumAvailabilityQuest.Always){ + if (avail.quest4Id != -1 && avail.quest4Available != EnumAvailabilityQuest.Always) { sendResult(sender, String.format("%s Quest: \u00A7c%d", avail.quest4Available.toString(), avail.quest4Id)); questFound = true; } - if(!questFound){ + if (!questFound) { sendResult(sender, "No Quest Availability Options"); } sendResult(sender, "--------------------"); @@ -230,11 +231,11 @@ public class DialogCommand extends CommandKamkeelBase { } @SubCommand( - desc = "Quick info on a dialog", - usage = "" + desc = "Quick info on a dialog", + usage = "" ) public void info(ICommandSender sender, String args[]) throws CommandException { - if(args.length == 0){ + if (args.length == 0) { sendError(sender, "Please provide an id for the quest"); return; } @@ -247,7 +248,7 @@ public class DialogCommand extends CommandKamkeelBase { return; } Dialog dialog = DialogController.Instance.dialogs.get(diagid); - if(dialog == null){ + if (dialog == null) { sendError(sender, "Unknown dialog id: " + args[0]); return; } diff --git a/src/main/java/kamkeel/npcs/command/EffectCommand.java b/src/main/java/kamkeel/npcs/command/EffectCommand.java index 50615cf4d..df25413ae 100644 --- a/src/main/java/kamkeel/npcs/command/EffectCommand.java +++ b/src/main/java/kamkeel/npcs/command/EffectCommand.java @@ -132,7 +132,7 @@ public class EffectCommand extends CommandKamkeelBase { } for (PlayerData pdata : players) { - if(pdata.player != null){ + if (pdata.player != null) { CustomEffectController.getInstance().applyEffect(pdata.player, match.id, time, (byte) 1, match.index); sendResult(sender, String.format("%s §agiven to §7'§b%s§7'", match.effect.getName(), pdata.playername)); } @@ -182,7 +182,7 @@ public class EffectCommand extends CommandKamkeelBase { } for (PlayerData pdata : players) { - if(pdata.player != null){ + if (pdata.player != null) { CustomEffectController.getInstance().removeEffect(pdata.player, match.id, match.index, ExpirationType.REMOVED); sendResult(sender, String.format("Effect %s removed from %s", match.effect.getName(), pdata.playername)); } @@ -236,7 +236,7 @@ public class EffectCommand extends CommandKamkeelBase { } for (PlayerData pdata : players) { - if(pdata.player != null){ + if (pdata.player != null) { CustomEffectController.getInstance().applyEffect(pdata.player, effect.id, time, (byte) 1, effect.index); sendResult(sender, String.format("%s §agiven to §7'§b%s§7'", effect.getName(), pdata.playername)); } @@ -282,7 +282,7 @@ public class EffectCommand extends CommandKamkeelBase { } for (PlayerData pdata : players) { - if(pdata.player != null){ + if (pdata.player != null) { CustomEffectController.getInstance().removeEffect(pdata.player, effect.id, effect.index, ExpirationType.REMOVED); sendResult(sender, String.format("Effect %s removed from %s", effect.getName(), pdata.playername)); } diff --git a/src/main/java/kamkeel/npcs/command/FactionCommand.java b/src/main/java/kamkeel/npcs/command/FactionCommand.java index 32bea0d2d..af615b9a7 100644 --- a/src/main/java/kamkeel/npcs/command/FactionCommand.java +++ b/src/main/java/kamkeel/npcs/command/FactionCommand.java @@ -20,28 +20,28 @@ public class FactionCommand extends CommandKamkeelBase { public List data; - @Override - public String getCommandName() { - return "faction"; - } + @Override + public String getCommandName() { + return "faction"; + } - @Override - public String getDescription() { - return "Faction operations"; - } + @Override + public String getDescription() { + return "Faction operations"; + } - @Override - public String getUsage() { - return " "; - } + @Override + public String getUsage() { + return " "; + } - @Override - public boolean runSubCommands(){ - return false; - } + @Override + public boolean runSubCommands() { + return false; + } - @Override - public void processCommand(ICommandSender sender, String[] args) throws CommandException { + @Override + public void processCommand(ICommandSender sender, String[] args) throws CommandException { String playername = args[0]; String factionname = args[1]; @@ -51,10 +51,9 @@ public class FactionCommand extends CommandKamkeelBase { return; } - try{ + try { selectedFaction = FactionController.getInstance().getFaction(Integer.parseInt(factionname)); - } - catch(NumberFormatException e){ + } catch (NumberFormatException e) { selectedFaction = FactionController.getInstance().getFactionFromName(factionname); } @@ -65,15 +64,15 @@ public class FactionCommand extends CommandKamkeelBase { processSubCommand(sender, args[2], Arrays.copyOfRange(args, 3, args.length)); - for(PlayerData playerdata : data){ + for (PlayerData playerdata : data) { playerdata.save(); playerdata.updateClient = true; } - } + } @SubCommand( - desc = "Add points", - usage = "" + desc = "Add points", + usage = "" ) public void add(ICommandSender sender, String[] args) throws CommandException { int points; @@ -85,17 +84,17 @@ public class FactionCommand extends CommandKamkeelBase { } int factionid = this.selectedFaction.id; - for(PlayerData playerdata : data){ - PlayerFactionData playerfactiondata = playerdata.factionData; - playerfactiondata.increasePoints(factionid, points, playerdata.player); + for (PlayerData playerdata : data) { + PlayerFactionData playerfactiondata = playerdata.factionData; + playerfactiondata.increasePoints(factionid, points, playerdata.player); playerdata.updateClient = true; sendResult(sender, String.format("Added Points \u00A7a%d\u00A77, Faction \u00A7e%s (%d)\u00A77 for Player \u00A7b%s\u00A77", points, this.selectedFaction.getName(), this.selectedFaction.id, playerdata.playername)); } } @SubCommand( - desc = "Substract points", - usage = "" + desc = "Substract points", + usage = "" ) public void subtract(ICommandSender sender, String[] args) throws CommandException { int points; @@ -106,9 +105,9 @@ public class FactionCommand extends CommandKamkeelBase { return; } int factionid = this.selectedFaction.id; - for(PlayerData playerdata : data){ - PlayerFactionData playerfactiondata = playerdata.factionData; - playerfactiondata.increasePoints(factionid, -points, playerdata.player); + for (PlayerData playerdata : data) { + PlayerFactionData playerfactiondata = playerdata.factionData; + playerfactiondata.increasePoints(factionid, -points, playerdata.player); playerdata.updateClient = true; sendResult(sender, String.format("Subtracted Points \u00A7a%d\u00A77, Faction \u00A7e%s (%d)\u00A77 for Player \u00A7b%s\u00A77", points, this.selectedFaction.getName(), this.selectedFaction.id, playerdata.playername)); } @@ -116,16 +115,16 @@ public class FactionCommand extends CommandKamkeelBase { @SubCommand(desc = "Reset points to default") public void reset(ICommandSender sender, String[] args) { - for(PlayerData playerdata : data){ - playerdata.factionData.factionData.put(this.selectedFaction.id, this.selectedFaction.defaultPoints); + for (PlayerData playerdata : data) { + playerdata.factionData.factionData.put(this.selectedFaction.id, this.selectedFaction.defaultPoints); playerdata.updateClient = true; sendResult(sender, String.format("Reset Faction \u00A7e%s (%d)\u00A77 for Player \u00A7b%s\u00A77", this.selectedFaction.getName(), this.selectedFaction.id, playerdata.playername)); } } @SubCommand( - desc = "Set points", - usage = "" + desc = "Set points", + usage = "" ) public void set(ICommandSender sender, String[] args) throws CommandException { int points; @@ -135,28 +134,28 @@ public class FactionCommand extends CommandKamkeelBase { sendError(sender, "Must be an integer: " + args[0]); return; } - for(PlayerData playerdata : data){ - PlayerFactionData playerfactiondata = playerdata.factionData; - playerfactiondata.factionData.put(this.selectedFaction.id, points); + for (PlayerData playerdata : data) { + PlayerFactionData playerfactiondata = playerdata.factionData; + playerfactiondata.factionData.put(this.selectedFaction.id, points); playerdata.updateClient = true; sendResult(sender, String.format("Set Points \u00A7a%d\u00A77, Faction \u00A7e%s (%d)\u00A77 for Player \u00A7b%s\u00A77", points, this.selectedFaction.getName(), this.selectedFaction.id, playerdata.playername)); } } @SubCommand(desc = "Drop relationship") - public void drop(ICommandSender sender, String[] args){ - for(PlayerData playerdata : data){ - playerdata.factionData.factionData.remove(this.selectedFaction.id); + public void drop(ICommandSender sender, String[] args) { + for (PlayerData playerdata : data) { + playerdata.factionData.factionData.remove(this.selectedFaction.id); playerdata.updateClient = true; sendResult(sender, String.format("Dropped Faction \u00A7e%s (%d)\u00A77 from Player \u00A7b%s\u00A77", this.selectedFaction.getName(), this.selectedFaction.id, playerdata.playername)); } } @Override - public List addTabCompletionOptions(ICommandSender par1, String[] args) { - if(args.length == 3){ - return getListOfStringsMatchingLastWord(args, new String[]{"add", "subtract", "set", "reset", "drop", "create"}); - } - return null; + public List addTabCompletionOptions(ICommandSender par1, String[] args) { + if (args.length == 3) { + return getListOfStringsMatchingLastWord(args, new String[]{"add", "subtract", "set", "reset", "drop", "create"}); + } + return null; } } diff --git a/src/main/java/kamkeel/npcs/command/HelpCommand.java b/src/main/java/kamkeel/npcs/command/HelpCommand.java index c5c3948d2..f1f335ec2 100644 --- a/src/main/java/kamkeel/npcs/command/HelpCommand.java +++ b/src/main/java/kamkeel/npcs/command/HelpCommand.java @@ -2,7 +2,6 @@ package kamkeel.npcs.command; import net.minecraft.command.CommandException; import net.minecraft.command.ICommandSender; -import net.minecraft.util.ChatComponentTranslation; import java.lang.reflect.Method; import java.util.Map.Entry; @@ -10,64 +9,63 @@ import java.util.Map.Entry; import static kamkeel.npcs.util.ColorUtil.sendError; import static kamkeel.npcs.util.ColorUtil.sendMessage; -public class HelpCommand extends CommandKamkeelBase{ - private CommandKamkeel parent; +public class HelpCommand extends CommandKamkeelBase { + private CommandKamkeel parent; - public HelpCommand(CommandKamkeel parent){ - this.parent = parent; - } + public HelpCommand(CommandKamkeel parent) { + this.parent = parent; + } - @Override - public String getCommandName() { - return "help"; - } + @Override + public String getCommandName() { + return "help"; + } - @Override - public String getDescription() { - return "help [command]"; - } + @Override + public String getDescription() { + return "help [command]"; + } - @Override - public void processCommand(ICommandSender sender, String[] args) throws CommandException { - if(args.length == 0){ - sendMessage(sender, "\u00A78------ \u00A7cKamkeel Commands \u00A78------"); - for(Entry entry : parent.map.entrySet()){ - sendMessage(sender, "\u00A77> " + "\u00A7e" + entry.getKey() + "\u00A78: \u00A77" + entry.getValue().getCommandUsage(sender)); - } - return; - } + @Override + public void processCommand(ICommandSender sender, String[] args) throws CommandException { + if (args.length == 0) { + sendMessage(sender, "\u00A78------ \u00A7cKamkeel Commands \u00A78------"); + for (Entry entry : parent.map.entrySet()) { + sendMessage(sender, "\u00A77> " + "\u00A7e" + entry.getKey() + "\u00A78: \u00A77" + entry.getValue().getCommandUsage(sender)); + } + return; + } - CommandKamkeelBase command = parent.getCommand(args); - if(command == null){ - sendError(sender, "Unknown command " + args[0]); - return; - } + CommandKamkeelBase command = parent.getCommand(args); + if (command == null) { + sendError(sender, "Unknown command " + args[0]); + return; + } - if(command.subcommands.isEmpty()){ - sendMessage(sender, (command.getCommandUsage(sender))); - return; - } + if (command.subcommands.isEmpty()) { + sendMessage(sender, (command.getCommandUsage(sender))); + return; + } - Method m = null; - if(args.length > 1){ - m = command.subcommands.get(args[1].toLowerCase()); - } - if(m == null){ - sendMessage(sender, "\u00A78------ \u00A7a" + command.getCommandName().toUpperCase() + " SubCommands \u00A78------"); - sendMessage(sender, "\u00A77Usage: \u00A76" + command.getUsage()); - for(Entry entry : command.subcommands.entrySet()){ - sendMessage(sender, ("\u00A77> " + "\u00A7e" + entry.getKey() + "\u00A78: \u00A77" + entry.getValue().getAnnotation(SubCommand.class).desc())); - } - sendMessage(sender, ("\u00A78Permission:\u00A77 " + CommandKamkeel.getCommandPermission(command.getCommandName()))); - } - else{ - sendMessage(sender, "\u00A78------ \u00A7b" + command.getCommandName().toUpperCase() + "." + args[1].toUpperCase() + " Command \u00A78------"); - SubCommand sc = m.getAnnotation(SubCommand.class); - sendMessage(sender, ("\u00A77" + sc.desc())); - if(!sc.usage().isEmpty()) - sendMessage(sender, ("\u00A77Usage: \u00A76" + sc.usage())); - sendMessage(sender, ("\u00A78Permission:\u00A77 " + getSubCommandPermission(args[1]))); - } - } + Method m = null; + if (args.length > 1) { + m = command.subcommands.get(args[1].toLowerCase()); + } + if (m == null) { + sendMessage(sender, "\u00A78------ \u00A7a" + command.getCommandName().toUpperCase() + " SubCommands \u00A78------"); + sendMessage(sender, "\u00A77Usage: \u00A76" + command.getUsage()); + for (Entry entry : command.subcommands.entrySet()) { + sendMessage(sender, ("\u00A77> " + "\u00A7e" + entry.getKey() + "\u00A78: \u00A77" + entry.getValue().getAnnotation(SubCommand.class).desc())); + } + sendMessage(sender, ("\u00A78Permission:\u00A77 " + CommandKamkeel.getCommandPermission(command.getCommandName()))); + } else { + sendMessage(sender, "\u00A78------ \u00A7b" + command.getCommandName().toUpperCase() + "." + args[1].toUpperCase() + " Command \u00A78------"); + SubCommand sc = m.getAnnotation(SubCommand.class); + sendMessage(sender, ("\u00A77" + sc.desc())); + if (!sc.usage().isEmpty()) + sendMessage(sender, ("\u00A77Usage: \u00A76" + sc.usage())); + sendMessage(sender, ("\u00A78Permission:\u00A77 " + getSubCommandPermission(args[1]))); + } + } } diff --git a/src/main/java/kamkeel/npcs/command/NpcCommand.java b/src/main/java/kamkeel/npcs/command/NpcCommand.java index 4e5745906..556976ed0 100644 --- a/src/main/java/kamkeel/npcs/command/NpcCommand.java +++ b/src/main/java/kamkeel/npcs/command/NpcCommand.java @@ -27,207 +27,206 @@ import static kamkeel.npcs.util.ColorUtil.sendResult; public class NpcCommand extends CommandKamkeelBase { - public EntityNPCInterface selectedNpc; + public EntityNPCInterface selectedNpc; - @Override - public String getCommandName() { - return "npc"; - } + @Override + public String getCommandName() { + return "npc"; + } - @Override - public String getDescription() { - return "NPC operation"; - } + @Override + public String getDescription() { + return "NPC operation"; + } - @Override - public String getUsage() { - return " "; - } + @Override + public String getUsage() { + return " "; + } - @Override - public boolean runSubCommands(){ - return false; - } + @Override + public boolean runSubCommands() { + return false; + } - @Override - public void processCommand(ICommandSender sender, String[] args) throws CommandException { - String npcname = args[0].replace("%", " "); - String command = args[1]; - args = Arrays.copyOfRange(args, 2, args.length); - if(command.equalsIgnoreCase("create")){ - args = ArrayUtils.add(args, 0, npcname); - processSubCommand(sender, command, args); - return; - } + @Override + public void processCommand(ICommandSender sender, String[] args) throws CommandException { + String npcname = args[0].replace("%", " "); + String command = args[1]; + args = Arrays.copyOfRange(args, 2, args.length); + if (command.equalsIgnoreCase("create")) { + args = ArrayUtils.add(args, 0, npcname); + processSubCommand(sender, command, args); + return; + } - int x = sender.getPlayerCoordinates().posX; - int y = sender.getPlayerCoordinates().posY; - int z = sender.getPlayerCoordinates().posZ; - List list = getEntities(EntityNPCInterface.class, sender.getEntityWorld(), x, y, z, 80); - for (EntityNPCInterface npc : list) { - String name = npc.display.getName().replace(" ", "_"); - if (name.equalsIgnoreCase(npcname)){ - if(selectedNpc == null || selectedNpc.getDistanceSq(x, y, z) > npc.getDistanceSq(x, y, z)) - selectedNpc = npc; - } - } - if(selectedNpc == null){ - sendError(sender, "Npc " + npcname + " was not found"); - return; - } + int x = sender.getPlayerCoordinates().posX; + int y = sender.getPlayerCoordinates().posY; + int z = sender.getPlayerCoordinates().posZ; + List list = getEntities(EntityNPCInterface.class, sender.getEntityWorld(), x, y, z, 80); + for (EntityNPCInterface npc : list) { + String name = npc.display.getName().replace(" ", "_"); + if (name.equalsIgnoreCase(npcname)) { + if (selectedNpc == null || selectedNpc.getDistanceSq(x, y, z) > npc.getDistanceSq(x, y, z)) + selectedNpc = npc; + } + } + if (selectedNpc == null) { + sendError(sender, "Npc " + npcname + " was not found"); + return; + } - processSubCommand(sender, command, args); - selectedNpc = null; - } + processSubCommand(sender, command, args); + selectedNpc = null; + } - @SubCommand( - desc = "Set Home (respawn place)", - usage = "[x] [y] [z]" - ) - public void home(ICommandSender sender, String[] args) { - double posX = sender.getPlayerCoordinates().posX; - double posY = sender.getPlayerCoordinates().posY; - double posZ = sender.getPlayerCoordinates().posZ; + @SubCommand( + desc = "Set Home (respawn place)", + usage = "[x] [y] [z]" + ) + public void home(ICommandSender sender, String[] args) { + double posX = sender.getPlayerCoordinates().posX; + double posY = sender.getPlayerCoordinates().posY; + double posZ = sender.getPlayerCoordinates().posZ; - if(args.length == 3){ - posX = CommandBase.func_110666_a(sender, selectedNpc.posX, args[0]); - posY = CommandBase.func_110665_a(sender, selectedNpc.posY, args[1].trim(), 0, 0); - posZ = CommandBase.func_110666_a(sender, selectedNpc.posZ, args[2]); - } + if (args.length == 3) { + posX = CommandBase.func_110666_a(sender, selectedNpc.posX, args[0]); + posY = CommandBase.func_110665_a(sender, selectedNpc.posY, args[1].trim(), 0, 0); + posZ = CommandBase.func_110666_a(sender, selectedNpc.posZ, args[2]); + } - selectedNpc.ais.startPos = new int[]{MathHelper.floor_double(posX), MathHelper.floor_double(posY), MathHelper.floor_double(posZ)}; - sendResult(sender, String.format("Set NPC \u00A7e%s\u00A77 Home to \u00A7b[%.1f] [%.1f] [%.1f]\u00A77", selectedNpc.display.name, posX, posY, posZ)); - } + selectedNpc.ais.startPos = new int[]{MathHelper.floor_double(posX), MathHelper.floor_double(posY), MathHelper.floor_double(posZ)}; + sendResult(sender, String.format("Set NPC \u00A7e%s\u00A77 Home to \u00A7b[%.1f] [%.1f] [%.1f]\u00A77", selectedNpc.display.name, posX, posY, posZ)); + } - @SubCommand( - desc = "Set NPC visibility", - usage = "[true/false/semi]" - ) - public void visible(ICommandSender sender, String[] args){ - if(args.length < 1) - return; - boolean bo = args[0].equalsIgnoreCase("true"); - boolean semi = args[0].equalsIgnoreCase("semi"); + @SubCommand( + desc = "Set NPC visibility", + usage = "[true/false/semi]" + ) + public void visible(ICommandSender sender, String[] args) { + if (args.length < 1) + return; + boolean bo = args[0].equalsIgnoreCase("true"); + boolean semi = args[0].equalsIgnoreCase("semi"); - int current = selectedNpc.display.visible; - if(semi) - selectedNpc.display.visible = 2; - else if(bo) - selectedNpc.display.visible = 0; - else - selectedNpc.display.visible = 1; + int current = selectedNpc.display.visible; + if (semi) + selectedNpc.display.visible = 2; + else if (bo) + selectedNpc.display.visible = 0; + else + selectedNpc.display.visible = 1; - String[] list = new String[]{"True", "False", "Semi"}; + String[] list = new String[]{"True", "False", "Semi"}; - if(current != selectedNpc.display.visible) - selectedNpc.updateClient = true; + if (current != selectedNpc.display.visible) + selectedNpc.updateClient = true; - sendResult(sender, String.format("Set NPC \u00A7e%s\u00A77 Visibility to \u00A7b%s\u00A77", selectedNpc.display.name, list[selectedNpc.display.visible])); - } + sendResult(sender, String.format("Set NPC \u00A7e%s\u00A77 Visibility to \u00A7b%s\u00A77", selectedNpc.display.name, list[selectedNpc.display.visible])); + } - @SubCommand(desc = "Delete an NPC") - public void delete(ICommandSender sender, String[] args){ - selectedNpc.delete(); - } + @SubCommand(desc = "Delete an NPC") + public void delete(ICommandSender sender, String[] args) { + selectedNpc.delete(); + } - @SubCommand( - desc = "Sets the owner of an follower/companion", - usage = "[player]" - ) - public void owner(ICommandSender sender, String[] args){ - if(args.length < 1){ - EntityPlayer player = null; - if(selectedNpc.roleInterface instanceof RoleFollower) - player = ((RoleFollower)selectedNpc.roleInterface).owner; + @SubCommand( + desc = "Sets the owner of an follower/companion", + usage = "[player]" + ) + public void owner(ICommandSender sender, String[] args) { + if (args.length < 1) { + EntityPlayer player = null; + if (selectedNpc.roleInterface instanceof RoleFollower) + player = ((RoleFollower) selectedNpc.roleInterface).owner; - if(selectedNpc.roleInterface instanceof RoleCompanion) - player = ((RoleCompanion)selectedNpc.roleInterface).owner; + if (selectedNpc.roleInterface instanceof RoleCompanion) + player = ((RoleCompanion) selectedNpc.roleInterface).owner; - if(player == null) - sendResult(sender, String.format("NPC \u00A7e%s\u00A77 Owner: \u00A7b%s\u00A77", selectedNpc.display.name, "NULL")); - else - sendResult(sender, String.format("NPC \u00A7e%s\u00A77 Owner: \u00A7b%s\u00A77", selectedNpc.display.name, player.getDisplayName())); - } - else{ - EntityPlayerMP player = null; - try { - player = CommandBase.getPlayer(sender, args[0]); - } catch (PlayerNotFoundException e) { + if (player == null) + sendResult(sender, String.format("NPC \u00A7e%s\u00A77 Owner: \u00A7b%s\u00A77", selectedNpc.display.name, "NULL")); + else + sendResult(sender, String.format("NPC \u00A7e%s\u00A77 Owner: \u00A7b%s\u00A77", selectedNpc.display.name, player.getDisplayName())); + } else { + EntityPlayerMP player = null; + try { + player = CommandBase.getPlayer(sender, args[0]); + } catch (PlayerNotFoundException e) { - } - if(selectedNpc.roleInterface instanceof RoleFollower) - ((RoleFollower)selectedNpc.roleInterface).setOwner(player); + } + if (selectedNpc.roleInterface instanceof RoleFollower) + ((RoleFollower) selectedNpc.roleInterface).setOwner(player); - if(selectedNpc.roleInterface instanceof RoleCompanion) - ((RoleCompanion)selectedNpc.roleInterface).setOwner(player); + if (selectedNpc.roleInterface instanceof RoleCompanion) + ((RoleCompanion) selectedNpc.roleInterface).setOwner(player); - if(player == null) - sendResult(sender, String.format("NPC \u00A7e%s\u00A77 Owner: \u00A7b%s\u00A77", selectedNpc.display.name, "NULL")); - else - sendResult(sender, String.format("NPC \u00A7e%s\u00A77 Owner: \u00A7b%s\u00A77", selectedNpc.display.name, player.getDisplayName())); - } - } + if (player == null) + sendResult(sender, String.format("NPC \u00A7e%s\u00A77 Owner: \u00A7b%s\u00A77", selectedNpc.display.name, "NULL")); + else + sendResult(sender, String.format("NPC \u00A7e%s\u00A77 Owner: \u00A7b%s\u00A77", selectedNpc.display.name, player.getDisplayName())); + } + } - @SubCommand( - desc = "Set NPC name", - usage = "[name]" - ) - public void name(ICommandSender sender, String[] args){ - if(args.length < 1) - return; + @SubCommand( + desc = "Set NPC name", + usage = "[name]" + ) + public void name(ICommandSender sender, String[] args) { + if (args.length < 1) + return; - String name = args[0]; - for(int i = 1; i < args.length; i++){ - name += " " + args[i]; - } + String name = args[0]; + for (int i = 1; i < args.length; i++) { + name += " " + args[i]; + } - sendResult(sender, String.format("NPC \u00A7e%s\u00A77 Name set to \u00A7b%s\u00A77", selectedNpc.display.name, name)); + sendResult(sender, String.format("NPC \u00A7e%s\u00A77 Name set to \u00A7b%s\u00A77", selectedNpc.display.name, name)); - if(!selectedNpc.display.getName().equals(name)){ - selectedNpc.display.setName(name); - selectedNpc.updateClient = true; - } - } + if (!selectedNpc.display.getName().equals(name)) { + selectedNpc.display.setName(name); + selectedNpc.updateClient = true; + } + } - @SubCommand( - desc = "Creates an NPC", - usage = "[name]" - ) - public void create(ICommandSender sender, String[] args) { - EntityPlayerMP player = (EntityPlayerMP) sender; - World pw = player.getEntityWorld(); - EntityCustomNpc npc = new EntityCustomNpc(pw); - if(args.length > 0) - npc.display.name = args[0]; - npc.setPositionAndRotation(player.posX, player.posY, player.posZ, player.cameraYaw, player.cameraPitch); - npc.ais.startPos = new int[]{MathHelper.floor_double(player.posX),MathHelper.floor_double(player.posY),MathHelper.floor_double(player.posZ)}; - pw.spawnEntityInWorld(npc); - npc.setHealth(npc.getMaxHealth()); - NoppesUtilServer.sendOpenGui(player, EnumGuiType.MainMenuDisplay, npc); - } + @SubCommand( + desc = "Creates an NPC", + usage = "[name]" + ) + public void create(ICommandSender sender, String[] args) { + EntityPlayerMP player = (EntityPlayerMP) sender; + World pw = player.getEntityWorld(); + EntityCustomNpc npc = new EntityCustomNpc(pw); + if (args.length > 0) + npc.display.name = args[0]; + npc.setPositionAndRotation(player.posX, player.posY, player.posZ, player.cameraYaw, player.cameraPitch); + npc.ais.startPos = new int[]{MathHelper.floor_double(player.posX), MathHelper.floor_double(player.posY), MathHelper.floor_double(player.posZ)}; + pw.spawnEntityInWorld(npc); + npc.setHealth(npc.getMaxHealth()); + NoppesUtilServer.sendOpenGui(player, EnumGuiType.MainMenuDisplay, npc); + } - @Override - public List addTabCompletionOptions(ICommandSender par1, String[] args) { - if(args.length == 2){ - return CommandBase.getListOfStringsMatchingLastWord(args, new String[]{"create", "home", "visible", "delete", "owner", "name"}); - } - if(args.length == 3 && args[1].equalsIgnoreCase("owner")){ - return CommandBase.getListOfStringsMatchingLastWord(args, MinecraftServer.getServer().getAllUsernames()); - } + @Override + public List addTabCompletionOptions(ICommandSender par1, String[] args) { + if (args.length == 2) { + return CommandBase.getListOfStringsMatchingLastWord(args, new String[]{"create", "home", "visible", "delete", "owner", "name"}); + } + if (args.length == 3 && args[1].equalsIgnoreCase("owner")) { + return CommandBase.getListOfStringsMatchingLastWord(args, MinecraftServer.getServer().getAllUsernames()); + } - return null; - } + return null; + } - @Override - public int getRequiredPermissionLevel(){ - return 4; - } + @Override + public int getRequiredPermissionLevel() { + return 4; + } - public List getEntities(Class cls, World world, int x, int y, int z, int range) { - AxisAlignedBB bb = AxisAlignedBB.getBoundingBox(x, y, z, x + 1, y + 1, z + 1).expand(range, range, range); - List list = world.getEntitiesWithinAABB(cls, bb); - return list; - } + public List getEntities(Class cls, World world, int x, int y, int z, int range) { + AxisAlignedBB bb = AxisAlignedBB.getBoundingBox(x, y, z, x + 1, y + 1, z + 1).expand(range, range, range); + List list = world.getEntitiesWithinAABB(cls, bb); + return list; + } } diff --git a/src/main/java/kamkeel/npcs/command/OverlayCommand.java b/src/main/java/kamkeel/npcs/command/OverlayCommand.java index 95e098f7c..3ee948d50 100644 --- a/src/main/java/kamkeel/npcs/command/OverlayCommand.java +++ b/src/main/java/kamkeel/npcs/command/OverlayCommand.java @@ -14,22 +14,22 @@ import static kamkeel.npcs.util.ColorUtil.sendResult; public class OverlayCommand extends CommandKamkeelBase { - @Override - public String getCommandName() { - return "overlay"; - } + @Override + public String getCommandName() { + return "overlay"; + } - @Override - public String getDescription() { - return "Overlay operations"; - } + @Override + public String getDescription() { + return "Overlay operations"; + } @SubCommand( - desc = "set an overlay to a player", - usage = " " + desc = "set an overlay to a player", + usage = " " ) - public void set(ICommandSender sender, String args[]) throws CommandException{ - String playername=args[0]; + public void set(ICommandSender sender, String args[]) throws CommandException { + String playername = args[0]; int overlayID; try { overlayID = Integer.parseInt(args[1]); @@ -42,7 +42,7 @@ public class OverlayCommand extends CommandKamkeelBase { sendError(sender, "Unknown player: " + playername); return; } - for(PlayerData playerdata : data){ + for (PlayerData playerdata : data) { SkinOverlay skinOverlay = new SkinOverlay(args[2]); playerdata.skinOverlays.add(overlayID, skinOverlay); playerdata.save(); @@ -52,11 +52,11 @@ public class OverlayCommand extends CommandKamkeelBase { } @SubCommand( - desc = "remove an overlay from a player", - usage = " " + desc = "remove an overlay from a player", + usage = " " ) - public void remove(ICommandSender sender, String args[]) throws CommandException{ - String playername=args[0]; + public void remove(ICommandSender sender, String args[]) throws CommandException { + String playername = args[0]; int overlayID; try { overlayID = Integer.parseInt(args[1]); @@ -69,13 +69,12 @@ public class OverlayCommand extends CommandKamkeelBase { sendError(sender, "Unknown player: " + playername); return; } - for(PlayerData playerdata : data){ - if(playerdata.skinOverlays.has(overlayID)){ + for (PlayerData playerdata : data) { + if (playerdata.skinOverlays.has(overlayID)) { playerdata.skinOverlays.remove(overlayID); playerdata.save(); sendResult(sender, String.format("Overlay removed to Player '\u00A7b%s\u00A77' on ID \u00A7d%d", playerdata.playername, overlayID)); - } - else { + } else { sendError(sender, String.format("No overlay found for Player '\u00A7b%s\u00A74' on ID \u00A7d%d", playerdata.playername, overlayID)); } return; @@ -83,11 +82,11 @@ public class OverlayCommand extends CommandKamkeelBase { } @SubCommand( - desc = "modify an overlay for a player", - usage = " " + desc = "modify an overlay for a player", + usage = " " ) - public void modify(ICommandSender sender, String args[]) throws CommandException{ - String playername=args[0]; + public void modify(ICommandSender sender, String args[]) throws CommandException { + String playername = args[0]; int overlayID; try { overlayID = Integer.parseInt(args[1]); @@ -101,35 +100,34 @@ public class OverlayCommand extends CommandKamkeelBase { return; } - if(!args[2].equalsIgnoreCase("blend") && !args[2].equalsIgnoreCase("glow")){ + if (!args[2].equalsIgnoreCase("blend") && !args[2].equalsIgnoreCase("glow")) { sendError(sender, "Unknown Entry: " + args[2]); return; } boolean isBlend = args[2].equalsIgnoreCase("blend"); - if(!args[3].equalsIgnoreCase("true") && !args[3].equalsIgnoreCase("false")){ + if (!args[3].equalsIgnoreCase("true") && !args[3].equalsIgnoreCase("false")) { sendError(sender, "Unknown Bool: " + args[3]); return; } boolean isTrue = args[3].equalsIgnoreCase("true"); - for(PlayerData playerdata : data){ - if(!playerdata.skinOverlays.has(overlayID)){ + for (PlayerData playerdata : data) { + if (!playerdata.skinOverlays.has(overlayID)) { sendError(sender, String.format("Player '\u00A7b%s\u00A7c' does not have Overlay ID \u00A7d%d", playerdata.playername, overlayID)); return; } ISkinOverlay skinOverlay = playerdata.skinOverlays.get(overlayID); - if(skinOverlay == null){ + if (skinOverlay == null) { sendError(sender, String.format("Player '\u00A7b%s\u00A7c' does not have Overlay ID \u00A7d%d", playerdata.playername, overlayID)); return; } - if(isBlend){ + if (isBlend) { skinOverlay.setBlend(isTrue); - } - else{ + } else { skinOverlay.setGlow(isTrue); } playerdata.skinOverlays.add(overlayID, skinOverlay); @@ -140,17 +138,17 @@ public class OverlayCommand extends CommandKamkeelBase { } @SubCommand( - desc = "clears all overlays from a player", - usage = "" + desc = "clears all overlays from a player", + usage = "" ) - public void clear(ICommandSender sender, String args[]) throws CommandException{ - String playername=args[0]; + public void clear(ICommandSender sender, String args[]) throws CommandException { + String playername = args[0]; List data = PlayerDataController.Instance.getPlayersData(sender, playername); if (data.isEmpty()) { sendError(sender, "Unknown player: " + playername); return; } - for(PlayerData playerdata : data){ + for (PlayerData playerdata : data) { playerdata.skinOverlays.clear(); playerdata.save(); sendResult(sender, String.format("Overlays cleared from Player '\u00A7b%s\u00A77'", playerdata.playername)); @@ -159,25 +157,24 @@ public class OverlayCommand extends CommandKamkeelBase { } @SubCommand( - desc = "List all overlays on a player", - usage = "" + desc = "List all overlays on a player", + usage = "" ) public void info(ICommandSender sender, String args[]) throws CommandException { - String playername=args[0]; + String playername = args[0]; List data = PlayerDataController.Instance.getPlayersData(sender, playername); if (data.isEmpty()) { sendError(sender, "Unknown player: " + playername); return; } - for(PlayerData playerdata : data){ + for (PlayerData playerdata : data) { sendResult(sender, "--------------------"); - if(playerdata.skinOverlays.size() == 0){ + if (playerdata.skinOverlays.size() == 0) { sendResult(sender, String.format("No Overlays found for Player '\u00A7b%s\u00A77'", playerdata.playername)); - } - else { - for(ISkinOverlay overlay : playerdata.skinOverlays.overlayList.values()){ - if(overlay != null){ + } else { + for (ISkinOverlay overlay : playerdata.skinOverlays.overlayList.values()) { + if (overlay != null) { sendResult(sender, String.format("%s", overlay.getTexture())); } } diff --git a/src/main/java/kamkeel/npcs/command/QuestCategoryCommand.java b/src/main/java/kamkeel/npcs/command/QuestCategoryCommand.java index eb673da35..f33d3626b 100644 --- a/src/main/java/kamkeel/npcs/command/QuestCategoryCommand.java +++ b/src/main/java/kamkeel/npcs/command/QuestCategoryCommand.java @@ -10,7 +10,6 @@ import noppes.npcs.config.ConfigMain; import noppes.npcs.constants.EnumProfileSync; import noppes.npcs.constants.EnumQuestRepeat; import noppes.npcs.controllers.PlayerDataController; -import noppes.npcs.controllers.PlayerQuestController; import noppes.npcs.controllers.QuestController; import noppes.npcs.controllers.data.PlayerData; import noppes.npcs.controllers.data.Quest; @@ -25,22 +24,22 @@ import static kamkeel.npcs.util.ColorUtil.sendResult; public class QuestCategoryCommand extends CommandKamkeelBase { - @Override - public String getCommandName() { - return "questcat"; - } + @Override + public String getCommandName() { + return "questcat"; + } - @Override - public String getDescription() { - return "Quest Category operations"; - } + @Override + public String getDescription() { + return "Quest Category operations"; + } @SubCommand( - desc = "Find quest category id number by its name", - usage = "" + desc = "Find quest category id number by its name", + usage = "" ) public void id(ICommandSender sender, String args[]) throws CommandException { - if(args.length == 0){ + if (args.length == 0) { sendError(sender, "Please provide a name for the quest category"); return; } @@ -48,52 +47,51 @@ public class QuestCategoryCommand extends CommandKamkeelBase { String catName = String.join(" ", args).toLowerCase(); final Collection questCats = QuestController.Instance.categories.values(); int count = 0; - for(QuestCategory cat : questCats){ - if(cat.getName().toLowerCase().contains(catName)){ + for (QuestCategory cat : questCats) { + if (cat.getName().toLowerCase().contains(catName)) { sendResult(sender, String.format("Quest Cat \u00A7e%d\u00A77 - \u00A7c'%s'", cat.id, cat.getName())); count++; } } - if(count == 0){ + if (count == 0) { sendResult(sender, String.format("No Quest Cat found with name: \u00A7c'%s'", catName)); } } @SubCommand( - desc = "Finish a quest category for a player", - usage = " " + desc = "Finish a quest category for a player", + usage = " " ) - public void finish(ICommandSender sender, String args[]) throws CommandException{ - String playername=args[0]; + public void finish(ICommandSender sender, String args[]) throws CommandException { + String playername = args[0]; int questcatid; try { - questcatid = Integer.parseInt(args[1]); - } - catch (NumberFormatException ex) { - sendError(sender, "QuestCatID must be an integer: " + args[1]); + questcatid = Integer.parseInt(args[1]); + } catch (NumberFormatException ex) { + sendError(sender, "QuestCatID must be an integer: " + args[1]); return; } List data = PlayerDataController.Instance.getPlayersData(sender, playername); if (data.isEmpty()) { - sendError(sender, String.format("Unknown player '%s'", playername)); + sendError(sender, String.format("Unknown player '%s'", playername)); return; } QuestCategory questCategory = QuestController.Instance.categories.get(questcatid); - if (questCategory == null){ - sendError(sender, "Unknown QuestCatID: " + questcatid); + if (questCategory == null) { + sendError(sender, "Unknown QuestCatID: " + questcatid); return; } int count = 0; - for(PlayerData playerdata : data){ + for (PlayerData playerdata : data) { count = 0; - for(Quest quest : questCategory.quests.values()){ + for (Quest quest : questCategory.quests.values()) { playerdata.questData.activeQuests.remove(quest.id); long completeTime; - if(quest.repeat == EnumQuestRepeat.RLDAILY || quest.repeat == EnumQuestRepeat.RLWEEKLY || quest.repeat == EnumQuestRepeat.RLCUSTOM){ + if (quest.repeat == EnumQuestRepeat.RLDAILY || quest.repeat == EnumQuestRepeat.RLWEEKLY || quest.repeat == EnumQuestRepeat.RLCUSTOM) { completeTime = System.currentTimeMillis(); playerdata.questData.finishedQuests.put(quest.id, completeTime); } else { @@ -101,10 +99,11 @@ public class QuestCategoryCommand extends CommandKamkeelBase { playerdata.questData.finishedQuests.put(quest.id, completeTime); } - if(ConfigMain.ProfilesEnabled && playerdata.player != null && quest.profileOptions.enableOptions && quest.profileOptions.completeControl == EnumProfileSync.Shared) - ProfileController.Instance.shareQuestCompletion(playerdata.player, quest.id, completeTime);; + if (ConfigMain.ProfilesEnabled && playerdata.player != null && quest.profileOptions.enableOptions && quest.profileOptions.completeControl == EnumProfileSync.Shared) + ProfileController.Instance.shareQuestCompletion(playerdata.player, quest.id, completeTime); + ; - if(playerdata.player != null){ + if (playerdata.player != null) { AchievementPacket.sendAchievement((EntityPlayerMP) playerdata.player, false, "quest.completed", quest.title); ChatAlertPacket.sendChatAlert((EntityPlayerMP) playerdata.player, "quest.completed", ": ", quest.title); } @@ -119,16 +118,15 @@ public class QuestCategoryCommand extends CommandKamkeelBase { } @SubCommand( - desc = "Stop a quest category for a players active quests", - usage = " " + desc = "Stop a quest category for a players active quests", + usage = " " ) - public void stop(ICommandSender sender, String args[]) throws CommandException{ - String playername=args[0]; + public void stop(ICommandSender sender, String args[]) throws CommandException { + String playername = args[0]; int questcatid; try { questcatid = Integer.parseInt(args[1]); - } - catch (NumberFormatException ex) { + } catch (NumberFormatException ex) { sendError(sender, "QuestCatID must be an integer: " + args[1]); return; } @@ -140,15 +138,15 @@ public class QuestCategoryCommand extends CommandKamkeelBase { } QuestCategory questCategory = QuestController.Instance.categories.get(questcatid); - if (questCategory == null){ + if (questCategory == null) { sendError(sender, "Unknown QuestCatID: " + questcatid); return; } int count = 0; - for(PlayerData playerdata : data){ - for(Quest quest : questCategory.quests.values()){ - if(playerdata.questData.activeQuests.containsKey(quest.id)){ + for (PlayerData playerdata : data) { + for (Quest quest : questCategory.quests.values()) { + if (playerdata.questData.activeQuests.containsKey(quest.id)) { playerdata.questData.activeQuests.remove(quest.id); count++; } @@ -162,16 +160,15 @@ public class QuestCategoryCommand extends CommandKamkeelBase { } @SubCommand( - desc = "Start a quest category for a player", - usage = " " + desc = "Start a quest category for a player", + usage = " " ) - public void start(ICommandSender sender, String args[]) throws CommandException{ - String playername=args[0]; + public void start(ICommandSender sender, String args[]) throws CommandException { + String playername = args[0]; int questcatid; try { questcatid = Integer.parseInt(args[1]); - } - catch (NumberFormatException ex) { + } catch (NumberFormatException ex) { sendError(sender, "QuestCatID must be an integer: " + args[1]); return; } @@ -183,20 +180,20 @@ public class QuestCategoryCommand extends CommandKamkeelBase { } QuestCategory questCategory = QuestController.Instance.categories.get(questcatid); - if (questCategory == null){ + if (questCategory == null) { sendError(sender, "Unknown QuestCatID: " + questcatid); return; } int count = 0; - for(PlayerData playerdata : data){ - for(Quest quest : questCategory.quests.values()){ - if(!playerdata.questData.activeQuests.containsKey(quest.id)){ + for (PlayerData playerdata : data) { + for (Quest quest : questCategory.quests.values()) { + if (!playerdata.questData.activeQuests.containsKey(quest.id)) { QuestData questData = new QuestData(quest); playerdata.questData.activeQuests.put(quest.id, questData); count++; - if(playerdata.player != null && questData.sendAlerts){ + if (playerdata.player != null && questData.sendAlerts) { AchievementPacket.sendAchievement((EntityPlayerMP) playerdata.player, false, "quest.newquest", quest.title); ChatAlertPacket.sendChatAlert((EntityPlayerMP) playerdata.player, "quest.newquest", ": ", quest.title); } @@ -212,16 +209,15 @@ public class QuestCategoryCommand extends CommandKamkeelBase { @SubCommand( - desc = "Remove a quest cat from active/finished", - usage = " " + desc = "Remove a quest cat from active/finished", + usage = " " ) - public void remove(ICommandSender sender, String args[]) throws CommandException{ - String playername=args[0]; + public void remove(ICommandSender sender, String args[]) throws CommandException { + String playername = args[0]; int questcatid; try { questcatid = Integer.parseInt(args[1]); - } - catch (NumberFormatException ex) { + } catch (NumberFormatException ex) { sendError(sender, "QuestCatID must be an integer: " + args[1]); return; } @@ -233,14 +229,14 @@ public class QuestCategoryCommand extends CommandKamkeelBase { } QuestCategory questCategory = QuestController.Instance.categories.get(questcatid); - if (questCategory == null){ + if (questCategory == null) { sendError(sender, "Unknown QuestCatID: " + questcatid); return; } int count = 0; - for(PlayerData playerdata : data){ - for(Quest quest : questCategory.quests.values()){ + for (PlayerData playerdata : data) { + for (Quest quest : questCategory.quests.values()) { playerdata.questData.activeQuests.remove(quest.id); playerdata.questData.finishedQuests.remove(quest.id); count++; diff --git a/src/main/java/kamkeel/npcs/command/QuestCommand.java b/src/main/java/kamkeel/npcs/command/QuestCommand.java index e1e0894d0..5382a203d 100644 --- a/src/main/java/kamkeel/npcs/command/QuestCommand.java +++ b/src/main/java/kamkeel/npcs/command/QuestCommand.java @@ -29,25 +29,25 @@ import static kamkeel.npcs.util.ColorUtil.sendResult; public class QuestCommand extends CommandKamkeelBase { - @Override - public String getCommandName() { - return "quest"; - } + @Override + public String getCommandName() { + return "quest"; + } - @Override - public String getDescription() { - return "Quest operations"; - } + @Override + public String getDescription() { + return "Quest operations"; + } @SubCommand( - desc = "Start a quest", - usage = " " + desc = "Start a quest", + usage = " " ) public void start(ICommandSender sender, String[] args) throws CommandException { String playername = args[0]; int questid; try { - questid = Integer.parseInt(args[1]); + questid = Integer.parseInt(args[1]); } catch (NumberFormatException ex) { sendError(sender, "QuestID must be an integer: " + args[1]); return; @@ -61,16 +61,16 @@ public class QuestCommand extends CommandKamkeelBase { } Quest quest = QuestController.Instance.quests.get(questid); - if (quest == null){ - sendError(sender, "Unknown QuestID: " + questid); + if (quest == null) { + sendError(sender, "Unknown QuestID: " + questid); return; } - for(PlayerData playerdata : data){ - QuestData questdata = new QuestData(quest); - playerdata.questData.activeQuests.put(questid, questdata); + for (PlayerData playerdata : data) { + QuestData questdata = new QuestData(quest); + playerdata.questData.activeQuests.put(questid, questdata); playerdata.save(); - if(playerdata.player != null && questdata.sendAlerts){ + if (playerdata.player != null && questdata.sendAlerts) { AchievementPacket.sendAchievement((EntityPlayerMP) playerdata.player, false, "quest.newquest", quest.title); ChatAlertPacket.sendChatAlert((EntityPlayerMP) playerdata.player, "quest.newquest", ": ", quest.title); } @@ -80,95 +80,14 @@ public class QuestCommand extends CommandKamkeelBase { } @SubCommand( - desc = "Finish a quest", - usage = " " + desc = "Finish a quest", + usage = " " ) - public void finish(ICommandSender sender, String args[]) throws CommandException{ - String playername=args[0]; + public void finish(ICommandSender sender, String args[]) throws CommandException { + String playername = args[0]; int questid; try { - questid = Integer.parseInt(args[1]); - } - catch (NumberFormatException ex) { - sendError(sender, "QuestID must be an integer: " + args[1]); - return; - } - - List data = PlayerDataController.Instance.getPlayersData(sender, playername); - if (data.isEmpty()) { - sendError(sender, String.format("Unknown player '%s'", playername)); - return; - } - - Quest quest = QuestController.Instance.quests.get(questid); - if (quest == null){ - sendError(sender, "Unknown QuestID: " + questid); - return; - } - for(PlayerData playerdata : data){ - playerdata.questData.activeQuests.remove(questid); - long completeTime; - if(quest.repeat == EnumQuestRepeat.RLDAILY || quest.repeat == EnumQuestRepeat.RLWEEKLY || quest.repeat == EnumQuestRepeat.RLCUSTOM){ - completeTime = System.currentTimeMillis(); - playerdata.questData.finishedQuests.put(quest.id, completeTime); - } else { - completeTime = sender.getEntityWorld().getTotalWorldTime(); - playerdata.questData.finishedQuests.put(quest.id, completeTime); - } - - if(ConfigMain.ProfilesEnabled && playerdata.player != null && quest.profileOptions.enableOptions && quest.profileOptions.completeControl == EnumProfileSync.Shared) - ProfileController.Instance.shareQuestCompletion(playerdata.player, quest.id, completeTime); - - playerdata.save(); - if(playerdata.player != null){ - AchievementPacket.sendAchievement((EntityPlayerMP) playerdata.player, false, "quest.completed", quest.title); - ChatAlertPacket.sendChatAlert((EntityPlayerMP) playerdata.player, "quest.completed", ": ", quest.title); - } - playerdata.updateClient = true; - sendResult(sender, String.format("Finished Quest \u00A7e%d\u00A77 for Player '\u00A7b%s\u00A77'", questid, playerdata.playername)); - } - } - - @SubCommand( - desc = "Stop a started quest", - usage = " " - ) - public void stop(ICommandSender sender, String[] args) throws CommandException { - String playername=args[0]; - int questid; - try { - questid = Integer.parseInt(args[1]); - } catch (NumberFormatException ex) { - sendError(sender, "QuestID must be an integer: " + args[1]); - return; - } - List data = PlayerDataController.Instance.getPlayersData(sender, playername); - if (data.isEmpty()) { - sendError(sender, String.format("Unknown player '%s'", playername)); - return; - } - Quest quest = QuestController.Instance.quests.get(questid); - if (quest == null){ - sendError(sender, "Unknown QuestID: " + questid); - return; - } - for(PlayerData playerdata : data){ - playerdata.questData.activeQuests.remove(questid); - playerdata.save(); - playerdata.updateClient = true; - sendResult(sender, String.format("Stopped Quest \u00A7e%d\u00A77 for Player '\u00A7b%s\u00A77'", questid, playerdata.playername)); - } - } - - @SubCommand( - desc = "Removes a quest from finished and active quests", - usage = " " - ) - public void remove(ICommandSender sender, String[] args) throws CommandException { - String playername=args[0]; - int questid; - try { - questid = Integer.parseInt(args[1]); + questid = Integer.parseInt(args[1]); } catch (NumberFormatException ex) { sendError(sender, "QuestID must be an integer: " + args[1]); return; @@ -181,14 +100,94 @@ public class QuestCommand extends CommandKamkeelBase { } Quest quest = QuestController.Instance.quests.get(questid); - if (quest == null){ - sendError(sender, "Unknown QuestID"); + if (quest == null) { + sendError(sender, "Unknown QuestID: " + questid); + return; + } + for (PlayerData playerdata : data) { + playerdata.questData.activeQuests.remove(questid); + long completeTime; + if (quest.repeat == EnumQuestRepeat.RLDAILY || quest.repeat == EnumQuestRepeat.RLWEEKLY || quest.repeat == EnumQuestRepeat.RLCUSTOM) { + completeTime = System.currentTimeMillis(); + playerdata.questData.finishedQuests.put(quest.id, completeTime); + } else { + completeTime = sender.getEntityWorld().getTotalWorldTime(); + playerdata.questData.finishedQuests.put(quest.id, completeTime); + } + + if (ConfigMain.ProfilesEnabled && playerdata.player != null && quest.profileOptions.enableOptions && quest.profileOptions.completeControl == EnumProfileSync.Shared) + ProfileController.Instance.shareQuestCompletion(playerdata.player, quest.id, completeTime); + + playerdata.save(); + if (playerdata.player != null) { + AchievementPacket.sendAchievement((EntityPlayerMP) playerdata.player, false, "quest.completed", quest.title); + ChatAlertPacket.sendChatAlert((EntityPlayerMP) playerdata.player, "quest.completed", ": ", quest.title); + } + playerdata.updateClient = true; + sendResult(sender, String.format("Finished Quest \u00A7e%d\u00A77 for Player '\u00A7b%s\u00A77'", questid, playerdata.playername)); + } + } + + @SubCommand( + desc = "Stop a started quest", + usage = " " + ) + public void stop(ICommandSender sender, String[] args) throws CommandException { + String playername = args[0]; + int questid; + try { + questid = Integer.parseInt(args[1]); + } catch (NumberFormatException ex) { + sendError(sender, "QuestID must be an integer: " + args[1]); + return; + } + List data = PlayerDataController.Instance.getPlayersData(sender, playername); + if (data.isEmpty()) { + sendError(sender, String.format("Unknown player '%s'", playername)); + return; + } + Quest quest = QuestController.Instance.quests.get(questid); + if (quest == null) { + sendError(sender, "Unknown QuestID: " + questid); + return; + } + for (PlayerData playerdata : data) { + playerdata.questData.activeQuests.remove(questid); + playerdata.save(); + playerdata.updateClient = true; + sendResult(sender, String.format("Stopped Quest \u00A7e%d\u00A77 for Player '\u00A7b%s\u00A77'", questid, playerdata.playername)); + } + } + + @SubCommand( + desc = "Removes a quest from finished and active quests", + usage = " " + ) + public void remove(ICommandSender sender, String[] args) throws CommandException { + String playername = args[0]; + int questid; + try { + questid = Integer.parseInt(args[1]); + } catch (NumberFormatException ex) { + sendError(sender, "QuestID must be an integer: " + args[1]); return; } - for(PlayerData playerdata : data){ - playerdata.questData.activeQuests.remove(questid); - playerdata.questData.finishedQuests.remove(questid); + List data = PlayerDataController.Instance.getPlayersData(sender, playername); + if (data.isEmpty()) { + sendError(sender, String.format("Unknown player '%s'", playername)); + return; + } + + Quest quest = QuestController.Instance.quests.get(questid); + if (quest == null) { + sendError(sender, "Unknown QuestID"); + return; + } + + for (PlayerData playerdata : data) { + playerdata.questData.activeQuests.remove(questid); + playerdata.questData.finishedQuests.remove(questid); playerdata.save(); playerdata.updateClient = true; sendResult(sender, String.format("Removed Quest \u00A7e%d\u00A77 for Player '\u00A7b%s\u00A77'", questid, playerdata.playername)); @@ -196,7 +195,7 @@ public class QuestCommand extends CommandKamkeelBase { } @SubCommand( - desc= "Get/Set objectives for quests progress", + desc = "Get/Set objectives for quests progress", usage = " [objective] [value]" ) public void objective(ICommandSender sender, String[] args) throws CommandException { @@ -210,13 +209,13 @@ public class QuestCommand extends CommandKamkeelBase { } Quest quest = QuestController.Instance.quests.get(questid); - if (quest == null){ + if (quest == null) { sendError(sender, "Unknown QuestID"); return; } PlayerData data = PlayerDataController.Instance.getPlayerData(player); - if (data == null){ + if (data == null) { sendError(sender, "No PlayerData found for:" + player); return; } @@ -224,21 +223,21 @@ public class QuestCommand extends CommandKamkeelBase { Party party = data.getPlayerParty(); boolean partyValid = party != null && party.getQuest() != null && party.getQuest().getId() == quest.id; - if(!partyValid && !data.questData.activeQuests.containsKey(quest.id)) { + if (!partyValid && !data.questData.activeQuests.containsKey(quest.id)) { sendError(sender, "Player does not have quest active"); return; } IQuestObjective[] objectives; - if(partyValid) + if (partyValid) objectives = quest.questInterface.getPartyObjectives(party); else objectives = quest.questInterface.getObjectives(player); - if(args.length <= 2) { - if(partyValid) + if (args.length <= 2) { + if (partyValid) sendResult(sender, "For Party: "); - for(IQuestObjective ob : objectives) { + for (IQuestObjective ob : objectives) { sendResult(sender, ob.getText()); } return; @@ -252,12 +251,12 @@ public class QuestCommand extends CommandKamkeelBase { return; } - if(objective < 0 || objective >= objectives.length) { + if (objective < 0 || objective >= objectives.length) { sendError(sender, "Invalid objective number was given"); return; } - if(args.length <= 3) { + if (args.length <= 3) { sendResult(sender, objectives[objective].getText()); return; } @@ -272,11 +271,11 @@ public class QuestCommand extends CommandKamkeelBase { return; } - if(s.startsWith("-") || s.startsWith("+")) { + if (s.startsWith("-") || s.startsWith("+")) { value = ValueUtil.CorrectInt(object.getProgress() + value, 0, object.getMaxProgress()); } - if(partyValid) + if (partyValid) object.setPlayerProgress(player.getCommandSenderName(), value); else object.setProgress(value); @@ -284,11 +283,11 @@ public class QuestCommand extends CommandKamkeelBase { } @SubCommand( - desc = "Find quest id number by its name", - usage = "" + desc = "Find quest id number by its name", + usage = "" ) public void id(ICommandSender sender, String args[]) throws CommandException { - if(args.length == 0){ + if (args.length == 0) { sendError(sender, "Please provide a name for the quest"); return; } @@ -296,23 +295,23 @@ public class QuestCommand extends CommandKamkeelBase { String catName = String.join(" ", args).toLowerCase(); final Collection quests = QuestController.Instance.quests.values(); int count = 0; - for(Quest quest : quests){ - if(quest.getName().toLowerCase().contains(catName)){ + for (Quest quest : quests) { + if (quest.getName().toLowerCase().contains(catName)) { sendResult(sender, String.format("Quest \u00A7e%d\u00A77 - \u00A7c'%s'", quest.id, quest.getName())); count++; } } - if(count == 0){ + if (count == 0) { sendResult(sender, String.format("No Quest found with name: \u00A7c'%s'", catName)); } } @SubCommand( - desc = "Find prerequisite quests for an id", - usage = "" + desc = "Find prerequisite quests for an id", + usage = "" ) public void prereq(ICommandSender sender, String args[]) throws CommandException { - if(args.length == 0){ + if (args.length == 0) { sendError(sender, "Please provide an id for the quest"); return; } @@ -326,7 +325,7 @@ public class QuestCommand extends CommandKamkeelBase { } Quest quest = QuestController.Instance.quests.get(questid); - if (quest == null){ + if (quest == null) { sendError(sender, "Unknown QuestID"); return; } @@ -334,25 +333,25 @@ public class QuestCommand extends CommandKamkeelBase { sendResult(sender, "Prerequisites:"); sendResult(sender, "--------------------"); boolean foundOne = false; - for(Quest allQuest : quests){ - if(allQuest.nextQuestid == questid){ + for (Quest allQuest : quests) { + if (allQuest.nextQuestid == questid) { foundOne = true; sendResult(sender, String.format("Quest %d: \u00A7a'%s'", allQuest.id, allQuest.title)); } } - if(!foundOne){ + if (!foundOne) { sendResult(sender, String.format("No Prerequisites found for Quest \u00A7c%d", questid)); } sendResult(sender, "--------------------"); } @SubCommand( - desc = "Quick info on a quest", - usage = "" + desc = "Quick info on a quest", + usage = "" ) public void info(ICommandSender sender, String args[]) throws CommandException { - if(args.length == 0){ + if (args.length == 0) { sendError(sender, "Please provide an id for the quest"); return; } @@ -366,7 +365,7 @@ public class QuestCommand extends CommandKamkeelBase { } Quest quest = QuestController.Instance.quests.get(questid); - if (quest == null){ + if (quest == null) { sendError(sender, "Unknown QuestID"); return; } @@ -377,21 +376,21 @@ public class QuestCommand extends CommandKamkeelBase { sendResult(sender, String.format("Type: \u00A76%s", quest.type.toString())); sendResult(sender, String.format("Repeatable: \u00A76%s", quest.repeat.toString())); sendResult(sender, String.format("Complete: \u00A76%s", quest.completion.toString())); - if(quest.completion == EnumQuestCompletion.Npc){ + if (quest.completion == EnumQuestCompletion.Npc) { sendResult(sender, String.format("NPC: \u00A76%s", quest.completerNpc)); } - if(quest.nextQuestid != -1){ + if (quest.nextQuestid != -1) { sendResult(sender, String.format("Next Quest ID: \u00A7c%d", quest.nextQuestid)); } sendResult(sender, "--------------------"); } @SubCommand( - desc="reload quests from disk", - permission = 4 + desc = "reload quests from disk", + permission = 4 ) - public void reload(ICommandSender sender, String args[]){ - new QuestController().load(); + public void reload(ICommandSender sender, String args[]) { + new QuestController().load(); SyncController.syncAllQuests(); sendResult(sender, "Quests Reloaded"); } diff --git a/src/main/java/kamkeel/npcs/command/ScriptCommand.java b/src/main/java/kamkeel/npcs/command/ScriptCommand.java index f314d2e42..41415cb81 100644 --- a/src/main/java/kamkeel/npcs/command/ScriptCommand.java +++ b/src/main/java/kamkeel/npcs/command/ScriptCommand.java @@ -11,33 +11,33 @@ public class ScriptCommand extends CommandKamkeelBase { @SubCommand(desc = "Reload scripts data and folders.") public Boolean reload(ICommandSender sender, String args[]) { - ScriptController.Instance.loadCategories(); + ScriptController.Instance.loadCategories(); - if(ScriptController.Instance.loadPlayerScripts()) - sendResult(sender, "Reload player scripts successfully"); - else - sendError(sender, "Failed reloading player scripts"); + if (ScriptController.Instance.loadPlayerScripts()) + sendResult(sender, "Reload player scripts successfully"); + else + sendError(sender, "Failed reloading player scripts"); - if(ScriptController.Instance.loadForgeScripts()) - sendResult(sender, "Reload forge scripts successfully"); - else - sendError(sender, "Failed reloading forge scripts"); + if (ScriptController.Instance.loadForgeScripts()) + sendResult(sender, "Reload forge scripts successfully"); + else + sendError(sender, "Failed reloading forge scripts"); - if(ScriptController.Instance.loadStoredData()) - sendResult(sender, "Reload stored data successfully"); - else - sendError(sender, "Failed reloading stored data"); - return true; + if (ScriptController.Instance.loadStoredData()) + sendResult(sender, "Reload stored data successfully"); + else + sendError(sender, "Failed reloading stored data"); + return true; - } + } - @Override - public String getCommandName() { - return "script"; - } + @Override + public String getCommandName() { + return "script"; + } - @Override - public String getDescription() { - return "Commands for scripts"; - } + @Override + public String getDescription() { + return "Commands for scripts"; + } } diff --git a/src/main/java/kamkeel/npcs/command/SlayCommand.java b/src/main/java/kamkeel/npcs/command/SlayCommand.java index 82400b148..260ef99c8 100644 --- a/src/main/java/kamkeel/npcs/command/SlayCommand.java +++ b/src/main/java/kamkeel/npcs/command/SlayCommand.java @@ -23,118 +23,117 @@ import java.util.*; import static kamkeel.npcs.util.ColorUtil.sendResult; public class SlayCommand extends CommandKamkeelBase { - public Map> SlayMap = new LinkedHashMap>(); + public Map> SlayMap = new LinkedHashMap>(); - public SlayCommand(){ + public SlayCommand() { SlayMap.clear(); - SlayMap.put("all",EntityLivingBase.class); - SlayMap.put("mobs",EntityMob.class); - SlayMap.put("animals", EntityAnimal.class); - SlayMap.put("items", EntityItem.class); - SlayMap.put("xporbs", EntityXPOrb.class); - SlayMap.put("npcs", EntityNPCInterface.class); + SlayMap.put("all", EntityLivingBase.class); + SlayMap.put("mobs", EntityMob.class); + SlayMap.put("animals", EntityAnimal.class); + SlayMap.put("items", EntityItem.class); + SlayMap.put("xporbs", EntityXPOrb.class); + SlayMap.put("npcs", EntityNPCInterface.class); - HashMap> list = new HashMap>(EntityList.stringToClassMapping); - for(String name : list.keySet()){ - Class cls = list.get(name); - if(EntityNPCInterface.class.isAssignableFrom(cls)) - continue; - if(!EntityLivingBase.class.isAssignableFrom(cls)) - continue; - SlayMap.put(name.toLowerCase(), list.get(name)); - } + HashMap> list = new HashMap>(EntityList.stringToClassMapping); + for (String name : list.keySet()) { + Class cls = list.get(name); + if (EntityNPCInterface.class.isAssignableFrom(cls)) + continue; + if (!EntityLivingBase.class.isAssignableFrom(cls)) + continue; + SlayMap.put(name.toLowerCase(), list.get(name)); + } - SlayMap.remove("monster"); - SlayMap.remove("mob"); - } + SlayMap.remove("monster"); + SlayMap.remove("mob"); + } - @Override - public String getCommandName() { - return "slay"; - } + @Override + public String getCommandName() { + return "slay"; + } - @Override - public String getDescription() { - return "Kills given entity within range. Tab to see options."; - } + @Override + public String getDescription() { + return "Kills given entity within range. Tab to see options."; + } - @Override - public String getUsage(){ - return ".. [range]"; - } + @Override + public String getUsage() { + return ".. [range]"; + } - @Override - public void processCommand(ICommandSender sender, String[] args) throws CommandException { - EntityPlayerMP player = (EntityPlayerMP) sender; - ArrayList> toDelete = new ArrayList>(); - boolean deleteNPCs = false; - for(String delete : args){ - delete = delete.toLowerCase(); - Class cls = SlayMap.get(delete); - if(cls != null) - toDelete.add(cls); - if(delete.equals("mobs")){ - toDelete.add(EntityGhast.class); - toDelete.add(EntityDragon.class); - } - if(delete.equals("npcs")) - deleteNPCs = true; - } - int count = 0; - int range = 120; - try{ - range = Integer.parseInt(args[args.length - 1]); - } - catch(NumberFormatException ex){ + @Override + public void processCommand(ICommandSender sender, String[] args) throws CommandException { + EntityPlayerMP player = (EntityPlayerMP) sender; + ArrayList> toDelete = new ArrayList>(); + boolean deleteNPCs = false; + for (String delete : args) { + delete = delete.toLowerCase(); + Class cls = SlayMap.get(delete); + if (cls != null) + toDelete.add(cls); + if (delete.equals("mobs")) { + toDelete.add(EntityGhast.class); + toDelete.add(EntityDragon.class); + } + if (delete.equals("npcs")) + deleteNPCs = true; + } + int count = 0; + int range = 120; + try { + range = Integer.parseInt(args[args.length - 1]); + } catch (NumberFormatException ex) { - } - AxisAlignedBB box = player.boundingBox.expand(range, range, range); - List list = sender.getEntityWorld().getEntitiesWithinAABB(EntityLivingBase.class, box); + } + AxisAlignedBB box = player.boundingBox.expand(range, range, range); + List list = sender.getEntityWorld().getEntitiesWithinAABB(EntityLivingBase.class, box); - for(Entity entity : list){ - if(entity instanceof EntityPlayer) - continue; - if(entity instanceof EntityTameable && ((EntityTameable)entity).isTamed()) - continue; - if(entity instanceof EntityNPCInterface && !deleteNPCs) - continue; - if(delete(entity,toDelete)) - count++; - } - if(toDelete.contains(EntityXPOrb.class)){ - list = sender.getEntityWorld().getEntitiesWithinAABB(EntityXPOrb.class, box); - for(Entity entity : list){ - entity.isDead = true; - count++; - } - } - if(toDelete.contains(EntityItem.class)){ - list = sender.getEntityWorld().getEntitiesWithinAABB(EntityItem.class, box); - for(Entity entity : list){ - entity.isDead = true; - count++; - } - } + for (Entity entity : list) { + if (entity instanceof EntityPlayer) + continue; + if (entity instanceof EntityTameable && ((EntityTameable) entity).isTamed()) + continue; + if (entity instanceof EntityNPCInterface && !deleteNPCs) + continue; + if (delete(entity, toDelete)) + count++; + } + if (toDelete.contains(EntityXPOrb.class)) { + list = sender.getEntityWorld().getEntitiesWithinAABB(EntityXPOrb.class, box); + for (Entity entity : list) { + entity.isDead = true; + count++; + } + } + if (toDelete.contains(EntityItem.class)) { + list = sender.getEntityWorld().getEntitiesWithinAABB(EntityItem.class, box); + for (Entity entity : list) { + entity.isDead = true; + count++; + } + } - sendResult(sender, count + " entities deleted"); - } + sendResult(sender, count + " entities deleted"); + } private boolean delete(Entity entity, ArrayList> toDelete) { - for(Class delete : toDelete){ - if(delete == EntityAnimal.class && (entity instanceof EntityHorse)){ - continue; - } - if(delete.isAssignableFrom(entity.getClass())){ - entity.isDead = true; - return true; - } - } - return false; - } + for (Class delete : toDelete) { + if (delete == EntityAnimal.class && (entity instanceof EntityHorse)) { + continue; + } + if (delete.isAssignableFrom(entity.getClass())) { + entity.isDead = true; + return true; + } + } + return false; + } - @Override - public List addTabCompletionOptions(ICommandSender sender, String[] args){ - return getListOfStringsMatchingLastWord(args, SlayMap.keySet().toArray(new String[SlayMap.size()])); - } + @Override + public List addTabCompletionOptions(ICommandSender sender, String[] args) { + return getListOfStringsMatchingLastWord(args, SlayMap.keySet().toArray(new String[SlayMap.size()])); + } } diff --git a/src/main/java/kamkeel/npcs/command/profile/CommandHelpProfile.java b/src/main/java/kamkeel/npcs/command/profile/CommandHelpProfile.java index acba768f5..bbbfcc066 100644 --- a/src/main/java/kamkeel/npcs/command/profile/CommandHelpProfile.java +++ b/src/main/java/kamkeel/npcs/command/profile/CommandHelpProfile.java @@ -15,7 +15,7 @@ import static kamkeel.npcs.util.ColorUtil.sendMessage; public class CommandHelpProfile extends CommandProfileBase { private CommandProfile parent; - public CommandHelpProfile(CommandProfile parent){ + public CommandHelpProfile(CommandProfile parent) { this.parent = parent; } @@ -31,9 +31,9 @@ public class CommandHelpProfile extends CommandProfileBase { @Override public void processCommand(ICommandSender sender, String[] args) throws CommandException { - if(args.length == 0){ + if (args.length == 0) { sendMessage(sender, "\u00A78------ \u00A7aProfile Commands \u00A78------"); - for(Entry entry : parent.map.entrySet()){ + for (Entry entry : parent.map.entrySet()) { sendMessage(sender, "\u00A77> " + "\u00A7e" + entry.getKey() + "\u00A78: \u00A77" + entry.getValue().getCommandUsage(sender)); } @@ -41,50 +41,49 @@ public class CommandHelpProfile extends CommandProfileBase { } CommandProfileBase command = parent.getCommand(args); - if(command == null){ + if (command == null) { sendError(sender, "Unknown command " + args[0]); return; } - if(command.subcommands.isEmpty()){ + if (command.subcommands.isEmpty()) { sendMessage(sender, (command.getCommandUsage(sender))); return; } Method m = null; - if(args.length > 1){ + if (args.length > 1) { m = command.subcommands.get(args[1].toLowerCase()); } - if(m == null){ + if (m == null) { sendMessage(sender, "\u00A78------ \u00A7a" + command.getCommandName().toUpperCase() + " SubCommands \u00A78------"); sendMessage(sender, "\u00A77Usage: \u00A76" + command.getUsage()); - for(Entry entry : command.subcommands.entrySet()){ + for (Entry entry : command.subcommands.entrySet()) { SubCommand sc = entry.getValue().getAnnotation(SubCommand.class); // For players, only list subcommands if they have permission; for console, show all. - if(!(sender instanceof EntityPlayer) || command.canSendCommand(sender, sc, entry.getKey())){ + if (!(sender instanceof EntityPlayer) || command.canSendCommand(sender, sc, entry.getKey())) { sendMessage(sender, ("\u00A77> " + "\u00A7e" + entry.getKey() + "\u00A78: \u00A77" + sc.desc())); } } // Show permission node only if sender is console or has permission. - if(!(sender instanceof EntityPlayer) || - CustomNpcsPermissions.hasPermission((EntityPlayer)sender, CustomNpcsPermissions.PROFILE_ADMIN)){ + if (!(sender instanceof EntityPlayer) || + CustomNpcsPermissions.hasPermission((EntityPlayer) sender, CustomNpcsPermissions.PROFILE_ADMIN)) { sendMessage(sender, ("\u00A78Permission:\u00A77 " + CommandProfile.getCommandPermission(command.getCommandName()))); } - } - else{ + } else { sendMessage(sender, "\u00A78------ \u00A7b" + command.getCommandName().toUpperCase() + "." + args[1].toUpperCase() + " Command \u00A78------"); SubCommand sc = m.getAnnotation(SubCommand.class); sendMessage(sender, ("\u00A77" + sc.desc())); - if(!sc.usage().isEmpty()){ + if (!sc.usage().isEmpty()) { sendMessage(sender, ("\u00A77Usage: \u00A76" + sc.usage())); } - if(!(sender instanceof EntityPlayer) || - CustomNpcsPermissions.hasPermission((EntityPlayer)sender, CustomNpcsPermissions.PROFILE_ADMIN)){ + if (!(sender instanceof EntityPlayer) || + CustomNpcsPermissions.hasPermission((EntityPlayer) sender, CustomNpcsPermissions.PROFILE_ADMIN)) { sendMessage(sender, ("\u00A78Permission:\u00A77 " + getSubCommandPermission(args[1]))); } diff --git a/src/main/java/kamkeel/npcs/command/profile/CommandProfile.java b/src/main/java/kamkeel/npcs/command/profile/CommandProfile.java index 4987f1bbf..843eb77f2 100644 --- a/src/main/java/kamkeel/npcs/command/profile/CommandProfile.java +++ b/src/main/java/kamkeel/npcs/command/profile/CommandProfile.java @@ -16,12 +16,12 @@ import java.util.Map; public class CommandProfile extends CommandBase { - public Map map = new HashMap(); - public CommandHelpProfile help = new CommandHelpProfile(this); - public String[] alias = {"profile"}; + public Map map = new HashMap(); + public CommandHelpProfile help = new CommandHelpProfile(this); + public String[] alias = {"profile"}; - public CommandProfile(){ - registerCommand(help); + public CommandProfile() { + registerCommand(help); registerCommand(new CommandProfileChange()); registerCommand(new CommandProfileCreate()); registerCommand(new CommandProfileRemove()); @@ -29,120 +29,119 @@ public class CommandProfile extends CommandBase { registerCommand(new CommandProfileRegion()); registerCommand(new CommandProfileList()); registerCommand(new CommandProfileRename()); - } - - public void registerCommand(CommandProfileBase command){ - String name = command.getCommandName().toLowerCase(); - if(map.containsKey(name)) - throw new CustomNPCsException("Already a subcommand with the name: " + name); - map.put(name, command); - } - - @Override - public String getCommandName() { - return "profile"; - } - - @Override - public List getCommandAliases() - { - return Arrays.asList(alias); - } - - @Override - public String getCommandUsage(ICommandSender sender) { - return "Use as /profile subcommand"; - } - - @Override - public void processCommand(ICommandSender sender, String[] args) throws CommandException { - if(args.length == 0){ - help.processCommand(sender, args); - return; - } - - CommandProfileBase command = getCommand(args); - if(command == null) - throw new CommandException("Unknown command " + args[0]); - - args = Arrays.copyOfRange(args, 1, args.length); - if(command.subcommands.isEmpty() || !command.runSubCommands()){ - if(!canSendCommand(sender, command)) - throw new CommandException("You are not allowed to use this command: " + command); - command.canRun(sender, command.getUsage(), args); - command.processCommand(sender, args); - return; - } - - if(args.length == 0){ - help.processCommand(sender, new String[]{command.getCommandName()}); - return; - } - - command.processSubCommand(sender, args[0], Arrays.copyOfRange(args, 1, args.length)); - } - - @Override - public List addTabCompletionOptions(ICommandSender sender, String[] args){ - if(args.length == 1) - return CommandBase.getListOfStringsMatchingLastWord(args, map.keySet().toArray(new String[map.size()])); - CommandProfileBase command = getCommand(args); - if(command == null) - return null; - if(args.length == 2 && command.runSubCommands()) - return getListOfStringsMatchingLastWord(args, command.subcommands.keySet().toArray(new String[command.subcommands.keySet().size()])); - String[] useArgs = command.getUsage().split(" "); - if(command.runSubCommands()) { - Method m = command.subcommands.get(args[1].toLowerCase()); - if(m != null) { - useArgs = m.getAnnotation(CommandProfileBase.SubCommand.class).usage().split(" "); - } - } - if(args.length <= useArgs.length + 2) { - if(args.length - 3 >= 0){ - String usage = useArgs[args.length - 3]; - if(usage.equals("") || usage.equals("[player]") || usage.equals("") - || usage.equals("") || usage.equals("")) { - return CommandBase.getListOfStringsMatchingLastWord(args, MinecraftServer.getServer().getAllUsernames()); - } - } - } - return command.addTabCompletionOptions(sender, Arrays.copyOfRange(args, 1, args.length)); } - public CommandProfileBase getCommand(String[] args){ - if(args.length == 0) - return null; - return map.get(args[0].toLowerCase()); + public void registerCommand(CommandProfileBase command) { + String name = command.getCommandName().toLowerCase(); + if (map.containsKey(name)) + throw new CustomNPCsException("Already a subcommand with the name: " + name); + map.put(name, command); } @Override - public int getRequiredPermissionLevel(){ + public String getCommandName() { + return "profile"; + } + + @Override + public List getCommandAliases() { + return Arrays.asList(alias); + } + + @Override + public String getCommandUsage(ICommandSender sender) { + return "Use as /profile subcommand"; + } + + @Override + public void processCommand(ICommandSender sender, String[] args) throws CommandException { + if (args.length == 0) { + help.processCommand(sender, args); + return; + } + + CommandProfileBase command = getCommand(args); + if (command == null) + throw new CommandException("Unknown command " + args[0]); + + args = Arrays.copyOfRange(args, 1, args.length); + if (command.subcommands.isEmpty() || !command.runSubCommands()) { + if (!canSendCommand(sender, command)) + throw new CommandException("You are not allowed to use this command: " + command); + command.canRun(sender, command.getUsage(), args); + command.processCommand(sender, args); + return; + } + + if (args.length == 0) { + help.processCommand(sender, new String[]{command.getCommandName()}); + return; + } + + command.processSubCommand(sender, args[0], Arrays.copyOfRange(args, 1, args.length)); + } + + @Override + public List addTabCompletionOptions(ICommandSender sender, String[] args) { + if (args.length == 1) + return CommandBase.getListOfStringsMatchingLastWord(args, map.keySet().toArray(new String[map.size()])); + CommandProfileBase command = getCommand(args); + if (command == null) + return null; + if (args.length == 2 && command.runSubCommands()) + return getListOfStringsMatchingLastWord(args, command.subcommands.keySet().toArray(new String[command.subcommands.keySet().size()])); + String[] useArgs = command.getUsage().split(" "); + if (command.runSubCommands()) { + Method m = command.subcommands.get(args[1].toLowerCase()); + if (m != null) { + useArgs = m.getAnnotation(CommandProfileBase.SubCommand.class).usage().split(" "); + } + } + if (args.length <= useArgs.length + 2) { + if (args.length - 3 >= 0) { + String usage = useArgs[args.length - 3]; + if (usage.equals("") || usage.equals("[player]") || usage.equals("") + || usage.equals("") || usage.equals("")) { + return CommandBase.getListOfStringsMatchingLastWord(args, MinecraftServer.getServer().getAllUsernames()); + } + } + } + return command.addTabCompletionOptions(sender, Arrays.copyOfRange(args, 1, args.length)); + } + + public CommandProfileBase getCommand(String[] args) { + if (args.length == 0) + return null; + return map.get(args[0].toLowerCase()); + } + + @Override + public int getRequiredPermissionLevel() { return 4; } - public static String getCommandPermission(String command){ - return "profile.kamkeel." + command.toLowerCase(); - } + public static String getCommandPermission(String command) { + return "profile.kamkeel." + command.toLowerCase(); + } - public static String getUniversalPermission(){ - return "profile.kamkeel.*"; - } + public static String getUniversalPermission() { + return "profile.kamkeel.*"; + } - public static boolean canSendCommand(ICommandSender sender, CommandProfileBase command){ - if(sender.canCommandSenderUseCommand(command.getRequiredPermissionLevel(), getUniversalPermission())){ - return true; - } + public static boolean canSendCommand(ICommandSender sender, CommandProfileBase command) { + if (sender.canCommandSenderUseCommand(command.getRequiredPermissionLevel(), getUniversalPermission())) { + return true; + } - if(sender.canCommandSenderUseCommand(command.getRequiredPermissionLevel(), getCommandPermission(command.getCommandName()))){ - return true; - } + if (sender.canCommandSenderUseCommand(command.getRequiredPermissionLevel(), getCommandPermission(command.getCommandName()))) { + return true; + } - if(sender instanceof EntityPlayer){ - return CustomNpcsPermissions.hasCustomPermission((EntityPlayer) sender, getCommandPermission(command.getCommandName())); - } + if (sender instanceof EntityPlayer) { + return CustomNpcsPermissions.hasCustomPermission((EntityPlayer) sender, getCommandPermission(command.getCommandName())); + } - return false; - } + return false; + } } diff --git a/src/main/java/kamkeel/npcs/command/profile/CommandProfileAdmin.java b/src/main/java/kamkeel/npcs/command/profile/CommandProfileAdmin.java index 044f7dff9..0d0f134eb 100644 --- a/src/main/java/kamkeel/npcs/command/profile/CommandProfileAdmin.java +++ b/src/main/java/kamkeel/npcs/command/profile/CommandProfileAdmin.java @@ -2,11 +2,11 @@ package kamkeel.npcs.command.profile; import kamkeel.npcs.controllers.ProfileController; import kamkeel.npcs.controllers.data.profile.EnumProfileOperation; -import noppes.npcs.api.handler.data.ISlot; import kamkeel.npcs.controllers.data.profile.Profile; import kamkeel.npcs.controllers.data.profile.ProfileOperation; import net.minecraft.command.CommandException; import net.minecraft.command.ICommandSender; +import noppes.npcs.api.handler.data.ISlot; import java.io.File; import java.util.Map; @@ -36,7 +36,7 @@ public class CommandProfileAdmin extends CommandProfileBase { usage = " [temp]" ) public void clone(ICommandSender sender, String[] args) throws CommandException { - if(args.length < 4) { + if (args.length < 4) { sendError(sender, "Usage: /profile admin clone [temp]"); return; } @@ -52,12 +52,12 @@ public class CommandProfileAdmin extends CommandProfileBase { } boolean temporary = (args.length >= 5 && args[4].equalsIgnoreCase("temp")); ProfileOperation result = ProfileController.Instance.cloneSlot(sourcePlayer, sourceSlot, destinationSlot, temporary); - if(result.getResult() == EnumProfileOperation.SUCCESS) { + if (result.getResult() == EnumProfileOperation.SUCCESS) { sendResult(sender, "Successfully cloned slot %d from %s to slot %d for %s.", sourceSlot, sourcePlayer, destinationSlot, destinationPlayer); - } else if(result.getResult() == EnumProfileOperation.LOCKED) { + } else if (result.getResult() == EnumProfileOperation.LOCKED) { // Detail message for admins – note: using result.getMessage() for further details. sendError(sender, "Clone failed for %s: Profile is locked. Details: %s", sourcePlayer, result.getMessage()); - } else if(result.getResult() == EnumProfileOperation.ERROR) { + } else if (result.getResult() == EnumProfileOperation.ERROR) { sendError(sender, "Error cloning slot for %s: %s", sourcePlayer, result.getMessage()); } else { sendError(sender, "Unexpected error cloning slot: %s", result.getMessage()); @@ -69,7 +69,7 @@ public class CommandProfileAdmin extends CommandProfileBase { usage = " " ) public void remove(ICommandSender sender, String[] args) throws CommandException { - if(args.length < 2) { + if (args.length < 2) { sendError(sender, "Usage: /profile admin remove "); return; } @@ -77,16 +77,16 @@ public class CommandProfileAdmin extends CommandProfileBase { int slotId; try { slotId = Integer.parseInt(args[1]); - } catch(NumberFormatException ex) { + } catch (NumberFormatException ex) { sendError(sender, "Slot ID must be a number."); return; } ProfileOperation result = ProfileController.Instance.removeSlot(targetPlayer, slotId); - if(result.getResult() == EnumProfileOperation.SUCCESS) { + if (result.getResult() == EnumProfileOperation.SUCCESS) { sendResult(sender, "Successfully removed slot %d from %s.", slotId, targetPlayer); - } else if(result.getResult() == EnumProfileOperation.LOCKED) { + } else if (result.getResult() == EnumProfileOperation.LOCKED) { sendError(sender, "Remove failed for %s: Profile is locked. Details: %s", targetPlayer, result.getMessage()); - } else if(result.getResult() == EnumProfileOperation.ERROR) { + } else if (result.getResult() == EnumProfileOperation.ERROR) { sendError(sender, "Error removing slot %d from %s: %s", slotId, targetPlayer, result.getMessage()); } else { sendError(sender, "Unexpected error during removal: %s", result.getMessage()); @@ -98,7 +98,7 @@ public class CommandProfileAdmin extends CommandProfileBase { usage = " " ) public void change(ICommandSender sender, String[] args) throws CommandException { - if(args.length < 2) { + if (args.length < 2) { sendError(sender, "Usage: /profile admin change "); return; } @@ -106,16 +106,16 @@ public class CommandProfileAdmin extends CommandProfileBase { int newSlotId; try { newSlotId = Integer.parseInt(args[1]); - } catch(NumberFormatException ex) { + } catch (NumberFormatException ex) { sendError(sender, "Slot ID must be a number."); return; } ProfileOperation result = ProfileController.Instance.changeSlot(targetPlayer, newSlotId); - if(result.getResult() == EnumProfileOperation.SUCCESS) { + if (result.getResult() == EnumProfileOperation.SUCCESS) { sendResult(sender, "Successfully changed %s's active slot to %d.", targetPlayer, newSlotId); - } else if(result.getResult() == EnumProfileOperation.LOCKED) { + } else if (result.getResult() == EnumProfileOperation.LOCKED) { sendError(sender, "Change failed for %s: Profile is locked. Details: %s", targetPlayer, result.getMessage()); - } else if(result.getResult() == EnumProfileOperation.ERROR) { + } else if (result.getResult() == EnumProfileOperation.ERROR) { sendError(sender, "Error changing active slot for %s: %s", targetPlayer, result.getMessage()); } else { sendError(sender, "Unexpected error during change: %s", result.getMessage()); @@ -127,22 +127,22 @@ public class CommandProfileAdmin extends CommandProfileBase { usage = "" ) public void create(ICommandSender sender, String[] args) throws CommandException { - if(args.length < 1) { + if (args.length < 1) { sendError(sender, "Usage: /profile admin create "); return; } String targetPlayer = args[0]; Profile profile = ProfileController.Instance.getProfile(targetPlayer); - if(profile == null) { + if (profile == null) { sendError(sender, "Profile not found for player: %s", targetPlayer); return; } ProfileOperation result = ProfileController.Instance.createSlotInternal(profile); - if(result.getResult() == EnumProfileOperation.SUCCESS) { + if (result.getResult() == EnumProfileOperation.SUCCESS) { sendResult(sender, "New slot created successfully for %s.", targetPlayer); - } else if(result.getResult() == EnumProfileOperation.LOCKED) { + } else if (result.getResult() == EnumProfileOperation.LOCKED) { sendError(sender, "Create failed for %s: Profile is locked. Details: %s", targetPlayer, result.getMessage()); - } else if(result.getResult() == EnumProfileOperation.ERROR) { + } else if (result.getResult() == EnumProfileOperation.ERROR) { sendError(sender, "Error creating new slot for %s: %s", targetPlayer, result.getMessage()); } else { sendError(sender, "Unexpected error during slot creation: %s", result.getMessage()); @@ -154,18 +154,18 @@ public class CommandProfileAdmin extends CommandProfileBase { usage = "" ) public void list(ICommandSender sender, String[] args) throws CommandException { - if(args.length < 1) { + if (args.length < 1) { sendError(sender, "Usage: /profile admin list "); return; } String targetPlayer = args[0]; Profile profile = ProfileController.Instance.getProfile(targetPlayer); - if(profile == null) { + if (profile == null) { sendError(sender, "Profile not found for player: %s", targetPlayer); return; } sendMessage(sender, "Profile Slots for %s:", targetPlayer); - for(Map.Entry entry : profile.getSlots().entrySet()) { + for (Map.Entry entry : profile.getSlots().entrySet()) { int id = entry.getKey(); String name = entry.getValue().getName(); String prefix = (id == profile.currentSlotId) ? "* " : "- "; @@ -178,7 +178,7 @@ public class CommandProfileAdmin extends CommandProfileBase { usage = " " ) public void rename(ICommandSender sender, String[] args) throws CommandException { - if(args.length < 3) { + if (args.length < 3) { sendError(sender, "Usage: /profile admin rename "); return; } @@ -186,42 +186,42 @@ public class CommandProfileAdmin extends CommandProfileBase { int slotId; try { slotId = Integer.parseInt(args[1]); - } catch(NumberFormatException ex) { + } catch (NumberFormatException ex) { sendError(sender, "Slot ID must be a number."); return; } StringBuilder sb = new StringBuilder(); - for(int i = 2; i < args.length; i++){ - if(i > 2) sb.append(" "); + for (int i = 2; i < args.length; i++) { + if (i > 2) sb.append(" "); sb.append(args[i]); } String newName = sb.toString().trim(); - if(newName.length() > 20) { + if (newName.length() > 20) { newName = newName.substring(0, 20); } - if(!newName.matches("[A-Za-z ]+")){ + if (!newName.matches("[A-Za-z ]+")) { sendError(sender, "Invalid name. Only alphabetic characters and spaces are allowed."); return; } Profile profile = ProfileController.Instance.getProfile(targetPlayer); - if(profile == null) { + if (profile == null) { sendError(sender, "Profile not found for player: %s", targetPlayer); return; } - if(profile.isLocked()) { + if (profile.isLocked()) { sendError(sender, "Profile for %s is locked. Please try again later.", targetPlayer); return; } - if(!profile.getSlots().containsKey(slotId)) { + if (!profile.getSlots().containsKey(slotId)) { sendError(sender, "Slot %d not found in %s's profile.", slotId, targetPlayer); return; } profile.getSlots().get(slotId).setName(newName); - if(profile.getPlayer() != null) { + if (profile.getPlayer() != null) { ProfileController.Instance.save(profile.player, profile); } else { UUID uuid = ProfileController.Instance.getUUIDFromUsername(targetPlayer); - if(uuid != null) + if (uuid != null) ProfileController.Instance.saveOffline(profile, uuid); } sendResult(sender, "Successfully renamed slot %d for %s to '%s'.", slotId, targetPlayer, newName); @@ -232,7 +232,7 @@ public class CommandProfileAdmin extends CommandProfileBase { usage = " " ) public void rollback(ICommandSender sender, String[] args) throws CommandException { - if(args.length < 2) { + if (args.length < 2) { sendError(sender, "Usage: /profile admin rollback "); return; } @@ -240,17 +240,17 @@ public class CommandProfileAdmin extends CommandProfileBase { String backupFileName = args[1] + ".dat"; Profile profile = ProfileController.Instance.getProfile(targetPlayer); - if(profile == null || profile.player == null) + if (profile == null || profile.player == null) return; File backupDir = new File(ProfileController.getBackupDir(), profile.getPlayer().getUniqueID().toString()); File backupFile = new File(backupDir, backupFileName); - if(!backupFile.exists()){ + if (!backupFile.exists()) { sendError(sender, "Backup file %s not found for player %s.", backupFileName, targetPlayer); return; } boolean success = ProfileController.Instance.rollbackProfile(targetPlayer, backupFile); - if(success) { + if (success) { sendResult(sender, "Successfully rolled back %s's profile to backup %s.", targetPlayer, backupFileName); } else { sendError(sender, "Failed to rollback %s's profile.", targetPlayer); diff --git a/src/main/java/kamkeel/npcs/command/profile/CommandProfileBase.java b/src/main/java/kamkeel/npcs/command/profile/CommandProfileBase.java index 71f44a4be..8eb15f8db 100644 --- a/src/main/java/kamkeel/npcs/command/profile/CommandProfileBase.java +++ b/src/main/java/kamkeel/npcs/command/profile/CommandProfileBase.java @@ -16,10 +16,10 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -public abstract class CommandProfileBase extends CommandBase{ - public Map subcommands = new HashMap(); +public abstract class CommandProfileBase extends CommandBase { + public Map subcommands = new HashMap(); - public CommandProfileBase(){ + public CommandProfileBase() { for (Method m : this.getClass().getDeclaredMethods()) { SubCommand sc = m.getAnnotation(SubCommand.class); if (sc != null) { @@ -29,107 +29,107 @@ public abstract class CommandProfileBase extends CommandBase{ subcommands.put(name.toLowerCase(), m); } } - } + } - @Override - public void processCommand(ICommandSender sender, String[] args) throws CommandException { + @Override + public void processCommand(ICommandSender sender, String[] args) throws CommandException { - } + } - @Override - public String getCommandUsage(ICommandSender sender) { - return getDescription(); - } + @Override + public String getCommandUsage(ICommandSender sender) { + return getDescription(); + } - public abstract String getDescription(); + public abstract String getDescription(); - /** - * @return Should return a string in the format of [arg4] where <> is a required parameter and [] optional - */ - public String getUsage(){ - return ""; - } + /** + * @return Should return a string in the format of [arg4] where <> is a required parameter and [] optional + */ + public String getUsage() { + return ""; + } - public boolean runSubCommands(){ - return !subcommands.isEmpty(); - } + public boolean runSubCommands() { + return !subcommands.isEmpty(); + } @Retention(value = RetentionPolicy.RUNTIME) - @Target(ElementType.METHOD) - public @interface SubCommand { + @Target(ElementType.METHOD) + public @interface SubCommand { - String name() default ""; + String name() default ""; - /** - * @return Should return a string in the format of [arg4] where <> is a required parameter and [] optional - */ - String usage() default ""; + /** + * @return Should return a string in the format of [arg4] where <> is a required parameter and [] optional + */ + String usage() default ""; - String desc(); + String desc(); - int permission() default 2; - } + int permission() default 2; + } - public void processSubCommand(ICommandSender sender, String command, String[] args) throws CommandException { - Method m = subcommands.get(command.toLowerCase()); - if(m == null) - throw new CommandException("Unknown subcommand " + command); + public void processSubCommand(ICommandSender sender, String command, String[] args) throws CommandException { + Method m = subcommands.get(command.toLowerCase()); + if (m == null) + throw new CommandException("Unknown subcommand " + command); - SubCommand sc = m.getAnnotation(SubCommand.class); - if(!canSendCommand(sender, sc, command)) - throw new CommandException("You are not allowed to use this command: " + command); + SubCommand sc = m.getAnnotation(SubCommand.class); + if (!canSendCommand(sender, sc, command)) + throw new CommandException("You are not allowed to use this command: " + command); - canRun(sender, sc.usage(), args); - try { - m.invoke(this, sender, args); - } catch (Exception e) { - e.printStackTrace(); - } - } + canRun(sender, sc.usage(), args); + try { + m.invoke(this, sender, args); + } catch (Exception e) { + e.printStackTrace(); + } + } - public void canRun(ICommandSender sender, String usage, String[] args) throws CommandException{ - String[] np = usage.split(" "); - List required = new ArrayList(); - for(int i = 0; i < np.length; i++){ - String command = np[i]; - if(command.startsWith("<")){ - required.add(command); - } - if(command.equals("") && args.length > i){ - CommandBase.getPlayer(sender, args[i]); //throws PlayerNotFoundException if no player is found - } + public void canRun(ICommandSender sender, String usage, String[] args) throws CommandException { + String[] np = usage.split(" "); + List required = new ArrayList(); + for (int i = 0; i < np.length; i++) { + String command = np[i]; + if (command.startsWith("<")) { + required.add(command); + } + if (command.equals("") && args.length > i) { + CommandBase.getPlayer(sender, args[i]); //throws PlayerNotFoundException if no player is found + } - } - if (args.length < required.size()) { - throw new CommandException("Missing parameter: " + required.get(args.length)); - } - } + } + if (args.length < required.size()) { + throw new CommandException("Missing parameter: " + required.get(args.length)); + } + } - public int getRequiredPermissionLevel(){ + public int getRequiredPermissionLevel() { return 2; } - public String getSubCommandPermission(String subCommand){ - return "profile.kamkeel." + getCommandName().toLowerCase() + "." + subCommand.toLowerCase(); - } + public String getSubCommandPermission(String subCommand) { + return "profile.kamkeel." + getCommandName().toLowerCase() + "." + subCommand.toLowerCase(); + } - public String getSubUniversalPermission(){ - return "profile.kamkeel." + getCommandName().toLowerCase() + "*"; - } + public String getSubUniversalPermission() { + return "profile.kamkeel." + getCommandName().toLowerCase() + "*"; + } - public boolean canSendCommand(ICommandSender sender, SubCommand command, String subCommand){ - if(sender.canCommandSenderUseCommand(command.permission(), getSubUniversalPermission())){ - return true; - } + public boolean canSendCommand(ICommandSender sender, SubCommand command, String subCommand) { + if (sender.canCommandSenderUseCommand(command.permission(), getSubUniversalPermission())) { + return true; + } - if(sender.canCommandSenderUseCommand(command.permission(), getSubCommandPermission(subCommand))){ - return true; - } + if (sender.canCommandSenderUseCommand(command.permission(), getSubCommandPermission(subCommand))) { + return true; + } - if(sender instanceof EntityPlayer){ - return CustomNpcsPermissions.hasCustomPermission((EntityPlayer) sender, getSubCommandPermission(subCommand)); - } + if (sender instanceof EntityPlayer) { + return CustomNpcsPermissions.hasCustomPermission((EntityPlayer) sender, getSubCommandPermission(subCommand)); + } - return false; - } + return false; + } } diff --git a/src/main/java/kamkeel/npcs/command/profile/CommandProfileChange.java b/src/main/java/kamkeel/npcs/command/profile/CommandProfileChange.java index 481664626..40776afbd 100644 --- a/src/main/java/kamkeel/npcs/command/profile/CommandProfileChange.java +++ b/src/main/java/kamkeel/npcs/command/profile/CommandProfileChange.java @@ -34,28 +34,28 @@ public class CommandProfileChange extends CommandProfileBase { @Override public void processCommand(ICommandSender sender, String[] args) throws CommandException { - if(!(sender instanceof EntityPlayer)) { + if (!(sender instanceof EntityPlayer)) { sendError(sender, "This command can only be used by a player."); return; } - if(args.length < 1) { + if (args.length < 1) { sendError(sender, "Usage: " + getUsage()); return; } int slotId; try { slotId = Integer.parseInt(args[0]); - } catch(NumberFormatException ex) { + } catch (NumberFormatException ex) { sendError(sender, "Slot ID must be a number: " + args[0]); return; } - EntityPlayer player = (EntityPlayer)sender; + EntityPlayer player = (EntityPlayer) sender; ProfileOperation result = ProfileController.Instance.changeSlot(player, slotId); - if(result.getResult() == EnumProfileOperation.SUCCESS) { + if (result.getResult() == EnumProfileOperation.SUCCESS) { sendResult(sender, "Successfully changed profile slot to %d.", slotId); - } else if(result.getResult() == EnumProfileOperation.LOCKED) { + } else if (result.getResult() == EnumProfileOperation.LOCKED) { sendError(sender, "Profile is locked. Details: %s", result.getMessage()); - } else if(result.getResult() == EnumProfileOperation.ERROR) { + } else if (result.getResult() == EnumProfileOperation.ERROR) { sendError(sender, "Error changing your profile slot: %s", result.getMessage()); } else { sendError(sender, "Unexpected error: %s", result.getMessage()); diff --git a/src/main/java/kamkeel/npcs/command/profile/CommandProfileCreate.java b/src/main/java/kamkeel/npcs/command/profile/CommandProfileCreate.java index bda50bd85..213f9d625 100644 --- a/src/main/java/kamkeel/npcs/command/profile/CommandProfileCreate.java +++ b/src/main/java/kamkeel/npcs/command/profile/CommandProfileCreate.java @@ -34,21 +34,21 @@ public class CommandProfileCreate extends CommandProfileBase { @Override public void processCommand(ICommandSender sender, String[] args) throws CommandException { - if(!(sender instanceof EntityPlayer)) { + if (!(sender instanceof EntityPlayer)) { sendError(sender, "This command can only be used by a player."); return; } - EntityPlayer player = (EntityPlayer)sender; - if(ProfileController.Instance.getProfile(player) == null) { + EntityPlayer player = (EntityPlayer) sender; + if (ProfileController.Instance.getProfile(player) == null) { sendError(sender, "Profile not found."); return; } ProfileOperation result = ProfileController.Instance.createSlotInternal(ProfileController.Instance.getProfile(player)); - if(result.getResult() == EnumProfileOperation.SUCCESS) { + if (result.getResult() == EnumProfileOperation.SUCCESS) { sendResult(sender, "New profile slot created successfully."); - } else if(result.getResult() == EnumProfileOperation.LOCKED) { + } else if (result.getResult() == EnumProfileOperation.LOCKED) { sendError(sender, "Profile is locked. Details: %s", result.getMessage()); - } else if(result.getResult() == EnumProfileOperation.ERROR) { + } else if (result.getResult() == EnumProfileOperation.ERROR) { sendError(sender, "Error creating new profile slot: %s", result.getMessage()); } else { sendError(sender, "Unexpected error: %s", result.getMessage()); diff --git a/src/main/java/kamkeel/npcs/command/profile/CommandProfileList.java b/src/main/java/kamkeel/npcs/command/profile/CommandProfileList.java index 4463a1f58..1cbd0f620 100644 --- a/src/main/java/kamkeel/npcs/command/profile/CommandProfileList.java +++ b/src/main/java/kamkeel/npcs/command/profile/CommandProfileList.java @@ -1,11 +1,11 @@ package kamkeel.npcs.command.profile; import kamkeel.npcs.controllers.ProfileController; -import noppes.npcs.api.handler.data.ISlot; import kamkeel.npcs.controllers.data.profile.Profile; import net.minecraft.command.CommandException; import net.minecraft.command.ICommandSender; import net.minecraft.entity.player.EntityPlayer; +import noppes.npcs.api.handler.data.ISlot; import java.util.Map; @@ -31,21 +31,21 @@ public class CommandProfileList extends CommandProfileBase { @Override public void processCommand(ICommandSender sender, String[] args) throws CommandException { - if(!(sender instanceof EntityPlayer)) { + if (!(sender instanceof EntityPlayer)) { sendError(sender, "This command can only be used by a player."); return; } - EntityPlayer player = (EntityPlayer)sender; + EntityPlayer player = (EntityPlayer) sender; Profile profile = ProfileController.Instance.getProfile(player); - if(profile == null) { + if (profile == null) { sendError(sender, "Profile not found."); return; } - if(profile.getSlots().isEmpty()){ + if (profile.getSlots().isEmpty()) { sendMessage(sender, "No slots found. Using default slot 0."); } sendMessage(sender, "Your Profile Slots:"); - for(Map.Entry entry : profile.getSlots().entrySet()) { + for (Map.Entry entry : profile.getSlots().entrySet()) { int id = entry.getKey(); String name = entry.getValue().getName(); String prefix = (id == profile.currentSlotId) ? "* " : "- "; diff --git a/src/main/java/kamkeel/npcs/command/profile/CommandProfileRegion.java b/src/main/java/kamkeel/npcs/command/profile/CommandProfileRegion.java index e91708b43..4c6e9ff1e 100644 --- a/src/main/java/kamkeel/npcs/command/profile/CommandProfileRegion.java +++ b/src/main/java/kamkeel/npcs/command/profile/CommandProfileRegion.java @@ -33,7 +33,7 @@ public class CommandProfileRegion extends CommandProfileBase { public void enable(ICommandSender sender, String[] args) throws CommandException { ConfigMain.RegionProfileSwitching = true; ConfigMain.RegionProfileSwitchingProperty.set(true); - if(ConfigMain.config.hasChanged()){ + if (ConfigMain.config.hasChanged()) { ConfigMain.config.save(); } sendResult(sender, "Profile region switching enabled."); @@ -46,7 +46,7 @@ public class CommandProfileRegion extends CommandProfileBase { public void disable(ICommandSender sender, String[] args) throws CommandException { ConfigMain.RegionProfileSwitching = false; ConfigMain.RegionProfileSwitchingProperty.set(false); - if(ConfigMain.config.hasChanged()){ + if (ConfigMain.config.hasChanged()) { ConfigMain.config.save(); } sendResult(sender, "Profile region switching disabled."); @@ -57,32 +57,32 @@ public class CommandProfileRegion extends CommandProfileBase { usage = " " ) public void add(ICommandSender sender, String[] args) throws CommandException { - if(args.length != 7){ + if (args.length != 7) { sendError(sender, "Usage: /profile region add "); return; } List regionList = new ArrayList<>(); try { - for(String arg : args){ + for (String arg : args) { regionList.add(Integer.parseInt(arg)); } - } catch(NumberFormatException e){ + } catch (NumberFormatException e) { sendError(sender, "Invalid number format in region data."); return; } ConfigMain.RestrictedProfileRegions.add(regionList); // Update config property value List regionStrings = new ArrayList<>(); - for(List region : ConfigMain.RestrictedProfileRegions) { + for (List region : ConfigMain.RestrictedProfileRegions) { StringBuilder sb = new StringBuilder(); for (int i = 0; i < region.size(); i++) { - if(i > 0) sb.append(" "); + if (i > 0) sb.append(" "); sb.append(region.get(i)); } regionStrings.add(sb.toString()); } ConfigMain.RestrictedProfileRegionsProperty.set(regionStrings.toArray(new String[0])); - if(ConfigMain.config.hasChanged()){ + if (ConfigMain.config.hasChanged()) { ConfigMain.config.save(); } sendResult(sender, "Region added successfully."); @@ -93,35 +93,35 @@ public class CommandProfileRegion extends CommandProfileBase { usage = "" ) public void remove(ICommandSender sender, String[] args) throws CommandException { - if(args.length < 1){ + if (args.length < 1) { sendError(sender, "Usage: /profile region remove "); return; } int index; try { index = Integer.parseInt(args[0]); - } catch(NumberFormatException e){ + } catch (NumberFormatException e) { sendError(sender, "Index must be a number."); return; } index = index - 1; // Convert to 0-based index - if(index < 0 || index >= ConfigMain.RestrictedProfileRegions.size()){ + if (index < 0 || index >= ConfigMain.RestrictedProfileRegions.size()) { sendError(sender, "Invalid index. Must be between 1 and " + ConfigMain.RestrictedProfileRegions.size()); return; } ConfigMain.RestrictedProfileRegions.remove(index); // Update config property value List regionStrings = new ArrayList<>(); - for(List region : ConfigMain.RestrictedProfileRegions) { + for (List region : ConfigMain.RestrictedProfileRegions) { StringBuilder sb = new StringBuilder(); for (int i = 0; i < region.size(); i++) { - if(i > 0) sb.append(", "); + if (i > 0) sb.append(", "); sb.append(region.get(i)); } regionStrings.add(sb.toString()); } ConfigMain.RestrictedProfileRegionsProperty.set(regionStrings.toArray(new String[0])); - if(ConfigMain.config.hasChanged()){ + if (ConfigMain.config.hasChanged()) { ConfigMain.config.save(); } sendResult(sender, "Region removed successfully."); @@ -132,17 +132,17 @@ public class CommandProfileRegion extends CommandProfileBase { usage = "" ) public void list(ICommandSender sender, String[] args) throws CommandException { - if(ConfigMain.RestrictedProfileRegions.isEmpty()){ + if (ConfigMain.RestrictedProfileRegions.isEmpty()) { sendMessage(sender, "No restricted profile regions configured."); return; } sendMessage(sender, "Restricted Profile Regions:"); int i = 1; - for(List region : ConfigMain.RestrictedProfileRegions) { + for (List region : ConfigMain.RestrictedProfileRegions) { StringBuilder sb = new StringBuilder(); sb.append(i).append(": "); for (int j = 0; j < region.size(); j++) { - if(j > 0) sb.append(", "); + if (j > 0) sb.append(", "); sb.append(region.get(j)); } sendMessage(sender, sb.toString()); diff --git a/src/main/java/kamkeel/npcs/command/profile/CommandProfileRemove.java b/src/main/java/kamkeel/npcs/command/profile/CommandProfileRemove.java index 3c3247895..464e6f0ac 100644 --- a/src/main/java/kamkeel/npcs/command/profile/CommandProfileRemove.java +++ b/src/main/java/kamkeel/npcs/command/profile/CommandProfileRemove.java @@ -34,28 +34,28 @@ public class CommandProfileRemove extends CommandProfileBase { @Override public void processCommand(ICommandSender sender, String[] args) throws CommandException { - if(!(sender instanceof EntityPlayer)) { + if (!(sender instanceof EntityPlayer)) { sendError(sender, "This command can only be used by a player."); return; } - if(args.length < 1) { + if (args.length < 1) { sendError(sender, "Usage: " + getUsage()); return; } int slotId; try { slotId = Integer.parseInt(args[0]); - } catch(NumberFormatException ex) { + } catch (NumberFormatException ex) { sendError(sender, "Slot ID must be a number: " + args[0]); return; } - EntityPlayer player = (EntityPlayer)sender; + EntityPlayer player = (EntityPlayer) sender; ProfileOperation result = ProfileController.Instance.removeSlot(player, slotId); - if(result.getResult() == EnumProfileOperation.SUCCESS) { + if (result.getResult() == EnumProfileOperation.SUCCESS) { sendResult(sender, "Successfully removed slot %d from your profile.", slotId); - } else if(result.getResult() == EnumProfileOperation.LOCKED) { + } else if (result.getResult() == EnumProfileOperation.LOCKED) { sendError(sender, "Profile is locked. Details: %s", result.getMessage()); - } else if(result.getResult() == EnumProfileOperation.ERROR) { + } else if (result.getResult() == EnumProfileOperation.ERROR) { sendError(sender, "Error removing slot: %s", result.getMessage()); } else { sendError(sender, "Unexpected error: %s", result.getMessage()); diff --git a/src/main/java/kamkeel/npcs/command/profile/CommandProfileRename.java b/src/main/java/kamkeel/npcs/command/profile/CommandProfileRename.java index 50108d7b1..4b3bbe4af 100644 --- a/src/main/java/kamkeel/npcs/command/profile/CommandProfileRename.java +++ b/src/main/java/kamkeel/npcs/command/profile/CommandProfileRename.java @@ -27,40 +27,40 @@ public class CommandProfileRename extends CommandProfileBase { @Override public void processCommand(ICommandSender sender, String[] args) throws CommandException { - if(!(sender instanceof EntityPlayer)) { + if (!(sender instanceof EntityPlayer)) { sendError(sender, "This command can only be used by a player."); return; } - if(args.length < 2) { + if (args.length < 2) { sendError(sender, "Usage: " + getUsage()); return; } int slotId; try { slotId = Integer.parseInt(args[0]); - } catch(NumberFormatException ex) { + } catch (NumberFormatException ex) { sendError(sender, "Slot ID must be a number."); return; } StringBuilder sb = new StringBuilder(); - for(int i = 1; i < args.length; i++){ - if(i > 1) sb.append(" "); + for (int i = 1; i < args.length; i++) { + if (i > 1) sb.append(" "); sb.append(args[i]); } String newName = sb.toString().trim(); - if(newName.length() > 20) { + if (newName.length() > 20) { newName = newName.substring(0, 20); } - if(!newName.matches("[A-Za-z ]+")){ + if (!newName.matches("[A-Za-z ]+")) { sendError(sender, "Invalid name. Only alphabetic characters and spaces are allowed."); return; } - EntityPlayer player = (EntityPlayer)sender; - if(ProfileController.Instance.getProfile(player) == null) { + EntityPlayer player = (EntityPlayer) sender; + if (ProfileController.Instance.getProfile(player) == null) { sendError(sender, "Profile not found."); return; } - if(!ProfileController.Instance.getProfile(player).getSlots().containsKey(slotId)) { + if (!ProfileController.Instance.getProfile(player).getSlots().containsKey(slotId)) { sendError(sender, "Slot %d not found in your profile.", slotId); return; } diff --git a/src/main/java/kamkeel/npcs/controllers/AttributeController.java b/src/main/java/kamkeel/npcs/controllers/AttributeController.java index dac29046c..6eb28b513 100644 --- a/src/main/java/kamkeel/npcs/controllers/AttributeController.java +++ b/src/main/java/kamkeel/npcs/controllers/AttributeController.java @@ -1,10 +1,10 @@ package kamkeel.npcs.controllers; -import net.minecraft.entity.player.EntityPlayer; +import kamkeel.npcs.CustomAttributes; import kamkeel.npcs.controllers.data.attribute.AttributeDefinition; import kamkeel.npcs.controllers.data.attribute.AttributeValueType; -import kamkeel.npcs.CustomAttributes; import kamkeel.npcs.controllers.data.attribute.tracker.PlayerAttributeTracker; +import net.minecraft.entity.player.EntityPlayer; import java.util.Collection; import java.util.HashMap; @@ -24,7 +24,7 @@ public class AttributeController { private static final Map trackers = new HashMap<>(); private static final Map definitions = new HashMap<>(); - public AttributeController(){ + public AttributeController() { this.Instance = this; definitions.clear(); trackers.clear(); diff --git a/src/main/java/kamkeel/npcs/controllers/ProfileController.java b/src/main/java/kamkeel/npcs/controllers/ProfileController.java index c309c8195..6c657b70c 100644 --- a/src/main/java/kamkeel/npcs/controllers/ProfileController.java +++ b/src/main/java/kamkeel/npcs/controllers/ProfileController.java @@ -7,8 +7,8 @@ import net.minecraft.nbt.NBTTagCompound; import noppes.npcs.*; import noppes.npcs.api.entity.IPlayer; import noppes.npcs.api.handler.IPlayerData; -import noppes.npcs.api.handler.data.IProfile; import noppes.npcs.api.handler.IProfileHandler; +import noppes.npcs.api.handler.data.IProfile; import noppes.npcs.api.handler.data.ISlot; import noppes.npcs.config.ConfigMain; import noppes.npcs.controllers.QuestController; @@ -31,24 +31,24 @@ import static noppes.npcs.CustomNpcsPermissions.*; public class ProfileController implements IProfileHandler { // Message constants - private static final String MSG_PLAYER_NOT_FOUND = "Player not found."; - private static final String MSG_PROFILE_LOCKED_CLONE = "Profile is locked; cannot clone slot."; - private static final String MSG_SOURCE_SLOT_NOT_EXIST = "Source slot does not exist."; - private static final String MSG_CANNOT_CLONE_CURRENT = "Cannot clone to the current active slot."; - private static final String MSG_INVALID_DEST_SLOT = "Invalid destination slot id."; - private static final String MSG_CLONE_SUCCESS = "Slot cloned successfully."; - private static final String MSG_PROFILE_LOCKED_REMOVE = "Profile is locked; cannot remove slot."; - private static final String MSG_CANNOT_REMOVE_ACTIVE = "Cannot remove the currently active slot."; - private static final String MSG_SLOT_NOT_EXIST = "Slot does not exist."; - private static final String MSG_REMOVE_SUCCESS = "Slot removed successfully."; - private static final String MSG_PROFILE_LOCKED_CREATE = "Profile is locked; cannot create slot."; - private static final String MSG_MAX_SLOTS_REACHED = "Maximum allowed slots reached."; - private static final String MSG_NEW_SLOT_CREATED = "New slot created successfully."; - private static final String MSG_PROFILE_LOCKED_CHANGE = "Profile is locked; cannot change slot."; - private static final String MSG_SLOT_ALREADY_ACTIVE = "Slot is already active."; - private static final String MSG_REGION_NOT_ALLOWED = "Profile switching not allowed from your current location."; - private static final String MSG_CHANGE_SUCCESS = "Slot changed successfully."; - private static final String MSG_CANCELLED = "Operation cancelled."; + private static final String MSG_PLAYER_NOT_FOUND = "Player not found."; + private static final String MSG_PROFILE_LOCKED_CLONE = "Profile is locked; cannot clone slot."; + private static final String MSG_SOURCE_SLOT_NOT_EXIST = "Source slot does not exist."; + private static final String MSG_CANNOT_CLONE_CURRENT = "Cannot clone to the current active slot."; + private static final String MSG_INVALID_DEST_SLOT = "Invalid destination slot id."; + private static final String MSG_CLONE_SUCCESS = "Slot cloned successfully."; + private static final String MSG_PROFILE_LOCKED_REMOVE = "Profile is locked; cannot remove slot."; + private static final String MSG_CANNOT_REMOVE_ACTIVE = "Cannot remove the currently active slot."; + private static final String MSG_SLOT_NOT_EXIST = "Slot does not exist."; + private static final String MSG_REMOVE_SUCCESS = "Slot removed successfully."; + private static final String MSG_PROFILE_LOCKED_CREATE = "Profile is locked; cannot create slot."; + private static final String MSG_MAX_SLOTS_REACHED = "Maximum allowed slots reached."; + private static final String MSG_NEW_SLOT_CREATED = "New slot created successfully."; + private static final String MSG_PROFILE_LOCKED_CHANGE = "Profile is locked; cannot change slot."; + private static final String MSG_SLOT_ALREADY_ACTIVE = "Slot is already active."; + private static final String MSG_REGION_NOT_ALLOWED = "Profile switching not allowed from your current location."; + private static final String MSG_CHANGE_SUCCESS = "Slot changed successfully."; + private static final String MSG_CANCELLED = "Operation cancelled."; public static Map profileTypes = new HashMap<>(); public static Map activeProfiles = new HashMap<>(); @@ -91,7 +91,7 @@ public class ProfileController implements IProfileHandler { } public synchronized void login(EntityPlayer player) { - if(!ConfigMain.ProfilesEnabled) + if (!ConfigMain.ProfilesEnabled) return; if (player == null) @@ -162,7 +162,7 @@ public class ProfileController implements IProfileHandler { backupProfile(uuid, compound); } catch (Exception e) { LogWriter.except(e); - } finally { + } finally { profile.setLocked(false); } }); @@ -365,17 +365,17 @@ public class ProfileController implements IProfileHandler { } PlayerDataScript handler = ScriptController.Instance.playerScripts; - if(profile.player != null){ + if (profile.player != null) { IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(profile.player); - if(EventHooks.onProfileRemove(handler, scriptPlayer, profile, slotId, false)) + if (EventHooks.onProfileRemove(handler, scriptPlayer, profile, slotId, false)) return ProfileOperation.error(MSG_CANCELLED); } profile.getSlots().remove(slotId); - if(profile.player != null){ + if (profile.player != null) { IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(profile.player); - EventHooks.onProfileRemove(handler, scriptPlayer, profile, slotId, true); + EventHooks.onProfileRemove(handler, scriptPlayer, profile, slotId, true); } return ProfileOperation.success(MSG_REMOVE_SUCCESS); @@ -403,21 +403,21 @@ public class ProfileController implements IProfileHandler { } PlayerDataScript handler = ScriptController.Instance.playerScripts; - if(profile.player != null){ + if (profile.player != null) { IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(profile.player); - if(EventHooks.onProfileCreate(handler, scriptPlayer, profile, newSlotId, false)) + if (EventHooks.onProfileCreate(handler, scriptPlayer, profile, newSlotId, false)) return ProfileOperation.error(MSG_CANCELLED); } Slot newSlot = new Slot(newSlotId, "Slot " + newSlotId); newSlot.setLastLoaded(System.currentTimeMillis()); profile.getSlots().put(newSlotId, newSlot); - if(profile.player != null){ + if (profile.player != null) { verifySlotQuests(profile.player); save(profile.player, profile); IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(profile.player); - EventHooks.onProfileCreate(handler, scriptPlayer, profile, newSlotId, true); + EventHooks.onProfileCreate(handler, scriptPlayer, profile, newSlotId, true); } return ProfileOperation.success(MSG_NEW_SLOT_CREATED); } @@ -476,7 +476,7 @@ public class ProfileController implements IProfileHandler { PlayerDataScript handler = ScriptController.Instance.playerScripts; IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(profile.player); - if(EventHooks.onProfileChange(handler, scriptPlayer, profile, newSlotId, prevSlot, false)) + if (EventHooks.onProfileChange(handler, scriptPlayer, profile, newSlotId, prevSlot, false)) return ProfileOperation.error(MSG_CANCELLED); @@ -484,7 +484,7 @@ public class ProfileController implements IProfileHandler { profile.currentSlotId = newSlotId; loadSlotData(profile.player); - EventHooks.onProfileChange(handler, scriptPlayer, profile, newSlotId, prevSlot, true); + EventHooks.onProfileChange(handler, scriptPlayer, profile, newSlotId, prevSlot, true); } else { return ProfileOperation.error(MSG_PLAYER_NOT_FOUND); } @@ -630,7 +630,7 @@ public class ProfileController implements IProfileHandler { pdata.profileSlot = profile.getCurrentSlotId(); pdata.save(); - if(ConfigMain.AttributesEnabled) + if (ConfigMain.AttributesEnabled) AttributeController.getTracker(player).recalcAttributes(player); } @@ -684,14 +684,14 @@ public class ProfileController implements IProfileHandler { @Override public IProfile getProfile(IPlayer player) { - if(player == null || player.getMCEntity() == null) + if (player == null || player.getMCEntity() == null) return null; return getProfile((EntityPlayer) player.getMCEntity()); } @Override public boolean changeSlot(IPlayer player, int slotID) { - if(player == null || player.getMCEntity() == null) + if (player == null || player.getMCEntity() == null) return false; EntityPlayer entityPlayer = (EntityPlayer) player.getMCEntity(); @@ -701,19 +701,19 @@ public class ProfileController implements IProfileHandler { @Override public boolean hasSlot(IPlayer player, int slotID) { - if(player == null || player.getMCEntity() == null) + if (player == null || player.getMCEntity() == null) return false; EntityPlayer entityPlayer = (EntityPlayer) player.getMCEntity(); Profile profile = getProfile(entityPlayer); - if(profile == null) + if (profile == null) return false; return profile.getSlots().containsKey(slotID); } @Override public boolean removeSlot(IPlayer player, int slotID) { - if(player == null || player.getMCEntity() == null) + if (player == null || player.getMCEntity() == null) return false; EntityPlayer entityPlayer = (EntityPlayer) player.getMCEntity(); @@ -724,19 +724,19 @@ public class ProfileController implements IProfileHandler { @Override public IPlayerData getSlotPlayerData(IPlayer player, int slotID) { PlayerData playerData; - if(player == null || player.getMCEntity() == null) + if (player == null || player.getMCEntity() == null) return null; EntityPlayer entityPlayer = (EntityPlayer) player.getMCEntity(); Profile profile = getProfile(entityPlayer); - if(profile == null) + if (profile == null) return null; return getSlotPlayerData(entityPlayer, slotID); } @Override public void saveSlotData(IPlayer player) { - if(player == null || player.getMCEntity() == null) + if (player == null || player.getMCEntity() == null) return; EntityPlayer entityPlayer = (EntityPlayer) player.getMCEntity(); @@ -746,10 +746,10 @@ public class ProfileController implements IProfileHandler { public IPlayerData getSlotPlayerData(EntityPlayer player, int slotID) { PlayerData playerData; Profile profile = getProfile(player); - if(profile == null) + if (profile == null) return null; - if(profile.currentSlotId == slotID){ + if (profile.currentSlotId == slotID) { playerData = PlayerData.get(player); } else { Slot slot = (Slot) profile.getSlots().get(slotID); @@ -759,14 +759,14 @@ public class ProfileController implements IProfileHandler { } public PlayerData getSlotPlayerData(EntityPlayer player, Slot slot) { - if(slot == null) + if (slot == null) return null; PlayerData playerData = new PlayerData(); playerData.player = player; NBTTagCompound compound = slot.getComponentData(new CNPCData().getTagName()); - if(compound == null) + if (compound == null) compound = new NBTTagCompound(); playerData.setNBT(compound); return playerData; diff --git a/src/main/java/kamkeel/npcs/controllers/SyncController.java b/src/main/java/kamkeel/npcs/controllers/SyncController.java index ee30eeb97..03a923485 100644 --- a/src/main/java/kamkeel/npcs/controllers/SyncController.java +++ b/src/main/java/kamkeel/npcs/controllers/SyncController.java @@ -22,7 +22,7 @@ import java.util.concurrent.ConcurrentHashMap; public class SyncController { - public static void syncPlayer(EntityPlayerMP player){ + public static void syncPlayer(EntityPlayerMP player) { // Login Packet PacketHandler.Instance.sendToPlayer(new LoginPacket(), player); @@ -99,43 +99,43 @@ public class SyncController { syncPlayerData(player, false); } - public static NBTTagCompound workbenchNBT(){ + public static NBTTagCompound workbenchNBT() { RecipeController controller = RecipeController.Instance; NBTTagList list = new NBTTagList(); NBTTagCompound compound = new NBTTagCompound(); - for(RecipeCarpentry recipe : controller.globalRecipes.values()){ + for (RecipeCarpentry recipe : controller.globalRecipes.values()) { list.appendTag(recipe.writeNBT()); } compound.setTag("recipes", list); return compound; } - public static NBTTagCompound carpentryNBT(){ + public static NBTTagCompound carpentryNBT() { RecipeController controller = RecipeController.Instance; NBTTagList list = new NBTTagList(); NBTTagCompound compound = new NBTTagCompound(); - for(RecipeCarpentry recipe : controller.carpentryRecipes.values()){ + for (RecipeCarpentry recipe : controller.carpentryRecipes.values()) { list.appendTag(recipe.writeNBT()); } compound.setTag("recipes", list); return compound; } - public static NBTTagCompound anvilNBT(){ + public static NBTTagCompound anvilNBT() { RecipeController controller = RecipeController.Instance; NBTTagList list = new NBTTagList(); NBTTagCompound compound = new NBTTagCompound(); - for(RecipeAnvil recipe : controller.anvilRecipes.values()){ + for (RecipeAnvil recipe : controller.anvilRecipes.values()) { list.appendTag(recipe.writeNBT()); } compound.setTag("recipes", list); return compound; } - public static NBTTagCompound factionsNBT(){ + public static NBTTagCompound factionsNBT() { NBTTagList list = new NBTTagList(); NBTTagCompound compound = new NBTTagCompound(); - for(Faction faction : FactionController.getInstance().factions.values()){ + for (Faction faction : FactionController.getInstance().factions.values()) { NBTTagCompound factioNBT = new NBTTagCompound(); faction.writeNBT(factioNBT); list.appendTag(factioNBT); @@ -144,13 +144,13 @@ public class SyncController { return compound; } - public static NBTTagCompound dialogCategoriesNBT(){ + public static NBTTagCompound dialogCategoriesNBT() { NBTTagCompound compound = new NBTTagCompound(); NBTTagList categoryList = new NBTTagList(); - for(DialogCategory category : DialogController.Instance.categories.values()){ + for (DialogCategory category : DialogController.Instance.categories.values()) { NBTTagCompound questCompound = new NBTTagCompound(); NBTTagList dialogList = new NBTTagList(); - for(int dialogID : category.dialogs.keySet()){ + for (int dialogID : category.dialogs.keySet()) { Dialog quest = category.dialogs.get(dialogID); dialogList.appendTag(quest.writeToNBT(new NBTTagCompound())); } @@ -162,13 +162,14 @@ public class SyncController { return compound; } - public static NBTTagCompound questCategoriesNBT(){ + public static NBTTagCompound questCategoriesNBT() { NBTTagCompound compound = new NBTTagCompound(); NBTTagList categoryList = new NBTTagList(); - for(QuestCategory category : QuestController.Instance.categories.values()){ - NBTTagCompound questCompound = new NBTTagCompound();; + for (QuestCategory category : QuestController.Instance.categories.values()) { + NBTTagCompound questCompound = new NBTTagCompound(); + ; NBTTagList questList = new NBTTagList(); - for(int questID : category.quests.keySet()){ + for (int questID : category.quests.keySet()) { Quest quest = category.quests.get(questID); questList.appendTag(quest.writeToNBT(new NBTTagCompound())); } @@ -180,7 +181,7 @@ public class SyncController { return compound; } - public static NBTTagCompound customEffectsNBT(){ + public static NBTTagCompound customEffectsNBT() { NBTTagList list = new NBTTagList(); NBTTagCompound compound = new NBTTagCompound(); for (CustomEffect effect : CustomEffectController.getInstance().getCustomEffects().values()) { @@ -190,7 +191,7 @@ public class SyncController { return compound; } - public static NBTTagCompound magicsNBT(){ + public static NBTTagCompound magicsNBT() { NBTTagList list = new NBTTagList(); NBTTagCompound compound = new NBTTagCompound(); for (Magic magic : MagicController.getInstance().magics.values()) { @@ -202,7 +203,7 @@ public class SyncController { return compound; } - public static NBTTagCompound magicCyclesNBT(){ + public static NBTTagCompound magicCyclesNBT() { NBTTagList list = new NBTTagList(); NBTTagCompound compound = new NBTTagCompound(); for (MagicCycle cycle : MagicController.getInstance().cycles.values()) { @@ -214,10 +215,10 @@ public class SyncController { return compound; } - public static void syncPlayerData(EntityPlayerMP player, boolean update){ + public static void syncPlayerData(EntityPlayerMP player, boolean update) { PlayerData data = PlayerData.get(player); - if(data != null){ - if(update){ + if (data != null) { + if (update) { PacketHandler.Instance.sendToPlayer(new SyncPacket( EnumSyncType.PLAYERDATA, EnumSyncAction.UPDATE, @@ -234,7 +235,7 @@ public class SyncController { } } - public static void syncRemove(EnumSyncType enumSyncType, int id){ + public static void syncRemove(EnumSyncType enumSyncType, int id) { PacketHandler.Instance.sendToAll(new SyncPacket( enumSyncType, EnumSyncAction.REMOVE, @@ -299,7 +300,7 @@ public class SyncController { @SideOnly(Side.CLIENT) public static void clientSync(EnumSyncType enumSyncType, NBTTagCompound fullCompound) { - switch (enumSyncType){ + switch (enumSyncType) { case FACTION: { NBTTagList list = fullCompound.getTagList("Factions", 10); for (int i = 0; i < list.tagCount(); i++) { @@ -312,22 +313,21 @@ public class SyncController { break; } case DIALOG_CATEGORY: { - if(!fullCompound.hasNoTags()){ + if (!fullCompound.hasNoTags()) { NBTTagList categories = fullCompound.getTagList("DialogCategories", 10); - for(int j = 0; j < fullCompound.getTagList("DialogCategories", 10).tagCount(); j++) { + for (int j = 0; j < fullCompound.getTagList("DialogCategories", 10).tagCount(); j++) { NBTTagCompound categoryCompound = categories.getCompoundTagAt(j); - if(categoryCompound.hasNoTags()) + if (categoryCompound.hasNoTags()) continue; DialogCategory category = new DialogCategory(); category.readSmallNBT(categoryCompound.getCompoundTag("CatNBT")); NBTTagList dialogList = categoryCompound.getTagList("Data", 10); - if(DialogController.Instance.categoriesSync.containsKey(category.id)){ + if (DialogController.Instance.categoriesSync.containsKey(category.id)) { category = DialogController.Instance.categoriesSync.get(category.id); category.readSmallNBT(categoryCompound.getCompoundTag("CatNBT")); } - for(int i = 0; i < dialogList.tagCount(); i++) - { + for (int i = 0; i < dialogList.tagCount(); i++) { Dialog dialog = new Dialog(); dialog.readNBT(dialogList.getCompoundTagAt(i)); dialog.category = category; @@ -338,8 +338,8 @@ public class SyncController { } HashMap dialogs = new HashMap(); - for(DialogCategory category : DialogController.Instance.categoriesSync.values()){ - for(Dialog dialog : category.dialogs.values()){ + for (DialogCategory category : DialogController.Instance.categoriesSync.values()) { + for (Dialog dialog : category.dialogs.values()) { dialogs.put(dialog.id, dialog); } } @@ -350,22 +350,21 @@ public class SyncController { break; } case QUEST_CATEGORY: { - if(!fullCompound.hasNoTags()){ + if (!fullCompound.hasNoTags()) { NBTTagList categories = fullCompound.getTagList("QuestCategories", 10); - for(int j = 0; j < fullCompound.getTagList("QuestCategories", 10).tagCount(); j++) { + for (int j = 0; j < fullCompound.getTagList("QuestCategories", 10).tagCount(); j++) { NBTTagCompound categoryCompound = categories.getCompoundTagAt(j); - if(categoryCompound.hasNoTags()) + if (categoryCompound.hasNoTags()) continue; QuestCategory category = new QuestCategory(); category.readSmallNBT(categoryCompound.getCompoundTag("CatNBT")); NBTTagList questList = categoryCompound.getTagList("Data", 10); - if(QuestController.Instance.categoriesSync.containsKey(category.id)){ + if (QuestController.Instance.categoriesSync.containsKey(category.id)) { category = QuestController.Instance.categoriesSync.get(category.id); category.readSmallNBT(categoryCompound.getCompoundTag("CatNBT")); } - for(int i = 0; i < questList.tagCount(); i++) - { + for (int i = 0; i < questList.tagCount(); i++) { Quest quest = new Quest(); quest.readNBT(questList.getCompoundTagAt(i)); quest.category = category; @@ -375,9 +374,9 @@ public class SyncController { } } - HashMap quests = new HashMap(); - for(QuestCategory category : QuestController.Instance.categoriesSync.values()){ - for(Quest quest : category.quests.values()){ + HashMap quests = new HashMap(); + for (QuestCategory category : QuestController.Instance.categoriesSync.values()) { + for (Quest quest : category.quests.values()) { quests.put(quest.id, quest); } } @@ -423,13 +422,12 @@ public class SyncController { } case WORKBENCH_RECIPES: { NBTTagList list = fullCompound.getTagList("recipes", 10); - if(list == null) + if (list == null) return; - for(int i = 0; i < list.tagCount(); i++) - { + for (int i = 0; i < list.tagCount(); i++) { RecipeCarpentry recipe = RecipeCarpentry.read(list.getCompoundTagAt(i)); - RecipeController.syncRecipes.put(recipe.id,recipe); + RecipeController.syncRecipes.put(recipe.id, recipe); } RecipeController.reloadGlobalRecipes(RecipeController.syncRecipes); @@ -438,13 +436,12 @@ public class SyncController { } case CARPENTRY_RECIPES: { NBTTagList list = fullCompound.getTagList("recipes", 10); - if(list == null) + if (list == null) return; - for(int i = 0; i < list.tagCount(); i++) - { + for (int i = 0; i < list.tagCount(); i++) { RecipeCarpentry recipe = RecipeCarpentry.read(list.getCompoundTagAt(i)); - RecipeController.syncRecipes.put(recipe.id,recipe); + RecipeController.syncRecipes.put(recipe.id, recipe); } RecipeController.Instance.carpentryRecipes = RecipeController.syncRecipes; @@ -453,11 +450,10 @@ public class SyncController { } case ANVIL_RECIPES: { NBTTagList list = fullCompound.getTagList("recipes", 10); - if(list == null) + if (list == null) return; - for(int i = 0; i < list.tagCount(); i++) - { + for (int i = 0; i < list.tagCount(); i++) { RecipeAnvil recipe = RecipeAnvil.read(list.getCompoundTagAt(i)); RecipeController.syncAnvilRecipes.put(recipe.id, recipe); } @@ -490,7 +486,7 @@ public class SyncController { */ @SideOnly(Side.CLIENT) public static void clientUpdate(EnumSyncType enumSyncType, int category_id, NBTTagCompound compound) { - switch (enumSyncType){ + switch (enumSyncType) { case FACTION: { Faction faction = new Faction(); faction.readNBT(compound); @@ -519,12 +515,11 @@ public class SyncController { QuestCategory category = new QuestCategory(); category.readSmallNBT(compound.getCompoundTag("CatNBT")); NBTTagList list = compound.getTagList("Data", 10); - if(QuestController.Instance.categoriesSync.containsKey(category.id)){ + if (QuestController.Instance.categoriesSync.containsKey(category.id)) { category = QuestController.Instance.categoriesSync.get(category.id); category.readSmallNBT(compound.getCompoundTag("CatNBT")); } - for(int i = 0; i < list.tagCount(); i++) - { + for (int i = 0; i < list.tagCount(); i++) { Quest quest = new Quest(); quest.readNBT(list.getCompoundTagAt(i)); quest.category = category; @@ -537,12 +532,11 @@ public class SyncController { DialogCategory category = new DialogCategory(); category.readSmallNBT(compound.getCompoundTag("CatNBT")); NBTTagList list = compound.getTagList("Data", 10); - if(DialogController.Instance.categoriesSync.containsKey(category.id)){ + if (DialogController.Instance.categoriesSync.containsKey(category.id)) { category = DialogController.Instance.categoriesSync.get(category.id); category.readSmallNBT(compound.getCompoundTag("CatNBT")); } - for(int i = 0; i < list.tagCount(); i++) - { + for (int i = 0; i < list.tagCount(); i++) { Dialog dialog = new Dialog(); dialog.readNBT(list.getCompoundTagAt(i)); dialog.category = category; @@ -591,7 +585,7 @@ public class SyncController { public static NBTTagCompound updateQuestCat(QuestCategory questCategory) { NBTTagCompound questCompound = new NBTTagCompound(); NBTTagList questList = new NBTTagList(); - for(int questID : questCategory.quests.keySet()){ + for (int questID : questCategory.quests.keySet()) { Quest quest = questCategory.quests.get(questID); questList.appendTag(quest.writeToNBT(new NBTTagCompound())); } @@ -603,7 +597,7 @@ public class SyncController { public static NBTTagCompound updateDialogCat(DialogCategory dialogCategory) { NBTTagCompound dialogCompound = new NBTTagCompound(); NBTTagList dialogList = new NBTTagList(); - for(int questID : dialogCategory.dialogs.keySet()){ + for (int questID : dialogCategory.dialogs.keySet()) { Dialog dialog = dialogCategory.dialogs.get(questID); dialogList.appendTag(dialog.writeToNBT(new NBTTagCompound())); } @@ -614,36 +608,36 @@ public class SyncController { @SideOnly(Side.CLIENT) public static void clientSyncRemove(EnumSyncType enumSyncType, int id) { - switch (enumSyncType){ + switch (enumSyncType) { case FACTION: FactionController.getInstance().factions.remove(id); break; case DIALOG: Dialog dialog = DialogController.Instance.dialogs.remove(id); - if(dialog != null) { + if (dialog != null) { dialog.category.dialogs.remove(id); } break; case DIALOG_CATEGORY: DialogCategory dialogCategory = DialogController.Instance.categories.remove(id); - if(dialogCategory != null) { + if (dialogCategory != null) { DialogController.Instance.dialogs.keySet().removeAll(dialogCategory.dialogs.keySet()); } break; case QUEST: Quest quest = QuestController.Instance.quests.remove(id); - if(quest != null) { + if (quest != null) { quest.category.quests.remove(id); } break; case QUEST_CATEGORY: QuestCategory questCategory = QuestController.Instance.categories.remove(id); - if(questCategory != null) { + if (questCategory != null) { QuestController.Instance.quests.keySet().removeAll(questCategory.quests.keySet()); } break; case MAGIC: - for(MagicCycle cycle : MagicController.getInstance().cycles.values()){ + for (MagicCycle cycle : MagicController.getInstance().cycles.values()) { cycle.associations.remove(id); } MagicController.getInstance().cycles.remove(id); @@ -657,7 +651,7 @@ public class SyncController { } } - public static void syncEffects(EntityPlayerMP playerMP){ + public static void syncEffects(EntityPlayerMP playerMP) { ConcurrentHashMap playerEffects = CustomEffectController.getInstance().getPlayerEffects(playerMP); PlayerData playerData = PlayerData.get(playerMP); playerData.effectData.setEffects(playerEffects); @@ -669,7 +663,7 @@ public class SyncController { @SideOnly(Side.CLIENT) public static void clientSyncEffects(NBTTagCompound compound) { PlayerData playerData = PlayerData.get(Minecraft.getMinecraft().thePlayer); - if(playerData != null){ + if (playerData != null) { playerData.setPlayerEffects(compound); } } diff --git a/src/main/java/kamkeel/npcs/controllers/data/attribute/ICustomAttribute.java b/src/main/java/kamkeel/npcs/controllers/data/attribute/ICustomAttribute.java index 98baab742..46b9ec2bc 100644 --- a/src/main/java/kamkeel/npcs/controllers/data/attribute/ICustomAttribute.java +++ b/src/main/java/kamkeel/npcs/controllers/data/attribute/ICustomAttribute.java @@ -5,6 +5,8 @@ package kamkeel.npcs.controllers.data.attribute; */ public interface ICustomAttribute { AttributeDefinition getAttribute(); + float getValue(); + void setValue(float value); } diff --git a/src/main/java/kamkeel/npcs/controllers/data/attribute/requirement/RequirementCheckerRegistry.java b/src/main/java/kamkeel/npcs/controllers/data/attribute/requirement/RequirementCheckerRegistry.java index 85a047f69..457f39547 100644 --- a/src/main/java/kamkeel/npcs/controllers/data/attribute/requirement/RequirementCheckerRegistry.java +++ b/src/main/java/kamkeel/npcs/controllers/data/attribute/requirement/RequirementCheckerRegistry.java @@ -2,6 +2,7 @@ package kamkeel.npcs.controllers.data.attribute.requirement; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.nbt.NBTTagCompound; + import java.util.HashMap; import java.util.Map; import java.util.Set; diff --git a/src/main/java/kamkeel/npcs/controllers/data/attribute/requirement/types/QuestActiveRequirement.java b/src/main/java/kamkeel/npcs/controllers/data/attribute/requirement/types/QuestActiveRequirement.java index 3edf40c94..af286a56a 100644 --- a/src/main/java/kamkeel/npcs/controllers/data/attribute/requirement/types/QuestActiveRequirement.java +++ b/src/main/java/kamkeel/npcs/controllers/data/attribute/requirement/types/QuestActiveRequirement.java @@ -20,9 +20,9 @@ public class QuestActiveRequirement implements IRequirementChecker { @Override public String getTooltipValue(NBTTagCompound nbt) { - if(nbt.hasKey(getKey())) { + if (nbt.hasKey(getKey())) { int questID = nbt.getInteger(getKey()); - if(QuestController.Instance.get(questID) != null) { + if (QuestController.Instance.get(questID) != null) { return QuestController.Instance.get(questID).getName(); } } @@ -31,14 +31,14 @@ public class QuestActiveRequirement implements IRequirementChecker { @Override public void apply(NBTTagCompound nbt, Object value) { - if(value instanceof Integer) { + if (value instanceof Integer) { nbt.setInteger(getKey(), (Integer) value); } } @Override public boolean check(EntityPlayer player, NBTTagCompound nbt) { - if(nbt.hasKey(getKey())) { + if (nbt.hasKey(getKey())) { int questID = nbt.getInteger(getKey()); return PlayerData.get(player).questData.hasActiveQuest(questID); } diff --git a/src/main/java/kamkeel/npcs/controllers/data/attribute/requirement/types/QuestCompletedRequirement.java b/src/main/java/kamkeel/npcs/controllers/data/attribute/requirement/types/QuestCompletedRequirement.java index 2c0f5fb1e..e2c887659 100644 --- a/src/main/java/kamkeel/npcs/controllers/data/attribute/requirement/types/QuestCompletedRequirement.java +++ b/src/main/java/kamkeel/npcs/controllers/data/attribute/requirement/types/QuestCompletedRequirement.java @@ -20,9 +20,9 @@ public class QuestCompletedRequirement implements IRequirementChecker { @Override public String getTooltipValue(NBTTagCompound nbt) { - if(nbt.hasKey(getKey())) { + if (nbt.hasKey(getKey())) { int questID = nbt.getInteger(getKey()); - if(QuestController.Instance.get(questID) != null) { + if (QuestController.Instance.get(questID) != null) { return QuestController.Instance.get(questID).getName(); } } @@ -31,14 +31,14 @@ public class QuestCompletedRequirement implements IRequirementChecker { @Override public void apply(NBTTagCompound nbt, Object value) { - if(value instanceof Integer) { + if (value instanceof Integer) { nbt.setInteger(getKey(), (Integer) value); } } @Override public boolean check(EntityPlayer player, NBTTagCompound nbt) { - if(nbt.hasKey(getKey())) { + if (nbt.hasKey(getKey())) { int questID = nbt.getInteger(getKey()); return PlayerData.get(player).questData.hasFinishedQuest(questID); } diff --git a/src/main/java/kamkeel/npcs/controllers/data/attribute/tracker/AttributeRecalcEvent.java b/src/main/java/kamkeel/npcs/controllers/data/attribute/tracker/AttributeRecalcEvent.java index f8f8fa473..d82b266a2 100644 --- a/src/main/java/kamkeel/npcs/controllers/data/attribute/tracker/AttributeRecalcEvent.java +++ b/src/main/java/kamkeel/npcs/controllers/data/attribute/tracker/AttributeRecalcEvent.java @@ -1,8 +1,9 @@ package kamkeel.npcs.controllers.data.attribute.tracker; +import net.minecraft.entity.player.EntityPlayer; + import java.util.ArrayList; import java.util.List; -import net.minecraft.entity.player.EntityPlayer; public class AttributeRecalcEvent { private static final List listeners = new ArrayList<>(); diff --git a/src/main/java/kamkeel/npcs/controllers/data/attribute/tracker/PlayerAttributeTracker.java b/src/main/java/kamkeel/npcs/controllers/data/attribute/tracker/PlayerAttributeTracker.java index 218c4ad1c..91244fb7f 100644 --- a/src/main/java/kamkeel/npcs/controllers/data/attribute/tracker/PlayerAttributeTracker.java +++ b/src/main/java/kamkeel/npcs/controllers/data/attribute/tracker/PlayerAttributeTracker.java @@ -1,10 +1,5 @@ package kamkeel.npcs.controllers.data.attribute.tracker; -import java.util.HashMap; -import java.util.Map; -import java.util.UUID; -import java.util.Map.Entry; - import kamkeel.npcs.CustomAttributes; import kamkeel.npcs.controllers.AttributeController; import kamkeel.npcs.controllers.data.attribute.AttributeDefinition; @@ -20,9 +15,14 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; +import java.util.HashMap; +import java.util.Map; +import java.util.Map.Entry; +import java.util.UUID; + public class PlayerAttributeTracker { - public static UUID healthUUID = UUID.fromString("48a0ad75-2cf8-4838-ad2f-9a0aadc57dfe"); + public static UUID healthUUID = UUID.fromString("48a0ad75-2cf8-4838-ad2f-9a0aadc57dfe"); private final UUID playerId; @@ -59,7 +59,7 @@ public class PlayerAttributeTracker { // Update equipment tracker. PlayerEquipmentTracker currentEquip = new PlayerEquipmentTracker(); currentEquip.updateFrom(player); - ItemStack[] equipment = new ItemStack[] { currentEquip.heldItem, currentEquip.boots, currentEquip.leggings, currentEquip.chestplate, currentEquip.helmet }; + ItemStack[] equipment = new ItemStack[]{currentEquip.heldItem, currentEquip.boots, currentEquip.leggings, currentEquip.chestplate, currentEquip.helmet}; for (ItemStack piece : equipment) { if (piece != null) { if (piece.stackTagCompound != null && piece.stackTagCompound.hasKey(AttributeItemUtil.TAG_RPGCORE)) { @@ -140,7 +140,8 @@ public class PlayerAttributeTracker { if (old != null) { maxHealthAttr.removeModifier(old); } - } catch (Exception ignored) {} + } catch (Exception ignored) { + } if (bonusHealth != 0) { maxHealthAttr.applyModifier(new AttributeModifier(healthUUID, "RPGCoreHealthBonus", bonusHealth, 0)); } diff --git a/src/main/java/kamkeel/npcs/controllers/data/attribute/tracker/PlayerEquipmentTracker.java b/src/main/java/kamkeel/npcs/controllers/data/attribute/tracker/PlayerEquipmentTracker.java index 3f4ff5317..e21e70d47 100644 --- a/src/main/java/kamkeel/npcs/controllers/data/attribute/tracker/PlayerEquipmentTracker.java +++ b/src/main/java/kamkeel/npcs/controllers/data/attribute/tracker/PlayerEquipmentTracker.java @@ -1,9 +1,9 @@ package kamkeel.npcs.controllers.data.attribute.tracker; +import kamkeel.npcs.util.AttributeItemUtil; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; -import kamkeel.npcs.util.AttributeItemUtil; public class PlayerEquipmentTracker { public ItemStack heldItem; diff --git a/src/main/java/kamkeel/npcs/controllers/data/profile/CNPCData.java b/src/main/java/kamkeel/npcs/controllers/data/profile/CNPCData.java index 3b923b792..ccbae74ef 100644 --- a/src/main/java/kamkeel/npcs/controllers/data/profile/CNPCData.java +++ b/src/main/java/kamkeel/npcs/controllers/data/profile/CNPCData.java @@ -32,12 +32,11 @@ public class CNPCData implements IProfileData { @Override public void setNBT(EntityPlayer player, NBTTagCompound replace) { PlayerData customNPCData = PlayerData.get(player); - if(replace.hasNoTags()){ + if (replace.hasNoTags()) { PlayerData newData = new PlayerData(); newData.player = player; customNPCData.setNBT((NBTTagCompound) newData.getNBT().copy()); - } - else { + } else { customNPCData.setNBT(replace); } customNPCData.updateClient = true; @@ -51,7 +50,7 @@ public class CNPCData implements IProfileData { @Override public ProfileOperation verifySwitch(EntityPlayer player) { PlayerData playerData = PlayerData.get(player); - if(playerData.partyUUID != null) + if (playerData.partyUUID != null) return ProfileOperation.error("Cannot switch while in Party"); return ProfileOperation.success(""); diff --git a/src/main/java/kamkeel/npcs/controllers/data/profile/IProfileData.java b/src/main/java/kamkeel/npcs/controllers/data/profile/IProfileData.java index 1fc00168e..2d2260462 100644 --- a/src/main/java/kamkeel/npcs/controllers/data/profile/IProfileData.java +++ b/src/main/java/kamkeel/npcs/controllers/data/profile/IProfileData.java @@ -9,6 +9,7 @@ public interface IProfileData { /** * Do not use the tags: Name, lastLoaded, ID. + * * @return The save tag utilized in the Profile. */ public String getTagName(); @@ -36,6 +37,7 @@ public interface IProfileData { /** * Called before a profile switch occurs. + * * @param player The player switching profiles. * @return true if allowed, false if not. */ @@ -44,7 +46,8 @@ public interface IProfileData { /** * NEW: Builds and returns a list of informational strings about this profile data, * based on the provided NBTTagCompound from the slot. - * @param player The player in question. + * + * @param player The player in question. * @param compound The NBT data from the slot under this profile data's tag. * @return A list of InfoEntry with information */ diff --git a/src/main/java/kamkeel/npcs/controllers/data/profile/Profile.java b/src/main/java/kamkeel/npcs/controllers/data/profile/Profile.java index d09bf4369..b7b2a8b3d 100644 --- a/src/main/java/kamkeel/npcs/controllers/data/profile/Profile.java +++ b/src/main/java/kamkeel/npcs/controllers/data/profile/Profile.java @@ -19,16 +19,16 @@ public class Profile implements IProfile { public Profile(EntityPlayer player, NBTTagCompound compound) { this.player = player; - if(compound.hasKey("CurrentSlotId")){ + if (compound.hasKey("CurrentSlotId")) { this.currentSlotId = compound.getInteger("CurrentSlotId"); } else { this.currentSlotId = 0; } - if(compound.hasKey("Slots")){ + if (compound.hasKey("Slots")) { NBTTagCompound slotsCompound = compound.getCompoundTag("Slots"); Set keys = slotsCompound.func_150296_c(); - for(String key : keys) { + for (String key : keys) { try { int slotId = Integer.parseInt(key); NBTTagCompound slotNBT = slotsCompound.getCompoundTag(key); @@ -76,13 +76,13 @@ public class Profile implements IProfile { @Override public NBTTagCompound writeToNBT() { NBTTagCompound compound = new NBTTagCompound(); - if(player != null) + if (player != null) compound.setString("Name", player.getCommandSenderName()); compound.setInteger("CurrentSlotId", currentSlotId); NBTTagCompound slotsCompound = new NBTTagCompound(); - for(Map.Entry entry : slots.entrySet()) { + for (Map.Entry entry : slots.entrySet()) { // Save only non-temporary slots. - if(entry.getValue().isTemporary()) + if (entry.getValue().isTemporary()) continue; slotsCompound.setTag(String.valueOf(entry.getKey()), entry.getValue().toNBT()); } diff --git a/src/main/java/kamkeel/npcs/controllers/data/profile/ProfileInfoEntry.java b/src/main/java/kamkeel/npcs/controllers/data/profile/ProfileInfoEntry.java index 6adef4e67..b5d7a896a 100644 --- a/src/main/java/kamkeel/npcs/controllers/data/profile/ProfileInfoEntry.java +++ b/src/main/java/kamkeel/npcs/controllers/data/profile/ProfileInfoEntry.java @@ -8,7 +8,8 @@ public class ProfileInfoEntry { private int labelColor; private int resultColor; - public ProfileInfoEntry() {} + public ProfileInfoEntry() { + } public ProfileInfoEntry(String label, int labelColor, String result, int resultColor) { this.label = label; @@ -43,8 +44,19 @@ public class ProfileInfoEntry { ); } - public String getLabel() { return label; } - public String getResult() { return result; } - public int getLabelColor() { return labelColor; } - public int getResultColor() { return resultColor; } + public String getLabel() { + return label; + } + + public String getResult() { + return result; + } + + public int getLabelColor() { + return labelColor; + } + + public int getResultColor() { + return resultColor; + } } diff --git a/src/main/java/kamkeel/npcs/developer/Developer.java b/src/main/java/kamkeel/npcs/developer/Developer.java index 2c89cfc50..1e26473ce 100644 --- a/src/main/java/kamkeel/npcs/developer/Developer.java +++ b/src/main/java/kamkeel/npcs/developer/Developer.java @@ -11,31 +11,31 @@ public class Developer { public static HashSet QuestMaker = new HashSet<>(); public static Developer Instance; - public Developer(){ + public Developer() { Instance = this; // Temp for testing Universal.add(UUID.fromString("29cc52dd-2c50-4e8f-a388-be6c497cf0b4")); } - public boolean hasUniversal(UUID uuid){ - if(Universal == null){ + public boolean hasUniversal(UUID uuid) { + if (Universal == null) { Universal = new HashSet<>(); } return Universal.contains(uuid); } - public boolean hasScriptUser(UUID uuid){ - if(ScriptUser == null){ + public boolean hasScriptUser(UUID uuid) { + if (ScriptUser == null) { ScriptUser = new HashSet<>(); } return ScriptUser.contains(uuid); } - public boolean hasWandUser(UUID uuid){ + public boolean hasWandUser(UUID uuid) { return WandUser.contains(uuid); } - public boolean hasQuestMaker(UUID uuid){ + public boolean hasQuestMaker(UUID uuid) { return QuestMaker.contains(uuid); } diff --git a/src/main/java/kamkeel/npcs/network/AbstractPacket.java b/src/main/java/kamkeel/npcs/network/AbstractPacket.java index 9965ddd4b..aa771661e 100644 --- a/src/main/java/kamkeel/npcs/network/AbstractPacket.java +++ b/src/main/java/kamkeel/npcs/network/AbstractPacket.java @@ -39,17 +39,18 @@ public abstract class AbstractPacket { } public abstract Enum getType(); + public abstract PacketChannel getChannel(); - public CustomNpcsPermissions.Permission getPermission(){ + public CustomNpcsPermissions.Permission getPermission() { return null; } - public boolean needsNPC(){ + public boolean needsNPC() { return false; } - public void setNPC(EntityNPCInterface npc){ + public void setNPC(EntityNPCInterface npc) { this.npc = npc; } diff --git a/src/main/java/kamkeel/npcs/network/LargeAbstractPacket.java b/src/main/java/kamkeel/npcs/network/LargeAbstractPacket.java index c55e391f1..5c1e9dcc4 100644 --- a/src/main/java/kamkeel/npcs/network/LargeAbstractPacket.java +++ b/src/main/java/kamkeel/npcs/network/LargeAbstractPacket.java @@ -139,10 +139,13 @@ public abstract class LargeAbstractPacket extends AbstractPacket { protected abstract void handleCompleteData(ByteBuf data, EntityPlayer player) throws IOException; @Override - public final FMLProxyPacket generatePacket() {return null;} + public final FMLProxyPacket generatePacket() { + return null; + } @Override - public void sendData(ByteBuf out) throws IOException {} + public void sendData(ByteBuf out) throws IOException { + } /** * Simple storage class to keep track of partial data and how many bytes we've received so far. diff --git a/src/main/java/kamkeel/npcs/network/PacketChannel.java b/src/main/java/kamkeel/npcs/network/PacketChannel.java index d080f1239..8897c0369 100644 --- a/src/main/java/kamkeel/npcs/network/PacketChannel.java +++ b/src/main/java/kamkeel/npcs/network/PacketChannel.java @@ -34,7 +34,7 @@ public class PacketChannel { } public void registerPacket(AbstractPacket packet) { - if(packets.containsKey(packet.getType().ordinal())){ + if (packets.containsKey(packet.getType().ordinal())) { System.out.println("Packet ID: " + packet.getType().ordinal() + " is already registered in " + this.channelName); return; } diff --git a/src/main/java/kamkeel/npcs/network/PacketClient.java b/src/main/java/kamkeel/npcs/network/PacketClient.java index 45aa91e2b..e8f2eca5e 100644 --- a/src/main/java/kamkeel/npcs/network/PacketClient.java +++ b/src/main/java/kamkeel/npcs/network/PacketClient.java @@ -2,7 +2,7 @@ package kamkeel.npcs.network; public class PacketClient extends PacketHandler { - public static void sendClient(AbstractPacket packet){ + public static void sendClient(AbstractPacket packet) { PacketHandler.Instance.sendToServer(packet); } } diff --git a/src/main/java/kamkeel/npcs/network/PacketHandler.java b/src/main/java/kamkeel/npcs/network/PacketHandler.java index cae754dd2..c0b9a9564 100644 --- a/src/main/java/kamkeel/npcs/network/PacketHandler.java +++ b/src/main/java/kamkeel/npcs/network/PacketHandler.java @@ -16,6 +16,10 @@ import kamkeel.npcs.network.packets.data.script.ScriptOverlayClosePacket; import kamkeel.npcs.network.packets.data.script.ScriptOverlayDataPacket; import kamkeel.npcs.network.packets.data.script.ScriptedParticlePacket; import kamkeel.npcs.network.packets.player.*; +import kamkeel.npcs.network.packets.player.customgui.CustomGuiButtonPacket; +import kamkeel.npcs.network.packets.player.customgui.CustomGuiClosePacket; +import kamkeel.npcs.network.packets.player.customgui.CustomGuiUnfocusedPacket; +import kamkeel.npcs.network.packets.player.customgui.CustomScrollClickPacket; import kamkeel.npcs.network.packets.player.profile.*; import kamkeel.npcs.network.packets.request.*; import kamkeel.npcs.network.packets.request.animation.AnimationGetPacket; @@ -27,10 +31,6 @@ import kamkeel.npcs.network.packets.request.bank.BankRemovePacket; import kamkeel.npcs.network.packets.request.bank.BankSavePacket; import kamkeel.npcs.network.packets.request.bank.BanksGetPacket; import kamkeel.npcs.network.packets.request.clone.*; -import kamkeel.npcs.network.packets.player.customgui.CustomGuiButtonPacket; -import kamkeel.npcs.network.packets.player.customgui.CustomGuiClosePacket; -import kamkeel.npcs.network.packets.player.customgui.CustomGuiUnfocusedPacket; -import kamkeel.npcs.network.packets.player.customgui.CustomScrollClickPacket; import kamkeel.npcs.network.packets.request.dialog.*; import kamkeel.npcs.network.packets.request.effects.EffectGetPacket; import kamkeel.npcs.network.packets.request.effects.EffectRemovePacket; @@ -97,10 +97,10 @@ public class PacketHandler { public Map channels = new Hashtable<>(); // Client to Server - public static final PacketChannel REQUEST_PACKET = new PacketChannel("CNPC+|Req", EnumChannelType.REQUEST); + public static final PacketChannel REQUEST_PACKET = new PacketChannel("CNPC+|Req", EnumChannelType.REQUEST); // Client to Server - Typically information - public static final PacketChannel PLAYER_PACKET = new PacketChannel("CNPC+|Player", EnumChannelType.PLAYER); + public static final PacketChannel PLAYER_PACKET = new PacketChannel("CNPC+|Player", EnumChannelType.PLAYER); // Server to Client public static final PacketChannel DATA_PACKET = new PacketChannel("CNPC+|Data", EnumChannelType.DATA); @@ -118,7 +118,7 @@ public class PacketHandler { this.registerPlayerPackets(); } - public void registerRequestPackets(){ + public void registerRequestPackets() { // NPC Packets REQUEST_PACKET.registerPacket(new NpcClosePacket()); REQUEST_PACKET.registerPacket(new NpcDeletePacket()); @@ -345,7 +345,7 @@ public class PacketHandler { REQUEST_PACKET.registerPacket(new DimensionTeleportPacket()); } - public void registerDataPackets(){ + public void registerDataPackets() { // Data Packets DATA_PACKET.registerPacket(new LoginPacket()); DATA_PACKET.registerPacket(new AchievementPacket()); @@ -454,7 +454,7 @@ public class PacketHandler { .orElse(null); } - public FMLEventChannel getEventChannel(AbstractPacket abstractPacket){ + public FMLEventChannel getEventChannel(AbstractPacket abstractPacket) { PacketChannel packetChannel = getPacketChannel(abstractPacket.getChannel().getChannelType()); if (packetChannel == null) { return null; @@ -491,20 +491,20 @@ public class PacketHandler { return; } - if(side == Side.SERVER){ - if(abstractPacket.getChannel() == REQUEST_PACKET && ConfigMain.OpsOnly && !NoppesUtilServer.isOp(player)){ + if (side == Side.SERVER) { + if (abstractPacket.getChannel() == REQUEST_PACKET && ConfigMain.OpsOnly && !NoppesUtilServer.isOp(player)) { LogWriter.error(String.format("%s tried to use CNPC+ without being an op", player.getCommandSenderName())); return; } // Check if permission is allowed - if(abstractPacket.getPermission() != null && !CustomNpcsPermissions.hasPermission(player, abstractPacket.getPermission())){ + if (abstractPacket.getPermission() != null && !CustomNpcsPermissions.hasPermission(player, abstractPacket.getPermission())) { return; } // Check for required NPC EntityNPCInterface npc = NoppesUtilServer.getEditingNpc(player); - if(abstractPacket.needsNPC() && npc == null){ + if (abstractPacket.needsNPC() && npc == null) { return; } diff --git a/src/main/java/kamkeel/npcs/network/PacketUtil.java b/src/main/java/kamkeel/npcs/network/PacketUtil.java index f6bc22e8b..c9a40a434 100644 --- a/src/main/java/kamkeel/npcs/network/PacketUtil.java +++ b/src/main/java/kamkeel/npcs/network/PacketUtil.java @@ -133,7 +133,7 @@ public class PacketUtil { } private static boolean isValidItemForType(ItemStack item, EnumItemPacketType type) { - if(item == null || item.getItem() == null) + if (item == null || item.getItem() == null) return false; switch (type) { @@ -213,9 +213,9 @@ public class PacketUtil { for (int i = 0; i < containers.size(); i++) { ScriptContainer container = containers.get(i); NBTTagCompound tabCompound = new NBTTagCompound(); - tabCompound.setInteger("Tab",i); - tabCompound.setTag("Script",container.writeToNBT(new NBTTagCompound())); - tabCompound.setInteger("TotalScripts",containers.size()); + tabCompound.setInteger("Tab", i); + tabCompound.setTag("Script", container.writeToNBT(new NBTTagCompound())); + tabCompound.setInteger("TotalScripts", containers.size()); GuiDataPacket.sendGuiData(player, tabCompound); } } @@ -229,14 +229,14 @@ public class PacketUtil { if (tab >= 0) { if (data.getScripts().size() > totalScripts) { - data.setScripts(data.getScripts().subList(0,totalScripts)); + data.setScripts(data.getScripts().subList(0, totalScripts)); } else while (data.getScripts().size() < totalScripts) { data.getScripts().add(new ScriptContainer(data)); } NBTTagCompound tabCompound = ByteBufUtils.readNBT(buffer); ScriptContainer script = new ScriptContainer(data); script.readFromNBT(tabCompound); - data.getScripts().set(tab,script); + data.getScripts().set(tab, script); } else { NBTTagCompound compound = ByteBufUtils.readNBT(buffer); data.setLanguage(compound.getString("ScriptLanguage")); diff --git a/src/main/java/kamkeel/npcs/network/packets/data/ConfigCommandPacket.java b/src/main/java/kamkeel/npcs/network/packets/data/ConfigCommandPacket.java index 6c8222b46..70701b057 100644 --- a/src/main/java/kamkeel/npcs/network/packets/data/ConfigCommandPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/data/ConfigCommandPacket.java @@ -53,7 +53,7 @@ public final class ConfigCommandPacket extends AbstractPacket { EnumConfigOperation configType = EnumConfigOperation.values()[in.readInt()]; if (configType == EnumConfigOperation.FONT) { // Font Configuration String font = ByteBufUtils.readString(in); - if(font == null) + if (font == null) return; int size = in.readInt(); diff --git a/src/main/java/kamkeel/npcs/network/packets/data/LoginPacket.java b/src/main/java/kamkeel/npcs/network/packets/data/LoginPacket.java index 022f4bc5e..a30d4266c 100644 --- a/src/main/java/kamkeel/npcs/network/packets/data/LoginPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/data/LoginPacket.java @@ -15,7 +15,9 @@ import java.io.IOException; public final class LoginPacket extends AbstractPacket { public static final String packetName = "CNPC+|Login"; - public LoginPacket() {} + + public LoginPacket() { + } @Override public Enum getType() { diff --git a/src/main/java/kamkeel/npcs/network/packets/data/OverlayQuestTrackingPacket.java b/src/main/java/kamkeel/npcs/network/packets/data/OverlayQuestTrackingPacket.java index f64756ba1..bf299a2ce 100644 --- a/src/main/java/kamkeel/npcs/network/packets/data/OverlayQuestTrackingPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/data/OverlayQuestTrackingPacket.java @@ -8,10 +8,8 @@ import kamkeel.npcs.network.PacketChannel; import kamkeel.npcs.network.PacketHandler; import kamkeel.npcs.network.enums.EnumDataPacket; import kamkeel.npcs.util.ByteBufUtils; -import net.minecraft.client.Minecraft; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.nbt.NBTTagCompound; -import noppes.npcs.client.ClientCacheHandler; import noppes.npcs.client.gui.hud.ClientHudManager; import noppes.npcs.client.gui.hud.EnumHudComponent; import noppes.npcs.client.gui.hud.HudComponent; @@ -52,7 +50,7 @@ public final class OverlayQuestTrackingPacket extends AbstractPacket { try { NBTTagCompound nbt = ByteBufUtils.readNBT(in); component.loadData(nbt); - if(nbt.hasNoTags()) + if (nbt.hasNoTags()) component.hasData = false; } catch (IOException e) { component.hasData = false; diff --git a/src/main/java/kamkeel/npcs/network/packets/data/ParticlePacket.java b/src/main/java/kamkeel/npcs/network/packets/data/ParticlePacket.java index 93fb772ea..afbc95e7a 100644 --- a/src/main/java/kamkeel/npcs/network/packets/data/ParticlePacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/data/ParticlePacket.java @@ -80,7 +80,7 @@ public final class ParticlePacket extends AbstractPacket { float yOffset = buffer.readFloat(); String particle = ByteBufUtils.readString(buffer); - if(particle != null){ + if (particle != null) { World worldObj = Minecraft.getMinecraft().theWorld; Random rand = worldObj.rand; diff --git a/src/main/java/kamkeel/npcs/network/packets/data/PlayerDataInfoPacket.java b/src/main/java/kamkeel/npcs/network/packets/data/PlayerDataInfoPacket.java index db0b44c2a..8a89f8086 100644 --- a/src/main/java/kamkeel/npcs/network/packets/data/PlayerDataInfoPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/data/PlayerDataInfoPacket.java @@ -10,7 +10,6 @@ import kamkeel.npcs.util.ByteBufUtils; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.nbt.NBTTagCompound; import noppes.npcs.client.NoppesUtil; -import noppes.npcs.controllers.data.Magic; import noppes.npcs.controllers.data.MagicData; import java.io.IOException; @@ -35,7 +34,8 @@ public final class PlayerDataInfoPacket extends LargeAbstractPacket { private MagicData playerMagicData; - public PlayerDataInfoPacket() {} + public PlayerDataInfoPacket() { + } public PlayerDataInfoPacket(String playerName, Map questCategories, Map questActive, Map questFinished, diff --git a/src/main/java/kamkeel/npcs/network/packets/data/gui/GuiOpenBookPacket.java b/src/main/java/kamkeel/npcs/network/packets/data/gui/GuiOpenBookPacket.java index c6e54678d..2cd3cf308 100644 --- a/src/main/java/kamkeel/npcs/network/packets/data/gui/GuiOpenBookPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/data/gui/GuiOpenBookPacket.java @@ -61,7 +61,7 @@ public final class GuiOpenBookPacket extends AbstractPacket { int z = in.readInt(); NBTTagCompound nbt = ByteBufUtils.readNBT(in); ItemStack book = ItemStack.loadItemStackFromNBT(nbt); - if(book != null) + if (book != null) NoppesUtil.openGUI(player, new GuiBook(player, book, x, y, z)); } } diff --git a/src/main/java/kamkeel/npcs/network/packets/data/large/ScrollListPacket.java b/src/main/java/kamkeel/npcs/network/packets/data/large/ScrollListPacket.java index 558b96292..5904b21d1 100644 --- a/src/main/java/kamkeel/npcs/network/packets/data/large/ScrollListPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/data/large/ScrollListPacket.java @@ -24,7 +24,7 @@ public final class ScrollListPacket extends LargeAbstractPacket { public ScrollListPacket() { } - public ScrollListPacket(List data, EnumScrollData enumScrollData) { + public ScrollListPacket(List data, EnumScrollData enumScrollData) { this.data = data; this.enumScrollData = enumScrollData; } diff --git a/src/main/java/kamkeel/npcs/network/packets/data/large/SyncEffectPacket.java b/src/main/java/kamkeel/npcs/network/packets/data/large/SyncEffectPacket.java index 2282be91b..66d7a5756 100644 --- a/src/main/java/kamkeel/npcs/network/packets/data/large/SyncEffectPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/data/large/SyncEffectPacket.java @@ -21,7 +21,8 @@ public final class SyncEffectPacket extends LargeAbstractPacket { private NBTTagCompound syncData; - public SyncEffectPacket() {} + public SyncEffectPacket() { + } public SyncEffectPacket(NBTTagCompound syncData) { this.syncData = syncData; @@ -54,8 +55,7 @@ public final class SyncEffectPacket extends LargeAbstractPacket { try { NBTTagCompound tag = ByteBufUtils.readBigNBT(data); SyncController.clientSyncEffects(tag); - } - catch (RuntimeException e){ + } catch (RuntimeException e) { LogWriter.error(String.format("Attempted to Sync Effects but it was too big")); } } diff --git a/src/main/java/kamkeel/npcs/network/packets/data/large/SyncPacket.java b/src/main/java/kamkeel/npcs/network/packets/data/large/SyncPacket.java index db7722ecb..2b4ca27b9 100644 --- a/src/main/java/kamkeel/npcs/network/packets/data/large/SyncPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/data/large/SyncPacket.java @@ -86,8 +86,7 @@ public final class SyncPacket extends LargeAbstractPacket { NBTTagCompound tag = ByteBufUtils.readBigNBT(data); // Now do your client-side logic (similar to your old clientSync() or clientSyncUpdate() approach) handleSyncPacketClient(type, action, categoryID, tag); - } - catch (RuntimeException e){ + } catch (RuntimeException e) { LogWriter.error(String.format("Attempted to Sync %s but it was too big", type.toString())); } } diff --git a/src/main/java/kamkeel/npcs/network/packets/player/BankActionPacket.java b/src/main/java/kamkeel/npcs/network/packets/player/BankActionPacket.java index 589d48796..087b82f76 100644 --- a/src/main/java/kamkeel/npcs/network/packets/player/BankActionPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/player/BankActionPacket.java @@ -42,9 +42,11 @@ public class BankActionPacket extends AbstractPacket { public static void Open(int bankID, int slotID) { PacketClient.sendClient(new BankActionPacket(Action.OpenSlot, bankID, slotID)); } + public static void Upgrade() { PacketClient.sendClient(new BankActionPacket(Action.Upgrade, -1, -1)); } + public static void Unlock() { PacketClient.sendClient(new BankActionPacket(Action.Unlock, -1, -1)); } @@ -79,7 +81,7 @@ public class BankActionPacket extends AbstractPacket { EntityPlayerMP playerMP = (EntityPlayerMP) player; - if(npc.advanced.role != EnumRoleType.Bank) + if (npc.advanced.role != EnumRoleType.Bank) return; switch (requestedAction) { @@ -92,7 +94,7 @@ public class BankActionPacket extends AbstractPacket { case OpenSlot: int bankID = in.readInt(); int slotID = in.readInt(); - BankData data = PlayerDataController.Instance.getBankData(playerMP,bankID).getBankOrDefault(bankID); + BankData data = PlayerDataController.Instance.getBankData(playerMP, bankID).getBankOrDefault(bankID); data.openBankGui(playerMP, npc, bankID, slotID); break; } diff --git a/src/main/java/kamkeel/npcs/network/packets/player/CheckPlayerValue.java b/src/main/java/kamkeel/npcs/network/packets/player/CheckPlayerValue.java index 9c3eb4c62..8e5eff27d 100644 --- a/src/main/java/kamkeel/npcs/network/packets/player/CheckPlayerValue.java +++ b/src/main/java/kamkeel/npcs/network/packets/player/CheckPlayerValue.java @@ -69,7 +69,7 @@ public class CheckPlayerValue extends AbstractPacket { PlayerData playerData = PlayerDataController.Instance.getPlayerData(playerMP); PlayerQuestData questData = PlayerDataController.Instance.getPlayerData(playerMP).questData; Party playerParty = playerData.getPlayerParty(); - if(playerParty != null) + if (playerParty != null) PartyController.Instance().checkQuestCompletion(playerParty, null); questData.checkQuestCompletion(playerData, null); diff --git a/src/main/java/kamkeel/npcs/network/packets/player/CompanionActionPacket.java b/src/main/java/kamkeel/npcs/network/packets/player/CompanionActionPacket.java index 266ab2d07..117b8f454 100644 --- a/src/main/java/kamkeel/npcs/network/packets/player/CompanionActionPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/player/CompanionActionPacket.java @@ -69,7 +69,7 @@ public class CompanionActionPacket extends AbstractPacket { public void receiveData(ByteBuf in, EntityPlayer player) throws IOException { Type type = Type.values()[in.readInt()]; - if(npc.advanced.role != EnumRoleType.Companion || player != npc.getOwner()) + if (npc.advanced.role != EnumRoleType.Companion || player != npc.getOwner()) return; if (type == Type.OpenInventory) { @@ -79,7 +79,7 @@ public class CompanionActionPacket extends AbstractPacket { int id = in.readInt(); int exp = in.readInt(); RoleCompanion role = (RoleCompanion) npc.roleInterface; - if(exp <= 0 || !role.canAddExp(-exp) || id < 0 || id >= EnumCompanionTalent.values().length) //should never happen unless hacking + if (exp <= 0 || !role.canAddExp(-exp) || id < 0 || id >= EnumCompanionTalent.values().length) //should never happen unless hacking return; EnumCompanionTalent talent = EnumCompanionTalent.values()[id]; role.addExp(-exp); diff --git a/src/main/java/kamkeel/npcs/network/packets/player/DialogSelectPacket.java b/src/main/java/kamkeel/npcs/network/packets/player/DialogSelectPacket.java index 8932b22a0..aeb137b65 100644 --- a/src/main/java/kamkeel/npcs/network/packets/player/DialogSelectPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/player/DialogSelectPacket.java @@ -16,8 +16,9 @@ public class DialogSelectPacket extends AbstractPacket { private int dialogID, optionID; - public DialogSelectPacket(){ + public DialogSelectPacket() { } + public DialogSelectPacket(int dialogID, int optionID) { this.dialogID = dialogID; this.optionID = optionID; diff --git a/src/main/java/kamkeel/npcs/network/packets/player/GetNPCRole.java b/src/main/java/kamkeel/npcs/network/packets/player/GetNPCRole.java index 1056ddb48..73eeeda8d 100644 --- a/src/main/java/kamkeel/npcs/network/packets/player/GetNPCRole.java +++ b/src/main/java/kamkeel/npcs/network/packets/player/GetNPCRole.java @@ -38,7 +38,7 @@ public class GetNPCRole extends AbstractPacket { @Override public void receiveData(ByteBuf in, EntityPlayer player) throws IOException { - if(!(player instanceof EntityPlayerMP)) + if (!(player instanceof EntityPlayerMP)) return; if (npc.advanced.role == EnumRoleType.None) return; diff --git a/src/main/java/kamkeel/npcs/network/packets/player/InputDevicePacket.java b/src/main/java/kamkeel/npcs/network/packets/player/InputDevicePacket.java index 84dac01fe..1b829747b 100644 --- a/src/main/java/kamkeel/npcs/network/packets/player/InputDevicePacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/player/InputDevicePacket.java @@ -34,6 +34,7 @@ public class InputDevicePacket extends AbstractPacket { this.key = key; this.isKeyPressed = isDown; } + public static void sendMouse(int mouseButton, int scroll, boolean isDown) { InputDevicePacket packet = new InputDevicePacket(Type.MOUSE, mouseButton, isDown); packet.scroll = scroll; @@ -121,20 +122,19 @@ public class InputDevicePacket extends AbstractPacket { } private static int[] getPressedArray(String pressedKeys) { - if(pressedKeys == null) + if (pressedKeys == null) return new int[0]; String[] split = pressedKeys.split(","); int[] keysDown; - if(pressedKeys.length() > 0) { + if (pressedKeys.length() > 0) { keysDown = new int[split.length]; try { for (int i = 0; i < split.length; i++) { keysDown[i] = Integer.parseInt(split[i]); } - } - catch (NumberFormatException ignored){ + } catch (NumberFormatException ignored) { } } else { keysDown = new int[0]; diff --git a/src/main/java/kamkeel/npcs/network/packets/player/MailActionPacket.java b/src/main/java/kamkeel/npcs/network/packets/player/MailActionPacket.java index 93f9034c3..82062485f 100644 --- a/src/main/java/kamkeel/npcs/network/packets/player/MailActionPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/player/MailActionPacket.java @@ -45,15 +45,19 @@ public class MailActionPacket extends AbstractPacket { packet.action = Action.GET; PacketClient.sendClient(packet); } + public static void OpenMail(long time, String sender) { PacketClient.sendClient(new MailActionPacket(Action.OPEN, time, sender)); } + public static void DeleteMail(long time, String sender) { PacketClient.sendClient(new MailActionPacket(Action.DELETE, time, sender)); } + public static void ReadMail(long time, String sender) { PacketClient.sendClient(new MailActionPacket(Action.READ, time, sender)); } + public static void SendMail(String receiver, NBTTagCompound mailData) { PacketClient.sendClient(new MailSendPacket(receiver, mailData)); } @@ -90,7 +94,7 @@ public class MailActionPacket extends AbstractPacket { public void receiveData(ByteBuf in, EntityPlayer player) throws IOException { Action type = Action.values()[in.readInt()]; - if(!(player instanceof EntityPlayerMP)) + if (!(player instanceof EntityPlayerMP)) return; EntityPlayerMP playerMP = (EntityPlayerMP) player; PlayerMailData data = PlayerDataController.Instance.getPlayerData(playerMP).mailData; @@ -107,9 +111,9 @@ public class MailActionPacket extends AbstractPacket { case OPEN: playerMP.closeContainer(); - while(it.hasNext()){ + while (it.hasNext()) { PlayerMail mail = it.next(); - if(mail.time == time && mail.sender.equals(user)){ + if (mail.time == time && mail.sender.equals(user)) { ContainerMail.staticmail = mail; playerMP.openGui(CustomNpcs.instance, EnumGuiType.PlayerMailman.ordinal(), playerMP.worldObj, 0, 0, 0); break; @@ -118,9 +122,9 @@ public class MailActionPacket extends AbstractPacket { break; case DELETE: - while(it.hasNext()){ + while (it.hasNext()) { PlayerMail mail = it.next(); - if(mail.time == time && mail.sender.equals(user)){ + if (mail.time == time && mail.sender.equals(user)) { it.remove(); } } @@ -128,11 +132,11 @@ public class MailActionPacket extends AbstractPacket { break; case READ: - while(it.hasNext()){ + while (it.hasNext()) { PlayerMail mail = it.next(); - if(mail.time == time && mail.sender.equals(user)){ + if (mail.time == time && mail.sender.equals(user)) { mail.beenRead = true; - if(mail.hasQuest()) + if (mail.hasQuest()) PlayerQuestController.addActiveQuest(new QuestData(mail.getQuest()), playerMP); } } @@ -148,6 +152,7 @@ public class MailActionPacket extends AbstractPacket { public MailSendPacket() { } + private MailSendPacket(String username, NBTTagCompound mailContent) { this.username = username; this.mailContent = mailContent; @@ -164,10 +169,10 @@ public class MailActionPacket extends AbstractPacket { @Override @SideOnly(Side.SERVER) protected void handleCompleteData(ByteBuf data, EntityPlayer player) throws IOException { - if(!(player instanceof EntityPlayerMP)) + if (!(player instanceof EntityPlayerMP)) return; EntityPlayerMP playerMP = (EntityPlayerMP) player; - if(!(playerMP.openContainer instanceof ContainerMail)) + if (!(playerMP.openContainer instanceof ContainerMail)) return; String mailReceiver = PlayerDataController.Instance.hasPlayer(ByteBufUtils.readString(data)); @@ -179,7 +184,7 @@ public class MailActionPacket extends AbstractPacket { PlayerMail mail = new PlayerMail(); String s = playerMP.getDisplayName(); if (!s.equals(playerMP.getCommandSenderName())) - s += " (" +playerMP.getCommandSenderName() + ")"; + s += " (" + playerMP.getCommandSenderName() + ")"; mail.readNBT(ByteBufUtils.readBigNBT(data)); mail.sender = s; mail.items = ((ContainerMail) playerMP.openContainer).mail.items; @@ -192,7 +197,7 @@ public class MailActionPacket extends AbstractPacket { NBTTagCompound comp = new NBTTagCompound(); comp.setString("username", mailReceiver); - NoppesUtilServer.sendGuiClose(playerMP, 1,comp); + NoppesUtilServer.sendGuiClose(playerMP, 1, comp); } @Override diff --git a/src/main/java/kamkeel/npcs/network/packets/player/SaveSignPacket.java b/src/main/java/kamkeel/npcs/network/packets/player/SaveSignPacket.java index e1c50257e..966265ee5 100644 --- a/src/main/java/kamkeel/npcs/network/packets/player/SaveSignPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/player/SaveSignPacket.java @@ -44,7 +44,7 @@ public class SaveSignPacket extends LargeAbstractPacket { int x = data.readInt(), y = data.readInt(), z = data.readInt(); if (player.worldObj.blockExists(x, y, z)) { TileEntity tile = player.worldObj.getTileEntity(x, y, z); - if(!(tile instanceof TileBigSign)) + if (!(tile instanceof TileBigSign)) return; TileBigSign sign = (TileBigSign) tile; if (sign.canEdit) { diff --git a/src/main/java/kamkeel/npcs/network/packets/player/ScreenSizePacket.java b/src/main/java/kamkeel/npcs/network/packets/player/ScreenSizePacket.java index 83beebcd9..b03a80fd3 100644 --- a/src/main/java/kamkeel/npcs/network/packets/player/ScreenSizePacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/player/ScreenSizePacket.java @@ -19,7 +19,7 @@ public class ScreenSizePacket extends AbstractPacket { public ScreenSizePacket() { } - public ScreenSizePacket(int width, int height){ + public ScreenSizePacket(int width, int height) { this.width = width; this.height = height; } @@ -44,6 +44,6 @@ public class ScreenSizePacket extends AbstractPacket { @Override public void receiveData(ByteBuf in, EntityPlayer player) throws IOException { int width = in.readInt(), height = in.readInt(); - PlayerDataController.Instance.getPlayerData(player).screenSize.setSize(width,height); + PlayerDataController.Instance.getPlayerData(player).screenSize.setSize(width, height); } } diff --git a/src/main/java/kamkeel/npcs/network/packets/player/customgui/CustomGuiButtonPacket.java b/src/main/java/kamkeel/npcs/network/packets/player/customgui/CustomGuiButtonPacket.java index b5616de4a..b95ee07c1 100644 --- a/src/main/java/kamkeel/npcs/network/packets/player/customgui/CustomGuiButtonPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/player/customgui/CustomGuiButtonPacket.java @@ -7,7 +7,6 @@ import kamkeel.npcs.network.AbstractPacket; import kamkeel.npcs.network.PacketChannel; import kamkeel.npcs.network.PacketHandler; import kamkeel.npcs.network.enums.EnumPlayerPacket; -import kamkeel.npcs.network.enums.EnumRequestPacket; import kamkeel.npcs.util.ByteBufUtils; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.nbt.NBTTagCompound; diff --git a/src/main/java/kamkeel/npcs/network/packets/player/customgui/CustomGuiClosePacket.java b/src/main/java/kamkeel/npcs/network/packets/player/customgui/CustomGuiClosePacket.java index 5802c1307..51bfacaa0 100644 --- a/src/main/java/kamkeel/npcs/network/packets/player/customgui/CustomGuiClosePacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/player/customgui/CustomGuiClosePacket.java @@ -7,7 +7,6 @@ import kamkeel.npcs.network.AbstractPacket; import kamkeel.npcs.network.PacketChannel; import kamkeel.npcs.network.PacketHandler; import kamkeel.npcs.network.enums.EnumPlayerPacket; -import kamkeel.npcs.network.enums.EnumRequestPacket; import kamkeel.npcs.util.ByteBufUtils; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.nbt.NBTTagCompound; diff --git a/src/main/java/kamkeel/npcs/network/packets/player/customgui/CustomGuiUnfocusedPacket.java b/src/main/java/kamkeel/npcs/network/packets/player/customgui/CustomGuiUnfocusedPacket.java index ebbe460c5..a147af24c 100644 --- a/src/main/java/kamkeel/npcs/network/packets/player/customgui/CustomGuiUnfocusedPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/player/customgui/CustomGuiUnfocusedPacket.java @@ -7,7 +7,6 @@ import kamkeel.npcs.network.AbstractPacket; import kamkeel.npcs.network.PacketChannel; import kamkeel.npcs.network.PacketHandler; import kamkeel.npcs.network.enums.EnumPlayerPacket; -import kamkeel.npcs.network.enums.EnumRequestPacket; import kamkeel.npcs.util.ByteBufUtils; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.nbt.NBTTagCompound; @@ -24,7 +23,8 @@ public final class CustomGuiUnfocusedPacket extends AbstractPacket { private NBTTagCompound compound; private int id; - public CustomGuiUnfocusedPacket() {} + public CustomGuiUnfocusedPacket() { + } public CustomGuiUnfocusedPacket(int id, NBTTagCompound comp) { this.compound = comp; diff --git a/src/main/java/kamkeel/npcs/network/packets/player/customgui/CustomScrollClickPacket.java b/src/main/java/kamkeel/npcs/network/packets/player/customgui/CustomScrollClickPacket.java index aacb873d0..24a8fcd33 100644 --- a/src/main/java/kamkeel/npcs/network/packets/player/customgui/CustomScrollClickPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/player/customgui/CustomScrollClickPacket.java @@ -7,7 +7,6 @@ import kamkeel.npcs.network.AbstractPacket; import kamkeel.npcs.network.PacketChannel; import kamkeel.npcs.network.PacketHandler; import kamkeel.npcs.network.enums.EnumPlayerPacket; -import kamkeel.npcs.network.enums.EnumRequestPacket; import kamkeel.npcs.util.ByteBufUtils; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.nbt.NBTTagCompound; @@ -28,7 +27,8 @@ public final class CustomScrollClickPacket extends AbstractPacket { private boolean doubleClick; private NBTTagCompound compound; - public CustomScrollClickPacket() {} + public CustomScrollClickPacket() { + } public CustomScrollClickPacket(NBTTagCompound compound, int scrollId, int scrollIndex, NBTTagCompound selection, boolean doubleClick) { this.compound = compound; diff --git a/src/main/java/kamkeel/npcs/network/packets/player/profile/ProfileChangePacket.java b/src/main/java/kamkeel/npcs/network/packets/player/profile/ProfileChangePacket.java index da05e2739..983e5e990 100644 --- a/src/main/java/kamkeel/npcs/network/packets/player/profile/ProfileChangePacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/player/profile/ProfileChangePacket.java @@ -22,7 +22,8 @@ public final class ProfileChangePacket extends AbstractPacket { private int slotID; - public ProfileChangePacket() {} + public ProfileChangePacket() { + } public ProfileChangePacket(int slotID) { this.slotID = slotID; @@ -54,7 +55,7 @@ public final class ProfileChangePacket extends AbstractPacket { if (!(player instanceof EntityPlayerMP)) return; - if(!ConfigMain.ProfilesEnabled) + if (!ConfigMain.ProfilesEnabled) return; int slot = in.readInt(); diff --git a/src/main/java/kamkeel/npcs/network/packets/player/profile/ProfileCreatePacket.java b/src/main/java/kamkeel/npcs/network/packets/player/profile/ProfileCreatePacket.java index 02700cafb..56779947b 100644 --- a/src/main/java/kamkeel/npcs/network/packets/player/profile/ProfileCreatePacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/player/profile/ProfileCreatePacket.java @@ -21,7 +21,8 @@ import java.io.IOException; public final class ProfileCreatePacket extends AbstractPacket { public static String packetName = "Request|ProfileCreate"; - public ProfileCreatePacket() {} + public ProfileCreatePacket() { + } @Override public Enum getType() { @@ -40,14 +41,15 @@ public final class ProfileCreatePacket extends AbstractPacket { @SideOnly(Side.CLIENT) @Override - public void sendData(ByteBuf out) throws IOException {} + public void sendData(ByteBuf out) throws IOException { + } @Override public void receiveData(ByteBuf in, EntityPlayer player) throws IOException { if (!(player instanceof EntityPlayerMP)) return; - if(!ConfigMain.ProfilesEnabled) + if (!ConfigMain.ProfilesEnabled) return; Profile profile = ProfileController.Instance.getProfile(player); diff --git a/src/main/java/kamkeel/npcs/network/packets/player/profile/ProfileGetInfoPacket.java b/src/main/java/kamkeel/npcs/network/packets/player/profile/ProfileGetInfoPacket.java index debb8a43c..c4d92d674 100644 --- a/src/main/java/kamkeel/npcs/network/packets/player/profile/ProfileGetInfoPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/player/profile/ProfileGetInfoPacket.java @@ -4,19 +4,19 @@ import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import io.netty.buffer.ByteBuf; import kamkeel.npcs.controllers.ProfileController; -import kamkeel.npcs.network.enums.EnumPlayerPacket; -import noppes.npcs.api.handler.data.ISlot; -import kamkeel.npcs.controllers.data.profile.ProfileInfoEntry; import kamkeel.npcs.controllers.data.profile.Profile; +import kamkeel.npcs.controllers.data.profile.ProfileInfoEntry; import kamkeel.npcs.network.AbstractPacket; import kamkeel.npcs.network.PacketChannel; import kamkeel.npcs.network.PacketHandler; +import kamkeel.npcs.network.enums.EnumPlayerPacket; import kamkeel.npcs.network.packets.data.large.GuiDataPacket; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraftforge.common.util.Constants; +import noppes.npcs.api.handler.data.ISlot; import noppes.npcs.config.ConfigMain; import java.io.IOException; @@ -27,7 +27,8 @@ import java.util.List; public final class ProfileGetInfoPacket extends AbstractPacket { public static String packetName = "Request|ProfileGetInfo"; - public ProfileGetInfoPacket() {} + public ProfileGetInfoPacket() { + } @Override public Enum getType() { @@ -41,31 +42,32 @@ public final class ProfileGetInfoPacket extends AbstractPacket { @SideOnly(Side.CLIENT) @Override - public void sendData(ByteBuf out) throws IOException {} + public void sendData(ByteBuf out) throws IOException { + } @Override public void receiveData(ByteBuf in, EntityPlayer player) throws IOException { if (!(player instanceof EntityPlayerMP)) return; - if(!ConfigMain.ProfilesEnabled) + if (!ConfigMain.ProfilesEnabled) return; sendProfileInfo(player); } - public static void sendProfileInfo(EntityPlayer player){ + public static void sendProfileInfo(EntityPlayer player) { NBTTagCompound compound = new NBTTagCompound(); compound.setBoolean("PROFILE_INFO", true); NBTTagList slotList = new NBTTagList(); Profile profile = ProfileController.Instance.getProfile(player); - if(profile != null){ - for(ISlot slot : profile.getSlots().values()){ + if (profile != null) { + for (ISlot slot : profile.getSlots().values()) { NBTTagCompound slotCompound = new NBTTagCompound(); NBTTagList infoList = new NBTTagList(); slotCompound.setInteger("ID", slot.getId()); List profileInfo = ProfileController.Instance.getProfileInfo(player, slot.getId()); - for(ProfileInfoEntry profileInfoEntry : profileInfo){ + for (ProfileInfoEntry profileInfoEntry : profileInfo) { infoList.appendTag(profileInfoEntry.writeToNBT()); } slotCompound.setTag("INFO", infoList); diff --git a/src/main/java/kamkeel/npcs/network/packets/player/profile/ProfileGetPacket.java b/src/main/java/kamkeel/npcs/network/packets/player/profile/ProfileGetPacket.java index fa7cbc196..6ef9cdefe 100644 --- a/src/main/java/kamkeel/npcs/network/packets/player/profile/ProfileGetPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/player/profile/ProfileGetPacket.java @@ -20,7 +20,8 @@ import java.io.IOException; public final class ProfileGetPacket extends AbstractPacket { public static String packetName = "Request|ProfileGet"; - public ProfileGetPacket() {} + public ProfileGetPacket() { + } @Override public Enum getType() { @@ -34,20 +35,21 @@ public final class ProfileGetPacket extends AbstractPacket { @SideOnly(Side.CLIENT) @Override - public void sendData(ByteBuf out) throws IOException {} + public void sendData(ByteBuf out) throws IOException { + } @Override public void receiveData(ByteBuf in, EntityPlayer player) throws IOException { if (!(player instanceof EntityPlayerMP)) return; - if(!ConfigMain.ProfilesEnabled) + if (!ConfigMain.ProfilesEnabled) return; sendProfileNBT(player); } - public static void sendProfileNBT(EntityPlayer player){ + public static void sendProfileNBT(EntityPlayer player) { Profile profile = ProfileController.Instance.getProfile(player); NBTTagCompound compound = profile.writeToNBT(); compound.setBoolean("PROFILE", true); diff --git a/src/main/java/kamkeel/npcs/network/packets/player/profile/ProfileRemovePacket.java b/src/main/java/kamkeel/npcs/network/packets/player/profile/ProfileRemovePacket.java index 92c145b57..c13de0938 100644 --- a/src/main/java/kamkeel/npcs/network/packets/player/profile/ProfileRemovePacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/player/profile/ProfileRemovePacket.java @@ -22,7 +22,8 @@ public final class ProfileRemovePacket extends AbstractPacket { private int slotID; - public ProfileRemovePacket() {} + public ProfileRemovePacket() { + } public ProfileRemovePacket(int slotID) { this.slotID = slotID; @@ -54,7 +55,7 @@ public final class ProfileRemovePacket extends AbstractPacket { if (!(player instanceof EntityPlayerMP)) return; - if(!ConfigMain.ProfilesEnabled) + if (!ConfigMain.ProfilesEnabled) return; int slot = in.readInt(); diff --git a/src/main/java/kamkeel/npcs/network/packets/player/profile/ProfileRenamePacket.java b/src/main/java/kamkeel/npcs/network/packets/player/profile/ProfileRenamePacket.java index 6ce78dc79..f7066d4d7 100644 --- a/src/main/java/kamkeel/npcs/network/packets/player/profile/ProfileRenamePacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/player/profile/ProfileRenamePacket.java @@ -24,7 +24,8 @@ public final class ProfileRenamePacket extends AbstractPacket { private int slotID; private String name; - public ProfileRenamePacket() {} + public ProfileRenamePacket() { + } public ProfileRenamePacket(int slotID, String name) { this.slotID = slotID; @@ -58,14 +59,14 @@ public final class ProfileRenamePacket extends AbstractPacket { if (!(player instanceof EntityPlayerMP)) return; - if(!ConfigMain.ProfilesEnabled) + if (!ConfigMain.ProfilesEnabled) return; int slot = in.readInt(); String newName = ByteBufUtils.readString(in); Profile profile = ProfileController.Instance.getProfile(player); - if(!profile.getSlots().containsKey(slot)) { + if (!profile.getSlots().containsKey(slot)) { ChatAlertPacket.sendChatAlert((EntityPlayerMP) player, "No slot found"); return; } diff --git a/src/main/java/kamkeel/npcs/network/packets/request/GuiRequestPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/GuiRequestPacket.java index e0ca00894..7ff122b19 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/GuiRequestPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/GuiRequestPacket.java @@ -28,7 +28,8 @@ public final class GuiRequestPacket extends AbstractPacket { this.posZ = posZ; } - public GuiRequestPacket() {} + public GuiRequestPacket() { + } @Override public Enum getType() { diff --git a/src/main/java/kamkeel/npcs/network/packets/request/MailOpenSetupPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/MailOpenSetupPacket.java index 473053715..9d0ec6b4b 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/MailOpenSetupPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/MailOpenSetupPacket.java @@ -25,7 +25,8 @@ public final class MailOpenSetupPacket extends AbstractPacket { private NBTTagCompound compound; - public MailOpenSetupPacket() { } + public MailOpenSetupPacket() { + } public MailOpenSetupPacket(NBTTagCompound compound) { this.compound = compound; diff --git a/src/main/java/kamkeel/npcs/network/packets/request/MerchantUpdatePacket.java b/src/main/java/kamkeel/npcs/network/packets/request/MerchantUpdatePacket.java index 41f812ae8..8e297fa10 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/MerchantUpdatePacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/MerchantUpdatePacket.java @@ -26,7 +26,8 @@ public final class MerchantUpdatePacket extends AbstractPacket { private int entityID; private MerchantRecipeList list; - public MerchantUpdatePacket() { } + public MerchantUpdatePacket() { + } public MerchantUpdatePacket(int entityID, MerchantRecipeList list) { this.entityID = entityID; @@ -68,6 +69,6 @@ public final class MerchantUpdatePacket extends AbstractPacket { return; MerchantRecipeList list = MerchantRecipeList.func_151390_b(new PacketBuffer(in)); - ((EntityVillager)entity).setRecipes(list); + ((EntityVillager) entity).setRecipes(list); } } diff --git a/src/main/java/kamkeel/npcs/network/packets/request/MountPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/MountPacket.java index b20694807..5facb2c5d 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/MountPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/MountPacket.java @@ -23,7 +23,8 @@ public final class MountPacket extends AbstractPacket { private Action action; private NBTTagCompound compound; - public MountPacket() {} + public MountPacket() { + } public MountPacket(Action action, NBTTagCompound nbtTagCompound) { this.action = action; @@ -51,7 +52,7 @@ public final class MountPacket extends AbstractPacket { @Override public void sendData(ByteBuf out) throws IOException { out.writeInt(action.ordinal()); - if(action == Action.Spawn) + if (action == Action.Spawn) ByteBufUtils.writeNBT(out, this.compound); } @@ -64,7 +65,7 @@ public final class MountPacket extends AbstractPacket { return; MountPacket.Action requestedAction = MountPacket.Action.values()[in.readInt()]; - switch (requestedAction){ + switch (requestedAction) { case Player: player.mountEntity(ServerEventsHandler.mounted); break; @@ -79,6 +80,7 @@ public final class MountPacket extends AbstractPacket { public static void Player() { PacketClient.sendClient(new MountPacket(Action.Player, new NBTTagCompound())); } + public static void Spawn(NBTTagCompound compound) { PacketClient.sendClient(new MountPacket(Action.Spawn, compound)); } diff --git a/src/main/java/kamkeel/npcs/network/packets/request/TileEntityGetPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/TileEntityGetPacket.java index 0ef4419a1..511fea361 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/TileEntityGetPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/TileEntityGetPacket.java @@ -25,7 +25,8 @@ public final class TileEntityGetPacket extends AbstractPacket { private int z; - public TileEntityGetPacket() {} + public TileEntityGetPacket() { + } public TileEntityGetPacket(int x, int y, int z) { this.x = x; diff --git a/src/main/java/kamkeel/npcs/network/packets/request/TileEntitySavePacket.java b/src/main/java/kamkeel/npcs/network/packets/request/TileEntitySavePacket.java index 42a0b5912..5b2a9a902 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/TileEntitySavePacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/TileEntitySavePacket.java @@ -22,7 +22,8 @@ public final class TileEntitySavePacket extends AbstractPacket { private NBTTagCompound compound; - public TileEntitySavePacket() {} + public TileEntitySavePacket() { + } public TileEntitySavePacket(NBTTagCompound compound) { this.compound = compound; diff --git a/src/main/java/kamkeel/npcs/network/packets/request/TraderMarketSavePacket.java b/src/main/java/kamkeel/npcs/network/packets/request/TraderMarketSavePacket.java index 1fee4191b..6d338830b 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/TraderMarketSavePacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/TraderMarketSavePacket.java @@ -24,7 +24,8 @@ public final class TraderMarketSavePacket extends AbstractPacket { private String marketName; private boolean setMarket; - public TraderMarketSavePacket() { } + public TraderMarketSavePacket() { + } public TraderMarketSavePacket(String marketName, boolean setMarket) { this.marketName = marketName; @@ -71,11 +72,11 @@ public final class TraderMarketSavePacket extends AbstractPacket { return; boolean bo = in.readBoolean(); - if(npc.roleInterface instanceof RoleTrader){ - if(bo) + if (npc.roleInterface instanceof RoleTrader) { + if (bo) Market.setMarket(npc, market); else - Market.save((RoleTrader)npc.roleInterface, market); + Market.save((RoleTrader) npc.roleInterface, market); } } } diff --git a/src/main/java/kamkeel/npcs/network/packets/request/animation/AnimationGetPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/animation/AnimationGetPacket.java index 2e65b098e..a577891fe 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/animation/AnimationGetPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/animation/AnimationGetPacket.java @@ -23,7 +23,8 @@ public final class AnimationGetPacket extends AbstractPacket { private int animationID; - public AnimationGetPacket() { } + public AnimationGetPacket() { + } public AnimationGetPacket(int animationID) { this.animationID = animationID; @@ -33,6 +34,7 @@ public final class AnimationGetPacket extends AbstractPacket { public Enum getType() { return EnumRequestPacket.AnimationGet; } + @Override public PacketChannel getChannel() { return PacketHandler.REQUEST_PACKET; diff --git a/src/main/java/kamkeel/npcs/network/packets/request/animation/AnimationRemovePacket.java b/src/main/java/kamkeel/npcs/network/packets/request/animation/AnimationRemovePacket.java index 49461a549..4aa8a4778 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/animation/AnimationRemovePacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/animation/AnimationRemovePacket.java @@ -25,7 +25,8 @@ public final class AnimationRemovePacket extends AbstractPacket { private int animationID; - public AnimationRemovePacket() { } + public AnimationRemovePacket() { + } public AnimationRemovePacket(int animationID) { this.animationID = animationID; @@ -49,7 +50,7 @@ public final class AnimationRemovePacket extends AbstractPacket { @SideOnly(Side.CLIENT) @Override public void sendData(ByteBuf out) throws IOException { - out.writeInt(this.animationID ); + out.writeInt(this.animationID); } @Override diff --git a/src/main/java/kamkeel/npcs/network/packets/request/animation/AnimationSavePacket.java b/src/main/java/kamkeel/npcs/network/packets/request/animation/AnimationSavePacket.java index 2b80eb5be..a34e82c1d 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/animation/AnimationSavePacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/animation/AnimationSavePacket.java @@ -29,7 +29,9 @@ public final class AnimationSavePacket extends AbstractPacket { public AnimationSavePacket(NBTTagCompound animationNBT) { this.animationNBT = animationNBT; } - public AnimationSavePacket(){} + + public AnimationSavePacket() { + } @Override public Enum getType() { diff --git a/src/main/java/kamkeel/npcs/network/packets/request/animation/AnimationsGetPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/animation/AnimationsGetPacket.java index 206a1900e..83c5ef33e 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/animation/AnimationsGetPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/animation/AnimationsGetPacket.java @@ -18,7 +18,8 @@ import java.io.IOException; public final class AnimationsGetPacket extends AbstractPacket { public static String packetName = "Request|AnimationsGet"; - public AnimationsGetPacket() { } + public AnimationsGetPacket() { + } @Override public Enum getType() { @@ -32,7 +33,8 @@ public final class AnimationsGetPacket extends AbstractPacket { @SideOnly(Side.CLIENT) @Override - public void sendData(ByteBuf out) throws IOException { } + public void sendData(ByteBuf out) throws IOException { + } @Override public void receiveData(ByteBuf in, EntityPlayer player) throws IOException { diff --git a/src/main/java/kamkeel/npcs/network/packets/request/bank/BankRemovePacket.java b/src/main/java/kamkeel/npcs/network/packets/request/bank/BankRemovePacket.java index ae34978f2..fb21141de 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/bank/BankRemovePacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/bank/BankRemovePacket.java @@ -27,7 +27,8 @@ public final class BankRemovePacket extends AbstractPacket { this.bankId = bankId; } - public BankRemovePacket() {} + public BankRemovePacket() { + } @Override public Enum getType() { diff --git a/src/main/java/kamkeel/npcs/network/packets/request/clone/CloneAllTagsPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/clone/CloneAllTagsPacket.java index c593e5097..2e17e72a0 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/clone/CloneAllTagsPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/clone/CloneAllTagsPacket.java @@ -23,7 +23,8 @@ import java.util.HashSet; public final class CloneAllTagsPacket extends AbstractPacket { public static String packetName = "Request|CloneAllTags"; - public CloneAllTagsPacket() {} + public CloneAllTagsPacket() { + } @Override public Enum getType() { @@ -37,7 +38,8 @@ public final class CloneAllTagsPacket extends AbstractPacket { @SideOnly(Side.CLIENT) @Override - public void sendData(ByteBuf out) throws IOException {} + public void sendData(ByteBuf out) throws IOException { + } @Override public void receiveData(ByteBuf in, EntityPlayer player) throws IOException { @@ -49,7 +51,7 @@ public final class CloneAllTagsPacket extends AbstractPacket { NBTTagCompound compound = new NBTTagCompound(); HashSet validTags = TagController.getInstance().getAllTags(); NBTTagList validTagList = new NBTTagList(); - for(Tag tag : validTags){ + for (Tag tag : validTags) { NBTTagCompound tagCompound = new NBTTagCompound(); tag.writeNBT(tagCompound); validTagList.appendTag(tagCompound); diff --git a/src/main/java/kamkeel/npcs/network/packets/request/clone/CloneAllTagsShortPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/clone/CloneAllTagsShortPacket.java index 127a7caf2..ef3ec908c 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/clone/CloneAllTagsShortPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/clone/CloneAllTagsShortPacket.java @@ -23,7 +23,8 @@ import java.util.HashSet; public final class CloneAllTagsShortPacket extends AbstractPacket { public static String packetName = "Request|CloneAllTagsShort"; - public CloneAllTagsShortPacket() {} + public CloneAllTagsShortPacket() { + } @Override public Enum getType() { @@ -37,7 +38,8 @@ public final class CloneAllTagsShortPacket extends AbstractPacket { @SideOnly(Side.CLIENT) @Override - public void sendData(ByteBuf out) throws IOException {} + public void sendData(ByteBuf out) throws IOException { + } @Override public void receiveData(ByteBuf in, EntityPlayer player) throws IOException { @@ -49,7 +51,7 @@ public final class CloneAllTagsShortPacket extends AbstractPacket { NBTTagCompound compound = new NBTTagCompound(); HashSet validTags = TagController.getInstance().getAllTags(); NBTTagList validTagList = new NBTTagList(); - for(Tag tag : validTags){ + for (Tag tag : validTags) { NBTTagCompound tagCompound = new NBTTagCompound(); tag.writeShortNBT(tagCompound); validTagList.appendTag(tagCompound); diff --git a/src/main/java/kamkeel/npcs/network/packets/request/clone/CloneListPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/clone/CloneListPacket.java index 4e9212e0f..20013b469 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/clone/CloneListPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/clone/CloneListPacket.java @@ -10,14 +10,12 @@ import kamkeel.npcs.network.PacketUtil; import kamkeel.npcs.network.enums.EnumItemPacketType; import kamkeel.npcs.network.enums.EnumRequestPacket; import kamkeel.npcs.network.packets.data.large.GuiDataPacket; -import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraft.nbt.NBTTagString; import noppes.npcs.controllers.ServerCloneController; -import noppes.npcs.entity.EntityNPCInterface; import java.io.IOException; @@ -30,7 +28,8 @@ public final class CloneListPacket extends AbstractPacket { this.tab = tab; } - public CloneListPacket() {} + public CloneListPacket() { + } @Override public Enum getType() { @@ -57,11 +56,11 @@ public final class CloneListPacket extends AbstractPacket { NBTTagList list = new NBTTagList(); int tab = in.readInt(); - for(String name : ServerCloneController.Instance.getClones(tab)) + for (String name : ServerCloneController.Instance.getClones(tab)) list.appendTag(new NBTTagString(name)); NBTTagList listDate = new NBTTagList(); - for(String name : ServerCloneController.Instance.getClonesDate(tab)) + for (String name : ServerCloneController.Instance.getClonesDate(tab)) listDate.appendTag(new NBTTagString(name)); NBTTagCompound compound = new NBTTagCompound(); diff --git a/src/main/java/kamkeel/npcs/network/packets/request/clone/ClonePreSavePacket.java b/src/main/java/kamkeel/npcs/network/packets/request/clone/ClonePreSavePacket.java index e769219c8..cbcc6ecf5 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/clone/ClonePreSavePacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/clone/ClonePreSavePacket.java @@ -25,7 +25,8 @@ public final class ClonePreSavePacket extends AbstractPacket { private String name; private int tab; - public ClonePreSavePacket() {} + public ClonePreSavePacket() { + } public ClonePreSavePacket(String name, int tab) { this.name = name; @@ -43,7 +44,7 @@ public final class ClonePreSavePacket extends AbstractPacket { } @Override - public CustomNpcsPermissions.Permission getPermission(){ + public CustomNpcsPermissions.Permission getPermission() { return CustomNpcsPermissions.NPC_CLONE; } diff --git a/src/main/java/kamkeel/npcs/network/packets/request/clone/CloneRemovePacket.java b/src/main/java/kamkeel/npcs/network/packets/request/clone/CloneRemovePacket.java index 44e33ccc9..282aeac99 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/clone/CloneRemovePacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/clone/CloneRemovePacket.java @@ -27,7 +27,8 @@ public final class CloneRemovePacket extends AbstractPacket { private int tab; private String name; - public CloneRemovePacket() {} + public CloneRemovePacket() { + } public CloneRemovePacket(int tab, String name) { this.tab = tab; @@ -45,7 +46,7 @@ public final class CloneRemovePacket extends AbstractPacket { } @Override - public CustomNpcsPermissions.Permission getPermission(){ + public CustomNpcsPermissions.Permission getPermission() { return CustomNpcsPermissions.NPC_CLONE; } @@ -68,11 +69,11 @@ public final class CloneRemovePacket extends AbstractPacket { NBTTagList list = new NBTTagList(); - for(String name : ServerCloneController.Instance.getClones(tab)) + for (String name : ServerCloneController.Instance.getClones(tab)) list.appendTag(new NBTTagString(name)); NBTTagList listDate = new NBTTagList(); - for(String name : ServerCloneController.Instance.getClonesDate(tab)) + for (String name : ServerCloneController.Instance.getClonesDate(tab)) listDate.appendTag(new NBTTagString(name)); NBTTagCompound compound = new NBTTagCompound(); diff --git a/src/main/java/kamkeel/npcs/network/packets/request/clone/CloneSavePacket.java b/src/main/java/kamkeel/npcs/network/packets/request/clone/CloneSavePacket.java index e757a9079..8b6fb39a1 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/clone/CloneSavePacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/clone/CloneSavePacket.java @@ -29,7 +29,8 @@ public final class CloneSavePacket extends AbstractPacket { private NBTTagCompound tagExtra; private NBTTagCompound tagCompound; - public CloneSavePacket() {} + public CloneSavePacket() { + } public CloneSavePacket(String name, int tab, NBTTagCompound tagExtra, NBTTagCompound tagCompound) { this.name = name; @@ -49,7 +50,7 @@ public final class CloneSavePacket extends AbstractPacket { } @Override - public CustomNpcsPermissions.Permission getPermission(){ + public CustomNpcsPermissions.Permission getPermission() { return CustomNpcsPermissions.NPC_CLONE; } @@ -70,7 +71,7 @@ public final class CloneSavePacket extends AbstractPacket { return; PlayerData data = PlayerDataController.Instance.getPlayerData(player); - if(data.cloned == null) + if (data.cloned == null) return; String name = ByteBufUtils.readString(in); diff --git a/src/main/java/kamkeel/npcs/network/packets/request/clone/CloneTagListPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/clone/CloneTagListPacket.java index a12a1fe0c..fe264d20a 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/clone/CloneTagListPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/clone/CloneTagListPacket.java @@ -27,7 +27,8 @@ public final class CloneTagListPacket extends AbstractPacket { this.tab = tab; } - public CloneTagListPacket() {} + public CloneTagListPacket() { + } @Override public Enum getType() { diff --git a/src/main/java/kamkeel/npcs/network/packets/request/clone/MobSpawnerPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/clone/MobSpawnerPacket.java index 9b6a1143f..aacc85a20 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/clone/MobSpawnerPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/clone/MobSpawnerPacket.java @@ -30,7 +30,8 @@ public class MobSpawnerPacket extends AbstractPacket { private NBTTagCompound compound; - public MobSpawnerPacket() {} + public MobSpawnerPacket() { + } public MobSpawnerPacket(Action type, int posX, int posY, int posz, String selectedName, int tab) { this.type = type; @@ -52,6 +53,7 @@ public class MobSpawnerPacket extends AbstractPacket { public static void Server(int x, int y, int z, String name, int tab) { PacketClient.sendClient(new MobSpawnerPacket(Action.Server, x, y, z, name, tab)); } + public static void Client(int x, int y, int z, NBTTagCompound compound) { PacketClient.sendClient(new MobSpawnerPacket(Action.Client, x, y, z, compound)); } @@ -101,7 +103,7 @@ public class MobSpawnerPacket extends AbstractPacket { int z = in.readInt(); NBTTagCompound compound; - if(requestedAction == Action.Server) + if (requestedAction == Action.Server) compound = ServerCloneController.Instance.getCloneData(player, ByteBufUtils.readString(in), in.readInt()); else compound = ByteBufUtils.readNBT(in); @@ -110,7 +112,7 @@ public class MobSpawnerPacket extends AbstractPacket { return; } - if(compound != null) + if (compound != null) NoppesUtilServer.createMobSpawner(x, y, z, compound, player); } diff --git a/src/main/java/kamkeel/npcs/network/packets/request/clone/SpawnMobPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/clone/SpawnMobPacket.java index ea9a6244d..a8d2b6e33 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/clone/SpawnMobPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/clone/SpawnMobPacket.java @@ -36,7 +36,8 @@ public class SpawnMobPacket extends AbstractPacket { private NBTTagCompound compound; - public SpawnMobPacket() {} + public SpawnMobPacket() { + } public SpawnMobPacket(Action type, int posX, int posY, int posz, String selectedName, int tab) { this.type = type; @@ -108,15 +109,15 @@ public class SpawnMobPacket extends AbstractPacket { int z = in.readInt(); NBTTagCompound compound; - if(requestedAction == Action.Server) + if (requestedAction == Action.Server) compound = ServerCloneController.Instance.getCloneData(player, ByteBufUtils.readString(in), in.readInt()); else compound = ByteBufUtils.readNBT(in); - if(compound == null) + if (compound == null) return; Entity entity = NoppesUtilServer.spawnClone(compound, x, y, z, player.worldObj); - if(entity == null){ + if (entity == null) { player.addChatMessage(new ChatComponentText("Failed to create an entity out of your clone")); return; } @@ -126,7 +127,7 @@ public class SpawnMobPacket extends AbstractPacket { npc.script.setEnabled(false); } - if(ConfigDebug.PlayerLogging && FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER){ + if (ConfigDebug.PlayerLogging && FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER) { LogWriter.script(String.format("[%s] (Player) %s SPAWNED ENTITY %s", "CLONER", player.getCommandSenderName(), entity)); } } diff --git a/src/main/java/kamkeel/npcs/network/packets/request/dialog/DialogCategoriesGetPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/dialog/DialogCategoriesGetPacket.java index 772dfed26..e948fdda8 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/dialog/DialogCategoriesGetPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/dialog/DialogCategoriesGetPacket.java @@ -20,7 +20,8 @@ import java.io.IOException; public final class DialogCategoriesGetPacket extends AbstractPacket { public static String packetName = "Request|DialogCategoriesGet"; - public DialogCategoriesGetPacket() {} + public DialogCategoriesGetPacket() { + } @Override public Enum getType() { @@ -34,7 +35,8 @@ public final class DialogCategoriesGetPacket extends AbstractPacket { @SideOnly(Side.CLIENT) @Override - public void sendData(ByteBuf out) throws IOException {} + public void sendData(ByteBuf out) throws IOException { + } @Override public void receiveData(ByteBuf in, EntityPlayer player) throws IOException { diff --git a/src/main/java/kamkeel/npcs/network/packets/request/dialog/DialogCategoryGetPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/dialog/DialogCategoryGetPacket.java index 0cf33b8dd..9ccad6677 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/dialog/DialogCategoryGetPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/dialog/DialogCategoryGetPacket.java @@ -23,7 +23,8 @@ public final class DialogCategoryGetPacket extends AbstractPacket { private int categoryID; - public DialogCategoryGetPacket() {} + public DialogCategoryGetPacket() { + } public DialogCategoryGetPacket(int categoryID) { this.categoryID = categoryID; diff --git a/src/main/java/kamkeel/npcs/network/packets/request/dialog/DialogGetPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/dialog/DialogGetPacket.java index f8787f435..2a0aec2c2 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/dialog/DialogGetPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/dialog/DialogGetPacket.java @@ -22,7 +22,8 @@ public final class DialogGetPacket extends AbstractPacket { private int dialogID; - public DialogGetPacket() {} + public DialogGetPacket() { + } public DialogGetPacket(int dialogID) { this.dialogID = dialogID; @@ -53,16 +54,16 @@ public final class DialogGetPacket extends AbstractPacket { return; Dialog dialog = DialogController.Instance.dialogs.get(in.readInt()); - if(dialog != null){ + if (dialog != null) { NBTTagCompound compound = dialog.writeToNBT(new NBTTagCompound()); Quest quest = QuestController.Instance.quests.get(dialog.quest); - if(quest != null) + if (quest != null) compound.setString("DialogQuestName", quest.title); GuiDataPacket.sendGuiData((EntityPlayerMP) player, compound); } } - public static void getDialog(int id){ + public static void getDialog(int id) { PacketClient.sendClient(new DialogGetPacket(id)); } } diff --git a/src/main/java/kamkeel/npcs/network/packets/request/dialog/DialogNpcGetPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/dialog/DialogNpcGetPacket.java index ef2dcbf8b..cae4b9c80 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/dialog/DialogNpcGetPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/dialog/DialogNpcGetPacket.java @@ -18,7 +18,8 @@ import java.io.IOException; public final class DialogNpcGetPacket extends AbstractPacket { public static String packetName = "Request|DialogNpcGet"; - public DialogNpcGetPacket() {} + public DialogNpcGetPacket() { + } @Override public Enum getType() { @@ -32,7 +33,8 @@ public final class DialogNpcGetPacket extends AbstractPacket { @SideOnly(Side.CLIENT) @Override - public void sendData(ByteBuf out) throws IOException {} + public void sendData(ByteBuf out) throws IOException { + } @Override public void receiveData(ByteBuf in, EntityPlayer player) throws IOException { diff --git a/src/main/java/kamkeel/npcs/network/packets/request/dialog/DialogNpcRemovePacket.java b/src/main/java/kamkeel/npcs/network/packets/request/dialog/DialogNpcRemovePacket.java index cf482b5fc..43769e16d 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/dialog/DialogNpcRemovePacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/dialog/DialogNpcRemovePacket.java @@ -24,7 +24,8 @@ public final class DialogNpcRemovePacket extends AbstractPacket { this.index = index; } - public DialogNpcRemovePacket() {} + public DialogNpcRemovePacket() { + } @Override public Enum getType() { diff --git a/src/main/java/kamkeel/npcs/network/packets/request/dialog/DialogRemovePacket.java b/src/main/java/kamkeel/npcs/network/packets/request/dialog/DialogRemovePacket.java index b0de2dc0a..22a917eb9 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/dialog/DialogRemovePacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/dialog/DialogRemovePacket.java @@ -63,13 +63,12 @@ public final class DialogRemovePacket extends AbstractPacket { int diagId = in.readInt(); boolean sendGroup = in.readBoolean(); Dialog dialog = DialogController.Instance.dialogs.get(diagId); - if(dialog != null && dialog.category != null){ + if (dialog != null && dialog.category != null) { DialogController.Instance.removeDialog(dialog); - if(sendGroup){ - NoppesUtilServer.sendDialogGroup((EntityPlayerMP) player,dialog.category); - } - else { - NoppesUtilServer.sendDialogData((EntityPlayerMP) player,dialog.category); + if (sendGroup) { + NoppesUtilServer.sendDialogGroup((EntityPlayerMP) player, dialog.category); + } else { + NoppesUtilServer.sendDialogData((EntityPlayerMP) player, dialog.category); } } } diff --git a/src/main/java/kamkeel/npcs/network/packets/request/dialog/DialogsGetPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/dialog/DialogsGetPacket.java index fb8563785..9ea47415a 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/dialog/DialogsGetPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/dialog/DialogsGetPacket.java @@ -22,7 +22,8 @@ public final class DialogsGetPacket extends AbstractPacket { private int categoryID; private boolean sendGroup; - public DialogsGetPacket() {} + public DialogsGetPacket() { + } public DialogsGetPacket(int categoryID, boolean send) { this.categoryID = categoryID; @@ -56,11 +57,10 @@ public final class DialogsGetPacket extends AbstractPacket { int catID = in.readInt(); boolean sendGroup = in.readBoolean(); - if(sendGroup){ - NoppesUtilServer.sendDialogGroup((EntityPlayerMP) player,DialogController.Instance.categories.get(catID)); - } - else { - NoppesUtilServer.sendDialogData((EntityPlayerMP) player,DialogController.Instance.categories.get(catID)); + if (sendGroup) { + NoppesUtilServer.sendDialogGroup((EntityPlayerMP) player, DialogController.Instance.categories.get(catID)); + } else { + NoppesUtilServer.sendDialogData((EntityPlayerMP) player, DialogController.Instance.categories.get(catID)); } } } diff --git a/src/main/java/kamkeel/npcs/network/packets/request/effects/EffectRemovePacket.java b/src/main/java/kamkeel/npcs/network/packets/request/effects/EffectRemovePacket.java index b8d4232f7..3b80a3f43 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/effects/EffectRemovePacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/effects/EffectRemovePacket.java @@ -27,7 +27,8 @@ public class EffectRemovePacket extends AbstractPacket { this.effectID = outlineID; } - public EffectRemovePacket() {} + public EffectRemovePacket() { + } @Override public Enum getType() { diff --git a/src/main/java/kamkeel/npcs/network/packets/request/effects/EffectSavePacket.java b/src/main/java/kamkeel/npcs/network/packets/request/effects/EffectSavePacket.java index de67d9017..1990fb205 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/effects/EffectSavePacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/effects/EffectSavePacket.java @@ -24,12 +24,13 @@ public class EffectSavePacket extends AbstractPacket { private String prevName; private NBTTagCompound effectCompound; - public EffectSavePacket(NBTTagCompound compound, String prev){ + public EffectSavePacket(NBTTagCompound compound, String prev) { this.effectCompound = compound; this.prevName = prev; } - public EffectSavePacket() {} + public EffectSavePacket() { + } @Override public Enum getType() { @@ -66,7 +67,7 @@ public class EffectSavePacket extends AbstractPacket { CustomEffectController.getInstance().saveEffect(effect); - if(!prevName.isEmpty() && !prevName.equals(effect.name)){ + if (!prevName.isEmpty() && !prevName.equals(effect.name)) { CustomEffectController.getInstance().deleteEffectFile(prevName); } diff --git a/src/main/java/kamkeel/npcs/network/packets/request/effects/EffectsGetPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/effects/EffectsGetPacket.java index b63cfd8ad..da144f4ab 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/effects/EffectsGetPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/effects/EffectsGetPacket.java @@ -25,7 +25,8 @@ public final class EffectsGetPacket extends AbstractPacket { this.effectID = outlineID; } - public EffectsGetPacket() {} + public EffectsGetPacket() { + } @Override public Enum getType() { diff --git a/src/main/java/kamkeel/npcs/network/packets/request/faction/FactionGetPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/faction/FactionGetPacket.java index 487e08f6c..9056337ec 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/faction/FactionGetPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/faction/FactionGetPacket.java @@ -20,7 +20,8 @@ public final class FactionGetPacket extends AbstractPacket { private int factionID; - public FactionGetPacket() {} + public FactionGetPacket() { + } public FactionGetPacket(int factionID) { this.factionID = factionID; @@ -56,7 +57,7 @@ public final class FactionGetPacket extends AbstractPacket { GuiDataPacket.sendGuiData((EntityPlayerMP) player, compound); } - public static void getFaction(int id){ + public static void getFaction(int id) { PacketClient.sendClient(new FactionGetPacket(id)); } } diff --git a/src/main/java/kamkeel/npcs/network/packets/request/faction/FactionsGetPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/faction/FactionsGetPacket.java index 7f4d90b5e..17431ae99 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/faction/FactionsGetPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/faction/FactionsGetPacket.java @@ -18,7 +18,8 @@ import java.io.IOException; public final class FactionsGetPacket extends AbstractPacket { public static String packetName = "Request|FactionsGet"; - public FactionsGetPacket() {} + public FactionsGetPacket() { + } @Override @@ -33,7 +34,8 @@ public final class FactionsGetPacket extends AbstractPacket { @SideOnly(Side.CLIENT) @Override - public void sendData(ByteBuf out) throws IOException {} + public void sendData(ByteBuf out) throws IOException { + } @Override public void receiveData(ByteBuf in, EntityPlayer player) throws IOException { diff --git a/src/main/java/kamkeel/npcs/network/packets/request/feather/DimensionTeleportPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/feather/DimensionTeleportPacket.java index 76215a38c..2c5c5fcdd 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/feather/DimensionTeleportPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/feather/DimensionTeleportPacket.java @@ -23,7 +23,8 @@ public final class DimensionTeleportPacket extends AbstractPacket { private int dimensionID; - public DimensionTeleportPacket() {} + public DimensionTeleportPacket() { + } public DimensionTeleportPacket(int dimensionID) { this.dimensionID = dimensionID; @@ -56,15 +57,15 @@ public final class DimensionTeleportPacket extends AbstractPacket { int dimension = in.readInt(); WorldServer world = MinecraftServer.getServer().worldServerForDimension(dimension); ChunkCoordinates coords = world.getEntrancePortalLocation(); - if(coords == null){ + if (coords == null) { coords = world.getSpawnPoint(); - if(!world.isAirBlock(coords.posX, coords.posY, coords.posZ)) + if (!world.isAirBlock(coords.posX, coords.posY, coords.posZ)) coords.posY = world.getTopSolidOrLiquidBlock(coords.posX, coords.posZ); - else{ - while(world.isAirBlock(coords.posX, coords.posY - 1, coords.posZ) && coords.posY > 0){ + else { + while (world.isAirBlock(coords.posX, coords.posY - 1, coords.posZ) && coords.posY > 0) { coords.posY--; } - if(coords.posY == 0) + if (coords.posY == 0) coords.posY = world.getTopSolidOrLiquidBlock(coords.posX, coords.posZ); } } diff --git a/src/main/java/kamkeel/npcs/network/packets/request/item/ColorBrushPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/item/ColorBrushPacket.java index 3daef0b19..6da217d7e 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/item/ColorBrushPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/item/ColorBrushPacket.java @@ -28,7 +28,8 @@ public final class ColorBrushPacket extends AbstractPacket { this.color = color; } - public ColorBrushPacket() {} + public ColorBrushPacket() { + } @Override public Enum getType() { @@ -63,9 +64,9 @@ public final class ColorBrushPacket extends AbstractPacket { setBrushColor(stack, color); } - public static void setBrushColor(ItemStack brush, int color){ + public static void setBrushColor(ItemStack brush, int color) { NBTTagCompound brushCompound = brush.getTagCompound(); - if(brushCompound == null) + if (brushCompound == null) brushCompound = new NBTTagCompound(); brushCompound.setInteger(BRUSH_COLOR_TAG, color); diff --git a/src/main/java/kamkeel/npcs/network/packets/request/item/ColorSetPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/item/ColorSetPacket.java index 0d3529137..3eef85569 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/item/ColorSetPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/item/ColorSetPacket.java @@ -35,7 +35,8 @@ public final class ColorSetPacket extends AbstractPacket { this.z = z; } - public ColorSetPacket() {} + public ColorSetPacket() { + } @Override public Enum getType() { @@ -73,16 +74,16 @@ public final class ColorSetPacket extends AbstractPacket { TileEntity tile = player.worldObj.getTileEntity(x, y, z); ItemStack stack = player.getHeldItem(); - if(tile instanceof TileColorable) { + if (tile instanceof TileColorable) { int color = getColor(stack.getTagCompound()); TileColorable colorable = (TileColorable) tile; colorable.setColor(color); } } - public static void setBrushColor(ItemStack brush, int color){ + public static void setBrushColor(ItemStack brush, int color) { NBTTagCompound brushCompound = brush.getTagCompound(); - if(brushCompound == null) + if (brushCompound == null) brushCompound = new NBTTagCompound(); brushCompound.setInteger(BRUSH_COLOR_TAG, color); diff --git a/src/main/java/kamkeel/npcs/network/packets/request/item/HammerPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/item/HammerPacket.java index 288c5ac84..8f42c100e 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/item/HammerPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/item/HammerPacket.java @@ -11,20 +11,13 @@ import kamkeel.npcs.network.enums.EnumItemPacketType; import kamkeel.npcs.network.enums.EnumRequestPacket; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import noppes.npcs.CustomNpcsPermissions; import noppes.npcs.blocks.tiles.TileBanner; import noppes.npcs.blocks.tiles.TileChair; -import noppes.npcs.blocks.tiles.TileColorable; -import noppes.npcs.blocks.tiles.TileWallBanner; import java.io.IOException; -import static noppes.npcs.items.ItemNpcTool.BRUSH_COLOR_TAG; -import static noppes.npcs.items.ItemNpcTool.getColor; - public final class HammerPacket extends AbstractPacket { public static String packetName = "Request|Hammer"; @@ -38,7 +31,8 @@ public final class HammerPacket extends AbstractPacket { this.z = z; } - public HammerPacket() {} + public HammerPacket() { + } @Override public Enum getType() { @@ -75,9 +69,9 @@ public final class HammerPacket extends AbstractPacket { int z = in.readInt(); TileEntity tile = player.worldObj.getTileEntity(x, y, z); - if(tile instanceof TileChair) { + if (tile instanceof TileChair) { ((TileChair) tile).push(); - } else if (tile instanceof TileBanner){ + } else if (tile instanceof TileBanner) { ((TileBanner) tile).changeVariant(); } } diff --git a/src/main/java/kamkeel/npcs/network/packets/request/jobs/JobGetPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/jobs/JobGetPacket.java index 4fa88fbb9..39bfdbc22 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/jobs/JobGetPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/jobs/JobGetPacket.java @@ -22,7 +22,8 @@ import java.io.IOException; public final class JobGetPacket extends AbstractPacket { public static String packetName = "Request|JobGet"; - public JobGetPacket() { } + public JobGetPacket() { + } @Override public Enum getType() { @@ -46,7 +47,8 @@ public final class JobGetPacket extends AbstractPacket { @SideOnly(Side.CLIENT) @Override - public void sendData(ByteBuf out) throws IOException { } + public void sendData(ByteBuf out) throws IOException { + } @Override public void receiveData(ByteBuf in, EntityPlayer player) throws IOException { @@ -56,16 +58,16 @@ public final class JobGetPacket extends AbstractPacket { if (!PacketUtil.verifyItemPacket(EnumItemPacketType.WAND, player)) return; - if(npc.jobInterface == null) + if (npc.jobInterface == null) return; NBTTagCompound compound = new NBTTagCompound(); compound.setBoolean("JobData", true); npc.jobInterface.writeToNBT(compound); - if(npc.advanced.job == EnumJobType.Spawner) - ((JobSpawner)npc.jobInterface).cleanCompound(compound); + if (npc.advanced.job == EnumJobType.Spawner) + ((JobSpawner) npc.jobInterface).cleanCompound(compound); GuiDataPacket.sendGuiData((EntityPlayerMP) player, compound); - if(npc.advanced.job == EnumJobType.Spawner) - GuiDataPacket.sendGuiData((EntityPlayerMP) player, ((JobSpawner)npc.jobInterface).getTitles()); + if (npc.advanced.job == EnumJobType.Spawner) + GuiDataPacket.sendGuiData((EntityPlayerMP) player, ((JobSpawner) npc.jobInterface).getTitles()); } } diff --git a/src/main/java/kamkeel/npcs/network/packets/request/jobs/JobSavePacket.java b/src/main/java/kamkeel/npcs/network/packets/request/jobs/JobSavePacket.java index 3ae0559b6..d2f68bd23 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/jobs/JobSavePacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/jobs/JobSavePacket.java @@ -21,7 +21,8 @@ public final class JobSavePacket extends AbstractPacket { private NBTTagCompound compound; - public JobSavePacket() { } + public JobSavePacket() { + } public JobSavePacket(NBTTagCompound compound) { this.compound = compound; @@ -64,14 +65,14 @@ public final class JobSavePacket extends AbstractPacket { NBTTagCompound original = npc.jobInterface.writeToNBT(new NBTTagCompound()); NBTTagCompound compound = ByteBufUtils.readNBT(in); Set names = compound.func_150296_c(); - for(String name : names) + for (String name : names) original.setTag(name, compound.getTag(name)); npc.jobInterface.readFromNBT(original); npc.updateClient = true; } - public static void saveJob(JobInterface job){ + public static void saveJob(JobInterface job) { PacketClient.sendClient(new JobSavePacket(job.writeToNBT(new NBTTagCompound()))); } } diff --git a/src/main/java/kamkeel/npcs/network/packets/request/jobs/JobSpawnerAddPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/jobs/JobSpawnerAddPacket.java index e0826b917..6bd16d215 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/jobs/JobSpawnerAddPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/jobs/JobSpawnerAddPacket.java @@ -32,7 +32,8 @@ public final class JobSpawnerAddPacket extends AbstractPacket { private NBTTagCompound compound; - public JobSpawnerAddPacket() { } + public JobSpawnerAddPacket() { + } public JobSpawnerAddPacket(boolean isServer, String selected, int activeTab, int slot) { this.isServer = isServer; @@ -71,10 +72,10 @@ public final class JobSpawnerAddPacket extends AbstractPacket { @Override public void sendData(ByteBuf out) throws IOException { out.writeBoolean(this.isServer); - if(this.isServer){ - ByteBufUtils.writeString(out, selected); - out.writeInt(this.activeTab); - out.writeInt(this.slot); + if (this.isServer) { + ByteBufUtils.writeString(out, selected); + out.writeInt(this.activeTab); + out.writeInt(this.slot); } else { out.writeInt(this.slot); ByteBufUtils.writeNBT(out, this.compound); @@ -89,12 +90,12 @@ public final class JobSpawnerAddPacket extends AbstractPacket { if (!PacketUtil.verifyItemPacket(EnumItemPacketType.WAND, player)) return; - if(npc.advanced.job != EnumJobType.Spawner) + if (npc.advanced.job != EnumJobType.Spawner) return; JobSpawner job = (JobSpawner) npc.jobInterface; boolean useServerClone = in.readBoolean(); - if(useServerClone){ + if (useServerClone) { NBTTagCompound compound = ServerCloneController.Instance.getCloneData(null, ByteBufUtils.readString(in), in.readInt()); job.setJobCompound(in.readInt(), compound); } else { diff --git a/src/main/java/kamkeel/npcs/network/packets/request/jobs/JobSpawnerRemovePacket.java b/src/main/java/kamkeel/npcs/network/packets/request/jobs/JobSpawnerRemovePacket.java index f5b415ed2..b70e85742 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/jobs/JobSpawnerRemovePacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/jobs/JobSpawnerRemovePacket.java @@ -23,7 +23,8 @@ public final class JobSpawnerRemovePacket extends AbstractPacket { private int slot; - public JobSpawnerRemovePacket(){} + public JobSpawnerRemovePacket() { + } public JobSpawnerRemovePacket(int slot) { this.slot = slot; @@ -63,7 +64,7 @@ public final class JobSpawnerRemovePacket extends AbstractPacket { if (!PacketUtil.verifyItemPacket(EnumItemPacketType.WAND, player)) return; - if(npc.advanced.job != EnumJobType.Spawner) + if (npc.advanced.job != EnumJobType.Spawner) return; JobSpawner job = (JobSpawner) npc.jobInterface; diff --git a/src/main/java/kamkeel/npcs/network/packets/request/linked/LinkedGetAllPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/linked/LinkedGetAllPacket.java index ceba1f7fd..272eefbcd 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/linked/LinkedGetAllPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/linked/LinkedGetAllPacket.java @@ -22,7 +22,9 @@ public final class LinkedGetAllPacket extends AbstractPacket { public static String packetName = "Request|LinkedGetAll"; private Action action; - public LinkedGetAllPacket() {} + + public LinkedGetAllPacket() { + } public LinkedGetAllPacket(Action action) { this.action = action; @@ -52,7 +54,7 @@ public final class LinkedGetAllPacket extends AbstractPacket { return; Action action = Action.values()[in.readInt()]; - if(action == Action.NPC){ + if (action == Action.NPC) { HashMap list = new HashMap<>(); for (LinkedNpcController.LinkedData d : LinkedNpcController.Instance.list) { list.put(d.name, 0); @@ -61,7 +63,7 @@ public final class LinkedGetAllPacket extends AbstractPacket { if (npc != null) { ScrollSelectedPacket.setSelectedList((EntityPlayerMP) player, npc.linkedName); } - } else if (action == Action.ITEM){ + } else if (action == Action.ITEM) { HashMap list = new HashMap<>(); for (LinkedItem linkedItem : LinkedItemController.getInstance().linkedItems.values()) { list.put(linkedItem.name, linkedItem.id); @@ -70,11 +72,11 @@ public final class LinkedGetAllPacket extends AbstractPacket { } } - public static void GetNPCs(){ + public static void GetNPCs() { PacketClient.sendClient(new LinkedGetAllPacket(Action.NPC)); } - public static void GetItems(){ + public static void GetItems() { PacketClient.sendClient(new LinkedGetAllPacket(Action.ITEM)); } diff --git a/src/main/java/kamkeel/npcs/network/packets/request/linked/LinkedGetPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/linked/LinkedGetPacket.java index c47b2eebc..2752fdffc 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/linked/LinkedGetPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/linked/LinkedGetPacket.java @@ -24,7 +24,8 @@ public final class LinkedGetPacket extends AbstractPacket { private int id; private String name; - public LinkedGetPacket() {} + public LinkedGetPacket() { + } public LinkedGetPacket(Action action, int id) { this.action = action; @@ -50,7 +51,7 @@ public final class LinkedGetPacket extends AbstractPacket { @Override public void sendData(ByteBuf out) throws IOException { out.writeInt(this.action.ordinal()); - if(action == Action.NPC){ + if (action == Action.NPC) { ByteBufUtils.writeString(out, this.name); } else { out.writeInt(this.id); @@ -65,7 +66,7 @@ public final class LinkedGetPacket extends AbstractPacket { return; Action action = Action.values()[in.readInt()]; - if(action == Action.NPC){ + if (action == Action.NPC) { String name = ByteBufUtils.readString(in); LinkedNpcController.LinkedData data = LinkedNpcController.Instance.getData(name); NBTTagCompound compound = data.getNBT(); diff --git a/src/main/java/kamkeel/npcs/network/packets/request/linked/LinkedItemBuildPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/linked/LinkedItemBuildPacket.java index b72ea1b0c..a0ec9dabf 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/linked/LinkedItemBuildPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/linked/LinkedItemBuildPacket.java @@ -22,9 +22,10 @@ public final class LinkedItemBuildPacket extends AbstractPacket { private int id; - public LinkedItemBuildPacket(){} + public LinkedItemBuildPacket() { + } - public LinkedItemBuildPacket(int id){ + public LinkedItemBuildPacket(int id) { this.id = id; } @@ -58,7 +59,7 @@ public final class LinkedItemBuildPacket extends AbstractPacket { int id = in.readInt(); LinkedItem linkedItem = LinkedItemController.getInstance().get(id); - if(linkedItem == null) + if (linkedItem == null) return; EntityPlayerMP playerMP = (EntityPlayerMP) player; diff --git a/src/main/java/kamkeel/npcs/network/packets/request/linked/LinkedItemRemovePacket.java b/src/main/java/kamkeel/npcs/network/packets/request/linked/LinkedItemRemovePacket.java index 1cbbe388a..fd45ff852 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/linked/LinkedItemRemovePacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/linked/LinkedItemRemovePacket.java @@ -26,7 +26,8 @@ public final class LinkedItemRemovePacket extends AbstractPacket { this.id = id; } - public LinkedItemRemovePacket() {} + public LinkedItemRemovePacket() { + } @Override public Enum getType() { diff --git a/src/main/java/kamkeel/npcs/network/packets/request/linked/LinkedItemSavePacket.java b/src/main/java/kamkeel/npcs/network/packets/request/linked/LinkedItemSavePacket.java index f68a0d813..2c76c3a1f 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/linked/LinkedItemSavePacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/linked/LinkedItemSavePacket.java @@ -26,9 +26,10 @@ public final class LinkedItemSavePacket extends AbstractPacket { private String prevName; private NBTTagCompound compound; - public LinkedItemSavePacket(){} + public LinkedItemSavePacket() { + } - public LinkedItemSavePacket(NBTTagCompound compound, String prev){ + public LinkedItemSavePacket(NBTTagCompound compound, String prev) { this.compound = compound; this.prevName = prev; } @@ -67,7 +68,7 @@ public final class LinkedItemSavePacket extends AbstractPacket { linkedItem.readFromNBT(ByteBufUtils.readNBT(in)); LinkedItemController.getInstance().saveLinkedItem(linkedItem); - if(!prevName.isEmpty() && !prevName.equals(linkedItem.name)){ + if (!prevName.isEmpty() && !prevName.equals(linkedItem.name)) { LinkedItemController.getInstance().deleteLinkedItemFile(prevName); } diff --git a/src/main/java/kamkeel/npcs/network/packets/request/linked/LinkedNPCAddPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/linked/LinkedNPCAddPacket.java index e7a81c85d..75fe6ed18 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/linked/LinkedNPCAddPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/linked/LinkedNPCAddPacket.java @@ -31,7 +31,8 @@ public final class LinkedNPCAddPacket extends AbstractPacket { this.data = data; } - public LinkedNPCAddPacket() {} + public LinkedNPCAddPacket() { + } @Override public Enum getType() { diff --git a/src/main/java/kamkeel/npcs/network/packets/request/linked/LinkedNPCRemovePacket.java b/src/main/java/kamkeel/npcs/network/packets/request/linked/LinkedNPCRemovePacket.java index bb2a99022..5c160b94f 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/linked/LinkedNPCRemovePacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/linked/LinkedNPCRemovePacket.java @@ -30,7 +30,8 @@ public final class LinkedNPCRemovePacket extends AbstractPacket { this.data = data; } - public LinkedNPCRemovePacket() {} + public LinkedNPCRemovePacket() { + } @Override public Enum getType() { diff --git a/src/main/java/kamkeel/npcs/network/packets/request/linked/LinkedSetPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/linked/LinkedSetPacket.java index ffdb49dc9..c0f8ca121 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/linked/LinkedSetPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/linked/LinkedSetPacket.java @@ -26,7 +26,8 @@ public final class LinkedSetPacket extends AbstractPacket { this.linkedName = linkedName; } - public LinkedSetPacket() {} + public LinkedSetPacket() { + } @Override public Enum getType() { diff --git a/src/main/java/kamkeel/npcs/network/packets/request/magic/MagicCycleRemovePacket.java b/src/main/java/kamkeel/npcs/network/packets/request/magic/MagicCycleRemovePacket.java index 61c3722e4..a9b157c87 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/magic/MagicCycleRemovePacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/magic/MagicCycleRemovePacket.java @@ -7,11 +7,12 @@ import kamkeel.npcs.network.AbstractPacket; import kamkeel.npcs.network.PacketChannel; import kamkeel.npcs.network.PacketHandler; import kamkeel.npcs.network.enums.EnumRequestPacket; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; import noppes.npcs.CustomNpcsPermissions; import noppes.npcs.NoppesUtilServer; import noppes.npcs.controllers.MagicController; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.EntityPlayerMP; + import java.io.IOException; public class MagicCycleRemovePacket extends AbstractPacket { @@ -20,7 +21,8 @@ public class MagicCycleRemovePacket extends AbstractPacket { private int cycleId; - public MagicCycleRemovePacket() { } + public MagicCycleRemovePacket() { + } public MagicCycleRemovePacket(int cycleId) { this.cycleId = cycleId; diff --git a/src/main/java/kamkeel/npcs/network/packets/request/magic/MagicCycleSavePacket.java b/src/main/java/kamkeel/npcs/network/packets/request/magic/MagicCycleSavePacket.java index 96becbaf3..e37f82646 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/magic/MagicCycleSavePacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/magic/MagicCycleSavePacket.java @@ -8,13 +8,14 @@ import kamkeel.npcs.network.PacketChannel; import kamkeel.npcs.network.PacketHandler; import kamkeel.npcs.network.enums.EnumRequestPacket; import kamkeel.npcs.util.ByteBufUtils; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.nbt.NBTTagCompound; import noppes.npcs.CustomNpcsPermissions; import noppes.npcs.NoppesUtilServer; import noppes.npcs.controllers.MagicController; import noppes.npcs.controllers.data.MagicCycle; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.EntityPlayerMP; -import net.minecraft.nbt.NBTTagCompound; + import java.io.IOException; public class MagicCycleSavePacket extends AbstractPacket { @@ -23,7 +24,8 @@ public class MagicCycleSavePacket extends AbstractPacket { private NBTTagCompound compound; - public MagicCycleSavePacket() { } + public MagicCycleSavePacket() { + } public MagicCycleSavePacket(NBTTagCompound compound) { this.compound = compound; diff --git a/src/main/java/kamkeel/npcs/network/packets/request/magic/MagicGetAllPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/magic/MagicGetAllPacket.java index 2c8c402d5..e20b0c078 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/magic/MagicGetAllPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/magic/MagicGetAllPacket.java @@ -7,21 +7,18 @@ import kamkeel.npcs.network.AbstractPacket; import kamkeel.npcs.network.PacketChannel; import kamkeel.npcs.network.PacketHandler; import kamkeel.npcs.network.enums.EnumRequestPacket; -import kamkeel.npcs.network.packets.data.large.GuiDataPacket; -import noppes.npcs.NoppesUtilServer; -import noppes.npcs.controllers.MagicController; -import noppes.npcs.controllers.data.Magic; -import noppes.npcs.controllers.data.MagicCycle; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; -import net.minecraft.nbt.NBTTagCompound; +import noppes.npcs.NoppesUtilServer; + import java.io.IOException; public class MagicGetAllPacket extends AbstractPacket { public static String packetName = "Request|MagicGetAll"; - public MagicGetAllPacket(){} + public MagicGetAllPacket() { + } @Override public Enum getType() { @@ -35,7 +32,8 @@ public class MagicGetAllPacket extends AbstractPacket { @SideOnly(Side.CLIENT) @Override - public void sendData(ByteBuf out) throws IOException {} + public void sendData(ByteBuf out) throws IOException { + } @Override public void receiveData(ByteBuf in, EntityPlayer player) throws IOException { diff --git a/src/main/java/kamkeel/npcs/network/packets/request/magic/MagicGetPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/magic/MagicGetPacket.java index 9c1673a1d..576aeec9a 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/magic/MagicGetPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/magic/MagicGetPacket.java @@ -7,14 +7,10 @@ import kamkeel.npcs.network.*; import kamkeel.npcs.network.enums.EnumItemPacketType; import kamkeel.npcs.network.enums.EnumRequestPacket; import kamkeel.npcs.network.packets.data.large.GuiDataPacket; -import kamkeel.npcs.util.ByteBufUtils; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.nbt.NBTTagCompound; -import noppes.npcs.controllers.LinkedItemController; -import noppes.npcs.controllers.LinkedNpcController; import noppes.npcs.controllers.MagicController; -import noppes.npcs.controllers.data.LinkedItem; import noppes.npcs.controllers.data.Magic; import noppes.npcs.controllers.data.MagicCycle; @@ -26,7 +22,8 @@ public final class MagicGetPacket extends AbstractPacket { private Action action; private int id; - public MagicGetPacket() {} + public MagicGetPacket() { + } public MagicGetPacket(Action action, int id) { this.action = action; @@ -60,7 +57,7 @@ public final class MagicGetPacket extends AbstractPacket { Action action = Action.values()[in.readInt()]; int id = in.readInt(); - if(action == Action.MAGIC){ + if (action == Action.MAGIC) { Magic magic = MagicController.getInstance().getMagic(id); NBTTagCompound compound = new NBTTagCompound(); NBTTagCompound magicCompound = new NBTTagCompound(); diff --git a/src/main/java/kamkeel/npcs/network/packets/request/magic/MagicNpcGetPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/magic/MagicNpcGetPacket.java index a0e78995d..f9b08b0e4 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/magic/MagicNpcGetPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/magic/MagicNpcGetPacket.java @@ -13,19 +13,14 @@ import kamkeel.npcs.network.packets.data.large.GuiDataPacket; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.nbt.NBTTagList; -import net.minecraft.nbt.NBTTagString; -import noppes.npcs.controllers.TagController; -import noppes.npcs.controllers.data.MagicData; -import noppes.npcs.controllers.data.Tag; import java.io.IOException; -import java.util.UUID; public final class MagicNpcGetPacket extends AbstractPacket { public static final String packetName = "Request|NpcMagicGet"; - public MagicNpcGetPacket() {} + public MagicNpcGetPacket() { + } @Override public Enum getType() { diff --git a/src/main/java/kamkeel/npcs/network/packets/request/magic/MagicNpcSavePacket.java b/src/main/java/kamkeel/npcs/network/packets/request/magic/MagicNpcSavePacket.java index 36c1e1dcb..cc1f5bcc3 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/magic/MagicNpcSavePacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/magic/MagicNpcSavePacket.java @@ -9,10 +9,8 @@ import kamkeel.npcs.network.PacketHandler; import kamkeel.npcs.network.PacketUtil; import kamkeel.npcs.network.enums.EnumItemPacketType; import kamkeel.npcs.network.enums.EnumRequestPacket; -import kamkeel.npcs.network.packets.data.large.GuiDataPacket; import kamkeel.npcs.util.ByteBufUtils; import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.nbt.NBTTagCompound; import noppes.npcs.CustomNpcsPermissions; import noppes.npcs.controllers.data.MagicData; @@ -24,7 +22,8 @@ public final class MagicNpcSavePacket extends AbstractPacket { private MagicData magicData; - public MagicNpcSavePacket() {} + public MagicNpcSavePacket() { + } public MagicNpcSavePacket(MagicData magicData) { this.magicData = magicData; @@ -54,7 +53,7 @@ public final class MagicNpcSavePacket extends AbstractPacket { @Override public void sendData(ByteBuf out) throws IOException { NBTTagCompound compound = new NBTTagCompound(); - if(magicData != null){ + if (magicData != null) { magicData.writeToNBT(compound); } ByteBufUtils.writeNBT(out, compound); diff --git a/src/main/java/kamkeel/npcs/network/packets/request/magic/MagicRemovePacket.java b/src/main/java/kamkeel/npcs/network/packets/request/magic/MagicRemovePacket.java index 16895c74c..f8e4978e0 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/magic/MagicRemovePacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/magic/MagicRemovePacket.java @@ -7,11 +7,12 @@ import kamkeel.npcs.network.AbstractPacket; import kamkeel.npcs.network.PacketChannel; import kamkeel.npcs.network.PacketHandler; import kamkeel.npcs.network.enums.EnumRequestPacket; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; import noppes.npcs.CustomNpcsPermissions; import noppes.npcs.NoppesUtilServer; import noppes.npcs.controllers.MagicController; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.EntityPlayerMP; + import java.io.IOException; public class MagicRemovePacket extends AbstractPacket { @@ -20,7 +21,8 @@ public class MagicRemovePacket extends AbstractPacket { private int magicId; - public MagicRemovePacket() { } + public MagicRemovePacket() { + } public MagicRemovePacket(int magicId) { this.magicId = magicId; diff --git a/src/main/java/kamkeel/npcs/network/packets/request/magic/MagicSavePacket.java b/src/main/java/kamkeel/npcs/network/packets/request/magic/MagicSavePacket.java index 907459664..c559891be 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/magic/MagicSavePacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/magic/MagicSavePacket.java @@ -8,13 +8,14 @@ import kamkeel.npcs.network.PacketChannel; import kamkeel.npcs.network.PacketHandler; import kamkeel.npcs.network.enums.EnumRequestPacket; import kamkeel.npcs.util.ByteBufUtils; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.nbt.NBTTagCompound; import noppes.npcs.CustomNpcsPermissions; import noppes.npcs.NoppesUtilServer; import noppes.npcs.controllers.MagicController; import noppes.npcs.controllers.data.Magic; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.EntityPlayerMP; -import net.minecraft.nbt.NBTTagCompound; + import java.io.IOException; public class MagicSavePacket extends AbstractPacket { @@ -23,7 +24,8 @@ public class MagicSavePacket extends AbstractPacket { private NBTTagCompound compound; - public MagicSavePacket() { } + public MagicSavePacket() { + } public MagicSavePacket(NBTTagCompound compound) { this.compound = compound; diff --git a/src/main/java/kamkeel/npcs/network/packets/request/mainmenu/MainmenuAIGetPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/mainmenu/MainmenuAIGetPacket.java index 875d9c762..bb5736c6d 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/mainmenu/MainmenuAIGetPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/mainmenu/MainmenuAIGetPacket.java @@ -19,7 +19,8 @@ import java.io.IOException; public final class MainmenuAIGetPacket extends AbstractPacket { public static String packetName = "Request|MainmenuAIGet"; - public MainmenuAIGetPacket() {} + public MainmenuAIGetPacket() { + } @Override public Enum getType() { @@ -38,7 +39,8 @@ public final class MainmenuAIGetPacket extends AbstractPacket { @SideOnly(Side.CLIENT) @Override - public void sendData(ByteBuf out) throws IOException {} + public void sendData(ByteBuf out) throws IOException { + } @Override public void receiveData(ByteBuf in, EntityPlayer player) throws IOException { diff --git a/src/main/java/kamkeel/npcs/network/packets/request/mainmenu/MainmenuAISavePacket.java b/src/main/java/kamkeel/npcs/network/packets/request/mainmenu/MainmenuAISavePacket.java index d08e9e056..89bdd6ea5 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/mainmenu/MainmenuAISavePacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/mainmenu/MainmenuAISavePacket.java @@ -22,7 +22,8 @@ public final class MainmenuAISavePacket extends AbstractPacket { private NBTTagCompound compound; - public MainmenuAISavePacket() {} + public MainmenuAISavePacket() { + } public MainmenuAISavePacket(NBTTagCompound compound) { this.compound = compound; diff --git a/src/main/java/kamkeel/npcs/network/packets/request/mainmenu/MainmenuAdvancedGetPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/mainmenu/MainmenuAdvancedGetPacket.java index 9665c07fe..659a26a41 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/mainmenu/MainmenuAdvancedGetPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/mainmenu/MainmenuAdvancedGetPacket.java @@ -19,7 +19,8 @@ import java.io.IOException; public final class MainmenuAdvancedGetPacket extends AbstractPacket { public static String packetName = "Request|MainmenuAdvancedGet"; - public MainmenuAdvancedGetPacket() {} + public MainmenuAdvancedGetPacket() { + } @Override public Enum getType() { @@ -38,7 +39,8 @@ public final class MainmenuAdvancedGetPacket extends AbstractPacket { @SideOnly(Side.CLIENT) @Override - public void sendData(ByteBuf out) throws IOException {} + public void sendData(ByteBuf out) throws IOException { + } @Override public void receiveData(ByteBuf in, EntityPlayer player) throws IOException { diff --git a/src/main/java/kamkeel/npcs/network/packets/request/mainmenu/MainmenuAdvancedMarkDataPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/mainmenu/MainmenuAdvancedMarkDataPacket.java index dc8048632..c1a5c8e84 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/mainmenu/MainmenuAdvancedMarkDataPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/mainmenu/MainmenuAdvancedMarkDataPacket.java @@ -23,7 +23,8 @@ public final class MainmenuAdvancedMarkDataPacket extends AbstractPacket { private NBTTagCompound compound; - public MainmenuAdvancedMarkDataPacket() {} + public MainmenuAdvancedMarkDataPacket() { + } public MainmenuAdvancedMarkDataPacket(NBTTagCompound compound) { this.compound = compound; diff --git a/src/main/java/kamkeel/npcs/network/packets/request/mainmenu/MainmenuAdvancedSavePacket.java b/src/main/java/kamkeel/npcs/network/packets/request/mainmenu/MainmenuAdvancedSavePacket.java index d979ceb03..2fb0667a9 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/mainmenu/MainmenuAdvancedSavePacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/mainmenu/MainmenuAdvancedSavePacket.java @@ -22,7 +22,8 @@ public final class MainmenuAdvancedSavePacket extends AbstractPacket { private NBTTagCompound compound; - public MainmenuAdvancedSavePacket() {} + public MainmenuAdvancedSavePacket() { + } public MainmenuAdvancedSavePacket(NBTTagCompound compound) { this.compound = compound; diff --git a/src/main/java/kamkeel/npcs/network/packets/request/mainmenu/MainmenuDisplaySavePacket.java b/src/main/java/kamkeel/npcs/network/packets/request/mainmenu/MainmenuDisplaySavePacket.java index 83c1af9b2..0cea8d821 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/mainmenu/MainmenuDisplaySavePacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/mainmenu/MainmenuDisplaySavePacket.java @@ -22,7 +22,8 @@ public final class MainmenuDisplaySavePacket extends AbstractPacket { private NBTTagCompound compound; - public MainmenuDisplaySavePacket() {} + public MainmenuDisplaySavePacket() { + } public MainmenuDisplaySavePacket(NBTTagCompound compound) { this.compound = compound; diff --git a/src/main/java/kamkeel/npcs/network/packets/request/mainmenu/MainmenuInvGetPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/mainmenu/MainmenuInvGetPacket.java index b4fbd2a3b..5e61a05e8 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/mainmenu/MainmenuInvGetPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/mainmenu/MainmenuInvGetPacket.java @@ -19,7 +19,8 @@ import java.io.IOException; public final class MainmenuInvGetPacket extends AbstractPacket { public static String packetName = "Request|MainmenuInvGet"; - public MainmenuInvGetPacket() {} + public MainmenuInvGetPacket() { + } @Override public Enum getType() { @@ -38,7 +39,8 @@ public final class MainmenuInvGetPacket extends AbstractPacket { @SideOnly(Side.CLIENT) @Override - public void sendData(ByteBuf out) throws IOException {} + public void sendData(ByteBuf out) throws IOException { + } @Override public void receiveData(ByteBuf in, EntityPlayer player) throws IOException { diff --git a/src/main/java/kamkeel/npcs/network/packets/request/mainmenu/MainmenuInvSavePacket.java b/src/main/java/kamkeel/npcs/network/packets/request/mainmenu/MainmenuInvSavePacket.java index 78933373c..ee8b43ff8 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/mainmenu/MainmenuInvSavePacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/mainmenu/MainmenuInvSavePacket.java @@ -22,7 +22,8 @@ public final class MainmenuInvSavePacket extends AbstractPacket { private NBTTagCompound compound; - public MainmenuInvSavePacket() {} + public MainmenuInvSavePacket() { + } public MainmenuInvSavePacket(NBTTagCompound compound) { this.compound = compound; diff --git a/src/main/java/kamkeel/npcs/network/packets/request/mainmenu/MainmenuStatsGetPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/mainmenu/MainmenuStatsGetPacket.java index 1c0165164..e987d6426 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/mainmenu/MainmenuStatsGetPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/mainmenu/MainmenuStatsGetPacket.java @@ -19,7 +19,8 @@ import java.io.IOException; public final class MainmenuStatsGetPacket extends AbstractPacket { public static String packetName = "Request|MainmenuStatsGet"; - public MainmenuStatsGetPacket() {} + public MainmenuStatsGetPacket() { + } @Override public Enum getType() { @@ -38,7 +39,8 @@ public final class MainmenuStatsGetPacket extends AbstractPacket { @SideOnly(Side.CLIENT) @Override - public void sendData(ByteBuf out) throws IOException {} + public void sendData(ByteBuf out) throws IOException { + } @Override public void receiveData(ByteBuf in, EntityPlayer player) throws IOException { diff --git a/src/main/java/kamkeel/npcs/network/packets/request/mainmenu/MainmenuStatsSavePacket.java b/src/main/java/kamkeel/npcs/network/packets/request/mainmenu/MainmenuStatsSavePacket.java index 3ff26f5a5..f53a221b3 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/mainmenu/MainmenuStatsSavePacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/mainmenu/MainmenuStatsSavePacket.java @@ -22,7 +22,8 @@ public final class MainmenuStatsSavePacket extends AbstractPacket { private NBTTagCompound compound; - public MainmenuStatsSavePacket() {} + public MainmenuStatsSavePacket() { + } public MainmenuStatsSavePacket(NBTTagCompound compound) { this.compound = compound; diff --git a/src/main/java/kamkeel/npcs/network/packets/request/naturalspawns/NaturalSpawnGetPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/naturalspawns/NaturalSpawnGetPacket.java index d49f6448e..7294874f6 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/naturalspawns/NaturalSpawnGetPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/naturalspawns/NaturalSpawnGetPacket.java @@ -27,7 +27,8 @@ public final class NaturalSpawnGetPacket extends AbstractPacket { this.spawnId = spawnId; } - public NaturalSpawnGetPacket() {} + public NaturalSpawnGetPacket() { + } @Override public Enum getType() { diff --git a/src/main/java/kamkeel/npcs/network/packets/request/naturalspawns/NaturalSpawnRemovePacket.java b/src/main/java/kamkeel/npcs/network/packets/request/naturalspawns/NaturalSpawnRemovePacket.java index 0590d8f10..a4e0fa878 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/naturalspawns/NaturalSpawnRemovePacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/naturalspawns/NaturalSpawnRemovePacket.java @@ -27,7 +27,8 @@ public final class NaturalSpawnRemovePacket extends AbstractPacket { this.spawnId = spawnId; } - public NaturalSpawnRemovePacket() {} + public NaturalSpawnRemovePacket() { + } @Override public Enum getType() { diff --git a/src/main/java/kamkeel/npcs/network/packets/request/naturalspawns/NaturalSpawnSavePacket.java b/src/main/java/kamkeel/npcs/network/packets/request/naturalspawns/NaturalSpawnSavePacket.java index 162acdbbe..ef465e493 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/naturalspawns/NaturalSpawnSavePacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/naturalspawns/NaturalSpawnSavePacket.java @@ -30,7 +30,8 @@ public final class NaturalSpawnSavePacket extends AbstractPacket { this.spawnNBT = spawnNBT; } - public NaturalSpawnSavePacket() {} + public NaturalSpawnSavePacket() { + } @Override public Enum getType() { diff --git a/src/main/java/kamkeel/npcs/network/packets/request/npc/ModelDataSavePacket.java b/src/main/java/kamkeel/npcs/network/packets/request/npc/ModelDataSavePacket.java index 81a426df1..382042539 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/npc/ModelDataSavePacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/npc/ModelDataSavePacket.java @@ -23,7 +23,8 @@ public final class ModelDataSavePacket extends AbstractPacket { private NBTTagCompound save; - public ModelDataSavePacket() { } + public ModelDataSavePacket() { + } public ModelDataSavePacket(NBTTagCompound save) { this.save = save; @@ -63,7 +64,7 @@ public final class ModelDataSavePacket extends AbstractPacket { if (!PacketUtil.verifyItemPacket(EnumItemPacketType.WAND, player)) return; - if(npc instanceof EntityCustomNpc) - ((EntityCustomNpc)npc).modelData.readFromNBT(ByteBufUtils.readNBT(in)); + if (npc instanceof EntityCustomNpc) + ((EntityCustomNpc) npc).modelData.readFromNBT(ByteBufUtils.readNBT(in)); } } diff --git a/src/main/java/kamkeel/npcs/network/packets/request/npc/NpcDeletePacket.java b/src/main/java/kamkeel/npcs/network/packets/request/npc/NpcDeletePacket.java index 6a4125ef2..373b75823 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/npc/NpcDeletePacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/npc/NpcDeletePacket.java @@ -21,7 +21,8 @@ import java.io.IOException; public final class NpcDeletePacket extends AbstractPacket { public static final String packetName = "Request|NPCDelete"; - public NpcDeletePacket() {} + public NpcDeletePacket() { + } @Override diff --git a/src/main/java/kamkeel/npcs/network/packets/request/npc/RemoteDeletePacket.java b/src/main/java/kamkeel/npcs/network/packets/request/npc/RemoteDeletePacket.java index 98fdaebb4..d77ae543d 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/npc/RemoteDeletePacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/npc/RemoteDeletePacket.java @@ -30,7 +30,8 @@ public final class RemoteDeletePacket extends AbstractPacket { this.entityId = entityId; } - public RemoteDeletePacket() {} + public RemoteDeletePacket() { + } @Override public Enum getType() { diff --git a/src/main/java/kamkeel/npcs/network/packets/request/npc/RemoteMainMenuPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/npc/RemoteMainMenuPacket.java index 31674ac80..5f9d1480b 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/npc/RemoteMainMenuPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/npc/RemoteMainMenuPacket.java @@ -27,7 +27,8 @@ public final class RemoteMainMenuPacket extends AbstractPacket { private int entityID; - public RemoteMainMenuPacket() {} + public RemoteMainMenuPacket() { + } public RemoteMainMenuPacket(int entityID) { this.entityID = entityID; @@ -49,7 +50,6 @@ public final class RemoteMainMenuPacket extends AbstractPacket { } - @SideOnly(Side.CLIENT) @Override public void sendData(ByteBuf out) throws IOException { @@ -64,12 +64,12 @@ public final class RemoteMainMenuPacket extends AbstractPacket { return; Entity entity = player.worldObj.getEntityByID(in.readInt()); - if(!(entity instanceof EntityNPCInterface)) + if (!(entity instanceof EntityNPCInterface)) return; NoppesUtilServer.sendOpenGui(player, EnumGuiType.MainMenuDisplay, (EntityNPCInterface) entity); - if(ConfigDebug.PlayerLogging && FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER){ - LogWriter.script(String.format("[%s] (Player) %s OPEN NPC %s (%s, %s, %s) [%s]", "WAND", player.getCommandSenderName(), ((EntityNPCInterface)entity).display.getName(), entity.posX, entity.posY, entity.posZ, entity.worldObj.getWorldInfo().getWorldName())); + if (ConfigDebug.PlayerLogging && FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER) { + LogWriter.script(String.format("[%s] (Player) %s OPEN NPC %s (%s, %s, %s) [%s]", "WAND", player.getCommandSenderName(), ((EntityNPCInterface) entity).display.getName(), entity.posX, entity.posY, entity.posZ, entity.worldObj.getWorldInfo().getWorldName())); } } } diff --git a/src/main/java/kamkeel/npcs/network/packets/request/npc/RemoteResetPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/npc/RemoteResetPacket.java index 73d34036a..15eb7945b 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/npc/RemoteResetPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/npc/RemoteResetPacket.java @@ -22,7 +22,8 @@ public final class RemoteResetPacket extends AbstractPacket { private int entityID; - public RemoteResetPacket() {} + public RemoteResetPacket() { + } public RemoteResetPacket(int entityID) { this.entityID = entityID; @@ -58,7 +59,7 @@ public final class RemoteResetPacket extends AbstractPacket { return; Entity entity = player.worldObj.getEntityByID(in.readInt()); - if(!(entity instanceof EntityNPCInterface)) + if (!(entity instanceof EntityNPCInterface)) return; npc = (EntityNPCInterface) entity; npc.reset(); diff --git a/src/main/java/kamkeel/npcs/network/packets/request/npc/RemoteTpToNpcPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/npc/RemoteTpToNpcPacket.java index 661f7d6e0..7b4ddf036 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/npc/RemoteTpToNpcPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/npc/RemoteTpToNpcPacket.java @@ -21,7 +21,9 @@ public final class RemoteTpToNpcPacket extends AbstractPacket { public static String packetName = "Request|RemoteTpToNpc"; private int entityID; - public RemoteTpToNpcPacket() {} + + public RemoteTpToNpcPacket() { + } public RemoteTpToNpcPacket(int entityID) { this.entityID = entityID; @@ -55,7 +57,7 @@ public final class RemoteTpToNpcPacket extends AbstractPacket { if (!PacketUtil.verifyItemPacket(EnumItemPacketType.WAND, player)) return; Entity entity = player.worldObj.getEntityByID(in.readInt()); - if(!(entity instanceof EntityNPCInterface)) + if (!(entity instanceof EntityNPCInterface)) return; npc = (EntityNPCInterface) entity; ((EntityPlayerMP) player).playerNetServerHandler.setPlayerLocation(npc.posX, npc.posY, npc.posZ, 0, 0); diff --git a/src/main/java/kamkeel/npcs/network/packets/request/party/PartyInfoPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/party/PartyInfoPacket.java index 02f146965..db5c4e090 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/party/PartyInfoPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/party/PartyInfoPacket.java @@ -84,7 +84,7 @@ public final class PartyInfoPacket extends AbstractPacket { list.appendTag(new NBTTagString(s)); } compound.setTag("QuestProgress", list); - if(quest.completion == EnumQuestCompletion.Npc && quest.questInterface.isPartyCompleted(party)) { + if (quest.completion == EnumQuestCompletion.Npc && quest.questInterface.isPartyCompleted(party)) { compound.setString("QuestCompleteWith", quest.completerNpc); } } diff --git a/src/main/java/kamkeel/npcs/network/packets/request/pather/MovingPathGetPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/pather/MovingPathGetPacket.java index e87b3c52b..6f5679e68 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/pather/MovingPathGetPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/pather/MovingPathGetPacket.java @@ -19,7 +19,8 @@ import java.io.IOException; public final class MovingPathGetPacket extends AbstractPacket { public static String packetName = "Request|MovingPathGet"; - public MovingPathGetPacket() {} + public MovingPathGetPacket() { + } @Override public Enum getType() { @@ -38,7 +39,8 @@ public final class MovingPathGetPacket extends AbstractPacket { @SideOnly(Side.CLIENT) @Override - public void sendData(ByteBuf out) throws IOException {} + public void sendData(ByteBuf out) throws IOException { + } @Override public void receiveData(ByteBuf in, EntityPlayer player) throws IOException { diff --git a/src/main/java/kamkeel/npcs/network/packets/request/pather/MovingPathSavePacket.java b/src/main/java/kamkeel/npcs/network/packets/request/pather/MovingPathSavePacket.java index c96564bba..258e76e37 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/pather/MovingPathSavePacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/pather/MovingPathSavePacket.java @@ -64,6 +64,6 @@ public final class MovingPathSavePacket extends AbstractPacket { if (!PacketUtil.verifyItemPacket(EnumItemPacketType.PATHER, player)) return; - npc.ais.setMovingPath(NBTTags.getIntegerArraySet(ByteBufUtils.readNBT(in).getTagList("MovingPathNew",10))); + npc.ais.setMovingPath(NBTTags.getIntegerArraySet(ByteBufUtils.readNBT(in).getTagList("MovingPathNew", 10))); } } diff --git a/src/main/java/kamkeel/npcs/network/packets/request/playerdata/PlayerDataDeleteInfoPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/playerdata/PlayerDataDeleteInfoPacket.java index 9d4433a11..39eb68fa3 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/playerdata/PlayerDataDeleteInfoPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/playerdata/PlayerDataDeleteInfoPacket.java @@ -20,7 +20,8 @@ public final class PlayerDataDeleteInfoPacket extends AbstractPacket { private EnumPlayerData tabType; private int value; - public PlayerDataDeleteInfoPacket() {} + public PlayerDataDeleteInfoPacket() { + } public PlayerDataDeleteInfoPacket(String playerName, EnumPlayerData tabType, int selectedKey) { this.playerName = playerName; diff --git a/src/main/java/kamkeel/npcs/network/packets/request/playerdata/PlayerDataGetInfoPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/playerdata/PlayerDataGetInfoPacket.java index f4037e2c7..6ace715a9 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/playerdata/PlayerDataGetInfoPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/playerdata/PlayerDataGetInfoPacket.java @@ -16,7 +16,8 @@ public final class PlayerDataGetInfoPacket extends AbstractPacket { public static final String packetName = "Request|PlayerDataGetNew"; private String playerName; - public PlayerDataGetInfoPacket() {} + public PlayerDataGetInfoPacket() { + } public PlayerDataGetInfoPacket(String playerName) { this.playerName = playerName; diff --git a/src/main/java/kamkeel/npcs/network/packets/request/playerdata/PlayerDataGetNamesPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/playerdata/PlayerDataGetNamesPacket.java index 7bc09452e..cc5431e4a 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/playerdata/PlayerDataGetNamesPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/playerdata/PlayerDataGetNamesPacket.java @@ -23,7 +23,8 @@ public final class PlayerDataGetNamesPacket extends AbstractPacket { private EnumPlayerData playerData; private String name; - public PlayerDataGetNamesPacket() {} + public PlayerDataGetNamesPacket() { + } public PlayerDataGetNamesPacket(EnumPlayerData playerData, String name) { this.playerData = playerData; @@ -44,7 +45,7 @@ public final class PlayerDataGetNamesPacket extends AbstractPacket { @Override public void sendData(ByteBuf out) throws IOException { out.writeInt(playerData.ordinal()); - if(playerData != EnumPlayerData.Players) + if (playerData != EnumPlayerData.Players) ByteBufUtils.writeString(out, this.name); } diff --git a/src/main/java/kamkeel/npcs/network/packets/request/playerdata/PlayerDataRemovePacket.java b/src/main/java/kamkeel/npcs/network/packets/request/playerdata/PlayerDataRemovePacket.java index 19ede4793..7002a7f06 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/playerdata/PlayerDataRemovePacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/playerdata/PlayerDataRemovePacket.java @@ -27,7 +27,8 @@ public final class PlayerDataRemovePacket extends AbstractPacket { private int type; private String selected; - public PlayerDataRemovePacket() {} + public PlayerDataRemovePacket() { + } public PlayerDataRemovePacket(EnumPlayerData playerData, String name, String selected) { this.playerData = playerData; @@ -59,13 +60,13 @@ public final class PlayerDataRemovePacket extends AbstractPacket { @SideOnly(Side.CLIENT) @Override public void sendData(ByteBuf out) throws IOException { - out.writeInt(playerData.ordinal()); - ByteBufUtils.writeString(out, this.name); - if(playerData == EnumPlayerData.Players){ - ByteBufUtils.writeString(out, this.selected); - } else { - out.writeInt(this.type); - } + out.writeInt(playerData.ordinal()); + ByteBufUtils.writeString(out, this.name); + if (playerData == EnumPlayerData.Players) { + ByteBufUtils.writeString(out, this.selected); + } else { + out.writeInt(this.type); + } } @Override diff --git a/src/main/java/kamkeel/npcs/network/packets/request/playerdata/PlayerDataSaveInfoPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/playerdata/PlayerDataSaveInfoPacket.java index 443012bd0..a6ff70b5d 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/playerdata/PlayerDataSaveInfoPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/playerdata/PlayerDataSaveInfoPacket.java @@ -22,7 +22,8 @@ public final class PlayerDataSaveInfoPacket extends AbstractPacket { private EnumPlayerData tabType; private NBTTagCompound value; - public PlayerDataSaveInfoPacket() {} + public PlayerDataSaveInfoPacket() { + } public PlayerDataSaveInfoPacket(String playerName, EnumPlayerData tabType, NBTTagCompound compound) { this.playerName = playerName; diff --git a/src/main/java/kamkeel/npcs/network/packets/request/quest/QuestCategoriesGetPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/quest/QuestCategoriesGetPacket.java index c276bfb1f..3448acf92 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/quest/QuestCategoriesGetPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/quest/QuestCategoriesGetPacket.java @@ -18,7 +18,8 @@ import java.io.IOException; public final class QuestCategoriesGetPacket extends AbstractPacket { public static String packetName = "Request|QuestCategoriesGet"; - public QuestCategoriesGetPacket() {} + public QuestCategoriesGetPacket() { + } @Override public Enum getType() { @@ -32,7 +33,8 @@ public final class QuestCategoriesGetPacket extends AbstractPacket { @SideOnly(Side.CLIENT) @Override - public void sendData(ByteBuf out) throws IOException {} + public void sendData(ByteBuf out) throws IOException { + } @Override public void receiveData(ByteBuf in, EntityPlayer player) throws IOException { diff --git a/src/main/java/kamkeel/npcs/network/packets/request/quest/QuestCategoryGetPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/quest/QuestCategoryGetPacket.java index 946fd8554..0404a5ab8 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/quest/QuestCategoryGetPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/quest/QuestCategoryGetPacket.java @@ -23,7 +23,8 @@ public final class QuestCategoryGetPacket extends AbstractPacket { private int categoryID; - public QuestCategoryGetPacket() {} + public QuestCategoryGetPacket() { + } public QuestCategoryGetPacket(int categoryID) { this.categoryID = categoryID; diff --git a/src/main/java/kamkeel/npcs/network/packets/request/quest/QuestCategoryRemovePacket.java b/src/main/java/kamkeel/npcs/network/packets/request/quest/QuestCategoryRemovePacket.java index 2e41d8bfe..bad9bfe95 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/quest/QuestCategoryRemovePacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/quest/QuestCategoryRemovePacket.java @@ -26,7 +26,8 @@ public final class QuestCategoryRemovePacket extends AbstractPacket { this.categoryId = categoryId; } - public QuestCategoryRemovePacket() {} + public QuestCategoryRemovePacket() { + } @Override public Enum getType() { diff --git a/src/main/java/kamkeel/npcs/network/packets/request/quest/QuestDialogGetTitlePacket.java b/src/main/java/kamkeel/npcs/network/packets/request/quest/QuestDialogGetTitlePacket.java index 251db49dd..e78955678 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/quest/QuestDialogGetTitlePacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/quest/QuestDialogGetTitlePacket.java @@ -26,7 +26,8 @@ public final class QuestDialogGetTitlePacket extends AbstractPacket { private int dialogTwo; private int dialogThree; - public QuestDialogGetTitlePacket() {} + public QuestDialogGetTitlePacket() { + } public QuestDialogGetTitlePacket(int dialogOne, int dialogTwo, int dialogThree) { this.dialogOne = dialogOne; diff --git a/src/main/java/kamkeel/npcs/network/packets/request/quest/QuestGetPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/quest/QuestGetPacket.java index bb236af33..4ccb34399 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/quest/QuestGetPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/quest/QuestGetPacket.java @@ -20,7 +20,8 @@ public final class QuestGetPacket extends AbstractPacket { private int questID; - public QuestGetPacket() {} + public QuestGetPacket() { + } public QuestGetPacket(int questID) { this.questID = questID; @@ -51,15 +52,15 @@ public final class QuestGetPacket extends AbstractPacket { return; Quest quest = QuestController.Instance.quests.get(in.readInt()); - if(quest != null){ + if (quest != null) { NBTTagCompound compound = new NBTTagCompound(); - if(quest.hasNewQuest()) + if (quest.hasNewQuest()) compound.setString("NextQuestTitle", quest.getNextQuest().title); GuiDataPacket.sendGuiData((EntityPlayerMP) player, quest.writeToNBT(compound)); } } - public static void getQuest(int id){ + public static void getQuest(int id) { PacketClient.sendClient(new QuestGetPacket(id)); } } diff --git a/src/main/java/kamkeel/npcs/network/packets/request/quest/QuestOpenGuiPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/quest/QuestOpenGuiPacket.java index 698fa75de..83d175d6d 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/quest/QuestOpenGuiPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/quest/QuestOpenGuiPacket.java @@ -31,7 +31,8 @@ public final class QuestOpenGuiPacket extends AbstractPacket { this.questNBT = questNBT; } - public QuestOpenGuiPacket() {} + public QuestOpenGuiPacket() { + } @Override public Enum getType() { diff --git a/src/main/java/kamkeel/npcs/network/packets/request/quest/QuestRemovePacket.java b/src/main/java/kamkeel/npcs/network/packets/request/quest/QuestRemovePacket.java index 199be0063..176e63364 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/quest/QuestRemovePacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/quest/QuestRemovePacket.java @@ -29,7 +29,8 @@ public final class QuestRemovePacket extends AbstractPacket { this.sendGroup = sendGroup; } - public QuestRemovePacket() {} + public QuestRemovePacket() { + } @Override public Enum getType() { @@ -62,13 +63,12 @@ public final class QuestRemovePacket extends AbstractPacket { Quest quest = QuestController.Instance.quests.get(in.readInt()); boolean sendGroup = in.readBoolean(); - if(quest != null){ + if (quest != null) { QuestController.Instance.removeQuest(quest); - if(sendGroup){ - NoppesUtilServer.sendQuestGroup((EntityPlayerMP) player,quest.category); - } - else { - NoppesUtilServer.sendQuestData((EntityPlayerMP) player,quest.category); + if (sendGroup) { + NoppesUtilServer.sendQuestGroup((EntityPlayerMP) player, quest.category); + } else { + NoppesUtilServer.sendQuestData((EntityPlayerMP) player, quest.category); } } } diff --git a/src/main/java/kamkeel/npcs/network/packets/request/quest/QuestsGetPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/quest/QuestsGetPacket.java index 500be2d03..206f7d375 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/quest/QuestsGetPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/quest/QuestsGetPacket.java @@ -23,7 +23,8 @@ public final class QuestsGetPacket extends AbstractPacket { private int categoryID; private boolean sendGroup; - public QuestsGetPacket() {} + public QuestsGetPacket() { + } public QuestsGetPacket(int categoryID, boolean send) { this.categoryID = categoryID; @@ -57,11 +58,10 @@ public final class QuestsGetPacket extends AbstractPacket { QuestCategory category = QuestController.Instance.categories.get(in.readInt()); boolean sendGroup = in.readBoolean(); - if(sendGroup){ - NoppesUtilServer.sendQuestGroup((EntityPlayerMP) player,category); - } - else { - NoppesUtilServer.sendQuestData((EntityPlayerMP) player,category); + if (sendGroup) { + NoppesUtilServer.sendQuestGroup((EntityPlayerMP) player, category); + } else { + NoppesUtilServer.sendQuestData((EntityPlayerMP) player, category); } } } diff --git a/src/main/java/kamkeel/npcs/network/packets/request/recipe/RecipeGetPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/recipe/RecipeGetPacket.java index 8f5eaf57d..31b0223d9 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/recipe/RecipeGetPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/recipe/RecipeGetPacket.java @@ -29,7 +29,8 @@ public final class RecipeGetPacket extends AbstractPacket { this.isAnvil = anvil; } - public RecipeGetPacket() {} + public RecipeGetPacket() { + } @Override public Enum getType() { @@ -57,7 +58,7 @@ public final class RecipeGetPacket extends AbstractPacket { return; int id = in.readInt(); boolean anvil = in.readBoolean(); - if(anvil){ + if (anvil) { RecipeAnvil recipe = RecipeController.Instance.getAnvilRecipe(id); NoppesUtilServer.setRecipeAnvilGui((EntityPlayerMP) player, recipe); } else { diff --git a/src/main/java/kamkeel/npcs/network/packets/request/recipe/RecipeRemovePacket.java b/src/main/java/kamkeel/npcs/network/packets/request/recipe/RecipeRemovePacket.java index 0df707054..b0bbbdf67 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/recipe/RecipeRemovePacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/recipe/RecipeRemovePacket.java @@ -30,7 +30,8 @@ public final class RecipeRemovePacket extends AbstractPacket { this.isAnvil = isAnvil; } - public RecipeRemovePacket() {} + public RecipeRemovePacket() { + } @Override public Enum getType() { @@ -62,7 +63,7 @@ public final class RecipeRemovePacket extends AbstractPacket { return; int id = in.readInt(); boolean anvil = in.readBoolean(); - if(anvil){ + if (anvil) { RecipeAnvil recipe = RecipeController.Instance.deleteAnvil(id); NoppesUtilServer.sendRecipeData((EntityPlayerMP) player, 1); NoppesUtilServer.setRecipeAnvilGui((EntityPlayerMP) player, new RecipeAnvil()); diff --git a/src/main/java/kamkeel/npcs/network/packets/request/recipe/RecipeSavePacket.java b/src/main/java/kamkeel/npcs/network/packets/request/recipe/RecipeSavePacket.java index cc6f69d87..59d4f8a57 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/recipe/RecipeSavePacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/recipe/RecipeSavePacket.java @@ -30,7 +30,8 @@ public final class RecipeSavePacket extends AbstractPacket { this.recipeNBT = recipeNBT; } - public RecipeSavePacket() {} + public RecipeSavePacket() { + } @Override public Enum getType() { @@ -61,7 +62,7 @@ public final class RecipeSavePacket extends AbstractPacket { return; NBTTagCompound compound = ByteBufUtils.readNBT(in); - if(compound.hasKey("IsAnvil")){ + if (compound.hasKey("IsAnvil")) { RecipeAnvil recipe = RecipeController.Instance.saveAnvilRecipe(compound); NoppesUtilServer.sendRecipeData((EntityPlayerMP) player, 1); NoppesUtilServer.setRecipeAnvilGui((EntityPlayerMP) player, recipe); diff --git a/src/main/java/kamkeel/npcs/network/packets/request/recipe/RecipesGetPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/recipe/RecipesGetPacket.java index c63ed66c2..cf148693d 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/recipe/RecipesGetPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/recipe/RecipesGetPacket.java @@ -24,7 +24,8 @@ public final class RecipesGetPacket extends AbstractPacket { this.categoryId = categoryId; } - public RecipesGetPacket() {} + public RecipesGetPacket() { + } @Override public Enum getType() { diff --git a/src/main/java/kamkeel/npcs/network/packets/request/role/RoleCompanionUpdatePacket.java b/src/main/java/kamkeel/npcs/network/packets/request/role/RoleCompanionUpdatePacket.java index 1b291fb0d..2b448b7de 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/role/RoleCompanionUpdatePacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/role/RoleCompanionUpdatePacket.java @@ -23,7 +23,8 @@ public final class RoleCompanionUpdatePacket extends AbstractPacket { private EnumCompanionStage companionStage; - public RoleCompanionUpdatePacket() { } + public RoleCompanionUpdatePacket() { + } public RoleCompanionUpdatePacket(EnumCompanionStage companionStage) { this.companionStage = companionStage; @@ -63,10 +64,10 @@ public final class RoleCompanionUpdatePacket extends AbstractPacket { if (!PacketUtil.verifyItemPacket(EnumItemPacketType.WAND, player)) return; - if(npc.advanced.role != EnumRoleType.Companion) + if (npc.advanced.role != EnumRoleType.Companion) return; - ((RoleCompanion)npc.roleInterface).matureTo(EnumCompanionStage.values()[in.readInt()]); + ((RoleCompanion) npc.roleInterface).matureTo(EnumCompanionStage.values()[in.readInt()]); npc.updateClient = true; } } diff --git a/src/main/java/kamkeel/npcs/network/packets/request/role/RoleGetPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/role/RoleGetPacket.java index c7bb7da2d..2bf45aa26 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/role/RoleGetPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/role/RoleGetPacket.java @@ -19,7 +19,8 @@ import java.io.IOException; public final class RoleGetPacket extends AbstractPacket { public static String packetName = "Request|RoleGet"; - public RoleGetPacket() { } + public RoleGetPacket() { + } @Override public Enum getType() { @@ -38,7 +39,8 @@ public final class RoleGetPacket extends AbstractPacket { @SideOnly(Side.CLIENT) @Override - public void sendData(ByteBuf out) throws IOException { } + public void sendData(ByteBuf out) throws IOException { + } @Override public void receiveData(ByteBuf in, EntityPlayer player) throws IOException { @@ -48,7 +50,7 @@ public final class RoleGetPacket extends AbstractPacket { if (!PacketUtil.verifyItemPacket(EnumItemPacketType.WAND, player)) return; - if(npc.roleInterface == null) + if (npc.roleInterface == null) return; NBTTagCompound compound = new NBTTagCompound(); diff --git a/src/main/java/kamkeel/npcs/network/packets/request/role/RoleSavePacket.java b/src/main/java/kamkeel/npcs/network/packets/request/role/RoleSavePacket.java index 8a7555d9b..6f0180b2c 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/role/RoleSavePacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/role/RoleSavePacket.java @@ -22,7 +22,8 @@ public final class RoleSavePacket extends AbstractPacket { private NBTTagCompound compound; - public RoleSavePacket() { } + public RoleSavePacket() { + } public RoleSavePacket(NBTTagCompound compound) { this.compound = compound; diff --git a/src/main/java/kamkeel/npcs/network/packets/request/script/BlockScriptPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/script/BlockScriptPacket.java index e354a611c..0fd7de927 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/script/BlockScriptPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/script/BlockScriptPacket.java @@ -30,7 +30,8 @@ public final class BlockScriptPacket extends AbstractPacket { private int z; private NBTTagCompound compound; - public BlockScriptPacket() {} + public BlockScriptPacket() { + } public BlockScriptPacket(Action type, int x, int y, int z, NBTTagCompound compound) { this.type = type; @@ -51,7 +52,7 @@ public final class BlockScriptPacket extends AbstractPacket { } @Override - public CustomNpcsPermissions.Permission getPermission(){ + public CustomNpcsPermissions.Permission getPermission() { return CustomNpcsPermissions.SCRIPT_BLOCK; } @@ -62,7 +63,7 @@ public final class BlockScriptPacket extends AbstractPacket { out.writeInt(x); out.writeInt(y); out.writeInt(z); - if(type == Action.SAVE){ + if (type == Action.SAVE) { ByteBufUtils.writeNBT(out, this.compound); } } @@ -76,9 +77,9 @@ public final class BlockScriptPacket extends AbstractPacket { return; Action requestedAction = Action.values()[in.readInt()]; - if(requestedAction == Action.GET){ + if (requestedAction == Action.GET) { TileEntity tile = player.worldObj.getTileEntity(in.readInt(), in.readInt(), in.readInt()); - if(!(tile instanceof TileScripted)) + if (!(tile instanceof TileScripted)) return; NBTTagCompound compound = ((TileScripted) tile).getNBT(new NBTTagCompound()); compound.setTag("Languages", ScriptController.Instance.nbtLanguages()); @@ -88,7 +89,7 @@ public final class BlockScriptPacket extends AbstractPacket { return; } TileEntity tile = player.worldObj.getTileEntity(in.readInt(), in.readInt(), in.readInt()); - if(!(tile instanceof TileScripted)) + if (!(tile instanceof TileScripted)) return; TileScripted script = (TileScripted) tile; script.setNBT(ByteBufUtils.readNBT(in)); @@ -99,6 +100,7 @@ public final class BlockScriptPacket extends AbstractPacket { public static void Save(int x, int y, int z, NBTTagCompound compound) { PacketClient.sendClient(new BlockScriptPacket(Action.SAVE, x, y, z, compound)); } + public static void Get(int x, int y, int z) { PacketClient.sendClient(new BlockScriptPacket(Action.GET, x, y, z, new NBTTagCompound())); } diff --git a/src/main/java/kamkeel/npcs/network/packets/request/script/EffectScriptPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/script/EffectScriptPacket.java index 8c1d878b7..66da65d8f 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/script/EffectScriptPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/script/EffectScriptPacket.java @@ -30,7 +30,8 @@ public final class EffectScriptPacket extends AbstractPacket { private int maxSize; private NBTTagCompound compound; - public EffectScriptPacket() {} + public EffectScriptPacket() { + } public EffectScriptPacket(Action type, int id, int page, int maxSize, NBTTagCompound compound) { this.type = type; @@ -51,7 +52,7 @@ public final class EffectScriptPacket extends AbstractPacket { } @Override - public CustomNpcsPermissions.Permission getPermission(){ + public CustomNpcsPermissions.Permission getPermission() { return CustomNpcsPermissions.SCRIPT_PLAYER; } @@ -61,7 +62,7 @@ public final class EffectScriptPacket extends AbstractPacket { out.writeInt(type.ordinal()); out.writeInt(id); - if(type == Action.SAVE){ + if (type == Action.SAVE) { out.writeInt(this.page); out.writeInt(this.maxSize); ByteBufUtils.writeNBT(out, this.compound); @@ -78,15 +79,15 @@ public final class EffectScriptPacket extends AbstractPacket { Action requestedAction = Action.values()[in.readInt()]; CustomEffect effect = CustomEffectController.getInstance().get(in.readInt()); - if(effect == null) + if (effect == null) return; EffectScript data = effect.getOrCreateScriptHandler(); - if(requestedAction == Action.GET){ + if (requestedAction == Action.GET) { PacketUtil.getScripts((IScriptHandler) data, (EntityPlayerMP) player); } else { data.saveScript(in); - if(ConfigDebug.PlayerLogging && FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER){ + if (ConfigDebug.PlayerLogging && FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER) { LogWriter.script(String.format("[%s] (Player) %s SAVED EFFECT %s [%s]", "EFFECT SCRIPTS", player.getCommandSenderName(), effect.getName())); } } @@ -95,6 +96,7 @@ public final class EffectScriptPacket extends AbstractPacket { public static void Save(int effectID, int id, int maxSize, NBTTagCompound compound) { PacketClient.sendClient(new EffectScriptPacket(Action.SAVE, effectID, id, maxSize, compound)); } + public static void Get(int effectID) { PacketClient.sendClient(new EffectScriptPacket(Action.GET, effectID, -1, -1, new NBTTagCompound())); } diff --git a/src/main/java/kamkeel/npcs/network/packets/request/script/EventScriptPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/script/EventScriptPacket.java index cac6be389..b6a9553b1 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/script/EventScriptPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/script/EventScriptPacket.java @@ -27,7 +27,8 @@ public final class EventScriptPacket extends AbstractPacket { private int maxSize; private NBTTagCompound compound; - public EventScriptPacket() {} + public EventScriptPacket() { + } public EventScriptPacket(Action type, int page, int maxSize, NBTTagCompound compound) { this.type = type; @@ -47,12 +48,12 @@ public final class EventScriptPacket extends AbstractPacket { } @Override - public boolean needsNPC(){ + public boolean needsNPC() { return true; } @Override - public CustomNpcsPermissions.Permission getPermission(){ + public CustomNpcsPermissions.Permission getPermission() { return CustomNpcsPermissions.SCRIPT_NPC; } @@ -61,7 +62,7 @@ public final class EventScriptPacket extends AbstractPacket { public void sendData(ByteBuf out) throws IOException { out.writeInt(type.ordinal()); - if(type == Action.SAVE){ + if (type == Action.SAVE) { out.writeInt(this.page); out.writeInt(this.maxSize); ByteBufUtils.writeNBT(out, this.compound); @@ -81,14 +82,14 @@ public final class EventScriptPacket extends AbstractPacket { Action requestedAction = Action.values()[in.readInt()]; DataScript data = npc.script; - if(requestedAction == Action.GET){ + if (requestedAction == Action.GET) { PacketUtil.getScripts(data, (EntityPlayerMP) player); } else { PacketUtil.saveScripts(data, in); npc.updateAI = true; npc.script.hasInited = false; - if(ConfigDebug.PlayerLogging && FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER){ - LogWriter.script(String.format("[%s] (Player) %s SAVED NPC %s (%s, %s, %s) [%s]", "SCRIPTER", player.getCommandSenderName(), npc.display.getName(), (int)npc.posX, (int)(npc).posY, (int)npc.posZ, npc.worldObj.getWorldInfo().getWorldName())); + if (ConfigDebug.PlayerLogging && FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER) { + LogWriter.script(String.format("[%s] (Player) %s SAVED NPC %s (%s, %s, %s) [%s]", "SCRIPTER", player.getCommandSenderName(), npc.display.getName(), (int) npc.posX, (int) (npc).posY, (int) npc.posZ, npc.worldObj.getWorldInfo().getWorldName())); } } } @@ -96,6 +97,7 @@ public final class EventScriptPacket extends AbstractPacket { public static void Save(int id, int maxSize, NBTTagCompound compound) { PacketClient.sendClient(new EventScriptPacket(Action.SAVE, id, maxSize, compound)); } + public static void Get() { PacketClient.sendClient(new EventScriptPacket(Action.GET, -1, -1, new NBTTagCompound())); } diff --git a/src/main/java/kamkeel/npcs/network/packets/request/script/ForgeScriptPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/script/ForgeScriptPacket.java index cb0fe7894..0083ff283 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/script/ForgeScriptPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/script/ForgeScriptPacket.java @@ -26,7 +26,8 @@ public final class ForgeScriptPacket extends AbstractPacket { private int maxSize; private NBTTagCompound compound; - public ForgeScriptPacket() {} + public ForgeScriptPacket() { + } public ForgeScriptPacket(Action type, int page, int maxSize, NBTTagCompound compound) { this.type = type; @@ -46,7 +47,7 @@ public final class ForgeScriptPacket extends AbstractPacket { } @Override - public CustomNpcsPermissions.Permission getPermission(){ + public CustomNpcsPermissions.Permission getPermission() { return CustomNpcsPermissions.SCRIPT_FORGE; } @@ -55,7 +56,7 @@ public final class ForgeScriptPacket extends AbstractPacket { public void sendData(ByteBuf out) throws IOException { out.writeInt(type.ordinal()); - if(type == Action.SAVE){ + if (type == Action.SAVE) { out.writeInt(this.page); out.writeInt(this.maxSize); ByteBufUtils.writeNBT(out, this.compound); @@ -75,13 +76,13 @@ public final class ForgeScriptPacket extends AbstractPacket { Action requestedAction = Action.values()[in.readInt()]; ForgeDataScript data = ScriptController.Instance.forgeScripts; - if(requestedAction == Action.GET){ + if (requestedAction == Action.GET) { PacketUtil.getScripts((IScriptHandler) data, (EntityPlayerMP) player); } else { int tab = in.getInt(in.readerIndex()); PacketUtil.saveScripts(data, in); ScriptController.Instance.lastForgeUpdate = System.currentTimeMillis(); - if(tab == -1) + if (tab == -1) ScriptController.Instance.saveForgeScriptsSync(); } } @@ -89,6 +90,7 @@ public final class ForgeScriptPacket extends AbstractPacket { public static void Save(int id, int maxSize, NBTTagCompound compound) { PacketClient.sendClient(new ForgeScriptPacket(Action.SAVE, id, maxSize, compound)); } + public static void Get() { PacketClient.sendClient(new ForgeScriptPacket(Action.GET, -1, -1, new NBTTagCompound())); } diff --git a/src/main/java/kamkeel/npcs/network/packets/request/script/GlobalNPCScriptPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/script/GlobalNPCScriptPacket.java index 70ecfecd4..9f9d72210 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/script/GlobalNPCScriptPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/script/GlobalNPCScriptPacket.java @@ -26,7 +26,8 @@ public final class GlobalNPCScriptPacket extends AbstractPacket { private int maxSize; private NBTTagCompound compound; - public GlobalNPCScriptPacket() {} + public GlobalNPCScriptPacket() { + } public GlobalNPCScriptPacket(Action type, int page, int maxSize, NBTTagCompound compound) { this.type = type; @@ -46,7 +47,7 @@ public final class GlobalNPCScriptPacket extends AbstractPacket { } @Override - public CustomNpcsPermissions.Permission getPermission(){ + public CustomNpcsPermissions.Permission getPermission() { return CustomNpcsPermissions.SCRIPT_GLOBAL; } @@ -55,7 +56,7 @@ public final class GlobalNPCScriptPacket extends AbstractPacket { public void sendData(ByteBuf out) throws IOException { out.writeInt(type.ordinal()); - if(type == Action.SAVE){ + if (type == Action.SAVE) { out.writeInt(this.page); out.writeInt(this.maxSize); ByteBufUtils.writeNBT(out, this.compound); @@ -75,13 +76,13 @@ public final class GlobalNPCScriptPacket extends AbstractPacket { Action requestedAction = Action.values()[in.readInt()]; GlobalNPCDataScript data = ScriptController.Instance.globalNpcScripts; - if(requestedAction == Action.GET){ + if (requestedAction == Action.GET) { PacketUtil.getScripts((IScriptHandler) data, (EntityPlayerMP) player); } else { int tab = in.getInt(in.readerIndex()); - PacketUtil.saveScripts(data,in); + PacketUtil.saveScripts(data, in); ScriptController.Instance.lastGlobalNpcUpdate = System.currentTimeMillis(); - if(tab == -1) + if (tab == -1) ScriptController.Instance.saveGlobalScriptsSync(); } } @@ -89,6 +90,7 @@ public final class GlobalNPCScriptPacket extends AbstractPacket { public static void Save(int id, int maxSize, NBTTagCompound compound) { PacketClient.sendClient(new GlobalNPCScriptPacket(Action.SAVE, id, maxSize, compound)); } + public static void Get() { PacketClient.sendClient(new GlobalNPCScriptPacket(Action.GET, -1, -1, new NBTTagCompound())); } diff --git a/src/main/java/kamkeel/npcs/network/packets/request/script/NPCScriptPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/script/NPCScriptPacket.java index 31eb1768e..2a775ea30 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/script/NPCScriptPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/script/NPCScriptPacket.java @@ -26,7 +26,8 @@ public final class NPCScriptPacket extends AbstractPacket { private NPCScriptPacket.Action type; private NBTTagCompound compound; - public NPCScriptPacket() {} + public NPCScriptPacket() { + } public NPCScriptPacket(Action type, NBTTagCompound compound) { this.type = type; @@ -44,12 +45,12 @@ public final class NPCScriptPacket extends AbstractPacket { } @Override - public CustomNpcsPermissions.Permission getPermission(){ + public CustomNpcsPermissions.Permission getPermission() { return CustomNpcsPermissions.SCRIPT_NPC; } @Override - public boolean needsNPC(){ + public boolean needsNPC() { return true; } @@ -58,7 +59,7 @@ public final class NPCScriptPacket extends AbstractPacket { public void sendData(ByteBuf out) throws IOException { out.writeInt(type.ordinal()); - if(type == Action.SAVE){ + if (type == Action.SAVE) { ByteBufUtils.writeNBT(out, this.compound); } } @@ -75,7 +76,7 @@ public final class NPCScriptPacket extends AbstractPacket { return; Action requestedAction = Action.values()[in.readInt()]; - if(requestedAction == Action.GET){ + if (requestedAction == Action.GET) { NBTTagCompound compound = npc.script.writeToNBT(new NBTTagCompound()); compound.setTag("Languages", ScriptController.Instance.nbtLanguages()); GuiDataPacket.sendGuiData((EntityPlayerMP) player, compound); @@ -83,8 +84,8 @@ public final class NPCScriptPacket extends AbstractPacket { npc.script.readFromNBT(ByteBufUtils.readNBT(in)); npc.updateAI = true; npc.script.hasInited = false; - if(ConfigDebug.PlayerLogging && FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER){ - LogWriter.script(String.format("[%s] (Player) %s SAVED NPC %s (%s, %s, %s) [%s]", "SCRIPTER", player.getCommandSenderName(), npc.display.getName(), (int)npc.posX, (int)(npc).posY, (int)npc.posZ, npc.worldObj.getWorldInfo().getWorldName())); + if (ConfigDebug.PlayerLogging && FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER) { + LogWriter.script(String.format("[%s] (Player) %s SAVED NPC %s (%s, %s, %s) [%s]", "SCRIPTER", player.getCommandSenderName(), npc.display.getName(), (int) npc.posX, (int) (npc).posY, (int) npc.posZ, npc.worldObj.getWorldInfo().getWorldName())); } } } @@ -92,6 +93,7 @@ public final class NPCScriptPacket extends AbstractPacket { public static void Save(NBTTagCompound compound) { PacketClient.sendClient(new NPCScriptPacket(Action.SAVE, compound)); } + public static void Get() { PacketClient.sendClient(new NPCScriptPacket(Action.GET, new NBTTagCompound())); } diff --git a/src/main/java/kamkeel/npcs/network/packets/request/script/PlayerScriptPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/script/PlayerScriptPacket.java index eadaab2b1..edd2768eb 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/script/PlayerScriptPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/script/PlayerScriptPacket.java @@ -26,7 +26,8 @@ public final class PlayerScriptPacket extends AbstractPacket { private int maxSize; private NBTTagCompound compound; - public PlayerScriptPacket() {} + public PlayerScriptPacket() { + } public PlayerScriptPacket(Action type, int page, int maxSize, NBTTagCompound compound) { this.type = type; @@ -46,7 +47,7 @@ public final class PlayerScriptPacket extends AbstractPacket { } @Override - public CustomNpcsPermissions.Permission getPermission(){ + public CustomNpcsPermissions.Permission getPermission() { return CustomNpcsPermissions.SCRIPT_PLAYER; } @@ -55,7 +56,7 @@ public final class PlayerScriptPacket extends AbstractPacket { public void sendData(ByteBuf out) throws IOException { out.writeInt(type.ordinal()); - if(type == Action.SAVE){ + if (type == Action.SAVE) { out.writeInt(this.page); out.writeInt(this.maxSize); ByteBufUtils.writeNBT(out, this.compound); @@ -75,13 +76,13 @@ public final class PlayerScriptPacket extends AbstractPacket { Action requestedAction = Action.values()[in.readInt()]; PlayerDataScript data = ScriptController.Instance.playerScripts; - if(requestedAction == Action.GET){ + if (requestedAction == Action.GET) { PacketUtil.getScripts((IScriptHandler) data, (EntityPlayerMP) player); } else { int tab = in.getInt(in.readerIndex()); PacketUtil.saveScripts(data, in); ScriptController.Instance.lastPlayerUpdate = System.currentTimeMillis(); - if(tab == -1) + if (tab == -1) ScriptController.Instance.savePlayerScriptsSync(); } } @@ -89,6 +90,7 @@ public final class PlayerScriptPacket extends AbstractPacket { public static void Save(int id, int maxSize, NBTTagCompound compound) { PacketClient.sendClient(new PlayerScriptPacket(Action.SAVE, id, maxSize, compound)); } + public static void Get() { PacketClient.sendClient(new PlayerScriptPacket(Action.GET, -1, -1, new NBTTagCompound())); } diff --git a/src/main/java/kamkeel/npcs/network/packets/request/script/ScriptInfoPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/script/ScriptInfoPacket.java index d97ee13b8..7a8f5fe39 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/script/ScriptInfoPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/script/ScriptInfoPacket.java @@ -22,7 +22,8 @@ public final class ScriptInfoPacket extends AbstractPacket { private ScriptInfoPacket.Action type; private NBTTagCompound compound; - public ScriptInfoPacket() {} + public ScriptInfoPacket() { + } public ScriptInfoPacket(Action type, NBTTagCompound compound) { this.type = type; @@ -40,7 +41,7 @@ public final class ScriptInfoPacket extends AbstractPacket { } @Override - public CustomNpcsPermissions.Permission getPermission(){ + public CustomNpcsPermissions.Permission getPermission() { return CustomNpcsPermissions.SCRIPT_GLOBAL; } @@ -49,7 +50,7 @@ public final class ScriptInfoPacket extends AbstractPacket { public void sendData(ByteBuf out) throws IOException { out.writeInt(type.ordinal()); - if(type == Action.SAVE){ + if (type == Action.SAVE) { ByteBufUtils.writeNBT(out, this.compound); } } @@ -66,7 +67,7 @@ public final class ScriptInfoPacket extends AbstractPacket { return; Action requestedAction = Action.values()[in.readInt()]; - if(requestedAction == Action.GET){ + if (requestedAction == Action.GET) { NBTTagCompound compound = new NBTTagCompound(); compound.setBoolean("ScriptsEnabled", ConfigScript.ScriptingEnabled); compound.setBoolean("PlayerScriptsEnabled", ConfigScript.GlobalPlayerScripts); @@ -85,6 +86,7 @@ public final class ScriptInfoPacket extends AbstractPacket { public static void Save(NBTTagCompound compound) { PacketClient.sendClient(new ScriptInfoPacket(Action.SAVE, compound)); } + public static void Get() { PacketClient.sendClient(new ScriptInfoPacket(Action.GET, new NBTTagCompound())); } diff --git a/src/main/java/kamkeel/npcs/network/packets/request/script/item/ItemScriptErrorPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/script/item/ItemScriptErrorPacket.java index 697e54f87..b4a8c619e 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/script/item/ItemScriptErrorPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/script/item/ItemScriptErrorPacket.java @@ -29,7 +29,8 @@ public final class ItemScriptErrorPacket extends AbstractPacket { private Action action; - public ItemScriptErrorPacket() {} + public ItemScriptErrorPacket() { + } public ItemScriptErrorPacket(Action action) { this.action = action; @@ -46,7 +47,7 @@ public final class ItemScriptErrorPacket extends AbstractPacket { } @Override - public CustomNpcsPermissions.Permission getPermission(){ + public CustomNpcsPermissions.Permission getPermission() { return CustomNpcsPermissions.SCRIPT_ITEM; } @@ -67,8 +68,8 @@ public final class ItemScriptErrorPacket extends AbstractPacket { Action requestedAction = Action.values()[in.readInt()]; IItemStack iw = NpcAPI.Instance().getIItemStack(player.getHeldItem()); - if(iw instanceof ScriptCustomItem){ - if(requestedAction == Action.GET){ + if (iw instanceof ScriptCustomItem) { + if (requestedAction == Action.GET) { TreeMap map = new TreeMap<>(); int tab = 0; for (ScriptContainer script : ((ScriptCustomItem) iw).scripts) { diff --git a/src/main/java/kamkeel/npcs/network/packets/request/script/item/ItemScriptPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/script/item/ItemScriptPacket.java index 67aaa5e1e..478340a63 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/script/item/ItemScriptPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/script/item/ItemScriptPacket.java @@ -27,7 +27,8 @@ public final class ItemScriptPacket extends AbstractPacket { private ItemScriptPacket.Action type; private NBTTagCompound compound; - public ItemScriptPacket() {} + public ItemScriptPacket() { + } public ItemScriptPacket(Action type, NBTTagCompound compound) { this.type = type; @@ -45,7 +46,7 @@ public final class ItemScriptPacket extends AbstractPacket { } @Override - public CustomNpcsPermissions.Permission getPermission(){ + public CustomNpcsPermissions.Permission getPermission() { return CustomNpcsPermissions.SCRIPT_ITEM; } @@ -54,7 +55,7 @@ public final class ItemScriptPacket extends AbstractPacket { public void sendData(ByteBuf out) throws IOException { out.writeInt(type.ordinal()); - if(type == Action.SAVE){ + if (type == Action.SAVE) { ByteBufUtils.writeNBT(out, this.compound); } } @@ -68,7 +69,7 @@ public final class ItemScriptPacket extends AbstractPacket { return; Action requestedAction = Action.values()[in.readInt()]; - if(requestedAction == Action.GET){ + if (requestedAction == Action.GET) { ScriptCustomItem iw = (ScriptCustomItem) NpcAPI.Instance().getIItemStack(player.getHeldItem()); iw.loadScriptData(); NBTTagCompound compound = iw.getMCNbt(); @@ -93,6 +94,7 @@ public final class ItemScriptPacket extends AbstractPacket { public static void Save(NBTTagCompound compound) { PacketClient.sendClient(new ItemScriptPacket(Action.SAVE, compound)); } + public static void Get() { PacketClient.sendClient(new ItemScriptPacket(Action.GET, new NBTTagCompound())); } diff --git a/src/main/java/kamkeel/npcs/network/packets/request/script/item/LinkedItemScriptPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/script/item/LinkedItemScriptPacket.java index 98a1927f6..8b5ec164f 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/script/item/LinkedItemScriptPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/script/item/LinkedItemScriptPacket.java @@ -30,7 +30,8 @@ public final class LinkedItemScriptPacket extends AbstractPacket { private int maxSize; private NBTTagCompound compound; - public LinkedItemScriptPacket() {} + public LinkedItemScriptPacket() { + } public LinkedItemScriptPacket(Action type, int id, int page, int maxSize, NBTTagCompound compound) { this.type = type; @@ -51,7 +52,7 @@ public final class LinkedItemScriptPacket extends AbstractPacket { } @Override - public CustomNpcsPermissions.Permission getPermission(){ + public CustomNpcsPermissions.Permission getPermission() { return CustomNpcsPermissions.SCRIPT_PLAYER; } @@ -61,7 +62,7 @@ public final class LinkedItemScriptPacket extends AbstractPacket { out.writeInt(type.ordinal()); out.writeInt(id); - if(type == Action.SAVE){ + if (type == Action.SAVE) { out.writeInt(this.page); out.writeInt(this.maxSize); ByteBufUtils.writeNBT(out, this.compound); @@ -78,15 +79,15 @@ public final class LinkedItemScriptPacket extends AbstractPacket { Action requestedAction = Action.values()[in.readInt()]; LinkedItem linkedItem = LinkedItemController.getInstance().get(in.readInt()); - if(linkedItem == null) + if (linkedItem == null) return; LinkedItemScript data = linkedItem.getOrCreateScriptHandler(); - if(requestedAction == Action.GET){ + if (requestedAction == Action.GET) { PacketUtil.getScripts((IScriptHandler) data, (EntityPlayerMP) player); } else { data.saveScript(in); - if(ConfigDebug.PlayerLogging && FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER){ + if (ConfigDebug.PlayerLogging && FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER) { LogWriter.script(String.format("[%s] (Player) %s SAVED EFFECT %s [%s]", "LINKED ITEM SCRIPTS", player.getCommandSenderName(), linkedItem.getName())); } } @@ -95,6 +96,7 @@ public final class LinkedItemScriptPacket extends AbstractPacket { public static void Save(int effectID, int id, int maxSize, NBTTagCompound compound) { PacketClient.sendClient(new LinkedItemScriptPacket(Action.SAVE, effectID, id, maxSize, compound)); } + public static void Get(int effectID) { PacketClient.sendClient(new LinkedItemScriptPacket(Action.GET, effectID, -1, -1, new NBTTagCompound())); } diff --git a/src/main/java/kamkeel/npcs/network/packets/request/tags/TagGetPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/tags/TagGetPacket.java index 29bfce39c..6438fd4b4 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/tags/TagGetPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/tags/TagGetPacket.java @@ -23,7 +23,8 @@ public final class TagGetPacket extends AbstractPacket { private int tagID; - public TagGetPacket() {} + public TagGetPacket() { + } public TagGetPacket(int tagID) { this.tagID = tagID; diff --git a/src/main/java/kamkeel/npcs/network/packets/request/tags/TagRemovePacket.java b/src/main/java/kamkeel/npcs/network/packets/request/tags/TagRemovePacket.java index 9e75492d2..8d3d90a81 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/tags/TagRemovePacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/tags/TagRemovePacket.java @@ -29,7 +29,8 @@ public final class TagRemovePacket extends AbstractPacket { this.tagId = tagId; } - public TagRemovePacket() {} + public TagRemovePacket() { + } @Override public Enum getType() { diff --git a/src/main/java/kamkeel/npcs/network/packets/request/tags/TagSetPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/tags/TagSetPacket.java index 2c49aae9c..271143276 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/tags/TagSetPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/tags/TagSetPacket.java @@ -25,7 +25,8 @@ public final class TagSetPacket extends AbstractPacket { private NBTTagCompound compound; - public TagSetPacket() {} + public TagSetPacket() { + } public TagSetPacket(NBTTagCompound compound) { this.compound = compound; diff --git a/src/main/java/kamkeel/npcs/network/packets/request/tags/TagsNpcGetPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/tags/TagsNpcGetPacket.java index 66cf66621..cba3e9de9 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/tags/TagsNpcGetPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/tags/TagsNpcGetPacket.java @@ -24,7 +24,8 @@ import java.util.UUID; public final class TagsNpcGetPacket extends AbstractPacket { public static final String packetName = "Request|NpcTagsGet"; - public TagsNpcGetPacket() {} + public TagsNpcGetPacket() { + } @Override public Enum getType() { diff --git a/src/main/java/kamkeel/npcs/network/packets/request/transform/TransformGetPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/transform/TransformGetPacket.java index 19f561c9d..0f2400af7 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/transform/TransformGetPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/transform/TransformGetPacket.java @@ -20,7 +20,8 @@ import java.io.IOException; public final class TransformGetPacket extends AbstractPacket { public static String packetName = "Request|TransformGet"; - public TransformGetPacket() { } + public TransformGetPacket() { + } @Override public Enum getType() { @@ -44,7 +45,8 @@ public final class TransformGetPacket extends AbstractPacket { @SideOnly(Side.CLIENT) @Override - public void sendData(ByteBuf out) throws IOException { } + public void sendData(ByteBuf out) throws IOException { + } @Override public void receiveData(ByteBuf in, EntityPlayer player) throws IOException { diff --git a/src/main/java/kamkeel/npcs/network/packets/request/transform/TransformLoadPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/transform/TransformLoadPacket.java index d4b82f2d9..7d7c19876 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/transform/TransformLoadPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/transform/TransformLoadPacket.java @@ -20,7 +20,8 @@ public final class TransformLoadPacket extends AbstractPacket { private boolean transform; - public TransformLoadPacket() { } + public TransformLoadPacket() { + } public TransformLoadPacket(boolean transform) { this.transform = transform; @@ -60,7 +61,7 @@ public final class TransformLoadPacket extends AbstractPacket { if (!PacketUtil.verifyItemPacket(EnumItemPacketType.WAND, player)) return; - if(npc.transform.isValid()) + if (npc.transform.isValid()) npc.transform.transform(in.readBoolean()); } } diff --git a/src/main/java/kamkeel/npcs/network/packets/request/transform/TransformSavePacket.java b/src/main/java/kamkeel/npcs/network/packets/request/transform/TransformSavePacket.java index 4872161a3..4f1e85ebd 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/transform/TransformSavePacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/transform/TransformSavePacket.java @@ -22,7 +22,8 @@ public final class TransformSavePacket extends AbstractPacket { private NBTTagCompound compound; - public TransformSavePacket() { } + public TransformSavePacket() { + } public TransformSavePacket(NBTTagCompound compound) { this.compound = compound; diff --git a/src/main/java/kamkeel/npcs/network/packets/request/transport/TransportCategoriesGetPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/transport/TransportCategoriesGetPacket.java index 44c8709ca..800befc48 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/transport/TransportCategoriesGetPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/transport/TransportCategoriesGetPacket.java @@ -18,7 +18,8 @@ import java.io.IOException; public final class TransportCategoriesGetPacket extends AbstractPacket { public static String packetName = "Request|TransportCategoriesGet"; - public TransportCategoriesGetPacket() {} + public TransportCategoriesGetPacket() { + } @Override public Enum getType() { diff --git a/src/main/java/kamkeel/npcs/network/packets/request/transport/TransportCategoryRemovePacket.java b/src/main/java/kamkeel/npcs/network/packets/request/transport/TransportCategoryRemovePacket.java index 379391328..ca85a6f51 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/transport/TransportCategoryRemovePacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/transport/TransportCategoryRemovePacket.java @@ -26,7 +26,8 @@ public final class TransportCategoryRemovePacket extends AbstractPacket { this.categoryId = categoryId; } - public TransportCategoryRemovePacket() {} + public TransportCategoryRemovePacket() { + } @Override public Enum getType() { diff --git a/src/main/java/kamkeel/npcs/network/packets/request/transport/TransportSavePacket.java b/src/main/java/kamkeel/npcs/network/packets/request/transport/TransportSavePacket.java index 119145e72..b4aad2e92 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/transport/TransportSavePacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/transport/TransportSavePacket.java @@ -32,7 +32,8 @@ public final class TransportSavePacket extends AbstractPacket { this.compound = compound; } - public TransportSavePacket() {} + public TransportSavePacket() { + } @Override public Enum getType() { @@ -71,8 +72,8 @@ public final class TransportSavePacket extends AbstractPacket { int cat = in.readInt(); TransportLocation location = TransportController.getInstance().saveLocation(cat, ByteBufUtils.readNBT(in), npc); - if(location != null){ - if(npc.advanced.role != EnumRoleType.Transporter) + if (location != null) { + if (npc.advanced.role != EnumRoleType.Transporter) return; RoleTransporter role = (RoleTransporter) npc.roleInterface; role.setTransport(location); diff --git a/src/main/java/kamkeel/npcs/network/packets/request/transport/TransportsGetPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/transport/TransportsGetPacket.java index 523bd66f0..4569b7a40 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/transport/TransportsGetPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/transport/TransportsGetPacket.java @@ -20,7 +20,8 @@ public final class TransportsGetPacket extends AbstractPacket { private int id; - public TransportsGetPacket() {} + public TransportsGetPacket() { + } public TransportsGetPacket(int id) { this.id = id; diff --git a/src/main/java/kamkeel/npcs/util/AttributeAttackUtil.java b/src/main/java/kamkeel/npcs/util/AttributeAttackUtil.java index b7c4e3f45..399d0457c 100644 --- a/src/main/java/kamkeel/npcs/util/AttributeAttackUtil.java +++ b/src/main/java/kamkeel/npcs/util/AttributeAttackUtil.java @@ -1,8 +1,8 @@ package kamkeel.npcs.util; import kamkeel.npcs.CustomAttributes; -import net.minecraft.entity.player.EntityPlayer; import kamkeel.npcs.controllers.data.attribute.tracker.PlayerAttributeTracker; +import net.minecraft.entity.player.EntityPlayer; import noppes.npcs.config.ConfigMain; import noppes.npcs.controllers.MagicController; import noppes.npcs.controllers.data.Magic; @@ -22,6 +22,7 @@ public class AttributeAttackUtil { private static class AllocationResult { public Map allocation; public float leftover; + public AllocationResult(Map allocation, float leftover) { this.allocation = allocation; this.leftover = leftover; @@ -43,7 +44,7 @@ public class AttributeAttackUtil { totalSplit += splitVal; } // Ensure double arithmetic for subtraction, then cast back to float. - float leftover = physicalDamage * (float)Math.max(0d, 1d - totalSplit); + float leftover = physicalDamage * (float) Math.max(0d, 1d - totalSplit); return new AllocationResult(allocation, leftover); } @@ -159,7 +160,7 @@ public class AttributeAttackUtil { return applyCrit(leftover + adjustedMagic, attacker); } - public static float applyCrit(float damage, PlayerAttributeTracker tracker){ + public static float applyCrit(float damage, PlayerAttributeTracker tracker) { if (ConfigMain.AttributesEnabled) { float critChance = tracker.getAttributeValue(CustomAttributes.CRITICAL_CHANCE); float critBonus = tracker.getAttributeValue(CustomAttributes.CRITICAL_DAMAGE); @@ -169,7 +170,7 @@ public class AttributeAttackUtil { return damage; } - public static float applyMainAttack(float damage, PlayerAttributeTracker tracker){ + public static float applyMainAttack(float damage, PlayerAttributeTracker tracker) { if (ConfigMain.AttributesEnabled) { float mainAttack = tracker.getAttributeValue(CustomAttributes.MAIN_ATTACK); float mainBoost = tracker.getAttributeValue(CustomAttributes.MAIN_BOOST) + 1; @@ -178,7 +179,7 @@ public class AttributeAttackUtil { return damage; } - public static float applyNeutral(float leftover, PlayerAttributeTracker tracker){ + public static float applyNeutral(float leftover, PlayerAttributeTracker tracker) { if (ConfigMain.AttributesEnabled) { float neutralDamage = tracker.getAttributeValue(CustomAttributes.NEUTRAL_ATTACK); float neutralBoost = tracker.getAttributeValue(CustomAttributes.NEUTRAL_BOOST); diff --git a/src/main/java/kamkeel/npcs/util/AttributeItemUtil.java b/src/main/java/kamkeel/npcs/util/AttributeItemUtil.java index 5ed0f6d9d..3a51ba4a0 100644 --- a/src/main/java/kamkeel/npcs/util/AttributeItemUtil.java +++ b/src/main/java/kamkeel/npcs/util/AttributeItemUtil.java @@ -2,7 +2,10 @@ package kamkeel.npcs.util; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import kamkeel.npcs.CustomAttributes; import kamkeel.npcs.controllers.AttributeController; +import kamkeel.npcs.controllers.data.attribute.AttributeDefinition; +import kamkeel.npcs.controllers.data.attribute.AttributeValueType; import kamkeel.npcs.controllers.data.attribute.requirement.IRequirementChecker; import kamkeel.npcs.controllers.data.attribute.requirement.RequirementCheckerRegistry; import net.minecraft.client.Minecraft; @@ -11,9 +14,6 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.StatCollector; -import kamkeel.npcs.controllers.data.attribute.AttributeDefinition; -import kamkeel.npcs.controllers.data.attribute.AttributeValueType; -import kamkeel.npcs.CustomAttributes; import noppes.npcs.client.ClientProxy; import noppes.npcs.controllers.MagicController; import noppes.npcs.controllers.data.Magic; @@ -25,11 +25,11 @@ import java.util.regex.Pattern; /** * Provides helper functions to write/read item attributes to/from NBT. * All data is now stored under a hierarchical structure: - * + *

* "RPGCore" - * ├─ "Attributes" - * ├─ "Magic" - * └─ "Requirements" + * ├─ "Attributes" + * ├─ "Magic" + * └─ "Requirements" */ public class AttributeItemUtil { // New hierarchical keys. @@ -380,8 +380,8 @@ public class AttributeItemUtil { } @SideOnly(Side.CLIENT) - private static String getMagicAppendix(String type){ - switch(type){ + private static String getMagicAppendix(String type) { + switch (type) { case CustomAttributes.MAGIC_DEFENSE_KEY: return StatCollector.translateToLocal("rpgcore:attribute.defense"); case CustomAttributes.MAGIC_RESISTANCE_KEY: @@ -450,6 +450,7 @@ public class AttributeItemUtil { private static class TooltipEntry { public String sortKey; public String line; + public TooltipEntry(String sortKey, String line) { this.sortKey = sortKey; this.line = line; diff --git a/src/main/java/kamkeel/npcs/util/ByteBufUtils.java b/src/main/java/kamkeel/npcs/util/ByteBufUtils.java index 86ad378d8..f3ef7d3b6 100644 --- a/src/main/java/kamkeel/npcs/util/ByteBufUtils.java +++ b/src/main/java/kamkeel/npcs/util/ByteBufUtils.java @@ -14,49 +14,46 @@ import java.util.Map; public class ByteBufUtils extends cpw.mods.fml.common.network.ByteBufUtils { - public static void fillBuffer(ByteBuf buffer, Object... obs) throws IOException{ - for(Object ob : obs){ - if(ob == null) + public static void fillBuffer(ByteBuf buffer, Object... obs) throws IOException { + for (Object ob : obs) { + if (ob == null) continue; - if(ob instanceof Map){ - Map map = (Map) ob; + if (ob instanceof Map) { + Map map = (Map) ob; buffer.writeInt(map.size()); - for(String key : map.keySet()){ + for (String key : map.keySet()) { int value = map.get(key); buffer.writeInt(value); writeString(buffer, key); } - } - else if(ob instanceof MerchantRecipeList) - ((MerchantRecipeList)ob).func_151391_a(new PacketBuffer(buffer)); - else if(ob instanceof List){ + } else if (ob instanceof MerchantRecipeList) + ((MerchantRecipeList) ob).func_151391_a(new PacketBuffer(buffer)); + else if (ob instanceof List) { List list = (List) ob; buffer.writeInt(list.size()); - for(String s : list) + for (String s : list) writeString(buffer, s); - } - else if(ob instanceof Enum) + } else if (ob instanceof Enum) buffer.writeInt(((Enum) ob).ordinal()); - else if(ob instanceof Integer) + else if (ob instanceof Integer) buffer.writeInt((Integer) ob); - else if(ob instanceof Boolean) + else if (ob instanceof Boolean) buffer.writeBoolean((Boolean) ob); - else if(ob instanceof String) + else if (ob instanceof String) writeString(buffer, (String) ob); - else if(ob instanceof Float) + else if (ob instanceof Float) buffer.writeFloat((Float) ob); - else if(ob instanceof Long) + else if (ob instanceof Long) buffer.writeLong((Long) ob); - else if(ob instanceof Double) + else if (ob instanceof Double) buffer.writeDouble((Double) ob); else if (ob instanceof byte[]) { // Write byte array length followed by bytes byte[] byteArray = (byte[]) ob; buffer.writeShort((short) byteArray.length); buffer.writeBytes(byteArray); - } - else if(ob instanceof NBTTagCompound) + } else if (ob instanceof NBTTagCompound) writeNBT(buffer, (NBTTagCompound) ob); } return; @@ -80,7 +77,7 @@ public class ByteBufUtils extends cpw.mods.fml.common.network.ByteBufUtils { public static void writeNBT(ByteBuf buffer, NBTTagCompound compound) throws IOException { byte[] bytes = CompressedStreamTools.compress(compound); - buffer.writeShort((short)bytes.length); + buffer.writeShort((short) bytes.length); buffer.writeBytes(bytes); } @@ -103,19 +100,18 @@ public class ByteBufUtils extends cpw.mods.fml.common.network.ByteBufUtils { return CompressedStreamTools.func_152457_a(bytes, new NBTSizeTracker(31457280L)); } - public static void writeString(ByteBuf buffer, String s){ + public static void writeString(ByteBuf buffer, String s) { byte[] bytes = s.getBytes(Charsets.UTF_8); - buffer.writeShort((short)bytes.length); + buffer.writeShort((short) bytes.length); buffer.writeBytes(bytes); } - public static String readString(ByteBuf buffer){ - try{ + public static String readString(ByteBuf buffer) { + try { byte[] bytes = new byte[buffer.readShort()]; buffer.readBytes(bytes); return new String(bytes, Charsets.UTF_8); - } - catch(IndexOutOfBoundsException ex){ + } catch (IndexOutOfBoundsException ex) { return null; } } diff --git a/src/main/java/kamkeel/npcs/util/ColorUtil.java b/src/main/java/kamkeel/npcs/util/ColorUtil.java index 1c72fc103..fa9defac8 100644 --- a/src/main/java/kamkeel/npcs/util/ColorUtil.java +++ b/src/main/java/kamkeel/npcs/util/ColorUtil.java @@ -10,22 +10,22 @@ public class ColorUtil { public static int[] colorTableInts = { - 0xFFFFFF , // White - 0xF2B233 , // Light Orange - 0xE680D9 , // Pinkish Purple - 0x99B2F2 , // Light Blue - 0xE6E633 , // Yellow - 0x80CC1A , // Green - 0xF2B2CC , // Light Pink - 0x4D4D4D , // Dark Gray - 0x999999 , // Gray - 0x4D99B2 , // Teal - 0xB266E6 , // Purple - 0x3366CC , // Deep Blue - 0x805D4D , // Brown - 0x668033 , // Olive Green - 0xCC4D4D , // Red - 0x1A1A1A // Black + 0xFFFFFF, // White + 0xF2B233, // Light Orange + 0xE680D9, // Pinkish Purple + 0x99B2F2, // Light Blue + 0xE6E633, // Yellow + 0x80CC1A, // Green + 0xF2B2CC, // Light Pink + 0x4D4D4D, // Dark Gray + 0x999999, // Gray + 0x4D99B2, // Teal + 0xB266E6, // Purple + 0x3366CC, // Deep Blue + 0x805D4D, // Brown + 0x668033, // Olive Green + 0xCC4D4D, // Red + 0x1A1A1A // Black }; public static float[] hexToRGB(int hex) { diff --git a/src/main/java/net/minecraft/client/gui/inventory/NPCGuiContainerHelper.java b/src/main/java/net/minecraft/client/gui/inventory/NPCGuiContainerHelper.java index 5a0a21bb2..d5d90bb9c 100644 --- a/src/main/java/net/minecraft/client/gui/inventory/NPCGuiContainerHelper.java +++ b/src/main/java/net/minecraft/client/gui/inventory/NPCGuiContainerHelper.java @@ -2,11 +2,11 @@ package net.minecraft.client.gui.inventory; public class NPCGuiContainerHelper { - public static int getLeft(GuiContainer gui) { - return gui.guiLeft; - } + public static int getLeft(GuiContainer gui) { + return gui.guiLeft; + } - public static int getTop(GuiContainer gui) { - return gui.guiTop; - } + public static int getTop(GuiContainer gui) { + return gui.guiTop; + } } diff --git a/src/main/java/net/minecraft/client/renderer/entity/NPCRendererHelper.java b/src/main/java/net/minecraft/client/renderer/entity/NPCRendererHelper.java index 5782c1cda..b3f19b181 100644 --- a/src/main/java/net/minecraft/client/renderer/entity/NPCRendererHelper.java +++ b/src/main/java/net/minecraft/client/renderer/entity/NPCRendererHelper.java @@ -7,35 +7,35 @@ import net.minecraft.util.ResourceLocation; public class NPCRendererHelper { - public static ModelBase getMainModel(RendererLivingEntity render){ - return render.mainModel; - } - - public static String getTexture(RendererLivingEntity render, Entity entity){ - ResourceLocation location = render.getEntityTexture(entity); - return location.toString(); - } + public static ModelBase getMainModel(RendererLivingEntity render) { + return render.mainModel; + } - public static int shouldRenderPass(EntityLivingBase entity, int par2, float par3, RendererLivingEntity renderEntity) { - return renderEntity.shouldRenderPass(entity, par2, par3); - } + public static String getTexture(RendererLivingEntity render, Entity entity) { + ResourceLocation location = render.getEntityTexture(entity); + return location.toString(); + } - public static void preRenderCallback(EntityLivingBase entity, float f, - RendererLivingEntity renderEntity) { - renderEntity.preRenderCallback(entity, f); - } + public static int shouldRenderPass(EntityLivingBase entity, int par2, float par3, RendererLivingEntity renderEntity) { + return renderEntity.shouldRenderPass(entity, par2, par3); + } - public static ModelBase getPassModel(RendererLivingEntity render) { - return render.renderPassModel; - } + public static void preRenderCallback(EntityLivingBase entity, float f, + RendererLivingEntity renderEntity) { + renderEntity.preRenderCallback(entity, f); + } - public static float handleRotationFloat(EntityLivingBase entity, - float par2, RendererLivingEntity renderEntity) { - return renderEntity.handleRotationFloat(entity, par2); - } + public static ModelBase getPassModel(RendererLivingEntity render) { + return render.renderPassModel; + } - public static void renderEquippedItems(EntityLivingBase entity, float f, - RendererLivingEntity renderEntity) { - renderEntity.renderEquippedItems(entity, f); - } + public static float handleRotationFloat(EntityLivingBase entity, + float par2, RendererLivingEntity renderEntity) { + return renderEntity.handleRotationFloat(entity, par2); + } + + public static void renderEquippedItems(EntityLivingBase entity, float f, + RendererLivingEntity renderEntity) { + renderEntity.renderEquippedItems(entity, f); + } } diff --git a/src/main/java/net/minecraft/client/resources/NPCResourceHelper.java b/src/main/java/net/minecraft/client/resources/NPCResourceHelper.java index d8160ba16..e746379ac 100644 --- a/src/main/java/net/minecraft/client/resources/NPCResourceHelper.java +++ b/src/main/java/net/minecraft/client/resources/NPCResourceHelper.java @@ -4,7 +4,7 @@ import java.io.File; public class NPCResourceHelper { - public static File getPackFile(AbstractResourcePack pack){ - return pack.resourcePackFile; - } + public static File getPackFile(AbstractResourcePack pack) { + return pack.resourcePackFile; + } } diff --git a/src/main/java/net/minecraft/entity/NPCEntityHelper.java b/src/main/java/net/minecraft/entity/NPCEntityHelper.java index 3db54db22..6d42d1f0c 100644 --- a/src/main/java/net/minecraft/entity/NPCEntityHelper.java +++ b/src/main/java/net/minecraft/entity/NPCEntityHelper.java @@ -4,12 +4,12 @@ import net.minecraft.item.Item; public class NPCEntityHelper { - public static Item getDropItem(EntityLiving entity){ - return entity.getDropItem(); - } + public static Item getDropItem(EntityLiving entity) { + return entity.getDropItem(); + } + + public static void setRecentlyHit(EntityLivingBase entity) { + entity.recentlyHit = 100; + } - public static void setRecentlyHit(EntityLivingBase entity){ - entity.recentlyHit = 100; - } - } diff --git a/src/main/java/nikedemos/markovnames/HashMap2D.java b/src/main/java/nikedemos/markovnames/HashMap2D.java index 5b0ec2000..c3184ac4b 100644 --- a/src/main/java/nikedemos/markovnames/HashMap2D.java +++ b/src/main/java/nikedemos/markovnames/HashMap2D.java @@ -5,77 +5,70 @@ import java.util.Map; public class HashMap2D { -public final Map> mMap; + public final Map> mMap; /* https://stackoverflow.com/a/10299689/9355344 */ -public HashMap2D() { - mMap = new HashMap>(); -} - -/** - * Associates the specified value with the specified keys in this map (optional operation). If the map previously - * contained a mapping for the key, the old value is replaced by the specified value. - * - * @param key1 - * the first key - * @param key2 - * the second key - * @param value - * the value to be set - * @return the value previously associated with (key1,key2), or null if none - * @see Map#put(Object, Object) - */ -public T3 put(T1 key1, T2 key2, T3 value) { - Map map; - if (mMap.containsKey(key1)) { - map = mMap.get(key1); - } else { - map = new HashMap(); - mMap.put(key1, map); + public HashMap2D() { + mMap = new HashMap>(); } - return map.put(key2, value); -} + /** + * Associates the specified value with the specified keys in this map (optional operation). If the map previously + * contained a mapping for the key, the old value is replaced by the specified value. + * + * @param key1 the first key + * @param key2 the second key + * @param value the value to be set + * @return the value previously associated with (key1,key2), or null if none + * @see Map#put(Object, Object) + */ + public T3 put(T1 key1, T2 key2, T3 value) { + Map map; + if (mMap.containsKey(key1)) { + map = mMap.get(key1); + } else { + map = new HashMap(); + mMap.put(key1, map); + } -/** - * Returns the value to which the specified key is mapped, or null if this map contains no mapping for - * the key. - * - * @param key1 - * the first key whose associated value is to be returned - * @param key2 - * the second key whose associated value is to be returned - * @return the value to which the specified key is mapped, or null if this map contains no mapping for - * the key - * @see Map#get(Object) - */ -public T3 get(T1 key1, T2 key2) { - if (mMap.containsKey(key1)) { - return mMap.get(key1).get(key2); - } else { - return null; + return map.put(key2, value); } -} -/** - * Returns true if this map contains a mapping for the specified key - * - * @param key1 - * the first key whose presence in this map is to be tested - * @param key2 - * the second key whose presence in this map is to be tested - * @return Returns true if this map contains a mapping for the specified key - * @see Map#containsKey(Object) - */ -public boolean containsKeys(T1 key1, T2 key2) { - return mMap.containsKey(key1) && mMap.get(key1).containsKey(key2); -} + /** + * Returns the value to which the specified key is mapped, or null if this map contains no mapping for + * the key. + * + * @param key1 the first key whose associated value is to be returned + * @param key2 the second key whose associated value is to be returned + * @return the value to which the specified key is mapped, or null if this map contains no mapping for + * the key + * @see Map#get(Object) + */ + public T3 get(T1 key1, T2 key2) { + if (mMap.containsKey(key1)) { + return mMap.get(key1).get(key2); + } else { + return null; + } + } -public void clear() { - mMap.clear(); -} + /** + * Returns true if this map contains a mapping for the specified key + * + * @param key1 the first key whose presence in this map is to be tested + * @param key2 the second key whose presence in this map is to be tested + * @return Returns true if this map contains a mapping for the specified key + * @see Map#containsKey(Object) + */ + public boolean containsKeys(T1 key1, T2 key2) { + return mMap.containsKey(key1) && mMap.get(key1).containsKey(key2); + } -} \ No newline at end of file + public void clear() { + mMap.clear(); + } + +} diff --git a/src/main/java/nikedemos/markovnames/Main.java b/src/main/java/nikedemos/markovnames/Main.java index ab9213842..8fa76ec7b 100644 --- a/src/main/java/nikedemos/markovnames/Main.java +++ b/src/main/java/nikedemos/markovnames/Main.java @@ -7,47 +7,46 @@ import java.util.Iterator; import java.util.Map.Entry; public class Main { - - public static final int GENDER_RANDOM=0; - public static final int GENDER_MALE=1; - public static final int GENDER_FEMALE=2; - - public static HashMap GENERATORS = new HashMap(); - - public static void main(String[] args){ - - //all the generators neatly in one HashMap, so you can iterate or w/e - - GENERATORS.put("ROMAN", new MarkovRoman(3)); - GENERATORS.put("JAPANESE", new MarkovJapanese(4)); - GENERATORS.put("SLAVIC", new MarkovSlavic(3)); - GENERATORS.put("WELSH", new MarkovWelsh(3)); - GENERATORS.put("SAAMI", new MarkovSaami(3)); - GENERATORS.put("OLDNORSE", new MarkovOldNorse(4)); - GENERATORS.put("ANCIENTGREEK", new MarkovAncientGreek(3)); - GENERATORS.put("AZTEC", new MarkovAztec(3)); - - //iterate through generators, generate 5 male and 5 female names, move on to the next - Iterator> g = GENERATORS.entrySet().iterator(); - - while (g.hasNext()) { - Entry pair = (Entry) g.next(); - - System.out.println("==="+pair.getKey()+"==="); - - for (int i=0; i<16; i++) - { - if (i==0) - System.out.println("GENTLEMEN-----------"); - int gender = i<8 ? 1 : 2; - String random_name = pair.getValue().fetch(gender); - System.out.println(random_name); - - if (i==15) //extra padding - System.out.println("\n"); - else if (i==7) //separate genders - System.out.println("LADIES--------------"); - } - } - } + + public static final int GENDER_RANDOM = 0; + public static final int GENDER_MALE = 1; + public static final int GENDER_FEMALE = 2; + + public static HashMap GENERATORS = new HashMap(); + + public static void main(String[] args) { + + //all the generators neatly in one HashMap, so you can iterate or w/e + + GENERATORS.put("ROMAN", new MarkovRoman(3)); + GENERATORS.put("JAPANESE", new MarkovJapanese(4)); + GENERATORS.put("SLAVIC", new MarkovSlavic(3)); + GENERATORS.put("WELSH", new MarkovWelsh(3)); + GENERATORS.put("SAAMI", new MarkovSaami(3)); + GENERATORS.put("OLDNORSE", new MarkovOldNorse(4)); + GENERATORS.put("ANCIENTGREEK", new MarkovAncientGreek(3)); + GENERATORS.put("AZTEC", new MarkovAztec(3)); + + //iterate through generators, generate 5 male and 5 female names, move on to the next + Iterator> g = GENERATORS.entrySet().iterator(); + + while (g.hasNext()) { + Entry pair = (Entry) g.next(); + + System.out.println("===" + pair.getKey() + "==="); + + for (int i = 0; i < 16; i++) { + if (i == 0) + System.out.println("GENTLEMEN-----------"); + int gender = i < 8 ? 1 : 2; + String random_name = pair.getValue().fetch(gender); + System.out.println(random_name); + + if (i == 15) //extra padding + System.out.println("\n"); + else if (i == 7) //separate genders + System.out.println("LADIES--------------"); + } + } + } } diff --git a/src/main/java/nikedemos/markovnames/MarkovDictionary.java b/src/main/java/nikedemos/markovnames/MarkovDictionary.java index e3e44e231..efe3f2a56 100644 --- a/src/main/java/nikedemos/markovnames/MarkovDictionary.java +++ b/src/main/java/nikedemos/markovnames/MarkovDictionary.java @@ -17,254 +17,253 @@ import java.util.Map.Entry; import java.util.Random; public class MarkovDictionary { - private Random rng; - private int sequenceLen = 3; + private Random rng; + private int sequenceLen = 3; - private HashMap2D occurrences = new HashMap2D(); + private HashMap2D occurrences = new HashMap2D(); - public MarkovDictionary(String dictionary, int seqlen, Random rng) { - this.rng = rng; + public MarkovDictionary(String dictionary, int seqlen, Random rng) { + this.rng = rng; - try { - applyDictionary(dictionary, seqlen); - } catch (Exception e) { - e.printStackTrace(); - } - } + try { + applyDictionary(dictionary, seqlen); + } catch (Exception e) { + e.printStackTrace(); + } + } - public MarkovDictionary(String dictionary, int seqlen) { - this(dictionary, seqlen, new Random()); - } + public MarkovDictionary(String dictionary, int seqlen) { + this(dictionary, seqlen, new Random()); + } - public MarkovDictionary(String dictionary) { - this(dictionary, 3, new Random()); // 3 is the default, anyway - } + public MarkovDictionary(String dictionary) { + this(dictionary, 3, new Random()); // 3 is the default, anyway + } - public MarkovDictionary(String dictionary, Random rng) { - this(dictionary, 3, rng); // 3 is the default, anyway - } + public MarkovDictionary(String dictionary, Random rng) { + this(dictionary, 3, rng); // 3 is the default, anyway + } - // Blatantly copied from EnderIO: - // https://github.com/SleepyTrousers/EnderIO/blob/master/enderio-base/src/main/java/crazypants/enderio/base/config/recipes/RecipeFactory.java#L44-L57 - // Thanks again for your help, Henry Loenwind! + // Blatantly copied from EnderIO: + // https://github.com/SleepyTrousers/EnderIO/blob/master/enderio-base/src/main/java/crazypants/enderio/base/config/recipes/RecipeFactory.java#L44-L57 + // Thanks again for your help, Henry Loenwind! - private InputStream getResource(ResourceLocation resourceLocation) { - final ModContainer container = Loader.instance().activeModContainer(); - if (container != null) { - final String resourcePath = String.format("/%s/%s/%s", "assets", resourceLocation.getResourceDomain(), - resourceLocation.getResourcePath()); - InputStream resourceAsStream = null; + private InputStream getResource(ResourceLocation resourceLocation) { + final ModContainer container = Loader.instance().activeModContainer(); + if (container != null) { + final String resourcePath = String.format("/%s/%s/%s", "assets", resourceLocation.getResourceDomain(), + resourceLocation.getResourcePath()); + InputStream resourceAsStream = null; - try { - resourceAsStream = container.getMod().getClass().getResourceAsStream(resourcePath); - } catch (Exception e) { - e.printStackTrace(); - } + try { + resourceAsStream = container.getMod().getClass().getResourceAsStream(resourcePath); + } catch (Exception e) { + e.printStackTrace(); + } - if (resourceAsStream != null) { - return resourceAsStream; - } else { - throw new RuntimeException("Could not find resource " + resourceLocation); - } - } else { - throw new RuntimeException("Failed to find current mod while looking for resource " + resourceLocation); - } - } + if (resourceAsStream != null) { + return resourceAsStream; + } else { + throw new RuntimeException("Could not find resource " + resourceLocation); + } + } else { + throw new RuntimeException("Failed to find current mod while looking for resource " + resourceLocation); + } + } - public String getCapitalized(String str) { - if (str == null || str.isEmpty()) - return str; - char[] chars = str.toCharArray(); - chars[0] = Character.toUpperCase(chars[0]); - return new String(chars); - } + public String getCapitalized(String str) { + if (str == null || str.isEmpty()) + return str; + char[] chars = str.toCharArray(); + chars[0] = Character.toUpperCase(chars[0]); + return new String(chars); + } - public static String readFile(String path) throws IOException { - byte[] encoded = Files.readAllBytes(Paths.get(path)); - return new String(encoded, StandardCharsets.UTF_8); - } + public static String readFile(String path) throws IOException { + byte[] encoded = Files.readAllBytes(Paths.get(path)); + return new String(encoded, StandardCharsets.UTF_8); + } - public void incrementSafe(String str1, String str2) { - // so for instance, "_DUP_AUX", "_TOTAL" will count how many "DUP" seqCurrs we have - if (occurrences.containsKeys(str1, str2)) - { - int curr = occurrences.get(str1, str2).intValue(); - occurrences.put(str1, str2, Integer.valueOf(curr + 1)); - } else { - occurrences.put(str1, str2, Integer.valueOf(1)); - } - } + public void incrementSafe(String str1, String str2) { + // so for instance, "_DUP_AUX", "_TOTAL" will count how many "DUP" seqCurrs we have + if (occurrences.containsKeys(str1, str2)) { + int curr = occurrences.get(str1, str2).intValue(); + occurrences.put(str1, str2, Integer.valueOf(curr + 1)); + } else { + occurrences.put(str1, str2, Integer.valueOf(1)); + } + } - public String generateWord() { + public String generateWord() { - // let's pick the first element, from which further picking shall proceed. - // first, we need to know how many top-level sequences (sequenceLen length) - // strings - // we have. So just take into account those surrounded by "_" - and count them. - // From that we'll get the weights. + // let's pick the first element, from which further picking shall proceed. + // first, we need to know how many top-level sequences (sequenceLen length) + // strings + // we have. So just take into account those surrounded by "_" - and count them. + // From that we'll get the weights. - int allEntries = 0; + int allEntries = 0; - // first iteration: we count top level entries. There's just no other way. - Iterator>> i = occurrences.mMap.entrySet().iterator(); + // first iteration: we count top level entries. There's just no other way. + Iterator>> i = occurrences.mMap.entrySet().iterator(); - while (i.hasNext()) { - Entry> pair = (Entry>) i.next(); + while (i.hasNext()) { + Entry> pair = (Entry>) i.next(); - String k = pair.getKey(); - if (k.startsWith("_[") && k.endsWith("_")) // dealing with meta entry here - { - allEntries += occurrences.get(k, "_TOTAL_"); - } - } - if(allEntries == 0) { - return "Kamkeel"; //shouldnt happen - } - int topLevelEntries; - int randomNumber = rng.nextInt(allEntries); + String k = pair.getKey(); + if (k.startsWith("_[") && k.endsWith("_")) // dealing with meta entry here + { + allEntries += occurrences.get(k, "_TOTAL_"); + } + } + if (allEntries == 0) { + return "Kamkeel"; //shouldnt happen + } + int topLevelEntries; + int randomNumber = rng.nextInt(allEntries); - // ok, so how does this weighted random work? - // easy. Check if the randomNumber is LESS than - // topLevelEntries variable for that entry (see below). - // If it is, break the while loop - we got our first element, - // from which we will go further. Just remember to - // remove the underscores at both ends! + // ok, so how does this weighted random work? + // easy. Check if the randomNumber is LESS than + // topLevelEntries variable for that entry (see below). + // If it is, break the while loop - we got our first element, + // from which we will go further. Just remember to + // remove the underscores at both ends! - Iterator>> it = occurrences.mMap.entrySet().iterator(); + Iterator>> it = occurrences.mMap.entrySet().iterator(); - StringBuilder sequence = new StringBuilder(""); + StringBuilder sequence = new StringBuilder(""); - while (it.hasNext()) { - Entry> pair = (Entry>) it.next(); + while (it.hasNext()) { + Entry> pair = (Entry>) it.next(); - String k = pair.getKey(); + String k = pair.getKey(); - if (k.startsWith("_[") && k.endsWith("_")) // dealing with meta entry here - { - topLevelEntries = occurrences.get(k, "_TOTAL_"); + if (k.startsWith("_[") && k.endsWith("_")) // dealing with meta entry here + { + topLevelEntries = occurrences.get(k, "_TOTAL_"); - if (randomNumber < topLevelEntries) { - sequence.append(k.substring(1, sequenceLen + 1)); // removing the underscores - break; - } else { - // keep going - randomNumber -= topLevelEntries; - } - } - } - // great! now that we have the first element, time for some generic iterations. - // in a very similar manner. Basically - perform this loop till you encounter - // "]" at the end - StringBuilder word = new StringBuilder(""); + if (randomNumber < topLevelEntries) { + sequence.append(k.substring(1, sequenceLen + 1)); // removing the underscores + break; + } else { + // keep going + randomNumber -= topLevelEntries; + } + } + } + // great! now that we have the first element, time for some generic iterations. + // in a very similar manner. Basically - perform this loop till you encounter + // "]" at the end + StringBuilder word = new StringBuilder(""); - word.append(sequence); // now we're gonna use firstElement to keep the sequence - while (sequence.charAt(sequence.length() - 1) != ']') { - // sequence is now your HashMap key for the 1st dimension. - // for that sequence: - // - get total elements that are not meta (not surrounded by underscores) - // and count their total occurrences - int subSize = 0; + word.append(sequence); // now we're gonna use firstElement to keep the sequence + while (sequence.charAt(sequence.length() - 1) != ']') { + // sequence is now your HashMap key for the 1st dimension. + // for that sequence: + // - get total elements that are not meta (not surrounded by underscores) + // and count their total occurrences + int subSize = 0; - Iterator> j = occurrences.mMap.get(sequence.toString()).entrySet().iterator(); + Iterator> j = occurrences.mMap.get(sequence.toString()).entrySet().iterator(); - while (j.hasNext()) { - Entry entry = j.next(); - subSize += entry.getValue(); - } + while (j.hasNext()) { + Entry entry = j.next(); + subSize += entry.getValue(); + } - // and now, the last iterator, with a random, just like before - randomNumber = rng.nextInt(subSize); + // and now, the last iterator, with a random, just like before + randomNumber = rng.nextInt(subSize); - Iterator> k = occurrences.mMap.get(sequence.toString()).entrySet().iterator(); + Iterator> k = occurrences.mMap.get(sequence.toString()).entrySet().iterator(); - String chosen = ""; + String chosen = ""; - while (k.hasNext()) { - Entry entry = k.next(); - int occu = occurrences.get(sequence.toString(), entry.getKey()); + while (k.hasNext()) { + Entry entry = k.next(); + int occu = occurrences.get(sequence.toString(), entry.getKey()); - if (randomNumber < occu) { - chosen = entry.getKey(); - break; - } else { // keep going! - randomNumber -= occu; - } - } - // now, append the word... - word.append(chosen); + if (randomNumber < occu) { + chosen = entry.getKey(); + break; + } else { // keep going! + randomNumber -= occu; + } + } + // now, append the word... + word.append(chosen); - // delete the first character of the sequence, - // and also append it with chosen character. - // So if the Sequence is ABC, and chosen is D, - // it now becomes BCD. - sequence.delete(0, 1); - sequence.append(chosen); - // System.out.println("FINAL: "+sequence); - // System.out.println("CHOSEN: "+chosen); + // delete the first character of the sequence, + // and also append it with chosen character. + // So if the Sequence is ABC, and chosen is D, + // it now becomes BCD. + sequence.delete(0, 1); + sequence.append(chosen); + // System.out.println("FINAL: "+sequence); + // System.out.println("CHOSEN: "+chosen); - } - // and now remove the square brackets surrounding it. - return this.getPost(word.substring(1, word.length() - 1)); - } + } + // and now remove the square brackets surrounding it. + return this.getPost(word.substring(1, word.length() - 1)); + } - public String getPost(String str) { - return getCapitalized(str); - } + public String getPost(String str) { + return getCapitalized(str); + } - public void applyDictionary(String dictionaryFile, int seqLen) throws IOException { - StringBuilder input = new StringBuilder(); + public void applyDictionary(String dictionaryFile, int seqLen) throws IOException { + StringBuilder input = new StringBuilder(); - ResourceLocation resource = new ResourceLocation("customnpcs:markovnames/" + dictionaryFile); + ResourceLocation resource = new ResourceLocation("customnpcs:markovnames/" + dictionaryFile); - BufferedReader readIn = new BufferedReader(new InputStreamReader(getResource(resource), "UTF-8")); - // Thread.currentThread().getContextClassLoader().getResourceAsStream("path/to/resource/file.ext"); + BufferedReader readIn = new BufferedReader(new InputStreamReader(getResource(resource), "UTF-8")); + // Thread.currentThread().getContextClassLoader().getResourceAsStream("path/to/resource/file.ext"); - for (String line = readIn.readLine(); line != null; line = readIn.readLine()) { - input.append(line).append(" "); - } + for (String line = readIn.readLine(); line != null; line = readIn.readLine()) { + input.append(line).append(" "); + } - readIn.close(); + readIn.close(); - if (input.length() == 0) { - throw new RuntimeException("Resource was empty: + " + resource); - } - // if seqLen != this.sequenceLen, we must clear occurrences + if (input.length() == 0) { + throw new RuntimeException("Resource was empty: + " + resource); + } + // if seqLen != this.sequenceLen, we must clear occurrences - if (this.sequenceLen != seqLen) { - sequenceLen = seqLen; - this.occurrences.clear(); - } + if (this.sequenceLen != seqLen) { + sequenceLen = seqLen; + this.occurrences.clear(); + } - String input_str = '[' + input.toString().toLowerCase().replaceAll("[\\t\\n\\r\\s]+", "][") + ']'; + String input_str = '[' + input.toString().toLowerCase().replaceAll("[\\t\\n\\r\\s]+", "][") + ']'; - int maxCursorPos = input_str.length() - 1 - sequenceLen; + int maxCursorPos = input_str.length() - 1 - sequenceLen; - for (int i = 0; i <= maxCursorPos; i++) { - String seqCurr = input_str.substring(i, i + (sequenceLen)); // i plus 2 characters next to it - String seqNext = input_str.substring(i + sequenceLen, i + sequenceLen + 1); // next character after that - incrementSafe(seqCurr, seqNext); - // aux counters + for (int i = 0; i <= maxCursorPos; i++) { + String seqCurr = input_str.substring(i, i + (sequenceLen)); // i plus 2 characters next to it + String seqNext = input_str.substring(i + sequenceLen, i + sequenceLen + 1); // next character after that + incrementSafe(seqCurr, seqNext); + // aux counters - StringBuilder meta = new StringBuilder("_").append(seqCurr).append("_"); + StringBuilder meta = new StringBuilder("_").append(seqCurr).append("_"); - // String aux1="_"+seqCurr+"_"; - incrementSafe(meta.toString(), "_TOTAL_"); - // String aux2="_"+seqNext+"_"; - // incrementSafe(aux1, aux2); + // String aux1="_"+seqCurr+"_"; + incrementSafe(meta.toString(), "_TOTAL_"); + // String aux2="_"+seqNext+"_"; + // incrementSafe(aux1, aux2); - // debug, feel free to uncomment + // debug, feel free to uncomment - /* - * System.out.println("<"+seqCurr+"><"+seqNext+"> => "+occurrences.get(seqCurr, - * seqNext)); - * System.out.println("<"+aux1+"><"+"_TOTAL_"+"> => "+occurrences.get(aux1, - * "_TOTAL_")); - * System.out.println("<"+aux1+"><"+aux2+"> => "+occurrences.get(aux1, aux2)); - * System.out.println(""); - */ + /* + * System.out.println("<"+seqCurr+"><"+seqNext+"> => "+occurrences.get(seqCurr, + * seqNext)); + * System.out.println("<"+aux1+"><"+"_TOTAL_"+"> => "+occurrences.get(aux1, + * "_TOTAL_")); + * System.out.println("<"+aux1+"><"+aux2+"> => "+occurrences.get(aux1, aux2)); + * System.out.println(""); + */ - } - // by now, we should have + } + // by now, we should have - } + } } diff --git a/src/main/java/nikedemos/markovnames/MarkovDictionarySPA.java b/src/main/java/nikedemos/markovnames/MarkovDictionarySPA.java index 129e0b8e2..81b3adb10 100644 --- a/src/main/java/nikedemos/markovnames/MarkovDictionarySPA.java +++ b/src/main/java/nikedemos/markovnames/MarkovDictionarySPA.java @@ -5,36 +5,36 @@ import java.util.Random; //used exclusively by the Spanish surname dictionary - because the capitalization is a little bit different public class MarkovDictionarySPA extends MarkovDictionary { - public MarkovDictionarySPA(String dictionary, int seqlen, Random rng) { - super(dictionary, seqlen, rng); - } + public MarkovDictionarySPA(String dictionary, int seqlen, Random rng) { + super(dictionary, seqlen, rng); + } - @Override - public String getPost(String str) { - return getCapitalizedSPA(str); - } + @Override + public String getPost(String str) { + return getCapitalizedSPA(str); + } - public String getCapitalizedSPA(String str) { - // for spanish capitalization + public String getCapitalizedSPA(String str) { + // for spanish capitalization - String[] parts = str.split("#"); + String[] parts = str.split("#"); - StringBuilder build = new StringBuilder(""); + StringBuilder build = new StringBuilder(""); - for (int p = 0; p < parts.length; p++) { - // capitalize this part, but only if it's not "de", "del", "la" or "los" - if (!parts[p].equals("de") && !parts[p].equals("del") && !parts[p].equals("la") - && !parts[p].equals("los")) { - parts[p] = getCapitalized(parts[p]); - } + for (int p = 0; p < parts.length; p++) { + // capitalize this part, but only if it's not "de", "del", "la" or "los" + if (!parts[p].equals("de") && !parts[p].equals("del") && !parts[p].equals("la") + && !parts[p].equals("los")) { + parts[p] = getCapitalized(parts[p]); + } - if (p > 0) // don't add spaces before the first part - build.append(" "); + if (p > 0) // don't add spaces before the first part + build.append(" "); - build.append(parts[p]); - } + build.append(parts[p]); + } - return build.toString(); - } + return build.toString(); + } } diff --git a/src/main/java/nikedemos/markovnames/generators/MarkovAncientGreek.java b/src/main/java/nikedemos/markovnames/generators/MarkovAncientGreek.java index 7a0753397..8d02601b9 100644 --- a/src/main/java/nikedemos/markovnames/generators/MarkovAncientGreek.java +++ b/src/main/java/nikedemos/markovnames/generators/MarkovAncientGreek.java @@ -6,53 +6,45 @@ import java.util.Random; public class MarkovAncientGreek extends MarkovGenerator { - public MarkovDictionary markov2; + public MarkovDictionary markov2; - public MarkovAncientGreek(int seqlen, Random rng) - { - this.rng = rng; - this.markov = new MarkovDictionary("ancient_greek_male.txt",seqlen,rng); - this.markov2 = new MarkovDictionary("ancient_greek_female.txt",seqlen,rng); - } - - public MarkovAncientGreek(int seqlen) - { - this(seqlen,new Random()); - - } - - public MarkovAncientGreek() - { - this(3, new Random()); //3 seems best-suited for Welsh - } - - @Override - public String fetch(int gender) - { - - String seq1; - - //check the gender. - //0 = random gender, 1 = male, 2 = female - //if there's no gender specified (0), - //now it's time to pick it at random - // - if (gender==0) - { - gender = rng.nextBoolean()==true? 1 : 2; - } - - //now if it's 2 - a lady - feminize the 3 sequences - if (gender==2) - { - seq1 = markov2.generateWord(); - } - else - { - seq1 = markov.generateWord(); - } - - - return seq1; - } + public MarkovAncientGreek(int seqlen, Random rng) { + this.rng = rng; + this.markov = new MarkovDictionary("ancient_greek_male.txt", seqlen, rng); + this.markov2 = new MarkovDictionary("ancient_greek_female.txt", seqlen, rng); + } + + public MarkovAncientGreek(int seqlen) { + this(seqlen, new Random()); + + } + + public MarkovAncientGreek() { + this(3, new Random()); //3 seems best-suited for Welsh + } + + @Override + public String fetch(int gender) { + + String seq1; + + //check the gender. + //0 = random gender, 1 = male, 2 = female + //if there's no gender specified (0), + //now it's time to pick it at random + // + if (gender == 0) { + gender = rng.nextBoolean() == true ? 1 : 2; + } + + //now if it's 2 - a lady - feminize the 3 sequences + if (gender == 2) { + seq1 = markov2.generateWord(); + } else { + seq1 = markov.generateWord(); + } + + + return seq1; + } } diff --git a/src/main/java/nikedemos/markovnames/generators/MarkovAztec.java b/src/main/java/nikedemos/markovnames/generators/MarkovAztec.java index d5d62637b..10b4454b4 100644 --- a/src/main/java/nikedemos/markovnames/generators/MarkovAztec.java +++ b/src/main/java/nikedemos/markovnames/generators/MarkovAztec.java @@ -6,26 +6,23 @@ import java.util.Random; public class MarkovAztec extends MarkovGenerator { - public MarkovAztec(int seqlen, Random rng) - { - this.rng = rng; - this.markov = new MarkovDictionary("aztec_given.txt",seqlen,rng); - } - - public MarkovAztec(int seqlen) - { - this(seqlen,new Random()); - - } - - public MarkovAztec() - { - this(3, new Random()); //3 seems best-suited for Aztec - } + public MarkovAztec(int seqlen, Random rng) { + this.rng = rng; + this.markov = new MarkovDictionary("aztec_given.txt", seqlen, rng); + } - @Override - public String fetch(int gender) //Aztec names are genderless - { - return markov.generateWord(); - } + public MarkovAztec(int seqlen) { + this(seqlen, new Random()); + + } + + public MarkovAztec() { + this(3, new Random()); //3 seems best-suited for Aztec + } + + @Override + public String fetch(int gender) //Aztec names are genderless + { + return markov.generateWord(); + } } diff --git a/src/main/java/nikedemos/markovnames/generators/MarkovCustomNPCsClassic.java b/src/main/java/nikedemos/markovnames/generators/MarkovCustomNPCsClassic.java index 16aed6cf3..ba6e886b6 100644 --- a/src/main/java/nikedemos/markovnames/generators/MarkovCustomNPCsClassic.java +++ b/src/main/java/nikedemos/markovnames/generators/MarkovCustomNPCsClassic.java @@ -15,26 +15,22 @@ import java.util.Random; public class MarkovCustomNPCsClassic extends MarkovGenerator { - public MarkovCustomNPCsClassic(int seqlen, Random rng) - { - this.rng = rng; - this.markov = new MarkovDictionary("customnpcs_classic.txt",seqlen,rng); - } - - public MarkovCustomNPCsClassic(int seqlen) - { - this(seqlen,new Random()); - - } - - public MarkovCustomNPCsClassic() - { - this(3, new Random()); - } + public MarkovCustomNPCsClassic(int seqlen, Random rng) { + this.rng = rng; + this.markov = new MarkovDictionary("customnpcs_classic.txt", seqlen, rng); + } - @Override - public String fetch(int gender) - { - return markov.generateWord(); - } + public MarkovCustomNPCsClassic(int seqlen) { + this(seqlen, new Random()); + + } + + public MarkovCustomNPCsClassic() { + this(3, new Random()); + } + + @Override + public String fetch(int gender) { + return markov.generateWord(); + } } diff --git a/src/main/java/nikedemos/markovnames/generators/MarkovGenerator.java b/src/main/java/nikedemos/markovnames/generators/MarkovGenerator.java index 43ecf4825..42a9c64c0 100644 --- a/src/main/java/nikedemos/markovnames/generators/MarkovGenerator.java +++ b/src/main/java/nikedemos/markovnames/generators/MarkovGenerator.java @@ -6,41 +6,36 @@ import java.util.Random; public class MarkovGenerator { - public MarkovDictionary markov; - public Random rng; - public String name; - public String symbol; - - public MarkovGenerator(int seqlen, Random rng) - { - this.rng = rng; - } - - public MarkovGenerator(int seqlen) - { - this(seqlen, new Random()); - } - - public MarkovGenerator() - { - this(3, new Random()); - } + public MarkovDictionary markov; + public Random rng; + public String name; + public String symbol; - public String fetch(int gender) { - return stylize(markov.generateWord()); - } - - public String fetch() - { - return fetch(0); //0 = random gender, 1 = male, 2 = female - } + public MarkovGenerator(int seqlen, Random rng) { + this.rng = rng; + } - public String stylize(String str) - { - return str; - } + public MarkovGenerator(int seqlen) { + this(seqlen, new Random()); + } - public String feminize(String element, boolean flag) { - return element; - } + public MarkovGenerator() { + this(3, new Random()); + } + + public String fetch(int gender) { + return stylize(markov.generateWord()); + } + + public String fetch() { + return fetch(0); //0 = random gender, 1 = male, 2 = female + } + + public String stylize(String str) { + return str; + } + + public String feminize(String element, boolean flag) { + return element; + } } diff --git a/src/main/java/nikedemos/markovnames/generators/MarkovJapanese.java b/src/main/java/nikedemos/markovnames/generators/MarkovJapanese.java index a610a25c8..e92f541b2 100644 --- a/src/main/java/nikedemos/markovnames/generators/MarkovJapanese.java +++ b/src/main/java/nikedemos/markovnames/generators/MarkovJapanese.java @@ -5,47 +5,46 @@ import nikedemos.markovnames.MarkovDictionary; import java.util.Random; public class MarkovJapanese extends MarkovGenerator { - public MarkovDictionary markov2; - public MarkovDictionary markov3; + public MarkovDictionary markov2; + public MarkovDictionary markov3; - public MarkovJapanese(int seqlen, Random rng) { - this.rng = rng; - this.markov = new MarkovDictionary("japanese_surnames.txt", seqlen, rng); - this.markov2 = new MarkovDictionary("japanese_given_male.txt", seqlen, rng); - this.markov3 = new MarkovDictionary("japanese_given_female.txt", seqlen, rng); - } + public MarkovJapanese(int seqlen, Random rng) { + this.rng = rng; + this.markov = new MarkovDictionary("japanese_surnames.txt", seqlen, rng); + this.markov2 = new MarkovDictionary("japanese_given_male.txt", seqlen, rng); + this.markov3 = new MarkovDictionary("japanese_given_female.txt", seqlen, rng); + } - public MarkovJapanese(int seqlen) { - this(seqlen, new Random()); + public MarkovJapanese(int seqlen) { + this(seqlen, new Random()); - } + } - public MarkovJapanese() { - this(4, new Random()); // 4 seems best suited for Japanese - } + public MarkovJapanese() { + this(4, new Random()); // 4 seems best suited for Japanese + } - @Override - public String fetch(int gender) { + @Override + public String fetch(int gender) { - StringBuilder name = new StringBuilder(markov.generateWord()); - name.append(" "); + StringBuilder name = new StringBuilder(markov.generateWord()); + name.append(" "); - // check the gender. - // 0 = random gender, 1 = male, 2 = female - // if there's no gender specified (0), - // now it's time to pick it at random - // - if (gender == 0) { - gender = rng.nextBoolean() == true ? 1 : 2; - } + // check the gender. + // 0 = random gender, 1 = male, 2 = female + // if there's no gender specified (0), + // now it's time to pick it at random + // + if (gender == 0) { + gender = rng.nextBoolean() == true ? 1 : 2; + } - if (gender == 2) { - name.append(markov3.generateWord()); - } - else { - name.append(markov2.generateWord()); - } + if (gender == 2) { + name.append(markov3.generateWord()); + } else { + name.append(markov2.generateWord()); + } - return name.toString(); - } + return name.toString(); + } } diff --git a/src/main/java/nikedemos/markovnames/generators/MarkovOldNorse.java b/src/main/java/nikedemos/markovnames/generators/MarkovOldNorse.java index b26db87ec..6e5b8d0f8 100644 --- a/src/main/java/nikedemos/markovnames/generators/MarkovOldNorse.java +++ b/src/main/java/nikedemos/markovnames/generators/MarkovOldNorse.java @@ -6,27 +6,24 @@ import java.util.Random; public class MarkovOldNorse extends MarkovGenerator { - public MarkovDictionary markov2; + public MarkovDictionary markov2; - public MarkovOldNorse(int seqlen, Random rng) - { - this.rng = rng; - this.markov = new MarkovDictionary("old_norse_bothgenders.txt",seqlen,rng); - } - - public MarkovOldNorse(int seqlen) - { - this(seqlen,new Random()); - } - - public MarkovOldNorse() - { - this(4, new Random()); //4 seems best-suited for Old Norse - } + public MarkovOldNorse(int seqlen, Random rng) { + this.rng = rng; + this.markov = new MarkovDictionary("old_norse_bothgenders.txt", seqlen, rng); + } - @Override - public String fetch(int gender) //Old Norse names are genderless - { - return markov.generateWord(); - } + public MarkovOldNorse(int seqlen) { + this(seqlen, new Random()); + } + + public MarkovOldNorse() { + this(4, new Random()); //4 seems best-suited for Old Norse + } + + @Override + public String fetch(int gender) //Old Norse names are genderless + { + return markov.generateWord(); + } } diff --git a/src/main/java/nikedemos/markovnames/generators/MarkovRoman.java b/src/main/java/nikedemos/markovnames/generators/MarkovRoman.java index 86c8dca25..8c537d026 100644 --- a/src/main/java/nikedemos/markovnames/generators/MarkovRoman.java +++ b/src/main/java/nikedemos/markovnames/generators/MarkovRoman.java @@ -5,61 +5,60 @@ import nikedemos.markovnames.MarkovDictionary; import java.util.Random; public class MarkovRoman extends MarkovGenerator { - public MarkovDictionary markov2; - public MarkovDictionary markov3; + public MarkovDictionary markov2; + public MarkovDictionary markov3; - public MarkovRoman(int seqlen, Random rng) { - this.rng = rng; - this.markov = new MarkovDictionary("roman_praenomina.txt", seqlen, rng); - this.markov2 = new MarkovDictionary("roman_nomina.txt", seqlen, rng); - this.markov3 = new MarkovDictionary("roman_cognomina.txt", seqlen, rng); - } + public MarkovRoman(int seqlen, Random rng) { + this.rng = rng; + this.markov = new MarkovDictionary("roman_praenomina.txt", seqlen, rng); + this.markov2 = new MarkovDictionary("roman_nomina.txt", seqlen, rng); + this.markov3 = new MarkovDictionary("roman_cognomina.txt", seqlen, rng); + } - public MarkovRoman(int seqlen) { - this(seqlen, new Random()); + public MarkovRoman(int seqlen) { + this(seqlen, new Random()); - } + } - public MarkovRoman() { - this(3, new Random()); - } + public MarkovRoman() { + this(3, new Random()); + } - @Override - public String feminize(String element, boolean flag) { - // change "us" into "a" and "o" at the end into "a" - if (element.endsWith("us")) { - element = element.substring(0, element.length() - 2) + "a"; - } - else if (element.endsWith("o")) { - element = element.substring(0, element.length() - 2) + "a"; - } + @Override + public String feminize(String element, boolean flag) { + // change "us" into "a" and "o" at the end into "a" + if (element.endsWith("us")) { + element = element.substring(0, element.length() - 2) + "a"; + } else if (element.endsWith("o")) { + element = element.substring(0, element.length() - 2) + "a"; + } - return element; - } + return element; + } - @Override - public String fetch(int gender) { + @Override + public String fetch(int gender) { - String seq1 = markov.generateWord(); - String seq2 = markov2.generateWord(); - String seq3 = markov3.generateWord(); + String seq1 = markov.generateWord(); + String seq2 = markov2.generateWord(); + String seq3 = markov3.generateWord(); - // check the gender. - // 0 = random gender, 1 = male, 2 = female - // if there's no gender specified (0), - // now it's time to pick it at random - // - if (gender == 0) { - gender = rng.nextBoolean() == true ? 1 : 2; - } + // check the gender. + // 0 = random gender, 1 = male, 2 = female + // if there's no gender specified (0), + // now it's time to pick it at random + // + if (gender == 0) { + gender = rng.nextBoolean() == true ? 1 : 2; + } - // now if it's 2 - a lady - feminize the 3 sequences - if (gender == 2) { - seq1 = feminize(seq1, false); - seq2 = feminize(seq2, false); - seq3 = feminize(seq3, true); - } + // now if it's 2 - a lady - feminize the 3 sequences + if (gender == 2) { + seq1 = feminize(seq1, false); + seq2 = feminize(seq2, false); + seq3 = feminize(seq3, true); + } - return (new StringBuilder(seq1).append(" ").append(seq2).append(" ").append(seq3).toString()); - } + return (new StringBuilder(seq1).append(" ").append(seq2).append(" ").append(seq3).toString()); + } } diff --git a/src/main/java/nikedemos/markovnames/generators/MarkovSaami.java b/src/main/java/nikedemos/markovnames/generators/MarkovSaami.java index 8989d5f75..6ee4a05f9 100644 --- a/src/main/java/nikedemos/markovnames/generators/MarkovSaami.java +++ b/src/main/java/nikedemos/markovnames/generators/MarkovSaami.java @@ -6,28 +6,25 @@ import java.util.Random; public class MarkovSaami extends MarkovGenerator { - public MarkovDictionary markov2; + public MarkovDictionary markov2; - public MarkovSaami(int seqlen, Random rng) - { - this.rng = rng; - this.markov = new MarkovDictionary("saami_bothgenders.txt",seqlen,rng); - } - - public MarkovSaami(int seqlen) - { - this(seqlen,new Random()); - - } - - public MarkovSaami() - { - this(3, new Random()); //3 seems best-suited for Saami - } + public MarkovSaami(int seqlen, Random rng) { + this.rng = rng; + this.markov = new MarkovDictionary("saami_bothgenders.txt", seqlen, rng); + } - @Override - public String fetch(int gender) //Saami names are genderless - { - return markov.generateWord(); - } + public MarkovSaami(int seqlen) { + this(seqlen, new Random()); + + } + + public MarkovSaami() { + this(3, new Random()); //3 seems best-suited for Saami + } + + @Override + public String fetch(int gender) //Saami names are genderless + { + return markov.generateWord(); + } } diff --git a/src/main/java/nikedemos/markovnames/generators/MarkovSlavic.java b/src/main/java/nikedemos/markovnames/generators/MarkovSlavic.java index 21d344a82..f0b348ea8 100644 --- a/src/main/java/nikedemos/markovnames/generators/MarkovSlavic.java +++ b/src/main/java/nikedemos/markovnames/generators/MarkovSlavic.java @@ -6,54 +6,53 @@ import java.util.Random; public class MarkovSlavic extends MarkovGenerator { - public MarkovSlavic(int seqlen, Random rng) { - this.rng = rng; - this.markov = new MarkovDictionary("slavic_given.txt", seqlen, rng); - } + public MarkovSlavic(int seqlen, Random rng) { + this.rng = rng; + this.markov = new MarkovDictionary("slavic_given.txt", seqlen, rng); + } - public MarkovSlavic(int seqlen) { - this(seqlen, new Random()); + public MarkovSlavic(int seqlen) { + this(seqlen, new Random()); - } + } - public MarkovSlavic() { - this(3, new Random()); // 3 seems best-suited for Slavic - } + public MarkovSlavic() { + this(3, new Random()); // 3 seems best-suited for Slavic + } - @Override - public String feminize(String element, boolean flag) { - // add "a" at the end, if there isn't one - String lastChar = element.substring(element.length() - 1); + @Override + public String feminize(String element, boolean flag) { + // add "a" at the end, if there isn't one + String lastChar = element.substring(element.length() - 1); - if (element.endsWith("o")) { - element = element.substring(0, element.length() - 1) + "a"; - } - else if (!lastChar.endsWith("a")) { - element += "a"; - } + if (element.endsWith("o")) { + element = element.substring(0, element.length() - 1) + "a"; + } else if (!lastChar.endsWith("a")) { + element += "a"; + } - return element; - } + return element; + } - @Override - public String fetch(int gender) { + @Override + public String fetch(int gender) { - String seq1 = markov.generateWord(); + String seq1 = markov.generateWord(); - // check the gender. - // 0 = random gender, 1 = male, 2 = female - // if there's no gender specified (0), - // now it's time to pick it at random - // - if (gender == 0) { - gender = rng.nextBoolean() == true ? 1 : 2; - } + // check the gender. + // 0 = random gender, 1 = male, 2 = female + // if there's no gender specified (0), + // now it's time to pick it at random + // + if (gender == 0) { + gender = rng.nextBoolean() == true ? 1 : 2; + } - // now if it's 2 - a lady - feminize the 3 sequences - if (gender == 2) { - seq1 = feminize(seq1, false); - } + // now if it's 2 - a lady - feminize the 3 sequences + if (gender == 2) { + seq1 = feminize(seq1, false); + } - return seq1; - } + return seq1; + } } diff --git a/src/main/java/nikedemos/markovnames/generators/MarkovSpanish.java b/src/main/java/nikedemos/markovnames/generators/MarkovSpanish.java index e8770e0ef..39b99e48a 100644 --- a/src/main/java/nikedemos/markovnames/generators/MarkovSpanish.java +++ b/src/main/java/nikedemos/markovnames/generators/MarkovSpanish.java @@ -6,47 +6,46 @@ import nikedemos.markovnames.MarkovDictionarySPA; import java.util.Random; public class MarkovSpanish extends MarkovGenerator { - public MarkovDictionary markov2; - public MarkovDictionary markov3; + public MarkovDictionary markov2; + public MarkovDictionary markov3; - public MarkovSpanish(int seqlen, Random rng) { - this.rng = rng; - this.markov = new MarkovDictionary("spanish_given_male.txt", seqlen, rng); - this.markov2 = new MarkovDictionary("spanish_given_female.txt", seqlen, rng); - this.markov3 = new MarkovDictionarySPA("spanish_surnames.txt", seqlen, rng); - } + public MarkovSpanish(int seqlen, Random rng) { + this.rng = rng; + this.markov = new MarkovDictionary("spanish_given_male.txt", seqlen, rng); + this.markov2 = new MarkovDictionary("spanish_given_female.txt", seqlen, rng); + this.markov3 = new MarkovDictionarySPA("spanish_surnames.txt", seqlen, rng); + } - public MarkovSpanish(int seqlen) { - this(seqlen, new Random()); - } + public MarkovSpanish(int seqlen) { + this(seqlen, new Random()); + } - public MarkovSpanish() { - this(3, new Random()); - } + public MarkovSpanish() { + this(3, new Random()); + } - @Override - public String fetch(int gender) { - String giv = ""; + @Override + public String fetch(int gender) { + String giv = ""; - String sur = markov3.generateWord(); + String sur = markov3.generateWord(); - // check the gender. - // 0 = random gender, 1 = male, 2 = female - // if there's no gender specified (0), - // now it's time to pick it at random - // - if (gender == 0) { - gender = rng.nextBoolean() == true ? 1 : 2; - } + // check the gender. + // 0 = random gender, 1 = male, 2 = female + // if there's no gender specified (0), + // now it's time to pick it at random + // + if (gender == 0) { + gender = rng.nextBoolean() == true ? 1 : 2; + } - if (gender == 1) { - giv = markov.generateWord(); - } - else { - giv = markov2.generateWord(); + if (gender == 1) { + giv = markov.generateWord(); + } else { + giv = markov2.generateWord(); - } + } - return new StringBuilder(giv).append(" ").append(sur).toString(); - } + return new StringBuilder(giv).append(" ").append(sur).toString(); + } } diff --git a/src/main/java/nikedemos/markovnames/generators/MarkovWelsh.java b/src/main/java/nikedemos/markovnames/generators/MarkovWelsh.java index 2ad00bf84..0153561dd 100644 --- a/src/main/java/nikedemos/markovnames/generators/MarkovWelsh.java +++ b/src/main/java/nikedemos/markovnames/generators/MarkovWelsh.java @@ -6,45 +6,44 @@ import java.util.Random; public class MarkovWelsh extends MarkovGenerator { - public MarkovDictionary markov2; + public MarkovDictionary markov2; - public MarkovWelsh(int seqlen, Random rng) { - this.rng = rng; - this.markov = new MarkovDictionary("welsh_male.txt", seqlen, rng); - this.markov2 = new MarkovDictionary("welsh_female.txt", seqlen, rng); - } + public MarkovWelsh(int seqlen, Random rng) { + this.rng = rng; + this.markov = new MarkovDictionary("welsh_male.txt", seqlen, rng); + this.markov2 = new MarkovDictionary("welsh_female.txt", seqlen, rng); + } - public MarkovWelsh(int seqlen) { - this(seqlen, new Random()); + public MarkovWelsh(int seqlen) { + this(seqlen, new Random()); - } + } - public MarkovWelsh() { - this(3, new Random()); // 3 seems best-suited for Welsh - } + public MarkovWelsh() { + this(3, new Random()); // 3 seems best-suited for Welsh + } - @Override - public String fetch(int gender) { + @Override + public String fetch(int gender) { - String seq1; + String seq1; - // check the gender. - // 0 = random gender, 1 = male, 2 = female - // if there's no gender specified (0), - // now it's time to pick it at random - // - if (gender == 0) { - gender = rng.nextBoolean() == true ? 1 : 2; - } + // check the gender. + // 0 = random gender, 1 = male, 2 = female + // if there's no gender specified (0), + // now it's time to pick it at random + // + if (gender == 0) { + gender = rng.nextBoolean() == true ? 1 : 2; + } - // now if it's 2 - a lady - feminize the 3 sequences - if (gender == 2) { - seq1 = markov2.generateWord(); - } - else { - seq1 = markov.generateWord(); - } + // now if it's 2 - a lady - feminize the 3 sequences + if (gender == 2) { + seq1 = markov2.generateWord(); + } else { + seq1 = markov.generateWord(); + } - return seq1; - } + return seq1; + } } diff --git a/src/main/java/noppes/npcs/AnimationMixinFunctions.java b/src/main/java/noppes/npcs/AnimationMixinFunctions.java index 96a90caa6..819874777 100644 --- a/src/main/java/noppes/npcs/AnimationMixinFunctions.java +++ b/src/main/java/noppes/npcs/AnimationMixinFunctions.java @@ -133,7 +133,7 @@ public class AnimationMixinFunctions { } private static EnumAnimationPart pivotEqualPart(ModelRenderer renderer) { - if(renderer.baseModel instanceof ModelBiped){ + if (renderer.baseModel instanceof ModelBiped) { ModelRenderer head = ((ModelBiped) renderer.baseModel).bipedHead; ModelRenderer body = ((ModelBiped) renderer.baseModel).bipedBody; ModelRenderer larm = ((ModelBiped) renderer.baseModel).bipedLeftArm; @@ -141,22 +141,22 @@ public class AnimationMixinFunctions { ModelRenderer lleg = ((ModelBiped) renderer.baseModel).bipedLeftLeg; ModelRenderer rleg = ((ModelBiped) renderer.baseModel).bipedRightLeg; - if (pivotsEqual(renderer,head)) { + if (pivotsEqual(renderer, head)) { return EnumAnimationPart.HEAD; } - if (pivotsEqual(renderer,body)) { + if (pivotsEqual(renderer, body)) { return EnumAnimationPart.BODY; } - if (pivotsEqual(renderer,rarm)) { + if (pivotsEqual(renderer, rarm)) { return EnumAnimationPart.RIGHT_ARM; } - if (pivotsEqual(renderer,larm)) { + if (pivotsEqual(renderer, larm)) { return EnumAnimationPart.LEFT_ARM; } - if (pivotsEqual(renderer,rleg)) { + if (pivotsEqual(renderer, rleg)) { return EnumAnimationPart.RIGHT_LEG; } - if (pivotsEqual(renderer,lleg)) { + if (pivotsEqual(renderer, lleg)) { return EnumAnimationPart.LEFT_LEG; } } @@ -179,7 +179,7 @@ public class AnimationMixinFunctions { declared = ClientEventHandler.declaredFieldCache.get(RenderClass); } else { declared = RenderClass.getDeclaredFields(); - ClientEventHandler.declaredFieldCache.put(RenderClass,declared); + ClientEventHandler.declaredFieldCache.put(RenderClass, declared); } for (Field f : declared) { f.setAccessible(true); @@ -190,7 +190,8 @@ public class AnimationMixinFunctions { if (partName.equals(f.getName()) && renderer == f.get(model)) { return entry.getKey(); } - } catch (IllegalAccessException ignored) {} + } catch (IllegalAccessException ignored) { + } } } } @@ -268,7 +269,7 @@ public class AnimationMixinFunctions { int i = Minecraft.getMinecraft().theWorld.getLightBrightnessForSkyBlocks(MathHelper.floor_double(entityclientplayermp.posX), MathHelper.floor_double(entityclientplayermp.posY), MathHelper.floor_double(entityclientplayermp.posZ), 0); int j = i % 65536; int k = i / 65536; - OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float)j, (float)k); + OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float) j, (float) k); float f3 = entityclientplayermp.prevRenderArmPitch + (entityclientplayermp.renderArmPitch - entityclientplayermp.prevRenderArmPitch) * partialRenderTick; float f4 = entityclientplayermp.prevRenderArmYaw + (entityclientplayermp.renderArmYaw - entityclientplayermp.prevRenderArmYaw) * partialRenderTick; @@ -285,13 +286,11 @@ public class AnimationMixinFunctions { ItemRenderer itemRenderer = Minecraft.getMinecraft().entityRenderer.itemRenderer; ItemStack itemstack = itemRenderer.itemToRender; - if (frame.frameParts.containsKey(EnumAnimationPart.RIGHT_ARM) && itemstack != null) - { + if (frame.frameParts.containsKey(EnumAnimationPart.RIGHT_ARM) && itemstack != null) { float f11, f12; GL11.glPushMatrix(); - if (player.fishEntity != null) - { + if (player.fishEntity != null) { itemstack = new ItemStack(Items.stick); } @@ -310,27 +309,23 @@ public class AnimationMixinFunctions { GL11.glRotatef(45, 1, 0, 0); GL11.glRotatef(80, 0, 0, 1); - float f6 = 1/1.5F; + float f6 = 1 / 1.5F; GL11.glScalef(f6, f6, f6); - if (itemstack.getItem().requiresMultipleRenderPasses()) - { - for (k = 0; k < itemstack.getItem().getRenderPasses(itemstack.getItemDamage()); ++k) - { + if (itemstack.getItem().requiresMultipleRenderPasses()) { + for (k = 0; k < itemstack.getItem().getRenderPasses(itemstack.getItemDamage()); ++k) { i = itemstack.getItem().getColorFromItemStack(itemstack, k); - f12 = (float)(i >> 16 & 255) / 255.0F; - f3 = (float)(i >> 8 & 255) / 255.0F; - f4 = (float)(i & 255) / 255.0F; + f12 = (float) (i >> 16 & 255) / 255.0F; + f3 = (float) (i >> 8 & 255) / 255.0F; + f4 = (float) (i & 255) / 255.0F; GL11.glColor4f(f12, f3, f4, 1.0F); mixin_renderItem(player, itemstack, k, EQUIPPED_FIRST_PERSON, renderBlocksIr, resItemGlint); } - } - else - { + } else { k = itemstack.getItem().getColorFromItemStack(itemstack, 0); - f11 = (float)(k >> 16 & 255) / 255.0F; - f12 = (float)(k >> 8 & 255) / 255.0F; - f3 = (float)(k & 255) / 255.0F; + f11 = (float) (k >> 16 & 255) / 255.0F; + f12 = (float) (k >> 8 & 255) / 255.0F; + f3 = (float) (k & 255) / 255.0F; GL11.glColor4f(f11, f12, f3, 1.0F); mixin_renderItem(player, itemstack, 0, EQUIPPED_FIRST_PERSON, renderBlocksIr, resItemGlint); } @@ -469,7 +464,7 @@ public class AnimationMixinFunctions { boolean instantTransmission = blocking == 2; int id = blocking != 0 ? (instantTransmission ? 6 : 0) : (animKiShoot != 0 ? an[animKiShoot - 1] + 2 : -1); - if (!(boolean)JGConfigClientSettings.getField("CLIENT_DA4").get(null)) { + if (!(boolean) JGConfigClientSettings.getField("CLIENT_DA4").get(null)) { id = -1; } @@ -478,12 +473,12 @@ public class AnimationMixinFunctions { int jx; int j; if (dbcBool) { - String[] s = ((String) JRMCoreH.getMethod("data", String.class, int.class, String.class).invoke(null,acp.getCommandSenderName(), 1, "0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0")).split(";"); + String[] s = ((String) JRMCoreH.getMethod("data", String.class, int.class, String.class).invoke(null, acp.getCommandSenderName(), 1, "0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0")).split(";"); tailCol = Integer.parseInt(s[2]); if (tailCol == 1) { String[] PlyrSkills = (String[]) JRMCoreH.getMethod("PlyrSkills", EntityPlayer.class).invoke(null, acp); - jx = (int) JRMCoreH.getMethod("SklLvl", int.class, String[].class).invoke(null,12, PlyrSkills); - j = (int) JRMCoreH.getMethod("SklLvl", int.class, String[].class).invoke(null,15, PlyrSkills); + jx = (int) JRMCoreH.getMethod("SklLvl", int.class, String[].class).invoke(null, 12, PlyrSkills); + j = (int) JRMCoreH.getMethod("SklLvl", int.class, String[].class).invoke(null, 15, PlyrSkills); String ss = s[17]; boolean v = dbcBool && !ss.equals("-1"); GL11.glPushMatrix(); @@ -676,10 +671,10 @@ public class AnimationMixinFunctions { if (State == 14) { tailCol = race != 2 && bodytype == 0 ? 6498048 : bodytype; - tailCol = (boolean)JRMCoreH.getMethod("isAprilFoolsModeOn").invoke(null) ? 13292516 : tailCol; + tailCol = (boolean) JRMCoreH.getMethod("isAprilFoolsModeOn").invoke(null) ? 13292516 : tailCol; tailCol = skintype == 1 ? bodyc1 : tailCol; if ((boolean) JRMCoreH.getMethod("rSai", int.class).invoke(null, race) && tailCol == 6498048 && State == 14) { - if ((boolean)JRMCoreH.getMethod("isAprilFoolsModeOn").invoke(null)) { + if ((boolean) JRMCoreH.getMethod("isAprilFoolsModeOn").invoke(null)) { tailCol = 13292516; } else { tailCol = 14292268; @@ -703,8 +698,8 @@ public class AnimationMixinFunctions { GL11.glDepthMask(false); tailCol = Integer.parseInt((String) JRMCoreH.getMethod("data", String.class, int.class, String.class ).invoke(null, par1EntityPlayer.getCommandSenderName(), 8, "200")); - float one = (float)tailCol / 100.0F; - j = (int)((float)tailCol / one); + float one = (float) tailCol / 100.0F; + j = (int) ((float) tailCol / one); if (j < 70) { GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); mc.getTextureManager().bindTexture(new ResourceLocation("jinryuumodscore:cc/bruises1.png")); @@ -744,7 +739,7 @@ public class AnimationMixinFunctions { if (itemstack != null) { item = itemstack.getItem(); if (item instanceof ItemArmor) { - itemarmor = (ItemArmor)item; + itemarmor = (ItemArmor) item; GL11.glPushMatrix(); dbcarmor = itemarmor.getArmorTexture(itemstack, par1EntityPlayer, 2, null); mcarmor = RenderBiped.getArmorResource(par1EntityPlayer, itemstack, 1, null); @@ -875,10 +870,10 @@ public class AnimationMixinFunctions { if (State == 14) { tailCol = race != 2 && bodytype == 0 ? 6498048 : bodytype; - tailCol = (boolean)JRMCoreH.getMethod("isAprilFoolsModeOn").invoke(null) ? 13292516 : tailCol; + tailCol = (boolean) JRMCoreH.getMethod("isAprilFoolsModeOn").invoke(null) ? 13292516 : tailCol; jx = skintype == 1 ? bodyc1 : tailCol; if ((boolean) JRMCoreH.getMethod("rSai", int.class).invoke(null, race) && jx == 6498048 && State == 14) { - if ((boolean)JRMCoreH.getMethod("isAprilFoolsModeOn").invoke(null)) { + if ((boolean) JRMCoreH.getMethod("isAprilFoolsModeOn").invoke(null)) { jx = 13292516; } else { jx = 14292268; @@ -907,8 +902,8 @@ public class AnimationMixinFunctions { ((int[]) JRMCoreH.getField("PlyrAttrbts").get(null))[2], race, (byte) JRMCoreH.getField("Class").get(null), 0.0F); jx = Integer.parseInt((String) JRMCoreH.getMethod("data", String.class, int.class, String.class).invoke(null, par1EntityPlayer.getCommandSenderName(), 8, "200")); - float one = (float)tailCol / 100.0F; - int perc = (int)((float)jx / one); + float one = (float) tailCol / 100.0F; + int perc = (int) ((float) jx / one); if (perc < 70) { GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); mc.getTextureManager().bindTexture(new ResourceLocation("jinryuumodscore:cc/bruises1.png")); @@ -942,7 +937,7 @@ public class AnimationMixinFunctions { if (itemstack != null) { item = itemstack.getItem(); if (item instanceof ItemArmor) { - itemarmor = (ItemArmor)item; + itemarmor = (ItemArmor) item; GL11.glPushMatrix(); dbcarmor = itemarmor.getArmorTexture(itemstack, par1EntityPlayer, 2, null); mcarmor = RenderBiped.getArmorResource(par1EntityPlayer, itemstack, 1, null); @@ -1020,9 +1015,9 @@ public class AnimationMixinFunctions { } private static void glColor3f(int c) throws ClassNotFoundException, InvocationTargetException, NoSuchMethodException, IllegalAccessException { - float h2 = (float)(c >> 16 & 255) / 255.0F; - float h3 = (float)(c >> 8 & 255) / 255.0F; - float h4 = (float)(c & 255) / 255.0F; + float h2 = (float) (c >> 16 & 255) / 255.0F; + float h3 = (float) (c >> 8 & 255) / 255.0F; + float h4 = (float) (c & 255) / 255.0F; float h1 = 1.0F; float r = h1 * h2; float g = h1 * h3; @@ -1048,7 +1043,7 @@ public class AnimationMixinFunctions { } else if (p_78443_2_.getItemSpriteNumber() == 0 && item instanceof ItemBlock && RenderBlocks.renderItemIn3d(block.getRenderType())) { texturemanager.bindTexture(texturemanager.getResourceLocation(0)); - GL11.glTranslatef(0.0F, 0.2F,-0.2F); + GL11.glTranslatef(0.0F, 0.2F, -0.2F); if (p_78443_2_ != null && block != null && block.getRenderBlockPass() != 0) { GL11.glDepthMask(false); renderBlocksIr.renderBlockAsItem(block, p_78443_2_.getItemDamage(), 1.0F); diff --git a/src/main/java/noppes/npcs/CommonProxy.java b/src/main/java/noppes/npcs/CommonProxy.java index da55ce86d..e8e879dd3 100644 --- a/src/main/java/noppes/npcs/CommonProxy.java +++ b/src/main/java/noppes/npcs/CommonProxy.java @@ -20,160 +20,163 @@ import noppes.npcs.controllers.data.PlayerData; import noppes.npcs.entity.EntityNPCInterface; public class CommonProxy implements IGuiHandler { - public boolean newVersionAvailable = false; - public int revision = 1; + public boolean newVersionAvailable = false; + public int revision = 1; - public void load() { - } + public void load() { + } - public PlayerData getPlayerData(EntityPlayer player) { - return null; - } + public PlayerData getPlayerData(EntityPlayer player) { + return null; + } public AnimationData getClientAnimationData(Entity entity) { return null; } - @Override - public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { - if(ID > EnumGuiType.values().length) - return null; - EntityNPCInterface npc = NoppesUtilServer.getEditingNpc(player); - EnumGuiType gui = EnumGuiType.values()[ID]; - return getContainer(gui, player, x, y, z, npc); - } - public Container getContainer(EnumGuiType gui,EntityPlayer player, int x, int y, int z,EntityNPCInterface npc){ - if(gui == EnumGuiType.CustomGui) - return new ContainerCustomGui(new InventoryBasic("", false, x)); + @Override + public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { + if (ID > EnumGuiType.values().length) + return null; + EntityNPCInterface npc = NoppesUtilServer.getEditingNpc(player); + EnumGuiType gui = EnumGuiType.values()[ID]; + return getContainer(gui, player, x, y, z, npc); + } - if(gui == EnumGuiType.MainMenuInv) - return new ContainerNPCInv(npc, player); + public Container getContainer(EnumGuiType gui, EntityPlayer player, int x, int y, int z, EntityNPCInterface npc) { + if (gui == EnumGuiType.CustomGui) + return new ContainerCustomGui(new InventoryBasic("", false, x)); - if(gui == EnumGuiType.PlayerBankSmall) - return new ContainerNPCBankSmall(player, x , y); + if (gui == EnumGuiType.MainMenuInv) + return new ContainerNPCInv(npc, player); - if(gui == EnumGuiType.PlayerBankUnlock) - return new ContainerNPCBankUnlock(player, x , y); + if (gui == EnumGuiType.PlayerBankSmall) + return new ContainerNPCBankSmall(player, x, y); - if(gui == EnumGuiType.PlayerBankUprade) - return new ContainerNPCBankUpgrade(player, x , y); + if (gui == EnumGuiType.PlayerBankUnlock) + return new ContainerNPCBankUnlock(player, x, y); - if(gui == EnumGuiType.PlayerBankLarge) - return new ContainerNPCBankLarge(player, x , y); + if (gui == EnumGuiType.PlayerBankUprade) + return new ContainerNPCBankUpgrade(player, x, y); - if(gui == EnumGuiType.PlayerFollowerHire) - return new ContainerNPCFollowerHire(npc, player); + if (gui == EnumGuiType.PlayerBankLarge) + return new ContainerNPCBankLarge(player, x, y); - if(gui == EnumGuiType.PlayerFollower) - return new ContainerNPCFollower(npc, player); + if (gui == EnumGuiType.PlayerFollowerHire) + return new ContainerNPCFollowerHire(npc, player); - if(gui == EnumGuiType.PlayerTrader) - return new ContainerNPCTrader(npc, player); + if (gui == EnumGuiType.PlayerFollower) + return new ContainerNPCFollower(npc, player); - if(gui == EnumGuiType.PlayerCarpentryBench) - return new ContainerCarpentryBench(player.inventory, player.worldObj, x, y, z); + if (gui == EnumGuiType.PlayerTrader) + return new ContainerNPCTrader(npc, player); - if(gui == EnumGuiType.PlayerAnvil) + if (gui == EnumGuiType.PlayerCarpentryBench) + return new ContainerCarpentryBench(player.inventory, player.worldObj, x, y, z); + + if (gui == EnumGuiType.PlayerAnvil) return new ContainerAnvilRepair(player.inventory, player.worldObj, x, y, z); - if(gui == EnumGuiType.SetupItemGiver) - return new ContainerNpcItemGiver(npc, player); + if (gui == EnumGuiType.SetupItemGiver) + return new ContainerNpcItemGiver(npc, player); - if(gui == EnumGuiType.SetupTrader) - return new ContainerNPCTraderSetup(npc, player); + if (gui == EnumGuiType.SetupTrader) + return new ContainerNPCTraderSetup(npc, player); - if(gui == EnumGuiType.SetupFollower) - return new ContainerNPCFollowerSetup(npc, player); + if (gui == EnumGuiType.SetupFollower) + return new ContainerNPCFollowerSetup(npc, player); - if(gui == EnumGuiType.QuestReward) - return new ContainerNpcQuestReward(player); + if (gui == EnumGuiType.QuestReward) + return new ContainerNpcQuestReward(player); - if(gui == EnumGuiType.QuestItem) - return new ContainerNpcQuestTypeItem(player); + if (gui == EnumGuiType.QuestItem) + return new ContainerNpcQuestTypeItem(player); - if(gui == EnumGuiType.ManageRecipes) - return new ContainerManageRecipes(player,x); + if (gui == EnumGuiType.ManageRecipes) + return new ContainerManageRecipes(player, x); - if(gui == EnumGuiType.ManageBanks) - return new ContainerManageBanks(player); + if (gui == EnumGuiType.ManageBanks) + return new ContainerManageBanks(player); - if(gui == EnumGuiType.MerchantAdd) - return new ContainerMerchantAdd(player, ServerEventsHandler.Merchant, player.worldObj); + if (gui == EnumGuiType.MerchantAdd) + return new ContainerMerchantAdd(player, ServerEventsHandler.Merchant, player.worldObj); - if(gui == EnumGuiType.Crate) - return new ContainerCrate(player.inventory, (TileNpcContainer)player.worldObj.getTileEntity(x, y, z)); + if (gui == EnumGuiType.Crate) + return new ContainerCrate(player.inventory, (TileNpcContainer) player.worldObj.getTileEntity(x, y, z)); - if(gui == EnumGuiType.PlayerMailman) - return new ContainerMail(player, x == 1, y == 1); + if (gui == EnumGuiType.PlayerMailman) + return new ContainerMail(player, x == 1, y == 1); - if(gui == EnumGuiType.CompanionInv) - return new ContainerNPCCompanion(npc, player); + if (gui == EnumGuiType.CompanionInv) + return new ContainerNPCCompanion(npc, player); - return null; - } + return null; + } - @Override - public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { + @Override + public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { - return null; - } + return null; + } - public void openGui(EntityNPCInterface npc, EnumGuiType gui) { + public void openGui(EntityNPCInterface npc, EnumGuiType gui) { - } + } - public void openGui(EntityNPCInterface npc, EnumGuiType gui, int x, int y, int z) { + public void openGui(EntityNPCInterface npc, EnumGuiType gui, int x, int y, int z) { - } + } - public void openGui(int i, int j, int k, EnumGuiType gui, EntityPlayer player) { + public void openGui(int i, int j, int k, EnumGuiType gui, EntityPlayer player) { - } + } - public void openGui(EntityPlayer player, Object guiscreen) { + public void openGui(EntityPlayer player, Object guiscreen) { - } + } - public void spawnParticle(EntityLivingBase player, String string, Object... ob) { + public void spawnParticle(EntityLivingBase player, String string, Object... ob) { - } + } - public FakePlayer getCommandPlayer(IWorld world) { return null; } + public FakePlayer getCommandPlayer(IWorld world) { + return null; + } - public boolean hasClient() { - return false; - } + public boolean hasClient() { + return false; + } - public EntityPlayer getPlayer() { - return null; - } + public EntityPlayer getPlayer() { + return null; + } - public void registerItem(Item item) { + public void registerItem(Item item) { - } + } - public ModelBiped getSkirtModel() { - return null; - } + public ModelBiped getSkirtModel() { + return null; + } - public void spawnParticle(String particle, double x, double y, double z, - double motionX, double motionY, double motionZ, float scale) { + public void spawnParticle(String particle, double x, double y, double z, + double motionX, double motionY, double motionZ, float scale) { - } + } - public void generateBigSmokeParticles(World world, int x, int y, int z, boolean signalFire){ + public void generateBigSmokeParticles(World world, int x, int y, int z, boolean signalFire) { } public String getAchievementDesc(Achievement achievement) { - return ""; - } + return ""; + } - public boolean isGUIOpen(){ - return false; - } + public boolean isGUIOpen() { + return false; + } } diff --git a/src/main/java/noppes/npcs/CreativeTabNpcs.java b/src/main/java/noppes/npcs/CreativeTabNpcs.java index 8a6a8924f..0b8e39210 100644 --- a/src/main/java/noppes/npcs/CreativeTabNpcs.java +++ b/src/main/java/noppes/npcs/CreativeTabNpcs.java @@ -4,21 +4,21 @@ import net.minecraft.creativetab.CreativeTabs; import net.minecraft.init.Items; import net.minecraft.item.Item; -public class CreativeTabNpcs extends CreativeTabs{ - public Item item = Items.bowl; - public int meta = 0; +public class CreativeTabNpcs extends CreativeTabs { + public Item item = Items.bowl; + public int meta = 0; - public CreativeTabNpcs(String label) { - super(label); - } + public CreativeTabNpcs(String label) { + super(label); + } - @Override - public Item getTabIconItem() { - return item; - } - - @Override - public int func_151243_f(){ + @Override + public Item getTabIconItem() { + return item; + } + + @Override + public int func_151243_f() { return meta; } } diff --git a/src/main/java/noppes/npcs/CustomItems.java b/src/main/java/noppes/npcs/CustomItems.java index 0dfbb421e..1b1bfed67 100644 --- a/src/main/java/noppes/npcs/CustomItems.java +++ b/src/main/java/noppes/npcs/CustomItems.java @@ -21,797 +21,797 @@ import noppes.npcs.items.*; public class CustomItems { - public static Item wand; - public static Item cloner; - public static Item scripter; - public static Item moving; - public static Item mount; - public static Item teleporter; + public static Item wand; + public static Item cloner; + public static Item scripter; + public static Item moving; + public static Item mount; + public static Item teleporter; public static Item tool; - public static Item scripted_item; + public static Item scripted_item; public static Item linked_item; - public static Item soulstoneEmpty; - public static Item soulstoneFull; + public static Item soulstoneEmpty; + public static Item soulstoneFull; - public static Item banjo; - public static Item violin; - public static Item violinbow; - public static Item harp; - public static Item guitar; - public static Item frenchHorn; - public static Item clarinet; - public static Item ocarina; + public static Item banjo; + public static Item violin; + public static Item violinbow; + public static Item harp; + public static Item guitar; + public static Item frenchHorn; + public static Item clarinet; + public static Item ocarina; - public static Item coinWood; - public static Item coinStone; - public static Item coinIron; - public static Item coinGold; - public static Item coinDiamond; - public static Item coinBronze; - public static Item coinEmerald; - public static Item moneyBag; + public static Item coinWood; + public static Item coinStone; + public static Item coinIron; + public static Item coinGold; + public static Item coinDiamond; + public static Item coinBronze; + public static Item coinEmerald; + public static Item moneyBag; - public static Item bulletWood; - public static Item bulletStone; - public static Item bulletIron; - public static Item bulletGold; - public static Item bulletDiamond; - public static Item bulletBronze; - public static Item bulletEmerald; - public static Item bulletBlack; + public static Item bulletWood; + public static Item bulletStone; + public static Item bulletIron; + public static Item bulletGold; + public static Item bulletDiamond; + public static Item bulletBronze; + public static Item bulletEmerald; + public static Item bulletBlack; - public static Item gunWood; - public static Item gunStone; - public static Item gunIron; - public static Item gunGold; - public static Item gunDiamond; - public static Item gunBronze; - public static Item gunEmerald; - public static Item gunMachine; + public static Item gunWood; + public static Item gunStone; + public static Item gunIron; + public static Item gunGold; + public static Item gunDiamond; + public static Item gunBronze; + public static Item gunEmerald; + public static Item gunMachine; - public static Item halberdWood; - public static Item halberdStone; - public static Item halberdIron; - public static Item halberdGold; - public static Item halberdDiamond; - public static Item halberdBronze; - public static Item halberdEmerald; - public static Item halberdDemonic; - public static Item halberdFrost; - public static Item halberdMithril; + public static Item halberdWood; + public static Item halberdStone; + public static Item halberdIron; + public static Item halberdGold; + public static Item halberdDiamond; + public static Item halberdBronze; + public static Item halberdEmerald; + public static Item halberdDemonic; + public static Item halberdFrost; + public static Item halberdMithril; - public static Item tridentWood; - public static Item tridentStone; - public static Item tridentIron; - public static Item tridentGold; - public static Item tridentDiamond; - public static Item tridentBronze; - public static Item tridentEmerald; - public static Item tridentCurse; - public static Item tridentDemonic; - public static Item tridentFrost; - public static Item tridentMithril; + public static Item tridentWood; + public static Item tridentStone; + public static Item tridentIron; + public static Item tridentGold; + public static Item tridentDiamond; + public static Item tridentBronze; + public static Item tridentEmerald; + public static Item tridentCurse; + public static Item tridentDemonic; + public static Item tridentFrost; + public static Item tridentMithril; - public static Item glaiveWood; - public static Item glaiveStone; - public static Item glaiveIron; - public static Item glaiveGold; - public static Item glaiveDiamond; - public static Item glaiveBronze; - public static Item glaiveEmerald; - public static Item glaiveDemonic; - public static Item glaiveFrost; - public static Item glaiveMithril; + public static Item glaiveWood; + public static Item glaiveStone; + public static Item glaiveIron; + public static Item glaiveGold; + public static Item glaiveDiamond; + public static Item glaiveBronze; + public static Item glaiveEmerald; + public static Item glaiveDemonic; + public static Item glaiveFrost; + public static Item glaiveMithril; - public static Item battleAxeWood; - public static Item battleAxeStone; - public static Item battleAxeIron; - public static Item battleAxeGold; - public static Item battleAxeDiamond; - public static Item battleAxeBronze; - public static Item battleAxeEmerald; - public static Item battleAxeCurse; - public static Item battleAxeDemonic; - public static Item battleAxeFrost; - public static Item battleAxeMithril; + public static Item battleAxeWood; + public static Item battleAxeStone; + public static Item battleAxeIron; + public static Item battleAxeGold; + public static Item battleAxeDiamond; + public static Item battleAxeBronze; + public static Item battleAxeEmerald; + public static Item battleAxeCurse; + public static Item battleAxeDemonic; + public static Item battleAxeFrost; + public static Item battleAxeMithril; - public static Item spellNature; - public static Item spellArcane; - public static Item spellItem; - public static Item spellLightning; - public static Item spellIce; - public static Item spellFire; - public static Item spellDark; - public static Item spellHoly; + public static Item spellNature; + public static Item spellArcane; + public static Item spellItem; + public static Item spellLightning; + public static Item spellIce; + public static Item spellFire; + public static Item spellDark; + public static Item spellHoly; public static Item earthElement; public static Item fireElement; public static Item waterElement; public static Item airElement; - public static Item staffWood; - public static Item staffStone; - public static Item staffIron; - public static Item staffGold; - public static Item staffDiamond; - public static Item staffBronze; - public static Item staffEmerald; - public static Item staffDemonic; - public static Item staffFrost; - public static Item staffMithril; - public static Item staffElemental; - public static Item orb; - public static Item mana; + public static Item staffWood; + public static Item staffStone; + public static Item staffIron; + public static Item staffGold; + public static Item staffDiamond; + public static Item staffBronze; + public static Item staffEmerald; + public static Item staffDemonic; + public static Item staffFrost; + public static Item staffMithril; + public static Item staffElemental; + public static Item orb; + public static Item mana; - public static Item swordBronze; - public static Item swordEmerald; - public static Item swordDemonic; - public static Item swordFrost; - public static Item swordMithril; + public static Item swordBronze; + public static Item swordEmerald; + public static Item swordDemonic; + public static Item swordFrost; + public static Item swordMithril; - public static Item bronze_ingot; - public static Item demonic_ingot; - public static Item mithril_ingot; + public static Item bronze_ingot; + public static Item demonic_ingot; + public static Item mithril_ingot; - public static Item kunai; - public static Item shuriken; + public static Item kunai; + public static Item shuriken; - public static Item excalibur; - public static Item letter; - public static Item bag; - public static Item satchel; + public static Item excalibur; + public static Item letter; + public static Item bag; + public static Item satchel; - public static Block redstoneBlock; - public static Block carpentyBench; - public static Block mailbox; - public static Block waypoint; - public static Block border; + public static Block redstoneBlock; + public static Block carpentyBench; + public static Block mailbox; + public static Block waypoint; + public static Block border; - public static Block banner; - public static Block wallBanner; - public static Block tallLamp; + public static Block banner; + public static Block wallBanner; + public static Block tallLamp; public static Block shortLamp; - public static Block blood; - public static Block book; - public static Block chair; - public static Block crate; - public static Block weaponsRack; - public static Block pedestal; - public static Block couchWool; - public static Block couchWood; - public static Block table; - public static Block stool; - public static Block bigsign; - public static Block barrel; - public static Block tombstone; - public static Block shelf; - public static Block sign; - public static Block beam; - public static Block crystal; + public static Block blood; + public static Block book; + public static Block chair; + public static Block crate; + public static Block weaponsRack; + public static Block pedestal; + public static Block couchWool; + public static Block couchWood; + public static Block table; + public static Block stool; + public static Block bigsign; + public static Block barrel; + public static Block tombstone; + public static Block shelf; + public static Block sign; + public static Block beam; + public static Block crystal; - public static Block lantern; - public static Block campfire; - public static Block candle; + public static Block lantern; + public static Block campfire; + public static Block candle; - public static Block lantern_unlit; - public static Block campfire_unlit; - public static Block candle_unlit; - public static Block scripted; + public static Block lantern_unlit; + public static Block campfire_unlit; + public static Block candle_unlit; + public static Block scripted; - public static Item crossbowBolt; + public static Item crossbowBolt; - public static CreativeTabNpcs tab = new CreativeTabNpcs("cnpcs"); - public static CreativeTabNpcs tabArmor; - public static CreativeTabNpcs tabWeapon; - public static CreativeTabNpcs tabBlocks = new CreativeTabNpcs("cnpcsb"); - public static CreativeTabNpcs tabMisc = new CreativeTabNpcs("cnpcsm"); + public static CreativeTabNpcs tab = new CreativeTabNpcs("cnpcs"); + public static CreativeTabNpcs tabArmor; + public static CreativeTabNpcs tabWeapon; + public static CreativeTabNpcs tabBlocks = new CreativeTabNpcs("cnpcsb"); + public static CreativeTabNpcs tabMisc = new CreativeTabNpcs("cnpcsm"); - public static void load(){ - GameRegistry.registerTileEntity(TileRedstoneBlock.class, "TileRedstoneBlock"); - GameRegistry.registerTileEntity(TileBlockAnvil.class, "TileBlockAnvil"); - GameRegistry.registerTileEntity(TileMailbox.class, "TileMailbox"); - GameRegistry.registerTileEntity(TileWaypoint.class, "TileWaypoint"); - GameRegistry.registerTileEntity(TileBanner.class, "TileNPCBanner"); - GameRegistry.registerTileEntity(TileScripted.class, "TileNPCScripted"); + public static void load() { + GameRegistry.registerTileEntity(TileRedstoneBlock.class, "TileRedstoneBlock"); + GameRegistry.registerTileEntity(TileBlockAnvil.class, "TileBlockAnvil"); + GameRegistry.registerTileEntity(TileMailbox.class, "TileMailbox"); + GameRegistry.registerTileEntity(TileWaypoint.class, "TileWaypoint"); + GameRegistry.registerTileEntity(TileBanner.class, "TileNPCBanner"); + GameRegistry.registerTileEntity(TileScripted.class, "TileNPCScripted"); - if(!ConfigItem.DisableExtraBlock){ - GameRegistry.registerTileEntity(TileWallBanner.class, "TileNPCWallBanner"); - GameRegistry.registerTileEntity(TileTallLamp.class, "TileNPCTallLamp"); + if (!ConfigItem.DisableExtraBlock) { + GameRegistry.registerTileEntity(TileWallBanner.class, "TileNPCWallBanner"); + GameRegistry.registerTileEntity(TileTallLamp.class, "TileNPCTallLamp"); GameRegistry.registerTileEntity(TileShortLamp.class, "TileNPCShortLamp"); - GameRegistry.registerTileEntity(TileChair.class, "TileNPCChair"); - GameRegistry.registerTileEntity(TileCrate.class, "TileNPCCrate"); - GameRegistry.registerTileEntity(TileWeaponRack.class, "TileNPCWeaponRack"); - GameRegistry.registerTileEntity(TileCouchWool.class, "TileNPCCouchWool"); - GameRegistry.registerTileEntity(TileCouchWood.class, "TileNPCCouchWood"); - GameRegistry.registerTileEntity(TileTable.class, "TileNPCTable"); - GameRegistry.registerTileEntity(TileLamp.class, "TileNPCLamp"); - GameRegistry.registerTileEntity(TileCandle.class, "TileNPCCandle"); - GameRegistry.registerTileEntity(TileBorder.class, "TileNPCBorder"); - GameRegistry.registerTileEntity(TileStool.class, "TileNPCStool"); - GameRegistry.registerTileEntity(TileBigSign.class, "TileNPCBigSign"); - GameRegistry.registerTileEntity(TileBarrel.class, "TileNPCBarrel"); - GameRegistry.registerTileEntity(TileCampfire.class, "TileNPCCampfire"); - GameRegistry.registerTileEntity(TileTombstone.class, "TileNPCTombstone"); - GameRegistry.registerTileEntity(TileShelf.class, "TileNPCShelf"); - GameRegistry.registerTileEntity(TileSign.class, "TileNPCSign"); - GameRegistry.registerTileEntity(TileBeam.class, "TileNPCBeam"); - GameRegistry.registerTileEntity(TileBook.class, "TileNPCBook"); - GameRegistry.registerTileEntity(TilePedestal.class, "TileNPCPedestal"); - } - wand = new ItemNpcWand().setUnlocalizedName("npcWand").setFull3D(); - cloner = new ItemNpcCloner().setUnlocalizedName("npcMobCloner").setFull3D(); - scripter = new ItemNpcScripter().setUnlocalizedName("npcScripter").setFull3D(); - moving = new ItemNpcMovingPath().setUnlocalizedName("npcMovingPath").setFull3D(); - mount = new ItemMounter().setUnlocalizedName("npcMounter").setFull3D(); - teleporter = new ItemTeleporter().setUnlocalizedName("npcTeleporter").setFull3D(); - scripted_item = new ItemScripted().setUnlocalizedName("scripted_item").setFull3D(); + GameRegistry.registerTileEntity(TileChair.class, "TileNPCChair"); + GameRegistry.registerTileEntity(TileCrate.class, "TileNPCCrate"); + GameRegistry.registerTileEntity(TileWeaponRack.class, "TileNPCWeaponRack"); + GameRegistry.registerTileEntity(TileCouchWool.class, "TileNPCCouchWool"); + GameRegistry.registerTileEntity(TileCouchWood.class, "TileNPCCouchWood"); + GameRegistry.registerTileEntity(TileTable.class, "TileNPCTable"); + GameRegistry.registerTileEntity(TileLamp.class, "TileNPCLamp"); + GameRegistry.registerTileEntity(TileCandle.class, "TileNPCCandle"); + GameRegistry.registerTileEntity(TileBorder.class, "TileNPCBorder"); + GameRegistry.registerTileEntity(TileStool.class, "TileNPCStool"); + GameRegistry.registerTileEntity(TileBigSign.class, "TileNPCBigSign"); + GameRegistry.registerTileEntity(TileBarrel.class, "TileNPCBarrel"); + GameRegistry.registerTileEntity(TileCampfire.class, "TileNPCCampfire"); + GameRegistry.registerTileEntity(TileTombstone.class, "TileNPCTombstone"); + GameRegistry.registerTileEntity(TileShelf.class, "TileNPCShelf"); + GameRegistry.registerTileEntity(TileSign.class, "TileNPCSign"); + GameRegistry.registerTileEntity(TileBeam.class, "TileNPCBeam"); + GameRegistry.registerTileEntity(TileBook.class, "TileNPCBook"); + GameRegistry.registerTileEntity(TilePedestal.class, "TileNPCPedestal"); + } + wand = new ItemNpcWand().setUnlocalizedName("npcWand").setFull3D(); + cloner = new ItemNpcCloner().setUnlocalizedName("npcMobCloner").setFull3D(); + scripter = new ItemNpcScripter().setUnlocalizedName("npcScripter").setFull3D(); + moving = new ItemNpcMovingPath().setUnlocalizedName("npcMovingPath").setFull3D(); + mount = new ItemMounter().setUnlocalizedName("npcMounter").setFull3D(); + teleporter = new ItemTeleporter().setUnlocalizedName("npcTeleporter").setFull3D(); + scripted_item = new ItemScripted().setUnlocalizedName("scripted_item").setFull3D(); linked_item = new ItemLinked().setUnlocalizedName("linked_item").setFull3D(); tool = new ItemNpcTool().setUnlocalizedName("npcTool").setFull3D(); - redstoneBlock = new BlockNpcRedstone().setHardness(50.0F).setResistance(2000).setBlockName("npcRedstoneBlock").setBlockTextureName("customnpcs:npcRedstoneBlock").setCreativeTab(tab); - carpentyBench = new BlockCarpentryBench().setBlockName("npcCarpentyBench").setHardness(5.0F).setResistance(10.0F).setStepSound(Block.soundTypePiston).setCreativeTab(tabBlocks); - mailbox = new BlockMailbox().setBlockName("npcMailbox").setHardness(5.0F).setResistance(10.0F).setStepSound(Block.soundTypeMetal).setCreativeTab(tabBlocks); - waypoint = new BlockWaypoint().setBlockName("npcLocationBlock").setHardness(5.0F).setResistance(10.0F).setStepSound(Block.soundTypeMetal).setBlockTextureName("customnpcs:npcWaypoint").setCreativeTab(tab); - border = new BlockBorder().setBlockName("npcBorder").setHardness(5.0F).setResistance(10.0F).setStepSound(Block.soundTypeWood).setCreativeTab(tab).setBlockTextureName("customnpcs:npcBorder"); - scripted = new BlockScripted().setBlockName("npcScripted").setHardness(5.0F).setResistance(10.0F).setCreativeTab(tab).setBlockTextureName("customnpcs:npcScripted"); + redstoneBlock = new BlockNpcRedstone().setHardness(50.0F).setResistance(2000).setBlockName("npcRedstoneBlock").setBlockTextureName("customnpcs:npcRedstoneBlock").setCreativeTab(tab); + carpentyBench = new BlockCarpentryBench().setBlockName("npcCarpentyBench").setHardness(5.0F).setResistance(10.0F).setStepSound(Block.soundTypePiston).setCreativeTab(tabBlocks); + mailbox = new BlockMailbox().setBlockName("npcMailbox").setHardness(5.0F).setResistance(10.0F).setStepSound(Block.soundTypeMetal).setCreativeTab(tabBlocks); + waypoint = new BlockWaypoint().setBlockName("npcLocationBlock").setHardness(5.0F).setResistance(10.0F).setStepSound(Block.soundTypeMetal).setBlockTextureName("customnpcs:npcWaypoint").setCreativeTab(tab); + border = new BlockBorder().setBlockName("npcBorder").setHardness(5.0F).setResistance(10.0F).setStepSound(Block.soundTypeWood).setCreativeTab(tab).setBlockTextureName("customnpcs:npcBorder"); + scripted = new BlockScripted().setBlockName("npcScripted").setHardness(5.0F).setResistance(10.0F).setCreativeTab(tab).setBlockTextureName("customnpcs:npcScripted"); - soulstoneEmpty = new ItemSoulstoneEmpty().setUnlocalizedName("npcSoulstoneEmpty").setTextureName("customnpcs:npcSoulstoneEmpty").setCreativeTab(tab); - soulstoneFull = new ItemSoulstoneFilled().setUnlocalizedName("npcSoulstoneFilled").setTextureName("customnpcs:npcSoulstoneFilled"); + soulstoneEmpty = new ItemSoulstoneEmpty().setUnlocalizedName("npcSoulstoneEmpty").setTextureName("customnpcs:npcSoulstoneEmpty").setCreativeTab(tab); + soulstoneFull = new ItemSoulstoneFilled().setUnlocalizedName("npcSoulstoneFilled").setTextureName("customnpcs:npcSoulstoneFilled"); - BlockDispenser.dispenseBehaviorRegistry.putObject(soulstoneFull, new BehaviorDefaultDispenseItem(){ + BlockDispenser.dispenseBehaviorRegistry.putObject(soulstoneFull, new BehaviorDefaultDispenseItem() { - @Override - public ItemStack dispenseStack(IBlockSource source, ItemStack item){ + @Override + public ItemStack dispenseStack(IBlockSource source, ItemStack item) { EnumFacing enumfacing = BlockDispenser.func_149937_b(source.getBlockMetadata()); - int x = source.getXInt() + enumfacing.getFrontOffsetX(); - int z = source.getZInt() + enumfacing.getFrontOffsetZ(); - ((ItemSoulstoneFilled)soulstoneFull).spawn(null, item, source.getWorld(), x, source.getYInt(), z); - item.splitStack(1); - return item; + int x = source.getXInt() + enumfacing.getFrontOffsetX(); + int z = source.getZInt() + enumfacing.getFrontOffsetZ(); + ((ItemSoulstoneFilled) soulstoneFull).spawn(null, item, source.getWorld(), x, source.getYInt(), z); + item.splitStack(1); + return item; } }); - GameRegistry.registerBlock(redstoneBlock, "npcRedstoneBlock"); - GameRegistry.registerBlock(carpentyBench, ItemNpcBlock.class, "npcCarpentyBench"); - GameRegistry.registerBlock(mailbox, ItemBlock.class, "npcMailbox"); - GameRegistry.registerBlock(waypoint, "npcWaypoint"); - GameRegistry.registerBlock(border, "npcBorder"); - GameRegistry.registerBlock(scripted, "npcScripted"); + GameRegistry.registerBlock(redstoneBlock, "npcRedstoneBlock"); + GameRegistry.registerBlock(carpentyBench, ItemNpcBlock.class, "npcCarpentyBench"); + GameRegistry.registerBlock(mailbox, ItemBlock.class, "npcMailbox"); + GameRegistry.registerBlock(waypoint, "npcWaypoint"); + GameRegistry.registerBlock(border, "npcBorder"); + GameRegistry.registerBlock(scripted, "npcScripted"); - Item.getItemFromBlock(mailbox).setHasSubtypes(true); - Item.getItemFromBlock(carpentyBench).setHasSubtypes(true); + Item.getItemFromBlock(mailbox).setHasSubtypes(true); + Item.getItemFromBlock(carpentyBench).setHasSubtypes(true); - ((ItemNpcBlock)Item.getItemFromBlock(carpentyBench)).names = new String[]{"tile.npcCarpentyBench", "tile.anvil"}; + ((ItemNpcBlock) Item.getItemFromBlock(carpentyBench)).names = new String[]{"tile.npcCarpentyBench", "tile.anvil"}; - if(!ConfigItem.DisableExtraBlock){ - blood = new BlockBlood().setBlockName("npcBloodBlock").setBlockTextureName("customnpcs:npcBloodBlock").setCreativeTab(tabBlocks); - banner = new BlockBanner().setBlockName("npcBanner").setHardness(5.0F).setResistance(10.0F).setStepSound(Block.soundTypeCloth).setCreativeTab(tabBlocks); - wallBanner = new BlockWallBanner().setBlockName("npcWallBanner").setHardness(5.0F).setResistance(10.0F).setStepSound(Block.soundTypeCloth).setCreativeTab(tabBlocks); - tallLamp = new BlockTallLamp().setBlockName("npcTallLamp").setHardness(5.0F).setResistance(10.0F).setStepSound(Block.soundTypeMetal).setCreativeTab(tabBlocks); + if (!ConfigItem.DisableExtraBlock) { + blood = new BlockBlood().setBlockName("npcBloodBlock").setBlockTextureName("customnpcs:npcBloodBlock").setCreativeTab(tabBlocks); + banner = new BlockBanner().setBlockName("npcBanner").setHardness(5.0F).setResistance(10.0F).setStepSound(Block.soundTypeCloth).setCreativeTab(tabBlocks); + wallBanner = new BlockWallBanner().setBlockName("npcWallBanner").setHardness(5.0F).setResistance(10.0F).setStepSound(Block.soundTypeCloth).setCreativeTab(tabBlocks); + tallLamp = new BlockTallLamp().setBlockName("npcTallLamp").setHardness(5.0F).setResistance(10.0F).setStepSound(Block.soundTypeMetal).setCreativeTab(tabBlocks); shortLamp = new BlockShortLamp().setBlockName("npcShortLamp").setHardness(5.0F).setResistance(10.0F).setStepSound(Block.soundTypeMetal).setCreativeTab(tabBlocks); chair = new BlockChair().setBlockName("npcChair").setHardness(5.0F).setResistance(10.0F).setStepSound(Block.soundTypeWood).setCreativeTab(tabBlocks); - crate = new BlockCrate().setBlockName("npcCrate").setHardness(5.0F).setResistance(10.0F).setStepSound(Block.soundTypeWood).setCreativeTab(tabBlocks); - weaponsRack = new BlockWeaponRack().setBlockName("npcWeaponRack").setHardness(5.0F).setResistance(10.0F).setStepSound(Block.soundTypeWood).setCreativeTab(tabBlocks); - couchWool = new BlockCouchWool().setBlockName("npcCouchWool").setHardness(5.0F).setResistance(10.0F).setStepSound(Block.soundTypeWood).setCreativeTab(tabBlocks); - table = new BlockTable().setBlockName("npcTable").setHardness(5.0F).setResistance(10.0F).setStepSound(Block.soundTypeWood).setCreativeTab(tabBlocks); - couchWood = new BlockCouchWood().setBlockName("npcCouchWood").setHardness(5.0F).setResistance(10.0F).setStepSound(Block.soundTypeWood).setCreativeTab(tabBlocks); - lantern = new BlockLantern(true).setBlockName("npcLamp").setHardness(5.0F).setResistance(10.0F).setStepSound(Block.soundTypeMetal).setCreativeTab(tabBlocks).setBlockTextureName("customnpcs:lantern"); - candle = new BlockCandle(true).setBlockName("npcCandle").setHardness(5.0F).setResistance(10.0F).setStepSound(Block.soundTypeStone).setCreativeTab(tabBlocks).setBlockTextureName("customnpcs:candle"); - stool = new BlockStool().setBlockName("npcStool").setHardness(5.0F).setResistance(10.0F).setStepSound(Block.soundTypeWood).setCreativeTab(tabBlocks); - Block placeholder = new BlockPlaceholder().setBlockName("npcPlaceholder").setHardness(5.0F).setResistance(10.0F).setStepSound(Block.soundTypeWood).setCreativeTab(tabMisc); - bigsign = new BlockBigSign().setBlockName("npcBigSign").setHardness(5.0F).setResistance(10.0F).setStepSound(Block.soundTypeWood).setCreativeTab(tabBlocks); - barrel = new BlockBarrel().setBlockName("npcBarrel").setHardness(5.0F).setResistance(10.0F).setStepSound(Block.soundTypeWood).setCreativeTab(tabBlocks); - campfire = new BlockCampfire(true).setBlockName("npcCampfire").setHardness(5.0F).setResistance(10.0F).setStepSound(Block.soundTypeStone).setCreativeTab(tabBlocks).setBlockTextureName("customnpcs:campfire"); - tombstone = new BlockTombstone().setBlockName("npcTombstone").setHardness(5.0F).setResistance(10.0F).setStepSound(Block.soundTypeStone).setCreativeTab(tabBlocks); - shelf = new BlockShelf().setBlockName("npcShelf").setHardness(5.0F).setResistance(10.0F).setStepSound(Block.soundTypeWood).setCreativeTab(tabBlocks); - sign = new BlockSign().setBlockName("npcSign").setHardness(5.0F).setResistance(10.0F).setStepSound(Block.soundTypeWood).setCreativeTab(tabBlocks); - beam = new BlockBeam().setBlockName("npcBeam").setHardness(5.0F).setResistance(10.0F).setStepSound(Block.soundTypeWood).setCreativeTab(tabBlocks); - book = new BlockBook().setHardness(5.0F).setResistance(10.0F).setStepSound(Block.soundTypeWood).setCreativeTab(tabBlocks); - pedestal = new BlockPedestal().setBlockName("npcPedestal").setHardness(5.0F).setResistance(10.0F).setStepSound(Block.soundTypeWood).setCreativeTab(tabBlocks); - crystal = new BlockCrystal().setBlockName("npcCrystal").setBlockTextureName("customnpcs:npcCrystal").setHardness(5.0F).setResistance(10.0F).setStepSound(Block.soundTypeGlass).setCreativeTab(tabBlocks); + crate = new BlockCrate().setBlockName("npcCrate").setHardness(5.0F).setResistance(10.0F).setStepSound(Block.soundTypeWood).setCreativeTab(tabBlocks); + weaponsRack = new BlockWeaponRack().setBlockName("npcWeaponRack").setHardness(5.0F).setResistance(10.0F).setStepSound(Block.soundTypeWood).setCreativeTab(tabBlocks); + couchWool = new BlockCouchWool().setBlockName("npcCouchWool").setHardness(5.0F).setResistance(10.0F).setStepSound(Block.soundTypeWood).setCreativeTab(tabBlocks); + table = new BlockTable().setBlockName("npcTable").setHardness(5.0F).setResistance(10.0F).setStepSound(Block.soundTypeWood).setCreativeTab(tabBlocks); + couchWood = new BlockCouchWood().setBlockName("npcCouchWood").setHardness(5.0F).setResistance(10.0F).setStepSound(Block.soundTypeWood).setCreativeTab(tabBlocks); + lantern = new BlockLantern(true).setBlockName("npcLamp").setHardness(5.0F).setResistance(10.0F).setStepSound(Block.soundTypeMetal).setCreativeTab(tabBlocks).setBlockTextureName("customnpcs:lantern"); + candle = new BlockCandle(true).setBlockName("npcCandle").setHardness(5.0F).setResistance(10.0F).setStepSound(Block.soundTypeStone).setCreativeTab(tabBlocks).setBlockTextureName("customnpcs:candle"); + stool = new BlockStool().setBlockName("npcStool").setHardness(5.0F).setResistance(10.0F).setStepSound(Block.soundTypeWood).setCreativeTab(tabBlocks); + Block placeholder = new BlockPlaceholder().setBlockName("npcPlaceholder").setHardness(5.0F).setResistance(10.0F).setStepSound(Block.soundTypeWood).setCreativeTab(tabMisc); + bigsign = new BlockBigSign().setBlockName("npcBigSign").setHardness(5.0F).setResistance(10.0F).setStepSound(Block.soundTypeWood).setCreativeTab(tabBlocks); + barrel = new BlockBarrel().setBlockName("npcBarrel").setHardness(5.0F).setResistance(10.0F).setStepSound(Block.soundTypeWood).setCreativeTab(tabBlocks); + campfire = new BlockCampfire(true).setBlockName("npcCampfire").setHardness(5.0F).setResistance(10.0F).setStepSound(Block.soundTypeStone).setCreativeTab(tabBlocks).setBlockTextureName("customnpcs:campfire"); + tombstone = new BlockTombstone().setBlockName("npcTombstone").setHardness(5.0F).setResistance(10.0F).setStepSound(Block.soundTypeStone).setCreativeTab(tabBlocks); + shelf = new BlockShelf().setBlockName("npcShelf").setHardness(5.0F).setResistance(10.0F).setStepSound(Block.soundTypeWood).setCreativeTab(tabBlocks); + sign = new BlockSign().setBlockName("npcSign").setHardness(5.0F).setResistance(10.0F).setStepSound(Block.soundTypeWood).setCreativeTab(tabBlocks); + beam = new BlockBeam().setBlockName("npcBeam").setHardness(5.0F).setResistance(10.0F).setStepSound(Block.soundTypeWood).setCreativeTab(tabBlocks); + book = new BlockBook().setHardness(5.0F).setResistance(10.0F).setStepSound(Block.soundTypeWood).setCreativeTab(tabBlocks); + pedestal = new BlockPedestal().setBlockName("npcPedestal").setHardness(5.0F).setResistance(10.0F).setStepSound(Block.soundTypeWood).setCreativeTab(tabBlocks); + crystal = new BlockCrystal().setBlockName("npcCrystal").setBlockTextureName("customnpcs:npcCrystal").setHardness(5.0F).setResistance(10.0F).setStepSound(Block.soundTypeGlass).setCreativeTab(tabBlocks); - campfire_unlit = new BlockCampfire(false).setBlockName("npcCampfire").setHardness(5.0F).setResistance(10.0F).setStepSound(Block.soundTypeStone).setBlockTextureName("customnpcs:campfire"); - lantern_unlit = new BlockLantern(false).setBlockName("npcLamp").setHardness(5.0F).setResistance(10.0F).setStepSound(Block.soundTypeMetal).setBlockTextureName("customnpcs:lantern"); - candle_unlit = new BlockCandle(false).setBlockName("npcCandle").setHardness(5.0F).setResistance(10.0F).setStepSound(Block.soundTypeStone).setBlockTextureName("customnpcs:candle"); + campfire_unlit = new BlockCampfire(false).setBlockName("npcCampfire").setHardness(5.0F).setResistance(10.0F).setStepSound(Block.soundTypeStone).setBlockTextureName("customnpcs:campfire"); + lantern_unlit = new BlockLantern(false).setBlockName("npcLamp").setHardness(5.0F).setResistance(10.0F).setStepSound(Block.soundTypeMetal).setBlockTextureName("customnpcs:lantern"); + candle_unlit = new BlockCandle(false).setBlockName("npcCandle").setHardness(5.0F).setResistance(10.0F).setStepSound(Block.soundTypeStone).setBlockTextureName("customnpcs:candle"); - GameRegistry.registerBlock(blood, "npcBloodBlock"); - GameRegistry.registerBlock(banner, ItemBlock.class, "npcBanner"); - GameRegistry.registerBlock(wallBanner, ItemBlock.class, "npcWallBanner"); - GameRegistry.registerBlock(tallLamp, ItemBlock.class, "npcTallLamp"); + GameRegistry.registerBlock(blood, "npcBloodBlock"); + GameRegistry.registerBlock(banner, ItemBlock.class, "npcBanner"); + GameRegistry.registerBlock(wallBanner, ItemBlock.class, "npcWallBanner"); + GameRegistry.registerBlock(tallLamp, ItemBlock.class, "npcTallLamp"); GameRegistry.registerBlock(shortLamp, ItemBlock.class, "npcShortLamp"); - GameRegistry.registerBlock(chair, ItemBlock.class, "npcChair"); - GameRegistry.registerBlock(crate, ItemBlock.class, "npcCrate"); - GameRegistry.registerBlock(weaponsRack, ItemBlock.class, "npcWeaponRack"); - GameRegistry.registerBlock(couchWool, ItemBlock.class, "npcCouchWool"); - GameRegistry.registerBlock(couchWood, ItemBlock.class, "npcCouchWood"); - GameRegistry.registerBlock(table, ItemBlock.class, "npcTable"); - GameRegistry.registerBlock(stool, ItemBlock.class, "npcStool"); - GameRegistry.registerBlock(placeholder, ItemPlaceholder.class, "npcPlaceholder"); - GameRegistry.registerBlock(bigsign, "npcBigSign"); - GameRegistry.registerBlock(barrel, ItemBlock.class, "npcBarrel"); - GameRegistry.registerBlock(tombstone, ItemBlock.class, "npcTombstone"); - GameRegistry.registerBlock(shelf, ItemBlock.class, "npcShelf"); - GameRegistry.registerBlock(sign, ItemBlock.class, "npcSign"); - GameRegistry.registerBlock(beam, ItemBlock.class, "npcBeam"); - GameRegistry.registerBlock(book, "npcBook"); - GameRegistry.registerBlock(pedestal, ItemBlock.class, "npcPedestal"); - GameRegistry.registerBlock(crystal, ItemNpcColored.class, "npcCrystalBlock"); - GameRegistry.registerBlock(campfire, "npcCampfire"); - GameRegistry.registerBlock(lantern, "npcLamp"); - GameRegistry.registerBlock(candle, "npcCandle"); - GameRegistry.registerBlock(campfire_unlit, "npcCampfireUnlit"); - GameRegistry.registerBlock(candle_unlit, "npcLampUnlit"); - GameRegistry.registerBlock(lantern_unlit, "npcCandleUnlit"); + GameRegistry.registerBlock(chair, ItemBlock.class, "npcChair"); + GameRegistry.registerBlock(crate, ItemBlock.class, "npcCrate"); + GameRegistry.registerBlock(weaponsRack, ItemBlock.class, "npcWeaponRack"); + GameRegistry.registerBlock(couchWool, ItemBlock.class, "npcCouchWool"); + GameRegistry.registerBlock(couchWood, ItemBlock.class, "npcCouchWood"); + GameRegistry.registerBlock(table, ItemBlock.class, "npcTable"); + GameRegistry.registerBlock(stool, ItemBlock.class, "npcStool"); + GameRegistry.registerBlock(placeholder, ItemPlaceholder.class, "npcPlaceholder"); + GameRegistry.registerBlock(bigsign, "npcBigSign"); + GameRegistry.registerBlock(barrel, ItemBlock.class, "npcBarrel"); + GameRegistry.registerBlock(tombstone, ItemBlock.class, "npcTombstone"); + GameRegistry.registerBlock(shelf, ItemBlock.class, "npcShelf"); + GameRegistry.registerBlock(sign, ItemBlock.class, "npcSign"); + GameRegistry.registerBlock(beam, ItemBlock.class, "npcBeam"); + GameRegistry.registerBlock(book, "npcBook"); + GameRegistry.registerBlock(pedestal, ItemBlock.class, "npcPedestal"); + GameRegistry.registerBlock(crystal, ItemNpcColored.class, "npcCrystalBlock"); + GameRegistry.registerBlock(campfire, "npcCampfire"); + GameRegistry.registerBlock(lantern, "npcLamp"); + GameRegistry.registerBlock(candle, "npcCandle"); + GameRegistry.registerBlock(campfire_unlit, "npcCampfireUnlit"); + GameRegistry.registerBlock(candle_unlit, "npcLampUnlit"); + GameRegistry.registerBlock(lantern_unlit, "npcCandleUnlit"); - Item.getItemFromBlock(banner).setHasSubtypes(true); - Item.getItemFromBlock(wallBanner).setHasSubtypes(true); - Item.getItemFromBlock(tallLamp).setHasSubtypes(true); + Item.getItemFromBlock(banner).setHasSubtypes(true); + Item.getItemFromBlock(wallBanner).setHasSubtypes(true); + Item.getItemFromBlock(tallLamp).setHasSubtypes(true); Item.getItemFromBlock(shortLamp).setHasSubtypes(true); - Item.getItemFromBlock(chair).setHasSubtypes(true); - Item.getItemFromBlock(crate).setHasSubtypes(true); - Item.getItemFromBlock(weaponsRack).setHasSubtypes(true); - Item.getItemFromBlock(couchWool).setHasSubtypes(true); - Item.getItemFromBlock(couchWood).setHasSubtypes(true); - Item.getItemFromBlock(table).setHasSubtypes(true); - Item.getItemFromBlock(stool).setHasSubtypes(true); - Item.getItemFromBlock(barrel).setHasSubtypes(true); - Item.getItemFromBlock(tombstone).setHasSubtypes(true); - Item.getItemFromBlock(shelf).setHasSubtypes(true); - Item.getItemFromBlock(sign).setHasSubtypes(true); - Item.getItemFromBlock(beam).setHasSubtypes(true); - Item.getItemFromBlock(pedestal).setHasSubtypes(true); + Item.getItemFromBlock(chair).setHasSubtypes(true); + Item.getItemFromBlock(crate).setHasSubtypes(true); + Item.getItemFromBlock(weaponsRack).setHasSubtypes(true); + Item.getItemFromBlock(couchWool).setHasSubtypes(true); + Item.getItemFromBlock(couchWood).setHasSubtypes(true); + Item.getItemFromBlock(table).setHasSubtypes(true); + Item.getItemFromBlock(stool).setHasSubtypes(true); + Item.getItemFromBlock(barrel).setHasSubtypes(true); + Item.getItemFromBlock(tombstone).setHasSubtypes(true); + Item.getItemFromBlock(shelf).setHasSubtypes(true); + Item.getItemFromBlock(sign).setHasSubtypes(true); + Item.getItemFromBlock(beam).setHasSubtypes(true); + Item.getItemFromBlock(pedestal).setHasSubtypes(true); - tabBlocks.item = Item.getItemFromBlock(couchWool); - tabBlocks.meta = 1; - } + tabBlocks.item = Item.getItemFromBlock(couchWool); + tabBlocks.meta = 1; + } - banjo = new ItemMusicBanjo().setUnlocalizedName("npcBanjo").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcBanjo"); - violin = new ItemMusicViolin().setUnlocalizedName("npcViolin").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcViolin"); - violinbow = new ItemNpcInterface().setUnlocalizedName("npcViolinBow").setFull3D().setMaxStackSize(1).setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcViolinBow"); - harp = new ItemMusicViolin().setUnlocalizedName("npcHarp").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcHarp"); - guitar = new ItemMusicBanjo().setUnlocalizedName("npcGuitar").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcGuitar"); - frenchHorn = new ItemMusic().setRotated().setUnlocalizedName("npcFrenchHorn").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcFrenchHorn"); - ocarina = new ItemMusicOracina().setUnlocalizedName("npcOcarina").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcOcarina"); - clarinet = new ItemMusicClarinet().setUnlocalizedName("npcClarinet").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcClarinet"); + banjo = new ItemMusicBanjo().setUnlocalizedName("npcBanjo").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcBanjo"); + violin = new ItemMusicViolin().setUnlocalizedName("npcViolin").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcViolin"); + violinbow = new ItemNpcInterface().setUnlocalizedName("npcViolinBow").setFull3D().setMaxStackSize(1).setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcViolinBow"); + harp = new ItemMusicViolin().setUnlocalizedName("npcHarp").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcHarp"); + guitar = new ItemMusicBanjo().setUnlocalizedName("npcGuitar").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcGuitar"); + frenchHorn = new ItemMusic().setRotated().setUnlocalizedName("npcFrenchHorn").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcFrenchHorn"); + ocarina = new ItemMusicOracina().setUnlocalizedName("npcOcarina").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcOcarina"); + clarinet = new ItemMusicClarinet().setUnlocalizedName("npcClarinet").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcClarinet"); - if(!ConfigItem.DisableExtraItems){ - tabArmor = new CreativeTabNpcs("cnpcsa"); - tabWeapon = new CreativeTabNpcs("cnpcsw"); + if (!ConfigItem.DisableExtraItems) { + tabArmor = new CreativeTabNpcs("cnpcsa"); + tabWeapon = new CreativeTabNpcs("cnpcsw"); - gunWood = new ItemGun(26820,EnumNpcToolMaterial.WOOD).setUnlocalizedName("npcWoodenGun").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcWoodenGun"); - bulletWood = new ItemBullet(26821,EnumNpcToolMaterial.WOOD).setUnlocalizedName("npcWoodenBullet").setMaxStackSize(64).setTextureName("customnpcs:npcWoodenBullet"); + gunWood = new ItemGun(26820, EnumNpcToolMaterial.WOOD).setUnlocalizedName("npcWoodenGun").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcWoodenGun"); + bulletWood = new ItemBullet(26821, EnumNpcToolMaterial.WOOD).setUnlocalizedName("npcWoodenBullet").setMaxStackSize(64).setTextureName("customnpcs:npcWoodenBullet"); - gunStone = new ItemGun(26822,EnumNpcToolMaterial.STONE).setUnlocalizedName("npcStoneGun").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcStoneGun"); - bulletStone = new ItemBullet(26823,EnumNpcToolMaterial.STONE).setUnlocalizedName("npcStoneBullet").setMaxStackSize(64).setTextureName("customnpcs:npcStoneBullet"); + gunStone = new ItemGun(26822, EnumNpcToolMaterial.STONE).setUnlocalizedName("npcStoneGun").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcStoneGun"); + bulletStone = new ItemBullet(26823, EnumNpcToolMaterial.STONE).setUnlocalizedName("npcStoneBullet").setMaxStackSize(64).setTextureName("customnpcs:npcStoneBullet"); - gunIron = new ItemGun(26824,EnumNpcToolMaterial.IRON).setUnlocalizedName("npcIronGun").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcIronGun"); - bulletIron = new ItemBullet(26825,EnumNpcToolMaterial.IRON).setUnlocalizedName("npcIronBullet").setMaxStackSize(64).setTextureName("customnpcs:npcIronBullet"); + gunIron = new ItemGun(26824, EnumNpcToolMaterial.IRON).setUnlocalizedName("npcIronGun").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcIronGun"); + bulletIron = new ItemBullet(26825, EnumNpcToolMaterial.IRON).setUnlocalizedName("npcIronBullet").setMaxStackSize(64).setTextureName("customnpcs:npcIronBullet"); - gunGold = new ItemGun(26826,EnumNpcToolMaterial.GOLD).setUnlocalizedName("npcGoldGun").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcGoldGun"); - bulletGold = new ItemBullet(26827,EnumNpcToolMaterial.GOLD).setUnlocalizedName("npcGoldenBullet").setMaxStackSize(64).setTextureName("customnpcs:npcGoldenBullet"); + gunGold = new ItemGun(26826, EnumNpcToolMaterial.GOLD).setUnlocalizedName("npcGoldGun").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcGoldGun"); + bulletGold = new ItemBullet(26827, EnumNpcToolMaterial.GOLD).setUnlocalizedName("npcGoldenBullet").setMaxStackSize(64).setTextureName("customnpcs:npcGoldenBullet"); - gunDiamond = new ItemGun(26828,EnumNpcToolMaterial.DIA).setUnlocalizedName("npcDiamondGun").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcDiamondGun"); - bulletDiamond = new ItemBullet(26829,EnumNpcToolMaterial.DIA).setUnlocalizedName("npcDiamondBullet").setMaxStackSize(64).setTextureName("customnpcs:npcDiamondBullet"); + gunDiamond = new ItemGun(26828, EnumNpcToolMaterial.DIA).setUnlocalizedName("npcDiamondGun").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcDiamondGun"); + bulletDiamond = new ItemBullet(26829, EnumNpcToolMaterial.DIA).setUnlocalizedName("npcDiamondBullet").setMaxStackSize(64).setTextureName("customnpcs:npcDiamondBullet"); - gunBronze = new ItemGun(26830,EnumNpcToolMaterial.BRONZE).setUnlocalizedName("npcBronzeGun").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcBronzeGun"); - bulletBronze = new ItemBullet(26831,EnumNpcToolMaterial.BRONZE).setUnlocalizedName("npcBronzeBullet").setMaxStackSize(64).setTextureName("customnpcs:npcBronzeBullet"); + gunBronze = new ItemGun(26830, EnumNpcToolMaterial.BRONZE).setUnlocalizedName("npcBronzeGun").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcBronzeGun"); + bulletBronze = new ItemBullet(26831, EnumNpcToolMaterial.BRONZE).setUnlocalizedName("npcBronzeBullet").setMaxStackSize(64).setTextureName("customnpcs:npcBronzeBullet"); - gunEmerald = new ItemGun(26832,EnumNpcToolMaterial.EMERALD).setUnlocalizedName("npcEmeraldGun").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcEmeraldGun"); - bulletEmerald = new ItemBullet(26833,EnumNpcToolMaterial.EMERALD).setUnlocalizedName("npcEmeraldBullet").setMaxStackSize(64).setTextureName("customnpcs:npcEmeraldBullet"); + gunEmerald = new ItemGun(26832, EnumNpcToolMaterial.EMERALD).setUnlocalizedName("npcEmeraldGun").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcEmeraldGun"); + bulletEmerald = new ItemBullet(26833, EnumNpcToolMaterial.EMERALD).setUnlocalizedName("npcEmeraldBullet").setMaxStackSize(64).setTextureName("customnpcs:npcEmeraldBullet"); - gunMachine = new ItemMachineGun(26834).setUnlocalizedName("npcMachineGun").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcMachineGun"); - bulletBlack = new ItemBullet(26835,EnumNpcToolMaterial.WOOD).setUnlocalizedName("npcBlackBullet").setMaxStackSize(64).setTextureName("customnpcs:npcBlackBullet"); + gunMachine = new ItemMachineGun(26834).setUnlocalizedName("npcMachineGun").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcMachineGun"); + bulletBlack = new ItemBullet(26835, EnumNpcToolMaterial.WOOD).setUnlocalizedName("npcBlackBullet").setMaxStackSize(64).setTextureName("customnpcs:npcBlackBullet"); - ToolMaterial bronze = EnumHelper.addToolMaterial("BRONZE", 2, 170, 5.0F, 2, 15); - ToolMaterial emerald = EnumHelper.addToolMaterial("REALEMERALD", 3, 1000, 8.0F, 4, 10); - ToolMaterial demonic = EnumHelper.addToolMaterial("DEMONIC", 3, 100, 8.0F, 6, 22); - ToolMaterial frost = EnumHelper.addToolMaterial("FROST", 2, 59, 6.0F, 3, 5); - ToolMaterial mithril = EnumHelper.addToolMaterial("MITHRIL", 3, 3000, 8.0F, 3.0F, 10); + ToolMaterial bronze = EnumHelper.addToolMaterial("BRONZE", 2, 170, 5.0F, 2, 15); + ToolMaterial emerald = EnumHelper.addToolMaterial("REALEMERALD", 3, 1000, 8.0F, 4, 10); + ToolMaterial demonic = EnumHelper.addToolMaterial("DEMONIC", 3, 100, 8.0F, 6, 22); + ToolMaterial frost = EnumHelper.addToolMaterial("FROST", 2, 59, 6.0F, 3, 5); + ToolMaterial mithril = EnumHelper.addToolMaterial("MITHRIL", 3, 3000, 8.0F, 3.0F, 10); - tridentWood = new ItemSpear(26840,ToolMaterial.WOOD).setUnlocalizedName("npcWoodenTrident").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcWoodenTrident"); - tridentStone = new ItemSpear(26841,ToolMaterial.STONE).setUnlocalizedName("npcStoneTrident").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcStoneTrident"); - tridentIron = new ItemSpear(26842,ToolMaterial.IRON).setUnlocalizedName("npcIronTrident").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcIronTrident"); - tridentGold = new ItemSpear(26843,ToolMaterial.GOLD).setUnlocalizedName("npcGoldTrident").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcGoldTrident"); - tridentDiamond = new ItemSpear(26844,ToolMaterial.EMERALD).setUnlocalizedName("npcDiamondTrident").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcDiamondTrident"); - tridentBronze = new ItemSpear(26845,bronze).setUnlocalizedName("npcBronzeTrident").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcBronzeTrident"); - tridentEmerald = new ItemSpear(26846,emerald).setUnlocalizedName("npcEmeraldTrident").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcEmeraldTrident"); - tridentCurse = new ItemSpear(26847,emerald).setUnlocalizedName("npcCursedTrident").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcCursedTrident"); - tridentDemonic = new ItemSpear(26847,demonic).setUnlocalizedName("npcDemonicTrident").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcDemonicTrident"); - tridentFrost = new ItemSpear(26847,frost).setUnlocalizedName("npcFrostTrident").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcFrostTrident"); - tridentMithril = new ItemSpear(26847,mithril).setUnlocalizedName("npcMithrilTrident").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcMithrilTrident"); + tridentWood = new ItemSpear(26840, ToolMaterial.WOOD).setUnlocalizedName("npcWoodenTrident").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcWoodenTrident"); + tridentStone = new ItemSpear(26841, ToolMaterial.STONE).setUnlocalizedName("npcStoneTrident").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcStoneTrident"); + tridentIron = new ItemSpear(26842, ToolMaterial.IRON).setUnlocalizedName("npcIronTrident").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcIronTrident"); + tridentGold = new ItemSpear(26843, ToolMaterial.GOLD).setUnlocalizedName("npcGoldTrident").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcGoldTrident"); + tridentDiamond = new ItemSpear(26844, ToolMaterial.EMERALD).setUnlocalizedName("npcDiamondTrident").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcDiamondTrident"); + tridentBronze = new ItemSpear(26845, bronze).setUnlocalizedName("npcBronzeTrident").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcBronzeTrident"); + tridentEmerald = new ItemSpear(26846, emerald).setUnlocalizedName("npcEmeraldTrident").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcEmeraldTrident"); + tridentCurse = new ItemSpear(26847, emerald).setUnlocalizedName("npcCursedTrident").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcCursedTrident"); + tridentDemonic = new ItemSpear(26847, demonic).setUnlocalizedName("npcDemonicTrident").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcDemonicTrident"); + tridentFrost = new ItemSpear(26847, frost).setUnlocalizedName("npcFrostTrident").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcFrostTrident"); + tridentMithril = new ItemSpear(26847, mithril).setUnlocalizedName("npcMithrilTrident").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcMithrilTrident"); - spellNature = new ItemNpcInterface(26930).setUnlocalizedName("npcNatureSpell").setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcNatureSpell"); - spellArcane = new ItemNpcInterface(26931).setUnlocalizedName("npcArcaneSpell").setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcArcaneSpell"); - spellLightning = new ItemNpcInterface(26932).setUnlocalizedName("npcLightningSpell").setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcLightningSpell"); - spellIce = new ItemNpcInterface(26933).setUnlocalizedName("npcIceSpell").setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcIceSpell"); - spellFire = new ItemNpcInterface(26934).setUnlocalizedName("npcFireSpell").setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcFireSpell"); - spellDark = new ItemNpcInterface(26935).setUnlocalizedName("npcDarkSpell").setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcDarkSpell"); - spellHoly = new ItemNpcInterface(26936).setUnlocalizedName("npcHolySpell").setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcHolySpell"); + spellNature = new ItemNpcInterface(26930).setUnlocalizedName("npcNatureSpell").setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcNatureSpell"); + spellArcane = new ItemNpcInterface(26931).setUnlocalizedName("npcArcaneSpell").setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcArcaneSpell"); + spellLightning = new ItemNpcInterface(26932).setUnlocalizedName("npcLightningSpell").setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcLightningSpell"); + spellIce = new ItemNpcInterface(26933).setUnlocalizedName("npcIceSpell").setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcIceSpell"); + spellFire = new ItemNpcInterface(26934).setUnlocalizedName("npcFireSpell").setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcFireSpell"); + spellDark = new ItemNpcInterface(26935).setUnlocalizedName("npcDarkSpell").setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcDarkSpell"); + spellHoly = new ItemNpcInterface(26936).setUnlocalizedName("npcHolySpell").setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcHolySpell"); - orb = new ItemOrb(26937).setUnlocalizedName("npcOrb").setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcOrb"); - mana = new ItemNpcInterface(26938).setUnlocalizedName("npcMana").setCreativeTab(CustomItems.tabWeapon).setTextureName("customnpcs:npcMana"); - Item brokenOrb = new ItemOrb(26939).setUnlocalizedName("npcBrokenOrb").setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcBrokenOrb"); + orb = new ItemOrb(26937).setUnlocalizedName("npcOrb").setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcOrb"); + mana = new ItemNpcInterface(26938).setUnlocalizedName("npcMana").setCreativeTab(CustomItems.tabWeapon).setTextureName("customnpcs:npcMana"); + Item brokenOrb = new ItemOrb(26939).setUnlocalizedName("npcBrokenOrb").setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcBrokenOrb"); - kunai = new ItemKunai(26910,ToolMaterial.IRON).setUnlocalizedName("npcKunai").setMaxStackSize(1).setFull3D().setTextureName("customnpcs:npcKunai"); - Item kunai = new ItemKunaiReversed(26911,ToolMaterial.IRON).setUnlocalizedName("npcReverseKunai").setMaxStackSize(1).setFull3D().setTextureName("customnpcs:npcReverseKunai"); - kunai = new ItemThrowingShuriken(26912).setRotating().setDropItem().setUnlocalizedName("npcShuriken").setFull3D().setTextureName("customnpcs:npcShuriken"); - shuriken = new ItemThrowingWeapon(26913).setDamage(4).setRotating().setDropItem().setUnlocalizedName("npcGiantShuriken").setFull3D().setTextureName("customnpcs:npcGiantShuriken"); - Item katana = new ItemNpcWeaponInterface(26914,ToolMaterial.IRON).setUnlocalizedName("npcKatana").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcKatana"); - Item knive = new ItemNpcWeaponInterface(26915,ToolMaterial.IRON).setUnlocalizedName("npcKukri").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcKukri"); + kunai = new ItemKunai(26910, ToolMaterial.IRON).setUnlocalizedName("npcKunai").setMaxStackSize(1).setFull3D().setTextureName("customnpcs:npcKunai"); + Item kunai = new ItemKunaiReversed(26911, ToolMaterial.IRON).setUnlocalizedName("npcReverseKunai").setMaxStackSize(1).setFull3D().setTextureName("customnpcs:npcReverseKunai"); + kunai = new ItemThrowingShuriken(26912).setRotating().setDropItem().setUnlocalizedName("npcShuriken").setFull3D().setTextureName("customnpcs:npcShuriken"); + shuriken = new ItemThrowingWeapon(26913).setDamage(4).setRotating().setDropItem().setUnlocalizedName("npcGiantShuriken").setFull3D().setTextureName("customnpcs:npcGiantShuriken"); + Item katana = new ItemNpcWeaponInterface(26914, ToolMaterial.IRON).setUnlocalizedName("npcKatana").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcKatana"); + Item knive = new ItemNpcWeaponInterface(26915, ToolMaterial.IRON).setUnlocalizedName("npcKukri").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcKukri"); - swordBronze = new ItemNpcWeaponInterface(bronze).setUnlocalizedName("npcBronzeSword").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcBronzeSword"); - swordEmerald = new ItemNpcWeaponInterface(emerald).setUnlocalizedName("npcEmeraldSword").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcEmeraldSword"); - swordDemonic = new ItemNpcWeaponInterface(demonic).setUnlocalizedName("npcDemonicSword").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcDemonicSword"); - swordFrost = new ItemNpcWeaponInterface(frost).setUnlocalizedName("npcFrostSword").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcFrostSword"); - swordMithril = new ItemNpcWeaponInterface(mithril).setUnlocalizedName("npcMithrilSword").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcMithrilSword"); + swordBronze = new ItemNpcWeaponInterface(bronze).setUnlocalizedName("npcBronzeSword").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcBronzeSword"); + swordEmerald = new ItemNpcWeaponInterface(emerald).setUnlocalizedName("npcEmeraldSword").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcEmeraldSword"); + swordDemonic = new ItemNpcWeaponInterface(demonic).setUnlocalizedName("npcDemonicSword").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcDemonicSword"); + swordFrost = new ItemNpcWeaponInterface(frost).setUnlocalizedName("npcFrostSword").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcFrostSword"); + swordMithril = new ItemNpcWeaponInterface(mithril).setUnlocalizedName("npcMithrilSword").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcMithrilSword"); - Item golf = new ItemSpear(26800,ToolMaterial.IRON).setUnlocalizedName("npcGolfClub").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcGolfClub"); - Item magicwand = new ItemWand(26801).setUnlocalizedName("npcMagicWand").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcMagicWand"); - Item chickenSword = new ItemNpcInterface(26802).setUnlocalizedName("npcChickenSword").setFull3D().setMaxStackSize(1).setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcChickenSword"); - Item handcuffs = new ItemNpcInterface(26803).setUnlocalizedName("npcHandCuffs").setFull3D().setMaxStackSize(1).setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcHandCuffs"); - Item hammer = new ItemNpcWeaponInterface(26804,ToolMaterial.STONE).setUnlocalizedName("npcHammer").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcHammer"); - Item baseballbat = new ItemNpcWeaponInterface(26805,ToolMaterial.IRON).setUnlocalizedName("npcBaseballBat").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcBaseballBat"); - Item leadpipe = new ItemNpcWeaponInterface(26806,ToolMaterial.IRON).setUnlocalizedName("npcLeadPipe").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcLeadPipe"); - Item cleaver = new ItemNpcWeaponInterface(26807,ToolMaterial.IRON).setUnlocalizedName("npcCleaver").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcCleaver"); - Item saber = new ItemNpcWeaponInterface(26808,ToolMaterial.IRON).setUnlocalizedName("npcSaber").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcSaber"); - Item hockey = new ItemSpear(26809,ToolMaterial.IRON).setUnlocalizedName("npcHockeyStick").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcHockeyStick"); - hammer = new ItemSpear(26810,ToolMaterial.IRON).setUnlocalizedName("npcSledgeHammer").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcSledgeHammer"); - Item bottle = new ItemNpcWeaponInterface(26811,ToolMaterial.IRON).setUnlocalizedName("npcBrokenBottle").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcBrokenBottle"); - knive = new ItemDagger(26812,ToolMaterial.STONE).setUnlocalizedName("npcCombatKnive").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcCombatKnive"); - Item lighter = new ItemFlintAndSteel().setUnlocalizedName("npcLighter").setMaxStackSize(1).setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcLighter"); - Item macuahuitl = new ItemNpcWeaponInterface(26714,ToolMaterial.IRON).setUnlocalizedName("npcMacuahuitl").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcMacuahuitl"); - Item bowstaff = new ItemGlaive(26715,ToolMaterial.IRON).setUnlocalizedName("npcBoStaff").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcBoStaff"); - Item sai = new ItemDagger(26757,ToolMaterial.IRON).setUnlocalizedName("npcSaiBlade").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcSaiBlade"); - Item slingshot = new ItemSlingshot(26767).setUnlocalizedName("npcSlingshot").setFull3D().setTextureName("customnpcs:npcSlingshot"); - Item musket = new ItemMusket(26758).setUnlocalizedName("npcMusket").setFull3D().setTextureName("customnpcs:npcMusket").setMaxStackSize(1); - Item leaf = new ItemLeafBlade(26758,ToolMaterial.IRON).setUnlocalizedName("npcLeafBlade").setFull3D().setTextureName("customnpcs:npcLeafBlade").setMaxStackSize(1); + Item golf = new ItemSpear(26800, ToolMaterial.IRON).setUnlocalizedName("npcGolfClub").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcGolfClub"); + Item magicwand = new ItemWand(26801).setUnlocalizedName("npcMagicWand").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcMagicWand"); + Item chickenSword = new ItemNpcInterface(26802).setUnlocalizedName("npcChickenSword").setFull3D().setMaxStackSize(1).setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcChickenSword"); + Item handcuffs = new ItemNpcInterface(26803).setUnlocalizedName("npcHandCuffs").setFull3D().setMaxStackSize(1).setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcHandCuffs"); + Item hammer = new ItemNpcWeaponInterface(26804, ToolMaterial.STONE).setUnlocalizedName("npcHammer").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcHammer"); + Item baseballbat = new ItemNpcWeaponInterface(26805, ToolMaterial.IRON).setUnlocalizedName("npcBaseballBat").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcBaseballBat"); + Item leadpipe = new ItemNpcWeaponInterface(26806, ToolMaterial.IRON).setUnlocalizedName("npcLeadPipe").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcLeadPipe"); + Item cleaver = new ItemNpcWeaponInterface(26807, ToolMaterial.IRON).setUnlocalizedName("npcCleaver").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcCleaver"); + Item saber = new ItemNpcWeaponInterface(26808, ToolMaterial.IRON).setUnlocalizedName("npcSaber").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcSaber"); + Item hockey = new ItemSpear(26809, ToolMaterial.IRON).setUnlocalizedName("npcHockeyStick").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcHockeyStick"); + hammer = new ItemSpear(26810, ToolMaterial.IRON).setUnlocalizedName("npcSledgeHammer").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcSledgeHammer"); + Item bottle = new ItemNpcWeaponInterface(26811, ToolMaterial.IRON).setUnlocalizedName("npcBrokenBottle").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcBrokenBottle"); + knive = new ItemDagger(26812, ToolMaterial.STONE).setUnlocalizedName("npcCombatKnive").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcCombatKnive"); + Item lighter = new ItemFlintAndSteel().setUnlocalizedName("npcLighter").setMaxStackSize(1).setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcLighter"); + Item macuahuitl = new ItemNpcWeaponInterface(26714, ToolMaterial.IRON).setUnlocalizedName("npcMacuahuitl").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcMacuahuitl"); + Item bowstaff = new ItemGlaive(26715, ToolMaterial.IRON).setUnlocalizedName("npcBoStaff").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcBoStaff"); + Item sai = new ItemDagger(26757, ToolMaterial.IRON).setUnlocalizedName("npcSaiBlade").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcSaiBlade"); + Item slingshot = new ItemSlingshot(26767).setUnlocalizedName("npcSlingshot").setFull3D().setTextureName("customnpcs:npcSlingshot"); + Item musket = new ItemMusket(26758).setUnlocalizedName("npcMusket").setFull3D().setTextureName("customnpcs:npcMusket").setMaxStackSize(1); + Item leaf = new ItemLeafBlade(26758, ToolMaterial.IRON).setUnlocalizedName("npcLeafBlade").setFull3D().setTextureName("customnpcs:npcLeafBlade").setMaxStackSize(1); - Item crossbow = new ItemCrossbow(26768).setUnlocalizedName("npcCrossbow").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcCrossbow"); - crossbowBolt = new ItemBullet(26769,EnumNpcToolMaterial.WOOD).setUnlocalizedName("npcCrossBolt").setMaxStackSize(64).setTextureName("customnpcs:npcCrossBolt"); + Item crossbow = new ItemCrossbow(26768).setUnlocalizedName("npcCrossbow").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcCrossbow"); + crossbowBolt = new ItemBullet(26769, EnumNpcToolMaterial.WOOD).setUnlocalizedName("npcCrossBolt").setMaxStackSize(64).setTextureName("customnpcs:npcCrossBolt"); - Item batton = new ItemNpcWeaponInterface(26814,ToolMaterial.STONE).setUnlocalizedName("npcBatton").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcBatton"); - Item chainsaw = new ItemGunChainsaw(26815,ToolMaterial.EMERALD).setUnlocalizedName("npcGunChainsaw").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcGunChainsaw"); - Item rapier = new ItemNpcWeaponInterface(26816,ToolMaterial.IRON).setUnlocalizedName("npcRapier").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcRapier"); - Item crowbar = new ItemNpcWeaponInterface(26817,ToolMaterial.IRON).setUnlocalizedName("npcCrowbar").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcCrowbar"); - Item pipewrench = new ItemNpcWeaponInterface(26818,ToolMaterial.IRON).setUnlocalizedName("npcPipeWrench").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcPipeWrench"); - Item swiss = new ItemDagger(26819,ToolMaterial.IRON).setUnlocalizedName("npcSwissArmyKnife").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcSwissArmyKnife"); - Item wrench = new ItemNpcWeaponInterface(26836,ToolMaterial.IRON).setUnlocalizedName("npcWrench").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcWrench"); - excalibur = new ItemExcalibur(26799,ToolMaterial.EMERALD).setUnlocalizedName("npcExcalibur").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcExcalibur"); + Item batton = new ItemNpcWeaponInterface(26814, ToolMaterial.STONE).setUnlocalizedName("npcBatton").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcBatton"); + Item chainsaw = new ItemGunChainsaw(26815, ToolMaterial.EMERALD).setUnlocalizedName("npcGunChainsaw").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcGunChainsaw"); + Item rapier = new ItemNpcWeaponInterface(26816, ToolMaterial.IRON).setUnlocalizedName("npcRapier").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcRapier"); + Item crowbar = new ItemNpcWeaponInterface(26817, ToolMaterial.IRON).setUnlocalizedName("npcCrowbar").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcCrowbar"); + Item pipewrench = new ItemNpcWeaponInterface(26818, ToolMaterial.IRON).setUnlocalizedName("npcPipeWrench").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcPipeWrench"); + Item swiss = new ItemDagger(26819, ToolMaterial.IRON).setUnlocalizedName("npcSwissArmyKnife").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcSwissArmyKnife"); + Item wrench = new ItemNpcWeaponInterface(26836, ToolMaterial.IRON).setUnlocalizedName("npcWrench").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcWrench"); + excalibur = new ItemExcalibur(26799, ToolMaterial.EMERALD).setUnlocalizedName("npcExcalibur").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcExcalibur"); - Item shield = new ItemShield(26729,EnumNpcToolMaterial.WOOD).setUnlocalizedName("npcWoodenShield").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcWoodenShield"); - shield = new ItemShield(26730,EnumNpcToolMaterial.STONE).setUnlocalizedName("npcStoneShield").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcStoneShield"); - shield = new ItemShield(26736,EnumNpcToolMaterial.IRON).setUnlocalizedName("npcIronShield").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcIronShield"); - shield = new ItemShield(26737,EnumNpcToolMaterial.GOLD).setUnlocalizedName("npcGoldenShield").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcGoldenShield"); - shield = new ItemShield(26738,EnumNpcToolMaterial.DIA).setUnlocalizedName("npcDiaShield").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcDiaShield"); - shield = new ItemShield(26739,EnumNpcToolMaterial.BRONZE).setUnlocalizedName("npcBronzeShield").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcBronzeShield"); - shield = new ItemShield(26728,EnumNpcToolMaterial.EMERALD).setUnlocalizedName("npcEmeraldShield").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcEmeraldShield"); - shield = new ItemShield(26739,EnumNpcToolMaterial.DEMONIC).setUnlocalizedName("npcDemonicShield").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcDemonicShield"); - shield = new ItemRotatedShield(26739,EnumNpcToolMaterial.FROST).setUnlocalizedName("npcFrostShield").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcFrostShield"); - shield = new ItemRotatedShield(26739,EnumNpcToolMaterial.MITHRIL).setUnlocalizedName("npcMithrilShield").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcMithrilShield"); + Item shield = new ItemShield(26729, EnumNpcToolMaterial.WOOD).setUnlocalizedName("npcWoodenShield").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcWoodenShield"); + shield = new ItemShield(26730, EnumNpcToolMaterial.STONE).setUnlocalizedName("npcStoneShield").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcStoneShield"); + shield = new ItemShield(26736, EnumNpcToolMaterial.IRON).setUnlocalizedName("npcIronShield").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcIronShield"); + shield = new ItemShield(26737, EnumNpcToolMaterial.GOLD).setUnlocalizedName("npcGoldenShield").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcGoldenShield"); + shield = new ItemShield(26738, EnumNpcToolMaterial.DIA).setUnlocalizedName("npcDiaShield").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcDiaShield"); + shield = new ItemShield(26739, EnumNpcToolMaterial.BRONZE).setUnlocalizedName("npcBronzeShield").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcBronzeShield"); + shield = new ItemShield(26728, EnumNpcToolMaterial.EMERALD).setUnlocalizedName("npcEmeraldShield").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcEmeraldShield"); + shield = new ItemShield(26739, EnumNpcToolMaterial.DEMONIC).setUnlocalizedName("npcDemonicShield").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcDemonicShield"); + shield = new ItemRotatedShield(26739, EnumNpcToolMaterial.FROST).setUnlocalizedName("npcFrostShield").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcFrostShield"); + shield = new ItemRotatedShield(26739, EnumNpcToolMaterial.MITHRIL).setUnlocalizedName("npcMithrilShield").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcMithrilShield"); - shield = new ItemRotatedShield(26740,EnumNpcToolMaterial.WOOD).setUnlocalizedName("npcFullWoodenShield").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcFullWoodenShield"); - shield = new ItemRotatedShield(26741,EnumNpcToolMaterial.STONE).setUnlocalizedName("npcFullStoneShield").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcFullStoneShield"); - shield = new ItemRotatedShield(26742,EnumNpcToolMaterial.IRON).setUnlocalizedName("npcFullIronShield").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcFullIronShield"); - shield = new ItemRotatedShield(26743,EnumNpcToolMaterial.GOLD).setUnlocalizedName("npcFullGoldenShield").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcFullGoldenShield"); - shield = new ItemRotatedShield(26744,EnumNpcToolMaterial.DIA).setUnlocalizedName("npcFullDiaShield").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcFullDiaShield"); - shield = new ItemRotatedShield(26745,EnumNpcToolMaterial.BRONZE).setUnlocalizedName("npcFullBronzeShield").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcFullBronzeShield"); - shield = new ItemRotatedShield(26727,EnumNpcToolMaterial.EMERALD).setUnlocalizedName("npcFullEmeraldShield").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcFullEmeraldShield"); - shield = new ItemRotatedShield(26727,EnumNpcToolMaterial.DEMONIC).setUnlocalizedName("npcFullDemonicShield").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcFullDemonicShield"); - shield = new ItemRotatedShield(26727,EnumNpcToolMaterial.FROST).setUnlocalizedName("npcFullFrostShield").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcFullFrostShield"); - shield = new ItemRotatedShield(26727,EnumNpcToolMaterial.MITHRIL).setUnlocalizedName("npcFullMithrilShield").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcFullMithrilShield"); + shield = new ItemRotatedShield(26740, EnumNpcToolMaterial.WOOD).setUnlocalizedName("npcFullWoodenShield").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcFullWoodenShield"); + shield = new ItemRotatedShield(26741, EnumNpcToolMaterial.STONE).setUnlocalizedName("npcFullStoneShield").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcFullStoneShield"); + shield = new ItemRotatedShield(26742, EnumNpcToolMaterial.IRON).setUnlocalizedName("npcFullIronShield").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcFullIronShield"); + shield = new ItemRotatedShield(26743, EnumNpcToolMaterial.GOLD).setUnlocalizedName("npcFullGoldenShield").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcFullGoldenShield"); + shield = new ItemRotatedShield(26744, EnumNpcToolMaterial.DIA).setUnlocalizedName("npcFullDiaShield").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcFullDiaShield"); + shield = new ItemRotatedShield(26745, EnumNpcToolMaterial.BRONZE).setUnlocalizedName("npcFullBronzeShield").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcFullBronzeShield"); + shield = new ItemRotatedShield(26727, EnumNpcToolMaterial.EMERALD).setUnlocalizedName("npcFullEmeraldShield").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcFullEmeraldShield"); + shield = new ItemRotatedShield(26727, EnumNpcToolMaterial.DEMONIC).setUnlocalizedName("npcFullDemonicShield").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcFullDemonicShield"); + shield = new ItemRotatedShield(26727, EnumNpcToolMaterial.FROST).setUnlocalizedName("npcFullFrostShield").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcFullFrostShield"); + shield = new ItemRotatedShield(26727, EnumNpcToolMaterial.MITHRIL).setUnlocalizedName("npcFullMithrilShield").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcFullMithrilShield"); - shield = new ItemShield(26746,EnumNpcToolMaterial.IRON).setUnlocalizedName("npcHeaterShield").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcHeaterShield"); - shield = new ItemShield(26747,EnumNpcToolMaterial.IRON).setUnlocalizedName("npcCryscentShield").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcCryscentShield"); - shield = new ItemShield(26748,EnumNpcToolMaterial.IRON).setUnlocalizedName("npcScutumShield").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcScutumShield"); - shield = new ItemRotatedShield(26749,EnumNpcToolMaterial.IRON).setUnlocalizedName("npcTowerShield").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcTowerShield"); + shield = new ItemShield(26746, EnumNpcToolMaterial.IRON).setUnlocalizedName("npcHeaterShield").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcHeaterShield"); + shield = new ItemShield(26747, EnumNpcToolMaterial.IRON).setUnlocalizedName("npcCryscentShield").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcCryscentShield"); + shield = new ItemShield(26748, EnumNpcToolMaterial.IRON).setUnlocalizedName("npcScutumShield").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcScutumShield"); + shield = new ItemRotatedShield(26749, EnumNpcToolMaterial.IRON).setUnlocalizedName("npcTowerShield").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcTowerShield"); - Item spear = new ItemSpear(26750,ToolMaterial.WOOD).setUnlocalizedName("npcWoodenSpear").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcWoodenSpear"); - spear = new ItemSpear(26751,ToolMaterial.STONE).setUnlocalizedName("npcStoneSpear").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcStoneSpear"); - spear = new ItemSpear(26752,ToolMaterial.IRON).setUnlocalizedName("npcIronSpear").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcIronSpear"); - spear = new ItemSpear(26753,ToolMaterial.GOLD).setUnlocalizedName("npcGoldenSpear").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcGoldenSpear"); - spear = new ItemSpear(26754,ToolMaterial.EMERALD).setUnlocalizedName("npcDiamondSpear").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcDiamondSpear"); - spear = new ItemSpear(26755,bronze).setUnlocalizedName("npcBronzeSpear").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcBronzeSpear"); - spear = new ItemSpear(26756,emerald).setUnlocalizedName("npcEmeraldSpear").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcEmeraldSpear"); - spear = new ItemSpear(26756,demonic).setUnlocalizedName("npcDemonicSpear").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcDemonicSpear"); - spear = new ItemSpear(26756,frost).setUnlocalizedName("npcFrostSpear").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcFrostSpear"); - spear = new ItemSpear(26756,mithril).setUnlocalizedName("npcMithrilSpear").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcMithrilSpear"); + Item spear = new ItemSpear(26750, ToolMaterial.WOOD).setUnlocalizedName("npcWoodenSpear").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcWoodenSpear"); + spear = new ItemSpear(26751, ToolMaterial.STONE).setUnlocalizedName("npcStoneSpear").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcStoneSpear"); + spear = new ItemSpear(26752, ToolMaterial.IRON).setUnlocalizedName("npcIronSpear").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcIronSpear"); + spear = new ItemSpear(26753, ToolMaterial.GOLD).setUnlocalizedName("npcGoldenSpear").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcGoldenSpear"); + spear = new ItemSpear(26754, ToolMaterial.EMERALD).setUnlocalizedName("npcDiamondSpear").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcDiamondSpear"); + spear = new ItemSpear(26755, bronze).setUnlocalizedName("npcBronzeSpear").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcBronzeSpear"); + spear = new ItemSpear(26756, emerald).setUnlocalizedName("npcEmeraldSpear").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcEmeraldSpear"); + spear = new ItemSpear(26756, demonic).setUnlocalizedName("npcDemonicSpear").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcDemonicSpear"); + spear = new ItemSpear(26756, frost).setUnlocalizedName("npcFrostSpear").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcFrostSpear"); + spear = new ItemSpear(26756, mithril).setUnlocalizedName("npcMithrilSpear").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcMithrilSpear"); - halberdWood = new ItemSpear(26750,ToolMaterial.WOOD).setUnlocalizedName("npcWoodenHalberd").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcWoodenHalberd"); - halberdStone = new ItemSpear(26751,ToolMaterial.STONE).setUnlocalizedName("npcStoneHalberd").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcStoneHalberd"); - halberdIron = new ItemSpear(26752,ToolMaterial.IRON).setUnlocalizedName("npcIronHalberd").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcIronHalberd"); - halberdGold = new ItemSpear(26753,ToolMaterial.GOLD).setUnlocalizedName("npcGoldenHalberd").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcGoldenHalberd"); - halberdDiamond = new ItemSpear(26754,ToolMaterial.EMERALD).setUnlocalizedName("npcDiamondHalberd").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcDiamondHalberd"); - halberdBronze = new ItemSpear(26755,bronze).setUnlocalizedName("npcBronzeHalberd").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcBronzeHalberd"); - halberdEmerald = new ItemSpear(26756,emerald).setUnlocalizedName("npcEmeraldHalberd").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcEmeraldHalberd"); - halberdDemonic = new ItemSpear(26756,demonic).setUnlocalizedName("npcDemonicHalberd").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcDemonicHalberd"); - halberdFrost = new ItemSpear(26756,frost).setUnlocalizedName("npcFrostHalberd").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcFrostHalberd"); - halberdMithril = new ItemSpear(26756,mithril).setUnlocalizedName("npcMithrilHalberd").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcMithrilHalberd"); + halberdWood = new ItemSpear(26750, ToolMaterial.WOOD).setUnlocalizedName("npcWoodenHalberd").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcWoodenHalberd"); + halberdStone = new ItemSpear(26751, ToolMaterial.STONE).setUnlocalizedName("npcStoneHalberd").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcStoneHalberd"); + halberdIron = new ItemSpear(26752, ToolMaterial.IRON).setUnlocalizedName("npcIronHalberd").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcIronHalberd"); + halberdGold = new ItemSpear(26753, ToolMaterial.GOLD).setUnlocalizedName("npcGoldenHalberd").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcGoldenHalberd"); + halberdDiamond = new ItemSpear(26754, ToolMaterial.EMERALD).setUnlocalizedName("npcDiamondHalberd").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcDiamondHalberd"); + halberdBronze = new ItemSpear(26755, bronze).setUnlocalizedName("npcBronzeHalberd").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcBronzeHalberd"); + halberdEmerald = new ItemSpear(26756, emerald).setUnlocalizedName("npcEmeraldHalberd").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcEmeraldHalberd"); + halberdDemonic = new ItemSpear(26756, demonic).setUnlocalizedName("npcDemonicHalberd").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcDemonicHalberd"); + halberdFrost = new ItemSpear(26756, frost).setUnlocalizedName("npcFrostHalberd").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcFrostHalberd"); + halberdMithril = new ItemSpear(26756, mithril).setUnlocalizedName("npcMithrilHalberd").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcMithrilHalberd"); - battleAxeWood = new ItemBattleAxe(26760,ToolMaterial.WOOD).setUnlocalizedName("npcWoodenBattleAxe").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcWoodenBattleAxe"); - battleAxeStone = new ItemBattleAxe(26761,ToolMaterial.STONE).setUnlocalizedName("npcStoneBattleAxe").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcStoneBattleAxe"); - battleAxeIron = new ItemBattleAxe(26762,ToolMaterial.IRON).setUnlocalizedName("npcIronBattleAxe").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcIronBattleAxe"); - battleAxeGold = new ItemBattleAxe(26763,ToolMaterial.GOLD).setUnlocalizedName("npcGoldenBattleAxe").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcGoldenBattleAxe"); - battleAxeDiamond = new ItemBattleAxe(26764,ToolMaterial.EMERALD).setUnlocalizedName("npcDiamondBattleAxe").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcDiamondBattleAxe"); - battleAxeBronze = new ItemBattleAxe(26765,bronze).setUnlocalizedName("npcBronzeBattleAxe").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcBronzeBattleAxe"); - battleAxeEmerald = new ItemBattleAxe(26766,emerald).setUnlocalizedName("npcEmeraldBattleAxe").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcEmeraldBattleAxe"); - battleAxeDemonic = new ItemBattleAxe(26766,demonic).setUnlocalizedName("npcDemonicBattleAxe").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcDemonicBattleAxe"); - battleAxeFrost = new ItemBattleAxe(26766,frost).setUnlocalizedName("npcFrostBattleAxe").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcFrostBattleAxe"); - battleAxeMithril = new ItemBattleAxe(26766,mithril).setUnlocalizedName("npcMithrilBattleAxe").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcMithrilBattleAxe"); + battleAxeWood = new ItemBattleAxe(26760, ToolMaterial.WOOD).setUnlocalizedName("npcWoodenBattleAxe").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcWoodenBattleAxe"); + battleAxeStone = new ItemBattleAxe(26761, ToolMaterial.STONE).setUnlocalizedName("npcStoneBattleAxe").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcStoneBattleAxe"); + battleAxeIron = new ItemBattleAxe(26762, ToolMaterial.IRON).setUnlocalizedName("npcIronBattleAxe").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcIronBattleAxe"); + battleAxeGold = new ItemBattleAxe(26763, ToolMaterial.GOLD).setUnlocalizedName("npcGoldenBattleAxe").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcGoldenBattleAxe"); + battleAxeDiamond = new ItemBattleAxe(26764, ToolMaterial.EMERALD).setUnlocalizedName("npcDiamondBattleAxe").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcDiamondBattleAxe"); + battleAxeBronze = new ItemBattleAxe(26765, bronze).setUnlocalizedName("npcBronzeBattleAxe").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcBronzeBattleAxe"); + battleAxeEmerald = new ItemBattleAxe(26766, emerald).setUnlocalizedName("npcEmeraldBattleAxe").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcEmeraldBattleAxe"); + battleAxeDemonic = new ItemBattleAxe(26766, demonic).setUnlocalizedName("npcDemonicBattleAxe").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcDemonicBattleAxe"); + battleAxeFrost = new ItemBattleAxe(26766, frost).setUnlocalizedName("npcFrostBattleAxe").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcFrostBattleAxe"); + battleAxeMithril = new ItemBattleAxe(26766, mithril).setUnlocalizedName("npcMithrilBattleAxe").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcMithrilBattleAxe"); - Item warhammer = new ItemWarhammer(26760,ToolMaterial.WOOD).setUnlocalizedName("npcWoodenWarhammer").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcWoodenWarhammer"); - warhammer = new ItemWarhammer(26761,ToolMaterial.STONE).setUnlocalizedName("npcStoneWarhammer").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcStoneWarhammer"); - warhammer = new ItemWarhammer(26762,ToolMaterial.IRON).setUnlocalizedName("npcIronWarhammer").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcIronWarhammer"); - warhammer = new ItemWarhammer(26763,ToolMaterial.GOLD).setUnlocalizedName("npcGoldenWarhammer").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcGoldenWarhammer"); - warhammer = new ItemWarhammer(26764,ToolMaterial.EMERALD).setUnlocalizedName("npcDiamondWarhammer").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcDiamondWarhammer"); - warhammer = new ItemWarhammer(26765,bronze).setUnlocalizedName("npcBronzeWarhammer").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcBronzeWarhammer"); - warhammer = new ItemWarhammer(26766,emerald).setUnlocalizedName("npcEmeraldWarhammer").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcEmeraldWarhammer"); - warhammer = new ItemWarhammer(26766,demonic).setUnlocalizedName("npcDemonicWarhammer").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcDemonicWarhammer"); - warhammer = new ItemWarhammer(26766,frost).setUnlocalizedName("npcFrostWarhammer").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcFrostWarhammer"); - warhammer = new ItemWarhammer(26766,mithril).setUnlocalizedName("npcMithrilWarhammer").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcMithrilWarhammer"); + Item warhammer = new ItemWarhammer(26760, ToolMaterial.WOOD).setUnlocalizedName("npcWoodenWarhammer").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcWoodenWarhammer"); + warhammer = new ItemWarhammer(26761, ToolMaterial.STONE).setUnlocalizedName("npcStoneWarhammer").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcStoneWarhammer"); + warhammer = new ItemWarhammer(26762, ToolMaterial.IRON).setUnlocalizedName("npcIronWarhammer").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcIronWarhammer"); + warhammer = new ItemWarhammer(26763, ToolMaterial.GOLD).setUnlocalizedName("npcGoldenWarhammer").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcGoldenWarhammer"); + warhammer = new ItemWarhammer(26764, ToolMaterial.EMERALD).setUnlocalizedName("npcDiamondWarhammer").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcDiamondWarhammer"); + warhammer = new ItemWarhammer(26765, bronze).setUnlocalizedName("npcBronzeWarhammer").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcBronzeWarhammer"); + warhammer = new ItemWarhammer(26766, emerald).setUnlocalizedName("npcEmeraldWarhammer").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcEmeraldWarhammer"); + warhammer = new ItemWarhammer(26766, demonic).setUnlocalizedName("npcDemonicWarhammer").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcDemonicWarhammer"); + warhammer = new ItemWarhammer(26766, frost).setUnlocalizedName("npcFrostWarhammer").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcFrostWarhammer"); + warhammer = new ItemWarhammer(26766, mithril).setUnlocalizedName("npcMithrilWarhammer").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcMithrilWarhammer"); - Item mace = new ItemNpcWeaponInterface(26770,ToolMaterial.WOOD).setUnlocalizedName("npcWoodenMace").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcWoodenMace"); - mace = new ItemNpcWeaponInterface(26771,ToolMaterial.STONE).setUnlocalizedName("npcStoneMace").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcStoneMace"); - mace = new ItemNpcWeaponInterface(26772,ToolMaterial.IRON).setUnlocalizedName("npcIronMace").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcIronMace"); - mace = new ItemNpcWeaponInterface(26773,ToolMaterial.GOLD).setUnlocalizedName("npcGoldenMace").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcGoldenMace"); - mace = new ItemNpcWeaponInterface(26774,ToolMaterial.EMERALD).setUnlocalizedName("npcDiamondMace").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcDiamondMace"); - mace = new ItemNpcWeaponInterface(26775,bronze).setUnlocalizedName("npcBronzeMace").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcBronzeMace"); - mace = new ItemNpcWeaponInterface(26776,emerald).setUnlocalizedName("npcEmeraldMace").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcEmeraldMace"); - mace = new ItemNpcWeaponInterface(26776,demonic).setUnlocalizedName("npcDemonicMace").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcDemonicMace"); - mace = new ItemNpcWeaponInterface(26776,frost).setUnlocalizedName("npcFrostMace").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcFrostMace"); - mace = new ItemNpcWeaponInterface(26776,mithril).setUnlocalizedName("npcMithrilMace").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcMithrilMace"); + Item mace = new ItemNpcWeaponInterface(26770, ToolMaterial.WOOD).setUnlocalizedName("npcWoodenMace").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcWoodenMace"); + mace = new ItemNpcWeaponInterface(26771, ToolMaterial.STONE).setUnlocalizedName("npcStoneMace").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcStoneMace"); + mace = new ItemNpcWeaponInterface(26772, ToolMaterial.IRON).setUnlocalizedName("npcIronMace").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcIronMace"); + mace = new ItemNpcWeaponInterface(26773, ToolMaterial.GOLD).setUnlocalizedName("npcGoldenMace").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcGoldenMace"); + mace = new ItemNpcWeaponInterface(26774, ToolMaterial.EMERALD).setUnlocalizedName("npcDiamondMace").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcDiamondMace"); + mace = new ItemNpcWeaponInterface(26775, bronze).setUnlocalizedName("npcBronzeMace").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcBronzeMace"); + mace = new ItemNpcWeaponInterface(26776, emerald).setUnlocalizedName("npcEmeraldMace").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcEmeraldMace"); + mace = new ItemNpcWeaponInterface(26776, demonic).setUnlocalizedName("npcDemonicMace").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcDemonicMace"); + mace = new ItemNpcWeaponInterface(26776, frost).setUnlocalizedName("npcFrostMace").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcFrostMace"); + mace = new ItemNpcWeaponInterface(26776, mithril).setUnlocalizedName("npcMithrilMace").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcMithrilMace"); - Item dagger = new ItemDagger(26700,ToolMaterial.WOOD).setUnlocalizedName("npcWoodenDagger").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcWoodenDagger"); - dagger = new ItemDaggerReversed(26701, (ItemDagger) dagger, ToolMaterial.WOOD).setUnlocalizedName("npcWoodenReversedDagger").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcWoodenDagger"); - dagger = new ItemDagger(26702,ToolMaterial.STONE).setUnlocalizedName("npcStoneDagger").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcStoneDagger"); - dagger = new ItemDaggerReversed(26703, (ItemDagger) dagger,ToolMaterial.STONE).setUnlocalizedName("npcStoneReversedDagger").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcStoneDagger"); - dagger = new ItemDagger(26704,ToolMaterial.IRON).setUnlocalizedName("npcIronDagger").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcIronDagger"); - dagger = new ItemDaggerReversed(26705, (ItemDagger) dagger,ToolMaterial.IRON).setUnlocalizedName("npcIronReversedDagger").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcIronDagger"); - dagger = new ItemDagger(26706,ToolMaterial.GOLD).setUnlocalizedName("npcGoldenDagger").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcGoldenDagger"); - dagger = new ItemDaggerReversed(26707, (ItemDagger) dagger,ToolMaterial.GOLD).setUnlocalizedName("npcGoldenReversedDagger").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcGoldenDagger"); - dagger = new ItemDagger(26708,ToolMaterial.EMERALD).setUnlocalizedName("npcDiamondDagger").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcDiamondDagger"); - dagger = new ItemDaggerReversed(26709, (ItemDagger) dagger,ToolMaterial.EMERALD).setUnlocalizedName("npcDiamondReversedDagger").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcDiamondDagger"); - dagger = new ItemDagger(26710,bronze).setUnlocalizedName("npcBronzeDagger").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcBronzeDagger"); - dagger = new ItemDaggerReversed(26711, (ItemDagger) dagger,bronze).setUnlocalizedName("npcBronzeReversedDagger").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcBronzeDagger"); - dagger = new ItemDagger(26712,emerald).setUnlocalizedName("npcEmeraldDagger").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcEmeraldDagger"); - dagger = new ItemDaggerReversed(26713, (ItemDagger) dagger,emerald).setUnlocalizedName("npcEmeraldReversedDagger").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcEmeraldDagger"); - dagger = new ItemDagger(26712,demonic).setUnlocalizedName("npcDemonicDagger").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcDemonicDagger"); - dagger = new ItemDaggerReversed(26713, (ItemDagger) dagger,demonic).setUnlocalizedName("npcDemonicReversedDagger").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcDemonicDagger"); - dagger = new ItemDagger(26712,frost).setUnlocalizedName("npcFrostDagger").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcFrostDagger"); - dagger = new ItemDaggerReversed(26713, (ItemDagger) dagger,frost).setUnlocalizedName("npcFrostReversedDagger").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcFrostDagger"); - dagger = new ItemDagger(26712,mithril).setUnlocalizedName("npcMithrilDagger").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcMithrilDagger"); - dagger = new ItemDaggerReversed(26713, (ItemDagger) dagger,frost).setUnlocalizedName("npcMithrilReversedDagger").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcMithrilDagger"); + Item dagger = new ItemDagger(26700, ToolMaterial.WOOD).setUnlocalizedName("npcWoodenDagger").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcWoodenDagger"); + dagger = new ItemDaggerReversed(26701, (ItemDagger) dagger, ToolMaterial.WOOD).setUnlocalizedName("npcWoodenReversedDagger").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcWoodenDagger"); + dagger = new ItemDagger(26702, ToolMaterial.STONE).setUnlocalizedName("npcStoneDagger").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcStoneDagger"); + dagger = new ItemDaggerReversed(26703, (ItemDagger) dagger, ToolMaterial.STONE).setUnlocalizedName("npcStoneReversedDagger").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcStoneDagger"); + dagger = new ItemDagger(26704, ToolMaterial.IRON).setUnlocalizedName("npcIronDagger").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcIronDagger"); + dagger = new ItemDaggerReversed(26705, (ItemDagger) dagger, ToolMaterial.IRON).setUnlocalizedName("npcIronReversedDagger").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcIronDagger"); + dagger = new ItemDagger(26706, ToolMaterial.GOLD).setUnlocalizedName("npcGoldenDagger").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcGoldenDagger"); + dagger = new ItemDaggerReversed(26707, (ItemDagger) dagger, ToolMaterial.GOLD).setUnlocalizedName("npcGoldenReversedDagger").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcGoldenDagger"); + dagger = new ItemDagger(26708, ToolMaterial.EMERALD).setUnlocalizedName("npcDiamondDagger").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcDiamondDagger"); + dagger = new ItemDaggerReversed(26709, (ItemDagger) dagger, ToolMaterial.EMERALD).setUnlocalizedName("npcDiamondReversedDagger").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcDiamondDagger"); + dagger = new ItemDagger(26710, bronze).setUnlocalizedName("npcBronzeDagger").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcBronzeDagger"); + dagger = new ItemDaggerReversed(26711, (ItemDagger) dagger, bronze).setUnlocalizedName("npcBronzeReversedDagger").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcBronzeDagger"); + dagger = new ItemDagger(26712, emerald).setUnlocalizedName("npcEmeraldDagger").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcEmeraldDagger"); + dagger = new ItemDaggerReversed(26713, (ItemDagger) dagger, emerald).setUnlocalizedName("npcEmeraldReversedDagger").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcEmeraldDagger"); + dagger = new ItemDagger(26712, demonic).setUnlocalizedName("npcDemonicDagger").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcDemonicDagger"); + dagger = new ItemDaggerReversed(26713, (ItemDagger) dagger, demonic).setUnlocalizedName("npcDemonicReversedDagger").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcDemonicDagger"); + dagger = new ItemDagger(26712, frost).setUnlocalizedName("npcFrostDagger").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcFrostDagger"); + dagger = new ItemDaggerReversed(26713, (ItemDagger) dagger, frost).setUnlocalizedName("npcFrostReversedDagger").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcFrostDagger"); + dagger = new ItemDagger(26712, mithril).setUnlocalizedName("npcMithrilDagger").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcMithrilDagger"); + dagger = new ItemDaggerReversed(26713, (ItemDagger) dagger, frost).setUnlocalizedName("npcMithrilReversedDagger").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcMithrilDagger"); - Item claw = new ItemClaw(26850,ToolMaterial.IRON).setUnlocalizedName("npcNinjaClaw").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcNinjaClaw"); - claw = new ItemClaw(26851,ToolMaterial.IRON).setUnlocalizedName("npcSteelClaw").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcSteelClaw"); - claw = new ItemClaw(26852,ToolMaterial.IRON).setUnlocalizedName("npcBearClaw").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcBearClaw"); - claw = new ItemClaw(26853,ToolMaterial.IRON).setUnlocalizedName("npcKatar").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcKatar"); + Item claw = new ItemClaw(26850, ToolMaterial.IRON).setUnlocalizedName("npcNinjaClaw").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcNinjaClaw"); + claw = new ItemClaw(26851, ToolMaterial.IRON).setUnlocalizedName("npcSteelClaw").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcSteelClaw"); + claw = new ItemClaw(26852, ToolMaterial.IRON).setUnlocalizedName("npcBearClaw").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcBearClaw"); + claw = new ItemClaw(26853, ToolMaterial.IRON).setUnlocalizedName("npcKatar").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcKatar"); - staffWood = new ItemStaff(26777,EnumNpcToolMaterial.WOOD).setUnlocalizedName("npcWoodenStaff").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcWoodenStaff"); - staffStone = new ItemStaff(26778,EnumNpcToolMaterial.STONE).setUnlocalizedName("npcStoneStaff").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcStoneStaff"); - staffIron = new ItemStaff(26779,EnumNpcToolMaterial.IRON).setUnlocalizedName("npcIronStaff").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcIronStaff"); - staffGold = new ItemStaff(26780,EnumNpcToolMaterial.GOLD).setUnlocalizedName("npcGoldenStaff").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcGoldenStaff"); - staffDiamond = new ItemStaff(26781,EnumNpcToolMaterial.DIA).setUnlocalizedName("npcDiamondStaff").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcDiamondStaff"); - staffBronze = new ItemStaff(26782,EnumNpcToolMaterial.BRONZE).setUnlocalizedName("npcBronzeStaff").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcBronzeStaff"); - staffEmerald = new ItemStaff(26783,EnumNpcToolMaterial.EMERALD).setUnlocalizedName("npcEmeraldStaff").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcEmeraldStaff"); - staffDemonic = new ItemStaff(26783,EnumNpcToolMaterial.DEMONIC).setUnlocalizedName("npcDemonicStaff").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcDemonicStaff"); - staffFrost = new ItemStaff(26783,EnumNpcToolMaterial.FROST).setUnlocalizedName("npcFrostStaff").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcFrostStaff"); - staffMithril = new ItemStaff(26783,EnumNpcToolMaterial.MITHRIL).setUnlocalizedName("npcMithrilStaff").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcMithrilStaff"); - staffElemental = new ItemElementalStaff(26784,EnumNpcToolMaterial.IRON).setUnlocalizedName("npcElementalStaff").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcElementalStaff"); + staffWood = new ItemStaff(26777, EnumNpcToolMaterial.WOOD).setUnlocalizedName("npcWoodenStaff").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcWoodenStaff"); + staffStone = new ItemStaff(26778, EnumNpcToolMaterial.STONE).setUnlocalizedName("npcStoneStaff").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcStoneStaff"); + staffIron = new ItemStaff(26779, EnumNpcToolMaterial.IRON).setUnlocalizedName("npcIronStaff").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcIronStaff"); + staffGold = new ItemStaff(26780, EnumNpcToolMaterial.GOLD).setUnlocalizedName("npcGoldenStaff").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcGoldenStaff"); + staffDiamond = new ItemStaff(26781, EnumNpcToolMaterial.DIA).setUnlocalizedName("npcDiamondStaff").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcDiamondStaff"); + staffBronze = new ItemStaff(26782, EnumNpcToolMaterial.BRONZE).setUnlocalizedName("npcBronzeStaff").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcBronzeStaff"); + staffEmerald = new ItemStaff(26783, EnumNpcToolMaterial.EMERALD).setUnlocalizedName("npcEmeraldStaff").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcEmeraldStaff"); + staffDemonic = new ItemStaff(26783, EnumNpcToolMaterial.DEMONIC).setUnlocalizedName("npcDemonicStaff").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcDemonicStaff"); + staffFrost = new ItemStaff(26783, EnumNpcToolMaterial.FROST).setUnlocalizedName("npcFrostStaff").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcFrostStaff"); + staffMithril = new ItemStaff(26783, EnumNpcToolMaterial.MITHRIL).setUnlocalizedName("npcMithrilStaff").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcMithrilStaff"); + staffElemental = new ItemElementalStaff(26784, EnumNpcToolMaterial.IRON).setUnlocalizedName("npcElementalStaff").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcElementalStaff"); - Item scythe = new ItemScythe(26785,ToolMaterial.WOOD).setUnlocalizedName("npcWoodenScythe").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcWoodenScythe"); - scythe = new ItemScythe(26786,ToolMaterial.STONE).setUnlocalizedName("npcStoneScythe").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcStoneScythe"); - scythe = new ItemScythe(26787,ToolMaterial.IRON).setUnlocalizedName("npcIronScythe").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcIronScythe"); - scythe = new ItemScythe(26788,ToolMaterial.GOLD).setUnlocalizedName("npcGoldenScythe").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcGoldenScythe"); - scythe = new ItemScythe(26789,ToolMaterial.EMERALD).setUnlocalizedName("npcDiamondScythe").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcDiamondScythe"); - scythe = new ItemScythe(26798,emerald).setUnlocalizedName("npcEmeraldScythe").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcEmeraldScythe"); - scythe = new ItemScythe(26797,bronze).setUnlocalizedName("npcBronzeScythe").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcBronzeScythe"); - scythe = new ItemScythe(26797,demonic).setUnlocalizedName("npcDemonicScythe").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcDemonicScythe"); - scythe = new ItemScythe(26797,frost).setUnlocalizedName("npcFrostScythe").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcFrostScythe"); - scythe = new ItemScythe(26797,mithril).setUnlocalizedName("npcMithrilScythe").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcMithrilScythe"); + Item scythe = new ItemScythe(26785, ToolMaterial.WOOD).setUnlocalizedName("npcWoodenScythe").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcWoodenScythe"); + scythe = new ItemScythe(26786, ToolMaterial.STONE).setUnlocalizedName("npcStoneScythe").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcStoneScythe"); + scythe = new ItemScythe(26787, ToolMaterial.IRON).setUnlocalizedName("npcIronScythe").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcIronScythe"); + scythe = new ItemScythe(26788, ToolMaterial.GOLD).setUnlocalizedName("npcGoldenScythe").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcGoldenScythe"); + scythe = new ItemScythe(26789, ToolMaterial.EMERALD).setUnlocalizedName("npcDiamondScythe").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcDiamondScythe"); + scythe = new ItemScythe(26798, emerald).setUnlocalizedName("npcEmeraldScythe").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcEmeraldScythe"); + scythe = new ItemScythe(26797, bronze).setUnlocalizedName("npcBronzeScythe").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcBronzeScythe"); + scythe = new ItemScythe(26797, demonic).setUnlocalizedName("npcDemonicScythe").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcDemonicScythe"); + scythe = new ItemScythe(26797, frost).setUnlocalizedName("npcFrostScythe").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcFrostScythe"); + scythe = new ItemScythe(26797, mithril).setUnlocalizedName("npcMithrilScythe").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcMithrilScythe"); - glaiveWood = new ItemGlaive(26790,ToolMaterial.WOOD).setUnlocalizedName("npcWoodenGlaive").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcWoodenGlaive"); - glaiveStone = new ItemGlaive(26791,ToolMaterial.STONE).setUnlocalizedName("npcStoneGlaive").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcStoneGlaive"); - glaiveIron = new ItemGlaive(26792,ToolMaterial.IRON).setUnlocalizedName("npcIronGlaive").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcIronGlaive"); - glaiveGold = new ItemGlaive(26793,ToolMaterial.GOLD).setUnlocalizedName("npcGoldenGlaive").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcGoldenGlaive"); - glaiveDiamond = new ItemGlaive(26794,ToolMaterial.EMERALD).setUnlocalizedName("npcDiamondGlaive").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcDiamondGlaive"); - glaiveBronze = new ItemGlaive(26795,bronze).setUnlocalizedName("npcBronzeGlaive").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcBronzeGlaive"); - glaiveEmerald = new ItemGlaive(26796,emerald).setUnlocalizedName("npcEmeraldGlaive").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcEmeraldGlaive"); - glaiveDemonic = new ItemGlaive(26796,demonic).setUnlocalizedName("npcDemonicGlaive").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcDemonicGlaive"); - glaiveFrost = new ItemGlaive(26796,frost).setUnlocalizedName("npcFrostGlaive").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcFrostGlaive"); - glaiveMithril = new ItemGlaive(26796,mithril).setUnlocalizedName("npcMithrilGlaive").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcMithrilGlaive"); + glaiveWood = new ItemGlaive(26790, ToolMaterial.WOOD).setUnlocalizedName("npcWoodenGlaive").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcWoodenGlaive"); + glaiveStone = new ItemGlaive(26791, ToolMaterial.STONE).setUnlocalizedName("npcStoneGlaive").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcStoneGlaive"); + glaiveIron = new ItemGlaive(26792, ToolMaterial.IRON).setUnlocalizedName("npcIronGlaive").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcIronGlaive"); + glaiveGold = new ItemGlaive(26793, ToolMaterial.GOLD).setUnlocalizedName("npcGoldenGlaive").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcGoldenGlaive"); + glaiveDiamond = new ItemGlaive(26794, ToolMaterial.EMERALD).setUnlocalizedName("npcDiamondGlaive").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcDiamondGlaive"); + glaiveBronze = new ItemGlaive(26795, bronze).setUnlocalizedName("npcBronzeGlaive").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcBronzeGlaive"); + glaiveEmerald = new ItemGlaive(26796, emerald).setUnlocalizedName("npcEmeraldGlaive").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcEmeraldGlaive"); + glaiveDemonic = new ItemGlaive(26796, demonic).setUnlocalizedName("npcDemonicGlaive").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcDemonicGlaive"); + glaiveFrost = new ItemGlaive(26796, frost).setUnlocalizedName("npcFrostGlaive").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcFrostGlaive"); + glaiveMithril = new ItemGlaive(26796, mithril).setUnlocalizedName("npcMithrilGlaive").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcMithrilGlaive"); - new ItemBroadSword(ToolMaterial.WOOD).setUnlocalizedName("npcWoodenBroadsword").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcWoodenBroadsword"); - new ItemBroadSword(ToolMaterial.STONE).setUnlocalizedName("npcStoneBroadsword").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcStoneBroadsword"); - new ItemBroadSword(ToolMaterial.IRON).setUnlocalizedName("npcIronBroadsword").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcIronBroadsword"); - new ItemBroadSword(ToolMaterial.GOLD).setUnlocalizedName("npcGoldenBroadsword").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcGoldenBroadsword"); - new ItemBroadSword(ToolMaterial.EMERALD).setUnlocalizedName("npcDiamondBroadsword").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcDiamondBroadsword"); - new ItemBroadSword(bronze).setUnlocalizedName("npcBronzeBroadsword").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcBronzeBroadsword"); - new ItemBroadSword(emerald).setUnlocalizedName("npcEmeraldBroadsword").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcEmeraldBroadsword"); - new ItemBroadSword(demonic).setUnlocalizedName("npcDemonicBroadsword").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcDemonicBroadsword"); - new ItemBroadSword(frost).setUnlocalizedName("npcFrostBroadsword").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcFrostBroadsword"); - new ItemBroadSword(mithril).setUnlocalizedName("npcMithrilBroadsword").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcMithrilBroadsword"); + new ItemBroadSword(ToolMaterial.WOOD).setUnlocalizedName("npcWoodenBroadsword").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcWoodenBroadsword"); + new ItemBroadSword(ToolMaterial.STONE).setUnlocalizedName("npcStoneBroadsword").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcStoneBroadsword"); + new ItemBroadSword(ToolMaterial.IRON).setUnlocalizedName("npcIronBroadsword").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcIronBroadsword"); + new ItemBroadSword(ToolMaterial.GOLD).setUnlocalizedName("npcGoldenBroadsword").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcGoldenBroadsword"); + new ItemBroadSword(ToolMaterial.EMERALD).setUnlocalizedName("npcDiamondBroadsword").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcDiamondBroadsword"); + new ItemBroadSword(bronze).setUnlocalizedName("npcBronzeBroadsword").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcBronzeBroadsword"); + new ItemBroadSword(emerald).setUnlocalizedName("npcEmeraldBroadsword").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcEmeraldBroadsword"); + new ItemBroadSword(demonic).setUnlocalizedName("npcDemonicBroadsword").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcDemonicBroadsword"); + new ItemBroadSword(frost).setUnlocalizedName("npcFrostBroadsword").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcFrostBroadsword"); + new ItemBroadSword(mithril).setUnlocalizedName("npcMithrilBroadsword").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcMithrilBroadsword"); - ItemArmor.ArmorMaterial armorMithril = EnumHelper.addArmorMaterial("MITHRIL", 40, new int[]{3, 8, 6, 3}, 20); - ItemArmor.ArmorMaterial armorBronze = EnumHelper.addArmorMaterial("BRONZE", 7, new int[]{2, 6, 5, 2}, 20); - ItemArmor.ArmorMaterial armorEmerald = EnumHelper.addArmorMaterial("EMERALD", 35, new int[]{5, 7, 4, 5}, 5); + ItemArmor.ArmorMaterial armorMithril = EnumHelper.addArmorMaterial("MITHRIL", 40, new int[]{3, 8, 6, 3}, 20); + ItemArmor.ArmorMaterial armorBronze = EnumHelper.addArmorMaterial("BRONZE", 7, new int[]{2, 6, 5, 2}, 20); + ItemArmor.ArmorMaterial armorEmerald = EnumHelper.addArmorMaterial("EMERALD", 35, new int[]{5, 7, 4, 5}, 5); - Item cowarmor = new ItemNpcArmor(26860, ArmorMaterial.CHAIN,0,"cowleather").setUnlocalizedName("npcCowleatherHead").setMaxStackSize(1).setTextureName("customnpcs:npcCowleatherHead"); - Item armor = new ItemNpcArmor(26861,ArmorMaterial.CHAIN,1,"cowleather").setUnlocalizedName("npcCowleatherChest").setMaxStackSize(1).setTextureName("customnpcs:npcCowleatherChest"); - armor = new ItemNpcArmor(26862,ArmorMaterial.CHAIN,2,"cowleather").setUnlocalizedName("npcCowleatherLegs").setMaxStackSize(1).setTextureName("customnpcs:npcCowleatherLegs"); - armor = new ItemNpcArmor(26863,ArmorMaterial.CHAIN,3,"cowleather").setUnlocalizedName("npcCowleatherBoots").setMaxStackSize(1).setTextureName("customnpcs:npcCowleatherBoots"); + Item cowarmor = new ItemNpcArmor(26860, ArmorMaterial.CHAIN, 0, "cowleather").setUnlocalizedName("npcCowleatherHead").setMaxStackSize(1).setTextureName("customnpcs:npcCowleatherHead"); + Item armor = new ItemNpcArmor(26861, ArmorMaterial.CHAIN, 1, "cowleather").setUnlocalizedName("npcCowleatherChest").setMaxStackSize(1).setTextureName("customnpcs:npcCowleatherChest"); + armor = new ItemNpcArmor(26862, ArmorMaterial.CHAIN, 2, "cowleather").setUnlocalizedName("npcCowleatherLegs").setMaxStackSize(1).setTextureName("customnpcs:npcCowleatherLegs"); + armor = new ItemNpcArmor(26863, ArmorMaterial.CHAIN, 3, "cowleather").setUnlocalizedName("npcCowleatherBoots").setMaxStackSize(1).setTextureName("customnpcs:npcCowleatherBoots"); - armor = new ItemNpcArmor(26864,ArmorMaterial.IRON,0,"nanorum").setUnlocalizedName("npcNanorumHead").setMaxStackSize(1).setTextureName("customnpcs:npcNanorumHead"); - armor = new ItemNpcArmor(26865,ArmorMaterial.IRON,1,"nanorum").setUnlocalizedName("npcNanorumChest").setMaxStackSize(1).setTextureName("customnpcs:npcNanorumChest"); - armor = new ItemNpcArmor(26866,ArmorMaterial.IRON,2,"nanorum").setUnlocalizedName("npcNanorumLegs").setMaxStackSize(1).setTextureName("customnpcs:npcNanorumLegs"); - armor = new ItemNpcArmor(26867,ArmorMaterial.IRON,3,"nanorum").setUnlocalizedName("npcNanorumBoots").setMaxStackSize(1).setTextureName("customnpcs:npcNanorumBoots"); + armor = new ItemNpcArmor(26864, ArmorMaterial.IRON, 0, "nanorum").setUnlocalizedName("npcNanorumHead").setMaxStackSize(1).setTextureName("customnpcs:npcNanorumHead"); + armor = new ItemNpcArmor(26865, ArmorMaterial.IRON, 1, "nanorum").setUnlocalizedName("npcNanorumChest").setMaxStackSize(1).setTextureName("customnpcs:npcNanorumChest"); + armor = new ItemNpcArmor(26866, ArmorMaterial.IRON, 2, "nanorum").setUnlocalizedName("npcNanorumLegs").setMaxStackSize(1).setTextureName("customnpcs:npcNanorumLegs"); + armor = new ItemNpcArmor(26867, ArmorMaterial.IRON, 3, "nanorum").setUnlocalizedName("npcNanorumBoots").setMaxStackSize(1).setTextureName("customnpcs:npcNanorumBoots"); - armor = new ItemNpcArmor(26868,ArmorMaterial.IRON,0,"tactical").setUnlocalizedName("npcTacticalHead").setMaxStackSize(1).setTextureName("customnpcs:npcTacticalHead"); - armor = new ItemNpcArmor(26869,ArmorMaterial.IRON,1,"tactical").setUnlocalizedName("npcTacticalChest").setMaxStackSize(1).setTextureName("customnpcs:npcTacticalChest"); + armor = new ItemNpcArmor(26868, ArmorMaterial.IRON, 0, "tactical").setUnlocalizedName("npcTacticalHead").setMaxStackSize(1).setTextureName("customnpcs:npcTacticalHead"); + armor = new ItemNpcArmor(26869, ArmorMaterial.IRON, 1, "tactical").setUnlocalizedName("npcTacticalChest").setMaxStackSize(1).setTextureName("customnpcs:npcTacticalChest"); - armor = new ItemNpcArmor(26919,ArmorMaterial.IRON,0,"fullcloth").setUnlocalizedName("npcFullLeatherHead").setMaxStackSize(1).setTextureName("customnpcs:npcFullLeatherHead"); - armor = new ItemNpcArmor(26920,ArmorMaterial.IRON,1,"fullcloth").setUnlocalizedName("npcFullLeatherChest").setMaxStackSize(1).setTextureName("customnpcs:npcFullLeatherChest"); + armor = new ItemNpcArmor(26919, ArmorMaterial.IRON, 0, "fullcloth").setUnlocalizedName("npcFullLeatherHead").setMaxStackSize(1).setTextureName("customnpcs:npcFullLeatherHead"); + armor = new ItemNpcArmor(26920, ArmorMaterial.IRON, 1, "fullcloth").setUnlocalizedName("npcFullLeatherChest").setMaxStackSize(1).setTextureName("customnpcs:npcFullLeatherChest"); - armor = new ItemNpcArmor(26870,ArmorMaterial.IRON,0,"fulliron").setUnlocalizedName("npcFullIronHead").setMaxStackSize(1).setTextureName("customnpcs:npcFullIronHead"); - armor = new ItemNpcArmor(26871,ArmorMaterial.IRON,1,"fulliron").setUnlocalizedName("npcFullIronChest").setMaxStackSize(1).setTextureName("customnpcs:npcFullIronChest"); + armor = new ItemNpcArmor(26870, ArmorMaterial.IRON, 0, "fulliron").setUnlocalizedName("npcFullIronHead").setMaxStackSize(1).setTextureName("customnpcs:npcFullIronHead"); + armor = new ItemNpcArmor(26871, ArmorMaterial.IRON, 1, "fulliron").setUnlocalizedName("npcFullIronChest").setMaxStackSize(1).setTextureName("customnpcs:npcFullIronChest"); - armor = new ItemNpcArmor(26872,ArmorMaterial.GOLD,0,"fullgold").setUnlocalizedName("npcFullGoldHead").setMaxStackSize(1).setTextureName("customnpcs:npcFullGoldHead"); - armor = new ItemNpcArmor(26873,ArmorMaterial.GOLD,1,"fullgold").setUnlocalizedName("npcFullGoldChest").setMaxStackSize(1).setTextureName("customnpcs:npcFullGoldChest"); + armor = new ItemNpcArmor(26872, ArmorMaterial.GOLD, 0, "fullgold").setUnlocalizedName("npcFullGoldHead").setMaxStackSize(1).setTextureName("customnpcs:npcFullGoldHead"); + armor = new ItemNpcArmor(26873, ArmorMaterial.GOLD, 1, "fullgold").setUnlocalizedName("npcFullGoldChest").setMaxStackSize(1).setTextureName("customnpcs:npcFullGoldChest"); - armor = new ItemNpcArmor(26874,ArmorMaterial.DIAMOND,0,"fulldiamond").setUnlocalizedName("npcFullDiamondHead").setMaxStackSize(1).setTextureName("customnpcs:npcFullDiamondHead"); - armor = new ItemNpcArmor(26875,ArmorMaterial.DIAMOND,1,"fulldiamond").setUnlocalizedName("npcFullDiamondChest").setMaxStackSize(1).setTextureName("customnpcs:npcFullDiamondChest"); + armor = new ItemNpcArmor(26874, ArmorMaterial.DIAMOND, 0, "fulldiamond").setUnlocalizedName("npcFullDiamondHead").setMaxStackSize(1).setTextureName("customnpcs:npcFullDiamondHead"); + armor = new ItemNpcArmor(26875, ArmorMaterial.DIAMOND, 1, "fulldiamond").setUnlocalizedName("npcFullDiamondChest").setMaxStackSize(1).setTextureName("customnpcs:npcFullDiamondChest"); - armor = new ItemNpcArmor(26876, armorBronze,0,"fullbronze").setUnlocalizedName("npcFullBronzeHead").setMaxStackSize(1).setTextureName("customnpcs:npcFullBronzeHead"); - armor = new ItemNpcArmor(26877, armorBronze,1,"fullbronze").setUnlocalizedName("npcFullBronzeChest").setMaxStackSize(1).setTextureName("customnpcs:npcFullBronzeChest"); - armor = new ItemNpcArmor(26878, armorBronze,2,"fullbronze").setUnlocalizedName("npcFullBronzeLeggings").setMaxStackSize(1).setTextureName("customnpcs:npcFullBronzeLeggings"); - armor = new ItemNpcArmor(26879, armorBronze,3,"fullbronze").setUnlocalizedName("npcFullBronzeBoots").setMaxStackSize(1).setTextureName("customnpcs:npcFullBronzeBoots"); + armor = new ItemNpcArmor(26876, armorBronze, 0, "fullbronze").setUnlocalizedName("npcFullBronzeHead").setMaxStackSize(1).setTextureName("customnpcs:npcFullBronzeHead"); + armor = new ItemNpcArmor(26877, armorBronze, 1, "fullbronze").setUnlocalizedName("npcFullBronzeChest").setMaxStackSize(1).setTextureName("customnpcs:npcFullBronzeChest"); + armor = new ItemNpcArmor(26878, armorBronze, 2, "fullbronze").setUnlocalizedName("npcFullBronzeLeggings").setMaxStackSize(1).setTextureName("customnpcs:npcFullBronzeLeggings"); + armor = new ItemNpcArmor(26879, armorBronze, 3, "fullbronze").setUnlocalizedName("npcFullBronzeBoots").setMaxStackSize(1).setTextureName("customnpcs:npcFullBronzeBoots"); - armor = new ItemNpcArmor(26921, armorEmerald,0,"fullemerald").setUnlocalizedName("npcFullEmeraldHead").setMaxStackSize(1).setTextureName("customnpcs:npcFullEmeraldHead"); - armor = new ItemNpcArmor(26922, armorEmerald,1,"fullemerald").setUnlocalizedName("npcFullEmeraldChest").setMaxStackSize(1).setTextureName("customnpcs:npcFullEmeraldChest"); - armor = new ItemNpcArmor(26923, armorEmerald,2,"fullemerald").setUnlocalizedName("npcFullEmeraldLeggings").setMaxStackSize(1).setTextureName("customnpcs:npcFullEmeraldLeggings"); - armor = new ItemNpcArmor(26924, armorEmerald,3,"fullemerald").setUnlocalizedName("npcFullEmeraldBoots").setMaxStackSize(1).setTextureName("customnpcs:npcFullEmeraldBoots"); + armor = new ItemNpcArmor(26921, armorEmerald, 0, "fullemerald").setUnlocalizedName("npcFullEmeraldHead").setMaxStackSize(1).setTextureName("customnpcs:npcFullEmeraldHead"); + armor = new ItemNpcArmor(26922, armorEmerald, 1, "fullemerald").setUnlocalizedName("npcFullEmeraldChest").setMaxStackSize(1).setTextureName("customnpcs:npcFullEmeraldChest"); + armor = new ItemNpcArmor(26923, armorEmerald, 2, "fullemerald").setUnlocalizedName("npcFullEmeraldLeggings").setMaxStackSize(1).setTextureName("customnpcs:npcFullEmeraldLeggings"); + armor = new ItemNpcArmor(26924, armorEmerald, 3, "fullemerald").setUnlocalizedName("npcFullEmeraldBoots").setMaxStackSize(1).setTextureName("customnpcs:npcFullEmeraldBoots"); - armor = new ItemNpcArmor(26880,ArmorMaterial.CLOTH,0,"fullwood").setUnlocalizedName("npcFullWoodenHead").setMaxStackSize(1).setTextureName("customnpcs:npcFullWoodenHead"); - armor = new ItemNpcArmor(26881,ArmorMaterial.CLOTH,1,"fullwood").setUnlocalizedName("npcFullWoodenChest").setMaxStackSize(1).setTextureName("customnpcs:npcFullWoodenChest"); - armor = new ItemNpcArmor(26882,ArmorMaterial.CLOTH,2,"fullwood").setUnlocalizedName("npcFullWoodenLeggings").setMaxStackSize(1).setTextureName("customnpcs:npcFullWoodenLeggings"); - armor = new ItemNpcArmor(26883,ArmorMaterial.CLOTH,3,"fullwood").setUnlocalizedName("npcFullWoodenBoots").setMaxStackSize(1).setTextureName("customnpcs:npcFullWoodenBoots"); + armor = new ItemNpcArmor(26880, ArmorMaterial.CLOTH, 0, "fullwood").setUnlocalizedName("npcFullWoodenHead").setMaxStackSize(1).setTextureName("customnpcs:npcFullWoodenHead"); + armor = new ItemNpcArmor(26881, ArmorMaterial.CLOTH, 1, "fullwood").setUnlocalizedName("npcFullWoodenChest").setMaxStackSize(1).setTextureName("customnpcs:npcFullWoodenChest"); + armor = new ItemNpcArmor(26882, ArmorMaterial.CLOTH, 2, "fullwood").setUnlocalizedName("npcFullWoodenLeggings").setMaxStackSize(1).setTextureName("customnpcs:npcFullWoodenLeggings"); + armor = new ItemNpcArmor(26883, ArmorMaterial.CLOTH, 3, "fullwood").setUnlocalizedName("npcFullWoodenBoots").setMaxStackSize(1).setTextureName("customnpcs:npcFullWoodenBoots"); - armor = new ItemNpcArmor(26884,ArmorMaterial.CHAIN,1,"tuxido").setUnlocalizedName("npcTuxedoChest").setMaxStackSize(1).setTextureName("customnpcs:npcTuxedoChest"); - armor = new ItemNpcArmor(26885,ArmorMaterial.CHAIN,2,"tuxido").setUnlocalizedName("npcTuxedoPants").setMaxStackSize(1).setTextureName("customnpcs:npcTuxedoPants"); - armor = new ItemNpcArmor(26886,ArmorMaterial.CHAIN,3,"tuxido").setUnlocalizedName("npcTuxedoBottom").setMaxStackSize(1).setTextureName("customnpcs:npcTuxedoBottom"); + armor = new ItemNpcArmor(26884, ArmorMaterial.CHAIN, 1, "tuxido").setUnlocalizedName("npcTuxedoChest").setMaxStackSize(1).setTextureName("customnpcs:npcTuxedoChest"); + armor = new ItemNpcArmor(26885, ArmorMaterial.CHAIN, 2, "tuxido").setUnlocalizedName("npcTuxedoPants").setMaxStackSize(1).setTextureName("customnpcs:npcTuxedoPants"); + armor = new ItemNpcArmor(26886, ArmorMaterial.CHAIN, 3, "tuxido").setUnlocalizedName("npcTuxedoBottom").setMaxStackSize(1).setTextureName("customnpcs:npcTuxedoBottom"); - armor = new ItemNpcArmor(26887,ArmorMaterial.CHAIN,0,"wizard").setUnlocalizedName("npcWizardHead").setMaxStackSize(1).setTextureName("customnpcs:npcWizardHead"); - armor = new ItemNpcArmor(26888,ArmorMaterial.CHAIN,1,"wizard").setUnlocalizedName("npcWizardChest").setMaxStackSize(1).setTextureName("customnpcs:npcWizardChest"); - armor = new ItemNpcArmor(26889,ArmorMaterial.CHAIN,2,"wizard").setUnlocalizedName("npcWizardPants").setMaxStackSize(1).setTextureName("customnpcs:npcWizardPants"); + armor = new ItemNpcArmor(26887, ArmorMaterial.CHAIN, 0, "wizard").setUnlocalizedName("npcWizardHead").setMaxStackSize(1).setTextureName("customnpcs:npcWizardHead"); + armor = new ItemNpcArmor(26888, ArmorMaterial.CHAIN, 1, "wizard").setUnlocalizedName("npcWizardChest").setMaxStackSize(1).setTextureName("customnpcs:npcWizardChest"); + armor = new ItemNpcArmor(26889, ArmorMaterial.CHAIN, 2, "wizard").setUnlocalizedName("npcWizardPants").setMaxStackSize(1).setTextureName("customnpcs:npcWizardPants"); - armor = new ItemNpcArmor(26890,ArmorMaterial.IRON,0,"assassin").setUnlocalizedName("npcAssassinHead").setMaxStackSize(1).setTextureName("customnpcs:npcAssassinHead"); - armor = new ItemNpcArmor(26891,ArmorMaterial.IRON,1,"assassin").setUnlocalizedName("npcAssassinChest").setMaxStackSize(1).setTextureName("customnpcs:npcAssassinChest"); - armor = new ItemNpcArmor(26892,ArmorMaterial.IRON,2,"assassin").setUnlocalizedName("npcAssassinLeggings").setMaxStackSize(1).setTextureName("customnpcs:npcAssassinLeggings"); - armor = new ItemNpcArmor(26893,ArmorMaterial.IRON,3,"assassin").setUnlocalizedName("npcAssassinBoots").setMaxStackSize(1).setTextureName("customnpcs:npcAssassinBoots"); + armor = new ItemNpcArmor(26890, ArmorMaterial.IRON, 0, "assassin").setUnlocalizedName("npcAssassinHead").setMaxStackSize(1).setTextureName("customnpcs:npcAssassinHead"); + armor = new ItemNpcArmor(26891, ArmorMaterial.IRON, 1, "assassin").setUnlocalizedName("npcAssassinChest").setMaxStackSize(1).setTextureName("customnpcs:npcAssassinChest"); + armor = new ItemNpcArmor(26892, ArmorMaterial.IRON, 2, "assassin").setUnlocalizedName("npcAssassinLeggings").setMaxStackSize(1).setTextureName("customnpcs:npcAssassinLeggings"); + armor = new ItemNpcArmor(26893, ArmorMaterial.IRON, 3, "assassin").setUnlocalizedName("npcAssassinBoots").setMaxStackSize(1).setTextureName("customnpcs:npcAssassinBoots"); - armor = new ItemNpcArmor(26894,ArmorMaterial.IRON,0,"soldier").setUnlocalizedName("npcSoldierHead").setMaxStackSize(1).setTextureName("customnpcs:npcSoldierHead"); - armor = new ItemNpcArmor(26895,ArmorMaterial.IRON,1,"soldier").setUnlocalizedName("npcSoldierChest").setMaxStackSize(1).setTextureName("customnpcs:npcSoldierChest"); - armor = new ItemNpcArmor(26896,ArmorMaterial.IRON,2,"soldier").setUnlocalizedName("npcSoldierLegs").setMaxStackSize(1).setTextureName("customnpcs:npcSoldierLegs"); - armor = new ItemNpcArmor(26897,ArmorMaterial.IRON,3,"soldier").setUnlocalizedName("npcSoldierBottom").setMaxStackSize(1).setTextureName("customnpcs:npcSoldierBottom"); + armor = new ItemNpcArmor(26894, ArmorMaterial.IRON, 0, "soldier").setUnlocalizedName("npcSoldierHead").setMaxStackSize(1).setTextureName("customnpcs:npcSoldierHead"); + armor = new ItemNpcArmor(26895, ArmorMaterial.IRON, 1, "soldier").setUnlocalizedName("npcSoldierChest").setMaxStackSize(1).setTextureName("customnpcs:npcSoldierChest"); + armor = new ItemNpcArmor(26896, ArmorMaterial.IRON, 2, "soldier").setUnlocalizedName("npcSoldierLegs").setMaxStackSize(1).setTextureName("customnpcs:npcSoldierLegs"); + armor = new ItemNpcArmor(26897, ArmorMaterial.IRON, 3, "soldier").setUnlocalizedName("npcSoldierBottom").setMaxStackSize(1).setTextureName("customnpcs:npcSoldierBottom"); - armor = new ItemNpcArmor(26898,ArmorMaterial.DIAMOND,0,"x407").setUnlocalizedName("npcX407Head").setMaxStackSize(1).setTextureName("customnpcs:npcX407Head"); - armor = new ItemNpcArmor(26899,ArmorMaterial.DIAMOND,1,"x407").setUnlocalizedName("npcX407Chest").setMaxStackSize(1).setTextureName("customnpcs:npcX407Chest"); - armor = new ItemNpcArmor(26900,ArmorMaterial.DIAMOND,2,"x407").setUnlocalizedName("npcX407Legs").setMaxStackSize(1).setTextureName("customnpcs:npcX407Legs"); - armor = new ItemNpcArmor(26901,ArmorMaterial.DIAMOND,3,"x407").setUnlocalizedName("npcX407Boots").setMaxStackSize(1).setTextureName("customnpcs:npcX407Boots"); + armor = new ItemNpcArmor(26898, ArmorMaterial.DIAMOND, 0, "x407").setUnlocalizedName("npcX407Head").setMaxStackSize(1).setTextureName("customnpcs:npcX407Head"); + armor = new ItemNpcArmor(26899, ArmorMaterial.DIAMOND, 1, "x407").setUnlocalizedName("npcX407Chest").setMaxStackSize(1).setTextureName("customnpcs:npcX407Chest"); + armor = new ItemNpcArmor(26900, ArmorMaterial.DIAMOND, 2, "x407").setUnlocalizedName("npcX407Legs").setMaxStackSize(1).setTextureName("customnpcs:npcX407Legs"); + armor = new ItemNpcArmor(26901, ArmorMaterial.DIAMOND, 3, "x407").setUnlocalizedName("npcX407Boots").setMaxStackSize(1).setTextureName("customnpcs:npcX407Boots"); - armor = new ItemNpcArmor(26898,armorMithril,0,"mithril").setUnlocalizedName("npcMithrilHead").setMaxStackSize(1).setTextureName("customnpcs:npcMithrilHead"); - armor = new ItemNpcArmor(26899,armorMithril,1,"mithril").setUnlocalizedName("npcMithrilChest").setMaxStackSize(1).setTextureName("customnpcs:npcMithrilChest"); - armor = new ItemNpcArmor(26900,armorMithril,2,"mithril").setUnlocalizedName("npcMithrilLegs").setMaxStackSize(1).setTextureName("customnpcs:npcMithrilLegs"); - armor = new ItemNpcArmor(26901,armorMithril,3,"mithril").setUnlocalizedName("npcMithrilBoots").setMaxStackSize(1).setTextureName("customnpcs:npcMithrilBoots"); + armor = new ItemNpcArmor(26898, armorMithril, 0, "mithril").setUnlocalizedName("npcMithrilHead").setMaxStackSize(1).setTextureName("customnpcs:npcMithrilHead"); + armor = new ItemNpcArmor(26899, armorMithril, 1, "mithril").setUnlocalizedName("npcMithrilChest").setMaxStackSize(1).setTextureName("customnpcs:npcMithrilChest"); + armor = new ItemNpcArmor(26900, armorMithril, 2, "mithril").setUnlocalizedName("npcMithrilLegs").setMaxStackSize(1).setTextureName("customnpcs:npcMithrilLegs"); + armor = new ItemNpcArmor(26901, armorMithril, 3, "mithril").setUnlocalizedName("npcMithrilBoots").setMaxStackSize(1).setTextureName("customnpcs:npcMithrilBoots"); - armor = new ItemNpcArmor(26898,ArmorMaterial.DIAMOND,0,"demonic").setUnlocalizedName("npcDemonicHead").setMaxStackSize(1).setTextureName("customnpcs:npcDemonicHead"); - armor = new ItemNpcArmor(26899,ArmorMaterial.DIAMOND,1,"demonic").setUnlocalizedName("npcDemonicChest").setMaxStackSize(1).setTextureName("customnpcs:npcDemonicChest"); - armor = new ItemNpcArmor(26900,ArmorMaterial.DIAMOND,2,"demonic").setUnlocalizedName("npcDemonicLegs").setMaxStackSize(1).setTextureName("customnpcs:npcDemonicLegs"); - armor = new ItemNpcArmor(26901,ArmorMaterial.DIAMOND,3,"demonic").setUnlocalizedName("npcDemonicBoots").setMaxStackSize(1).setTextureName("customnpcs:npcDemonicBoots"); + armor = new ItemNpcArmor(26898, ArmorMaterial.DIAMOND, 0, "demonic").setUnlocalizedName("npcDemonicHead").setMaxStackSize(1).setTextureName("customnpcs:npcDemonicHead"); + armor = new ItemNpcArmor(26899, ArmorMaterial.DIAMOND, 1, "demonic").setUnlocalizedName("npcDemonicChest").setMaxStackSize(1).setTextureName("customnpcs:npcDemonicChest"); + armor = new ItemNpcArmor(26900, ArmorMaterial.DIAMOND, 2, "demonic").setUnlocalizedName("npcDemonicLegs").setMaxStackSize(1).setTextureName("customnpcs:npcDemonicLegs"); + armor = new ItemNpcArmor(26901, ArmorMaterial.DIAMOND, 3, "demonic").setUnlocalizedName("npcDemonicBoots").setMaxStackSize(1).setTextureName("customnpcs:npcDemonicBoots"); - armor = new ItemNpcArmor(26902,ArmorMaterial.GOLD,0,"commissar").setUnlocalizedName("npcCommissarHead").setMaxStackSize(1).setTextureName("customnpcs:npcCommissarHead"); - armor = new ItemNpcArmor(26903,ArmorMaterial.GOLD,1,"commissar").setUnlocalizedName("npcCommissarChest").setMaxStackSize(1).setTextureName("customnpcs:npcCommissarChest"); - armor = new ItemNpcArmor(26904,ArmorMaterial.GOLD,2,"commissar").setUnlocalizedName("npcCommissarLegs").setMaxStackSize(1).setTextureName("customnpcs:npcCommissarLegs"); - armor = new ItemNpcArmor(26905,ArmorMaterial.GOLD,3,"commissar").setUnlocalizedName("npcCommissarBottom").setMaxStackSize(1).setTextureName("customnpcs:npcCommissarBottom"); + armor = new ItemNpcArmor(26902, ArmorMaterial.GOLD, 0, "commissar").setUnlocalizedName("npcCommissarHead").setMaxStackSize(1).setTextureName("customnpcs:npcCommissarHead"); + armor = new ItemNpcArmor(26903, ArmorMaterial.GOLD, 1, "commissar").setUnlocalizedName("npcCommissarChest").setMaxStackSize(1).setTextureName("customnpcs:npcCommissarChest"); + armor = new ItemNpcArmor(26904, ArmorMaterial.GOLD, 2, "commissar").setUnlocalizedName("npcCommissarLegs").setMaxStackSize(1).setTextureName("customnpcs:npcCommissarLegs"); + armor = new ItemNpcArmor(26905, ArmorMaterial.GOLD, 3, "commissar").setUnlocalizedName("npcCommissarBottom").setMaxStackSize(1).setTextureName("customnpcs:npcCommissarBottom"); - armor = new ItemNpcArmor(26906,ArmorMaterial.IRON,0,"infantry").setUnlocalizedName("npcInfantryHelmet").setMaxStackSize(1).setTextureName("customnpcs:npcInfantryHelmet"); - armor = new ItemNpcArmor(26907,ArmorMaterial.DIAMOND,1,"officer").setUnlocalizedName("npcOfficerChest").setMaxStackSize(1).setTextureName("customnpcs:npcOfficerChest"); + armor = new ItemNpcArmor(26906, ArmorMaterial.IRON, 0, "infantry").setUnlocalizedName("npcInfantryHelmet").setMaxStackSize(1).setTextureName("customnpcs:npcInfantryHelmet"); + armor = new ItemNpcArmor(26907, ArmorMaterial.DIAMOND, 1, "officer").setUnlocalizedName("npcOfficerChest").setMaxStackSize(1).setTextureName("customnpcs:npcOfficerChest"); - armor = new ItemNpcArmor(26908,ArmorMaterial.DIAMOND,0,"crown1").setUnlocalizedName("npcCrown2").setMaxStackSize(1).setTextureName("customnpcs:npcCrown2"); - armor = new ItemNpcArmor(26909,ArmorMaterial.DIAMOND,0,"crown2").setUnlocalizedName("npcCrown").setMaxStackSize(1).setTextureName("customnpcs:npcCrown"); - armor = new ItemNpcArmorColorable(26909,ArmorMaterial.CLOTH,0,"papercrown").setUnlocalizedName("npcPaperCrown").setMaxStackSize(1).setTextureName("customnpcs:npcPaperCrown"); + armor = new ItemNpcArmor(26908, ArmorMaterial.DIAMOND, 0, "crown1").setUnlocalizedName("npcCrown2").setMaxStackSize(1).setTextureName("customnpcs:npcCrown2"); + armor = new ItemNpcArmor(26909, ArmorMaterial.DIAMOND, 0, "crown2").setUnlocalizedName("npcCrown").setMaxStackSize(1).setTextureName("customnpcs:npcCrown"); + armor = new ItemNpcArmorColorable(26909, ArmorMaterial.CLOTH, 0, "papercrown").setUnlocalizedName("npcPaperCrown").setMaxStackSize(1).setTextureName("customnpcs:npcPaperCrown"); - armor = new ItemNpcArmor(26916,ArmorMaterial.IRON,0,"ninja").setUnlocalizedName("npcNinjaHead").setMaxStackSize(1).setTextureName("customnpcs:npcNinjaHead"); - armor = new ItemNpcArmor(26917,ArmorMaterial.IRON,1,"ninja").setUnlocalizedName("npcNinjaChest").setMaxStackSize(1).setTextureName("customnpcs:npcNinjaChest"); - armor = new ItemNpcArmor(26918,ArmorMaterial.IRON,2,"ninja").setUnlocalizedName("npcNinjaPants").setMaxStackSize(1).setTextureName("customnpcs:npcNinjaPants"); + armor = new ItemNpcArmor(26916, ArmorMaterial.IRON, 0, "ninja").setUnlocalizedName("npcNinjaHead").setMaxStackSize(1).setTextureName("customnpcs:npcNinjaHead"); + armor = new ItemNpcArmor(26917, ArmorMaterial.IRON, 1, "ninja").setUnlocalizedName("npcNinjaChest").setMaxStackSize(1).setTextureName("customnpcs:npcNinjaChest"); + armor = new ItemNpcArmor(26918, ArmorMaterial.IRON, 2, "ninja").setUnlocalizedName("npcNinjaPants").setMaxStackSize(1).setTextureName("customnpcs:npcNinjaPants"); - armor = new ItemSkirt(ArmorMaterial.CHAIN,"textures/models/armor/chainmail_layer_2.png").setUnlocalizedName("npcChainSkirt").setTextureName("customnpcs:npcChainSkirt"); - armor = new ItemSkirt(ArmorMaterial.CLOTH,"textures/models/armor/leather_layer_2.png").setUnlocalizedName("npcLeatherSkirt").setTextureName("customnpcs:npcLeatherSkirt"); - armor = new ItemSkirt(ArmorMaterial.GOLD,"textures/models/armor/gold_layer_2.png").setUnlocalizedName("npcGoldSkirt").setTextureName("customnpcs:npcGoldSkirt"); - armor = new ItemSkirt(ArmorMaterial.IRON,"textures/models/armor/iron_layer_2.png").setUnlocalizedName("npcIronSkirt").setTextureName("customnpcs:npcIronSkirt"); - armor = new ItemSkirt(ArmorMaterial.DIAMOND,"textures/models/armor/diamond_layer_2.png").setUnlocalizedName("npcDiamondSkirt").setTextureName("customnpcs:npcDiamondSkirt"); - armor = new ItemSkirt(armorEmerald,"customnpcs:textures/armor/fullemerald_2.png").setUnlocalizedName("npcEmeraldSkirt").setTextureName("customnpcs:npcEmeraldSkirt"); - armor = new ItemSkirt(armorBronze,"customnpcs:textures/armor/fullbronze_2.png").setUnlocalizedName("npcBronzeSkirt").setTextureName("customnpcs:npcBronzeSkirt"); - armor = new ItemSkirt(ArmorMaterial.DIAMOND,"customnpcs:textures/armor/demonic_2.png").setUnlocalizedName("npcDemonicSkirt").setTextureName("customnpcs:npcDemonicSkirt"); - armor = new ItemSkirt(armorMithril,"customnpcs:textures/armor/mithril_2.png").setUnlocalizedName("npcMithrilSkirt").setTextureName("customnpcs:npcMithrilSkirt"); + armor = new ItemSkirt(ArmorMaterial.CHAIN, "textures/models/armor/chainmail_layer_2.png").setUnlocalizedName("npcChainSkirt").setTextureName("customnpcs:npcChainSkirt"); + armor = new ItemSkirt(ArmorMaterial.CLOTH, "textures/models/armor/leather_layer_2.png").setUnlocalizedName("npcLeatherSkirt").setTextureName("customnpcs:npcLeatherSkirt"); + armor = new ItemSkirt(ArmorMaterial.GOLD, "textures/models/armor/gold_layer_2.png").setUnlocalizedName("npcGoldSkirt").setTextureName("customnpcs:npcGoldSkirt"); + armor = new ItemSkirt(ArmorMaterial.IRON, "textures/models/armor/iron_layer_2.png").setUnlocalizedName("npcIronSkirt").setTextureName("customnpcs:npcIronSkirt"); + armor = new ItemSkirt(ArmorMaterial.DIAMOND, "textures/models/armor/diamond_layer_2.png").setUnlocalizedName("npcDiamondSkirt").setTextureName("customnpcs:npcDiamondSkirt"); + armor = new ItemSkirt(armorEmerald, "customnpcs:textures/armor/fullemerald_2.png").setUnlocalizedName("npcEmeraldSkirt").setTextureName("customnpcs:npcEmeraldSkirt"); + armor = new ItemSkirt(armorBronze, "customnpcs:textures/armor/fullbronze_2.png").setUnlocalizedName("npcBronzeSkirt").setTextureName("customnpcs:npcBronzeSkirt"); + armor = new ItemSkirt(ArmorMaterial.DIAMOND, "customnpcs:textures/armor/demonic_2.png").setUnlocalizedName("npcDemonicSkirt").setTextureName("customnpcs:npcDemonicSkirt"); + armor = new ItemSkirt(armorMithril, "customnpcs:textures/armor/mithril_2.png").setUnlocalizedName("npcMithrilSkirt").setTextureName("customnpcs:npcMithrilSkirt"); - coinWood = new ItemNpcInterface(26717).setUnlocalizedName("npcCoinWooden").setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcCoinWooden"); - coinStone = new ItemNpcInterface(26718).setUnlocalizedName("npcCoinStone").setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcCoinStone"); - coinBronze = new ItemNpcInterface(26719).setUnlocalizedName("npcCoinBronze").setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcCoinBronze"); - coinIron = new ItemNpcInterface(26720).setUnlocalizedName("npcCoinIron").setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcCoinIron"); - coinGold = new ItemNpcInterface(26721).setUnlocalizedName("npcCoinGold").setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcCoinGold"); - coinDiamond = new ItemNpcInterface(26722).setUnlocalizedName("npcCoinDiamond").setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcCoinDiamond"); - coinEmerald = new ItemNpcInterface(26723).setUnlocalizedName("npcCoinEmerald").setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcCoinEmerald"); - Item quest = new ItemNpcInterface().setUnlocalizedName("npcAncientCoin").setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcAncientCoin"); + coinWood = new ItemNpcInterface(26717).setUnlocalizedName("npcCoinWooden").setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcCoinWooden"); + coinStone = new ItemNpcInterface(26718).setUnlocalizedName("npcCoinStone").setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcCoinStone"); + coinBronze = new ItemNpcInterface(26719).setUnlocalizedName("npcCoinBronze").setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcCoinBronze"); + coinIron = new ItemNpcInterface(26720).setUnlocalizedName("npcCoinIron").setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcCoinIron"); + coinGold = new ItemNpcInterface(26721).setUnlocalizedName("npcCoinGold").setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcCoinGold"); + coinDiamond = new ItemNpcInterface(26722).setUnlocalizedName("npcCoinDiamond").setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcCoinDiamond"); + coinEmerald = new ItemNpcInterface(26723).setUnlocalizedName("npcCoinEmerald").setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcCoinEmerald"); + Item quest = new ItemNpcInterface().setUnlocalizedName("npcAncientCoin").setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcAncientCoin"); - letter = new ItemNpcInterface(26950).setUnlocalizedName("npcLetter").setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcLetter"); - quest = new ItemNpcInterface(26951).setUnlocalizedName("npcPlans").setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcPlans"); - satchel = new ItemNpcInterface(26952).setUnlocalizedName("npcSatchel").setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcSatchel"); - bag = new ItemNpcInterface(26953).setUnlocalizedName("npcBag").setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcBag"); + letter = new ItemNpcInterface(26950).setUnlocalizedName("npcLetter").setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcLetter"); + quest = new ItemNpcInterface(26951).setUnlocalizedName("npcPlans").setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcPlans"); + satchel = new ItemNpcInterface(26952).setUnlocalizedName("npcSatchel").setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcSatchel"); + bag = new ItemNpcInterface(26953).setUnlocalizedName("npcBag").setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcBag"); - quest = new ItemNpcInterface(26954).setUnlocalizedName("npcCrystal").setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcCrystal"); - quest = new ItemNpcInterface(26955).setUnlocalizedName("npcSeveredEar").setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcSeveredEar"); - quest = new ItemNpcInterface(26956).setUnlocalizedName("npcPhone").setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcPhone"); + quest = new ItemNpcInterface(26954).setUnlocalizedName("npcCrystal").setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcCrystal"); + quest = new ItemNpcInterface(26955).setUnlocalizedName("npcSeveredEar").setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcSeveredEar"); + quest = new ItemNpcInterface(26956).setUnlocalizedName("npcPhone").setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcPhone"); - quest = new ItemNpcArmor(26957,ArmorMaterial.IRON,0,"mask").setMaxStackSize(64).setUnlocalizedName("npcBanditMask").setCreativeTab(CustomItems.tabArmor).setTextureName("customnpcs:npcBanditMask"); - quest = new ItemNpcInterface(26958).setUnlocalizedName("npcBrokenArrow").setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcBrokenArrow"); - earthElement = new ItemNpcInterface(26959).setUnlocalizedName("npcEarthElement").setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcEarthElement"); - waterElement = new ItemNpcInterface(26960).setUnlocalizedName("npcWaterElement").setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcWaterElement"); + quest = new ItemNpcArmor(26957, ArmorMaterial.IRON, 0, "mask").setMaxStackSize(64).setUnlocalizedName("npcBanditMask").setCreativeTab(CustomItems.tabArmor).setTextureName("customnpcs:npcBanditMask"); + quest = new ItemNpcInterface(26958).setUnlocalizedName("npcBrokenArrow").setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcBrokenArrow"); + earthElement = new ItemNpcInterface(26959).setUnlocalizedName("npcEarthElement").setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcEarthElement"); + waterElement = new ItemNpcInterface(26960).setUnlocalizedName("npcWaterElement").setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcWaterElement"); fireElement = new ItemNpcInterface(26961).setUnlocalizedName("npcFireElement").setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcFireElement"); - airElement = new ItemNpcInterface(26962).setUnlocalizedName("npcAirElement").setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcAirElement"); + airElement = new ItemNpcInterface(26962).setUnlocalizedName("npcAirElement").setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcAirElement"); - quest = new ItemNpcInterface(26963).setUnlocalizedName("npcCarKey").setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcCarKey"); - quest = new ItemNpcInterface(26964).setUnlocalizedName("npcKey").setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcKey"); - quest = new ItemNpcInterface(26965).setUnlocalizedName("npcKey2").setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcKey2"); - quest = new ItemNpcInterface(26966).setUnlocalizedName("npcPendant").setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcPendant"); - quest = new ItemNpcInterface(26967).setUnlocalizedName("npcBlueprint").setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcBlueprint"); - quest = new ItemNpcInterface(26968).setUnlocalizedName("npcRing").setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcRing"); - quest = new ItemNpcInterface(26969).setUnlocalizedName("npcSkull").setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcSkull"); + quest = new ItemNpcInterface(26963).setUnlocalizedName("npcCarKey").setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcCarKey"); + quest = new ItemNpcInterface(26964).setUnlocalizedName("npcKey").setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcKey"); + quest = new ItemNpcInterface(26965).setUnlocalizedName("npcKey2").setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcKey2"); + quest = new ItemNpcInterface(26966).setUnlocalizedName("npcPendant").setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcPendant"); + quest = new ItemNpcInterface(26967).setUnlocalizedName("npcBlueprint").setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcBlueprint"); + quest = new ItemNpcInterface(26968).setUnlocalizedName("npcRing").setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcRing"); + quest = new ItemNpcInterface(26969).setUnlocalizedName("npcSkull").setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcSkull"); - Item sapphire = new ItemNpcInterface(26970).setUnlocalizedName("npcSaphire").setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcSaphire"); - Item ruby = new ItemNpcInterface(26971).setUnlocalizedName("npcRuby").setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcRuby"); - Item amethyst = new ItemNpcInterface(26972).setUnlocalizedName("npcAmethyst").setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcAmethyst"); + Item sapphire = new ItemNpcInterface(26970).setUnlocalizedName("npcSaphire").setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcSaphire"); + Item ruby = new ItemNpcInterface(26971).setUnlocalizedName("npcRuby").setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcRuby"); + Item amethyst = new ItemNpcInterface(26972).setUnlocalizedName("npcAmethyst").setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcAmethyst"); - OreDictionary.registerOre("gemSaphire", sapphire); - OreDictionary.registerOre("gemRuby", ruby); - OreDictionary.registerOre("gemAmethyst", amethyst); + OreDictionary.registerOre("gemSaphire", sapphire); + OreDictionary.registerOre("gemRuby", ruby); + OreDictionary.registerOre("gemAmethyst", amethyst); - bronze_ingot = new ItemNpcInterface(26973).setUnlocalizedName("npcBronzeIngot").setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcBronzeIngot"); - demonic_ingot = new ItemNpcInterface(26973).setUnlocalizedName("npcDemonicIngot").setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcDemonicIngot"); - mithril_ingot = new ItemNpcInterface(26973).setUnlocalizedName("npcMithrilIngot").setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcMithrilIngot"); + bronze_ingot = new ItemNpcInterface(26973).setUnlocalizedName("npcBronzeIngot").setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcBronzeIngot"); + demonic_ingot = new ItemNpcInterface(26973).setUnlocalizedName("npcDemonicIngot").setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcDemonicIngot"); + mithril_ingot = new ItemNpcInterface(26973).setUnlocalizedName("npcMithrilIngot").setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcMithrilIngot"); - armorMithril.customCraftingMaterial = mithril_ingot; + armorMithril.customCraftingMaterial = mithril_ingot; - bronze.customCraftingMaterial = bronze_ingot; - emerald.customCraftingMaterial = Items.emerald; - demonic.customCraftingMaterial = demonic_ingot; - frost.customCraftingMaterial = Item.getItemFromBlock(Blocks.ice); - mithril.customCraftingMaterial = mithril_ingot; + bronze.customCraftingMaterial = bronze_ingot; + emerald.customCraftingMaterial = Items.emerald; + demonic.customCraftingMaterial = demonic_ingot; + frost.customCraftingMaterial = Item.getItemFromBlock(Blocks.ice); + mithril.customCraftingMaterial = mithril_ingot; - OreDictionary.registerOre("ingotBronze", bronze_ingot); - OreDictionary.registerOre("ingotDemonic", demonic_ingot); - OreDictionary.registerOre("ingotMithril", mithril_ingot); + OreDictionary.registerOre("ingotBronze", bronze_ingot); + OreDictionary.registerOre("ingotDemonic", demonic_ingot); + OreDictionary.registerOre("ingotMithril", mithril_ingot); - quest = new ItemNpcInterface().setUnlocalizedName("npcAncientScroll").setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcAncientScroll"); - quest = new ItemNpcInterface().setUnlocalizedName("npcArtifact").setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcArtifact"); - quest = new ItemNpcInterface().setUnlocalizedName("npcLocket").setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcLocket"); - quest = new ItemNpcInterface().setUnlocalizedName("npcSilk").setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcSilk"); - quest = new ItemNpcInterface().setUnlocalizedName("npcStatuette").setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcStatuette"); - quest = new ItemNpcInterface().setUnlocalizedName("npcTablet").setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcTablet"); + quest = new ItemNpcInterface().setUnlocalizedName("npcAncientScroll").setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcAncientScroll"); + quest = new ItemNpcInterface().setUnlocalizedName("npcArtifact").setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcArtifact"); + quest = new ItemNpcInterface().setUnlocalizedName("npcLocket").setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcLocket"); + quest = new ItemNpcInterface().setUnlocalizedName("npcSilk").setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcSilk"); + quest = new ItemNpcInterface().setUnlocalizedName("npcStatuette").setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcStatuette"); + quest = new ItemNpcInterface().setUnlocalizedName("npcTablet").setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcTablet"); - quest = new ItemNpcInterface().setUnlocalizedName("npcHeart").setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcHeart"); - quest = new ItemNpcInterface().setUnlocalizedName("npcMoney").setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcMoney"); - quest = new ItemNpcInterface().setUnlocalizedName("npcNecklace").setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcNecklace"); - quest = new ItemNpcInterface().setUnlocalizedName("npcUsbStick").setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcUsbStick"); + quest = new ItemNpcInterface().setUnlocalizedName("npcHeart").setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcHeart"); + quest = new ItemNpcInterface().setUnlocalizedName("npcMoney").setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcMoney"); + quest = new ItemNpcInterface().setUnlocalizedName("npcNecklace").setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcNecklace"); + quest = new ItemNpcInterface().setUnlocalizedName("npcUsbStick").setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcUsbStick"); - tabArmor.item = cowarmor; - tabWeapon.item = CustomItems.shuriken; - tabMisc.item = CustomItems.coinGold; - } + tabArmor.item = cowarmor; + tabWeapon.item = CustomItems.shuriken; + tabMisc.item = CustomItems.coinGold; + } - tab.item = wand; - } + tab.item = wand; + } } diff --git a/src/main/java/noppes/npcs/CustomNpcs.java b/src/main/java/noppes/npcs/CustomNpcs.java index dd9068a85..5e9a988a5 100644 --- a/src/main/java/noppes/npcs/CustomNpcs.java +++ b/src/main/java/noppes/npcs/CustomNpcs.java @@ -12,6 +12,7 @@ import foxz.command.CommandNoppes; import kamkeel.npcs.addon.AddonManager; import kamkeel.npcs.command.CommandKamkeel; import kamkeel.npcs.command.profile.CommandProfile; +import kamkeel.npcs.controllers.AttributeController; import kamkeel.npcs.controllers.ProfileController; import kamkeel.npcs.controllers.data.profile.CNPCData; import kamkeel.npcs.developer.Developer; @@ -27,7 +28,6 @@ import net.minecraft.server.MinecraftServer; import net.minecraftforge.common.ForgeChunkManager; import net.minecraftforge.common.MinecraftForge; import nikedemos.markovnames.generators.*; -import kamkeel.npcs.controllers.AttributeController; import noppes.npcs.compat.PixelmonHelper; import noppes.npcs.config.ConfigMain; import noppes.npcs.config.LoadConfiguration; @@ -100,10 +100,10 @@ public class CustomNpcs { legacyPath = ev.getModConfigurationDirectory() + "/CustomNpcs.cfg"; File configDir = new File(configPath); - if(!configDir.exists()){ + if (!configDir.exists()) { // Convert Legacy Config to New Config if NO Config Folder Exists File legacyFile = new File(legacyPath); - if(legacyFile.exists()){ + if (legacyFile.exists()) { System.out.println("Loading Legacy Config"); legacyExist = true; legacyConfig = new LegacyConfig(); @@ -228,15 +228,15 @@ public class CustomNpcs { PlayerDataController.Instance.clearCache(); Set names = Block.blockRegistry.getKeys(); - for(String name : names){ + for (String name : names) { Block block = (Block) Block.blockRegistry.getObject(name); - if(block instanceof BlockLeavesBase){ + if (block instanceof BlockLeavesBase) { block.setTickRandomly(ConfigMain.LeavesDecayEnabled); } - if(block instanceof BlockVine){ + if (block instanceof BlockVine) { block.setTickRandomly(ConfigMain.VineGrowthEnabled); } - if(block instanceof BlockIce){ + if (block instanceof BlockIce) { block.setTickRandomly(ConfigMain.IceMeltsEnabled); } } @@ -256,7 +256,7 @@ public class CustomNpcs { @EventHandler - public void stopped(FMLServerStoppedEvent event){ + public void stopped(FMLServerStoppedEvent event) { ServerCloneController.Instance = null; GlobalDataController.Instance.saveData(); ScriptController.Instance.saveForgeScripts(); @@ -268,7 +268,7 @@ public class CustomNpcs { public void serverstart(FMLServerStartingEvent event) { event.registerServerCommand(new CommandNoppes()); event.registerServerCommand(new CommandKamkeel()); - if(ConfigMain.ProfilesEnabled) + if (ConfigMain.ProfilesEnabled) event.registerServerCommand(new CommandProfile()); } @@ -323,7 +323,7 @@ public class CustomNpcs { } } - public static MinecraftServer getServer(){ + public static MinecraftServer getServer() { return MinecraftServer.getServer(); } diff --git a/src/main/java/noppes/npcs/CustomNpcsPermissions.java b/src/main/java/noppes/npcs/CustomNpcsPermissions.java index 71419fada..6d0cbc0c1 100644 --- a/src/main/java/noppes/npcs/CustomNpcsPermissions.java +++ b/src/main/java/noppes/npcs/CustomNpcsPermissions.java @@ -14,7 +14,7 @@ import java.util.Collections; import java.util.List; -public class CustomNpcsPermissions{ +public class CustomNpcsPermissions { // Open GUI public static final Permission NPC_GUI = new Permission("customnpcs.npc.gui"); public static final Permission PAINTBRUSH_GUI = new Permission("customnpcs.npc.paintbrush"); @@ -24,7 +24,7 @@ public class CustomNpcsPermissions{ // Modify NPC public static final Permission NPC_DELETE = new Permission("customnpcs.npc.delete"); - public static final Permission NPC_CREATE = new Permission("customnpcs.npc.create"); + public static final Permission NPC_CREATE = new Permission("customnpcs.npc.create"); public static final Permission NPC_RESET = new Permission("customnpcs.npc.reset"); // Extra NPCs @@ -32,43 +32,43 @@ public class CustomNpcsPermissions{ public static final Permission NPC_TELEPORT = new Permission("customnpcs.npc.teleport"); // Save NPC - public static final Permission NPC_AI = new Permission("customnpcs.npc.ai"); - public static final Permission NPC_ADVANCED = new Permission("customnpcs.npc.advanced"); - public static final Permission NPC_DISPLAY = new Permission("customnpcs.npc.display"); - public static final Permission NPC_INVENTORY = new Permission("customnpcs.npc.inventory"); - public static final Permission NPC_STATS = new Permission("customnpcs.npc.stats"); - public static final Permission NPC_CLONE = new Permission("customnpcs.npc.clone"); + public static final Permission NPC_AI = new Permission("customnpcs.npc.ai"); + public static final Permission NPC_ADVANCED = new Permission("customnpcs.npc.advanced"); + public static final Permission NPC_DISPLAY = new Permission("customnpcs.npc.display"); + public static final Permission NPC_INVENTORY = new Permission("customnpcs.npc.inventory"); + public static final Permission NPC_STATS = new Permission("customnpcs.npc.stats"); + public static final Permission NPC_CLONE = new Permission("customnpcs.npc.clone"); public static final Permission GLOBAL_REMOTE = new Permission("customnpcs.global.remote"); // Save Globel Preferences public static final Permission GLOBAL_LINKED = new Permission("customnpcs.global.linked"); - public static final Permission GLOBAL_PLAYERDATA = new Permission("customnpcs.global.playerdata"); - public static final Permission GLOBAL_BANK = new Permission("customnpcs.global.bank"); - public static final Permission GLOBAL_DIALOG = new Permission("customnpcs.global.dialog"); - public static final Permission GLOBAL_QUEST = new Permission("customnpcs.global.quest"); - public static final Permission GLOBAL_FACTION = new Permission("customnpcs.global.faction"); - public static final Permission GLOBAL_TRANSPORT = new Permission("customnpcs.global.transport"); - public static final Permission GLOBAL_RECIPE = new Permission("customnpcs.global.recipe"); - public static final Permission GLOBAL_NATURALSPAWN = new Permission("customnpcs.global.naturalspawn"); - public static final Permission GLOBAL_TAG = new Permission("customnpcs.global.tag"); + public static final Permission GLOBAL_PLAYERDATA = new Permission("customnpcs.global.playerdata"); + public static final Permission GLOBAL_BANK = new Permission("customnpcs.global.bank"); + public static final Permission GLOBAL_DIALOG = new Permission("customnpcs.global.dialog"); + public static final Permission GLOBAL_QUEST = new Permission("customnpcs.global.quest"); + public static final Permission GLOBAL_FACTION = new Permission("customnpcs.global.faction"); + public static final Permission GLOBAL_TRANSPORT = new Permission("customnpcs.global.transport"); + public static final Permission GLOBAL_RECIPE = new Permission("customnpcs.global.recipe"); + public static final Permission GLOBAL_NATURALSPAWN = new Permission("customnpcs.global.naturalspawn"); + public static final Permission GLOBAL_TAG = new Permission("customnpcs.global.tag"); public static final Permission GLOBAL_ANIMATION = new Permission("customnpcs.global.animation"); public static final Permission GLOBAL_MAGIC = new Permission("customnpcs.global.magic"); public static final Permission GLOBAL_EFFECT = new Permission("customnpcs.global.effect"); public static final Permission SPAWNER_MOB = new Permission("customnpcs.spawner.mob"); - public static final Permission SPAWNER_CREATE = new Permission("customnpcs.spawner.create"); + public static final Permission SPAWNER_CREATE = new Permission("customnpcs.spawner.create"); // Open / Use Wands - public static final Permission TOOL_MOUNTER = new Permission("customnpcs.tool.mounter"); - public static final Permission TOOL_PATHER = new Permission("customnpcs.tool.pather"); - public static final Permission TOOL_SCRIPTER = new Permission("customnpcs.tool.scripter"); + public static final Permission TOOL_MOUNTER = new Permission("customnpcs.tool.mounter"); + public static final Permission TOOL_PATHER = new Permission("customnpcs.tool.pather"); + public static final Permission TOOL_SCRIPTER = new Permission("customnpcs.tool.scripter"); public static final Permission TOOL_CLONER = new Permission("customnpcs.tool.cloner"); public static final Permission TOOL_SCRIPTED_ITEM = new Permission("customnpcs.tool.scripteditem"); public static final Permission TOOL_TELEPORTER = new Permission("customnpcs.tool.teleporter"); // Edit Villager - public static final Permission EDIT_VILLAGER = new Permission("customnpcs.edit.villager"); + public static final Permission EDIT_VILLAGER = new Permission("customnpcs.edit.villager"); public static final Permission EDIT_BLOCKS = new Permission("customnpcs.edit.blocks"); public static final Permission EDIT_REDSTONE = new Permission("customnpcs.edit.redstone"); @@ -97,87 +97,90 @@ public class CustomNpcsPermissions{ public static final Permission PROFILE_REGION_BYPASS = new Permission("customnpcs.profile.region-bypass"); public static final Permission PROFILE_MAX = new Permission("customnpcs.profile.max.*"); - public static CustomNpcsPermissions Instance; - private Class bukkit; - private Method getPlayer; - private Method hasPermission; + public static CustomNpcsPermissions Instance; + private Class bukkit; + private Method getPlayer; + private Method hasPermission; - public CustomNpcsPermissions(){ - Instance = this; - try { - bukkit = Class.forName("org.bukkit.Bukkit"); - getPlayer = bukkit.getMethod("getPlayer", String.class); - hasPermission = Class.forName("org.bukkit.entity.Player").getMethod("hasPermission", String.class); - LogManager.getLogger(CustomNpcs.class).info("Bukkit permissions enabled"); - LogManager.getLogger(CustomNpcs.class).info("Permissions available:"); - Collections.sort(Permission.permissions, String.CASE_INSENSITIVE_ORDER); - for(String p : Permission.permissions){ - LogManager.getLogger(CustomNpcs.class).info(p); - } - } catch (ClassNotFoundException e) { - // bukkit/mcpc+ is not loaded - } catch (NoSuchMethodException e) { - e.printStackTrace(); - } catch (SecurityException e) { - e.printStackTrace(); - } - } + public CustomNpcsPermissions() { + Instance = this; + try { + bukkit = Class.forName("org.bukkit.Bukkit"); + getPlayer = bukkit.getMethod("getPlayer", String.class); + hasPermission = Class.forName("org.bukkit.entity.Player").getMethod("hasPermission", String.class); + LogManager.getLogger(CustomNpcs.class).info("Bukkit permissions enabled"); + LogManager.getLogger(CustomNpcs.class).info("Permissions available:"); + Collections.sort(Permission.permissions, String.CASE_INSENSITIVE_ORDER); + for (String p : Permission.permissions) { + LogManager.getLogger(CustomNpcs.class).info(p); + } + } catch (ClassNotFoundException e) { + // bukkit/mcpc+ is not loaded + } catch (NoSuchMethodException e) { + e.printStackTrace(); + } catch (SecurityException e) { + e.printStackTrace(); + } + } - public static boolean hasPermission(EntityPlayer player, Permission permission){ - if(player != null){ - if(FMLCommonHandler.instance().getSide() == Side.SERVER && NoppesUtilServer.isOp(player)) + public static boolean hasPermission(EntityPlayer player, Permission permission) { + if (player != null) { + if (FMLCommonHandler.instance().getSide() == Side.SERVER && NoppesUtilServer.isOp(player)) return true; - if(Developer.Instance.hasUniversal(player.getUniqueID())) - return true; - if(permission != null){ - if(Instance.bukkit != null){ - return Instance.bukkitPermission(player.getCommandSenderName(), permission.name); - } - } - } - return true; - } + if (Developer.Instance.hasUniversal(player.getUniqueID())) + return true; + if (permission != null) { + if (Instance.bukkit != null) { + return Instance.bukkitPermission(player.getCommandSenderName(), permission.name); + } + } + } + return true; + } - public static boolean hasCustomPermission(EntityPlayer player, String permission){ - if(Developer.Instance.hasUniversal(player.getUniqueID())){ - return true; - } - if(Instance.bukkit != null){ - return Instance.bukkitPermission(player.getCommandSenderName(), permission); - } - return false; - } + public static boolean hasCustomPermission(EntityPlayer player, String permission) { + if (Developer.Instance.hasUniversal(player.getUniqueID())) { + return true; + } + if (Instance.bukkit != null) { + return Instance.bukkitPermission(player.getCommandSenderName(), permission); + } + return false; + } - private boolean bukkitPermission(String username, String permission) { - try { - Object player = getPlayer.invoke(null, username); - return (Boolean) hasPermission.invoke(player, permission); - } catch (IllegalAccessException e) { - e.printStackTrace(); - } catch (IllegalArgumentException e) { - e.printStackTrace(); - } catch (InvocationTargetException e) { - e.printStackTrace(); - } - return false; - } - public static class Permission{ - private static final List permissions = new ArrayList(); - public String name; - public Permission(String name){ - this.name = name; - if(!permissions.contains(name)) - permissions.add(name); - } - } - public static boolean hasPermissionString(EntityPlayerMP player, String permission) { - if(Instance.bukkit != null){ - return Instance.bukkitPermission(player.getCommandSenderName(), permission); - } - return true; - } + private boolean bukkitPermission(String username, String permission) { + try { + Object player = getPlayer.invoke(null, username); + return (Boolean) hasPermission.invoke(player, permission); + } catch (IllegalAccessException e) { + e.printStackTrace(); + } catch (IllegalArgumentException e) { + e.printStackTrace(); + } catch (InvocationTargetException e) { + e.printStackTrace(); + } + return false; + } - public static boolean enabled() { - return Instance.bukkit != null; - } + public static class Permission { + private static final List permissions = new ArrayList(); + public String name; + + public Permission(String name) { + this.name = name; + if (!permissions.contains(name)) + permissions.add(name); + } + } + + public static boolean hasPermissionString(EntityPlayerMP player, String permission) { + if (Instance.bukkit != null) { + return Instance.bukkitPermission(player.getCommandSenderName(), permission); + } + return true; + } + + public static boolean enabled() { + return Instance.bukkit != null; + } } diff --git a/src/main/java/noppes/npcs/CustomTeleporter.java b/src/main/java/noppes/npcs/CustomTeleporter.java index 5800ad606..0ddf3c874 100644 --- a/src/main/java/noppes/npcs/CustomTeleporter.java +++ b/src/main/java/noppes/npcs/CustomTeleporter.java @@ -4,15 +4,14 @@ import net.minecraft.entity.Entity; import net.minecraft.world.Teleporter; import net.minecraft.world.WorldServer; -public class CustomTeleporter extends Teleporter{ - - public CustomTeleporter(WorldServer par1WorldServer) { - super(par1WorldServer); - } +public class CustomTeleporter extends Teleporter { + + public CustomTeleporter(WorldServer par1WorldServer) { + super(par1WorldServer); + } + + @Override + public void placeInPortal(Entity par1Entity, double par2, double par4, double par6, float par8) { - @Override - public void placeInPortal(Entity par1Entity, double par2, double par4, double par6, float par8) - { - } } diff --git a/src/main/java/noppes/npcs/DataAI.java b/src/main/java/noppes/npcs/DataAI.java index 3952cc421..a85b214d8 100644 --- a/src/main/java/noppes/npcs/DataAI.java +++ b/src/main/java/noppes/npcs/DataAI.java @@ -12,255 +12,249 @@ import java.util.List; public class DataAI { private EntityNPCInterface npc; - public int onAttack = 0; //0:fight 1:panic 2:retreat 3:nothing - public int doorInteract = 2; - public int findShelter = 2; - public int distanceToMelee = 4; - public int canFireIndirect = 0; - public boolean canSwim = true; - public boolean reactsToFire = false; - public boolean avoidsWater = false; - public boolean avoidsSun = false; - public boolean returnToStart = true; - public boolean directLOS = true; - public int leapType = 0; - public boolean canSprint = false; - public boolean stopAndInteract = true; - public EnumNavType tacticalVariant = EnumNavType.Default; - public EnumCombatPolicy combatPolicy = EnumCombatPolicy.Flip; - public int useRangeMelee = 0; - public int tacticalRadius = 8; - public int tacticalChance = 5; + public int onAttack = 0; //0:fight 1:panic 2:retreat 3:nothing + public int doorInteract = 2; + public int findShelter = 2; + public int distanceToMelee = 4; + public int canFireIndirect = 0; + public boolean canSwim = true; + public boolean reactsToFire = false; + public boolean avoidsWater = false; + public boolean avoidsSun = false; + public boolean returnToStart = true; + public boolean directLOS = true; + public int leapType = 0; + public boolean canSprint = false; + public boolean stopAndInteract = true; + public EnumNavType tacticalVariant = EnumNavType.Default; + public EnumCombatPolicy combatPolicy = EnumCombatPolicy.Flip; + public int useRangeMelee = 0; + public int tacticalRadius = 8; + public int tacticalChance = 5; - public int movementType = 0; // 0 - Ground , 1 - Flying - public double flySpeed = 1.0D; - public double flyGravity = 0.0D; - public boolean hasFlyLimit = true; - public int flyHeightLimit = 2; + public int movementType = 0; // 0 - Ground , 1 - Flying + public double flySpeed = 1.0D; + public double flyGravity = 0.0D; + public boolean hasFlyLimit = true; + public int flyHeightLimit = 2; - public EnumAnimation animationType = EnumAnimation.NONE; - public EnumStandingType standingType = EnumStandingType.RotateBody; - public EnumMovingType movingType = EnumMovingType.Standing; - public boolean npcInteracting = true; + public EnumAnimation animationType = EnumAnimation.NONE; + public EnumStandingType standingType = EnumStandingType.RotateBody; + public EnumMovingType movingType = EnumMovingType.Standing; + public boolean npcInteracting = true; - public int orientation = 0; - public float bodyOffsetX = 5, bodyOffsetY = 5, bodyOffsetZ = 5; - public int walkingRange = 10; - private int moveSpeed = 5; + public int orientation = 0; + public float bodyOffsetX = 5, bodyOffsetY = 5, bodyOffsetZ = 5; + public int walkingRange = 10; + private int moveSpeed = 5; - private List movingPath = new ArrayList(); - public int[] startPos; - public int movingPos = 0; - public int movingPattern = 0; // 0:Looping 1:Backtracking + private List movingPath = new ArrayList(); + public int[] startPos; + public int movingPos = 0; + public int movingPattern = 0; // 0:Looping 1:Backtracking - public boolean movingPause = true; + public boolean movingPause = true; - public DataAI(EntityNPCInterface npc){ - this.npc = npc; - } + public DataAI(EntityNPCInterface npc) { + this.npc = npc; + } - public void readToNBT(NBTTagCompound compound) { - canSwim = compound.getBoolean("CanSwim"); - reactsToFire = compound.getBoolean("ReactsToFire"); - avoidsWater = compound.getBoolean("AvoidsWater"); - avoidsSun = compound.getBoolean("AvoidsSun"); - returnToStart = compound.getBoolean("ReturnToStart"); - onAttack = compound.getInteger("OnAttack"); - doorInteract = compound.getInteger("DoorInteract"); - findShelter = compound.getInteger("FindShelter"); - directLOS = compound.getBoolean("DirectLOS"); - leapType = compound.getInteger("LeapType"); - canSprint = compound.getBoolean("CanSprint"); - canFireIndirect = compound.getInteger("FireIndirect"); - useRangeMelee = compound.getInteger("RangeAndMelee"); - distanceToMelee = compound.getInteger("DistanceToMelee"); - tacticalRadius = compound.getInteger("TacticalRadius"); - tacticalChance = compound.getInteger("TacticalChance"); - movingPause = compound.getBoolean("MovingPause"); - npcInteracting = compound.getBoolean("npcInteracting"); - stopAndInteract = compound.getBoolean("stopAndInteract"); + public void readToNBT(NBTTagCompound compound) { + canSwim = compound.getBoolean("CanSwim"); + reactsToFire = compound.getBoolean("ReactsToFire"); + avoidsWater = compound.getBoolean("AvoidsWater"); + avoidsSun = compound.getBoolean("AvoidsSun"); + returnToStart = compound.getBoolean("ReturnToStart"); + onAttack = compound.getInteger("OnAttack"); + doorInteract = compound.getInteger("DoorInteract"); + findShelter = compound.getInteger("FindShelter"); + directLOS = compound.getBoolean("DirectLOS"); + leapType = compound.getInteger("LeapType"); + canSprint = compound.getBoolean("CanSprint"); + canFireIndirect = compound.getInteger("FireIndirect"); + useRangeMelee = compound.getInteger("RangeAndMelee"); + distanceToMelee = compound.getInteger("DistanceToMelee"); + tacticalRadius = compound.getInteger("TacticalRadius"); + tacticalChance = compound.getInteger("TacticalChance"); + movingPause = compound.getBoolean("MovingPause"); + npcInteracting = compound.getBoolean("npcInteracting"); + stopAndInteract = compound.getBoolean("stopAndInteract"); - animationType = EnumAnimation.values()[compound.getInteger("MoveState") % EnumAnimation.values().length]; - standingType = EnumStandingType.values()[compound.getInteger("StandingState") % EnumStandingType.values().length]; - movingType = EnumMovingType.values()[compound.getInteger("MovingState") % EnumMovingType.values().length]; - tacticalVariant = EnumNavType.values()[compound.getInteger("TacticalVariant") % EnumNavType.values().length]; - combatPolicy = EnumCombatPolicy.values()[compound.getInteger("CombatPolicy") % EnumCombatPolicy.values().length]; + animationType = EnumAnimation.values()[compound.getInteger("MoveState") % EnumAnimation.values().length]; + standingType = EnumStandingType.values()[compound.getInteger("StandingState") % EnumStandingType.values().length]; + movingType = EnumMovingType.values()[compound.getInteger("MovingState") % EnumMovingType.values().length]; + tacticalVariant = EnumNavType.values()[compound.getInteger("TacticalVariant") % EnumNavType.values().length]; + combatPolicy = EnumCombatPolicy.values()[compound.getInteger("CombatPolicy") % EnumCombatPolicy.values().length]; - orientation = compound.getInteger("Orientation"); - bodyOffsetY = compound.getFloat("PositionOffsetY"); - bodyOffsetZ = compound.getFloat("PositionOffsetZ"); - bodyOffsetX = compound.getFloat("PositionOffsetX"); - walkingRange = compound.getInteger("WalkingRange"); - setWalkingSpeed(compound.getInteger("MoveSpeed")); + orientation = compound.getInteger("Orientation"); + bodyOffsetY = compound.getFloat("PositionOffsetY"); + bodyOffsetZ = compound.getFloat("PositionOffsetZ"); + bodyOffsetX = compound.getFloat("PositionOffsetX"); + walkingRange = compound.getInteger("WalkingRange"); + setWalkingSpeed(compound.getInteger("MoveSpeed")); - setMovingPath(NBTTags.getIntegerArraySet(compound.getTagList("MovingPathNew",10))); - movingPos = compound.getInteger("MovingPos"); - movingPattern = compound.getInteger("MovingPatern"); + setMovingPath(NBTTags.getIntegerArraySet(compound.getTagList("MovingPathNew", 10))); + movingPos = compound.getInteger("MovingPos"); + movingPattern = compound.getInteger("MovingPatern"); - movementType = compound.getInteger("MovingType"); - if(!compound.hasKey("FlySpeed")) - flySpeed = 1.0D; - else - flySpeed = compound.getDouble("FlySpeed"); + movementType = compound.getInteger("MovingType"); + if (!compound.hasKey("FlySpeed")) + flySpeed = 1.0D; + else + flySpeed = compound.getDouble("FlySpeed"); - if(!compound.hasKey("FlyGravity")) - flyGravity = 0.0D; - else - flyGravity = compound.getDouble("FlyGravity"); + if (!compound.hasKey("FlyGravity")) + flyGravity = 0.0D; + else + flyGravity = compound.getDouble("FlyGravity"); - if(!compound.hasKey("HasFlyLimit")) - hasFlyLimit = false; - else - hasFlyLimit = compound.getBoolean("HasFlyLimit"); + if (!compound.hasKey("HasFlyLimit")) + hasFlyLimit = false; + else + hasFlyLimit = compound.getBoolean("HasFlyLimit"); - if(!compound.hasKey("FlyHeightLimit")) - flyHeightLimit = 5; - else - flyHeightLimit = compound.getInteger("FlyHeightLimit"); + if (!compound.hasKey("FlyHeightLimit")) + flyHeightLimit = 5; + else + flyHeightLimit = compound.getInteger("FlyHeightLimit"); - startPos = compound.getIntArray("StartPosNew"); - if (startPos == null || startPos.length != 3){ - startPos = new int[] { - MathHelper.floor_double(npc.posX), - MathHelper.floor_double(npc.posY), - MathHelper.floor_double(npc.posZ) }; - } - } + startPos = compound.getIntArray("StartPosNew"); + if (startPos == null || startPos.length != 3) { + startPos = new int[]{ + MathHelper.floor_double(npc.posX), + MathHelper.floor_double(npc.posY), + MathHelper.floor_double(npc.posZ)}; + } + } - public NBTTagCompound writeToNBT(NBTTagCompound compound) { - compound.setBoolean("CanSwim", canSwim); - compound.setBoolean("ReactsToFire", reactsToFire); - compound.setBoolean("AvoidsWater", avoidsWater ); - compound.setBoolean("AvoidsSun", avoidsSun); - compound.setBoolean("ReturnToStart", returnToStart); - compound.setInteger("OnAttack", onAttack); - compound.setInteger("DoorInteract", doorInteract); - compound.setInteger("FindShelter", findShelter); - compound.setBoolean("DirectLOS", directLOS); - compound.setInteger("LeapType", leapType); - compound.setBoolean("CanSprint", canSprint); - compound.setInteger("FireIndirect", canFireIndirect); - compound.setInteger("RangeAndMelee", useRangeMelee); - compound.setInteger("DistanceToMelee", distanceToMelee); - compound.setInteger("TacticalRadius", tacticalRadius); - compound.setInteger("TacticalChance", tacticalChance); - compound.setBoolean("MovingPause", movingPause); - compound.setBoolean("npcInteracting", npcInteracting); - compound.setBoolean("stopAndInteract", stopAndInteract); + public NBTTagCompound writeToNBT(NBTTagCompound compound) { + compound.setBoolean("CanSwim", canSwim); + compound.setBoolean("ReactsToFire", reactsToFire); + compound.setBoolean("AvoidsWater", avoidsWater); + compound.setBoolean("AvoidsSun", avoidsSun); + compound.setBoolean("ReturnToStart", returnToStart); + compound.setInteger("OnAttack", onAttack); + compound.setInteger("DoorInteract", doorInteract); + compound.setInteger("FindShelter", findShelter); + compound.setBoolean("DirectLOS", directLOS); + compound.setInteger("LeapType", leapType); + compound.setBoolean("CanSprint", canSprint); + compound.setInteger("FireIndirect", canFireIndirect); + compound.setInteger("RangeAndMelee", useRangeMelee); + compound.setInteger("DistanceToMelee", distanceToMelee); + compound.setInteger("TacticalRadius", tacticalRadius); + compound.setInteger("TacticalChance", tacticalChance); + compound.setBoolean("MovingPause", movingPause); + compound.setBoolean("npcInteracting", npcInteracting); + compound.setBoolean("stopAndInteract", stopAndInteract); - compound.setInteger("MoveState", animationType.ordinal()); - compound.setInteger("StandingState", standingType.ordinal()); - compound.setInteger("MovingState", movingType.ordinal()); - compound.setInteger("TacticalVariant", tacticalVariant.ordinal()); - compound.setInteger("CombatPolicy", combatPolicy.ordinal()); + compound.setInteger("MoveState", animationType.ordinal()); + compound.setInteger("StandingState", standingType.ordinal()); + compound.setInteger("MovingState", movingType.ordinal()); + compound.setInteger("TacticalVariant", tacticalVariant.ordinal()); + compound.setInteger("CombatPolicy", combatPolicy.ordinal()); - compound.setInteger("Orientation", orientation); - compound.setFloat("PositionOffsetX", bodyOffsetX); - compound.setFloat("PositionOffsetY", bodyOffsetY); - compound.setFloat("PositionOffsetZ", bodyOffsetZ); - compound.setInteger("WalkingRange", walkingRange); - compound.setInteger("MoveSpeed", moveSpeed); + compound.setInteger("Orientation", orientation); + compound.setFloat("PositionOffsetX", bodyOffsetX); + compound.setFloat("PositionOffsetY", bodyOffsetY); + compound.setFloat("PositionOffsetZ", bodyOffsetZ); + compound.setInteger("WalkingRange", walkingRange); + compound.setInteger("MoveSpeed", moveSpeed); - compound.setTag("MovingPathNew", NBTTags.nbtIntegerArraySet(movingPath)); - compound.setInteger("MovingPos", movingPos); - compound.setInteger("MovingPatern", movingPattern); + compound.setTag("MovingPathNew", NBTTags.nbtIntegerArraySet(movingPath)); + compound.setInteger("MovingPos", movingPos); + compound.setInteger("MovingPatern", movingPattern); - compound.setInteger("MovingType", movementType); - compound.setDouble("FlySpeed",flySpeed); - compound.setDouble("FlyGravity",flyGravity); - compound.setBoolean("HasFlyLimit",hasFlyLimit); - compound.setInteger("FlyHeightLimit", flyHeightLimit); + compound.setInteger("MovingType", movementType); + compound.setDouble("FlySpeed", flySpeed); + compound.setDouble("FlyGravity", flyGravity); + compound.setBoolean("HasFlyLimit", hasFlyLimit); + compound.setInteger("FlyHeightLimit", flyHeightLimit); - npc.setAvoidWater(avoidsWater); + npc.setAvoidWater(avoidsWater); - compound.setIntArray("StartPosNew", npc.getStartPos()); + compound.setIntArray("StartPosNew", npc.getStartPos()); - return compound; - } + return compound; + } - public List getMovingPath() { - if(movingPath.isEmpty() && startPos != null) - movingPath.add(startPos); - return movingPath; - } + public List getMovingPath() { + if (movingPath.isEmpty() && startPos != null) + movingPath.add(startPos); + return movingPath; + } - public void setMovingPath(List list) { - movingPath = list; - if(!movingPath.isEmpty()) - startPos = movingPath.get(0); - } + public void setMovingPath(List list) { + movingPath = list; + if (!movingPath.isEmpty()) + startPos = movingPath.get(0); + } - public int[] getCurrentMovingPath(){ - List list = getMovingPath(); - if(list.size() == 1){ - movingPos = 0; - } - else if(movingPos >= list.size()){ - if(movingPattern == 0) - movingPos = 0; - else{ - int size = list.size() * 2 - 2; - if(movingPos >= size){ - movingPos = 0; - } - else if(movingPos >= list.size()){ - return list.get(list.size() - (movingPos % list.size()) - 2); - } - } - } + public int[] getCurrentMovingPath() { + List list = getMovingPath(); + if (list.size() == 1) { + movingPos = 0; + } else if (movingPos >= list.size()) { + if (movingPattern == 0) + movingPos = 0; + else { + int size = list.size() * 2 - 2; + if (movingPos >= size) { + movingPos = 0; + } else if (movingPos >= list.size()) { + return list.get(list.size() - (movingPos % list.size()) - 2); + } + } + } - return list.get(movingPos); - } + return list.get(movingPos); + } - public void incrementMovingPath(){ - List list = getMovingPath(); - if(list.size() == 1){ - movingPos = 0; - } - else if(movingPattern == 0){ - movingPos++; - movingPos = movingPos % list.size(); - } - else if(movingPattern == 1){ - movingPos++; - int size = list.size() * 2 - 2; - movingPos = movingPos % size; - } - } + public void incrementMovingPath() { + List list = getMovingPath(); + if (list.size() == 1) { + movingPos = 0; + } else if (movingPattern == 0) { + movingPos++; + movingPos = movingPos % list.size(); + } else if (movingPattern == 1) { + movingPos++; + int size = list.size() * 2 - 2; + movingPos = movingPos % size; + } + } - public void decreaseMovingPath() { - List list = getMovingPath(); - if(list.size() == 1){ - movingPos = 0; - } - else if(movingPattern == 0){ - movingPos--; - if(movingPos < 0) - movingPos += list.size(); - } - else if(movingPattern == 1){ - movingPos--; - if(movingPos < 0){ - int size = list.size() * 2 - 2; - movingPos += size; - } - } - } + public void decreaseMovingPath() { + List list = getMovingPath(); + if (list.size() == 1) { + movingPos = 0; + } else if (movingPattern == 0) { + movingPos--; + if (movingPos < 0) + movingPos += list.size(); + } else if (movingPattern == 1) { + movingPos--; + if (movingPos < 0) { + int size = list.size() * 2 - 2; + movingPos += size; + } + } + } - public double getDistanceSqToPathPoint() { - int[] pos = getCurrentMovingPath(); - return npc.getDistanceSq(pos[0] + 0.5, pos[1], pos[2] + 0.5); - } + public double getDistanceSqToPathPoint() { + int[] pos = getCurrentMovingPath(); + return npc.getDistanceSq(pos[0] + 0.5, pos[1], pos[2] + 0.5); + } - public void setWalkingSpeed(double speed){ - this.moveSpeed = (int)speed; - npc.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(npc.getSpeed()); - } + public void setWalkingSpeed(double speed) { + this.moveSpeed = (int) speed; + npc.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(npc.getSpeed()); + } - public int getWalkingSpeed(){ - return this.moveSpeed; - } + public int getWalkingSpeed() { + return this.moveSpeed; + } } diff --git a/src/main/java/noppes/npcs/DataAdvanced.java b/src/main/java/noppes/npcs/DataAdvanced.java index 8965a40e2..5d35fc5c4 100644 --- a/src/main/java/noppes/npcs/DataAdvanced.java +++ b/src/main/java/noppes/npcs/DataAdvanced.java @@ -41,12 +41,12 @@ public class DataAdvanced { public boolean attackOtherFactions = false; public boolean defendFaction = false; - public boolean disablePitch = false; + public boolean disablePitch = false; - public String soulStonePlayerName = ""; - public boolean refuseSoulStone = false; - public boolean soulStoneInit = false; - public int minFactionPointsToSoulStone = -1; + public String soulStonePlayerName = ""; + public boolean refuseSoulStone = false; + public boolean soulStoneInit = false; + public int minFactionPointsToSoulStone = -1; public DataAdvanced(EntityNPCInterface npc) { this.npc = npc; @@ -76,13 +76,13 @@ public class DataAdvanced { compound.setInteger("NpcJob", job.ordinal()); compound.setTag("FactionPoints", factions.writeToNBT(new NBTTagCompound())); - compound.setTag("NPCDialogOptions", nbtDialogs(npc.dialogs)); + compound.setTag("NPCDialogOptions", nbtDialogs(npc.dialogs)); - compound.setBoolean("RefuseSoulStone", refuseSoulStone); - compound.setString("SoulStonePlayerName", soulStonePlayerName); - compound.setInteger("MinFactionPointsToSoulStone", minFactionPointsToSoulStone); + compound.setBoolean("RefuseSoulStone", refuseSoulStone); + compound.setString("SoulStonePlayerName", soulStonePlayerName); + compound.setInteger("MinFactionPointsToSoulStone", minFactionPointsToSoulStone); - if(!tagUUIDs.isEmpty()){ + if (!tagUUIDs.isEmpty()) { NBTTagList nbtTagList = new NBTTagList(); for (UUID uuid : tagUUIDs) { nbtTagList.appendTag(new NBTTagString(uuid.toString())); @@ -119,45 +119,45 @@ public class DataAdvanced { factions.readFromNBT(compound.getCompoundTag("FactionPoints")); - npc.dialogs = getDialogs(compound.getTagList("NPCDialogOptions", 10)); + npc.dialogs = getDialogs(compound.getTagList("NPCDialogOptions", 10)); - refuseSoulStone = compound.getBoolean("RefuseSoulStone"); - soulStonePlayerName = compound.getString("SoulStonePlayerName"); - minFactionPointsToSoulStone = compound.getInteger("MinFactionPointsToSoulStone"); + refuseSoulStone = compound.getBoolean("RefuseSoulStone"); + soulStonePlayerName = compound.getString("SoulStonePlayerName"); + minFactionPointsToSoulStone = compound.getInteger("MinFactionPointsToSoulStone"); - if(compound.hasKey("TagUUIDs")){ - NBTTagList nbtTagList = compound.getTagList("TagUUIDs",8); + if (compound.hasKey("TagUUIDs")) { + NBTTagList nbtTagList = compound.getTagList("TagUUIDs", 8); for (int i = 0; i < nbtTagList.tagCount(); i++) { tagUUIDs.add(UUID.fromString(nbtTagList.getStringTagAt(i))); } } } - private HashMap getDialogs(NBTTagList tagList) { - HashMap map = new HashMap(); - for (int i = 0; i < tagList.tagCount(); i++) { - NBTTagCompound nbttagcompound = tagList.getCompoundTagAt(i); - int slot = nbttagcompound.getInteger("DialogSlot"); - DialogOption option = new DialogOption(); - option.readNBT(nbttagcompound.getCompoundTag("NPCDialog")); - map.put(slot, option); + private HashMap getDialogs(NBTTagList tagList) { + HashMap map = new HashMap(); + for (int i = 0; i < tagList.tagCount(); i++) { + NBTTagCompound nbttagcompound = tagList.getCompoundTagAt(i); + int slot = nbttagcompound.getInteger("DialogSlot"); + DialogOption option = new DialogOption(); + option.readNBT(nbttagcompound.getCompoundTag("NPCDialog")); + map.put(slot, option); - } - return map; - } + } + return map; + } - private NBTTagList nbtDialogs(HashMap dialogs2) { - NBTTagList nbttaglist = new NBTTagList(); - for (int slot : dialogs2.keySet()) { - NBTTagCompound nbttagcompound = new NBTTagCompound(); - nbttagcompound.setInteger("DialogSlot", slot); - nbttagcompound.setTag("NPCDialog", dialogs2.get(slot) - .writeNBT()); - nbttaglist.appendTag(nbttagcompound); - } - return nbttaglist; - } + private NBTTagList nbtDialogs(HashMap dialogs2) { + NBTTagList nbttaglist = new NBTTagList(); + for (int slot : dialogs2.keySet()) { + NBTTagCompound nbttagcompound = new NBTTagCompound(); + nbttagcompound.setInteger("DialogSlot", slot); + nbttagcompound.setTag("NPCDialog", dialogs2.get(slot) + .writeNBT()); + nbttaglist.appendTag(nbttagcompound); + } + return nbttaglist; + } public Line getInteractLine() { return (Line) interactLines.getLine(!orderedLines); @@ -184,25 +184,25 @@ public class DataAdvanced { i -= 2; } role = EnumRoleType.values()[i]; - if(role == EnumRoleType.None) + if (role == EnumRoleType.None) npc.roleInterface = null; - else if(role == EnumRoleType.Bank && !(npc.roleInterface instanceof RoleBank)) + else if (role == EnumRoleType.Bank && !(npc.roleInterface instanceof RoleBank)) npc.roleInterface = new RoleBank(npc); - else if(role == EnumRoleType.Follower && !(npc.roleInterface instanceof RoleFollower)) + else if (role == EnumRoleType.Follower && !(npc.roleInterface instanceof RoleFollower)) npc.roleInterface = new RoleFollower(npc); - else if(role == EnumRoleType.Postman && !(npc.roleInterface instanceof RolePostman)) + else if (role == EnumRoleType.Postman && !(npc.roleInterface instanceof RolePostman)) npc.roleInterface = new RolePostman(npc); - else if(role == EnumRoleType.Trader && !(npc.roleInterface instanceof RoleTrader)) + else if (role == EnumRoleType.Trader && !(npc.roleInterface instanceof RoleTrader)) npc.roleInterface = new RoleTrader(npc); - else if(role == EnumRoleType.Transporter && !(npc.roleInterface instanceof RoleTransporter)) + else if (role == EnumRoleType.Transporter && !(npc.roleInterface instanceof RoleTransporter)) npc.roleInterface = new RoleTransporter(npc); - else if(role == EnumRoleType.Companion && !(npc.roleInterface instanceof RoleCompanion)) + else if (role == EnumRoleType.Companion && !(npc.roleInterface instanceof RoleCompanion)) npc.roleInterface = new RoleCompanion(npc); } public void setJob(int i) { - if(npc.jobInterface != null && !npc.worldObj.isRemote) - npc.jobInterface.reset(); + if (npc.jobInterface != null && !npc.worldObj.isRemote) + npc.jobInterface.reset(); job = EnumJobType.values()[i % EnumJobType.values().length]; if (job == EnumJobType.None) diff --git a/src/main/java/noppes/npcs/DataDisplay.java b/src/main/java/noppes/npcs/DataDisplay.java index 9eacfe171..09b45913d 100644 --- a/src/main/java/noppes/npcs/DataDisplay.java +++ b/src/main/java/noppes/npcs/DataDisplay.java @@ -36,7 +36,7 @@ public class DataDisplay { private int markovGeneratorId = 8; //roman,japanese,slavic,welsh,sami,oldnorse,ancientgreek,aztec,classic,spanish (0 - 9 inclusively) private int markovGender = 0; //0:random, 1:male, 2:female - public byte skinType = 0; //0:normal, 1:player, 2:url, 3:url64 + public byte skinType = 0; //0:normal, 1:player, 2:url, 3:url64 public String url = ""; @@ -53,7 +53,7 @@ public class DataDisplay { public String glowTexture = ""; - public int visible = 0; //0:visible 1:Invisible 2:semi-invisible + public int visible = 0; //0:visible 1:Invisible 2:semi-invisible public int modelSize = 5; public int showName = 0; public int modelType = 0; @@ -68,9 +68,9 @@ public class DataDisplay { @SideOnly(Side.CLIENT) public HashSet tempInvisIds; - public DataDisplay(EntityNPCInterface npc){ + public DataDisplay(EntityNPCInterface npc) { this.npc = npc; - markovGeneratorId = new Random().nextInt(CustomNpcs.MARKOV_GENERATOR.length-1); + markovGeneratorId = new Random().nextInt(CustomNpcs.MARKOV_GENERATOR.length - 1); skinOverlayData = new DataSkinOverlays(npc); name = getRandomName(); animationData = new AnimationData(this); @@ -100,8 +100,7 @@ public class DataDisplay { nbttagcompound = hitboxData.writeToNBT(nbttagcompound); nbttagcompound = tintData.writeToNBT(nbttagcompound); - if (this.playerProfile != null) - { + if (this.playerProfile != null) { NBTTagCompound nbttagcompound1 = new NBTTagCompound(); NBTUtil.func_152460_a(nbttagcompound1, this.playerProfile); nbttagcompound.setTag("SkinUsername", nbttagcompound1); @@ -120,16 +119,16 @@ public class DataDisplay { ArrayList nonPersistedIDs = new ArrayList<>(); NBTTagList list = new NBTTagList(); - for(UUID uuid : invisibleToList){ - if(saveNonPersistendIDs){ + for (UUID uuid : invisibleToList) { + if (saveNonPersistendIDs) { EntityPlayer p = NoppesUtilServer.getPlayer(uuid); - if(p != null) + if (p != null) nonPersistedIDs.add(p.getEntityId()); } list.appendTag(new NBTTagString(uuid.toString())); } - if(!nonPersistedIDs.isEmpty()) { + if (!nonPersistedIDs.isEmpty()) { int[] tempIDArr = nonPersistedIDs.stream().filter(Objects::nonNull).mapToInt(i -> i).toArray(); nbttagcompound.setIntArray("InvisibleToNonPersistentID", tempIDArr); } @@ -137,6 +136,7 @@ public class DataDisplay { nbttagcompound.setTag("InvisibleToList", list); return nbttagcompound; } + public void readToNBT(NBTTagCompound nbttagcompound) { setName(nbttagcompound.getString("Name")); setMarkovGeneratorId(nbttagcompound.getInteger("MarkovGeneratorId")); @@ -151,11 +151,10 @@ public class DataDisplay { skinType = nbttagcompound.getByte("UsingSkinUrl"); this.playerProfile = null; - if(skinType == 1){ - if (nbttagcompound.hasKey("SkinUsername", 10)){ + if (skinType == 1) { + if (nbttagcompound.hasKey("SkinUsername", 10)) { this.playerProfile = NBTUtil.func_152459_a(nbttagcompound.getCompoundTag("SkinUsername")); - } - else if (nbttagcompound.hasKey("SkinUsername", 8) && !StringUtils.isNullOrEmpty(nbttagcompound.getString("SkinUsername"))){ + } else if (nbttagcompound.hasKey("SkinUsername", 8) && !StringUtils.isNullOrEmpty(nbttagcompound.getString("SkinUsername"))) { this.playerProfile = new GameProfile(null, nbttagcompound.getString("SkinUsername")); } this.loadProfile(); @@ -190,7 +189,7 @@ public class DataDisplay { tintData.readFromNBT(nbttagcompound); modelSize = ValueUtil.clamp(nbttagcompound.getInteger("Size"), 1, Integer.MAX_VALUE); - if(modelSize > ConfigMain.NpcSizeLimit) + if (modelSize > ConfigMain.NpcSizeLimit) modelSize = ConfigMain.NpcSizeLimit; modelType = nbttagcompound.getInteger("modelType"); @@ -201,21 +200,20 @@ public class DataDisplay { disableLivingAnimation = nbttagcompound.getBoolean("NoLivingAnimation"); showBossBar = nbttagcompound.getByte("BossBar"); - NBTTagList tagList = (NBTTagList)nbttagcompound.getTag("InvisibleToList"); - if(tagList != null) { + NBTTagList tagList = (NBTTagList) nbttagcompound.getTag("InvisibleToList"); + if (tagList != null) { invisibleToList.clear(); for (int i = 0; i < tagList.tagCount(); i++) { String nbtTagString = tagList.getStringTagAt(i); invisibleToList.add(UUID.fromString(nbtTagString)); } - } - else { + } else { invisibleToList = new ArrayList<>(); } - if(FMLCommonHandler.instance().getEffectiveSide() == Side.CLIENT){ + if (FMLCommonHandler.instance().getEffectiveSide() == Side.CLIENT) { - if(tempInvisIds == null){ + if (tempInvisIds == null) { tempInvisIds = new HashSet<>(); } else { tempInvisIds.clear(); @@ -223,28 +221,28 @@ public class DataDisplay { int[] tempEntityIDList = nbttagcompound.getIntArray("InvisibleToNonPersistentID"); final int playerID = Minecraft.getMinecraft().thePlayer.getEntityId(); - for(int i : tempEntityIDList){ - if(i == playerID){ + for (int i : tempEntityIDList) { + if (i == playerID) { isInvisibleToMe = true; } tempInvisIds.add(i); } } - if(prevSkinType != skinType || !texture.equals(prevTexture)|| !url.equals(prevUrl)) + if (prevSkinType != skinType || !texture.equals(prevTexture) || !url.equals(prevUrl)) npc.textureLocation = null; npc.updateHitbox(); } - public void loadProfile(){ - if (this.playerProfile != null && !StringUtils.isNullOrEmpty(this.playerProfile.getName()) && MinecraftServer.getServer() != null){ - if (!this.playerProfile.isComplete() || !this.playerProfile.getProperties().containsKey("textures")){ + public void loadProfile() { + if (this.playerProfile != null && !StringUtils.isNullOrEmpty(this.playerProfile.getName()) && MinecraftServer.getServer() != null) { + if (!this.playerProfile.isComplete() || !this.playerProfile.getProperties().containsKey("textures")) { GameProfile gameprofile = MinecraftServer.getServer().func_152358_ax().func_152655_a(this.playerProfile.getName()); - if (gameprofile != null){ - Property property = (Property)Iterables.getFirst(gameprofile.getProperties().get("textures"), (Object)null); + if (gameprofile != null) { + Property property = (Property) Iterables.getFirst(gameprofile.getProperties().get("textures"), (Object) null); - if (property == null){ + if (property == null) { gameprofile = MinecraftServer.getServer().func_147130_as().fillProfileProperties(gameprofile, false); } @@ -255,17 +253,17 @@ public class DataDisplay { } public boolean showName() { - if(npc.isKilled()) + if (npc.isKilled()) return false; return showName == 0 || (showName == 2 && npc.isAttacking()); } - public String getSkinTexture(){ + public String getSkinTexture() { return texture; } - public void setSkinTexture(String texture){ - if(this.texture.equals(texture)) + public void setSkinTexture(String texture) { + if (this.texture.equals(texture)) return; this.texture = texture; npc.textureLocation = null; @@ -273,35 +271,35 @@ public class DataDisplay { npc.updateClient = true; } - public String getName(){ + public String getName() { return name; } - public void setName(String name){ - if(this.name.equals(name)) + public void setName(String name) { + if (this.name.equals(name)) return; this.name = name; npc.updateClient = true; } - public int getMarkovGender(){ + public int getMarkovGender() { return markovGender; } public void setMarkovGender(int gender) { - if(markovGender == gender) + if (markovGender == gender) return; this.markovGender = ValueUtil.clamp(gender, 0, 2); } - public int getMarkovGeneratorId(){ + public int getMarkovGeneratorId() { return markovGeneratorId; } public void setMarkovGeneratorId(int id) { - if(markovGeneratorId == id) + if (markovGeneratorId == id) return; - this.markovGeneratorId = ValueUtil.clamp(id, 0, CustomNpcs.MARKOV_GENERATOR.length-1); + this.markovGeneratorId = ValueUtil.clamp(id, 0, CustomNpcs.MARKOV_GENERATOR.length - 1); } @SideOnly(Side.CLIENT) diff --git a/src/main/java/noppes/npcs/DataInventory.java b/src/main/java/noppes/npcs/DataInventory.java index 6db4c4ccf..49877fb37 100644 --- a/src/main/java/noppes/npcs/DataInventory.java +++ b/src/main/java/noppes/npcs/DataInventory.java @@ -18,354 +18,357 @@ import java.util.HashMap; import java.util.Random; public class DataInventory implements IInventory { - public static Random random = new Random(); - public HashMap items = new HashMap(); - public HashMap dropchance = new HashMap(); - public HashMap weapons = new HashMap(); - public HashMap prevWeapons = new HashMap(); - public HashMap armor = new HashMap(); + public static Random random = new Random(); + public HashMap items = new HashMap(); + public HashMap dropchance = new HashMap(); + public HashMap weapons = new HashMap(); + public HashMap prevWeapons = new HashMap(); + public HashMap armor = new HashMap(); - public int minExp = 0; - public int maxExp = 0; + public int minExp = 0; + public int maxExp = 0; - public int lootMode = 0; + public int lootMode = 0; - private EntityNPCInterface npc; + private EntityNPCInterface npc; - public DataInventory(EntityNPCInterface npc){ - this.npc = npc; - } - public NBTTagCompound writeEntityToNBT(NBTTagCompound nbttagcompound){ - nbttagcompound.setInteger("MinExp", minExp); - nbttagcompound.setInteger("MaxExp", maxExp); - nbttagcompound.setTag("NpcInv", NBTTags.nbtItemStackList(items)); - nbttagcompound.setTag("Armor", NBTTags.nbtItemStackList(getArmor())); - nbttagcompound.setTag("Weapons", NBTTags.nbtItemStackList(getWeapons())); - nbttagcompound.setTag("DoubleDropChance", NBTTags.nbtIntegerDoubleMap(dropchance)); - nbttagcompound.setInteger("LootMode", lootMode); + public DataInventory(EntityNPCInterface npc) { + this.npc = npc; + } - return nbttagcompound; - } - public void readEntityFromNBT(NBTTagCompound nbttagcompound){ - minExp = nbttagcompound.getInteger("MinExp"); - maxExp = nbttagcompound.getInteger("MaxExp"); - items = NBTTags.getItemStackList(nbttagcompound.getTagList("NpcInv", 10)); - setArmor(NBTTags.getItemStackList(nbttagcompound.getTagList("Armor", 10))); - setWeapons(NBTTags.getItemStackList(nbttagcompound.getTagList("Weapons", 10))); + public NBTTagCompound writeEntityToNBT(NBTTagCompound nbttagcompound) { + nbttagcompound.setInteger("MinExp", minExp); + nbttagcompound.setInteger("MaxExp", maxExp); + nbttagcompound.setTag("NpcInv", NBTTags.nbtItemStackList(items)); + nbttagcompound.setTag("Armor", NBTTags.nbtItemStackList(getArmor())); + nbttagcompound.setTag("Weapons", NBTTags.nbtItemStackList(getWeapons())); + nbttagcompound.setTag("DoubleDropChance", NBTTags.nbtIntegerDoubleMap(dropchance)); + nbttagcompound.setInteger("LootMode", lootMode); - if(!nbttagcompound.hasKey("DoubleDropChance")) { - dropchance.clear(); - HashMap oldDropChance = NBTTags.getIntegerIntegerMap(nbttagcompound.getTagList("DropChance", 10)); - for(int i = 0; i < oldDropChance.entrySet().size(); i++){ - dropchance.put(i, Double.valueOf(oldDropChance.get(i))); - } - } else { - dropchance = NBTTags.getIntegerDoubleMap(nbttagcompound.getTagList("DoubleDropChance", 10)); - } + return nbttagcompound; + } - lootMode = nbttagcompound.getInteger("LootMode"); - } - public HashMap getWeapons() { - return weapons; - } - public void setWeapons(HashMap list) { - weapons = list; - } - public HashMap getArmor() { - return armor; - } - public void setArmor(HashMap list) { - armor = list; - } - public ItemStack getWeapon(){ - return weapons.get(0); - } - public void setWeapon(ItemStack item){ - weapons.put(0, item); - } - public ItemStack getProjectile(){ - return weapons.get(1); - } - public void setProjectile(ItemStack item){ - weapons.put(1, item); - } - public ItemStack getOffHand(){ - return weapons.get(2); - } - public void setOffHand(ItemStack item){ - weapons.put(2, item); - } + public void readEntityFromNBT(NBTTagCompound nbttagcompound) { + minExp = nbttagcompound.getInteger("MinExp"); + maxExp = nbttagcompound.getInteger("MaxExp"); + items = NBTTags.getItemStackList(nbttagcompound.getTagList("NpcInv", 10)); + setArmor(NBTTags.getItemStackList(nbttagcompound.getTagList("Armor", 10))); + setWeapons(NBTTags.getItemStackList(nbttagcompound.getTagList("Weapons", 10))); - public ArrayList getDroppedItems(DamageSource damagesource) { - ArrayList drops = new ArrayList<>(); - - ArrayList list = new ArrayList(); - for (int i : items.keySet()) { - ItemStack item = items.get(i); - if(item == null) - continue; - double dchance = 100; - double chance = random.nextDouble() * 100; - if(dropchance.containsKey(i)) - dchance = dropchance.get(i); - - // double chance = Math.random()*100 + dchance; - if(chance < dchance){ - EntityItem e = getEntityItem(item.copy()); - if(e != null) - list.add(e); - } - } - for (EntityItem e : list) { - drops.add(e.getEntityItem()); - } - - int enchant = 0; - if (damagesource.getEntity() instanceof EntityPlayer){ - enchant = EnchantmentHelper.getLootingModifier((EntityLivingBase)damagesource.getEntity()); - } - - if (!net.minecraftforge.common.ForgeHooks.onLivingDrops(npc, damagesource, list, enchant, true, 0)){ - return drops; - } else { - return new ArrayList<>(); - } - } - - public int getDroppedXp() { - int droppedXp = minExp; - if (maxExp - minExp > 0) - droppedXp += npc.worldObj.rand.nextInt(maxExp - minExp); - - return droppedXp; - } - - public void dropXp(Entity entity, int droppedXp) { - while (droppedXp > 0){ - int var2 = EntityXPOrb.getXPSplit(droppedXp); - droppedXp -= var2; - if(lootMode == 1 && entity instanceof EntityPlayer){ - npc.worldObj.spawnEntityInWorld(new EntityXPOrb(entity.worldObj, entity.posX, entity.posY, entity.posZ, var2)); - } - else{ - npc.worldObj.spawnEntityInWorld(new EntityXPOrb(npc.worldObj, npc.posX, npc.posY, npc.posZ, var2)); - } - } - } - - public void dropItems(Entity entity, ArrayList itemList) { - ArrayList list = new ArrayList(); - for (ItemStack item : itemList) { - if(item == null) - continue; - EntityItem e = getEntityItem(item.copy()); - if(e != null) - list.add(e); - } - - for (EntityItem item : list){ - if(lootMode == 1 && entity instanceof EntityPlayer){ - EntityPlayer player = (EntityPlayer)entity; - item.delayBeforeCanPickup = 2; - npc.worldObj.spawnEntityInWorld(item); - ItemStack stack = item.getEntityItem(); - int i = stack.stackSize; - - if (player.inventory.addItemStackToInventory(stack)) { - npc.worldObj.playSoundAtEntity(item, - "random.pop", - 0.2F, - ((npc.getRNG().nextFloat() - npc.getRNG().nextFloat()) * 0.7F + 1.0F) * 2.0F); - player.onItemPickup(item, i); - - if (stack.stackSize <= 0) { - item.setDead(); - } - } - } - else - npc.worldObj.spawnEntityInWorld(item); - } - } - - public EntityItem getEntityItem(ItemStack itemstack) { - if (itemstack == null) { - return null; - } - EntityItem entityitem = new EntityItem(npc.worldObj, npc.posX, - (npc.posY - 0.30000001192092896D) + (double) npc.getEyeHeight(), npc.posZ, - itemstack); - entityitem.delayBeforeCanPickup = 40; - - float f2 = npc.getRNG().nextFloat() * 0.5F; - float f4 = npc.getRNG().nextFloat() * 3.141593F * 2.0F; - entityitem.motionX = -MathHelper.sin(f4) * f2; - entityitem.motionZ = MathHelper.cos(f4) * f2; - entityitem.motionY = 0.20000000298023224D; - - return entityitem; - } - - public ItemStack armorItemInSlot(int i) { - return getArmor().get(i); - } - @Override - public int getSizeInventory() { - - return 15; - } - @Override - public ItemStack getStackInSlot(int i) { - if(i < 4) - return armorItemInSlot(i); - else if(i < 7) - return getWeapons().get(i-4); - else - return items.get(i-7); - } - @Override - public ItemStack decrStackSize(int par1, int par2) { - int i =0; - HashMap var3; - - if (par1 >= 7) - { - var3 = items; - par1 -= 7; + if (!nbttagcompound.hasKey("DoubleDropChance")) { + dropchance.clear(); + HashMap oldDropChance = NBTTags.getIntegerIntegerMap(nbttagcompound.getTagList("DropChance", 10)); + for (int i = 0; i < oldDropChance.entrySet().size(); i++) { + dropchance.put(i, Double.valueOf(oldDropChance.get(i))); + } + } else { + dropchance = NBTTags.getIntegerDoubleMap(nbttagcompound.getTagList("DoubleDropChance", 10)); } - else if (par1 >= 4) - { - var3 = getWeapons(); + + lootMode = nbttagcompound.getInteger("LootMode"); + } + + public HashMap getWeapons() { + return weapons; + } + + public void setWeapons(HashMap list) { + weapons = list; + } + + public HashMap getArmor() { + return armor; + } + + public void setArmor(HashMap list) { + armor = list; + } + + public ItemStack getWeapon() { + return weapons.get(0); + } + + public void setWeapon(ItemStack item) { + weapons.put(0, item); + } + + public ItemStack getProjectile() { + return weapons.get(1); + } + + public void setProjectile(ItemStack item) { + weapons.put(1, item); + } + + public ItemStack getOffHand() { + return weapons.get(2); + } + + public void setOffHand(ItemStack item) { + weapons.put(2, item); + } + + public ArrayList getDroppedItems(DamageSource damagesource) { + ArrayList drops = new ArrayList<>(); + + ArrayList list = new ArrayList(); + for (int i : items.keySet()) { + ItemStack item = items.get(i); + if (item == null) + continue; + double dchance = 100; + double chance = random.nextDouble() * 100; + if (dropchance.containsKey(i)) + dchance = dropchance.get(i); + + // double chance = Math.random()*100 + dchance; + if (chance < dchance) { + EntityItem e = getEntityItem(item.copy()); + if (e != null) + list.add(e); + } + } + for (EntityItem e : list) { + drops.add(e.getEntityItem()); + } + + int enchant = 0; + if (damagesource.getEntity() instanceof EntityPlayer) { + enchant = EnchantmentHelper.getLootingModifier((EntityLivingBase) damagesource.getEntity()); + } + + if (!net.minecraftforge.common.ForgeHooks.onLivingDrops(npc, damagesource, list, enchant, true, 0)) { + return drops; + } else { + return new ArrayList<>(); + } + } + + public int getDroppedXp() { + int droppedXp = minExp; + if (maxExp - minExp > 0) + droppedXp += npc.worldObj.rand.nextInt(maxExp - minExp); + + return droppedXp; + } + + public void dropXp(Entity entity, int droppedXp) { + while (droppedXp > 0) { + int var2 = EntityXPOrb.getXPSplit(droppedXp); + droppedXp -= var2; + if (lootMode == 1 && entity instanceof EntityPlayer) { + npc.worldObj.spawnEntityInWorld(new EntityXPOrb(entity.worldObj, entity.posX, entity.posY, entity.posZ, var2)); + } else { + npc.worldObj.spawnEntityInWorld(new EntityXPOrb(npc.worldObj, npc.posX, npc.posY, npc.posZ, var2)); + } + } + } + + public void dropItems(Entity entity, ArrayList itemList) { + ArrayList list = new ArrayList(); + for (ItemStack item : itemList) { + if (item == null) + continue; + EntityItem e = getEntityItem(item.copy()); + if (e != null) + list.add(e); + } + + for (EntityItem item : list) { + if (lootMode == 1 && entity instanceof EntityPlayer) { + EntityPlayer player = (EntityPlayer) entity; + item.delayBeforeCanPickup = 2; + npc.worldObj.spawnEntityInWorld(item); + ItemStack stack = item.getEntityItem(); + int i = stack.stackSize; + + if (player.inventory.addItemStackToInventory(stack)) { + npc.worldObj.playSoundAtEntity(item, + "random.pop", + 0.2F, + ((npc.getRNG().nextFloat() - npc.getRNG().nextFloat()) * 0.7F + 1.0F) * 2.0F); + player.onItemPickup(item, i); + + if (stack.stackSize <= 0) { + item.setDead(); + } + } + } else + npc.worldObj.spawnEntityInWorld(item); + } + } + + public EntityItem getEntityItem(ItemStack itemstack) { + if (itemstack == null) { + return null; + } + EntityItem entityitem = new EntityItem(npc.worldObj, npc.posX, + (npc.posY - 0.30000001192092896D) + (double) npc.getEyeHeight(), npc.posZ, + itemstack); + entityitem.delayBeforeCanPickup = 40; + + float f2 = npc.getRNG().nextFloat() * 0.5F; + float f4 = npc.getRNG().nextFloat() * 3.141593F * 2.0F; + entityitem.motionX = -MathHelper.sin(f4) * f2; + entityitem.motionZ = MathHelper.cos(f4) * f2; + entityitem.motionY = 0.20000000298023224D; + + return entityitem; + } + + public ItemStack armorItemInSlot(int i) { + return getArmor().get(i); + } + + @Override + public int getSizeInventory() { + + return 15; + } + + @Override + public ItemStack getStackInSlot(int i) { + if (i < 4) + return armorItemInSlot(i); + else if (i < 7) + return getWeapons().get(i - 4); + else + return items.get(i - 7); + } + + @Override + public ItemStack decrStackSize(int par1, int par2) { + int i = 0; + HashMap var3; + + if (par1 >= 7) { + var3 = items; + par1 -= 7; + } else if (par1 >= 4) { + var3 = getWeapons(); par1 -= 4; i = 1; - } - else{ - var3 = getArmor(); + } else { + var3 = getArmor(); i = 2; } ItemStack var4 = null; - if (var3.get(par1) != null) - { + if (var3.get(par1) != null) { - if (var3.get(par1).stackSize <= par2) - { + if (var3.get(par1).stackSize <= par2) { var4 = var3.get(par1); - var3.put(par1,null); - } - else - { + var3.put(par1, null); + } else { var4 = var3.get(par1).splitStack(par2); - if (var3.get(par1).stackSize == 0) - { - var3.put(par1,null); + if (var3.get(par1).stackSize == 0) { + var3.put(par1, null); } } } - if(i == 1) - setWeapons(var3); - if(i == 2) - setArmor(var3); + if (i == 1) + setWeapons(var3); + if (i == 2) + setArmor(var3); return var4; - } - @Override - public ItemStack getStackInSlotOnClosing(int par1) { - int i = 0; - HashMap var2;; + } - if (par1 >= 7) - { - var2 = items; + @Override + public ItemStack getStackInSlotOnClosing(int par1) { + int i = 0; + HashMap var2; + ; + + if (par1 >= 7) { + var2 = items; par1 -= 7; - } - else if (par1 >= 4) - { - var2 = getWeapons(); + } else if (par1 >= 4) { + var2 = getWeapons(); par1 -= 4; i = 1; - } - else{ - var2 = getArmor(); + } else { + var2 = getArmor(); i = 2; } - if (var2.get(par1) != null) - { + if (var2.get(par1) != null) { ItemStack var3 = var2.get(par1); - var2.put(par1,null); - if(i == 1) - setWeapons(var2); - if(i == 2) - setArmor(var2); + var2.put(par1, null); + if (i == 1) + setWeapons(var2); + if (i == 2) + setArmor(var2); return var3; - } - else - { + } else { return null; } - } - @Override - public void setInventorySlotContents(int par1, ItemStack par2ItemStack) - { - int i = 0; - HashMap var3; + } - if (par1 >= 7) - { - var3 = items; + @Override + public void setInventorySlotContents(int par1, ItemStack par2ItemStack) { + int i = 0; + HashMap var3; + + if (par1 >= 7) { + var3 = items; par1 -= 7; - } - else if (par1 >= 4) - { - var3 = getWeapons(); + } else if (par1 >= 4) { + var3 = getWeapons(); par1 -= 4; i = 1; - } - else{ - var3 = getArmor(); + } else { + var3 = getArmor(); i = 2; } - var3.put(par1,par2ItemStack); - if(i == 1) - setWeapons(var3); - if(i == 2) - setArmor(var3); + var3.put(par1, par2ItemStack); + if (i == 1) + setWeapons(var3); + if (i == 2) + setArmor(var3); } - @Override - public int getInventoryStackLimit() { - return 64; - } - @Override - public boolean isUseableByPlayer(EntityPlayer var1) { - return true; - } - @Override - public boolean isItemValidForSlot(int i, ItemStack itemstack) { - return true; - } - @Override - public String getInventoryName() { - return "NPC Inventory"; - } - @Override - public boolean hasCustomInventoryName() { - return true; - } - @Override - public void markDirty() { + + @Override + public int getInventoryStackLimit() { + return 64; + } + + @Override + public boolean isUseableByPlayer(EntityPlayer var1) { + return true; + } + + @Override + public boolean isItemValidForSlot(int i, ItemStack itemstack) { + return true; + } + + @Override + public String getInventoryName() { + return "NPC Inventory"; + } + + @Override + public boolean hasCustomInventoryName() { + return true; + } + + @Override + public void markDirty() { - } - @Override - public void openInventory() { + } + + @Override + public void openInventory() { - } - @Override - public void closeInventory() { + } + + @Override + public void closeInventory() { - } + } } diff --git a/src/main/java/noppes/npcs/DataStats.java b/src/main/java/noppes/npcs/DataStats.java index 071e34aeb..d1bbd06ad 100644 --- a/src/main/java/noppes/npcs/DataStats.java +++ b/src/main/java/noppes/npcs/DataStats.java @@ -2,134 +2,131 @@ package noppes.npcs; import net.minecraft.entity.EnumCreatureAttribute; import net.minecraft.entity.SharedMonsterAttributes; -import net.minecraft.nbt.*; +import net.minecraft.nbt.NBTTagCompound; import noppes.npcs.constants.EnumParticleType; import noppes.npcs.constants.EnumPotionType; import noppes.npcs.controllers.data.MagicData; import noppes.npcs.entity.EntityNPCInterface; import noppes.npcs.util.ValueUtil; -import java.util.HashSet; -import java.util.UUID; - public class DataStats { - private float attackStrength = 5; - public int attackSpeed = 20, swingWarmUp = 0, attackRange = 2, knockback = 0; - public int minDelay = 20, maxDelay = 40, rangedRange = 15, fireRate = 5, burstCount = 1, shotCount = 1, accuracy = 60; - public int aggroRange = 16; + private float attackStrength = 5; + public int attackSpeed = 20, swingWarmUp = 0, attackRange = 2, knockback = 0; + public int minDelay = 20, maxDelay = 40, rangedRange = 15, fireRate = 5, burstCount = 1, shotCount = 1, accuracy = 60; + public int aggroRange = 16; - public EnumPotionType potionType = EnumPotionType.None; - public int potionDuration = 5; //20 = 1 second - public int potionAmp = 0; + public EnumPotionType potionType = EnumPotionType.None; + public int potionDuration = 5; //20 = 1 second + public int potionAmp = 0; - public double maxHealth = 20; - public int respawnTime = 20; - public int spawnCycle = 0; - public boolean hideKilledBody = false; - public boolean canDespawn = false; - public boolean playerSetCanDespawn = false; + public double maxHealth = 20; + public int respawnTime = 20; + public int spawnCycle = 0; + public boolean hideKilledBody = false; + public boolean canDespawn = false; + public boolean playerSetCanDespawn = false; - public Resistances resistances = new Resistances(); + public Resistances resistances = new Resistances(); public MagicData magicData = new MagicData(); - public boolean ignoreCobweb = false; - public boolean immuneToFire = false; - public boolean potionImmune = false; - public int drowningType = 1; // 0 - Never, 1 - Water, 2 - Air - public boolean burnInSun = false; - public boolean noFallDamage = false; - public float healthRegen = 1; - public float combatRegen = 0; + public boolean ignoreCobweb = false; + public boolean immuneToFire = false; + public boolean potionImmune = false; + public int drowningType = 1; // 0 - Never, 1 - Water, 2 - Air + public boolean burnInSun = false; + public boolean noFallDamage = false; + public float healthRegen = 1; + public float combatRegen = 0; - public float pDamage = 4; - public int pImpact = 0, pSize = 5, pSpeed = 10, pArea = 0, pDur = 5; + public float pDamage = 4; + public int pImpact = 0, pSize = 5, pSpeed = 10, pArea = 0, pDur = 5; public boolean pPhysics = true, pXlr8 = false, pGlows = false, pExplode = false; public boolean pRender3D = false, pSpin = false, pStick = false; public EnumPotionType pEffect = EnumPotionType.None; public EnumParticleType pTrail = EnumParticleType.None; public int pEffAmp = 0; public String fireSound = "random.bow"; - public boolean aimWhileShooting = false; - public boolean projectilesKeepTerrain = false; + public boolean aimWhileShooting = false; + public boolean projectilesKeepTerrain = false; - public EnumCreatureAttribute creatureType = EnumCreatureAttribute.UNDEFINED; + public EnumCreatureAttribute creatureType = EnumCreatureAttribute.UNDEFINED; - private EntityNPCInterface npc; - public boolean attackInvisible = false; + private EntityNPCInterface npc; + public boolean attackInvisible = false; // 0 - Yes, 1 - No, 2 - Only NPCs, 3 - Only Players, 4 - NPCs and Players public int collidesWith = 1; - public DataStats(EntityNPCInterface npc){ - this.npc = npc; - } - public NBTTagCompound writeToNBT(NBTTagCompound compound) - { - compound.setTag("Resistances", resistances.writeToNBT()); - compound.setDouble("MaxHealth", maxHealth); - compound.setInteger("AggroRange", aggroRange); - compound.setBoolean("HideBodyWhenKilled", hideKilledBody); - compound.setInteger("RespawnTime", respawnTime); - compound.setInteger("SpawnCycle", spawnCycle); - compound.setInteger("CreatureType", creatureType.ordinal()); - compound.setBoolean("IgnoreCobweb", ignoreCobweb); - compound.setFloat("HealthRegen", healthRegen); - compound.setFloat("CombatRegen", combatRegen); + public DataStats(EntityNPCInterface npc) { + this.npc = npc; + } - compound.setFloat("AttackStrenght", attackStrength); - compound.setInteger("AttackRange", attackRange); - compound.setInteger("AttackSpeed", attackSpeed); - compound.setInteger("SwingWarmup", swingWarmUp); - compound.setInteger("KnockBack", knockback); - compound.setInteger("PotionEffect", potionType.ordinal()); - compound.setInteger("PotionDuration", potionDuration); - compound.setInteger("PotionAmp", potionAmp); + public NBTTagCompound writeToNBT(NBTTagCompound compound) { + compound.setTag("Resistances", resistances.writeToNBT()); + compound.setDouble("MaxHealth", maxHealth); + compound.setInteger("AggroRange", aggroRange); + compound.setBoolean("HideBodyWhenKilled", hideKilledBody); + compound.setInteger("RespawnTime", respawnTime); + compound.setInteger("SpawnCycle", spawnCycle); + compound.setInteger("CreatureType", creatureType.ordinal()); + compound.setBoolean("IgnoreCobweb", ignoreCobweb); + compound.setFloat("HealthRegen", healthRegen); + compound.setFloat("CombatRegen", combatRegen); - compound.setInteger("MaxFiringRange", rangedRange); - compound.setInteger("FireRate", fireRate); - compound.setInteger("minDelay", minDelay); - compound.setInteger("maxDelay", maxDelay); - compound.setInteger("BurstCount", burstCount); - compound.setInteger("ShotCount", shotCount); - compound.setInteger("Accuracy", accuracy); + compound.setFloat("AttackStrenght", attackStrength); + compound.setInteger("AttackRange", attackRange); + compound.setInteger("AttackSpeed", attackSpeed); + compound.setInteger("SwingWarmup", swingWarmUp); + compound.setInteger("KnockBack", knockback); + compound.setInteger("PotionEffect", potionType.ordinal()); + compound.setInteger("PotionDuration", potionDuration); + compound.setInteger("PotionAmp", potionAmp); - compound.setFloat("pDamage", pDamage); - compound.setInteger("pImpact", pImpact); - compound.setInteger("pSize", pSize); - compound.setInteger("pSpeed", pSpeed); - compound.setInteger("pArea", pArea); - compound.setInteger("pDur", pDur); - compound.setBoolean("pPhysics", pPhysics); - compound.setBoolean("pXlr8", pXlr8); - compound.setBoolean("pGlows", pGlows); - compound.setBoolean("pExplode", pExplode); - compound.setBoolean("pRender3D", pRender3D); - compound.setBoolean("pSpin", pSpin); - compound.setBoolean("pStick", pStick); - compound.setInteger("pEffect", pEffect.ordinal()); - compound.setInteger("pTrail", pTrail.ordinal()); - compound.setInteger("pEffAmp", pEffAmp); - compound.setString("FiringSound", fireSound); - compound.setBoolean("AimWhileShooting", aimWhileShooting); - compound.setBoolean("ProjectilesKeepTerrain", projectilesKeepTerrain); + compound.setInteger("MaxFiringRange", rangedRange); + compound.setInteger("FireRate", fireRate); + compound.setInteger("minDelay", minDelay); + compound.setInteger("maxDelay", maxDelay); + compound.setInteger("BurstCount", burstCount); + compound.setInteger("ShotCount", shotCount); + compound.setInteger("Accuracy", accuracy); - compound.setBoolean("ImmuneToFire", immuneToFire); - compound.setBoolean("PotionImmune", potionImmune); - compound.setInteger("DrowningType", drowningType); - compound.setBoolean("BurnInSun", burnInSun); - compound.setBoolean("NoFallDamage", noFallDamage); - compound.setBoolean("AttackInvisible", attackInvisible); - compound.setBoolean("CanDespawn", canDespawn); - compound.setBoolean("PlayerSetCanDespawn", playerSetCanDespawn); - compound.setInteger("CollidesWith",collidesWith); + compound.setFloat("pDamage", pDamage); + compound.setInteger("pImpact", pImpact); + compound.setInteger("pSize", pSize); + compound.setInteger("pSpeed", pSpeed); + compound.setInteger("pArea", pArea); + compound.setInteger("pDur", pDur); + compound.setBoolean("pPhysics", pPhysics); + compound.setBoolean("pXlr8", pXlr8); + compound.setBoolean("pGlows", pGlows); + compound.setBoolean("pExplode", pExplode); + compound.setBoolean("pRender3D", pRender3D); + compound.setBoolean("pSpin", pSpin); + compound.setBoolean("pStick", pStick); + compound.setInteger("pEffect", pEffect.ordinal()); + compound.setInteger("pTrail", pTrail.ordinal()); + compound.setInteger("pEffAmp", pEffAmp); + compound.setString("FiringSound", fireSound); + compound.setBoolean("AimWhileShooting", aimWhileShooting); + compound.setBoolean("ProjectilesKeepTerrain", projectilesKeepTerrain); + + compound.setBoolean("ImmuneToFire", immuneToFire); + compound.setBoolean("PotionImmune", potionImmune); + compound.setInteger("DrowningType", drowningType); + compound.setBoolean("BurnInSun", burnInSun); + compound.setBoolean("NoFallDamage", noFallDamage); + compound.setBoolean("AttackInvisible", attackInvisible); + compound.setBoolean("CanDespawn", canDespawn); + compound.setBoolean("PlayerSetCanDespawn", playerSetCanDespawn); + compound.setInteger("CollidesWith", collidesWith); magicData.writeToNBT(compound); - return compound; - } + return compound; + } - public void readToNBT(NBTTagCompound compound) { + public void readToNBT(NBTTagCompound compound) { resistances.readToNBT(compound.getCompoundTag("Resistances")); setMaxHealth(compound.getDouble("MaxHealth")); hideKilledBody = compound.getBoolean("HideBodyWhenKilled"); @@ -198,16 +195,17 @@ public class DataStats { } - public float getAttackStrength(){ - return attackStrength; - } - public void setAttackStrength(double strength){ - attackStrength = (float)(Math.floor(strength)); - npc.getEntityAttribute(SharedMonsterAttributes.attackDamage).setBaseValue(attackStrength); - } + public float getAttackStrength() { + return attackStrength; + } - public void setMaxHealth(double maxHealth) { - this.maxHealth = Math.floor(maxHealth); - npc.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(maxHealth); - } + public void setAttackStrength(double strength) { + attackStrength = (float) (Math.floor(strength)); + npc.getEntityAttribute(SharedMonsterAttributes.attackDamage).setBaseValue(attackStrength); + } + + public void setMaxHealth(double maxHealth) { + this.maxHealth = Math.floor(maxHealth); + npc.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(maxHealth); + } } diff --git a/src/main/java/noppes/npcs/EventHooks.java b/src/main/java/noppes/npcs/EventHooks.java index fa145f87f..e2c8a7482 100644 --- a/src/main/java/noppes/npcs/EventHooks.java +++ b/src/main/java/noppes/npcs/EventHooks.java @@ -17,7 +17,6 @@ import net.minecraftforge.event.world.WorldEvent; import noppes.npcs.api.IWorld; import noppes.npcs.api.entity.*; import noppes.npcs.api.event.IAnimationEvent; -import noppes.npcs.api.event.IPlayerEvent; import noppes.npcs.api.gui.ICustomGui; import noppes.npcs.api.gui.IItemSlot; import noppes.npcs.api.handler.data.IAnimation; @@ -64,7 +63,7 @@ public class EventHooks { public static boolean onScriptItemTossed(IItemCustomizable item, EntityPlayer player, EntityItem entity) { INpcScriptHandler handler = (INpcScriptHandler) item.getScriptHandler(); - ItemEvent.TossedEvent event = new ItemEvent.TossedEvent(item, (IPlayer)NpcAPI.Instance().getIEntity(player), NpcAPI.Instance().getIEntity(entity)); + ItemEvent.TossedEvent event = new ItemEvent.TossedEvent(item, (IPlayer) NpcAPI.Instance().getIEntity(player), NpcAPI.Instance().getIEntity(entity)); if (handler != null) { handler.callScript(EnumScriptType.TOSSED, event); } @@ -73,7 +72,7 @@ public class EventHooks { public static boolean onScriptItemPickedUp(IItemCustomizable item, EntityPlayer player) { INpcScriptHandler handler = (INpcScriptHandler) item.getScriptHandler(); - ItemEvent.PickedUpEvent event = new ItemEvent.PickedUpEvent(item, (IPlayer)NpcAPI.Instance().getIEntity(player)); + ItemEvent.PickedUpEvent event = new ItemEvent.PickedUpEvent(item, (IPlayer) NpcAPI.Instance().getIEntity(player)); if (handler != null) { handler.callScript(EnumScriptType.PICKEDUP, event); } @@ -186,7 +185,7 @@ public class EventHooks { } public static void onNPCInit(EntityNPCInterface npc) { - if(npc == null || npc.wrappedNPC == null) + if (npc == null || npc.wrappedNPC == null) return; noppes.npcs.scripted.event.NpcEvent.InitEvent event = new noppes.npcs.scripted.event.NpcEvent.InitEvent(npc.wrappedNPC); @@ -197,7 +196,7 @@ public class EventHooks { } public static void onNPCUpdate(EntityNPCInterface npc) { - if(npc == null || npc.wrappedNPC == null) + if (npc == null || npc.wrappedNPC == null) return; noppes.npcs.scripted.event.NpcEvent.UpdateEvent event = new noppes.npcs.scripted.event.NpcEvent.UpdateEvent(npc.wrappedNPC); @@ -207,7 +206,7 @@ public class EventHooks { } public static boolean onNPCDialog(EntityNPCInterface npc, EntityPlayer player, int dialogId, int optionId, Dialog dialog) { - if(npc == null || npc.wrappedNPC == null) + if (npc == null || npc.wrappedNPC == null) return false; NpcEvent.DialogEvent event = new NpcEvent.DialogEvent(npc.wrappedNPC, player, dialogId, optionId, dialog); @@ -218,7 +217,7 @@ public class EventHooks { } public static void onNPCDialogClosed(EntityNPCInterface npc, EntityPlayer player, int dialogId, int optionId, Dialog dialog) { - if(npc == null || npc.wrappedNPC == null) + if (npc == null || npc.wrappedNPC == null) return; NpcEvent.DialogClosedEvent event = new NpcEvent.DialogClosedEvent(npc.wrappedNPC, player, dialogId, optionId, dialog); @@ -229,37 +228,37 @@ public class EventHooks { } public static boolean onNPCInteract(EntityNPCInterface npc, EntityPlayer player) { - if(npc == null || npc.wrappedNPC == null) + if (npc == null || npc.wrappedNPC == null) return false; - NpcEvent.InteractEvent event = new NpcEvent.InteractEvent(npc.wrappedNPC,player); + NpcEvent.InteractEvent event = new NpcEvent.InteractEvent(npc.wrappedNPC, player); ScriptController.Instance.globalNpcScripts.callScript(EnumScriptType.INTERACT, event); boolean result = npc.script.callScript(EnumScriptType.INTERACT, event, "player", player); NpcAPI.EVENT_BUS.post(event); return result; } - public static boolean onNPCMeleeAttack(EntityNPCInterface npc, NpcEvent.MeleeAttackEvent event){ - if(npc == null || npc.wrappedNPC == null) + public static boolean onNPCMeleeAttack(EntityNPCInterface npc, NpcEvent.MeleeAttackEvent event) { + if (npc == null || npc.wrappedNPC == null) return false; ScriptController.Instance.globalNpcScripts.callScript(EnumScriptType.ATTACK_MELEE, event); - npc.script.callScript(EnumScriptType.ATTACK_MELEE, event, "target", event.target); - npc.script.callScript(EnumScriptType.ATTACK, event, "target", event.target); + npc.script.callScript(EnumScriptType.ATTACK_MELEE, event, "target", event.target); + npc.script.callScript(EnumScriptType.ATTACK, event, "target", event.target); return NpcAPI.EVENT_BUS.post(event); } - public static boolean onNPCMeleeSwing(EntityNPCInterface npc, NpcEvent.SwingEvent event){ - if(npc == null || npc.wrappedNPC == null) + public static boolean onNPCMeleeSwing(EntityNPCInterface npc, NpcEvent.SwingEvent event) { + if (npc == null || npc.wrappedNPC == null) return false; ScriptController.Instance.globalNpcScripts.callScript(EnumScriptType.ATTACK_SWING, event); - npc.script.callScript(EnumScriptType.ATTACK_SWING, event); + npc.script.callScript(EnumScriptType.ATTACK_SWING, event); return NpcAPI.EVENT_BUS.post(event); } - public static boolean onNPCRangedAttack(EntityNPCInterface npc, NpcEvent.RangedLaunchedEvent event){ - if(npc == null || npc.wrappedNPC == null) + public static boolean onNPCRangedAttack(EntityNPCInterface npc, NpcEvent.RangedLaunchedEvent event) { + if (npc == null || npc.wrappedNPC == null) return false; ScriptController.Instance.globalNpcScripts.callScript(EnumScriptType.RANGED_LAUNCHED, event); @@ -268,18 +267,18 @@ public class EventHooks { return NpcAPI.EVENT_BUS.post(event); } - public static void onNPCKilledEntity(EntityNPCInterface npc, EntityLivingBase entity){ - if(npc == null || npc.wrappedNPC == null) + public static void onNPCKilledEntity(EntityNPCInterface npc, EntityLivingBase entity) { + if (npc == null || npc.wrappedNPC == null) return; - NpcEvent.KilledEntityEvent event = new NpcEvent.KilledEntityEvent(npc.wrappedNPC,entity); + NpcEvent.KilledEntityEvent event = new NpcEvent.KilledEntityEvent(npc.wrappedNPC, entity); ScriptController.Instance.globalNpcScripts.callScript(EnumScriptType.KILLS, event); npc.script.callScript(EnumScriptType.KILLS, event, "target", entity); NpcAPI.EVENT_BUS.post(event); } - public static boolean onNPCTarget(EntityNPCInterface npc, NpcEvent.TargetEvent event){ - if(npc == null || npc.wrappedNPC == null) + public static boolean onNPCTarget(EntityNPCInterface npc, NpcEvent.TargetEvent event) { + if (npc == null || npc.wrappedNPC == null) return false; ScriptController.Instance.globalNpcScripts.callScript(EnumScriptType.TARGET, event); @@ -288,7 +287,7 @@ public class EventHooks { } public static boolean onNPCTargetLost(EntityNPCInterface npc, EntityLivingBase prevtarget, EntityLivingBase newTarget) { - if(npc.script.isClient()) + if (npc.script.isClient()) return false; NpcEvent.TargetLostEvent event = new NpcEvent.TargetLostEvent(npc.wrappedNPC, prevtarget, newTarget); @@ -297,18 +296,18 @@ public class EventHooks { return NpcAPI.EVENT_BUS.post(event); } - public static void onNPCCollide(EntityNPCInterface npc, Entity entity){ - if(npc == null || npc.wrappedNPC == null) + public static void onNPCCollide(EntityNPCInterface npc, Entity entity) { + if (npc == null || npc.wrappedNPC == null) return; - NpcEvent.CollideEvent event = new NpcEvent.CollideEvent(npc.wrappedNPC,entity); + NpcEvent.CollideEvent event = new NpcEvent.CollideEvent(npc.wrappedNPC, entity); ScriptController.Instance.globalNpcScripts.callScript(EnumScriptType.COLLIDE, event); npc.script.callScript(EnumScriptType.COLLIDE, event, "entity", entity); NpcAPI.EVENT_BUS.post(event); } - public static boolean onNPCDamaged(EntityNPCInterface npc, NpcEvent.DamagedEvent event){ - if(npc == null || npc.wrappedNPC == null) + public static boolean onNPCDamaged(EntityNPCInterface npc, NpcEvent.DamagedEvent event) { + if (npc == null || npc.wrappedNPC == null) return false; ScriptController.Instance.globalNpcScripts.callScript(EnumScriptType.DAMAGED, event); @@ -316,8 +315,8 @@ public class EventHooks { return NpcAPI.EVENT_BUS.post(event); } - public static boolean onNPCKilled(EntityNPCInterface npc, NpcEvent.DiedEvent event){ - if(npc == null || npc.wrappedNPC == null) + public static boolean onNPCKilled(EntityNPCInterface npc, NpcEvent.DiedEvent event) { + if (npc == null || npc.wrappedNPC == null) return false; ScriptController.Instance.globalNpcScripts.callScript(EnumScriptType.KILLED, event); @@ -326,7 +325,7 @@ public class EventHooks { } public static void onNPCTimer(EntityNPCInterface npc, int id) { - if(npc == null || npc.wrappedNPC == null) + if (npc == null || npc.wrappedNPC == null) return; NpcEvent.TimerEvent event = new NpcEvent.TimerEvent(npc.wrappedNPC, id); @@ -338,15 +337,15 @@ public class EventHooks { public static void onProjectileTick(EntityProjectile projectile) { ProjectileEvent.UpdateEvent event = new ProjectileEvent.UpdateEvent((IProjectile) NpcAPI.Instance().getIEntity(projectile)); ScriptController.Instance.globalNpcScripts.callScript(EnumScriptType.PROJECTILE_TICK, event); - for(ScriptContainer script : projectile.scripts) { - if(script.isValid()) { + for (ScriptContainer script : projectile.scripts) { + if (script.isValid()) { script.run(EnumScriptType.PROJECTILE_TICK, event); } } EntityLivingBase thrower = projectile.getThrower(); - if(thrower != null){ - if(thrower instanceof EntityNPCInterface){ + if (thrower != null) { + if (thrower instanceof EntityNPCInterface) { ((EntityNPCInterface) thrower).script.callScript(EnumScriptType.PROJECTILE_TICK, event); } } @@ -356,15 +355,15 @@ public class EventHooks { public static void onProjectileImpact(EntityProjectile projectile, ProjectileEvent.ImpactEvent event) { ScriptController.Instance.globalNpcScripts.callScript(EnumScriptType.PROJECTILE_IMPACT, event); - for(ScriptContainer script : projectile.scripts) { - if(script.isValid()) { + for (ScriptContainer script : projectile.scripts) { + if (script.isValid()) { script.run(EnumScriptType.PROJECTILE_IMPACT, event); } } EntityLivingBase thrower = projectile.getThrower(); - if(thrower != null){ - if(thrower instanceof EntityNPCInterface){ + if (thrower != null) { + if (thrower instanceof EntityNPCInterface) { ((EntityNPCInterface) thrower).script.callScript(EnumScriptType.PROJECTILE_IMPACT, event); } } @@ -407,25 +406,25 @@ public class EventHooks { return NpcAPI.EVENT_BUS.post(event); } - public static boolean onStartUsingItem(PlayerDataScript handler, IPlayer player, int duration, ItemStack item){ + public static boolean onStartUsingItem(PlayerDataScript handler, IPlayer player, int duration, ItemStack item) { PlayerEvent.StartUsingItem event = new PlayerEvent.StartUsingItem(player, item, duration); handler.callScript(EnumScriptType.START_USING_ITEM, event); return NpcAPI.EVENT_BUS.post(event); } - public static boolean onUsingItem(PlayerDataScript handler, IPlayer player, int duration, ItemStack item){ + public static boolean onUsingItem(PlayerDataScript handler, IPlayer player, int duration, ItemStack item) { PlayerEvent.UsingItem event = new PlayerEvent.UsingItem(player, item, duration); handler.callScript(EnumScriptType.USING_ITEM, event); return NpcAPI.EVENT_BUS.post(event); } - public static boolean onStopUsingItem(PlayerDataScript handler, IPlayer player, int duration, ItemStack item){ + public static boolean onStopUsingItem(PlayerDataScript handler, IPlayer player, int duration, ItemStack item) { PlayerEvent.StopUsingItem event = new PlayerEvent.StopUsingItem(player, item, duration); handler.callScript(EnumScriptType.STOP_USING_ITEM, event); return NpcAPI.EVENT_BUS.post(event); } - public static void onFinishUsingItem(PlayerDataScript handler, IPlayer player, int duration, ItemStack item){ + public static void onFinishUsingItem(PlayerDataScript handler, IPlayer player, int duration, ItemStack item) { PlayerEvent.FinishUsingItem event = new PlayerEvent.FinishUsingItem(player, item, duration); handler.callScript(EnumScriptType.FINISH_USING_ITEM, event); NpcAPI.EVENT_BUS.post(event); @@ -433,7 +432,9 @@ public class EventHooks { public static boolean onPlayerDropItems(PlayerDataScript handler, IPlayer player, ArrayList entityItems) { IItemStack[] items = new IItemStack[entityItems.size()]; - for(int i = 0; i < entityItems.size(); i++){ items[i] = NpcAPI.Instance().getIItemStack(entityItems.get(i).getEntityItem()); } + for (int i = 0; i < entityItems.size(); i++) { + items[i] = NpcAPI.Instance().getIItemStack(entityItems.get(i).getEntityItem()); + } DropEvent event = new DropEvent(player, items); handler.callScript(EnumScriptType.DROP, event); @@ -517,7 +518,7 @@ public class EventHooks { } public static boolean onPlayerFall(PlayerDataScript handler, IPlayer player, float distance) { - PlayerEvent.FallEvent event = new PlayerEvent.FallEvent(player,distance); + PlayerEvent.FallEvent event = new PlayerEvent.FallEvent(player, distance); handler.callScript(EnumScriptType.FALL, event); return NpcAPI.EVENT_BUS.post(event); } @@ -597,21 +598,21 @@ public class EventHooks { public static void onPlayerMouseClicked(EntityPlayerMP player, int button, int mouseWheel, boolean buttonDown, boolean isCtrlPressed, boolean isShiftPressed, boolean isAltPressed, boolean isMetaPressed, int[] heldKeys) { PlayerDataScript handler = ScriptController.Instance.playerScripts; - PlayerEvent.MouseClickedEvent event = new PlayerEvent.MouseClickedEvent((IPlayer)NpcAPI.Instance().getIEntity(player), button, mouseWheel, buttonDown, isCtrlPressed, isAltPressed, isShiftPressed, isMetaPressed, heldKeys); + PlayerEvent.MouseClickedEvent event = new PlayerEvent.MouseClickedEvent((IPlayer) NpcAPI.Instance().getIEntity(player), button, mouseWheel, buttonDown, isCtrlPressed, isAltPressed, isShiftPressed, isMetaPressed, heldKeys); handler.callScript(EnumScriptType.MOUSE_CLICKED, event); NpcAPI.EVENT_BUS.post(event); } public static void onPlayerKeyPressed(EntityPlayerMP player, int button, boolean isCtrlPressed, boolean isShiftPressed, boolean isAltPressed, boolean isMetaPressed, boolean buttonDown, int[] heldKeys) { PlayerDataScript handler = ScriptController.Instance.playerScripts; - KeyPressedEvent event = new KeyPressedEvent((IPlayer)NpcAPI.Instance().getIEntity(player), button, isCtrlPressed, isAltPressed, isShiftPressed, isMetaPressed, buttonDown, heldKeys); + KeyPressedEvent event = new KeyPressedEvent((IPlayer) NpcAPI.Instance().getIEntity(player), button, isCtrlPressed, isAltPressed, isShiftPressed, isMetaPressed, buttonDown, heldKeys); handler.callScript(EnumScriptType.KEY_PRESSED, event); NpcAPI.EVENT_BUS.post(event); } public static void onPlayerTimer(PlayerData data, int id) { PlayerDataScript handler = ScriptController.Instance.playerScripts; - noppes.npcs.scripted.event.PlayerEvent.TimerEvent event = new noppes.npcs.scripted.event.PlayerEvent.TimerEvent((IPlayer)NpcAPI.Instance().getIEntity(data.player), id); + noppes.npcs.scripted.event.PlayerEvent.TimerEvent event = new noppes.npcs.scripted.event.PlayerEvent.TimerEvent((IPlayer) NpcAPI.Instance().getIEntity(data.player), id); handler.callScript(EnumScriptType.TIMER, event); NpcAPI.EVENT_BUS.post(event); } @@ -627,8 +628,8 @@ public class EventHooks { } public static void onForgeWorldEvent(WorldEvent event) { - if(ScriptController.Instance.forgeScripts.isEnabled()) { - IWorld e = NpcAPI.Instance().getIWorld((WorldServer)event.world); + if (ScriptController.Instance.forgeScripts.isEnabled()) { + IWorld e = NpcAPI.Instance().getIWorld((WorldServer) event.world); onForgeEvent(new noppes.npcs.scripted.event.ForgeEvent.WorldEvent(event, e), event); } } @@ -641,17 +642,17 @@ public class EventHooks { public static void onForgeEvent(ForgeEvent ev, Event event) { ForgeDataScript handler = ScriptController.Instance.forgeScripts; - if(handler.isEnabled()) { + if (handler.isEnabled()) { String eventName = event.getClass().getName(); int i = eventName.lastIndexOf("."); eventName = StringUtils.uncapitalize(eventName.substring(i + 1).replace("$", "")); - if(event.isCancelable()) { + if (event.isCancelable()) { ev.setCanceled(event.isCanceled()); } handler.callScript(eventName, event); NpcAPI.EVENT_BUS.post(ev); - if(event.isCancelable()) { + if (event.isCancelable()) { event.setCanceled(ev.isCanceled()); } @@ -702,52 +703,52 @@ public class EventHooks { CustomGuiController.onClose(event); } - public static void onQuestFinished(EntityPlayer player, Quest quest){ + public static void onQuestFinished(EntityPlayer player, Quest quest) { PlayerDataScript handler = ScriptController.Instance.playerScripts; QuestEvent.QuestCompletedEvent event = new QuestEvent.QuestCompletedEvent((IPlayer) NpcAPI.Instance().getIEntity((EntityPlayerMP) player), quest); handler.callScript(EnumScriptType.QUEST_COMPLETED, event); NpcAPI.EVENT_BUS.post(event); } - public static boolean onQuestStarted(EntityPlayer player, Quest quest){ + public static boolean onQuestStarted(EntityPlayer player, Quest quest) { PlayerDataScript handler = ScriptController.Instance.playerScripts; QuestEvent.QuestStartEvent event = new QuestEvent.QuestStartEvent((IPlayer) NpcAPI.Instance().getIEntity((EntityPlayerMP) player), quest); handler.callScript(EnumScriptType.QUEST_START, event); return NpcAPI.EVENT_BUS.post(event); } - public static void onQuestTurnedIn(QuestEvent.QuestTurnedInEvent event){ + public static void onQuestTurnedIn(QuestEvent.QuestTurnedInEvent event) { PlayerDataScript handler = ScriptController.Instance.playerScripts; handler.callScript(EnumScriptType.QUEST_TURNIN, event); NpcAPI.EVENT_BUS.post(event); } - public static boolean onFactionPoints(FactionEvent.FactionPoints event){ + public static boolean onFactionPoints(FactionEvent.FactionPoints event) { PlayerDataScript handler = ScriptController.Instance.playerScripts; handler.callScript(EnumScriptType.FACTION_POINTS, event); return NpcAPI.EVENT_BUS.post(event); } - public static boolean onDialogOpen(DialogEvent.DialogOpen event){ + public static boolean onDialogOpen(DialogEvent.DialogOpen event) { PlayerDataScript handler = ScriptController.Instance.playerScripts; handler.callScript(EnumScriptType.DIALOG_OPEN, event); return NpcAPI.EVENT_BUS.post(event); } - public static boolean onDialogOption(DialogEvent.DialogOption event){ + public static boolean onDialogOption(DialogEvent.DialogOption event) { PlayerDataScript handler = ScriptController.Instance.playerScripts; handler.callScript(EnumScriptType.DIALOG_OPTION, event); return NpcAPI.EVENT_BUS.post(event); } - public static void onDialogClosed(DialogEvent.DialogClosed event){ + public static void onDialogClosed(DialogEvent.DialogClosed event) { PlayerDataScript handler = ScriptController.Instance.playerScripts; handler.callScript(EnumScriptType.DIALOG_CLOSE, event); NpcAPI.EVENT_BUS.post(event); } public static boolean onScriptBlockInteract(IScriptBlockHandler handler, EntityPlayer player, int side, float hitX, float hitY, float hitZ) { - if(handler.isClient()) + if (handler.isClient()) return false; BlockEvent.InteractEvent event = new BlockEvent.InteractEvent(handler.getBlock(), player, side, hitX, hitY, hitZ); handler.callScript(EnumScriptType.INTERACT, event); @@ -755,7 +756,7 @@ public class EventHooks { } public static void onScriptBlockCollide(IScriptBlockHandler handler, Entity entityIn) { - if(handler.isClient()) + if (handler.isClient()) return; BlockEvent.CollidedEvent event = new BlockEvent.CollidedEvent(handler.getBlock(), entityIn); handler.callScript(EnumScriptType.COLLIDE, event); @@ -763,7 +764,7 @@ public class EventHooks { } public static void onScriptBlockRainFill(IScriptBlockHandler handler) { - if(handler.isClient()) + if (handler.isClient()) return; BlockEvent.RainFillEvent event = new BlockEvent.RainFillEvent(handler.getBlock()); handler.callScript(EnumScriptType.RAIN_FILLED, event); @@ -771,17 +772,17 @@ public class EventHooks { } public static float onScriptBlockFallenUpon(IScriptBlockHandler handler, Entity entity, float distance) { - if(handler.isClient()) + if (handler.isClient()) return distance; BlockEvent.EntityFallenUponEvent event = new BlockEvent.EntityFallenUponEvent(handler.getBlock(), entity, distance); handler.callScript(EnumScriptType.FALLEN_UPON, event); - if(NpcAPI.EVENT_BUS.post(event)) + if (NpcAPI.EVENT_BUS.post(event)) return 0; return event.distanceFallen; } public static void onScriptBlockClicked(IScriptBlockHandler handler, EntityPlayer player) { - if(handler.isClient()) + if (handler.isClient()) return; BlockEvent.ClickedEvent event = new BlockEvent.ClickedEvent(handler.getBlock(), player); handler.callScript(EnumScriptType.CLICKED, event); @@ -789,7 +790,7 @@ public class EventHooks { } public static void onScriptBlockBreak(IScriptBlockHandler handler) { - if(handler.isClient()) + if (handler.isClient()) return; BlockEvent.BreakEvent event = new BlockEvent.BreakEvent(handler.getBlock()); handler.callScript(EnumScriptType.BROKEN, event); @@ -797,7 +798,7 @@ public class EventHooks { } public static boolean onScriptBlockHarvest(IScriptBlockHandler handler, EntityPlayer player) { - if(handler.isClient()) + if (handler.isClient()) return false; BlockEvent.HarvestedEvent event = new BlockEvent.HarvestedEvent(handler.getBlock(), player); handler.callScript(EnumScriptType.HARVESTED, event); @@ -805,7 +806,7 @@ public class EventHooks { } public static boolean onScriptBlockExploded(IScriptBlockHandler handler) { - if(handler.isClient()) + if (handler.isClient()) return false; BlockEvent.ExplodedEvent event = new BlockEvent.ExplodedEvent(handler.getBlock()); handler.callScript(EnumScriptType.EXPLODED, event); @@ -813,15 +814,15 @@ public class EventHooks { } public static void onScriptBlockNeighborChanged(IScriptBlockHandler handler, int x, int y, int z) { - if(handler.isClient()) + if (handler.isClient()) return; - BlockEvent.NeighborChangedEvent event = new BlockEvent.NeighborChangedEvent(handler.getBlock(), NpcAPI.Instance().getIPos(x,y,z)); + BlockEvent.NeighborChangedEvent event = new BlockEvent.NeighborChangedEvent(handler.getBlock(), NpcAPI.Instance().getIPos(x, y, z)); handler.callScript(EnumScriptType.NEIGHBOR_CHANGED, event); NpcAPI.EVENT_BUS.post(event); } public static void onScriptBlockRedstonePower(IScriptBlockHandler handler, int prevPower, int power) { - if(handler.isClient()) + if (handler.isClient()) return; BlockEvent.RedstoneEvent event = new BlockEvent.RedstoneEvent(handler.getBlock(), prevPower, power); handler.callScript(EnumScriptType.REDSTONE, event); @@ -829,7 +830,7 @@ public class EventHooks { } public static void onScriptBlockInit(IScriptBlockHandler handler) { - if(handler.isClient()) + if (handler.isClient()) return; BlockEvent.InitEvent event = new BlockEvent.InitEvent(handler.getBlock()); handler.callScript(EnumScriptType.INIT, event); @@ -837,7 +838,7 @@ public class EventHooks { } public static void onScriptBlockUpdate(IScriptBlockHandler handler) { - if(handler.isClient()) + if (handler.isClient()) return; BlockEvent.UpdateEvent event = new BlockEvent.UpdateEvent(handler.getBlock()); handler.callScript(EnumScriptType.TICK, event); @@ -850,44 +851,44 @@ public class EventHooks { NpcAPI.EVENT_BUS.post(event); } - public static void onPartyFinished(Party party, Quest quest){ + public static void onPartyFinished(Party party, Quest quest) { PlayerDataScript handler = ScriptController.Instance.playerScripts; PartyEvent.PartyQuestCompletedEvent event = new PartyEvent.PartyQuestCompletedEvent(party, quest); handler.callScript(EnumScriptType.PARTY_QUEST_COMPLETED, event); NpcAPI.EVENT_BUS.post(event); } - public static void onPartyQuestSet(PartyEvent.PartyQuestSetEvent event){ + public static void onPartyQuestSet(PartyEvent.PartyQuestSetEvent event) { PlayerDataScript handler = ScriptController.Instance.playerScripts; handler.callScript(EnumScriptType.PARTY_QUEST_SET, event); NpcAPI.EVENT_BUS.post(event); } - public static void onPartyTurnIn(PartyEvent.PartyQuestTurnedInEvent event){ + public static void onPartyTurnIn(PartyEvent.PartyQuestTurnedInEvent event) { PlayerDataScript handler = ScriptController.Instance.playerScripts; handler.callScript(EnumScriptType.PARTY_QUEST_TURNED_IN, event); NpcAPI.EVENT_BUS.post(event); } - public static void onPartyInvite(PartyEvent.PartyInviteEvent event){ + public static void onPartyInvite(PartyEvent.PartyInviteEvent event) { PlayerDataScript handler = ScriptController.Instance.playerScripts; handler.callScript(EnumScriptType.PARTY_INVITE, event); NpcAPI.EVENT_BUS.post(event); } - public static void onPartyKick(PartyEvent.PartyKickEvent event){ + public static void onPartyKick(PartyEvent.PartyKickEvent event) { PlayerDataScript handler = ScriptController.Instance.playerScripts; handler.callScript(EnumScriptType.PARTY_KICK, event); NpcAPI.EVENT_BUS.post(event); } - public static void onPartyLeave(PartyEvent.PartyLeaveEvent event){ + public static void onPartyLeave(PartyEvent.PartyLeaveEvent event) { PlayerDataScript handler = ScriptController.Instance.playerScripts; handler.callScript(EnumScriptType.PARTY_LEAVE, event); NpcAPI.EVENT_BUS.post(event); } - public static void onPartyDisband(PartyEvent.PartyDisbandEvent event){ + public static void onPartyDisband(PartyEvent.PartyDisbandEvent event) { PlayerDataScript handler = ScriptController.Instance.playerScripts; handler.callScript(EnumScriptType.PARTY_DISBAND, event); NpcAPI.EVENT_BUS.post(event); diff --git a/src/main/java/noppes/npcs/IChatMessages.java b/src/main/java/noppes/npcs/IChatMessages.java index 40b28eb24..387f809c2 100644 --- a/src/main/java/noppes/npcs/IChatMessages.java +++ b/src/main/java/noppes/npcs/IChatMessages.java @@ -4,7 +4,8 @@ import noppes.npcs.entity.EntityNPCInterface; public interface IChatMessages { - public void addMessage(String message, EntityNPCInterface npc); - public void renderMessages(double par3, double par5, double par7, float scale, boolean inRange); + public void addMessage(String message, EntityNPCInterface npc); + + public void renderMessages(double par3, double par5, double par7, float scale, boolean inRange); } diff --git a/src/main/java/noppes/npcs/ICompatibilty.java b/src/main/java/noppes/npcs/ICompatibilty.java index 7c34a739b..e552cca13 100644 --- a/src/main/java/noppes/npcs/ICompatibilty.java +++ b/src/main/java/noppes/npcs/ICompatibilty.java @@ -3,7 +3,9 @@ package noppes.npcs; import net.minecraft.nbt.NBTTagCompound; public interface ICompatibilty { - public int getVersion(); - public void setVersion(int version); - public NBTTagCompound writeToNBT(NBTTagCompound compound); + public int getVersion(); + + public void setVersion(int version); + + public NBTTagCompound writeToNBT(NBTTagCompound compound); } diff --git a/src/main/java/noppes/npcs/LogWriter.java b/src/main/java/noppes/npcs/LogWriter.java index aeccab32f..2c14af3a6 100644 --- a/src/main/java/noppes/npcs/LogWriter.java +++ b/src/main/java/noppes/npcs/LogWriter.java @@ -12,215 +12,214 @@ import java.util.concurrent.TimeUnit; import java.util.logging.*; public class LogWriter { - private final static String name = "CustomNPCs"; - private final static Logger logger = Logger.getLogger(name); + private final static String name = "CustomNPCs"; + private final static Logger logger = Logger.getLogger(name); - private final static WeakHashMap InitCacheMap = new WeakHashMap(); - private final static WeakHashMap TickCacheMap = new WeakHashMap(); - private final static WeakHashMap InteractCacheMap = new WeakHashMap(); - private final static WeakHashMap DialogCacheMap = new WeakHashMap(); - private final static WeakHashMap DamagedCacheMap = new WeakHashMap(); - private final static WeakHashMap KilledCacheMap = new WeakHashMap(); - private final static WeakHashMap AttackCacheMap = new WeakHashMap(); - private final static WeakHashMap TargetCacheMap = new WeakHashMap(); - private final static WeakHashMap CollideCacheMap = new WeakHashMap(); - private final static WeakHashMap KillsCacheMap = new WeakHashMap(); - private final static WeakHashMap DialogCloseCacheMap = new WeakHashMap(); - private final static WeakHashMap TimerCacheMap = new WeakHashMap(); + private final static WeakHashMap InitCacheMap = new WeakHashMap(); + private final static WeakHashMap TickCacheMap = new WeakHashMap(); + private final static WeakHashMap InteractCacheMap = new WeakHashMap(); + private final static WeakHashMap DialogCacheMap = new WeakHashMap(); + private final static WeakHashMap DamagedCacheMap = new WeakHashMap(); + private final static WeakHashMap KilledCacheMap = new WeakHashMap(); + private final static WeakHashMap AttackCacheMap = new WeakHashMap(); + private final static WeakHashMap TargetCacheMap = new WeakHashMap(); + private final static WeakHashMap CollideCacheMap = new WeakHashMap(); + private final static WeakHashMap KillsCacheMap = new WeakHashMap(); + private final static WeakHashMap DialogCloseCacheMap = new WeakHashMap(); + private final static WeakHashMap TimerCacheMap = new WeakHashMap(); - private final static SimpleDateFormat dateformat = new SimpleDateFormat("HH:mm:ss"); - private static Handler handler; - static { - try { - File dir = new File("logs"); - if(!dir.exists()) - dir.mkdir(); - File file = new File(dir, name + "-latest.log"); - File lock = new File(dir, name + "-latest.log.lck"); - File file1 = new File(dir, name + "-1.log"); - File file2 = new File(dir, name + "-2.log"); - File file3 = new File(dir, name + "-3.log"); + private final static SimpleDateFormat dateformat = new SimpleDateFormat("HH:mm:ss"); + private static Handler handler; - if(lock.exists()) - lock.delete(); + static { + try { + File dir = new File("logs"); + if (!dir.exists()) + dir.mkdir(); + File file = new File(dir, name + "-latest.log"); + File lock = new File(dir, name + "-latest.log.lck"); + File file1 = new File(dir, name + "-1.log"); + File file2 = new File(dir, name + "-2.log"); + File file3 = new File(dir, name + "-3.log"); - if(file3.exists()) - file3.delete(); - if(file2.exists()) - file2.renameTo(file3); - if(file1.exists()) - file1.renameTo(file2); - if(file.exists()) - file.renameTo(file1); + if (lock.exists()) + lock.delete(); - handler = new StreamHandler(new FileOutputStream(file), new Formatter() { - @Override - public String format(LogRecord record) { - String line = ""; - if (record.getLevel() != NPCLogLevel.CNPCLog){ - StackTraceElement element = Thread.currentThread().getStackTrace()[8]; - line = "[" + element.getClassName() + ":" + element.getLineNumber() + "] "; - } - String time = "[" + dateformat.format(new Date(record.getMillis())) + "][" + record.getLevel() + "]" + line; - if(record.getThrown() != null){ - StringWriter sw = new StringWriter(); - PrintWriter pw = new PrintWriter(sw); - record.getThrown().printStackTrace(pw); - return time + sw.toString(); - } - return time + record.getMessage() + System.getProperty("line.separator"); - } - }); - handler.setLevel(Level.ALL); - logger.addHandler(handler); - logger.setUseParentHandlers(false); - Handler consoleHandler = new ConsoleHandler(); - consoleHandler.setFormatter(handler.getFormatter()); - consoleHandler.setLevel(Level.FINEST); - logger.addHandler(consoleHandler); - logger.setLevel(Level.ALL); - info(new Date().toString()); - } catch (SecurityException e) { + if (file3.exists()) + file3.delete(); + if (file2.exists()) + file2.renameTo(file3); + if (file1.exists()) + file1.renameTo(file2); + if (file.exists()) + file.renameTo(file1); - e.printStackTrace(); - } catch (IOException e) { + handler = new StreamHandler(new FileOutputStream(file), new Formatter() { + @Override + public String format(LogRecord record) { + String line = ""; + if (record.getLevel() != NPCLogLevel.CNPCLog) { + StackTraceElement element = Thread.currentThread().getStackTrace()[8]; + line = "[" + element.getClassName() + ":" + element.getLineNumber() + "] "; + } + String time = "[" + dateformat.format(new Date(record.getMillis())) + "][" + record.getLevel() + "]" + line; + if (record.getThrown() != null) { + StringWriter sw = new StringWriter(); + PrintWriter pw = new PrintWriter(sw); + record.getThrown().printStackTrace(pw); + return time + sw.toString(); + } + return time + record.getMessage() + System.getProperty("line.separator"); + } + }); + handler.setLevel(Level.ALL); + logger.addHandler(handler); + logger.setUseParentHandlers(false); + Handler consoleHandler = new ConsoleHandler(); + consoleHandler.setFormatter(handler.getFormatter()); + consoleHandler.setLevel(Level.FINEST); + logger.addHandler(consoleHandler); + logger.setLevel(Level.ALL); + info(new Date().toString()); + } catch (SecurityException e) { - e.printStackTrace(); - } - } + e.printStackTrace(); + } catch (IOException e) { - public static void postScriptLog(UUID npcUUID, EnumScriptType type, String message) { - switch (type){ - case INIT: - if(!CustomNpcs.InitIgnore){ - scriptLogCalculator(InitCacheMap, npcUUID, message); - } - break; - case TICK: - if(!CustomNpcs.TickIgnore){ - scriptLogCalculator(TickCacheMap, npcUUID, message); - } - break; - case INTERACT: - if(!CustomNpcs.InteractIgnore){ - scriptLogCalculator(InteractCacheMap, npcUUID, message); - } - break; - case DIALOG: - if(!CustomNpcs.DialogIgnore){ - scriptLogCalculator(DialogCacheMap, npcUUID, message); - } - break; - case DAMAGED: - if(!CustomNpcs.DamagedIgnore){ - scriptLogCalculator(DamagedCacheMap, npcUUID, message); - } - break; - case KILLED: - if(!CustomNpcs.KilledIgnore){ - scriptLogCalculator(KilledCacheMap, npcUUID, message); - } - break; - case ATTACK: - if(!CustomNpcs.AttackIgnore){ - scriptLogCalculator(AttackCacheMap, npcUUID, message); - } - break; - case TARGET: - if(!CustomNpcs.TargetIgnore){ - scriptLogCalculator(TargetCacheMap, npcUUID, message); - } - break; - case COLLIDE: - if(!CustomNpcs.CollideIgnore){ - scriptLogCalculator(CollideCacheMap, npcUUID, message); - } - break; - case KILLS: - if(!CustomNpcs.KillsIgnore){ - scriptLogCalculator(KillsCacheMap, npcUUID, message); - } - case DIALOG_CLOSE: - if(!CustomNpcs.DialogCloseIgnore){ - scriptLogCalculator(DialogCloseCacheMap, npcUUID, message); - } - break; - case TIMER: - if(!CustomNpcs.TimerIgnore){ - scriptLogCalculator(TimerCacheMap, npcUUID, message); - } - break; - default: - break; - } - } + e.printStackTrace(); + } + } - public static void scriptLogCalculator(WeakHashMap map, UUID npcUUID, String message) { - if(map.containsKey(npcUUID)){ - NPCStamp stamp = map.get(npcUUID); - long secondsSinceFirst = TimeUnit.MILLISECONDS.toSeconds(new Date().getTime() - stamp.makeDate.getTime()); - long millisecSinceLast = TimeUnit.MILLISECONDS.toMillis(stamp.recentDate.getTime() - stamp.makeDate.getTime()); + public static void postScriptLog(UUID npcUUID, EnumScriptType type, String message) { + switch (type) { + case INIT: + if (!CustomNpcs.InitIgnore) { + scriptLogCalculator(InitCacheMap, npcUUID, message); + } + break; + case TICK: + if (!CustomNpcs.TickIgnore) { + scriptLogCalculator(TickCacheMap, npcUUID, message); + } + break; + case INTERACT: + if (!CustomNpcs.InteractIgnore) { + scriptLogCalculator(InteractCacheMap, npcUUID, message); + } + break; + case DIALOG: + if (!CustomNpcs.DialogIgnore) { + scriptLogCalculator(DialogCacheMap, npcUUID, message); + } + break; + case DAMAGED: + if (!CustomNpcs.DamagedIgnore) { + scriptLogCalculator(DamagedCacheMap, npcUUID, message); + } + break; + case KILLED: + if (!CustomNpcs.KilledIgnore) { + scriptLogCalculator(KilledCacheMap, npcUUID, message); + } + break; + case ATTACK: + if (!CustomNpcs.AttackIgnore) { + scriptLogCalculator(AttackCacheMap, npcUUID, message); + } + break; + case TARGET: + if (!CustomNpcs.TargetIgnore) { + scriptLogCalculator(TargetCacheMap, npcUUID, message); + } + break; + case COLLIDE: + if (!CustomNpcs.CollideIgnore) { + scriptLogCalculator(CollideCacheMap, npcUUID, message); + } + break; + case KILLS: + if (!CustomNpcs.KillsIgnore) { + scriptLogCalculator(KillsCacheMap, npcUUID, message); + } + case DIALOG_CLOSE: + if (!CustomNpcs.DialogCloseIgnore) { + scriptLogCalculator(DialogCloseCacheMap, npcUUID, message); + } + break; + case TIMER: + if (!CustomNpcs.TimerIgnore) { + scriptLogCalculator(TimerCacheMap, npcUUID, message); + } + break; + default: + break; + } + } - double frequency = (float) ConfigDebug.ScriptFrequency / 60; - // Reset Log if 2 Minutes Pass - if (secondsSinceFirst > 120) { - LogWriter.script(message); - stamp.counter = 1; - stamp.makeDate = new Date(); - stamp.recentDate = new Date(); - } - // ALWAYS Log the First 3 of Event - else if(secondsSinceFirst < 10 && stamp.counter < 3) { - LogWriter.script(message); - stamp.recentDate = new Date(); - } - // IF event occurs to QUICKLY Ignore. - else if (millisecSinceLast < ConfigDebug.ScriptIgnoreTime){ - stamp.recentDate = new Date(); - } - else if(secondsSinceFirst > 10 && (double)stamp.counter / secondsSinceFirst > frequency){ - // WARN - LogWriter.script("[SPAM]:" + message); - stamp.counter = 0; - stamp.recentDate = new Date(); - } - stamp.counter++; - } else { - map.put(npcUUID, new NPCStamp()); - LogWriter.script(message); - } - } + public static void scriptLogCalculator(WeakHashMap map, UUID npcUUID, String message) { + if (map.containsKey(npcUUID)) { + NPCStamp stamp = map.get(npcUUID); + long secondsSinceFirst = TimeUnit.MILLISECONDS.toSeconds(new Date().getTime() - stamp.makeDate.getTime()); + long millisecSinceLast = TimeUnit.MILLISECONDS.toMillis(stamp.recentDate.getTime() - stamp.makeDate.getTime()); - public static void script(Object msg) { - logger.log(NPCLogLevel.CNPCLog, msg.toString()); - handler.flush(); - } + double frequency = (float) ConfigDebug.ScriptFrequency / 60; + // Reset Log if 2 Minutes Pass + if (secondsSinceFirst > 120) { + LogWriter.script(message); + stamp.counter = 1; + stamp.makeDate = new Date(); + stamp.recentDate = new Date(); + } + // ALWAYS Log the First 3 of Event + else if (secondsSinceFirst < 10 && stamp.counter < 3) { + LogWriter.script(message); + stamp.recentDate = new Date(); + } + // IF event occurs to QUICKLY Ignore. + else if (millisecSinceLast < ConfigDebug.ScriptIgnoreTime) { + stamp.recentDate = new Date(); + } else if (secondsSinceFirst > 10 && (double) stamp.counter / secondsSinceFirst > frequency) { + // WARN + LogWriter.script("[SPAM]:" + message); + stamp.counter = 0; + stamp.recentDate = new Date(); + } + stamp.counter++; + } else { + map.put(npcUUID, new NPCStamp()); + LogWriter.script(message); + } + } - public static void info(Object msg) { - logger.log(Level.INFO, msg.toString()); - handler.flush(); - } + public static void script(Object msg) { + logger.log(NPCLogLevel.CNPCLog, msg.toString()); + handler.flush(); + } - public static void error(Object msg) { - logger.log(Level.SEVERE, msg.toString()); - handler.flush(); - } + public static void info(Object msg) { + logger.log(Level.INFO, msg.toString()); + handler.flush(); + } - public static void error(Object msg, Exception e) { - logger.log(Level.SEVERE, msg.toString()); - logger.log(Level.SEVERE, e.getMessage(), e); - handler.flush(); - } + public static void error(Object msg) { + logger.log(Level.SEVERE, msg.toString()); + handler.flush(); + } - public static void except(Exception e) { - logger.log(Level.SEVERE, e.getMessage(), e); - handler.flush(); - } + public static void error(Object msg, Exception e) { + logger.log(Level.SEVERE, msg.toString()); + logger.log(Level.SEVERE, e.getMessage(), e); + handler.flush(); + } + + public static void except(Exception e) { + logger.log(Level.SEVERE, e.getMessage(), e); + handler.flush(); + } } -class NPCStamp -{ - public Date makeDate = new Date(); - public Date recentDate = new Date(); - public int counter = 1; +class NPCStamp { + public Date makeDate = new Date(); + public Date recentDate = new Date(); + public int counter = 1; }; diff --git a/src/main/java/noppes/npcs/NBTTags.java b/src/main/java/noppes/npcs/NBTTags.java index 315be283e..d8771caf5 100644 --- a/src/main/java/noppes/npcs/NBTTags.java +++ b/src/main/java/noppes/npcs/NBTTags.java @@ -22,112 +22,101 @@ public class NBTTags { public static int TAG_Compound = 10; public static int TAG_Int_Array = 11; - public static HashMap getItemStackList( - NBTTagList tagList) { - HashMap list = new HashMap(); - for(int i = 0; i < tagList.tagCount(); i++) - { + public static HashMap getItemStackList( + NBTTagList tagList) { + HashMap list = new HashMap(); + for (int i = 0; i < tagList.tagCount(); i++) { NBTTagCompound nbttagcompound = tagList.getCompoundTagAt(i); - try{ - list.put(nbttagcompound.getByte("Slot") & 0xff, NoppesUtilServer.readItem(nbttagcompound)); - } - catch(ClassCastException e){ - list.put(nbttagcompound.getInteger("Slot"), NoppesUtilServer.readItem(nbttagcompound)); + try { + list.put(nbttagcompound.getByte("Slot") & 0xff, NoppesUtilServer.readItem(nbttagcompound)); + } catch (ClassCastException e) { + list.put(nbttagcompound.getInteger("Slot"), NoppesUtilServer.readItem(nbttagcompound)); } } - return list; - } + return list; + } - public static ItemStack[] getItemStackArray( - NBTTagList tagList) { - ItemStack[] list = new ItemStack[tagList.tagCount()]; - for(int i = 0; i < tagList.tagCount(); i++) - { + public static ItemStack[] getItemStackArray( + NBTTagList tagList) { + ItemStack[] list = new ItemStack[tagList.tagCount()]; + for (int i = 0; i < tagList.tagCount(); i++) { NBTTagCompound nbttagcompound = tagList.getCompoundTagAt(i); - list[nbttagcompound.getByte("Slot") & 0xff] = NoppesUtilServer.readItem(nbttagcompound); + list[nbttagcompound.getByte("Slot") & 0xff] = NoppesUtilServer.readItem(nbttagcompound); } - return list; - } + return list; + } - public static ArrayList getIntegerArraySet(NBTTagList tagList) { - ArrayList set = new ArrayList(); - for(int i = 0; i < tagList.tagCount(); i++) - { - NBTTagCompound compound = tagList.getCompoundTagAt(i); - set.add(compound.getIntArray("Array")); + public static ArrayList getIntegerArraySet(NBTTagList tagList) { + ArrayList set = new ArrayList(); + for (int i = 0; i < tagList.tagCount(); i++) { + NBTTagCompound compound = tagList.getCompoundTagAt(i); + set.add(compound.getIntArray("Array")); } - return set; - } + return set; + } - public static HashMap getBooleanList(NBTTagList tagList) { - HashMap list = new HashMap(); - for(int i = 0; i < tagList.tagCount(); i++) - { + public static HashMap getBooleanList(NBTTagList tagList) { + HashMap list = new HashMap(); + for (int i = 0; i < tagList.tagCount(); i++) { NBTTagCompound nbttagcompound = tagList.getCompoundTagAt(i); list.put(nbttagcompound.getInteger("Slot"), nbttagcompound.getBoolean("Boolean")); } - return list; - } + return list; + } - public static HashMap getIntegerIntegerMap( - NBTTagList tagList) { - HashMap list = new HashMap(); - for(int i = 0; i < tagList.tagCount(); i++) - { + public static HashMap getIntegerIntegerMap( + NBTTagList tagList) { + HashMap list = new HashMap(); + for (int i = 0; i < tagList.tagCount(); i++) { NBTTagCompound nbttagcompound = tagList.getCompoundTagAt(i); list.put(nbttagcompound.getInteger("Slot"), nbttagcompound.getInteger("Integer")); } - return list; - } + return list; + } public static HashMap getIntegerFloatMap( NBTTagList tagList) { HashMap list = new HashMap(); - for(int i = 0; i < tagList.tagCount(); i++) - { + for (int i = 0; i < tagList.tagCount(); i++) { NBTTagCompound nbttagcompound = tagList.getCompoundTagAt(i); list.put(nbttagcompound.getInteger("Slot"), nbttagcompound.getFloat("Float")); } return list; } - public static HashMap getIntegerDoubleMap( - NBTTagList tagList) { - HashMap list = new HashMap(); - for(int i = 0; i < tagList.tagCount(); i++) - { - NBTTagCompound nbttagcompound = tagList.getCompoundTagAt(i); - list.put(nbttagcompound.getInteger("Slot"), nbttagcompound.getDouble("Double")); - } - return list; - } + public static HashMap getIntegerDoubleMap( + NBTTagList tagList) { + HashMap list = new HashMap(); + for (int i = 0; i < tagList.tagCount(); i++) { + NBTTagCompound nbttagcompound = tagList.getCompoundTagAt(i); + list.put(nbttagcompound.getInteger("Slot"), nbttagcompound.getDouble("Double")); + } + return list; + } - public static HashMap getIntegerLongMap( - NBTTagList tagList) { - HashMap list = new HashMap(); - for(int i = 0; i < tagList.tagCount(); i++) - { + public static HashMap getIntegerLongMap( + NBTTagList tagList) { + HashMap list = new HashMap(); + for (int i = 0; i < tagList.tagCount(); i++) { NBTTagCompound nbttagcompound = tagList.getCompoundTagAt(i); list.put(nbttagcompound.getInteger("Slot"), nbttagcompound.getLong("Long")); } - return list; - } + return list; + } - public static HashSet getStringSet(NBTTagList tagList) { - HashSet list = new HashSet<>(); - for(int i = 0; i < tagList.tagCount(); i++) - { - NBTTagCompound nbttagcompound = tagList.getCompoundTagAt(i); - list.add(nbttagcompound.getString("String")); - } - return list; - } + public static HashSet getStringSet(NBTTagList tagList) { + HashSet list = new HashSet<>(); + for (int i = 0; i < tagList.tagCount(); i++) { + NBTTagCompound nbttagcompound = tagList.getCompoundTagAt(i); + list.add(nbttagcompound.getString("String")); + } + return list; + } public static HashMap getIntegerByteMap( NBTTagList tagList) { HashMap list = new HashMap(); - for(int i = 0; i < tagList.tagCount(); i++) - { + for (int i = 0; i < tagList.tagCount(); i++) { NBTTagCompound nbttagcompound = tagList.getCompoundTagAt(i); list.put(nbttagcompound.getInteger("Slot"), nbttagcompound.getByte("Byte")); } @@ -136,7 +125,7 @@ public class NBTTags { public static NBTTagList nbtIntegerByteMap(Map lines) { NBTTagList nbttaglist = new NBTTagList(); - if(lines == null) + if (lines == null) return nbttaglist; for (int slot : lines.keySet()) { NBTTagCompound nbttagcompound = new NBTTagCompound(); @@ -147,194 +136,182 @@ public class NBTTags { return nbttaglist; } - public static NBTTagList nbtStringSet(HashSet collection) { - NBTTagList nbttaglist = new NBTTagList(); - if(collection == null) - return nbttaglist; - for (String slot : collection) { - NBTTagCompound nbttagcompound = new NBTTagCompound(); - nbttagcompound.setString("String", slot); - nbttaglist.appendTag(nbttagcompound); - } - return nbttaglist; - } + public static NBTTagList nbtStringSet(HashSet collection) { + NBTTagList nbttaglist = new NBTTagList(); + if (collection == null) + return nbttaglist; + for (String slot : collection) { + NBTTagCompound nbttagcompound = new NBTTagCompound(); + nbttagcompound.setString("String", slot); + nbttaglist.appendTag(nbttagcompound); + } + return nbttaglist; + } - public static HashSet getIntegerSet(NBTTagList tagList) { - HashSet list = new HashSet(); - for(int i = 0; i < tagList.tagCount(); i++) - { + public static HashSet getIntegerSet(NBTTagList tagList) { + HashSet list = new HashSet(); + for (int i = 0; i < tagList.tagCount(); i++) { NBTTagCompound nbttagcompound = tagList.getCompoundTagAt(i); list.add(nbttagcompound.getInteger("Integer")); } - return list; - } + return list; + } - public static NBTTagList nbtIntegerSet(HashSet set) { - NBTTagList nbttaglist = new NBTTagList(); - if(set == null) - return nbttaglist; - for (int slot : set) { - NBTTagCompound nbttagcompound = new NBTTagCompound(); - nbttagcompound.setInteger("Integer", slot); - nbttaglist.appendTag(nbttagcompound); - } - return nbttaglist; - } + public static NBTTagList nbtIntegerSet(HashSet set) { + NBTTagList nbttaglist = new NBTTagList(); + if (set == null) + return nbttaglist; + for (int slot : set) { + NBTTagCompound nbttagcompound = new NBTTagCompound(); + nbttagcompound.setInteger("Integer", slot); + nbttaglist.appendTag(nbttagcompound); + } + return nbttaglist; + } - public static HashMap getStringStringMap(NBTTagList tagList) { - HashMap list = new HashMap(); - for(int i = 0; i < tagList.tagCount(); i++) - { + public static HashMap getStringStringMap(NBTTagList tagList) { + HashMap list = new HashMap(); + for (int i = 0; i < tagList.tagCount(); i++) { NBTTagCompound nbttagcompound = tagList.getCompoundTagAt(i); list.put(nbttagcompound.getString("Slot"), nbttagcompound.getString("Value")); } - return list; - } + return list; + } - public static HashMap getIntegerStringMap(NBTTagList tagList) { - HashMap list = new HashMap(); - for(int i = 0; i < tagList.tagCount(); i++) - { + public static HashMap getIntegerStringMap(NBTTagList tagList) { + HashMap list = new HashMap(); + for (int i = 0; i < tagList.tagCount(); i++) { NBTTagCompound nbttagcompound = tagList.getCompoundTagAt(i); list.put(nbttagcompound.getInteger("Slot"), nbttagcompound.getString("Value")); } - return list; - } + return list; + } - public static HashMap getStringIntegerMap(NBTTagList tagList) { - HashMap list = new HashMap(); - for(int i = 0; i < tagList.tagCount(); i++) - { + public static HashMap getStringIntegerMap(NBTTagList tagList) { + HashMap list = new HashMap(); + for (int i = 0; i < tagList.tagCount(); i++) { NBTTagCompound nbttagcompound = tagList.getCompoundTagAt(i); list.put(nbttagcompound.getString("Slot"), nbttagcompound.getInteger("Value")); } - return list; - } + return list; + } - public static HashMap getStringIntegerArrayMap(NBTTagList tagList) { - HashMap list = new HashMap(); - for(int i = 0; i < tagList.tagCount(); i++) - { + public static HashMap getStringIntegerArrayMap(NBTTagList tagList) { + HashMap list = new HashMap(); + for (int i = 0; i < tagList.tagCount(); i++) { NBTTagCompound nbttagcompound = tagList.getCompoundTagAt(i); list.put(nbttagcompound.getString("Slot"), nbttagcompound.getIntArray("Value")); } - return list; - } + return list; + } - /** - * @param tagList - * @param arrayLength if an int array is not this length a new int array with this length is made - * @return - */ - public static HashMap getStringIntegerArrayMap(NBTTagList tagList, int arrayLength) { - HashMap list = new HashMap(); - for(int i = 0; i < tagList.tagCount(); i++) - { + /** + * @param tagList + * @param arrayLength if an int array is not this length a new int array with this length is made + * @return + */ + public static HashMap getStringIntegerArrayMap(NBTTagList tagList, int arrayLength) { + HashMap list = new HashMap(); + for (int i = 0; i < tagList.tagCount(); i++) { NBTTagCompound nbttagcompound = tagList.getCompoundTagAt(i); int[] a = nbttagcompound.getIntArray("Value"); if (a.length != arrayLength) a = new int[arrayLength]; list.put(nbttagcompound.getString("Slot"), a); } - return list; - } + return list; + } - public static HashMap> getVectorMap(NBTTagList tagList) { - HashMap> map = new HashMap>(); - for(int i = 0; i < tagList.tagCount(); i++) - { - Vector values = new Vector(); + public static HashMap> getVectorMap(NBTTagList tagList) { + HashMap> map = new HashMap>(); + for (int i = 0; i < tagList.tagCount(); i++) { + Vector values = new Vector(); NBTTagCompound nbttagcompound = tagList.getCompoundTagAt(i); NBTTagList list = nbttagcompound.getTagList("Values", 10); - for(int j = 0; j < list.tagCount(); j++) - { + for (int j = 0; j < list.tagCount(); j++) { NBTTagCompound value = list.getCompoundTagAt(j); values.add(value.getString("Value")); } map.put(nbttagcompound.getString("Key"), values); } - return map; - } + return map; + } - public static List getStringList(NBTTagList tagList) { - List list = new ArrayList(); - for (int i = 0; i < tagList.tagCount(); i++) { - NBTTagCompound nbttagcompound = tagList.getCompoundTagAt(i); - String line = nbttagcompound.getString("Line"); - list.add(line); - } - return list; - } + public static List getStringList(NBTTagList tagList) { + List list = new ArrayList(); + for (int i = 0; i < tagList.tagCount(); i++) { + NBTTagCompound nbttagcompound = tagList.getCompoundTagAt(i); + String line = nbttagcompound.getString("Line"); + list.add(line); + } + return list; + } - public static String[] getStringArray(NBTTagList tagList, int size) { - String[] arr = new String[size]; - for (int i = 0; i < tagList.tagCount(); i++) { - NBTTagCompound nbttagcompound = tagList.getCompoundTagAt(i); - String line = nbttagcompound.getString("Value"); - int slot = nbttagcompound.getInteger("Slot"); - arr[slot] = line; - } - return arr; - } + public static String[] getStringArray(NBTTagList tagList, int size) { + String[] arr = new String[size]; + for (int i = 0; i < tagList.tagCount(); i++) { + NBTTagCompound nbttagcompound = tagList.getCompoundTagAt(i); + String line = nbttagcompound.getString("Value"); + int slot = nbttagcompound.getInteger("Slot"); + arr[slot] = line; + } + return arr; + } public static NBTTagList nbtIntegerArraySet(List set) { NBTTagList nbttaglist = new NBTTagList(); - if(set == null) - return nbttaglist; - for(int[] arr : set) - { + if (set == null) + return nbttaglist; + for (int[] arr : set) { NBTTagCompound nbttagcompound = new NBTTagCompound(); nbttagcompound.setIntArray("Array", arr); nbttaglist.appendTag(nbttagcompound); } return nbttaglist; - } + } - public static NBTTagList nbtItemStackList(HashMapinventory) { + public static NBTTagList nbtItemStackList(HashMap inventory) { NBTTagList nbttaglist = new NBTTagList(); - if(inventory == null) - return nbttaglist; - for(int slot : inventory.keySet()) - { - ItemStack item = inventory.get(slot); - if(item == null) - continue; + if (inventory == null) + return nbttaglist; + for (int slot : inventory.keySet()) { + ItemStack item = inventory.get(slot); + if (item == null) + continue; NBTTagCompound nbttagcompound = new NBTTagCompound(); - nbttagcompound.setByte("Slot", (byte)slot); + nbttagcompound.setByte("Slot", (byte) slot); - NoppesUtilServer.writeItem(item, nbttagcompound); + NoppesUtilServer.writeItem(item, nbttagcompound); nbttaglist.appendTag(nbttagcompound); } return nbttaglist; - } + } public static NBTTagList nbtItemStackArray(ItemStack[] inventory) { NBTTagList nbttaglist = new NBTTagList(); - if(inventory == null) - return nbttaglist; - for(int slot = 0 ; slot < inventory.length; slot++) - { - ItemStack item = inventory[slot]; + if (inventory == null) + return nbttaglist; + for (int slot = 0; slot < inventory.length; slot++) { + ItemStack item = inventory[slot]; NBTTagCompound nbttagcompound = new NBTTagCompound(); - nbttagcompound.setByte("Slot", (byte)slot); + nbttagcompound.setByte("Slot", (byte) slot); - if(item != null) - NoppesUtilServer.writeItem(item, nbttagcompound); + if (item != null) + NoppesUtilServer.writeItem(item, nbttagcompound); nbttaglist.appendTag(nbttagcompound); } return nbttaglist; - } + } - public static NBTTagList nbtBooleanList(HashMap updatedSlots) { + public static NBTTagList nbtBooleanList(HashMap updatedSlots) { NBTTagList nbttaglist = new NBTTagList(); - if(updatedSlots == null) - return nbttaglist; - HashMap inventory2 = updatedSlots; - for(Integer slot : inventory2.keySet()) - { + if (updatedSlots == null) + return nbttaglist; + HashMap inventory2 = updatedSlots; + for (Integer slot : inventory2.keySet()) { NBTTagCompound nbttagcompound = new NBTTagCompound(); nbttagcompound.setInteger("Slot", slot); nbttagcompound.setBoolean("Boolean", inventory2.get(slot)); @@ -342,24 +319,24 @@ public class NBTTags { nbttaglist.appendTag(nbttagcompound); } return nbttaglist; - } + } - public static NBTTagList nbtIntegerIntegerMap(Map lines) { - NBTTagList nbttaglist = new NBTTagList(); - if(lines == null) - return nbttaglist; - for (int slot : lines.keySet()) { - NBTTagCompound nbttagcompound = new NBTTagCompound(); + public static NBTTagList nbtIntegerIntegerMap(Map lines) { + NBTTagList nbttaglist = new NBTTagList(); + if (lines == null) + return nbttaglist; + for (int slot : lines.keySet()) { + NBTTagCompound nbttagcompound = new NBTTagCompound(); nbttagcompound.setInteger("Slot", slot); nbttagcompound.setInteger("Integer", lines.get(slot)); - nbttaglist.appendTag(nbttagcompound); - } - return nbttaglist; - } + nbttaglist.appendTag(nbttagcompound); + } + return nbttaglist; + } public static NBTTagList nbtIntegerFloatMap(Map lines) { NBTTagList nbttaglist = new NBTTagList(); - if(lines == null) + if (lines == null) return nbttaglist; for (int slot : lines.keySet()) { NBTTagCompound nbttagcompound = new NBTTagCompound(); @@ -370,57 +347,56 @@ public class NBTTags { return nbttaglist; } - public static NBTTagList nbtIntegerDoubleMap(Map lines) { - NBTTagList nbttaglist = new NBTTagList(); - if(lines == null) - return nbttaglist; - for (int slot : lines.keySet()) { - NBTTagCompound nbttagcompound = new NBTTagCompound(); - nbttagcompound.setInteger("Slot", slot); - nbttagcompound.setDouble("Double", lines.get(slot)); - nbttaglist.appendTag(nbttagcompound); - } - return nbttaglist; - } + public static NBTTagList nbtIntegerDoubleMap(Map lines) { + NBTTagList nbttaglist = new NBTTagList(); + if (lines == null) + return nbttaglist; + for (int slot : lines.keySet()) { + NBTTagCompound nbttagcompound = new NBTTagCompound(); + nbttagcompound.setInteger("Slot", slot); + nbttagcompound.setDouble("Double", lines.get(slot)); + nbttaglist.appendTag(nbttagcompound); + } + return nbttaglist; + } - public static NBTTagList nbtIntegerLongMap(Map lines) { - NBTTagList nbttaglist = new NBTTagList(); - if(lines == null) - return nbttaglist; - for (int slot : lines.keySet()) { - NBTTagCompound nbttagcompound = new NBTTagCompound(); + public static NBTTagList nbtIntegerLongMap(Map lines) { + NBTTagList nbttaglist = new NBTTagList(); + if (lines == null) + return nbttaglist; + for (int slot : lines.keySet()) { + NBTTagCompound nbttagcompound = new NBTTagCompound(); nbttagcompound.setInteger("Slot", slot); nbttagcompound.setLong("Long", lines.get(slot)); - nbttaglist.appendTag(nbttagcompound); - } - return nbttaglist; - } - - public static NBTTagList nbtVectorMap(Map> map) { - NBTTagList list = new NBTTagList(); - if(map == null) - return list; - for(String key : map.keySet()){ - NBTTagCompound compound = new NBTTagCompound(); - compound.setString("Key", key); - NBTTagList values = new NBTTagList(); - for(String value : map.get(key)){ - NBTTagCompound comp = new NBTTagCompound(); - comp.setString("Value", value); - values.appendTag(comp); - } - compound.setTag("Values", values); - list.appendTag(compound); + nbttaglist.appendTag(nbttagcompound); } - return list; - } + return nbttaglist; + } - public static NBTTagList nbtStringStringMap(Map map) { + public static NBTTagList nbtVectorMap(Map> map) { + NBTTagList list = new NBTTagList(); + if (map == null) + return list; + for (String key : map.keySet()) { + NBTTagCompound compound = new NBTTagCompound(); + compound.setString("Key", key); + NBTTagList values = new NBTTagList(); + for (String value : map.get(key)) { + NBTTagCompound comp = new NBTTagCompound(); + comp.setString("Value", value); + values.appendTag(comp); + } + compound.setTag("Values", values); + list.appendTag(compound); + } + return list; + } + + public static NBTTagList nbtStringStringMap(Map map) { NBTTagList nbttaglist = new NBTTagList(); - if(map == null) - return nbttaglist; - for(String slot : map.keySet()) - { + if (map == null) + return nbttaglist; + for (String slot : map.keySet()) { NBTTagCompound nbttagcompound = new NBTTagCompound(); nbttagcompound.setString("Slot", slot); nbttagcompound.setString("Value", map.get(slot)); @@ -428,14 +404,13 @@ public class NBTTags { nbttaglist.appendTag(nbttagcompound); } return nbttaglist; - } + } - public static NBTTagList nbtStringIntegerMap(Map map) { + public static NBTTagList nbtStringIntegerMap(Map map) { NBTTagList nbttaglist = new NBTTagList(); - if(map == null) - return nbttaglist; - for(String slot : map.keySet()) - { + if (map == null) + return nbttaglist; + for (String slot : map.keySet()) { NBTTagCompound nbttagcompound = new NBTTagCompound(); nbttagcompound.setString("Slot", slot); nbttagcompound.setInteger("Value", map.get(slot)); @@ -443,14 +418,13 @@ public class NBTTags { nbttaglist.appendTag(nbttagcompound); } return nbttaglist; - } + } - public static NBTTagList nbtStringIntegerArrayMap(Map map) { - NBTTagList nbttaglist = new NBTTagList(); - if(map == null) - return nbttaglist; - for(String slot : map.keySet()) - { + public static NBTTagList nbtStringIntegerArrayMap(Map map) { + NBTTagList nbttaglist = new NBTTagList(); + if (map == null) + return nbttaglist; + for (String slot : map.keySet()) { NBTTagCompound nbttagcompound = new NBTTagCompound(); nbttagcompound.setString("Slot", slot); nbttagcompound.setIntArray("Value", map.get(slot)); @@ -458,14 +432,13 @@ public class NBTTags { nbttaglist.appendTag(nbttagcompound); } return nbttaglist; - } + } - public static NBTBase nbtIntegerStringMap(HashMap map) { + public static NBTBase nbtIntegerStringMap(HashMap map) { NBTTagList nbttaglist = new NBTTagList(); - if(map == null) - return nbttaglist; - for(int slot : map.keySet()) - { + if (map == null) + return nbttaglist; + for (int slot : map.keySet()) { NBTTagCompound nbttagcompound = new NBTTagCompound(); nbttagcompound.setInteger("Slot", slot); nbttagcompound.setString("Value", map.get(slot)); @@ -473,40 +446,39 @@ public class NBTTags { nbttaglist.appendTag(nbttagcompound); } return nbttaglist; - } + } - public static NBTTagList nbtStringArray(String[] list) { + public static NBTTagList nbtStringArray(String[] list) { NBTTagList nbttaglist = new NBTTagList(); - if(list == null) - return nbttaglist; - for(int i = 0; i < list.length; i++){ - if(list[i] == null) - continue; - NBTTagCompound nbttagcompound = new NBTTagCompound(); - nbttagcompound.setString("Value", list[i]); - nbttagcompound.setInteger("Slot", i); - nbttaglist.appendTag(nbttagcompound); + if (list == null) + return nbttaglist; + for (int i = 0; i < list.length; i++) { + if (list[i] == null) + continue; + NBTTagCompound nbttagcompound = new NBTTagCompound(); + nbttagcompound.setString("Value", list[i]); + nbttagcompound.setInteger("Slot", i); + nbttaglist.appendTag(nbttagcompound); } return nbttaglist; - } + } - public static NBTTagList nbtStringList(List list) { - NBTTagList nbttaglist = new NBTTagList(); - for (String s : list) { - NBTTagCompound nbttagcompound = new NBTTagCompound(); - nbttagcompound.setString("Line", s); - nbttaglist.appendTag(nbttagcompound); - } - return nbttaglist; - } + public static NBTTagList nbtStringList(List list) { + NBTTagList nbttaglist = new NBTTagList(); + for (String s : list) { + NBTTagCompound nbttagcompound = new NBTTagCompound(); + nbttagcompound.setString("Line", s); + nbttaglist.appendTag(nbttagcompound); + } + return nbttaglist; + } - public static NBTTagList nbtDoubleList(double ... par1ArrayOfDouble){ + public static NBTTagList nbtDoubleList(double... par1ArrayOfDouble) { NBTTagList nbttaglist = new NBTTagList(); double[] adouble = par1ArrayOfDouble; int i = par1ArrayOfDouble.length; - for (int j = 0; j < i; ++j) - { + for (int j = 0; j < i; ++j) { double d1 = adouble[j]; nbttaglist.appendTag(new NBTTagDouble(d1)); } @@ -514,97 +486,94 @@ public class NBTTags { return nbttaglist; } - public static NBTTagCompound NBTMerge(NBTTagCompound data, NBTTagCompound merge) { - NBTTagCompound compound = (NBTTagCompound) data.copy(); - Set names = merge.func_150296_c(); - for(String name : names){ - NBTBase base = merge.getTag(name); - if(base.getId() == 10) - base = NBTMerge(compound.getCompoundTag(name), (NBTTagCompound) base); - compound.setTag(name, base); - } - return compound; - } + public static NBTTagCompound NBTMerge(NBTTagCompound data, NBTTagCompound merge) { + NBTTagCompound compound = (NBTTagCompound) data.copy(); + Set names = merge.func_150296_c(); + for (String name : names) { + NBTBase base = merge.getTag(name); + if (base.getId() == 10) + base = NBTMerge(compound.getCompoundTag(name), (NBTTagCompound) base); + compound.setTag(name, base); + } + return compound; + } - public static TreeMap GetLongStringMap(NBTTagList tagList) { - TreeMap list = new TreeMap(); + public static TreeMap GetLongStringMap(NBTTagList tagList) { + TreeMap list = new TreeMap(); - for(int i = 0; i < tagList.tagCount(); ++i) { - NBTTagCompound nbttagcompound = tagList.getCompoundTagAt(i); - list.put(Long.valueOf(nbttagcompound.getLong("Long")), nbttagcompound.getString("String")); - } + for (int i = 0; i < tagList.tagCount(); ++i) { + NBTTagCompound nbttagcompound = tagList.getCompoundTagAt(i); + list.put(Long.valueOf(nbttagcompound.getLong("Long")), nbttagcompound.getString("String")); + } - return list; - } + return list; + } - public static NBTTagList NBTLongStringMap(Map map) { - NBTTagList nbttaglist = new NBTTagList(); - if(map == null) { - return nbttaglist; - } else { - Iterator var2 = map.keySet().iterator(); + public static NBTTagList NBTLongStringMap(Map map) { + NBTTagList nbttaglist = new NBTTagList(); + if (map == null) { + return nbttaglist; + } else { + Iterator var2 = map.keySet().iterator(); - while(var2.hasNext()) { - long slot = ((Long)var2.next()).longValue(); - NBTTagCompound nbttagcompound = new NBTTagCompound(); - nbttagcompound.setLong("Long", slot); - nbttagcompound.setString("String", (String) map.get(Long.valueOf(slot))); - nbttaglist.appendTag(nbttagcompound); - } + while (var2.hasNext()) { + long slot = ((Long) var2.next()).longValue(); + NBTTagCompound nbttagcompound = new NBTTagCompound(); + nbttagcompound.setLong("Long", slot); + nbttagcompound.setString("String", (String) map.get(Long.valueOf(slot))); + nbttaglist.appendTag(nbttagcompound); + } - return nbttaglist; - } - } + return nbttaglist; + } + } - public static List GetScriptOld(NBTTagList list, IScriptHandler handler) { - ArrayList scripts = new ArrayList(); + public static List GetScriptOld(NBTTagList list, IScriptHandler handler) { + ArrayList scripts = new ArrayList(); - for(int i = 0; i < list.tagCount(); ++i) { - NBTTagCompound compoundd = list.getCompoundTagAt(i); - ScriptContainer script = new ScriptContainer(handler); - script.readFromNBT(compoundd); - scripts.add(script); - } + for (int i = 0; i < list.tagCount(); ++i) { + NBTTagCompound compoundd = list.getCompoundTagAt(i); + ScriptContainer script = new ScriptContainer(handler); + script.readFromNBT(compoundd); + scripts.add(script); + } - return scripts; - } + return scripts; + } - public static List GetScript(NBTTagCompound compound, IScriptHandler handler) { - ArrayList scripts = new ArrayList<>(); + public static List GetScript(NBTTagCompound compound, IScriptHandler handler) { + ArrayList scripts = new ArrayList<>(); - for(int i = 0; i < compound.getInteger("TotalScripts"); ++i) { - NBTTagCompound containerCompound = compound.getCompoundTag("Tab"+i); - ScriptContainer script = new ScriptContainer(handler); - script.readFromNBT(containerCompound); - scripts.add(script); - } + for (int i = 0; i < compound.getInteger("TotalScripts"); ++i) { + NBTTagCompound containerCompound = compound.getCompoundTag("Tab" + i); + ScriptContainer script = new ScriptContainer(handler); + script.readFromNBT(containerCompound); + scripts.add(script); + } - return scripts; - } + return scripts; + } - public static NBTTagList NBTScript(List scripts) { - NBTTagList list = new NBTTagList(); - Iterator var2 = scripts.iterator(); + public static NBTTagList NBTScript(List scripts) { + NBTTagList list = new NBTTagList(); + Iterator var2 = scripts.iterator(); - while(var2.hasNext()) { - ScriptContainer script = (ScriptContainer)var2.next(); - NBTTagCompound compound = new NBTTagCompound(); - script.writeToNBT(compound); - list.appendTag(compound); - } + while (var2.hasNext()) { + ScriptContainer script = (ScriptContainer) var2.next(); + NBTTagCompound compound = new NBTTagCompound(); + script.writeToNBT(compound); + list.appendTag(compound); + } - return list; - } + return list; + } - public static int getIntAt(NBTTagList tagList, int index) - { - if (index >= 0 && index < tagList.tagCount()) - { + public static int getIntAt(NBTTagList tagList, int index) { + if (index >= 0 && index < tagList.tagCount()) { NBTBase nbtbase = tagList.getCompoundTagAt(index); - if (nbtbase.getId() == 3) - { - return ((NBTTagInt)nbtbase).func_150287_d(); + if (nbtbase.getId() == 3) { + return ((NBTTagInt) nbtbase).func_150287_d(); } } diff --git a/src/main/java/noppes/npcs/NPCLogLevel.java b/src/main/java/noppes/npcs/NPCLogLevel.java index c5c0ee159..c4e52fa40 100644 --- a/src/main/java/noppes/npcs/NPCLogLevel.java +++ b/src/main/java/noppes/npcs/NPCLogLevel.java @@ -3,9 +3,9 @@ package noppes.npcs; import java.util.logging.Level; class NPCLogLevel extends Level { - public static final Level CNPCLog = new NPCLogLevel("CNPC", 0); + public static final Level CNPCLog = new NPCLogLevel("CNPC", 0); - public NPCLogLevel(String name, int value) { - super(name, value); - } -} \ No newline at end of file + public NPCLogLevel(String name, int value) { + super(name, value); + } +} diff --git a/src/main/java/noppes/npcs/NPCSpawning.java b/src/main/java/noppes/npcs/NPCSpawning.java index aa7eff574..28b8c320c 100644 --- a/src/main/java/noppes/npcs/NPCSpawning.java +++ b/src/main/java/noppes/npcs/NPCSpawning.java @@ -29,40 +29,40 @@ import noppes.npcs.scripted.event.CustomNPCsEvent; import java.util.*; public class NPCSpawning { - private static Set eligibleChunksForSpawning = Sets.newHashSet(); + private static Set eligibleChunksForSpawning = Sets.newHashSet(); private static boolean animalSpawn; private static boolean monsterSpawn; private static boolean airSpawn; private static boolean liquidSpawn; - public static void findChunksForSpawning(WorldServer world){ - if(SpawnController.Instance.data.isEmpty() || world.getWorldInfo().getWorldTotalTime() % 400L != 0L) - return; - eligibleChunksForSpawning.clear(); - for (int i = 0; i < world.playerEntities.size(); ++i){ - EntityPlayer entityplayer = (EntityPlayer)world.playerEntities.get(i); + public static void findChunksForSpawning(WorldServer world) { + if (SpawnController.Instance.data.isEmpty() || world.getWorldInfo().getWorldTotalTime() % 400L != 0L) + return; + eligibleChunksForSpawning.clear(); + for (int i = 0; i < world.playerEntities.size(); ++i) { + EntityPlayer entityplayer = (EntityPlayer) world.playerEntities.get(i); int j = MathHelper.floor_double(entityplayer.posX / 16.0D); int k = MathHelper.floor_double(entityplayer.posZ / 16.0D); byte size = 7; - for (int x = -size; x <= size; ++x){ - for (int z = -size; z <= size; ++z){ + for (int x = -size; x <= size; ++x) { + for (int z = -size; z <= size; ++z) { ChunkCoordIntPair chunkcoordintpair = new ChunkCoordIntPair(x + j, z + k); - if (!eligibleChunksForSpawning.contains(chunkcoordintpair)){ + if (!eligibleChunksForSpawning.contains(chunkcoordintpair)) { eligibleChunksForSpawning.add(chunkcoordintpair); } } } } - if (countNPCs(world) > eligibleChunksForSpawning.size()){ - return; + if (countNPCs(world) > eligibleChunksForSpawning.size()) { + return; } ArrayList tmp = new ArrayList(eligibleChunksForSpawning); Collections.shuffle(tmp); Iterator iterator = tmp.iterator(); - while (iterator.hasNext()){ + while (iterator.hasNext()) { ChunkCoordIntPair chunkcoordintpair1 = iterator.next(); ChunkPosition chunkposition = getChunk(world, chunkcoordintpair1.chunkXPos, chunkcoordintpair1.chunkZPos); @@ -70,7 +70,7 @@ public class NPCSpawning { int y = chunkposition.chunkPosY; int l1 = chunkposition.chunkPosZ; - for(int i = 0; i < 3; i++){ + for (int i = 0; i < 3; i++) { int x = j1; int z = l1; byte b1 = 6; @@ -78,28 +78,28 @@ public class NPCSpawning { x += world.rand.nextInt(b1) - world.rand.nextInt(b1); z += world.rand.nextInt(b1) - world.rand.nextInt(b1); - String name = world.getBiomeGenForCoords(x, z).biomeName; - SpawnData data = SpawnController.Instance.getRandomSpawnData(name, world.provider.dimensionId); + String name = world.getBiomeGenForCoords(x, z).biomeName; + SpawnData data = SpawnController.Instance.getRandomSpawnData(name, world.provider.dimensionId); if (data == null || !canCreatureTypeSpawnAtLocation(data, world, x, y, z) || world.getClosestPlayer(x, y, z, 24.0D) != null) - continue; + continue; spawnData(data, world, x, y, z); } } } - public static int countNPCs(World world){ + public static int countNPCs(World world) { int count = 0; List list = world.loadedEntityList; - for (Entity entity : list){ - if (entity instanceof EntityNPCInterface){ + for (Entity entity : list) { + if (entity instanceof EntityNPCInterface) { count++; } } return count; } - protected static ChunkPosition getChunk(World world, int x, int z){ + protected static ChunkPosition getChunk(World world, int x, int z) { Chunk chunk = world.getChunkFromChunkCoords(x, z); int k = x * 16 + world.rand.nextInt(16); int l = z * 16 + world.rand.nextInt(16); @@ -107,21 +107,21 @@ public class NPCSpawning { return new ChunkPosition(k, i1, l); } - public static void performWorldGenSpawning(World world, int x, int z, Random rand){ + public static void performWorldGenSpawning(World world, int x, int z, Random rand) { BiomeGenBase biome = world.getBiomeGenForCoords(x + 8, z + 8); - while (rand.nextFloat() < biome.getSpawningChance()){ - SpawnData data = SpawnController.Instance.getRandomSpawnData(biome.biomeName, world.provider.dimensionId); - if(data == null) - continue; + while (rand.nextFloat() < biome.getSpawningChance()) { + SpawnData data = SpawnController.Instance.getRandomSpawnData(biome.biomeName, world.provider.dimensionId); + if (data == null) + continue; - int size = 16; + int size = 16; int j1 = x + rand.nextInt(size); int k1 = z + rand.nextInt(size); int l1 = j1; int i2 = k1; - for (int k2 = 0; k2 < 4; ++k2){ + for (int k2 = 0; k2 < 4; ++k2) { int l2 = world.getTopSolidOrLiquidBlock(j1, k1); if (l2 > data.spawnHeightMax || l2 < data.spawnHeightMin) { continue; @@ -129,31 +129,29 @@ public class NPCSpawning { l2 = l2 + (int) ((data.spawnHeightMax - l2) * Math.random()); } - if (!canCreatureTypeSpawnAtLocation(data, world, j1, l2, k1)){ + if (!canCreatureTypeSpawnAtLocation(data, world, j1, l2, k1)) { j1 += rand.nextInt(5) - rand.nextInt(5); - for (k1 += rand.nextInt(5) - rand.nextInt(5); j1 < x || j1 >= x + size || k1 < z || k1 >= z + size; k1 = i2 + rand.nextInt(5) - rand.nextInt(5)) - { + for (k1 += rand.nextInt(5) - rand.nextInt(5); j1 < x || j1 >= x + size || k1 < z || k1 >= z + size; k1 = i2 + rand.nextInt(5) - rand.nextInt(5)) { j1 = l1 + rand.nextInt(5) - rand.nextInt(5); } - } - else if(spawnData(data, world, j1, l2, k1)) - break; + } else if (spawnData(data, world, j1, l2, k1)) + break; } } } - private static boolean spawnData(SpawnData data, World world, int x, int y, int z){ + private static boolean spawnData(SpawnData data, World world, int x, int y, int z) { EntityLiving entityliving; - try{ + try { NBTTagCompound[] allCompoundList = data.spawnCompounds.values().toArray(new NBTTagCompound[0]); ArrayList entities = new ArrayList<>(); for (NBTTagCompound compound : allCompoundList) { Entity entity; try { - Class oclass = (Class)EntityList.stringToClassMapping.get(compound.getString("id")); + Class oclass = (Class) EntityList.stringToClassMapping.get(compound.getString("id")); if (oclass == null) { continue; } @@ -170,43 +168,42 @@ public class NPCSpawning { return false; } - Entity spawnEntity = entities.get((int)Math.floor(Math.random()*entities.size())); + Entity spawnEntity = entities.get((int) Math.floor(Math.random() * entities.size())); - if (!(spawnEntity instanceof EntityLiving)) { + if (!(spawnEntity instanceof EntityLiving)) { return false; } - entityliving = (EntityLiving) spawnEntity; + entityliving = (EntityLiving) spawnEntity; - if(spawnEntity instanceof EntityCustomNpc){ - EntityCustomNpc npc = (EntityCustomNpc) spawnEntity; - npc.stats.spawnCycle = 3; - npc.ais.returnToStart = false; - npc.ais.startPos = new int[]{x,y, z}; + if (spawnEntity instanceof EntityCustomNpc) { + EntityCustomNpc npc = (EntityCustomNpc) spawnEntity; + npc.stats.spawnCycle = 3; + npc.ais.returnToStart = false; + npc.ais.startPos = new int[]{x, y, z}; npc.updateAI = true; npc.updateClient = true; npc.getNavigator().clearPathEntity(); - } - spawnEntity.setLocationAndAngles(x + 0.5, y, z + 0.5, world.rand.nextFloat() * 360.0F, 0.0F); - } - catch (Exception exception){ + } + spawnEntity.setLocationAndAngles(x + 0.5, y, z + 0.5, world.rand.nextFloat() * 360.0F, 0.0F); + } catch (Exception exception) { exception.printStackTrace(); return false; } Result canSpawn = ForgeEventFactory.canEntitySpawn(entityliving, world, x + 0.5f, y, z + 0.5f); - if (canSpawn == Result.DENY || (canSpawn == Result.DEFAULT && !canEntitySpawn(data,entityliving))) - return false; + if (canSpawn == Result.DENY || (canSpawn == Result.DEFAULT && !canEntitySpawn(data, entityliving))) + return false; - CustomNPCsEvent.CNPCNaturalSpawnEvent event = new CustomNPCsEvent.CNPCNaturalSpawnEvent(entityliving, data, NpcAPI.Instance().getIPos(new BlockPos(x,y,z)), NPCSpawning.animalSpawn, NPCSpawning.monsterSpawn, NPCSpawning.liquidSpawn, NPCSpawning.airSpawn); + CustomNPCsEvent.CNPCNaturalSpawnEvent event = new CustomNPCsEvent.CNPCNaturalSpawnEvent(entityliving, data, NpcAPI.Instance().getIPos(new BlockPos(x, y, z)), NPCSpawning.animalSpawn, NPCSpawning.monsterSpawn, NPCSpawning.liquidSpawn, NPCSpawning.airSpawn); if (EventHooks.onCNPCNaturalSpawn(event)) { return false; } - entityliving.setPosition(event.attemptPosition.getX(),event.attemptPosition.getY(),event.attemptPosition.getZ()); + entityliving.setPosition(event.attemptPosition.getX(), event.attemptPosition.getY(), event.attemptPosition.getZ()); world.spawnEntityInWorld(entityliving); - return true; + return true; } public static boolean canEntitySpawn(SpawnData data, EntityLiving entityLiving) { @@ -217,7 +214,7 @@ public class NPCSpawning { } } - public static boolean canCreatureTypeSpawnAtLocation(SpawnData data, World world, int x, int y, int z){ + public static boolean canCreatureTypeSpawnAtLocation(SpawnData data, World world, int x, int y, int z) { Block block = world.getBlock(x, y - 1, z); boolean hasSolidSurface = World.doesBlockHaveSolidTopSurface(world, x, y - 1, z); diff --git a/src/main/java/noppes/npcs/NoppesStringUtils.java b/src/main/java/noppes/npcs/NoppesStringUtils.java index 6dbf26b53..f0e2a76f9 100644 --- a/src/main/java/noppes/npcs/NoppesStringUtils.java +++ b/src/main/java/noppes/npcs/NoppesStringUtils.java @@ -11,72 +11,73 @@ import java.util.Arrays; public class NoppesStringUtils { - final static int[] illegalChars = {34, 60, 62, 124, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 58, 42, 63, 92, 47}; - static { - Arrays.sort(illegalChars); - } - public static String cleanFileName(String badFileName) { - StringBuilder cleanName = new StringBuilder(); - for (int i = 0; i < badFileName.length(); i++) { - int c = (int)badFileName.charAt(i); - if (Arrays.binarySearch(illegalChars, c) < 0) { - cleanName.append((char)c); - } - } - return cleanName.toString(); - } - - public static String formatText(String text, Object... obs) { - for(Object ob : obs){ - if(ob instanceof EntityPlayer){ - String username = ((EntityPlayer)ob).getDisplayName(); - text = text.replace("{player}", username); - text = text.replace("@p", username); - } - else if(ob instanceof EntityNPCInterface) - text = text.replace("@npc", ((EntityNPCInterface)ob).getCommandSenderName()); - - } - text = text.replace("&", Character.toChars(167)[0] + ""); - text = text.replace("%","%%"); - return text; - } + final static int[] illegalChars = {34, 60, 62, 124, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 58, 42, 63, 92, 47}; - public static void setClipboardContents(String aString) { - StringSelection stringSelection = new StringSelection(aString); - Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); - clipboard.setContents(stringSelection, new ClipboardOwner() { - @Override - public void lostOwnership(Clipboard arg0, Transferable arg1) { + static { + Arrays.sort(illegalChars); + } - } - }); - } + public static String cleanFileName(String badFileName) { + StringBuilder cleanName = new StringBuilder(); + for (int i = 0; i < badFileName.length(); i++) { + int c = (int) badFileName.charAt(i); + if (Arrays.binarySearch(illegalChars, c) < 0) { + cleanName.append((char) c); + } + } + return cleanName.toString(); + } - public static String getClipboardContents() { - String result = ""; - Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); - Transferable contents = clipboard.getContents(null); - boolean hasTransferableText = contents != null && contents.isDataFlavorSupported(DataFlavor.stringFlavor); - if (hasTransferableText) { - try { - result = (String) contents.getTransferData(DataFlavor.stringFlavor); - } catch (UnsupportedFlavorException ex) { - System.err.println(ex); - ex.printStackTrace(); - } catch (IOException ex) { - System.err.println(ex); - ex.printStackTrace(); - } - } - return result; - } + public static String formatText(String text, Object... obs) { + for (Object ob : obs) { + if (ob instanceof EntityPlayer) { + String username = ((EntityPlayer) ob).getDisplayName(); + text = text.replace("{player}", username); + text = text.replace("@p", username); + } else if (ob instanceof EntityNPCInterface) + text = text.replace("@npc", ((EntityNPCInterface) ob).getCommandSenderName()); - public static String translate(Object... arr) { - String s = ""; - for(Object str : arr){ - s += StatCollector.translateToLocal(str.toString()); - } - return s; - } + } + text = text.replace("&", Character.toChars(167)[0] + ""); + text = text.replace("%", "%%"); + return text; + } + + public static void setClipboardContents(String aString) { + StringSelection stringSelection = new StringSelection(aString); + Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); + clipboard.setContents(stringSelection, new ClipboardOwner() { + @Override + public void lostOwnership(Clipboard arg0, Transferable arg1) { + + } + }); + } + + public static String getClipboardContents() { + String result = ""; + Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); + Transferable contents = clipboard.getContents(null); + boolean hasTransferableText = contents != null && contents.isDataFlavorSupported(DataFlavor.stringFlavor); + if (hasTransferableText) { + try { + result = (String) contents.getTransferData(DataFlavor.stringFlavor); + } catch (UnsupportedFlavorException ex) { + System.err.println(ex); + ex.printStackTrace(); + } catch (IOException ex) { + System.err.println(ex); + ex.printStackTrace(); + } + } + return result; + } + + public static String translate(Object... arr) { + String s = ""; + for (Object str : arr) { + s += StatCollector.translateToLocal(str.toString()); + } + return s; + } } diff --git a/src/main/java/noppes/npcs/NoppesUtilPlayer.java b/src/main/java/noppes/npcs/NoppesUtilPlayer.java index 26b5f5f73..b39b759ca 100644 --- a/src/main/java/noppes/npcs/NoppesUtilPlayer.java +++ b/src/main/java/noppes/npcs/NoppesUtilPlayer.java @@ -43,278 +43,277 @@ import java.util.*; public class NoppesUtilPlayer { - public static void changeFollowerState(EntityPlayerMP player, EntityNPCInterface npc) { - if(npc.advanced.role != EnumRoleType.Follower) - return; + public static void changeFollowerState(EntityPlayerMP player, EntityNPCInterface npc) { + if (npc.advanced.role != EnumRoleType.Follower) + return; - RoleFollower role = (RoleFollower) npc.roleInterface; - EntityPlayer owner = role.owner; - if(owner == null || !owner.getCommandSenderName().equals(player.getCommandSenderName())) - return; + RoleFollower role = (RoleFollower) npc.roleInterface; + EntityPlayer owner = role.owner; + if (owner == null || !owner.getCommandSenderName().equals(player.getCommandSenderName())) + return; - role.isFollowing = !role.isFollowing; - } - public static void hireFollower(EntityPlayerMP player, EntityNPCInterface npc) { - if(npc.advanced.role != EnumRoleType.Follower) - return; - Container con = player.openContainer; - if(con == null || !(con instanceof ContainerNPCFollowerHire)) - return; + role.isFollowing = !role.isFollowing; + } - ContainerNPCFollowerHire container = (ContainerNPCFollowerHire) con; - RoleFollower role = (RoleFollower) npc.roleInterface; - followerBuy(role, container.currencyMatrix, player, npc); - } - public static void extendFollower(EntityPlayerMP player, EntityNPCInterface npc) { - if(npc.advanced.role != EnumRoleType.Follower) - return; - Container con = player.openContainer; - if(con == null || !(con instanceof ContainerNPCFollower)) - return; + public static void hireFollower(EntityPlayerMP player, EntityNPCInterface npc) { + if (npc.advanced.role != EnumRoleType.Follower) + return; + Container con = player.openContainer; + if (con == null || !(con instanceof ContainerNPCFollowerHire)) + return; - ContainerNPCFollower container = (ContainerNPCFollower) con; - RoleFollower role = (RoleFollower) npc.roleInterface; - followerBuy(role, container.currencyMatrix, player, npc); - } - public static void transport(EntityPlayerMP player, EntityNPCInterface npc, String location){ - TransportLocation loc = TransportController.getInstance().getTransport(location); + ContainerNPCFollowerHire container = (ContainerNPCFollowerHire) con; + RoleFollower role = (RoleFollower) npc.roleInterface; + followerBuy(role, container.currencyMatrix, player, npc); + } + + public static void extendFollower(EntityPlayerMP player, EntityNPCInterface npc) { + if (npc.advanced.role != EnumRoleType.Follower) + return; + Container con = player.openContainer; + if (con == null || !(con instanceof ContainerNPCFollower)) + return; + + ContainerNPCFollower container = (ContainerNPCFollower) con; + RoleFollower role = (RoleFollower) npc.roleInterface; + followerBuy(role, container.currencyMatrix, player, npc); + } + + public static void transport(EntityPlayerMP player, EntityNPCInterface npc, String location) { + TransportLocation loc = TransportController.getInstance().getTransport(location); PlayerTransportData playerdata = PlayerDataController.Instance.getPlayerData(player).transportData; - if(loc == null || !loc.isDefault() && !playerdata.transports.contains(loc.id)) - return; + if (loc == null || !loc.isDefault() && !playerdata.transports.contains(loc.id)) + return; - teleportPlayer(player, loc.posX, loc.posY, loc.posZ, loc.dimension); - } + teleportPlayer(player, loc.posX, loc.posY, loc.posZ, loc.dimension); + } - public static void teleportPlayer(EntityPlayerMP player, double posX, double posY, double posZ, int dimension){ - if(player.dimension != dimension){ - int dim = player.dimension; - MinecraftServer server = MinecraftServer.getServer(); + public static void teleportPlayer(EntityPlayerMP player, double posX, double posY, double posZ, int dimension) { + if (player.dimension != dimension) { + int dim = player.dimension; + MinecraftServer server = MinecraftServer.getServer(); WorldServer wor = server.worldServerForDimension(dimension); - if(wor == null){ - player.addChatMessage(new ChatComponentText("Broken transporter. Dimension does not exist")); - return; + if (wor == null) { + player.addChatMessage(new ChatComponentText("Broken transporter. Dimension does not exist")); + return; } player.setLocationAndAngles(posX, posY, posZ, player.rotationYaw, player.rotationPitch); server.getConfigurationManager().transferPlayerToDimension(player, dimension, new CustomTeleporter(wor)); - player.playerNetServerHandler.setPlayerLocation(posX, posY, posZ, player.rotationYaw, player.rotationPitch); + player.playerNetServerHandler.setPlayerLocation(posX, posY, posZ, player.rotationYaw, player.rotationPitch); - if(!wor.playerEntities.contains(player)) + if (!wor.playerEntities.contains(player)) wor.spawnEntityInWorld(player); - } - else{ - player.playerNetServerHandler.setPlayerLocation(posX, posY, posZ, player.rotationYaw, player.rotationPitch); - } + } else { + player.playerNetServerHandler.setPlayerLocation(posX, posY, posZ, player.rotationYaw, player.rotationPitch); + } player.worldObj.updateEntityWithOptionalForce(player, false); - } + } - public static void teleportPlayer(EntityPlayerMP player, double posX, double posY, double posZ, float yaw, float pitch, int dimension){ - if(player.dimension != dimension){ - int dim = player.dimension; - MinecraftServer server = MinecraftServer.getServer(); - WorldServer wor = server.worldServerForDimension(dimension); - if(wor == null){ - player.addChatMessage(new ChatComponentText("Broken transporter. Dimenion does not exist")); - return; - } - player.setLocationAndAngles(posX, posY, posZ, yaw, pitch); - server.getConfigurationManager().transferPlayerToDimension(player, dimension, new CustomTeleporter(wor)); - player.playerNetServerHandler.setPlayerLocation(posX, posY, posZ, yaw, pitch); + public static void teleportPlayer(EntityPlayerMP player, double posX, double posY, double posZ, float yaw, float pitch, int dimension) { + if (player.dimension != dimension) { + int dim = player.dimension; + MinecraftServer server = MinecraftServer.getServer(); + WorldServer wor = server.worldServerForDimension(dimension); + if (wor == null) { + player.addChatMessage(new ChatComponentText("Broken transporter. Dimenion does not exist")); + return; + } + player.setLocationAndAngles(posX, posY, posZ, yaw, pitch); + server.getConfigurationManager().transferPlayerToDimension(player, dimension, new CustomTeleporter(wor)); + player.playerNetServerHandler.setPlayerLocation(posX, posY, posZ, yaw, pitch); - if(!wor.playerEntities.contains(player)) - wor.spawnEntityInWorld(player); - } - else{ - player.playerNetServerHandler.setPlayerLocation(posX, posY, posZ, yaw, pitch); - } - player.worldObj.updateEntityWithOptionalForce(player, false); - } + if (!wor.playerEntities.contains(player)) + wor.spawnEntityInWorld(player); + } else { + player.playerNetServerHandler.setPlayerLocation(posX, posY, posZ, yaw, pitch); + } + player.worldObj.updateEntityWithOptionalForce(player, false); + } - public static void disableMouseInput(EntityPlayerMP player, long time, int... buttonIds) { - StringBuilder stringedIds = new StringBuilder(); - for (int i = 0; i < buttonIds.length; i++) { - stringedIds.append(i); - if (i < buttonIds.length - 1) { - stringedIds.append(";"); - } - } + public static void disableMouseInput(EntityPlayerMP player, long time, int... buttonIds) { + StringBuilder stringedIds = new StringBuilder(); + for (int i = 0; i < buttonIds.length; i++) { + stringedIds.append(i); + if (i < buttonIds.length - 1) { + stringedIds.append(";"); + } + } PacketHandler.Instance.sendToPlayer(new DisableMouseInputPacket(time, stringedIds.toString()), player); - } + } - public static void swingPlayerArm(EntityPlayerMP player){ + public static void swingPlayerArm(EntityPlayerMP player) { PacketHandler.Instance.sendToPlayer(new SwingPlayerArmPacket(), player); - } + } - private static void followerBuy(RoleFollower role,IInventory currencyInv,EntityPlayerMP player, EntityNPCInterface npc){ - ItemStack currency = currencyInv.getStackInSlot(0); - if(currency == null) - return; - HashMap cd = new HashMap(); - for(int i : role.inventory.items.keySet()){ - ItemStack is = role.inventory.items.get(i); - if(is == null || is.getItem() != currency.getItem() || is.getHasSubtypes() && is.getItemDamage() != currency.getItemDamage()) - continue; - int days = 1; - if(role.rates.containsKey(i)) - days = role.rates.get(i); + private static void followerBuy(RoleFollower role, IInventory currencyInv, EntityPlayerMP player, EntityNPCInterface npc) { + ItemStack currency = currencyInv.getStackInSlot(0); + if (currency == null) + return; + HashMap cd = new HashMap(); + for (int i : role.inventory.items.keySet()) { + ItemStack is = role.inventory.items.get(i); + if (is == null || is.getItem() != currency.getItem() || is.getHasSubtypes() && is.getItemDamage() != currency.getItemDamage()) + continue; + int days = 1; + if (role.rates.containsKey(i)) + days = role.rates.get(i); - cd.put(is,days); - } - if(cd.size() == 0) - return; - int stackSize = currency.stackSize; - int days = 0; + cd.put(is, days); + } + if (cd.size() == 0) + return; + int stackSize = currency.stackSize; + int days = 0; - int possibleDays = 0; - int possibleSize = stackSize; - while(true){ - for(ItemStack item : cd.keySet()){ - int rDays = cd.get(item); - int rValue = item.stackSize; - if(rValue > stackSize) - continue; - int newStackSize = stackSize % rValue; - int size = stackSize - newStackSize; - int posDays = (size / rValue) * rDays; - if(possibleDays <= posDays){ - possibleDays = posDays; - possibleSize = newStackSize; - } - } - if(stackSize == possibleSize) - break; - stackSize = possibleSize; - days += possibleDays; - possibleDays = 0; - } - if(days == 0) - return; - if(stackSize <= 0) - currencyInv.setInventorySlotContents(0, null); - else - currency = currency.splitStack(stackSize); + int possibleDays = 0; + int possibleSize = stackSize; + while (true) { + for (ItemStack item : cd.keySet()) { + int rDays = cd.get(item); + int rValue = item.stackSize; + if (rValue > stackSize) + continue; + int newStackSize = stackSize % rValue; + int size = stackSize - newStackSize; + int posDays = (size / rValue) * rDays; + if (possibleDays <= posDays) { + possibleDays = posDays; + possibleSize = newStackSize; + } + } + if (stackSize == possibleSize) + break; + stackSize = possibleSize; + days += possibleDays; + possibleDays = 0; + } + if (days == 0) + return; + if (stackSize <= 0) + currencyInv.setInventorySlotContents(0, null); + else + currency = currency.splitStack(stackSize); - npc.say(player, new Line(NoppesStringUtils.formatText(role.dialogHire.replace("{days}", days+""), player, npc))); - role.setOwner(player); - role.addDays(days); - } + npc.say(player, new Line(NoppesStringUtils.formatText(role.dialogHire.replace("{days}", days + ""), player, npc))); + role.setOwner(player); + role.addDays(days); + } - public static void bankUpgrade(EntityPlayerMP player, EntityNPCInterface npc) { - if(npc.advanced.role != EnumRoleType.Bank) - return; - Container con = player.openContainer; - if(con == null || !(con instanceof ContainerNPCBankInterface)) - return; + public static void bankUpgrade(EntityPlayerMP player, EntityNPCInterface npc) { + if (npc.advanced.role != EnumRoleType.Bank) + return; + Container con = player.openContainer; + if (con == null || !(con instanceof ContainerNPCBankInterface)) + return; - ContainerNPCBankInterface container = (ContainerNPCBankInterface) con; - Bank bank = BankController.getInstance().getBank(container.bankid); - ItemStack item = bank.upgradeInventory.getStackInSlot(container.slot); - if(item == null) - return; + ContainerNPCBankInterface container = (ContainerNPCBankInterface) con; + Bank bank = BankController.getInstance().getBank(container.bankid); + ItemStack item = bank.upgradeInventory.getStackInSlot(container.slot); + if (item == null) + return; - int price = item.stackSize; - ItemStack currency = container.currencyMatrix.getStackInSlot(0); - if(currency == null || price > currency.stackSize) - return; - if(currency.stackSize - price == 0) - container.currencyMatrix.setInventorySlotContents(0, null); - else - currency = currency.splitStack(price); - player.closeContainer(); - PlayerBankData data = PlayerDataController.Instance.getBankData(player,bank.id); + int price = item.stackSize; + ItemStack currency = container.currencyMatrix.getStackInSlot(0); + if (currency == null || price > currency.stackSize) + return; + if (currency.stackSize - price == 0) + container.currencyMatrix.setInventorySlotContents(0, null); + else + currency = currency.splitStack(price); + player.closeContainer(); + PlayerBankData data = PlayerDataController.Instance.getBankData(player, bank.id); BankData bankData = data.getBank(bank.id); - bankData.upgradedSlots.put(container.slot, true); + bankData.upgradedSlots.put(container.slot, true); - bankData.openBankGui(player, npc, bank.id, container.slot); - } - public static void bankUnlock(EntityPlayerMP player, EntityNPCInterface npc) { - if(npc.advanced.role != EnumRoleType.Bank) - return; - Container con = player.openContainer; - if(con == null || !(con instanceof ContainerNPCBankInterface)) - return; - ContainerNPCBankInterface container = (ContainerNPCBankInterface) con; - Bank bank = BankController.getInstance().getBank(container.bankid); + bankData.openBankGui(player, npc, bank.id, container.slot); + } - ItemStack item = bank.currencyInventory.getStackInSlot(container.slot); - if(item == null) - return; + public static void bankUnlock(EntityPlayerMP player, EntityNPCInterface npc) { + if (npc.advanced.role != EnumRoleType.Bank) + return; + Container con = player.openContainer; + if (con == null || !(con instanceof ContainerNPCBankInterface)) + return; + ContainerNPCBankInterface container = (ContainerNPCBankInterface) con; + Bank bank = BankController.getInstance().getBank(container.bankid); - int price = item.stackSize; - ItemStack currency = container.currencyMatrix.getStackInSlot(0); - if(currency == null || price > currency.stackSize) - return; - if(currency.stackSize - price == 0) - container.currencyMatrix.setInventorySlotContents(0, null); - else - currency = currency.splitStack(price); - player.closeContainer(); - PlayerBankData data = PlayerDataController.Instance.getBankData(player,bank.id); + ItemStack item = bank.currencyInventory.getStackInSlot(container.slot); + if (item == null) + return; + + int price = item.stackSize; + ItemStack currency = container.currencyMatrix.getStackInSlot(0); + if (currency == null || price > currency.stackSize) + return; + if (currency.stackSize - price == 0) + container.currencyMatrix.setInventorySlotContents(0, null); + else + currency = currency.splitStack(price); + player.closeContainer(); + PlayerBankData data = PlayerDataController.Instance.getBankData(player, bank.id); BankData bankData = data.getBank(bank.id); - if(bankData.unlockedSlots + 1 <= bank.maxSlots) - bankData.unlockedSlots++; + if (bankData.unlockedSlots + 1 <= bank.maxSlots) + bankData.unlockedSlots++; - bankData.openBankGui(player, npc, bank.id, container.slot); - } + bankData.openBankGui(player, npc, bank.id, container.slot); + } - public static void dialogSelected(int dialogId, int optionId, EntityPlayerMP player, EntityNPCInterface npc) { - Dialog dialog = DialogController.Instance.dialogs.get(dialogId); - if(dialog == null) - return; - DialogOption option = dialog.options.get(optionId); - if (EventHooks.onDialogOption(new DialogEvent.DialogOption((IPlayer) NpcAPI.Instance().getIEntity(player), dialog))) - return; + public static void dialogSelected(int dialogId, int optionId, EntityPlayerMP player, EntityNPCInterface npc) { + Dialog dialog = DialogController.Instance.dialogs.get(dialogId); + if (dialog == null) + return; + DialogOption option = dialog.options.get(optionId); + if (EventHooks.onDialogOption(new DialogEvent.DialogOption((IPlayer) NpcAPI.Instance().getIEntity(player), dialog))) + return; - if (!npc.isRemote()) { - EventHooks.onNPCDialogClosed(npc, player, dialogId, optionId + 1, dialog); + if (!npc.isRemote()) { + EventHooks.onNPCDialogClosed(npc, player, dialogId, optionId + 1, dialog); - if (!dialog.hasDialogs(player) && !dialog.hasOtherOptions()) { - EventHooks.onDialogClosed(new DialogEvent.DialogClosed((IPlayer) NpcAPI.Instance().getIEntity(player), dialog)); - return; - } - if (option == null || option.optionType == EnumOptionType.DialogOption && (!option.isAvailable(player) || !option.hasDialog()) || option.optionType == EnumOptionType.Disabled || option.optionType == EnumOptionType.QuitOption) { - EventHooks.onDialogClosed(new DialogEvent.DialogClosed((IPlayer) NpcAPI.Instance().getIEntity(player), dialog)); - return; - } - } - if(option.optionType == EnumOptionType.RoleOption){ - if(npc.roleInterface != null) - npc.roleInterface.interact(player); - else - GuiClosePacket.closeGUI(player, -1 , new NBTTagCompound()); - } - else if(option.optionType == EnumOptionType.DialogOption){ - NoppesUtilServer.openDialog(player, npc, option.getDialog(), optionId+1); - } - else if(option.optionType == EnumOptionType.CommandBlock){ - GuiClosePacket.closeGUI(player, -1 , new NBTTagCompound()); - NoppesUtilServer.runCommand(player, npc.getCommandSenderName(), option.command); - } - else - GuiClosePacket.closeGUI(player, -1 , new NBTTagCompound()); - } + if (!dialog.hasDialogs(player) && !dialog.hasOtherOptions()) { + EventHooks.onDialogClosed(new DialogEvent.DialogClosed((IPlayer) NpcAPI.Instance().getIEntity(player), dialog)); + return; + } + if (option == null || option.optionType == EnumOptionType.DialogOption && (!option.isAvailable(player) || !option.hasDialog()) || option.optionType == EnumOptionType.Disabled || option.optionType == EnumOptionType.QuitOption) { + EventHooks.onDialogClosed(new DialogEvent.DialogClosed((IPlayer) NpcAPI.Instance().getIEntity(player), dialog)); + return; + } + } + if (option.optionType == EnumOptionType.RoleOption) { + if (npc.roleInterface != null) + npc.roleInterface.interact(player); + else + GuiClosePacket.closeGUI(player, -1, new NBTTagCompound()); + } else if (option.optionType == EnumOptionType.DialogOption) { + NoppesUtilServer.openDialog(player, npc, option.getDialog(), optionId + 1); + } else if (option.optionType == EnumOptionType.CommandBlock) { + GuiClosePacket.closeGUI(player, -1, new NBTTagCompound()); + NoppesUtilServer.runCommand(player, npc.getCommandSenderName(), option.command); + } else + GuiClosePacket.closeGUI(player, -1, new NBTTagCompound()); + } - public static void updateQuestLogData(ByteBuf buffer, EntityPlayerMP player) throws IOException { - PlayerData playerData = PlayerDataController.Instance.getPlayerData(player); + public static void updateQuestLogData(ByteBuf buffer, EntityPlayerMP player) throws IOException { + PlayerData playerData = PlayerDataController.Instance.getPlayerData(player); - NBTTagCompound compound = ByteBufUtils.readNBT(buffer); - HashMap questAlerts = NBTTags.getStringStringMap(compound.getTagList("Alerts", 10)); - for (Map.Entry entry : questAlerts.entrySet()) { - Quest quest = getQuestFromStringKey(entry.getKey()); - if (quest != null) { - playerData.questData.activeQuests.get(quest.id).sendAlerts = Boolean.parseBoolean(entry.getValue()); - } - } + NBTTagCompound compound = ByteBufUtils.readNBT(buffer); + HashMap questAlerts = NBTTags.getStringStringMap(compound.getTagList("Alerts", 10)); + for (Map.Entry entry : questAlerts.entrySet()) { + Quest quest = getQuestFromStringKey(entry.getKey()); + if (quest != null) { + playerData.questData.activeQuests.get(quest.id).sendAlerts = Boolean.parseBoolean(entry.getValue()); + } + } - String trackedQuestString = ByteBufUtils.readString(buffer); - Quest trackedQuest = getQuestFromStringKey(trackedQuestString); - if (trackedQuest != null) { - playerData.questData.trackQuest(trackedQuest); - } else { - playerData.questData.untrackQuest(); - } - } + String trackedQuestString = ByteBufUtils.readString(buffer); + Quest trackedQuest = getQuestFromStringKey(trackedQuestString); + if (trackedQuest != null) { + playerData.questData.trackQuest(trackedQuest); + } else { + playerData.questData.untrackQuest(); + } + } public static void clearTrackQuest(EntityPlayerMP player) throws IOException { PlayerData playerData = PlayerDataController.Instance.getPlayerData(player); @@ -333,9 +332,9 @@ public class NoppesUtilPlayer { } } - private static Quest getQuestFromStringKey(String string) { - if (string != null && string.contains(":")) { - String[] splitString = string.split(":"); + private static Quest getQuestFromStringKey(String string) { + if (string != null && string.contains(":")) { + String[] splitString = string.split(":"); String categoryName; String questName; @@ -349,72 +348,70 @@ public class NoppesUtilPlayer { questName = splitString[1]; } - for (QuestCategory category : QuestController.Instance.categories.values()) { - if (category.title.equals(categoryName)) { - for (Quest quest : category.quests.values()) { - if (quest.title.equals(questName)) { - return quest; - } - } - } - } - } - return null; - } + for (QuestCategory category : QuestController.Instance.categories.values()) { + if (category.title.equals(categoryName)) { + for (Quest quest : category.quests.values()) { + if (quest.title.equals(questName)) { + return quest; + } + } + } + } + } + return null; + } - public static void sendTrackedQuestData(EntityPlayerMP player) { - Quest trackedQuest = (Quest) PlayerDataController.Instance.getPlayerData(player).questData.getTrackedQuest(); - if(trackedQuest != null){ - NBTTagCompound compound = new NBTTagCompound(); - compound.setTag("Quest",trackedQuest.writeToNBT(new NBTTagCompound())); - compound.setString("CategoryName", trackedQuest.getCategory().getName()); - if(trackedQuest.completion == EnumQuestCompletion.Instant){ - compound.setBoolean("Instant", true); - } - else { - compound.setString("TurnInNPC", trackedQuest.getNpcName()); - } - NBTTagList nbtTagList = new NBTTagList(); - for (IQuestObjective objective : trackedQuest.questInterface.getObjectives(player)) { - nbtTagList.appendTag(new NBTTagString(objective.getText())); - } - compound.setTag("ObjectiveList",nbtTagList); + public static void sendTrackedQuestData(EntityPlayerMP player) { + Quest trackedQuest = (Quest) PlayerDataController.Instance.getPlayerData(player).questData.getTrackedQuest(); + if (trackedQuest != null) { + NBTTagCompound compound = new NBTTagCompound(); + compound.setTag("Quest", trackedQuest.writeToNBT(new NBTTagCompound())); + compound.setString("CategoryName", trackedQuest.getCategory().getName()); + if (trackedQuest.completion == EnumQuestCompletion.Instant) { + compound.setBoolean("Instant", true); + } else { + compound.setString("TurnInNPC", trackedQuest.getNpcName()); + } + NBTTagList nbtTagList = new NBTTagList(); + for (IQuestObjective objective : trackedQuest.questInterface.getObjectives(player)) { + nbtTagList.appendTag(new NBTTagString(objective.getText())); + } + compound.setTag("ObjectiveList", nbtTagList); PacketHandler.Instance.sendToPlayer(new OverlayQuestTrackingPacket(compound), player); - } - } + } + } public static void sendPartyTrackedQuestData(EntityPlayerMP player, Party party) { Quest trackedQuest = (Quest) PlayerDataController.Instance.getPlayerData(player).questData.getTrackedQuest(); - if(trackedQuest != null){ + if (trackedQuest != null) { NBTTagCompound compound = new NBTTagCompound(); - compound.setTag("Quest",trackedQuest.writeToNBT(new NBTTagCompound())); + compound.setTag("Quest", trackedQuest.writeToNBT(new NBTTagCompound())); compound.setString("CategoryName", trackedQuest.getCategory().getName()); - if(trackedQuest.completion == EnumQuestCompletion.Instant){ + if (trackedQuest.completion == EnumQuestCompletion.Instant) { compound.setBoolean("Instant", true); - } - else { + } else { compound.setString("TurnInNPC", trackedQuest.getNpcName()); } NBTTagList nbtTagList = new NBTTagList(); for (IQuestObjective objective : trackedQuest.questInterface.getPartyObjectives(party)) { nbtTagList.appendTag(new NBTTagString(objective.getText())); - if(objective.getAdditionalText() != null) + if (objective.getAdditionalText() != null) nbtTagList.appendTag(new NBTTagString(objective.getAdditionalText())); } - compound.setTag("ObjectiveList",nbtTagList); + compound.setTag("ObjectiveList", nbtTagList); PacketHandler.Instance.sendToPlayer(new OverlayQuestTrackingPacket(compound), player); } } - public static void sendQuestLogData(EntityPlayerMP player) { - if(!PlayerQuestController.hasActiveQuests(player)){ - return; + public static void sendQuestLogData(EntityPlayerMP player) { + if (!PlayerQuestController.hasActiveQuests(player)) { + return; } QuestLogData data = new QuestLogData(); data.setData(player); GuiDataPacket.sendGuiData(player, data.writeNBT()); - } + } public static void sendTrackedQuest(EntityPlayerMP player) { QuestLogData data = new QuestLogData(); @@ -423,89 +420,89 @@ public class NoppesUtilPlayer { PartyDataPacket.sendPartyData(player, data.writeTrackedQuest()); } - public static boolean questCompletion(EntityPlayerMP player, int questId) { - if(player == null) - return false; + public static boolean questCompletion(EntityPlayerMP player, int questId) { + if (player == null) + return false; - PlayerData playerData = PlayerDataController.Instance.getPlayerData(player); - PlayerQuestData questData = playerData.questData; - QuestData data = questData.activeQuests.get(questId); + PlayerData playerData = PlayerDataController.Instance.getPlayerData(player); + PlayerQuestData questData = playerData.questData; + QuestData data = questData.activeQuests.get(questId); - if (data == null) - return false; + if (data == null) + return false; - if (!data.quest.questInterface.isCompleted(playerData)) - return false; + if (!data.quest.questInterface.isCompleted(playerData)) + return false; - if (data.quest.completion == EnumQuestCompletion.Instant) { - EventHooks.onQuestFinished(player, data.quest); - } + if (data.quest.completion == EnumQuestCompletion.Instant) { + EventHooks.onQuestFinished(player, data.quest); + } - QuestEvent.QuestTurnedInEvent event = new QuestEvent.QuestTurnedInEvent((IPlayer) NpcAPI.Instance().getIEntity(player), data.quest); + QuestEvent.QuestTurnedInEvent event = new QuestEvent.QuestTurnedInEvent((IPlayer) NpcAPI.Instance().getIEntity(player), data.quest); - event.expReward = data.quest.rewardExp; - List list = new ArrayList(); - Iterator var8 = data.quest.rewardItems.items.values().iterator(); + event.expReward = data.quest.rewardExp; + List list = new ArrayList(); + Iterator var8 = data.quest.rewardItems.items.values().iterator(); - while(var8.hasNext()) { - ItemStack item = (ItemStack)var8.next(); - if (item != null && item.stackSize > 0) { - IItemStack iStack = NpcAPI.Instance().getIItemStack(item); - if (iStack != null){ - list.add(iStack); - } - } - } + while (var8.hasNext()) { + ItemStack item = (ItemStack) var8.next(); + if (item != null && item.stackSize > 0) { + IItemStack iStack = NpcAPI.Instance().getIItemStack(item); + if (iStack != null) { + list.add(iStack); + } + } + } - if (!data.quest.randomReward) { - event.itemRewards = (IItemStack[])list.toArray(new IItemStack[list.size()]); - } else if (!list.isEmpty()) { - event.itemRewards = new IItemStack[]{(IItemStack)list.get(player.getRNG().nextInt(list.size()))}; - } + if (!data.quest.randomReward) { + event.itemRewards = (IItemStack[]) list.toArray(new IItemStack[list.size()]); + } else if (!list.isEmpty()) { + event.itemRewards = new IItemStack[]{(IItemStack) list.get(player.getRNG().nextInt(list.size()))}; + } - EventHooks.onQuestTurnedIn(event); - if (event.isCancelled()) - return false; + EventHooks.onQuestTurnedIn(event); + if (event.isCancelled()) + return false; - IItemStack[] var12 = event.itemRewards; - int var14 = var12.length; - for(int var10 = 0; var10 < var14; ++var10) { - IItemStack item = var12[var10]; - if (item != null) { - NoppesUtilServer.GivePlayerItem(player, player, item.getMCItemStack()); - } - } + IItemStack[] var12 = event.itemRewards; + int var14 = var12.length; + for (int var10 = 0; var10 < var14; ++var10) { + IItemStack item = var12[var10]; + if (item != null) { + NoppesUtilServer.GivePlayerItem(player, player, item.getMCItemStack()); + } + } - data.quest.questInterface.handleComplete(player); - if(data.quest.rewardExp > 0){ - player.worldObj.playSoundAtEntity(player, "random.orb", 0.1F, 0.5F * ((player.worldObj.rand.nextFloat() - player.worldObj.rand.nextFloat()) * 0.7F + 1.8F)); - player.addExperience(data.quest.rewardExp); - } - data.quest.factionOptions.addPoints(player); - if(data.quest.mail.isValid()){ - PlayerDataController.Instance.addPlayerMessage(player.getCommandSenderName(), data.quest.mail); - } + data.quest.questInterface.handleComplete(player); + if (data.quest.rewardExp > 0) { + player.worldObj.playSoundAtEntity(player, "random.orb", 0.1F, 0.5F * ((player.worldObj.rand.nextFloat() - player.worldObj.rand.nextFloat()) * 0.7F + 1.8F)); + player.addExperience(data.quest.rewardExp); + } + data.quest.factionOptions.addPoints(player); + if (data.quest.mail.isValid()) { + PlayerDataController.Instance.addPlayerMessage(player.getCommandSenderName(), data.quest.mail); + } - if(!data.quest.command.isEmpty()){ - NoppesUtilServer.runCommand(player, "QuestCompletion", data.quest.command); - } + if (!data.quest.command.isEmpty()) { + NoppesUtilServer.runCommand(player, "QuestCompletion", data.quest.command); + } - PlayerQuestController.setQuestFinished(data.quest, player); - if (data.quest.hasNewQuest()) { - QuestData nextQuest = new QuestData(data.quest.getNextQuest()); - nextQuest.sendAlerts = data.quest.id != data.quest.getNextQuest().id || data.sendAlerts; - PlayerQuestController.addActiveQuest(nextQuest, player); - questData.trackQuest(nextQuest.quest); - } + PlayerQuestController.setQuestFinished(data.quest, player); + if (data.quest.hasNewQuest()) { + QuestData nextQuest = new QuestData(data.quest.getNextQuest()); + nextQuest.sendAlerts = data.quest.id != data.quest.getNextQuest().id || data.sendAlerts; + PlayerQuestController.addActiveQuest(nextQuest, player); + questData.trackQuest(nextQuest.quest); + } - playerData.save(); + playerData.save(); - return true; - } + return true; + } public static boolean questPartyCompletion(Party party) { - if(party == null) + if (party == null) return false; QuestData data = party.getQuestData(); @@ -517,7 +514,7 @@ public class NoppesUtilPlayer { Quest quest = data.quest; - if(quest == null) + if (quest == null) return false; if (data.quest.completion == EnumQuestCompletion.Instant) @@ -533,13 +530,13 @@ public class NoppesUtilPlayer { EnumPartyExchange complete = partyOptions.completeFor; EnumPartyExchange reward = partyOptions.rewardControl; EnumPartyExchange command = partyOptions.executeCommand; - for(String name : party.getPlayerNames()){ + for (String name : party.getPlayerNames()) { EntityPlayer player = NoppesUtilServer.getPlayerByName(name); - if(player == null) + if (player == null) continue; PlayerData playerData = PlayerDataController.Instance.getPlayerData(player); - if(playerData == null) + if (playerData == null) continue; boolean isLeader = party.getLeaderUUID().equals(player.getUniqueID()); @@ -550,33 +547,33 @@ public class NoppesUtilPlayer { boolean meetsReward = meetsPartyExchange(reward, hasActiveQuest, hasFinishedQuest, isLeader); boolean meetsCommand = meetsPartyExchange(command, hasActiveQuest, hasFinishedQuest, isLeader); - if(meetsComplete){ + if (meetsComplete) { if (data.quest.completion == EnumQuestCompletion.Instant) { EventHooks.onQuestFinished(player, data.quest); } } - if(meetsReward){ + if (meetsReward) { QuestEvent.QuestTurnedInEvent event = new QuestEvent.QuestTurnedInEvent((IPlayer) NpcAPI.Instance().getIEntity(player), data.quest); event.expReward = data.quest.rewardExp; List list = new ArrayList(); Iterator var8 = data.quest.rewardItems.items.values().iterator(); - while(var8.hasNext()) { - ItemStack item = (ItemStack)var8.next(); + while (var8.hasNext()) { + ItemStack item = (ItemStack) var8.next(); if (item != null && item.stackSize > 0) { IItemStack iStack = NpcAPI.Instance().getIItemStack(item); - if (iStack != null){ + if (iStack != null) { list.add(iStack); } } } if (!data.quest.randomReward) { - event.itemRewards = (IItemStack[])list.toArray(new IItemStack[list.size()]); + event.itemRewards = (IItemStack[]) list.toArray(new IItemStack[list.size()]); } else if (!list.isEmpty()) { - event.itemRewards = new IItemStack[]{(IItemStack)list.get(player.getRNG().nextInt(list.size()))}; + event.itemRewards = new IItemStack[]{(IItemStack) list.get(player.getRNG().nextInt(list.size()))}; } EventHooks.onQuestTurnedIn(event); @@ -585,7 +582,7 @@ public class NoppesUtilPlayer { IItemStack[] var12 = event.itemRewards; int var14 = var12.length; - for(int var10 = 0; var10 < var14; ++var10) { + for (int var10 = 0; var10 < var14; ++var10) { IItemStack item = var12[var10]; if (item != null) { NoppesUtilServer.GivePlayerItem(player, player, item.getMCItemStack()); @@ -593,25 +590,25 @@ public class NoppesUtilPlayer { } } data.quest.questInterface.handlePartyComplete(player, party, isLeader, partyOptions.objectiveRequirement); - if(meetsReward){ - if(data.quest.rewardExp > 0){ + if (meetsReward) { + if (data.quest.rewardExp > 0) { player.worldObj.playSoundAtEntity(player, "random.orb", 0.1F, 0.5F * ((player.worldObj.rand.nextFloat() - player.worldObj.rand.nextFloat()) * 0.7F + 1.8F)); player.addExperience(data.quest.rewardExp); } data.quest.factionOptions.addPoints(player); - if(data.quest.mail.isValid()){ + if (data.quest.mail.isValid()) { PlayerDataController.Instance.addPlayerMessage(player.getCommandSenderName(), data.quest.mail); } } - if(meetsCommand){ - if(!data.quest.command.isEmpty()){ + if (meetsCommand) { + if (!data.quest.command.isEmpty()) { NoppesUtilServer.runCommand(player, "QuestCompletion", data.quest.command); } } - if(meetsComplete){ + if (meetsComplete) { PlayerQuestController.setQuestPartyFinished(data.quest, player, data); } @@ -622,17 +619,17 @@ public class NoppesUtilPlayer { } playerData.save(); - QuestCompletionPacket.sendQuestComplete((EntityPlayerMP)player, data.quest.writeToNBT(new NBTTagCompound())); + QuestCompletionPacket.sendQuestComplete((EntityPlayerMP) player, data.quest.writeToNBT(new NBTTagCompound())); } - if(quest.type == EnumQuestType.Item && partyOptions.objectiveRequirement == EnumPartyObjectives.Shared){ + if (quest.type == EnumQuestType.Item && partyOptions.objectiveRequirement == EnumPartyObjectives.Shared) { quest.questInterface.removePartyItems(party); } if (hasNextQuest) { - if(party.validateQuest(data.quest.getNextQuest().getId(), true)){ + if (party.validateQuest(data.quest.getNextQuest().getId(), true)) { party.setQuest(data.quest.getNextQuest()); - for(String name : party.getPlayerNames()) { + for (String name : party.getPlayerNames()) { EntityPlayer player = NoppesUtilServer.getPlayerByName(name); if (player == null) continue; @@ -643,15 +640,14 @@ public class NoppesUtilPlayer { playerData.questData.trackParty(party); } - } - else { + } else { party.setQuest(null); } } else { party.setQuest(null); } - if(data.quest.completion == EnumQuestCompletion.Npc){ + if (data.quest.completion == EnumQuestCompletion.Npc) { PartyController.Instance().sendQuestChat(party, "party.completeChat"); PartyController.Instance().pingPartyUpdate(party); } @@ -659,140 +655,143 @@ public class NoppesUtilPlayer { return true; } - public static boolean meetsPartyExchange(EnumPartyExchange exchange, boolean hasActive, boolean hasFinished, boolean isLeader){ - if(exchange == EnumPartyExchange.All){ + public static boolean meetsPartyExchange(EnumPartyExchange exchange, boolean hasActive, boolean hasFinished, boolean isLeader) { + if (exchange == EnumPartyExchange.All) { return true; - } else if (isLeader){ + } else if (isLeader) { return true; - } else if(exchange == EnumPartyExchange.Enrolled && hasActive){ + } else if (exchange == EnumPartyExchange.Enrolled && hasActive) { return true; } else return exchange == EnumPartyExchange.Valid && (hasActive || hasFinished); } - public static boolean compareItems(ItemStack item, ItemStack item2, boolean ignoreDamage, boolean ignoreNBT){ - if (item2 == null || item == null){ + public static boolean compareItems(ItemStack item, ItemStack item2, boolean ignoreDamage, boolean ignoreNBT) { + if (item2 == null || item == null) { return false; } boolean oreMatched = false; OreDictionary.itemMatches(item, item2, false); int[] ids = OreDictionary.getOreIDs(item); - if(ids.length > 0){ - for(int id : ids){ - boolean match1 = false, match2 = false; - for(ItemStack is : OreDictionary.getOres(id)){ - if(compareItemDetails(item, is, ignoreDamage, ignoreNBT)){ - match1 = true; - } - if(compareItemDetails(item2, is, ignoreDamage, ignoreNBT)){ - match2 = true; - } - } - if(match1 && match2) - return true; - } + if (ids.length > 0) { + for (int id : ids) { + boolean match1 = false, match2 = false; + for (ItemStack is : OreDictionary.getOres(id)) { + if (compareItemDetails(item, is, ignoreDamage, ignoreNBT)) { + match1 = true; + } + if (compareItemDetails(item2, is, ignoreDamage, ignoreNBT)) { + match2 = true; + } + } + if (match1 && match2) + return true; + } } - return compareItemDetails(item, item2, ignoreDamage, ignoreNBT); - } - private static boolean compareItemDetails(ItemStack item, ItemStack item2, boolean ignoreDamage, boolean ignoreNBT){ - if (item.getItem() != item2.getItem() ){ + return compareItemDetails(item, item2, ignoreDamage, ignoreNBT); + } + + private static boolean compareItemDetails(ItemStack item, ItemStack item2, boolean ignoreDamage, boolean ignoreNBT) { + if (item.getItem() != item2.getItem()) { return false; } - if (!ignoreDamage && item.getItemDamage() != -1 && item.getItemDamage() != item2.getItemDamage()){ + if (!ignoreDamage && item.getItemDamage() != -1 && item.getItemDamage() != item2.getItemDamage()) { return false; } - if(!ignoreNBT && item.stackTagCompound != null && (item2.stackTagCompound == null || !item.stackTagCompound.equals(item2.stackTagCompound))){ + if (!ignoreNBT && item.stackTagCompound != null && (item2.stackTagCompound == null || !item.stackTagCompound.equals(item2.stackTagCompound))) { return false; } - if(!ignoreNBT && item2.stackTagCompound != null && item.stackTagCompound == null){ + if (!ignoreNBT && item2.stackTagCompound != null && item.stackTagCompound == null) { return false; } - return true; - } - public static boolean compareItems(EntityPlayer player, ItemStack item, boolean ignoreDamage, boolean ignoreNBT){ - int size = 0; - for(ItemStack is : player.inventory.mainInventory){ - if(is != null && compareItems(item, is, ignoreDamage, ignoreNBT)) - size += is.stackSize; - } - return size >= item.stackSize; - } - public static void consumeItem(EntityPlayer player, ItemStack item, boolean ignoreDamage, boolean ignoreNBT) { - if(item == null) - return; - int size = item.stackSize; - for(int i = 0; i < player.inventory.mainInventory.length; i++){ - ItemStack is = player.inventory.mainInventory[i]; - if(is == null || !compareItems(item, is, ignoreDamage, ignoreNBT)) - continue; - if(size >= is.stackSize){ - size -= is.stackSize; - player.inventory.mainInventory[i] = null; - } - else{ - player.inventory.mainInventory[i].splitStack(size); - break; - } - } - } - public static void isGUIOpen(EntityPlayerMP player){ + return true; + } + + public static boolean compareItems(EntityPlayer player, ItemStack item, boolean ignoreDamage, boolean ignoreNBT) { + int size = 0; + for (ItemStack is : player.inventory.mainInventory) { + if (is != null && compareItems(item, is, ignoreDamage, ignoreNBT)) + size += is.stackSize; + } + return size >= item.stackSize; + } + + public static void consumeItem(EntityPlayer player, ItemStack item, boolean ignoreDamage, boolean ignoreNBT) { + if (item == null) + return; + int size = item.stackSize; + for (int i = 0; i < player.inventory.mainInventory.length; i++) { + ItemStack is = player.inventory.mainInventory[i]; + if (is == null || !compareItems(item, is, ignoreDamage, ignoreNBT)) + continue; + if (size >= is.stackSize) { + size -= is.stackSize; + player.inventory.mainInventory[i] = null; + } else { + player.inventory.mainInventory[i].splitStack(size); + break; + } + } + } + + public static void isGUIOpen(EntityPlayerMP player) { PacketHandler.Instance.sendToPlayer(new IsGuiOpenPacket(), player); - } + } - public static List countStacks(IInventory inv, boolean ignoreDamage, boolean ignoreNBT) { - List list = new ArrayList(); + public static List countStacks(IInventory inv, boolean ignoreDamage, boolean ignoreNBT) { + List list = new ArrayList(); - for(int i = 0; i < inv.getSizeInventory(); ++i) { - ItemStack item = inv.getStackInSlot(i); - if (!NoppesUtilServer.IsItemStackNull(item)) { - boolean found = false; - Iterator var7 = list.iterator(); + for (int i = 0; i < inv.getSizeInventory(); ++i) { + ItemStack item = inv.getStackInSlot(i); + if (!NoppesUtilServer.IsItemStackNull(item)) { + boolean found = false; + Iterator var7 = list.iterator(); - while(var7.hasNext()) { - ItemStack is = (ItemStack)var7.next(); - if (compareItems(item, is, ignoreDamage, ignoreNBT)) { - is.stackSize = is.stackSize + item.stackSize; - found = true; - break; - } - } + while (var7.hasNext()) { + ItemStack is = (ItemStack) var7.next(); + if (compareItems(item, is, ignoreDamage, ignoreNBT)) { + is.stackSize = is.stackSize + item.stackSize; + found = true; + break; + } + } - if (!found) { - list.add(item.copy()); - } - } - } + if (!found) { + list.add(item.copy()); + } + } + } - return list; - } + return list; + } - public static void playSoundTo(EntityPlayerMP player, int id, ScriptSound sound) { - NBTTagCompound compound = sound.writeToNBT(); - if (sound.sourceEntity == null || player.worldObj.provider.dimensionId == sound.sourceEntity.getDimension()) { + public static void playSoundTo(EntityPlayerMP player, int id, ScriptSound sound) { + NBTTagCompound compound = sound.writeToNBT(); + if (sound.sourceEntity == null || player.worldObj.provider.dimensionId == sound.sourceEntity.getDimension()) { PacketHandler.Instance.sendToPlayer(new SoundManagementPacket(EnumSoundOperation.PLAY_SOUND_TO, id, compound), player); - } - } + } + } - public static void playSoundTo(EntityPlayerMP player, ScriptSound sound) { - NBTTagCompound compound = sound.writeToNBT(); - if (sound.sourceEntity == null || player.worldObj.provider.dimensionId == sound.sourceEntity.getDimension()) { + public static void playSoundTo(EntityPlayerMP player, ScriptSound sound) { + NBTTagCompound compound = sound.writeToNBT(); + if (sound.sourceEntity == null || player.worldObj.provider.dimensionId == sound.sourceEntity.getDimension()) { PacketHandler.Instance.sendToPlayer(new SoundManagementPacket(EnumSoundOperation.PLAY_SOUND_TO_NO_ID, compound), player); - } - } + } + } - public static void stopSoundFor(EntityPlayerMP player, int id) { + public static void stopSoundFor(EntityPlayerMP player, int id) { PacketHandler.Instance.sendToPlayer(new SoundManagementPacket(EnumSoundOperation.STOP_SOUND_FOR, id), player); - } + } - public static void pauseSoundsFor(EntityPlayerMP player) { + public static void pauseSoundsFor(EntityPlayerMP player) { PacketHandler.Instance.sendToPlayer(new SoundManagementPacket(EnumSoundOperation.PAUSE_SOUNDS), player); - } + } - public static void continueSoundsFor(EntityPlayerMP player) { + public static void continueSoundsFor(EntityPlayerMP player) { PacketHandler.Instance.sendToPlayer(new SoundManagementPacket(EnumSoundOperation.CONTINUE_SOUNDS), player); - } + } - public static void stopSoundsFor(EntityPlayerMP player) { + public static void stopSoundsFor(EntityPlayerMP player) { PacketHandler.Instance.sendToPlayer(new SoundManagementPacket(EnumSoundOperation.STOP_SOUNDS), player); - } + } } diff --git a/src/main/java/noppes/npcs/NoppesUtilServer.java b/src/main/java/noppes/npcs/NoppesUtilServer.java index 3f7275653..b07a99254 100644 --- a/src/main/java/noppes/npcs/NoppesUtilServer.java +++ b/src/main/java/noppes/npcs/NoppesUtilServer.java @@ -65,7 +65,7 @@ import java.util.*; import static kamkeel.npcs.network.packets.data.large.ScrollDataPacket.sendScrollData; public class NoppesUtilServer { - private static HashMap editingQuests = new HashMap(); + private static HashMap editingQuests = new HashMap(); public static IPlayer getIPlayer(EntityPlayer p) { return (IPlayer) NpcAPI.Instance().getIEntity(p); @@ -75,18 +75,18 @@ public class NoppesUtilServer { return entity instanceof EntityPlayer ? ((EntityPlayer) entity).getGameProfile().getId() : entity.getUniqueID(); } - public static boolean isScriptableItem(Item item){ + public static boolean isScriptableItem(Item item) { return item == CustomItems.scripted_item || item == CustomItems.linked_item; } - public static void setEditingNpc(EntityPlayer player, EntityNPCInterface npc){ + public static void setEditingNpc(EntityPlayer player, EntityNPCInterface npc) { PlayerData data = PlayerDataController.Instance.getPlayerData(player); data.editingNpc = npc; - if(npc != null) - PacketHandler.Instance.sendToPlayer(new EditNpcPacket(npc.getEntityId()), (EntityPlayerMP)player); + if (npc != null) + PacketHandler.Instance.sendToPlayer(new EditNpcPacket(npc.getEntityId()), (EntityPlayerMP) player); } - public static EntityNPCInterface getEditingNpc(EntityPlayer player){ + public static EntityNPCInterface getEditingNpc(EntityPlayer player) { PlayerData data = PlayerDataController.Instance.getPlayerData(player); return data.editingNpc; } @@ -95,102 +95,96 @@ public class NoppesUtilServer { editingQuests.put(player.getCommandSenderName(), quest); } - public static Quest getEditingQuest(EntityPlayer player){ + public static Quest getEditingQuest(EntityPlayer player) { return editingQuests.get(player.getCommandSenderName()); } - public static void sendRoleData(EntityPlayer player, EntityNPCInterface npc){ - if(npc.advanced.role == EnumRoleType.None) + public static void sendRoleData(EntityPlayer player, EntityNPCInterface npc) { + if (npc.advanced.role == EnumRoleType.None) return; NBTTagCompound comp = new NBTTagCompound(); npc.roleInterface.writeToNBT(comp); comp.setInteger("EntityId", npc.getEntityId()); comp.setInteger("Role", npc.advanced.role.ordinal()); - PacketHandler.Instance.sendToPlayer(new RolePacket(comp), (EntityPlayerMP)player); + PacketHandler.Instance.sendToPlayer(new RolePacket(comp), (EntityPlayerMP) player); } - public static void sendFactionDataAll(EntityPlayerMP player) { - Map map = new HashMap(); - for(Faction faction : FactionController.getInstance().factions.values()){ - map.put(faction.name, faction.id); - } - sendScrollData(player, map, EnumScrollData.OPTIONAL); - } + public static void sendFactionDataAll(EntityPlayerMP player) { + Map map = new HashMap(); + for (Faction faction : FactionController.getInstance().factions.values()) { + map.put(faction.name, faction.id); + } + sendScrollData(player, map, EnumScrollData.OPTIONAL); + } - public static void sendAnimationDataAll(EntityPlayerMP player) { - Map map = new HashMap(); - for(Animation animation : AnimationController.getInstance().animations.values()){ - map.put(animation.name, animation.id); - } - sendScrollData(player, map, EnumScrollData.OPTIONAL); - } + public static void sendAnimationDataAll(EntityPlayerMP player) { + Map map = new HashMap(); + for (Animation animation : AnimationController.getInstance().animations.values()) { + map.put(animation.name, animation.id); + } + sendScrollData(player, map, EnumScrollData.OPTIONAL); + } - public static void sendTagDataAll(EntityPlayerMP player) { - Map map = new HashMap(); - for(Tag tag : TagController.getInstance().tags.values()){ - map.put(tag.name, tag.id); - } - sendScrollData(player, map, EnumScrollData.OPTIONAL); - } + public static void sendTagDataAll(EntityPlayerMP player) { + Map map = new HashMap(); + for (Tag tag : TagController.getInstance().tags.values()) { + map.put(tag.name, tag.id); + } + sendScrollData(player, map, EnumScrollData.OPTIONAL); + } - public static void sendBankDataAll(EntityPlayerMP player) { - Map map = new HashMap(); - for(Bank bank : BankController.getInstance().banks.values()){ - map.put(bank.name, bank.id); - } - sendScrollData(player, map, EnumScrollData.OPTIONAL); - } + public static void sendBankDataAll(EntityPlayerMP player) { + Map map = new HashMap(); + for (Bank bank : BankController.getInstance().banks.values()) { + map.put(bank.name, bank.id); + } + sendScrollData(player, map, EnumScrollData.OPTIONAL); + } - public static NBTTagCompound writeItem(ItemStack item, NBTTagCompound nbt){ + public static NBTTagCompound writeItem(ItemStack item, NBTTagCompound nbt) { String resourcelocation = Item.itemRegistry.getNameForObject(item.getItem()); nbt.setString("id", resourcelocation == null ? "minecraft:air" : resourcelocation.toString()); - nbt.setByte("Count", (byte)item.stackSize); - nbt.setShort("Damage", (short)item.getItemDamage()); + nbt.setByte("Count", (byte) item.stackSize); + nbt.setShort("Damage", (short) item.getItemDamage()); - if (item.stackTagCompound != null){ + if (item.stackTagCompound != null) { nbt.setTag("tag", item.stackTagCompound); } return nbt; } - public static ItemStack readItem(NBTTagCompound nbt){ - Item item; - if (nbt.hasKey("id", 8)){ - item = getByNameOrId(nbt.getString("id")); + public static ItemStack readItem(NBTTagCompound nbt) { + Item item; + if (nbt.hasKey("id", 8)) { + item = getByNameOrId(nbt.getString("id")); + } else { + item = Item.getItemById(nbt.getShort("id")); } - else{ - item = Item.getItemById(nbt.getShort("id")); - } - if(item == null) - return null; + if (item == null) + return null; ItemStack itemstack = new ItemStack(item); itemstack.stackSize = nbt.getByte("Count"); itemstack.setItemDamage(nbt.getShort("Damage")); - if (itemstack.getItemDamage() < 0){ - itemstack.setItemDamage(0); + if (itemstack.getItemDamage() < 0) { + itemstack.setItemDamage(0); } - if (nbt.hasKey("tag", 10)){ - itemstack.stackTagCompound = nbt.getCompoundTag("tag"); + if (nbt.hasKey("tag", 10)) { + itemstack.stackTagCompound = nbt.getCompoundTag("tag"); } return itemstack; } - public static Item getByNameOrId(String id) - { - Item item = (Item)Item.itemRegistry.getObject(id); + public static Item getByNameOrId(String id) { + Item item = (Item) Item.itemRegistry.getObject(id); - if (item == null) - { - try - { + if (item == null) { + try { return Item.getItemById(Integer.parseInt(id)); - } - catch (NumberFormatException numberformatexception) - { + } catch (NumberFormatException numberformatexception) { ; } } @@ -198,47 +192,47 @@ public class NoppesUtilServer { return item; } - public static void openDialog(EntityPlayer player, EntityNPCInterface npc, Dialog dia, int optionId){ - Dialog dialog = dia.copy(player); + public static void openDialog(EntityPlayer player, EntityNPCInterface npc, Dialog dia, int optionId) { + Dialog dialog = dia.copy(player); PlayerData playerdata = PlayerData.get(player); - if (!npc.isRemote()) { - if (EventHooks.onNPCDialog(npc, player, dialog.id, optionId, dialog)) { - return; - } - if (EventHooks.onDialogOpen(new DialogEvent.DialogOpen((IPlayer) NpcAPI.Instance().getIEntity(player), dialog))) { - return; - } - } + if (!npc.isRemote()) { + if (EventHooks.onNPCDialog(npc, player, dialog.id, optionId, dialog)) { + return; + } + if (EventHooks.onDialogOpen(new DialogEvent.DialogOpen((IPlayer) NpcAPI.Instance().getIEntity(player), dialog))) { + return; + } + } - if(npc instanceof EntityDialogNpc || dia.id < 0){ - dialog.hideNPC = true; - PacketHandler.Instance.sendToPlayer(new DialogPacket(npc.getCommandSenderName(), -1, dialog.writeToNBT(new NBTTagCompound())), (EntityPlayerMP)player); - } - else - PacketHandler.Instance.sendToPlayer(new DialogPacket("Real", npc.getEntityId(), dialog.writeToNBT(new NBTTagCompound())), (EntityPlayerMP)player); + if (npc instanceof EntityDialogNpc || dia.id < 0) { + dialog.hideNPC = true; + PacketHandler.Instance.sendToPlayer(new DialogPacket(npc.getCommandSenderName(), -1, dialog.writeToNBT(new NBTTagCompound())), (EntityPlayerMP) player); + } else + PacketHandler.Instance.sendToPlayer(new DialogPacket("Real", npc.getEntityId(), dialog.writeToNBT(new NBTTagCompound())), (EntityPlayerMP) player); dia.factionOptions.addPoints(player); - if(dialog.hasQuest()) - PlayerQuestController.addActiveQuest(new QuestData(dialog.getQuest()),player); - if(!dialog.command.isEmpty()){ + if (dialog.hasQuest()) + PlayerQuestController.addActiveQuest(new QuestData(dialog.getQuest()), player); + if (!dialog.command.isEmpty()) { runCommand(player, npc.getCommandSenderName(), dialog.command); } - if(dialog.mail.isValid()) - PlayerDataController.Instance.addPlayerMessage(player.getCommandSenderName(), dialog.mail); + if (dialog.mail.isValid()) + PlayerDataController.Instance.addPlayerMessage(player.getCommandSenderName(), dialog.mail); PlayerDialogData data = PlayerDataController.Instance.getPlayerData(player).dialogData; - if(!data.dialogsRead.contains(dialog.id) && dialog.id >= 0){ + if (!data.dialogsRead.contains(dialog.id) && dialog.id >= 0) { data.dialogsRead.add(dialog.id); playerdata.updateClient = true; } - setEditingNpc(player, npc); - } - public static void runCommand(EntityPlayer player, String name, String command){ + setEditingNpc(player, npc); + } + + public static void runCommand(EntityPlayer player, String name, String command) { runCommand(player, name, command, player); - } + } public static void runCommand(EntityLivingBase executer, String name, String command, EntityPlayer player) { - if(player != null) + if (player != null) command = command.replace("@dp", player.getCommandSenderName()); command = command.replace("@npc", name); @@ -264,13 +258,12 @@ public class NoppesUtilServer { } - public static void runCommand(World world, String name, String command) { - TileEntityCommandBlock tile = new TileEntityCommandBlock(); - tile.setWorldObj(world.provider.worldObj); - tile.xCoord = 0; - tile.yCoord = 0; - tile.zCoord = 0; + TileEntityCommandBlock tile = new TileEntityCommandBlock(); + tile.setWorldObj(world.provider.worldObj); + tile.xCoord = 0; + tile.yCoord = 0; + tile.zCoord = 0; // Trim the command to remove leading/trailing spaces command = command.trim(); @@ -281,390 +274,383 @@ public class NoppesUtilServer { logic.func_145754_b("@" + name); logic.func_145755_a(world); } - } + } - public static void consumeItemStack(int i, EntityPlayer player){ - ItemStack item = player.inventory.getCurrentItem(); - if(player.capabilities.isCreativeMode || item == null) - return; + public static void consumeItemStack(int i, EntityPlayer player) { + ItemStack item = player.inventory.getCurrentItem(); + if (player.capabilities.isCreativeMode || item == null) + return; --item.stackSize; if (item.stackSize <= 0) - player.destroyCurrentEquippedItem(); - } - - public static void sendOpenGui(EntityPlayer player, - EnumGuiType gui, EntityNPCInterface npc) { - sendOpenGui(player, gui, npc, 0, 0, 0); - } - - public static void sendOpenGuiNoDelay(EntityPlayer player, - EnumGuiType gui, EntityNPCInterface npc) { - sendOpenGuiNoDelay(player, gui, npc, 0, 0, 0); - } - - public static void sendOpenGui(final EntityPlayer player, - final EnumGuiType gui, final EntityNPCInterface npc, final int i, final int j, final int k) { - if(!(player instanceof EntityPlayerMP)) - return; - - setEditingNpc(player, npc); - sendExtraData(player, npc,gui, i, j, k); - - if(CustomNpcs.proxy.getServerGuiElement(gui.ordinal(), player, player.worldObj, i, j, k) != null){ - player.openGui(CustomNpcs.instance, gui.ordinal(), player.worldObj, i, j, k); - return; - } - else{ - GuiOpenPacket.openGUI((EntityPlayerMP)player, gui, i, j, k); - } - ArrayList list = getScrollData(player, gui, npc); - if(list == null || list.isEmpty()) - return; - - ScrollListPacket.sendList((EntityPlayerMP)player, list, EnumScrollData.OPTIONAL); + player.destroyCurrentEquippedItem(); } - public static void sendOpenGuiNoDelay(final EntityPlayer player, - final EnumGuiType gui, final EntityNPCInterface npc, final int i, final int j, final int k) { - if(!(player instanceof EntityPlayerMP)) - return; + public static void sendOpenGui(EntityPlayer player, + EnumGuiType gui, EntityNPCInterface npc) { + sendOpenGui(player, gui, npc, 0, 0, 0); + } - setEditingNpc(player, npc); - sendExtraData(player, npc,gui, i, j, k); + public static void sendOpenGuiNoDelay(EntityPlayer player, + EnumGuiType gui, EntityNPCInterface npc) { + sendOpenGuiNoDelay(player, gui, npc, 0, 0, 0); + } - if(CustomNpcs.proxy.getServerGuiElement(gui.ordinal(), player, player.worldObj, i, j, k) != null){ - player.openGui(CustomNpcs.instance, gui.ordinal(), player.worldObj, i, j, k); - return; - } - else{ - GuiOpenPacket.openGUI((EntityPlayerMP)player, gui, i, j, k); - } - ArrayList list = getScrollData(player, gui, npc); - if(list == null || list.isEmpty()) - return; + public static void sendOpenGui(final EntityPlayer player, + final EnumGuiType gui, final EntityNPCInterface npc, final int i, final int j, final int k) { + if (!(player instanceof EntityPlayerMP)) + return; - ScrollListPacket.sendList((EntityPlayerMP)player, list, EnumScrollData.OPTIONAL); - } + setEditingNpc(player, npc); + sendExtraData(player, npc, gui, i, j, k); + + if (CustomNpcs.proxy.getServerGuiElement(gui.ordinal(), player, player.worldObj, i, j, k) != null) { + player.openGui(CustomNpcs.instance, gui.ordinal(), player.worldObj, i, j, k); + return; + } else { + GuiOpenPacket.openGUI((EntityPlayerMP) player, gui, i, j, k); + } + ArrayList list = getScrollData(player, gui, npc); + if (list == null || list.isEmpty()) + return; + + ScrollListPacket.sendList((EntityPlayerMP) player, list, EnumScrollData.OPTIONAL); + } + + public static void sendOpenGuiNoDelay(final EntityPlayer player, + final EnumGuiType gui, final EntityNPCInterface npc, final int i, final int j, final int k) { + if (!(player instanceof EntityPlayerMP)) + return; + + setEditingNpc(player, npc); + sendExtraData(player, npc, gui, i, j, k); + + if (CustomNpcs.proxy.getServerGuiElement(gui.ordinal(), player, player.worldObj, i, j, k) != null) { + player.openGui(CustomNpcs.instance, gui.ordinal(), player.worldObj, i, j, k); + return; + } else { + GuiOpenPacket.openGUI((EntityPlayerMP) player, gui, i, j, k); + } + ArrayList list = getScrollData(player, gui, npc); + if (list == null || list.isEmpty()) + return; + + ScrollListPacket.sendList((EntityPlayerMP) player, list, EnumScrollData.OPTIONAL); + } - private static void sendExtraData(EntityPlayer player, EntityNPCInterface npc, EnumGuiType gui, int i, int j, int k) { - if(gui == EnumGuiType.PlayerFollower || gui == EnumGuiType.PlayerFollowerHire || gui == EnumGuiType.PlayerTrader || gui == EnumGuiType.PlayerTransporter){ - sendRoleData(player, npc); - } - } + private static void sendExtraData(EntityPlayer player, EntityNPCInterface npc, EnumGuiType gui, int i, int j, int k) { + if (gui == EnumGuiType.PlayerFollower || gui == EnumGuiType.PlayerFollowerHire || gui == EnumGuiType.PlayerTrader || gui == EnumGuiType.PlayerTransporter) { + sendRoleData(player, npc); + } + } - private static ArrayList getScrollData(EntityPlayer player, EnumGuiType gui, EntityNPCInterface npc) { - if(gui == EnumGuiType.PlayerTransporter){ - RoleTransporter role = (RoleTransporter) npc.roleInterface; - ArrayList list = new ArrayList(); - TransportLocation location = role.getLocation(); - String name = role.getLocation().name; - for(TransportLocation loc: location.category.getDefaultLocations()){ - if(!list.contains(loc.name)){ - list.add(loc.name); - } - } - PlayerTransportData playerdata = PlayerDataController.Instance.getPlayerData(player).transportData; - for(int i : playerdata.transports){ - TransportLocation loc = TransportController.getInstance().getTransport(i); - if(loc != null && location.category.locations.containsKey(loc.id)){ - if(!list.contains(loc.name)){ - list.add(loc.name); - } - } - } - list.remove(name); - return list; - } - return null; - } - public static void spawnParticle(Entity entity,String particle, int dimension){ + private static ArrayList getScrollData(EntityPlayer player, EnumGuiType gui, EntityNPCInterface npc) { + if (gui == EnumGuiType.PlayerTransporter) { + RoleTransporter role = (RoleTransporter) npc.roleInterface; + ArrayList list = new ArrayList(); + TransportLocation location = role.getLocation(); + String name = role.getLocation().name; + for (TransportLocation loc : location.category.getDefaultLocations()) { + if (!list.contains(loc.name)) { + list.add(loc.name); + } + } + PlayerTransportData playerdata = PlayerDataController.Instance.getPlayerData(player).transportData; + for (int i : playerdata.transports) { + TransportLocation loc = TransportController.getInstance().getTransport(i); + if (loc != null && location.category.locations.containsKey(loc.id)) { + if (!list.contains(loc.name)) { + list.add(loc.name); + } + } + } + list.remove(name); + return list; + } + return null; + } + + public static void spawnParticle(Entity entity, String particle, int dimension) { PacketHandler.Instance.sendTracking(new ParticlePacket(entity.posX, entity.posY, entity.posZ, entity.height, entity.width, entity.yOffset, particle), entity); } - public static void spawnScriptedParticle(NBTTagCompound compound, int dimensionId){ + public static void spawnScriptedParticle(NBTTagCompound compound, int dimensionId) { PacketHandler.Instance.sendToDimension(new ScriptedParticlePacket(compound), dimensionId); - } + } - public static void playSound(int id, ScriptSound sound) { - List list = MinecraftServer.getServer().getConfigurationManager().playerEntityList; - for (EntityPlayer player : list) { - NoppesUtilPlayer.playSoundTo((EntityPlayerMP) player, id, sound); - } - } + public static void playSound(int id, ScriptSound sound) { + List list = MinecraftServer.getServer().getConfigurationManager().playerEntityList; + for (EntityPlayer player : list) { + NoppesUtilPlayer.playSoundTo((EntityPlayerMP) player, id, sound); + } + } - public static void playSound(ScriptSound sound) { - List list = MinecraftServer.getServer().getConfigurationManager().playerEntityList; - for (EntityPlayer player : list) { - NoppesUtilPlayer.playSoundTo((EntityPlayerMP) player, sound); - } - } + public static void playSound(ScriptSound sound) { + List list = MinecraftServer.getServer().getConfigurationManager().playerEntityList; + for (EntityPlayer player : list) { + NoppesUtilPlayer.playSoundTo((EntityPlayerMP) player, sound); + } + } - public static void stopSound(int id) { - List list = MinecraftServer.getServer().getConfigurationManager().playerEntityList; - for (EntityPlayer player : list) { - NoppesUtilPlayer.stopSoundFor((EntityPlayerMP) player, id); - } - } + public static void stopSound(int id) { + List list = MinecraftServer.getServer().getConfigurationManager().playerEntityList; + for (EntityPlayer player : list) { + NoppesUtilPlayer.stopSoundFor((EntityPlayerMP) player, id); + } + } - public static void pauseSounds() { - List list = MinecraftServer.getServer().getConfigurationManager().playerEntityList; - for (EntityPlayer player : list) { - NoppesUtilPlayer.pauseSoundsFor((EntityPlayerMP) player); - } - } + public static void pauseSounds() { + List list = MinecraftServer.getServer().getConfigurationManager().playerEntityList; + for (EntityPlayer player : list) { + NoppesUtilPlayer.pauseSoundsFor((EntityPlayerMP) player); + } + } - public static void continueSounds() { - List list = MinecraftServer.getServer().getConfigurationManager().playerEntityList; - for (EntityPlayer player : list) { - NoppesUtilPlayer.continueSoundsFor((EntityPlayerMP) player); - } - } + public static void continueSounds() { + List list = MinecraftServer.getServer().getConfigurationManager().playerEntityList; + for (EntityPlayer player : list) { + NoppesUtilPlayer.continueSoundsFor((EntityPlayerMP) player); + } + } - public static void stopSounds() { - List list = MinecraftServer.getServer().getConfigurationManager().playerEntityList; - for (EntityPlayer player : list) { - NoppesUtilPlayer.stopSoundsFor((EntityPlayerMP) player); - } - } + public static void stopSounds() { + List list = MinecraftServer.getServer().getConfigurationManager().playerEntityList; + for (EntityPlayer player : list) { + NoppesUtilPlayer.stopSoundsFor((EntityPlayerMP) player); + } + } - public static void deleteNpc(EntityNPCInterface npc,EntityPlayer player) { + public static void deleteNpc(EntityNPCInterface npc, EntityPlayer player) { PacketHandler.Instance.sendTracking(new DeleteNpcPacket(npc.getEntityId()), npc); - } + } - public static void createMobSpawner(int x, int y, int z, NBTTagCompound comp, EntityPlayer player) { - comp.removeTag("Pos"); - ServerCloneController.Instance.cleanTags(comp); + public static void createMobSpawner(int x, int y, int z, NBTTagCompound comp, EntityPlayer player) { + comp.removeTag("Pos"); + ServerCloneController.Instance.cleanTags(comp); - if(comp.getString("id").equalsIgnoreCase("entityhorse")){ - player.addChatMessage(new ChatComponentTranslation("Currently you cant create horse spawner, its a minecraft bug")); - return; - } + if (comp.getString("id").equalsIgnoreCase("entityhorse")) { + player.addChatMessage(new ChatComponentTranslation("Currently you cant create horse spawner, its a minecraft bug")); + return; + } - player.worldObj.setBlock(x, y, z, Blocks.mob_spawner); //setBlock - TileEntityMobSpawner tile = (TileEntityMobSpawner) player.worldObj.getTileEntity(x, y, z); - MobSpawnerBaseLogic logic = tile.func_145881_a(); + player.worldObj.setBlock(x, y, z, Blocks.mob_spawner); //setBlock + TileEntityMobSpawner tile = (TileEntityMobSpawner) player.worldObj.getTileEntity(x, y, z); + MobSpawnerBaseLogic logic = tile.func_145881_a(); - logic.setRandomEntity(logic.new WeightedRandomMinecart(comp, comp.getString("id"))); - } + logic.setRandomEntity(logic.new WeightedRandomMinecart(comp, comp.getString("id"))); + } - public static void sendQuestCategoryData(EntityPlayerMP player) { - Map map = new HashMap(); - for(QuestCategory category : QuestController.Instance.categories.values()){ - map.put(category.title, category.id); - } - sendScrollData(player, map, EnumScrollData.OPTIONAL); - } + public static void sendQuestCategoryData(EntityPlayerMP player) { + Map map = new HashMap(); + for (QuestCategory category : QuestController.Instance.categories.values()) { + map.put(category.title, category.id); + } + sendScrollData(player, map, EnumScrollData.OPTIONAL); + } - public static void sendPlayerData(EnumPlayerData type, EntityPlayerMP player, String name) throws IOException { - Map map = new HashMap(); + public static void sendPlayerData(EnumPlayerData type, EntityPlayerMP player, String name) throws IOException { + Map map = new HashMap(); - if(type == EnumPlayerData.Players){ - for(String username : PlayerDataController.Instance.nameUUIDs.keySet()){ - map.put(username, 0); - } - for(String username : MinecraftServer.getServer().getConfigurationManager().getAllUsernames()){ - map.put(username, 0); - } - } - else{ - PlayerData playerdata = PlayerDataController.Instance.getDataFromUsername(name); - if(type == EnumPlayerData.Dialog){ - PlayerDialogData data = playerdata.dialogData; + if (type == EnumPlayerData.Players) { + for (String username : PlayerDataController.Instance.nameUUIDs.keySet()) { + map.put(username, 0); + } + for (String username : MinecraftServer.getServer().getConfigurationManager().getAllUsernames()) { + map.put(username, 0); + } + } else { + PlayerData playerdata = PlayerDataController.Instance.getDataFromUsername(name); + if (type == EnumPlayerData.Dialog) { + PlayerDialogData data = playerdata.dialogData; - for(int questId : data.dialogsRead){ - Dialog dialog = DialogController.Instance.dialogs.get(questId); - if(dialog == null) - continue; - map.put(dialog.category.title + ": " + dialog.title,questId); - } - } - else if(type == EnumPlayerData.Quest){ - PlayerQuestData data = playerdata.questData; + for (int questId : data.dialogsRead) { + Dialog dialog = DialogController.Instance.dialogs.get(questId); + if (dialog == null) + continue; + map.put(dialog.category.title + ": " + dialog.title, questId); + } + } else if (type == EnumPlayerData.Quest) { + PlayerQuestData data = playerdata.questData; - for(int questId : data.activeQuests.keySet()){ - Quest quest = QuestController.Instance.quests.get(questId); - if(quest == null) - continue; - map.put(quest.category.title + ": " + quest.title + " (Active)",questId); - } - for(int questId : data.finishedQuests.keySet()){ - Quest quest = QuestController.Instance.quests.get(questId); - if(quest == null) - continue; - map.put(quest.category.title + ": " + quest.title + " (Finished)",questId); - } - } - else if(type == EnumPlayerData.Transport){ - PlayerTransportData data = playerdata.transportData; + for (int questId : data.activeQuests.keySet()) { + Quest quest = QuestController.Instance.quests.get(questId); + if (quest == null) + continue; + map.put(quest.category.title + ": " + quest.title + " (Active)", questId); + } + for (int questId : data.finishedQuests.keySet()) { + Quest quest = QuestController.Instance.quests.get(questId); + if (quest == null) + continue; + map.put(quest.category.title + ": " + quest.title + " (Finished)", questId); + } + } else if (type == EnumPlayerData.Transport) { + PlayerTransportData data = playerdata.transportData; - for(int questId : data.transports){ - TransportLocation location = TransportController.getInstance().getTransport(questId); - if(location == null) - continue; - map.put(location.category.title + ": " + location.name,questId); - } - } - else if(type == EnumPlayerData.Bank){ - PlayerBankData data = playerdata.bankData; + for (int questId : data.transports) { + TransportLocation location = TransportController.getInstance().getTransport(questId); + if (location == null) + continue; + map.put(location.category.title + ": " + location.name, questId); + } + } else if (type == EnumPlayerData.Bank) { + PlayerBankData data = playerdata.bankData; - for(int bankId : data.banks.keySet()){ - Bank bank = BankController.getInstance().banks.get(bankId); - if(bank == null) - continue; - map.put(bank.name,bankId); - } - } - else if(type == EnumPlayerData.Factions){ - PlayerFactionData data = playerdata.factionData; - for(int factionId : data.factionData.keySet()){ - Faction faction = FactionController.getInstance().factions.get(factionId); - if(faction == null) - continue; - map.put(faction.name + "(" + data.getFactionPoints(factionId) + ")" ,factionId); - } - } - } + for (int bankId : data.banks.keySet()) { + Bank bank = BankController.getInstance().banks.get(bankId); + if (bank == null) + continue; + map.put(bank.name, bankId); + } + } else if (type == EnumPlayerData.Factions) { + PlayerFactionData data = playerdata.factionData; + for (int factionId : data.factionData.keySet()) { + Faction faction = FactionController.getInstance().factions.get(factionId); + if (faction == null) + continue; + map.put(faction.name + "(" + data.getFactionPoints(factionId) + ")", factionId); + } + } + } - sendScrollData(player, map, EnumScrollData.OPTIONAL); - } + sendScrollData(player, map, EnumScrollData.OPTIONAL); + } - public static void removePlayerData(ByteBuf buffer, EntityPlayerMP player) throws IOException { - int id = buffer.readInt(); - if(EnumPlayerData.values().length <= id) - return; - String name = ByteBufUtils.readString(buffer); - EnumPlayerData type = EnumPlayerData.values()[id]; + public static void removePlayerData(ByteBuf buffer, EntityPlayerMP player) throws IOException { + int id = buffer.readInt(); + if (EnumPlayerData.values().length <= id) + return; + String name = ByteBufUtils.readString(buffer); + EnumPlayerData type = EnumPlayerData.values()[id]; EntityPlayer pl = MinecraftServer.getServer().getConfigurationManager().func_152612_a(name); - PlayerData playerdata = null; - if(pl == null) - playerdata = PlayerDataController.Instance.getDataFromUsername(name); - else - playerdata = PlayerDataController.Instance.getPlayerData(pl); + PlayerData playerdata = null; + if (pl == null) + playerdata = PlayerDataController.Instance.getDataFromUsername(name); + else + playerdata = PlayerDataController.Instance.getPlayerData(pl); - if(type == EnumPlayerData.Players){ - String fileType = ".json"; - if(ConfigMain.DatFormat){ - fileType = ".dat"; - } + if (type == EnumPlayerData.Players) { + String fileType = ".json"; + if (ConfigMain.DatFormat) { + fileType = ".dat"; + } File file = new File(PlayerDataController.Instance.getSaveDir(), playerdata.uuid + fileType); - if(file.exists()) - file.delete(); - if(pl != null){ - PlayerDataController.Instance.removePlayerDataCache(pl.getUniqueID().toString()); + if (file.exists()) + file.delete(); + if (pl != null) { + PlayerDataController.Instance.removePlayerDataCache(pl.getUniqueID().toString()); - PlayerDataController.Instance.nameUUIDs.remove(name); - PlayerDataController.Instance.savePlayerDataMap(); + PlayerDataController.Instance.nameUUIDs.remove(name); + PlayerDataController.Instance.savePlayerDataMap(); - playerdata.setNBT(new NBTTagCompound()); + playerdata.setNBT(new NBTTagCompound()); sendPlayerData(type, player, name); playerdata.save(); return; } } - if(type == EnumPlayerData.Quest){ - PlayerQuestData data = playerdata.questData; - int questId = buffer.readInt(); - data.activeQuests.remove(questId); - data.finishedQuests.remove(questId); + if (type == EnumPlayerData.Quest) { + PlayerQuestData data = playerdata.questData; + int questId = buffer.readInt(); + data.activeQuests.remove(questId); + data.finishedQuests.remove(questId); playerdata.save(); } - if(type == EnumPlayerData.Dialog){ - PlayerDialogData data = playerdata.dialogData; - data.dialogsRead.remove(buffer.readInt()); + if (type == EnumPlayerData.Dialog) { + PlayerDialogData data = playerdata.dialogData; + data.dialogsRead.remove(buffer.readInt()); playerdata.save(); } - if(type == EnumPlayerData.Transport){ - PlayerTransportData data = playerdata.transportData; - data.transports.remove(buffer.readInt()); + if (type == EnumPlayerData.Transport) { + PlayerTransportData data = playerdata.transportData; + data.transports.remove(buffer.readInt()); playerdata.save(); } - if(type == EnumPlayerData.Bank){ - PlayerBankData data = playerdata.bankData; - data.banks.remove(buffer.readInt()); + if (type == EnumPlayerData.Bank) { + PlayerBankData data = playerdata.bankData; + data.banks.remove(buffer.readInt()); playerdata.save(); } - if(type == EnumPlayerData.Factions){ - PlayerFactionData data = playerdata.factionData; - data.factionData.remove(buffer.readInt()); + if (type == EnumPlayerData.Factions) { + PlayerFactionData data = playerdata.factionData; + data.factionData.remove(buffer.readInt()); playerdata.save(); } - if(type == EnumPlayerData.Magic){ + if (type == EnumPlayerData.Magic) { MagicData data = playerdata.magicData; data.removeMagic(buffer.readInt()); playerdata.save(); } - if(pl != null) { + if (pl != null) { SyncController.syncPlayer((EntityPlayerMP) pl); } sendPlayerData(type, player, name); - } + } - public static void regenPlayerData(EntityPlayerMP player) throws IOException { - PlayerDataController.Instance.generatePlayerMap(player); - } + public static void regenPlayerData(EntityPlayerMP player) throws IOException { + PlayerDataController.Instance.generatePlayerMap(player); + } - public static void sendRecipeData(EntityPlayerMP player, int size) { - HashMap map = new HashMap(); - if(size == 3){ - for(RecipeCarpentry recipe : RecipeController.Instance.globalRecipes.values()){ - map.put(recipe.name, recipe.id); - } - } else if (size == 4){ - for(RecipeCarpentry recipe : RecipeController.Instance.carpentryRecipes.values()){ + public static void sendRecipeData(EntityPlayerMP player, int size) { + HashMap map = new HashMap(); + if (size == 3) { + for (RecipeCarpentry recipe : RecipeController.Instance.globalRecipes.values()) { + map.put(recipe.name, recipe.id); + } + } else if (size == 4) { + for (RecipeCarpentry recipe : RecipeController.Instance.carpentryRecipes.values()) { + map.put(recipe.name, recipe.id); + } + } else { + for (RecipeAnvil recipe : RecipeController.Instance.anvilRecipes.values()) { map.put(recipe.name, recipe.id); } } - else{ - for(RecipeAnvil recipe : RecipeController.Instance.anvilRecipes.values()){ - map.put(recipe.name, recipe.id); - } - } - sendScrollData(player, map, EnumScrollData.OPTIONAL); - } + sendScrollData(player, map, EnumScrollData.OPTIONAL); + } - public static void sendDialogData(EntityPlayerMP player, DialogCategory category) { - if(category == null) - return; - HashMap map = new HashMap(); - for(Dialog dialog : category.dialogs.values()){ - map.put(dialog.title, dialog.id); - } - sendScrollData(player, map, EnumScrollData.OPTIONAL); - } + public static void sendDialogData(EntityPlayerMP player, DialogCategory category) { + if (category == null) + return; + HashMap map = new HashMap(); + for (Dialog dialog : category.dialogs.values()) { + map.put(dialog.title, dialog.id); + } + sendScrollData(player, map, EnumScrollData.OPTIONAL); + } - public static void sendDialogGroup(EntityPlayerMP player, DialogCategory category) { - if(category == null) - return; - HashMap map = new HashMap(); - for(Dialog dialog : category.dialogs.values()){ - map.put(dialog.title, dialog.id); - } + public static void sendDialogGroup(EntityPlayerMP player, DialogCategory category) { + if (category == null) + return; + HashMap map = new HashMap(); + for (Dialog dialog : category.dialogs.values()) { + map.put(dialog.title, dialog.id); + } sendScrollData(player, map, EnumScrollData.DIALOG_GROUP); - } + } - public static void sendQuestData(EntityPlayerMP player, QuestCategory category) { - if(category == null) - return; - HashMap map = new HashMap(); - for(Quest quest : category.quests.values()){ - map.put(quest.title, quest.id); - } - sendScrollData(player, map, EnumScrollData.OPTIONAL); - } + public static void sendQuestData(EntityPlayerMP player, QuestCategory category) { + if (category == null) + return; + HashMap map = new HashMap(); + for (Quest quest : category.quests.values()) { + map.put(quest.title, quest.id); + } + sendScrollData(player, map, EnumScrollData.OPTIONAL); + } - public static void sendQuestGroup(EntityPlayerMP player, QuestCategory category) { - if(category == null) - return; - HashMap map = new HashMap(); - for(Quest quest : category.quests.values()){ - map.put(quest.title, quest.id); - } + public static void sendQuestGroup(EntityPlayerMP player, QuestCategory category) { + if (category == null) + return; + HashMap map = new HashMap(); + for (Quest quest : category.quests.values()) { + map.put(quest.title, quest.id); + } sendScrollData(player, map, EnumScrollData.QUEST_GROUP); - } + } public static void sendCustomEffectDataAll(EntityPlayerMP player) { Map map = new HashMap(); @@ -682,220 +668,219 @@ public class NoppesUtilServer { ScrollDataPacket.sendScrollData(player, map, EnumScrollData.OPTIONAL); } - public static void sendTransportCategoryData(EntityPlayerMP player) { - HashMap map = new HashMap(); - for(TransportCategory category : TransportController.getInstance().categories.values()){ - map.put(category.title, category.id); - } - sendScrollData(player, map, EnumScrollData.OPTIONAL); - } + public static void sendTransportCategoryData(EntityPlayerMP player) { + HashMap map = new HashMap(); + for (TransportCategory category : TransportController.getInstance().categories.values()) { + map.put(category.title, category.id); + } + sendScrollData(player, map, EnumScrollData.OPTIONAL); + } - public static void sendTransportData(EntityPlayerMP player, int categoryid) { - TransportCategory category = TransportController.getInstance().categories.get(categoryid); - if(category == null) - return; - HashMap map = new HashMap(); - for(TransportLocation transport : category.locations.values()){ - map.put(transport.name, transport.id); - } - sendScrollData(player, map, EnumScrollData.OPTIONAL); - } + public static void sendTransportData(EntityPlayerMP player, int categoryid) { + TransportCategory category = TransportController.getInstance().categories.get(categoryid); + if (category == null) + return; + HashMap map = new HashMap(); + for (TransportLocation transport : category.locations.values()) { + map.put(transport.name, transport.id); + } + sendScrollData(player, map, EnumScrollData.OPTIONAL); + } - public static void sendNpcDialogs(EntityPlayer player) { - EntityNPCInterface npc = getEditingNpc(player); - if(npc == null) - return; - for(int pos : npc.dialogs.keySet()){ - DialogOption option = npc.dialogs.get(pos); - if(option == null || !option.hasDialog()) - continue; + public static void sendNpcDialogs(EntityPlayer player) { + EntityNPCInterface npc = getEditingNpc(player); + if (npc == null) + return; + for (int pos : npc.dialogs.keySet()) { + DialogOption option = npc.dialogs.get(pos); + if (option == null || !option.hasDialog()) + continue; - NBTTagCompound compound = option.writeNBT(); - compound.setInteger("Position", pos); - GuiDataPacket.sendGuiData((EntityPlayerMP)player, compound); - } - } + NBTTagCompound compound = option.writeNBT(); + compound.setInteger("Position", pos); + GuiDataPacket.sendGuiData((EntityPlayerMP) player, compound); + } + } public static void sendMagicInfo(EntityPlayerMP player, boolean cycles) { - HashMap map = new HashMap(); - if(cycles){ - for(Magic magic : MagicController.getInstance().magics.values()){ + HashMap map = new HashMap(); + if (cycles) { + for (Magic magic : MagicController.getInstance().magics.values()) { map.put(magic.name, magic.id); } sendScrollData(player, map, EnumScrollData.MAGIC); } else { - for(MagicCycle magicCycle : MagicController.getInstance().cycles.values()){ + for (MagicCycle magicCycle : MagicController.getInstance().cycles.values()) { map.put(magicCycle.name, magicCycle.id); } sendScrollData(player, map, EnumScrollData.MAGIC_CYCLES); } } - public static DialogOption setNpcDialog(int slot, int dialogId, EntityPlayer player) throws IOException { - return setNpcDialog(slot, dialogId, getEditingNpc(player)); - } + public static DialogOption setNpcDialog(int slot, int dialogId, EntityPlayer player) throws IOException { + return setNpcDialog(slot, dialogId, getEditingNpc(player)); + } - public static DialogOption setNpcDialog(int slot, int dialogId, EntityNPCInterface npc) { - if(npc == null) - return null; - if(!npc.dialogs.containsKey(slot)) - npc.dialogs.put(slot, new DialogOption()); + public static DialogOption setNpcDialog(int slot, int dialogId, EntityNPCInterface npc) { + if (npc == null) + return null; + if (!npc.dialogs.containsKey(slot)) + npc.dialogs.put(slot, new DialogOption()); - DialogOption option = npc.dialogs.get(slot); - option.dialogId = dialogId; - if(option.hasDialog()) - option.title = option.getDialog().title; + DialogOption option = npc.dialogs.get(slot); + option.dialogId = dialogId; + if (option.hasDialog()) + option.title = option.getDialog().title; - return option; - } + return option; + } - public static void saveTileEntity(EntityPlayerMP player, NBTTagCompound compound){ - int x = compound.getInteger("x"); - int y = compound.getInteger("y"); - int z = compound.getInteger("z"); + public static void saveTileEntity(EntityPlayerMP player, NBTTagCompound compound) { + int x = compound.getInteger("x"); + int y = compound.getInteger("y"); + int z = compound.getInteger("z"); - TileEntity tile = player.worldObj.getTileEntity(x, y, z); - if(tile != null) - tile.readFromNBT(compound); + TileEntity tile = player.worldObj.getTileEntity(x, y, z); + if (tile != null) + tile.readFromNBT(compound); - } + } - public static void setClonerGui(EntityPlayerMP player, int x, int y, int z){ - if(player == null) + public static void setClonerGui(EntityPlayerMP player, int x, int y, int z) { + if (player == null) return; GuiOpenPacket.openGUI(player, EnumGuiType.Cloner, x, y, z); } - public static void setTeleporterGUI(EntityPlayerMP player){ - if(player == null) + public static void setTeleporterGUI(EntityPlayerMP player) { + if (player == null) return; PacketHandler.Instance.sendToPlayer(new GuiTeleporterPacket(), player); } - public static void setRecipeGui(EntityPlayerMP player, RecipeCarpentry recipe){ - if(recipe == null) - return; - if(!(player.openContainer instanceof ContainerManageRecipes)) - return; - - ContainerManageRecipes container = (ContainerManageRecipes) player.openContainer; - container.setRecipe(recipe); - GuiDataPacket.sendGuiData((EntityPlayerMP)player, recipe.writeNBT()); - } - - public static void setRecipeAnvilGui(EntityPlayerMP player, RecipeAnvil recipe){ - if(recipe == null) + public static void setRecipeGui(EntityPlayerMP player, RecipeCarpentry recipe) { + if (recipe == null) return; - if(!(player.openContainer instanceof ContainerManageRecipes)) + if (!(player.openContainer instanceof ContainerManageRecipes)) return; ContainerManageRecipes container = (ContainerManageRecipes) player.openContainer; container.setRecipe(recipe); - GuiDataPacket.sendGuiData((EntityPlayerMP)player, recipe.writeNBT()); + GuiDataPacket.sendGuiData((EntityPlayerMP) player, recipe.writeNBT()); } - public static void sendBank(EntityPlayerMP player,Bank bank) { - NBTTagCompound compound = new NBTTagCompound(); - bank.writeEntityToNBT(compound); - GuiDataPacket.sendGuiData((EntityPlayerMP)player, compound); + public static void setRecipeAnvilGui(EntityPlayerMP player, RecipeAnvil recipe) { + if (recipe == null) + return; + if (!(player.openContainer instanceof ContainerManageRecipes)) + return; - if(player.openContainer instanceof ContainerManageBanks){ - ((ContainerManageBanks)player.openContainer).setBank(bank); - } - player.sendContainerAndContentsToPlayer(player.openContainer, player.openContainer.getInventory()); - } + ContainerManageRecipes container = (ContainerManageRecipes) player.openContainer; + container.setRecipe(recipe); + GuiDataPacket.sendGuiData((EntityPlayerMP) player, recipe.writeNBT()); + } - public static void sendNearbyNpcs(EntityPlayerMP player) { - List npcs = player.worldObj.getEntitiesWithinAABB(EntityNPCInterface.class, player.boundingBox.expand(120, 120, 120)); - HashMap map = new HashMap(); - for(EntityNPCInterface npc : npcs){ - if(npc.isDead) - continue; - float distance = player.getDistanceToEntity(npc); - DecimalFormat df = new DecimalFormat("#.#"); - String s = df.format(distance); - if(distance < 10) - s = "0" + s; - map.put(s + " : " + npc.display.name, npc.getEntityId()); - } + public static void sendBank(EntityPlayerMP player, Bank bank) { + NBTTagCompound compound = new NBTTagCompound(); + bank.writeEntityToNBT(compound); + GuiDataPacket.sendGuiData((EntityPlayerMP) player, compound); - sendScrollData(player, map, EnumScrollData.OPTIONAL); - } + if (player.openContainer instanceof ContainerManageBanks) { + ((ContainerManageBanks) player.openContainer).setBank(bank); + } + player.sendContainerAndContentsToPlayer(player.openContainer, player.openContainer.getInventory()); + } - public static void sendGuiError(EntityPlayer player, int i) { - GuiErrorPacket.errorGUI((EntityPlayerMP)player, i, new NBTTagCompound()); - } + public static void sendNearbyNpcs(EntityPlayerMP player) { + List npcs = player.worldObj.getEntitiesWithinAABB(EntityNPCInterface.class, player.boundingBox.expand(120, 120, 120)); + HashMap map = new HashMap(); + for (EntityNPCInterface npc : npcs) { + if (npc.isDead) + continue; + float distance = player.getDistanceToEntity(npc); + DecimalFormat df = new DecimalFormat("#.#"); + String s = df.format(distance); + if (distance < 10) + s = "0" + s; + map.put(s + " : " + npc.display.name, npc.getEntityId()); + } - public static void sendGuiClose(EntityPlayerMP player, int i, NBTTagCompound comp) { - if(player.openContainer != player.inventoryContainer){ - player.openContainer = player.inventoryContainer; - } + sendScrollData(player, map, EnumScrollData.OPTIONAL); + } + + public static void sendGuiError(EntityPlayer player, int i) { + GuiErrorPacket.errorGUI((EntityPlayerMP) player, i, new NBTTagCompound()); + } + + public static void sendGuiClose(EntityPlayerMP player, int i, NBTTagCompound comp) { + if (player.openContainer != player.inventoryContainer) { + player.openContainer = player.inventoryContainer; + } GuiClosePacket.closeGUI(player, i, comp); - } + } - public static Entity spawnCloneWithProtection(NBTTagCompound compound, int x, int y, - int z, World worldObj) { - ServerCloneController.Instance.cleanTags(compound); - compound.setTag("Pos", NBTTags.nbtDoubleList(x + 0.5, y, z + 0.5)); - Entity entity = EntityList.createEntityFromNBT(compound, worldObj); - if(entity == null){ - return null; - } - entity.setPosition((double) x + 0.5, (double) y, (double) z + 0.5); - if(entity instanceof EntityNPCInterface){ - EntityNPCInterface npc = (EntityNPCInterface) entity; - npc.ais.startPos = new int[]{MathHelper.floor_double(npc.posX),MathHelper.floor_double(npc.posY),MathHelper.floor_double(npc.posZ)}; - npc.ticksExisted = 0; - npc.totalTicksAlive = 0; - } - worldObj.spawnEntityInWorld(entity); - entity.prevPosY = entity.lastTickPosY = entity.posY = y + 1; - return entity; - } + public static Entity spawnCloneWithProtection(NBTTagCompound compound, int x, int y, + int z, World worldObj) { + ServerCloneController.Instance.cleanTags(compound); + compound.setTag("Pos", NBTTags.nbtDoubleList(x + 0.5, y, z + 0.5)); + Entity entity = EntityList.createEntityFromNBT(compound, worldObj); + if (entity == null) { + return null; + } + entity.setPosition((double) x + 0.5, (double) y, (double) z + 0.5); + if (entity instanceof EntityNPCInterface) { + EntityNPCInterface npc = (EntityNPCInterface) entity; + npc.ais.startPos = new int[]{MathHelper.floor_double(npc.posX), MathHelper.floor_double(npc.posY), MathHelper.floor_double(npc.posZ)}; + npc.ticksExisted = 0; + npc.totalTicksAlive = 0; + } + worldObj.spawnEntityInWorld(entity); + entity.prevPosY = entity.lastTickPosY = entity.posY = y + 1; + return entity; + } - public static Entity getEntityFromNBT(NBTTagCompound compound, int x, int y, - int z, World worldObj) { - ServerCloneController.Instance.cleanTags(compound); - compound.setTag("Pos", NBTTags.nbtDoubleList(x + 0.5, y + 1, z + 0.5)); - Entity entity = EntityList.createEntityFromNBT(compound, worldObj); - if(entity == null){ - return null; - } - if(entity instanceof EntityNPCInterface){ - EntityNPCInterface npc = (EntityNPCInterface) entity; - npc.ais.startPos = new int[]{MathHelper.floor_double(npc.posX),MathHelper.floor_double(npc.posY),MathHelper.floor_double(npc.posZ)}; - npc.ticksExisted = 0; - npc.totalTicksAlive = 0; - } - return entity; - } + public static Entity getEntityFromNBT(NBTTagCompound compound, int x, int y, + int z, World worldObj) { + ServerCloneController.Instance.cleanTags(compound); + compound.setTag("Pos", NBTTags.nbtDoubleList(x + 0.5, y + 1, z + 0.5)); + Entity entity = EntityList.createEntityFromNBT(compound, worldObj); + if (entity == null) { + return null; + } + if (entity instanceof EntityNPCInterface) { + EntityNPCInterface npc = (EntityNPCInterface) entity; + npc.ais.startPos = new int[]{MathHelper.floor_double(npc.posX), MathHelper.floor_double(npc.posY), MathHelper.floor_double(npc.posZ)}; + npc.ticksExisted = 0; + npc.totalTicksAlive = 0; + } + return entity; + } - public static Entity spawnClone(NBTTagCompound compound, int x, int y, - int z, World worldObj) { - Entity entity = getEntityFromNBT(compound,x,y,z,worldObj); - if(entity == null){ - return null; - } + public static Entity spawnClone(NBTTagCompound compound, int x, int y, + int z, World worldObj) { + Entity entity = getEntityFromNBT(compound, x, y, z, worldObj); + if (entity == null) { + return null; + } - entity.dimension = worldObj.provider.dimensionId; - int i = MathHelper.floor_double(entity.posX / 16.0D); - int j = MathHelper.floor_double(entity.posZ / 16.0D); - if (!entity.forceSpawn && !worldObj.checkChunksExist( - (int)entity.posX,(int)entity.posY,(int)entity.posZ,(int)entity.posX,(int)entity.posY,(int)entity.posZ)) { - return null; - } - else { - worldObj.getChunkFromChunkCoords(i, j).addEntity(entity); - worldObj.loadedEntityList.add(entity); - worldObj.onEntityAdded(entity); - return entity; - } - } + entity.dimension = worldObj.provider.dimensionId; + int i = MathHelper.floor_double(entity.posX / 16.0D); + int j = MathHelper.floor_double(entity.posZ / 16.0D); + if (!entity.forceSpawn && !worldObj.checkChunksExist( + (int) entity.posX, (int) entity.posY, (int) entity.posZ, (int) entity.posX, (int) entity.posY, (int) entity.posZ)) { + return null; + } else { + worldObj.getChunkFromChunkCoords(i, j).addEntity(entity); + worldObj.loadedEntityList.add(entity); + worldObj.onEntityAdded(entity); + return entity; + } + } public static boolean isOp(EntityPlayer player) { - return MinecraftServer.getServer().getConfigurationManager().func_152596_g(player.getGameProfile()); - } + return MinecraftServer.getServer().getConfigurationManager().func_152596_g(player.getGameProfile()); + } public static void GivePlayerItem(Entity entity, EntityPlayer player, ItemStack item) { @@ -908,7 +893,7 @@ public class NoppesUtilServer { double d1 = (double) (entity.worldObj.rand.nextFloat() * f) + (double) (1.0F - f); double d2 = (double) (entity.worldObj.rand.nextFloat() * f) + (double) (1.0F - f); EntityItem entityitem = new EntityItem(entity.worldObj, entity.posX + d, entity.posY + d1, entity.posZ + d2, - item); + item); entityitem.delayBeforeCanPickup = 2; entity.worldObj.spawnEntityInWorld(entityitem); @@ -916,7 +901,7 @@ public class NoppesUtilServer { if (player.inventory.addItemStackToInventory(item)) { entity.worldObj.playSoundAtEntity(entityitem, "random.pop", 0.2F, - ((entity.worldObj.rand.nextFloat() - entity.worldObj.rand.nextFloat()) * 0.7F + 1.0F) * 2.0F); + ((entity.worldObj.rand.nextFloat() - entity.worldObj.rand.nextFloat()) * 0.7F + 1.0F) * 2.0F); player.onItemPickup(entityitem, i); if (item.stackSize <= 0) { @@ -924,14 +909,15 @@ public class NoppesUtilServer { } } } - public static EntityPlayer getPlayer(UUID id) { - List list = MinecraftServer.getServer().getConfigurationManager().playerEntityList; - for(EntityPlayer player : list){ - if(id.equals(player.getUniqueID())) - return player; - } + + public static EntityPlayer getPlayer(UUID id) { + List list = MinecraftServer.getServer().getConfigurationManager().playerEntityList; + for (EntityPlayer player : list) { + if (id.equals(player.getUniqueID())) + return player; + } return null; - } + } public static Entity getEntityFromUUID(World world, UUID uuid) { for (Object obj : world.loadedEntityList) { @@ -945,57 +931,57 @@ public class NoppesUtilServer { return null; } - static public EntityPlayer getPlayerByName(String playername){ - return MinecraftServer.getServer().getConfigurationManager().func_152612_a(playername); - } + static public EntityPlayer getPlayerByName(String playername) { + return MinecraftServer.getServer().getConfigurationManager().func_152612_a(playername); + } - public static Entity GetDamageSource(DamageSource damagesource) { - Entity entity = damagesource.getEntity(); - if(entity == null) { - entity = damagesource.getSourceOfDamage(); - } + public static Entity GetDamageSource(DamageSource damagesource) { + Entity entity = damagesource.getEntity(); + if (entity == null) { + entity = damagesource.getSourceOfDamage(); + } - if(entity instanceof EntityArrow && ((EntityArrow)entity).shootingEntity instanceof EntityLivingBase) { - entity = ((EntityArrow)entity).shootingEntity; - } else if(entity instanceof EntityThrowable) { - entity = ((EntityThrowable)entity).getThrower(); - } + if (entity instanceof EntityArrow && ((EntityArrow) entity).shootingEntity instanceof EntityLivingBase) { + entity = ((EntityArrow) entity).shootingEntity; + } else if (entity instanceof EntityThrowable) { + entity = ((EntityThrowable) entity).getThrower(); + } - return entity; - } + return entity; + } - public static void isGUIOpen(ByteBuf buffer, EntityPlayer player) throws IOException { - PlayerData playerdata = PlayerDataController.Instance.getPlayerData(player); - boolean isGUIOpen = buffer.readBoolean(); - playerdata.setGUIOpen(isGUIOpen); - } + public static void isGUIOpen(ByteBuf buffer, EntityPlayer player) throws IOException { + PlayerData playerdata = PlayerDataController.Instance.getPlayerData(player); + boolean isGUIOpen = buffer.readBoolean(); + playerdata.setGUIOpen(isGUIOpen); + } - public static boolean IsItemStackNull(ItemStack is) { - return is == null || is.stackSize == 0 || is.getItem() == null; - } + public static boolean IsItemStackNull(ItemStack is) { + return is == null || is.stackSize == 0 || is.getItem() == null; + } - public static String millisToTime(long millis) { - long seconds = millis / 1000; - long minutes = seconds / 60; - long hours = minutes / 60; - long days = hours / 24; - seconds %= 60; - minutes %= 60; - hours %= 24; + public static String millisToTime(long millis) { + long seconds = millis / 1000; + long minutes = seconds / 60; + long hours = minutes / 60; + long days = hours / 24; + seconds %= 60; + minutes %= 60; + hours %= 24; - StringBuilder sb = new StringBuilder(); - if (days > 0) { - sb.append(days).append(" day").append(days == 1 ? "" : "s").append(", "); - } - if (hours > 0) { - sb.append(hours).append(" hour").append(hours == 1 ? "" : "s").append(", "); - } - if (minutes > 0) { - sb.append(minutes).append(" minute").append(minutes == 1 ? "" : "s").append(", "); - } - sb.append(seconds).append(" second").append(seconds == 1 ? "" : "s"); - return sb.toString(); - } + StringBuilder sb = new StringBuilder(); + if (days > 0) { + sb.append(days).append(" day").append(days == 1 ? "" : "s").append(", "); + } + if (hours > 0) { + sb.append(hours).append(" hour").append(hours == 1 ? "" : "s").append(", "); + } + if (minutes > 0) { + sb.append(minutes).append(" minute").append(minutes == 1 ? "" : "s").append(", "); + } + sb.append(seconds).append(" second").append(seconds == 1 ? "" : "s"); + return sb.toString(); + } /** * Retrieves the player's data from the existing PlayerDataController and sends @@ -1004,7 +990,7 @@ public class NoppesUtilServer { public static void sendPlayerDataInfo(String playerName, EntityPlayerMP player) { PlayerData playerdata; EntityPlayer pl = MinecraftServer.getServer().getConfigurationManager().func_152612_a(playerName); - if(pl == null) + if (pl == null) playerdata = PlayerDataController.Instance.getDataFromUsername(playerName); else playerdata = PlayerDataController.Instance.getPlayerData(pl); @@ -1016,7 +1002,7 @@ public class NoppesUtilServer { QuestController qc = QuestController.Instance; PlayerQuestData qData = playerdata.questData; for (Integer questId : qData.activeQuests.keySet()) { - if(!qc.quests.containsKey(questId)) + if (!qc.quests.containsKey(questId)) continue; Quest quest = qc.quests.get(questId); questActiveMap.put(quest.category.title + ": " + quest.title, questId); @@ -1024,7 +1010,7 @@ public class NoppesUtilServer { questCategoriesMap.put(quest.category.title, quest.category.id); } for (Integer questId : qData.finishedQuests.keySet()) { - if(!qc.quests.containsKey(questId)) + if (!qc.quests.containsKey(questId)) continue; Quest quest = qc.quests.get(questId); questFinishedMap.put(quest.category.title + ": " + quest.title, questId); @@ -1037,7 +1023,7 @@ public class NoppesUtilServer { Map dialogCategoriesMap = new HashMap<>(); PlayerDialogData dData = playerdata.dialogData; for (Integer dialogId : dData.dialogsRead) { - if(!DialogController.Instance.dialogs.containsKey(dialogId)) + if (!DialogController.Instance.dialogs.containsKey(dialogId)) continue; Dialog dialog = DialogController.Instance.dialogs.get(dialogId); dialogReadMap.put(dialog.category.title + ": " + dialog.title, dialogId); @@ -1052,7 +1038,7 @@ public class NoppesUtilServer { TransportController tc = TransportController.getInstance(); for (Integer id : tData.transports) { TransportLocation location = tc.getTransport(id); - if(location == null) + if (location == null) continue; transportLocationsMap.put(location.category.title + ": " + location.name, id); if (!transportCategoriesMap.containsKey(location.category.title)) @@ -1064,7 +1050,7 @@ public class NoppesUtilServer { PlayerBankData bData = playerdata.bankData; BankController bc = BankController.getInstance(); for (Integer bankId : bData.banks.keySet()) { - if(!bc.banks.containsKey(bankId)) + if (!bc.banks.containsKey(bankId)) continue; Bank bank = bc.banks.get(bankId); bankMap.put(bank.name, bankId); @@ -1075,7 +1061,7 @@ public class NoppesUtilServer { PlayerFactionData fData = playerdata.factionData; FactionController fc = FactionController.getInstance(); for (Integer factionId : fData.factionData.keySet()) { - if(!fc.factions.containsKey(factionId)) + if (!fc.factions.containsKey(factionId)) continue; Faction faction = fc.factions.get(factionId); factionMap.put(faction.name + "(" + fData.getFactionPoints(factionId) + ")", factionId); @@ -1092,15 +1078,15 @@ public class NoppesUtilServer { /** * Removes a specific data entry from the player's data. - * + *

* The tabType parameter is used as follows: - * 0: Quest – remove from both activeQuests and finishedQuests. - * 1: Dialog – remove from dialogsRead. - * 2: Transport – remove from transports. - * 3: Bank – remove from banks. - * 4: Factions – remove from factionData. - * 5: Magic - remove from magicData. - * + * 0: Quest – remove from both activeQuests and finishedQuests. + * 1: Dialog – remove from dialogsRead. + * 2: Transport – remove from transports. + * 3: Bank – remove from banks. + * 4: Factions – remove from factionData. + * 5: Magic - remove from magicData. + *

* The selectedKey is expected to be the string representation of the entry's ID. */ public static void removePlayerDataInfo(String playerName, int tabType, int value, EntityPlayerMP player) { @@ -1108,47 +1094,47 @@ public class NoppesUtilServer { PlayerData playerdata; EnumPlayerData enumPlayerData = EnumPlayerData.values()[tabType]; - if(pl == null) + if (pl == null) playerdata = PlayerDataController.Instance.getDataFromUsername(playerName); else playerdata = PlayerDataController.Instance.getPlayerData(pl); - if(enumPlayerData == EnumPlayerData.Quest) { // Quest removal + if (enumPlayerData == EnumPlayerData.Quest) { // Quest removal playerdata.questData.activeQuests.remove(value); playerdata.questData.finishedQuests.remove(value); } - if(enumPlayerData == EnumPlayerData.Dialog){ // Dialog removal + if (enumPlayerData == EnumPlayerData.Dialog) { // Dialog removal playerdata.dialogData.dialogsRead.remove(value); } - if(enumPlayerData == EnumPlayerData.Transport) { // Transport removal + if (enumPlayerData == EnumPlayerData.Transport) { // Transport removal playerdata.transportData.transports.remove(value); } - if(enumPlayerData == EnumPlayerData.Bank) { // Bank removal + if (enumPlayerData == EnumPlayerData.Bank) { // Bank removal playerdata.bankData.banks.remove(value); } - if(enumPlayerData == EnumPlayerData.Factions) { // Faction removal + if (enumPlayerData == EnumPlayerData.Factions) { // Faction removal playerdata.factionData.factionData.remove(value); } - if(enumPlayerData == EnumPlayerData.Magic) { // Faction removal + if (enumPlayerData == EnumPlayerData.Magic) { // Faction removal playerdata.magicData.removeMagic(value); } playerdata.save(); - if(pl != null) { + if (pl != null) { SyncController.syncPlayer((EntityPlayerMP) pl); } } /** * Removes a specific data entry from the player's data. - * + *

* The tabType parameter is used as follows: - * 0: Quest – remove from both activeQuests and finishedQuests. - * 1: Dialog – remove from dialogsRead. - * 2: Transport – remove from transports. - * 3: Bank – remove from banks. - * 4: Factions – remove from factionData. - * + * 0: Quest – remove from both activeQuests and finishedQuests. + * 1: Dialog – remove from dialogsRead. + * 2: Transport – remove from transports. + * 3: Bank – remove from banks. + * 4: Factions – remove from factionData. + *

* The selectedKey is expected to be the string representation of the entry's ID. */ public static void savePlayerDataInfo(String playerName, int tabType, NBTTagCompound compound, EntityPlayerMP player) { @@ -1156,17 +1142,17 @@ public class NoppesUtilServer { PlayerData playerdata; EnumPlayerData enumPlayerData = EnumPlayerData.values()[tabType]; - if(pl == null) + if (pl == null) playerdata = PlayerDataController.Instance.getDataFromUsername(playerName); else playerdata = PlayerDataController.Instance.getPlayerData(pl); - if(enumPlayerData == EnumPlayerData.Magic) { // Quest removal + if (enumPlayerData == EnumPlayerData.Magic) { // Quest removal playerdata.magicData.readToNBT(compound); } playerdata.save(); - if(pl != null) { + if (pl != null) { SyncController.syncPlayer((EntityPlayerMP) pl); } } diff --git a/src/main/java/noppes/npcs/NpcDamageSource.java b/src/main/java/noppes/npcs/NpcDamageSource.java index 6a69adcf9..32559eaee 100644 --- a/src/main/java/noppes/npcs/NpcDamageSource.java +++ b/src/main/java/noppes/npcs/NpcDamageSource.java @@ -3,15 +3,14 @@ package noppes.npcs; import net.minecraft.entity.Entity; import net.minecraft.util.EntityDamageSource; -public class NpcDamageSource extends EntityDamageSource{ +public class NpcDamageSource extends EntityDamageSource { - public NpcDamageSource(String par1Str, Entity par2Entity) { - super(par1Str, par2Entity); - } + public NpcDamageSource(String par1Str, Entity par2Entity) { + super(par1Str, par2Entity); + } - @Override - public boolean isDifficultyScaled() - { - return false; + @Override + public boolean isDifficultyScaled() { + return false; } } diff --git a/src/main/java/noppes/npcs/NpcDamageSourceInderect.java b/src/main/java/noppes/npcs/NpcDamageSourceInderect.java index 702d85d26..0623ab019 100644 --- a/src/main/java/noppes/npcs/NpcDamageSourceInderect.java +++ b/src/main/java/noppes/npcs/NpcDamageSourceInderect.java @@ -3,15 +3,14 @@ package noppes.npcs; import net.minecraft.entity.Entity; import net.minecraft.util.EntityDamageSourceIndirect; -public class NpcDamageSourceInderect extends EntityDamageSourceIndirect{ +public class NpcDamageSourceInderect extends EntityDamageSourceIndirect { - public NpcDamageSourceInderect(String par1Str, Entity par2Entity, Entity par3Entity) { - super(par1Str, par2Entity, par3Entity); - } + public NpcDamageSourceInderect(String par1Str, Entity par2Entity, Entity par3Entity) { + super(par1Str, par2Entity, par3Entity); + } - @Override - public boolean isDifficultyScaled() - { - return false; + @Override + public boolean isDifficultyScaled() { + return false; } } diff --git a/src/main/java/noppes/npcs/NpcMiscInventory.java b/src/main/java/noppes/npcs/NpcMiscInventory.java index cb55f45b8..976030ef5 100644 --- a/src/main/java/noppes/npcs/NpcMiscInventory.java +++ b/src/main/java/noppes/npcs/NpcMiscInventory.java @@ -8,167 +8,170 @@ import net.minecraft.nbt.NBTTagCompound; import java.util.HashMap; public class NpcMiscInventory implements IInventory { - public HashMap items = new HashMap(); - public int stackLimit = 64; + public HashMap items = new HashMap(); + public int stackLimit = 64; - private int size; - - public NpcMiscInventory(int size){ - this.size = size; - } - - public NBTTagCompound getToNBT(){ - NBTTagCompound nbttagcompound = new NBTTagCompound(); - nbttagcompound.setTag("NpcMiscInv", NBTTags.nbtItemStackList(items)); - return nbttagcompound; - } - public void setFromNBT(NBTTagCompound nbttagcompound){ - items = NBTTags.getItemStackList(nbttagcompound.getTagList("NpcMiscInv", 10)); - } - @Override - public int getSizeInventory() { - return size; - } + private int size; - @Override - public ItemStack getStackInSlot(int var1) { - return items.get(var1); - } + public NpcMiscInventory(int size) { + this.size = size; + } - @Override - public ItemStack decrStackSize(int par1, int par2) { + public NBTTagCompound getToNBT() { + NBTTagCompound nbttagcompound = new NBTTagCompound(); + nbttagcompound.setTag("NpcMiscInv", NBTTags.nbtItemStackList(items)); + return nbttagcompound; + } + + public void setFromNBT(NBTTagCompound nbttagcompound) { + items = NBTTags.getItemStackList(nbttagcompound.getTagList("NpcMiscInv", 10)); + } + + @Override + public int getSizeInventory() { + return size; + } + + @Override + public ItemStack getStackInSlot(int var1) { + return items.get(var1); + } + + @Override + public ItemStack decrStackSize(int par1, int par2) { if (items.get(par1) == null) - return null; + return null; ItemStack var4 = null; - if (items.get(par1).stackSize <= par2){ + if (items.get(par1).stackSize <= par2) { var4 = items.get(par1); - items.put(par1,null); - } - else{ + items.put(par1, null); + } else { var4 = items.get(par1).splitStack(par2); - if (items.get(par1).stackSize == 0){ - items.put(par1,null); + if (items.get(par1).stackSize == 0) { + items.put(par1, null); } } - - return var4; - } + + return var4; + } - public boolean decrStackSize(ItemStack eating, int decrease) { - for(int slot : items.keySet()){ - ItemStack item = items.get(slot); - if(items != null && eating == item && item.stackSize >= decrease){ - item.splitStack(decrease); - if(item.stackSize <= 0) - items.put(slot, null); - return true; - } - } - return false; - } - - @Override - public ItemStack getStackInSlotOnClosing(int var1) { - if (items.get(var1) != null) - { + public boolean decrStackSize(ItemStack eating, int decrease) { + for (int slot : items.keySet()) { + ItemStack item = items.get(slot); + if (items != null && eating == item && item.stackSize >= decrease) { + item.splitStack(decrease); + if (item.stackSize <= 0) + items.put(slot, null); + return true; + } + } + return false; + } + + @Override + public ItemStack getStackInSlotOnClosing(int var1) { + if (items.get(var1) != null) { ItemStack var3 = items.get(var1); - items.put(var1,null); + items.put(var1, null); return var3; } return null; - } + } - @Override - public void setInventorySlotContents(int var1, ItemStack var2) { - if(var1 >= getSizeInventory()) - return; - items.put(var1,var2); - } + @Override + public void setInventorySlotContents(int var1, ItemStack var2) { + if (var1 >= getSizeInventory()) + return; + items.put(var1, var2); + } - @Override - public int getInventoryStackLimit() { - return stackLimit; - } + @Override + public int getInventoryStackLimit() { + return stackLimit; + } - @Override - public boolean isUseableByPlayer(EntityPlayer var1) { - return true; - } + @Override + public boolean isUseableByPlayer(EntityPlayer var1) { + return true; + } - @Override - public boolean isItemValidForSlot(int i, ItemStack itemstack) { - return true; - } - - @Override - public String getInventoryName() { - return "Npc Misc Inventory"; - } - - @Override - public boolean hasCustomInventoryName() { - return true; - } - - @Override - public void markDirty() { - - } - @Override - public void openInventory() { - - } - @Override - public void closeInventory() { - - } - public boolean addItemStack(ItemStack item) { - ItemStack mergable; - boolean merged = false; - while((mergable = getMergableItem(item)) != null && mergable.stackSize > 0){ - int size = mergable.getMaxStackSize() - mergable.stackSize; - if(size > item.stackSize){ - mergable.stackSize = mergable.getMaxStackSize(); - item.stackSize -= size; - merged = true; - } - else{ - mergable.stackSize += item.stackSize; - item.stackSize = 0; - } - } - if(item.stackSize <= 0) - return true; - int slot = firstFreeSlot(); - if(slot >= 0){ - items.put(slot, item.copy()); - item.stackSize = 0; - return true; - } - return merged; - } - - public ItemStack getMergableItem(ItemStack item){ - for(ItemStack is : items.values()){ - if(NoppesUtilPlayer.compareItems(item, is, false, false) && is.stackSize < is.getMaxStackSize()){ - return is; - } - } - return null; - } - - public int firstFreeSlot(){ - for(int i = 0; i < getSizeInventory(); i++){ - if(items.get(i) == null) - return i; - } - return -1; - } - public void setSize(int i) { - size = i; - } + @Override + public boolean isItemValidForSlot(int i, ItemStack itemstack) { + return true; + } + + @Override + public String getInventoryName() { + return "Npc Misc Inventory"; + } + + @Override + public boolean hasCustomInventoryName() { + return true; + } + + @Override + public void markDirty() { + + } + + @Override + public void openInventory() { + + } + + @Override + public void closeInventory() { + + } + + public boolean addItemStack(ItemStack item) { + ItemStack mergable; + boolean merged = false; + while ((mergable = getMergableItem(item)) != null && mergable.stackSize > 0) { + int size = mergable.getMaxStackSize() - mergable.stackSize; + if (size > item.stackSize) { + mergable.stackSize = mergable.getMaxStackSize(); + item.stackSize -= size; + merged = true; + } else { + mergable.stackSize += item.stackSize; + item.stackSize = 0; + } + } + if (item.stackSize <= 0) + return true; + int slot = firstFreeSlot(); + if (slot >= 0) { + items.put(slot, item.copy()); + item.stackSize = 0; + return true; + } + return merged; + } + + public ItemStack getMergableItem(ItemStack item) { + for (ItemStack is : items.values()) { + if (NoppesUtilPlayer.compareItems(item, is, false, false) && is.stackSize < is.getMaxStackSize()) { + return is; + } + } + return null; + } + + public int firstFreeSlot() { + for (int i = 0; i < getSizeInventory(); i++) { + if (items.get(i) == null) + return i; + } + return -1; + } + + public void setSize(int i) { + size = i; + } } diff --git a/src/main/java/noppes/npcs/QuestLogData.java b/src/main/java/noppes/npcs/QuestLogData.java index 575c0ede8..ad41ccd0b 100644 --- a/src/main/java/noppes/npcs/QuestLogData.java +++ b/src/main/java/noppes/npcs/QuestLogData.java @@ -14,133 +14,131 @@ import java.util.HashMap; import java.util.Vector; public class QuestLogData { - public String trackedQuestKey = ""; - public HashMap> categories = new HashMap>(); - public String selectedQuest = ""; - public String selectedCategory = ""; - public HashMap questText = new HashMap<>(); - public HashMap questAlerts = new HashMap<>(); - public HashMap> questStatus = new HashMap<>(); - public HashMap finish = new HashMap<>(); - public HashMap partyQuests = new HashMap<>(); - public HashMap> partyOptions = new HashMap<>(); + public String trackedQuestKey = ""; + public HashMap> categories = new HashMap>(); + public String selectedQuest = ""; + public String selectedCategory = ""; + public HashMap questText = new HashMap<>(); + public HashMap questAlerts = new HashMap<>(); + public HashMap> questStatus = new HashMap<>(); + public HashMap finish = new HashMap<>(); + public HashMap partyQuests = new HashMap<>(); + public HashMap> partyOptions = new HashMap<>(); - public NBTTagCompound writeNBT(){ - NBTTagCompound compound = new NBTTagCompound(); - compound.setTag("Categories", NBTTags.nbtVectorMap(categories)); - compound.setTag("Logs", NBTTags.nbtStringStringMap(questText)); - compound.setTag("Alerts", NBTTags.nbtStringStringMap(questAlerts)); - compound.setTag("Status", NBTTags.nbtVectorMap(questStatus)); - compound.setTag("QuestFinisher", NBTTags.nbtStringStringMap(finish)); - compound.setString("TrackedQuestID", trackedQuestKey); - compound.setTag("PartyQuests", NBTTags.nbtStringIntegerMap(partyQuests)); + public NBTTagCompound writeNBT() { + NBTTagCompound compound = new NBTTagCompound(); + compound.setTag("Categories", NBTTags.nbtVectorMap(categories)); + compound.setTag("Logs", NBTTags.nbtStringStringMap(questText)); + compound.setTag("Alerts", NBTTags.nbtStringStringMap(questAlerts)); + compound.setTag("Status", NBTTags.nbtVectorMap(questStatus)); + compound.setTag("QuestFinisher", NBTTags.nbtStringStringMap(finish)); + compound.setString("TrackedQuestID", trackedQuestKey); + compound.setTag("PartyQuests", NBTTags.nbtStringIntegerMap(partyQuests)); compound.setTag("PartyOptions", NBTTags.nbtVectorMap(partyOptions)); - return compound; - } + return compound; + } - public void readNBT(NBTTagCompound compound){ - categories = NBTTags.getVectorMap(compound.getTagList("Categories", 10)); - questText = NBTTags.getStringStringMap(compound.getTagList("Logs", 10)); - questAlerts = NBTTags.getStringStringMap(compound.getTagList("Alerts", 10)); - questStatus = NBTTags.getVectorMap(compound.getTagList("Status", 10)); - finish = NBTTags.getStringStringMap(compound.getTagList("QuestFinisher", 10)); - trackedQuestKey = compound.getString("TrackedQuestID"); - partyQuests = NBTTags.getStringIntegerMap(compound.getTagList("PartyQuests", 10)); + public void readNBT(NBTTagCompound compound) { + categories = NBTTags.getVectorMap(compound.getTagList("Categories", 10)); + questText = NBTTags.getStringStringMap(compound.getTagList("Logs", 10)); + questAlerts = NBTTags.getStringStringMap(compound.getTagList("Alerts", 10)); + questStatus = NBTTags.getVectorMap(compound.getTagList("Status", 10)); + finish = NBTTags.getStringStringMap(compound.getTagList("QuestFinisher", 10)); + trackedQuestKey = compound.getString("TrackedQuestID"); + partyQuests = NBTTags.getStringIntegerMap(compound.getTagList("PartyQuests", 10)); partyOptions = NBTTags.getVectorMap(compound.getTagList("PartyOptions", 10)); - } + } - public NBTTagCompound writeTrackedQuest(){ + public NBTTagCompound writeTrackedQuest() { NBTTagCompound compound = new NBTTagCompound(); compound.setString("TrackedQuestID", trackedQuestKey); return compound; } - public void readTrackedQuest(NBTTagCompound compound){ + public void readTrackedQuest(NBTTagCompound compound) { trackedQuestKey = compound.getString("TrackedQuestID"); } - public void setData(EntityPlayer player){ - PlayerData playerData = PlayerDataController.Instance.getPlayerData(player); + public void setData(EntityPlayer player) { + PlayerData playerData = PlayerDataController.Instance.getPlayerData(player); - for(Quest quest : PlayerQuestController.getActiveQuests(player)) - { - String category = quest.category.title; - if(!categories.containsKey(category)) - categories.put(category, new Vector()); - Vector list = categories.get(category); - list.add(quest.title); + for (Quest quest : PlayerQuestController.getActiveQuests(player)) { + String category = quest.category.title; + if (!categories.containsKey(category)) + categories.put(category, new Vector()); + Vector list = categories.get(category); + list.add(quest.title); String key = category + ":" + quest.title; - questText.put(key, quest.logText); - questAlerts.put(key, String.valueOf(playerData.questData.activeQuests.get(quest.id).sendAlerts)); - questStatus.put(key, quest.questInterface.getQuestLogStatus(player)); - if(quest.completion == EnumQuestCompletion.Npc && quest.questInterface.isCompleted(playerData)) - finish.put(key, quest.completerNpc); + questText.put(key, quest.logText); + questAlerts.put(key, String.valueOf(playerData.questData.activeQuests.get(quest.id).sendAlerts)); + questStatus.put(key, quest.questInterface.getQuestLogStatus(player)); + if (quest.completion == EnumQuestCompletion.Npc && quest.questInterface.isCompleted(playerData)) + finish.put(key, quest.completerNpc); - if (playerData.questData.getTrackedQuest() != null) { - if (quest.id == playerData.questData.getTrackedQuest().getId()) { - trackedQuestKey = key; - } - } + if (playerData.questData.getTrackedQuest() != null) { + if (quest.id == playerData.questData.getTrackedQuest().getId()) { + trackedQuestKey = key; + } + } - if (quest.partyOptions.allowParty) { - partyQuests.put(key, quest.id); + if (quest.partyOptions.allowParty) { + partyQuests.put(key, quest.id); partyOptions.put(key, quest.partyOptions.getPartyOptionsList()); - } + } } Party party = playerData.getPlayerParty(); - if(party != null && party.getQuest() != null){ + if (party != null && party.getQuest() != null) { if (playerData.questData.getTrackedQuest() != null) { if (party.getQuest().getId() == playerData.questData.getTrackedQuest().getId()) { trackedQuestKey = "P" + ":" + party.getQuest().getCategory().getName() + ":" + party.getQuest().getName(); } } } - } + } - public void setTrackedQuestKey(EntityPlayer player){ + public void setTrackedQuestKey(EntityPlayer player) { PlayerData playerData = PlayerDataController.Instance.getPlayerData(player); Party party = playerData.getPlayerParty(); - if(party != null && party.getQuest() != null){ + if (party != null && party.getQuest() != null) { if (playerData.questData.getTrackedQuest() != null) { if (party.getQuest().getId() == playerData.questData.getTrackedQuest().getId()) { trackedQuestKey = "P" + ":" + party.getQuest().getCategory().getName() + ":" + party.getQuest().getName(); } } - } else if(playerData.questData != null && playerData.questData.getTrackedQuest() != null){ + } else if (playerData.questData != null && playerData.questData.getTrackedQuest() != null) { IQuest quest = playerData.questData.getTrackedQuest(); trackedQuestKey = quest.getCategory().getName() + ":" + quest.getName(); - } - else { + } else { trackedQuestKey = ""; } } - public boolean hasSelectedQuest() { - return !selectedQuest.isEmpty(); - } + public boolean hasSelectedQuest() { + return !selectedQuest.isEmpty(); + } - public String getQuestText() { - return questText.get(selectedCategory + ":" + selectedQuest); - } + public String getQuestText() { + return questText.get(selectedCategory + ":" + selectedQuest); + } - public Boolean getQuestAlerts() { - return Boolean.valueOf(questAlerts.get(selectedCategory+":"+selectedQuest)); - } + public Boolean getQuestAlerts() { + return Boolean.valueOf(questAlerts.get(selectedCategory + ":" + selectedQuest)); + } - public void toggleQuestAlerts() { - questAlerts.put(selectedCategory+":"+selectedQuest,String.valueOf(!getQuestAlerts())); - } + public void toggleQuestAlerts() { + questAlerts.put(selectedCategory + ":" + selectedQuest, String.valueOf(!getQuestAlerts())); + } - public Vector getQuestStatus() { - return questStatus.get(selectedCategory + ":" + selectedQuest); - } + public Vector getQuestStatus() { + return questStatus.get(selectedCategory + ":" + selectedQuest); + } - public String getComplete() { - return finish.get(selectedCategory + ":" + selectedQuest); - } + public String getComplete() { + return finish.get(selectedCategory + ":" + selectedQuest); + } public Vector getPartyOptions() { return partyOptions.get(selectedCategory + ":" + selectedQuest); diff --git a/src/main/java/noppes/npcs/Resistances.java b/src/main/java/noppes/npcs/Resistances.java index 7598e0f4e..790c273f0 100644 --- a/src/main/java/noppes/npcs/Resistances.java +++ b/src/main/java/noppes/npcs/Resistances.java @@ -5,47 +5,45 @@ import net.minecraft.util.DamageSource; public class Resistances { - public float knockback = 1f; - public float arrow = 1f; - public float playermelee = 1f; - public float explosion = 1f; + public float knockback = 1f; + public float arrow = 1f; + public float playermelee = 1f; + public float explosion = 1f; - public boolean disableDamage = false; - - public NBTTagCompound writeToNBT() { - NBTTagCompound compound = new NBTTagCompound(); - compound.setFloat("Knockback", knockback); - compound.setFloat("Arrow", arrow); - compound.setFloat("Melee", playermelee); - compound.setFloat("Explosion", explosion); - compound.setBoolean("disableDamage", disableDamage); - return compound; - } + public boolean disableDamage = false; - public void readToNBT(NBTTagCompound compound) { - knockback = compound.getFloat("Knockback"); - arrow = compound.getFloat("Arrow"); - playermelee = compound.getFloat("Melee"); - explosion = compound.getFloat("Explosion"); - disableDamage = compound.getBoolean("disableDamage"); - } + public NBTTagCompound writeToNBT() { + NBTTagCompound compound = new NBTTagCompound(); + compound.setFloat("Knockback", knockback); + compound.setFloat("Arrow", arrow); + compound.setFloat("Melee", playermelee); + compound.setFloat("Explosion", explosion); + compound.setBoolean("disableDamage", disableDamage); + return compound; + } - public float applyResistance(DamageSource source, float damage) { - if(disableDamage){ - return 0; - } + public void readToNBT(NBTTagCompound compound) { + knockback = compound.getFloat("Knockback"); + arrow = compound.getFloat("Arrow"); + playermelee = compound.getFloat("Melee"); + explosion = compound.getFloat("Explosion"); + disableDamage = compound.getBoolean("disableDamage"); + } - if(source.damageType.equals("arrow") || source.damageType.equals("thrown")){ - damage *= (2 - arrow); - } - else if(source.damageType.equals("player") || source.damageType.equals("mob")){ - damage *= (2 - playermelee); - } - else if(source.damageType.equals("explosion") || source.damageType.equals("explosion.player")){ - damage *= (2 - explosion); - } - - return damage; - } + public float applyResistance(DamageSource source, float damage) { + if (disableDamage) { + return 0; + } + + if (source.damageType.equals("arrow") || source.damageType.equals("thrown")) { + damage *= (2 - arrow); + } else if (source.damageType.equals("player") || source.damageType.equals("mob")) { + damage *= (2 - playermelee); + } else if (source.damageType.equals("explosion") || source.damageType.equals("explosion.player")) { + damage *= (2 - explosion); + } + + return damage; + } } diff --git a/src/main/java/noppes/npcs/ScriptForgeEventHandler.java b/src/main/java/noppes/npcs/ScriptForgeEventHandler.java index 163fb25ea..649557b43 100644 --- a/src/main/java/noppes/npcs/ScriptForgeEventHandler.java +++ b/src/main/java/noppes/npcs/ScriptForgeEventHandler.java @@ -35,22 +35,22 @@ public class ScriptForgeEventHandler { @SubscribeEvent public void forgeEntity(Event event) { - if(CustomNpcs.getServer() != null && ScriptController.Instance.forgeScripts.isEnabled()) { - if(event instanceof TickEvent && !(((TickEvent)event).side == Side.SERVER && ((TickEvent)event).phase == TickEvent.Phase.START)) { + if (CustomNpcs.getServer() != null && ScriptController.Instance.forgeScripts.isEnabled()) { + if (event instanceof TickEvent && !(((TickEvent) event).side == Side.SERVER && ((TickEvent) event).phase == TickEvent.Phase.START)) { return; } - if(event instanceof EntityEvent) { - EntityEvent ev2 = (EntityEvent)event; - if(ev2.entity != null && ev2.entity.worldObj instanceof WorldServer) { + if (event instanceof EntityEvent) { + EntityEvent ev2 = (EntityEvent) event; + if (ev2.entity != null && ev2.entity.worldObj instanceof WorldServer) { EventHooks.onForgeEntityEvent(ev2); } - } else if(event instanceof WorldEvent) { - WorldEvent ev1 = (WorldEvent)event; - if(ev1.world instanceof WorldServer) { + } else if (event instanceof WorldEvent) { + WorldEvent ev1 = (WorldEvent) event; + if (ev1.world instanceof WorldServer) { EventHooks.onForgeWorldEvent(ev1); } - } else if(!(event instanceof TickEvent) || ((TickEvent)event).side != Side.CLIENT) { + } else if (!(event instanceof TickEvent) || ((TickEvent) event).side != Side.CLIENT) { if (event instanceof PlayerEvent) { PlayerEvent ev = (PlayerEvent) event; if (ev.player == null || !(ev.player.worldObj instanceof WorldServer)) { @@ -74,21 +74,21 @@ public class ScriptForgeEventHandler { list.removeAll(ClassPath.from(this.getClass().getClassLoader()).getTopLevelClassesRecursive("net.minecraftforge.event.terraingen")); Iterator e1 = list.iterator(); - while(true) { + while (true) { ClassPath.ClassInfo classLoader; String classes; do { - if(!e1.hasNext()) { - if(PixelmonHelper.Enabled) { + if (!e1.hasNext()) { + if (PixelmonHelper.Enabled) { try { Field e2 = ClassLoader.class.getDeclaredField("classes"); e2.setAccessible(true); ClassLoader classLoader1 = Thread.currentThread().getContextClassLoader(); - ArrayList classes1 = new ArrayList((Vector)e2.get(classLoader1)); + ArrayList classes1 = new ArrayList((Vector) e2.get(classLoader1)); Iterator infoClass1 = classes1.iterator(); - while(infoClass1.hasNext()) { - Class c2 = (Class)infoClass1.next(); + while (infoClass1.hasNext()) { + Class c2 = (Class) infoClass1.next(); } } catch (Exception var12) { var12.printStackTrace(); @@ -100,20 +100,20 @@ public class ScriptForgeEventHandler { return this; } - classLoader = (ClassPath.ClassInfo)e1.next(); + classLoader = (ClassPath.ClassInfo) e1.next(); classes = classLoader.getName(); - } while(classes.startsWith("net.minecraftforge.event.terraingen")); + } while (classes.startsWith("net.minecraftforge.event.terraingen")); Class infoClass = classLoader.load(); ArrayList c = new ArrayList(Arrays.asList(infoClass.getDeclaredClasses())); - if(c.isEmpty()) { + if (c.isEmpty()) { c.add(infoClass); } Iterator var10 = c.iterator(); - while(var10.hasNext()) { - Class c1 = (Class)var10.next(); - if(!EntityEvent.EntityConstructing.class.isAssignableFrom(c1) && !WorldEvent.PotentialSpawns.class.isAssignableFrom(c1) && !TickEvent.RenderTickEvent.class.isAssignableFrom(c1) && !TickEvent.ClientTickEvent.class.isAssignableFrom(c1) && !FMLNetworkEvent.ClientCustomPacketEvent.class.isAssignableFrom(c1) && !ItemTooltipEvent.class.isAssignableFrom(c1) && Event.class.isAssignableFrom(c1) && !Modifier.isAbstract(c1.getModifiers()) && Modifier.isPublic(c1.getModifiers()) && !ChunkEvent.class.isAssignableFrom(c1) && !ChunkWatchEvent.class.isAssignableFrom(c1) && !ChunkDataEvent.class.isAssignableFrom(c1)) { + while (var10.hasNext()) { + Class c1 = (Class) var10.next(); + if (!EntityEvent.EntityConstructing.class.isAssignableFrom(c1) && !WorldEvent.PotentialSpawns.class.isAssignableFrom(c1) && !TickEvent.RenderTickEvent.class.isAssignableFrom(c1) && !TickEvent.ClientTickEvent.class.isAssignableFrom(c1) && !FMLNetworkEvent.ClientCustomPacketEvent.class.isAssignableFrom(c1) && !ItemTooltipEvent.class.isAssignableFrom(c1) && Event.class.isAssignableFrom(c1) && !Modifier.isAbstract(c1.getModifiers()) && Modifier.isPublic(c1.getModifiers()) && !ChunkEvent.class.isAssignableFrom(c1) && !ChunkWatchEvent.class.isAssignableFrom(c1) && !ChunkDataEvent.class.isAssignableFrom(c1)) { register.invoke(FMLCommonHandler.instance().bus(), new Object[]{c1, this, e, Loader.instance().activeModContainer()}); } } @@ -123,4 +123,4 @@ public class ScriptForgeEventHandler { return this; } } -} \ No newline at end of file +} diff --git a/src/main/java/noppes/npcs/ScriptItemEventHandler.java b/src/main/java/noppes/npcs/ScriptItemEventHandler.java index b6416aaef..a3cbcc490 100644 --- a/src/main/java/noppes/npcs/ScriptItemEventHandler.java +++ b/src/main/java/noppes/npcs/ScriptItemEventHandler.java @@ -23,11 +23,12 @@ import noppes.npcs.scripted.event.ItemEvent; import java.util.HashMap; public class ScriptItemEventHandler { - public ScriptItemEventHandler() {} + public ScriptItemEventHandler() { + } @SubscribeEvent public void invoke(LivingEvent.LivingUpdateEvent event) { - if(event.entityLiving == null || event.entityLiving.worldObj == null || event.entityLiving instanceof EntityPlayer || event.entityLiving.ticksExisted%10 != 0) + if (event.entityLiving == null || event.entityLiving.worldObj == null || event.entityLiving instanceof EntityPlayer || event.entityLiving.ticksExisted % 10 != 0) return; if (event.entityLiving instanceof EntityCustomNpc) { @@ -43,7 +44,7 @@ public class ScriptItemEventHandler { } } } - } else if(event.entityLiving.getHeldItem() != null && NoppesUtilServer.isScriptableItem(event.entityLiving.getHeldItem().getItem()) && !event.isCanceled()) { + } else if (event.entityLiving.getHeldItem() != null && NoppesUtilServer.isScriptableItem(event.entityLiving.getHeldItem().getItem()) && !event.isCanceled()) { IItemStack itemStack = NpcAPI.Instance().getIItemStack(event.entityLiving.getHeldItem()); EventHooks.onScriptItemUpdate((IItemCustomizable) itemStack, event.entityLiving); } @@ -51,177 +52,186 @@ public class ScriptItemEventHandler { @SubscribeEvent public void invoke(ItemTossEvent event) { - if(event.player == null || event.player.worldObj == null) + if (event.player == null || event.player.worldObj == null) return; - if(event.player.worldObj instanceof WorldServer) { + if (event.player.worldObj instanceof WorldServer) { try { if (NoppesUtilServer.isScriptableItem(event.entityItem.getEntityItem().getItem()) && !event.isCanceled()) { IItemStack isw = NpcAPI.Instance().getIItemStack(event.entityItem.getEntityItem()); - if(isw instanceof IItemCustomizable) + if (isw instanceof IItemCustomizable) event.setCanceled(EventHooks.onScriptItemTossed((IItemCustomizable) isw, event.player, event.entityItem)); } - } catch (Exception e) {} + } catch (Exception e) { + } } } @SubscribeEvent public void invoke(PlayerEvent.ItemPickupEvent event) { - if(event.player == null || event.player.worldObj == null) + if (event.player == null || event.player.worldObj == null) return; - if(event.player.worldObj instanceof WorldServer) { + if (event.player.worldObj instanceof WorldServer) { try { if (NoppesUtilServer.isScriptableItem(event.player.getHeldItem().getItem()) && !event.isCanceled()) { IItemStack isw = NpcAPI.Instance().getIItemStack(event.player.getHeldItem()); - if(isw instanceof IItemCustomizable) + if (isw instanceof IItemCustomizable) EventHooks.onScriptItemPickedUp((IItemCustomizable) isw, event.player); } - } catch(Exception e) {} + } catch (Exception e) { + } } } @SubscribeEvent public void invoke(EntityJoinWorldEvent event) { if (!event.world.isRemote && event.entity instanceof EntityItem) { - EntityItem entity = (EntityItem)event.entity; + EntityItem entity = (EntityItem) event.entity; ItemStack stack = entity.getEntityItem(); try { - if (stack.stackSize > 0 && NoppesUtilServer.isScriptableItem(stack.getItem())) { + if (stack.stackSize > 0 && NoppesUtilServer.isScriptableItem(stack.getItem())) { IItemStack isw = NpcAPI.Instance().getIItemStack(stack); - if(isw instanceof IItemCustomizable){ - if(EventHooks.onScriptItemSpawn((IItemCustomizable) isw, entity)){ + if (isw instanceof IItemCustomizable) { + if (EventHooks.onScriptItemSpawn((IItemCustomizable) isw, entity)) { event.setCanceled(true); } } } - } catch(Exception e) {} + } catch (Exception e) { + } } } @SubscribeEvent public void invoke(EntityInteractEvent event) { - if(event.entityPlayer == null || event.entityPlayer.worldObj == null) + if (event.entityPlayer == null || event.entityPlayer.worldObj == null) return; - if(!event.entityPlayer.worldObj.isRemote && event.entityPlayer.worldObj instanceof WorldServer) { + if (!event.entityPlayer.worldObj.isRemote && event.entityPlayer.worldObj instanceof WorldServer) { try { if (NoppesUtilServer.isScriptableItem(event.entityPlayer.getHeldItem().getItem()) && !event.isCanceled()) { IItemStack isw = NpcAPI.Instance().getIItemStack(event.entityPlayer.getHeldItem()); - if(isw instanceof IItemCustomizable){ + if (isw instanceof IItemCustomizable) { ItemEvent.InteractEvent eve = new ItemEvent.InteractEvent((IItemCustomizable) isw, (IPlayer) NpcAPI.Instance().getIEntity(event.entityPlayer), 2, NpcAPI.Instance().getIEntity(event.target)); event.setCanceled(EventHooks.onScriptItemInteract((IItemCustomizable) isw, eve)); - ItemEvent.RightClickEvent rightClickEvent = new ItemEvent.RightClickEvent((IItemCustomizable) isw, (IPlayer) NpcAPI.Instance().getIEntity(event.entityPlayer), 1, NpcAPI.Instance().getIEntity(event.target)); + ItemEvent.RightClickEvent rightClickEvent = new ItemEvent.RightClickEvent((IItemCustomizable) isw, (IPlayer) NpcAPI.Instance().getIEntity(event.entityPlayer), 1, NpcAPI.Instance().getIEntity(event.target)); event.setCanceled(EventHooks.onScriptItemRightClick((IItemCustomizable) isw, rightClickEvent)); } } - } catch(Exception e) {} + } catch (Exception e) { + } } } @SubscribeEvent public void invoke(PlayerInteractEvent event) { - if(event.entityPlayer == null || event.entityPlayer.worldObj == null || event.action == null) + if (event.entityPlayer == null || event.entityPlayer.worldObj == null || event.action == null) return; - if(event.entityPlayer.worldObj.isRemote || !(event.entityPlayer.worldObj instanceof WorldServer)) + if (event.entityPlayer.worldObj.isRemote || !(event.entityPlayer.worldObj instanceof WorldServer)) return; if (PlayerDataController.Instance != null) { - if(event.action == PlayerInteractEvent.Action.RIGHT_CLICK_AIR){ + if (event.action == PlayerInteractEvent.Action.RIGHT_CLICK_AIR) { PlayerData handler = PlayerDataController.Instance.getPlayerData(event.entityPlayer); - if(handler == null) + if (handler == null) return; - if(handler.hadInteract) { + if (handler.hadInteract) { handler.hadInteract = false; return; } try { if (NoppesUtilServer.isScriptableItem(event.entityPlayer.getHeldItem().getItem()) && !event.isCanceled()) { IItemStack isw = NpcAPI.Instance().getIItemStack(event.entityPlayer.getHeldItem()); - if(isw instanceof IItemCustomizable){ + if (isw instanceof IItemCustomizable) { ItemEvent.RightClickEvent eve = new ItemEvent.RightClickEvent((IItemCustomizable) isw, (IPlayer) NpcAPI.Instance().getIEntity(event.entityPlayer), 0, null); event.setCanceled(EventHooks.onScriptItemRightClick((IItemCustomizable) isw, eve)); } } - } catch(Exception e) {} - } - else if(event.action == PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK){ + } catch (Exception e) { + } + } else if (event.action == PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK) { PlayerData handler = PlayerDataController.Instance.getPlayerData(event.entityPlayer); - if(handler == null) + if (handler == null) return; handler.hadInteract = true; try { if (NoppesUtilServer.isScriptableItem(event.entityPlayer.getHeldItem().getItem()) && !event.isCanceled()) { IItemStack isw = NpcAPI.Instance().getIItemStack(event.entityPlayer.getHeldItem()); - if(isw instanceof IItemCustomizable){ + if (isw instanceof IItemCustomizable) { ItemEvent.RightClickEvent eve = new ItemEvent.RightClickEvent((IItemCustomizable) isw, (IPlayer) NpcAPI.Instance().getIEntity(event.entityPlayer), 2, NpcAPI.Instance().getIBlock((IWorld) NpcAPI.Instance().getIWorld(event.world), event.x, event.y, event.z)); event.setCanceled(EventHooks.onScriptItemRightClick((IItemCustomizable) isw, eve)); } } - } catch(Exception e) {} + } catch (Exception e) { + } } } } @SubscribeEvent public void invoke(PlayerUseItemEvent.Start event) { - if(event.entityPlayer == null || event.entityPlayer.worldObj == null) + if (event.entityPlayer == null || event.entityPlayer.worldObj == null) return; - if(event.entityPlayer.worldObj instanceof WorldServer) { + if (event.entityPlayer.worldObj instanceof WorldServer) { IItemStack isw = NpcAPI.Instance().getIItemStack(event.item); - if(isw instanceof IItemCustomizable){ + if (isw instanceof IItemCustomizable) { IPlayer IPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.entityPlayer); event.setCanceled(EventHooks.onStartUsingCustomItem((IItemCustomizable) isw, IPlayer, event.duration)); } } } + @SubscribeEvent public void invoke(PlayerUseItemEvent.Tick event) { - if(event.entityPlayer == null || event.entityPlayer.worldObj == null) + if (event.entityPlayer == null || event.entityPlayer.worldObj == null) return; - if(event.entityPlayer.worldObj instanceof WorldServer && NoppesUtilServer.isScriptableItem(event.item.getItem())) { + if (event.entityPlayer.worldObj instanceof WorldServer && NoppesUtilServer.isScriptableItem(event.item.getItem())) { IItemStack isw = NpcAPI.Instance().getIItemStack(event.item); - if(isw instanceof IItemCustomizable){ + if (isw instanceof IItemCustomizable) { IPlayer IPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.entityPlayer); event.setCanceled(EventHooks.onUsingCustomItem((IItemCustomizable) isw, IPlayer, event.duration)); } } } + @SubscribeEvent public void invoke(PlayerUseItemEvent.Stop event) { - if(event.entityPlayer == null || event.entityPlayer.worldObj == null) + if (event.entityPlayer == null || event.entityPlayer.worldObj == null) return; - if(event.entityPlayer.worldObj instanceof WorldServer && NoppesUtilServer.isScriptableItem(event.item.getItem())) { + if (event.entityPlayer.worldObj instanceof WorldServer && NoppesUtilServer.isScriptableItem(event.item.getItem())) { IItemStack isw = NpcAPI.Instance().getIItemStack(event.item); - if(isw instanceof IItemCustomizable){ + if (isw instanceof IItemCustomizable) { IPlayer IPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.entityPlayer); event.setCanceled(EventHooks.onStopUsingCustomItem((IItemCustomizable) isw, IPlayer, event.duration)); } } } + @SubscribeEvent public void invoke(PlayerUseItemEvent.Finish event) { - if(event.entityPlayer == null || event.entityPlayer.worldObj == null) + if (event.entityPlayer == null || event.entityPlayer.worldObj == null) return; - if(event.entityPlayer.worldObj instanceof WorldServer && NoppesUtilServer.isScriptableItem(event.item.getItem())) { + if (event.entityPlayer.worldObj instanceof WorldServer && NoppesUtilServer.isScriptableItem(event.item.getItem())) { IItemStack isw = NpcAPI.Instance().getIItemStack(event.item); - if(isw instanceof IItemCustomizable){ + if (isw instanceof IItemCustomizable) { IPlayer IPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.entityPlayer); EventHooks.onFinishUsingCustomItem((IItemCustomizable) isw, IPlayer, event.duration); } } } + @SubscribeEvent public void invoke(AnvilRepairEvent repairEvent) { IItemStack output = NpcAPI.Instance().getIItemStack(repairEvent.output); diff --git a/src/main/java/noppes/npcs/ScriptPlayerEventHandler.java b/src/main/java/noppes/npcs/ScriptPlayerEventHandler.java index 6ca506cc0..e32580616 100644 --- a/src/main/java/noppes/npcs/ScriptPlayerEventHandler.java +++ b/src/main/java/noppes/npcs/ScriptPlayerEventHandler.java @@ -5,7 +5,9 @@ import cpw.mods.fml.common.eventhandler.SubscribeEvent; import cpw.mods.fml.common.gameevent.PlayerEvent; import cpw.mods.fml.common.gameevent.TickEvent; import cpw.mods.fml.relauncher.Side; +import kamkeel.npcs.controllers.AttributeController; import kamkeel.npcs.controllers.SyncController; +import kamkeel.npcs.util.AttributeAttackUtil; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; @@ -23,8 +25,6 @@ import net.minecraftforge.event.entity.player.*; import net.minecraftforge.event.world.BlockEvent; import noppes.npcs.api.entity.IPlayer; import noppes.npcs.api.item.IItemCustomizable; -import kamkeel.npcs.controllers.AttributeController; -import kamkeel.npcs.util.AttributeAttackUtil; import noppes.npcs.config.ConfigMain; import noppes.npcs.constants.EnumQuestType; import noppes.npcs.controllers.CustomEffectController; @@ -42,6 +42,7 @@ import static noppes.npcs.config.ConfigMain.TrackedQuestUpdateFrequency; public class ScriptPlayerEventHandler { public ScriptPlayerEventHandler() { } + @SubscribeEvent public void onServerTick(TickEvent.PlayerTickEvent event) { if (event.player == null || event.player.worldObj == null) @@ -55,23 +56,23 @@ public class ScriptPlayerEventHandler { IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(player); EventHooks.onPlayerTick(handler, scriptPlayer); - for(int i = 0; i < player.inventory.getSizeInventory(); i++){ + for (int i = 0; i < player.inventory.getSizeInventory(); i++) { ItemStack item = player.inventory.getStackInSlot(i); - if(item != null && NoppesUtilServer.isScriptableItem(item.getItem())){ + if (item != null && NoppesUtilServer.isScriptableItem(item.getItem())) { IItemCustomizable isw = (IItemCustomizable) NpcAPI.Instance().getIItemStack(item); EventHooks.onScriptItemUpdate(isw, player); } } - if(ConfigMain.AttributesEnabled) + if (ConfigMain.AttributesEnabled) AttributeController.getTracker(player).updateIfChanged(player); } if (PlayerDataController.Instance != null) { PlayerData playerData = PlayerDataController.Instance.getPlayerData(player); - if(playerData.updateClient) { - SyncController.syncPlayerData((EntityPlayerMP)player, true); + if (playerData.updateClient) { + SyncController.syncPlayerData((EntityPlayerMP) player, true); playerData.updateClient = false; } @@ -79,7 +80,7 @@ public class ScriptPlayerEventHandler { playerData.timers.update(); } - if(player.ticksExisted % 10 == 0) + if (player.ticksExisted % 10 == 0) SyncController.syncEffects((EntityPlayerMP) player); if (player.ticksExisted % 10 == 0) @@ -100,12 +101,11 @@ public class ScriptPlayerEventHandler { if (player.ticksExisted % (TrackedQuestUpdateFrequency * 20) == 0) { PlayerQuestData questData = playerData.questData; - if(questData != null){ + if (questData != null) { if (questData.getTrackedQuest() != null && ((Quest) questData.getTrackedQuest()).type == EnumQuestType.Item) { - if(trackingPartyQuest){ + if (trackingPartyQuest) { NoppesUtilPlayer.sendPartyTrackedQuestData((EntityPlayerMP) event.player, party); - } - else { + } else { NoppesUtilPlayer.sendTrackedQuestData((EntityPlayerMP) event.player); } } @@ -117,10 +117,10 @@ public class ScriptPlayerEventHandler { @SubscribeEvent public void invoke(EntityInteractEvent event) { - if(event.entityPlayer == null || event.entityPlayer.worldObj == null) + if (event.entityPlayer == null || event.entityPlayer.worldObj == null) return; - if(!event.entityPlayer.worldObj.isRemote && event.entityPlayer.worldObj instanceof WorldServer) { + if (!event.entityPlayer.worldObj.isRemote && event.entityPlayer.worldObj instanceof WorldServer) { PlayerDataScript handler = ScriptController.Instance.playerScripts; IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.entityPlayer); noppes.npcs.scripted.event.PlayerEvent.InteractEvent ev = new noppes.npcs.scripted.event.PlayerEvent.InteractEvent(scriptPlayer, 1, NpcAPI.Instance().getIEntity(event.target)); @@ -130,10 +130,10 @@ public class ScriptPlayerEventHandler { @SubscribeEvent public void invoke(ArrowNockEvent event) { - if(event.entityPlayer == null || event.entityPlayer.worldObj == null) + if (event.entityPlayer == null || event.entityPlayer.worldObj == null) return; - if(!event.entityPlayer.worldObj.isRemote && event.entityPlayer.worldObj instanceof WorldServer) { + if (!event.entityPlayer.worldObj.isRemote && event.entityPlayer.worldObj instanceof WorldServer) { PlayerDataScript handler = ScriptController.Instance.playerScripts; IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.entityPlayer); noppes.npcs.scripted.event.PlayerEvent.RangedChargeEvent ev = new noppes.npcs.scripted.event.PlayerEvent.RangedChargeEvent(scriptPlayer); @@ -143,10 +143,10 @@ public class ScriptPlayerEventHandler { @SubscribeEvent public void invoke(ArrowLooseEvent event) { - if(event.entityPlayer == null || event.entityPlayer.worldObj == null) + if (event.entityPlayer == null || event.entityPlayer.worldObj == null) return; - if(!event.entityPlayer.worldObj.isRemote && event.entityPlayer.worldObj instanceof WorldServer) { + if (!event.entityPlayer.worldObj.isRemote && event.entityPlayer.worldObj instanceof WorldServer) { PlayerDataScript handler = ScriptController.Instance.playerScripts; IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.entityPlayer); noppes.npcs.scripted.event.PlayerEvent.RangedLaunchedEvent ev = new noppes.npcs.scripted.event.PlayerEvent.RangedLaunchedEvent(scriptPlayer, event.bow, event.charge); @@ -156,18 +156,18 @@ public class ScriptPlayerEventHandler { @SubscribeEvent public void invoke(BlockEvent.BreakEvent event) { - if(event.getPlayer() == null || event.getPlayer().worldObj == null) + if (event.getPlayer() == null || event.getPlayer().worldObj == null) return; - if(event.getPlayer().getHeldItem() != null && event.getPlayer().getHeldItem().getItem() instanceof ItemNpcTool){ + if (event.getPlayer().getHeldItem() != null && event.getPlayer().getHeldItem().getItem() instanceof ItemNpcTool) { event.setCanceled(true); return; } - if(!event.getPlayer().worldObj.isRemote && event.world instanceof WorldServer) { + if (!event.getPlayer().worldObj.isRemote && event.world instanceof WorldServer) { PlayerDataScript handler = ScriptController.Instance.playerScripts; IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.getPlayer()); - noppes.npcs.scripted.event.PlayerEvent.BreakEvent ev = new noppes.npcs.scripted.event.PlayerEvent.BreakEvent(scriptPlayer, NpcAPI.Instance().getIBlock(NpcAPI.Instance().getIWorld(event.world), NpcAPI.Instance().getIPos(event.x,event.y,event.z)), event.getExpToDrop()); + noppes.npcs.scripted.event.PlayerEvent.BreakEvent ev = new noppes.npcs.scripted.event.PlayerEvent.BreakEvent(scriptPlayer, NpcAPI.Instance().getIBlock(NpcAPI.Instance().getIWorld(event.world), NpcAPI.Instance().getIPos(event.x, event.y, event.z)), event.getExpToDrop()); event.setCanceled(EventHooks.onPlayerBreak(handler, ev)); event.setExpToDrop(ev.exp); } @@ -175,43 +175,46 @@ public class ScriptPlayerEventHandler { @SubscribeEvent public void invoke(PlayerUseItemEvent.Start event) { - if(event.entityPlayer == null || event.entityPlayer.worldObj == null) + if (event.entityPlayer == null || event.entityPlayer.worldObj == null) return; - if(event.entityPlayer.worldObj instanceof WorldServer) { + if (event.entityPlayer.worldObj instanceof WorldServer) { PlayerDataScript handler = ScriptController.Instance.playerScripts; IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.entityPlayer); event.setCanceled(EventHooks.onStartUsingItem(handler, scriptPlayer, event.duration, event.item)); } } + @SubscribeEvent public void invoke(PlayerUseItemEvent.Tick event) { - if(event.entityPlayer == null || event.entityPlayer.worldObj == null) + if (event.entityPlayer == null || event.entityPlayer.worldObj == null) return; - if(event.entityPlayer.worldObj instanceof WorldServer) { + if (event.entityPlayer.worldObj instanceof WorldServer) { PlayerDataScript handler = ScriptController.Instance.playerScripts; IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.entityPlayer); event.setCanceled(EventHooks.onUsingItem(handler, scriptPlayer, event.duration, event.item)); } } + @SubscribeEvent public void invoke(PlayerUseItemEvent.Stop event) { - if(event.entityPlayer == null || event.entityPlayer.worldObj == null) + if (event.entityPlayer == null || event.entityPlayer.worldObj == null) return; - if(event.entityPlayer.worldObj instanceof WorldServer) { + if (event.entityPlayer.worldObj instanceof WorldServer) { PlayerDataScript handler = ScriptController.Instance.playerScripts; IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.entityPlayer); event.setCanceled(EventHooks.onStopUsingItem(handler, scriptPlayer, event.duration, event.item)); } } + @SubscribeEvent public void invoke(PlayerUseItemEvent.Finish event) { - if(event.entityPlayer == null || event.entityPlayer.worldObj == null) + if (event.entityPlayer == null || event.entityPlayer.worldObj == null) return; - if(event.entityPlayer.worldObj instanceof WorldServer) { + if (event.entityPlayer.worldObj instanceof WorldServer) { PlayerDataScript handler = ScriptController.Instance.playerScripts; IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.entityPlayer); EventHooks.onFinishUsingItem(handler, scriptPlayer, event.duration, event.item); @@ -220,10 +223,10 @@ public class ScriptPlayerEventHandler { @SubscribeEvent public void invoke(PlayerDropsEvent event) { - if(event.entityPlayer == null || event.entityPlayer.worldObj == null) + if (event.entityPlayer == null || event.entityPlayer.worldObj == null) return; - if(event.entityPlayer.worldObj instanceof WorldServer) { + if (event.entityPlayer.worldObj instanceof WorldServer) { PlayerDataScript handler = ScriptController.Instance.playerScripts; IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.entityPlayer); event.setCanceled(EventHooks.onPlayerDropItems(handler, scriptPlayer, event.drops)); @@ -232,10 +235,10 @@ public class ScriptPlayerEventHandler { @SubscribeEvent public void invoke(PlayerPickupXpEvent event) { - if(event.entityPlayer == null || event.entityPlayer.worldObj == null) + if (event.entityPlayer == null || event.entityPlayer.worldObj == null) return; - if(event.entityPlayer.worldObj instanceof WorldServer) { + if (event.entityPlayer.worldObj instanceof WorldServer) { PlayerDataScript handler = ScriptController.Instance.playerScripts; IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.entityPlayer); EventHooks.onPlayerPickupXP(handler, scriptPlayer, event.orb); @@ -244,10 +247,10 @@ public class ScriptPlayerEventHandler { @SubscribeEvent public void invoke(PlayerEvent.PlayerChangedDimensionEvent event) { - if(event.player == null || event.player.worldObj == null) + if (event.player == null || event.player.worldObj == null) return; - if(event.player.worldObj instanceof WorldServer) { + if (event.player.worldObj instanceof WorldServer) { PlayerDataScript handler = ScriptController.Instance.playerScripts; IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.player); EventHooks.onPlayerChangeDim(handler, scriptPlayer, event.fromDim, event.toDim); @@ -256,16 +259,16 @@ public class ScriptPlayerEventHandler { @SubscribeEvent public void invoke(PlayerEvent.ItemPickupEvent event) { - if(event.player == null || event.player.worldObj == null) + if (event.player == null || event.player.worldObj == null) return; - if(!event.player.worldObj.isRemote && !(event.player instanceof FakePlayer)){ + if (!event.player.worldObj.isRemote && !(event.player instanceof FakePlayer)) { PlayerData playerData = PlayerDataController.Instance.getPlayerData(event.player); PlayerQuestData questData = playerData.questData; QuestItem.pickedUp = event.pickedUp.getEntityItem(); Party playerParty = playerData.getPlayerParty(); - if(playerParty != null){ + if (playerParty != null) { QuestItem.pickedUpParty = event.pickedUp.getEntityItem(); QuestItem.pickedUpPlayer = event.player; PartyController.Instance().checkQuestCompletion(playerParty, EnumQuestType.Item); @@ -274,7 +277,7 @@ public class ScriptPlayerEventHandler { questData.checkQuestCompletion(playerData, EnumQuestType.Item); } - if(event.player.worldObj instanceof WorldServer && event.player instanceof EntityPlayer) { + if (event.player.worldObj instanceof WorldServer && event.player instanceof EntityPlayer) { PlayerDataScript handler = ScriptController.Instance.playerScripts; IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.player); EventHooks.onPlayerPickUp(handler, scriptPlayer, event.pickedUp); @@ -283,10 +286,10 @@ public class ScriptPlayerEventHandler { @SubscribeEvent public void invoke(PlayerOpenContainerEvent event) { - if(event.entityPlayer == null || event.entityPlayer.worldObj == null) + if (event.entityPlayer == null || event.entityPlayer.worldObj == null) return; - if(event.entityPlayer.worldObj instanceof WorldServer && !(event.entityPlayer.openContainer instanceof ContainerPlayer)) { + if (event.entityPlayer.worldObj instanceof WorldServer && !(event.entityPlayer.openContainer instanceof ContainerPlayer)) { PlayerDataScript handler = ScriptController.Instance.playerScripts; IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.entityPlayer); EventHooks.onPlayerContainerOpen(handler, scriptPlayer, event.entityPlayer.openContainer); @@ -295,10 +298,10 @@ public class ScriptPlayerEventHandler { @SubscribeEvent public void invoke(UseHoeEvent event) { - if(event.entityPlayer == null || event.entityPlayer.worldObj == null) + if (event.entityPlayer == null || event.entityPlayer.worldObj == null) return; - if(event.entityPlayer.worldObj instanceof WorldServer) { + if (event.entityPlayer.worldObj instanceof WorldServer) { PlayerDataScript handler = ScriptController.Instance.playerScripts; IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.entityPlayer); EventHooks.onPlayerUseHoe(handler, scriptPlayer, event.current, event.x, event.y, event.z); @@ -307,10 +310,10 @@ public class ScriptPlayerEventHandler { @SubscribeEvent public void invoke(PlayerSleepInBedEvent event) { - if(event.entityPlayer == null || event.entityPlayer.worldObj == null) + if (event.entityPlayer == null || event.entityPlayer.worldObj == null) return; - if(event.entityPlayer.worldObj instanceof WorldServer) { + if (event.entityPlayer.worldObj instanceof WorldServer) { PlayerDataScript handler = ScriptController.Instance.playerScripts; IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.entityPlayer); EventHooks.onPlayerSleep(handler, scriptPlayer, event.x, event.y, event.z); @@ -319,10 +322,10 @@ public class ScriptPlayerEventHandler { @SubscribeEvent public void invoke(PlayerWakeUpEvent event) { - if(event.entityPlayer == null || event.entityPlayer.worldObj == null) + if (event.entityPlayer == null || event.entityPlayer.worldObj == null) return; - if(event.entityPlayer.worldObj instanceof WorldServer) { + if (event.entityPlayer.worldObj instanceof WorldServer) { PlayerDataScript handler = ScriptController.Instance.playerScripts; IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.entityPlayer); EventHooks.onPlayerWakeUp(handler, scriptPlayer, event.setSpawn); @@ -331,10 +334,10 @@ public class ScriptPlayerEventHandler { @SubscribeEvent public void invoke(FillBucketEvent event) { - if(event.entityPlayer == null || event.entityPlayer.worldObj == null) + if (event.entityPlayer == null || event.entityPlayer.worldObj == null) return; - if(event.entityPlayer.worldObj instanceof WorldServer) { + if (event.entityPlayer.worldObj instanceof WorldServer) { PlayerDataScript handler = ScriptController.Instance.playerScripts; IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.entityPlayer); EventHooks.onPlayerFillBucket(handler, scriptPlayer, event.current, event.result); @@ -343,10 +346,10 @@ public class ScriptPlayerEventHandler { @SubscribeEvent public void invoke(BonemealEvent event) { - if(event.entityPlayer == null || event.entityPlayer.worldObj == null) + if (event.entityPlayer == null || event.entityPlayer.worldObj == null) return; - if(event.entityPlayer.worldObj instanceof WorldServer) { + if (event.entityPlayer.worldObj instanceof WorldServer) { PlayerDataScript handler = ScriptController.Instance.playerScripts; IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.entityPlayer); EventHooks.onPlayerBonemeal(handler, scriptPlayer, event.x, event.y, event.z, event.world); @@ -355,10 +358,10 @@ public class ScriptPlayerEventHandler { @SubscribeEvent public void invoke(AchievementEvent event) { - if(event.entityPlayer == null || event.entityPlayer.worldObj == null) + if (event.entityPlayer == null || event.entityPlayer.worldObj == null) return; - if(event.entityPlayer.worldObj instanceof WorldServer) { + if (event.entityPlayer.worldObj instanceof WorldServer) { PlayerDataScript handler = ScriptController.Instance.playerScripts; IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.entityPlayer); EventHooks.onPlayerAchievement(handler, scriptPlayer, CustomNpcs.proxy.getAchievementDesc(event.achievement)); @@ -367,10 +370,10 @@ public class ScriptPlayerEventHandler { @SubscribeEvent public void invoke(ItemTossEvent event) { - if(event.player == null || event.player.worldObj == null) + if (event.player == null || event.player.worldObj == null) return; - if(event.player.worldObj instanceof WorldServer) { + if (event.player.worldObj instanceof WorldServer) { PlayerDataScript handler = ScriptController.Instance.playerScripts; IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.player); event.setCanceled(EventHooks.onPlayerToss(handler, scriptPlayer, event.entityItem)); @@ -379,10 +382,10 @@ public class ScriptPlayerEventHandler { @SubscribeEvent public void invoke(LivingFallEvent event) { - if(event.entityLiving == null || event.entityLiving.worldObj == null) + if (event.entityLiving == null || event.entityLiving.worldObj == null) return; - if(event.entityLiving.worldObj instanceof WorldServer) { + if (event.entityLiving.worldObj instanceof WorldServer) { if (event.entityLiving instanceof EntityPlayer) { PlayerDataScript handler = ScriptController.Instance.playerScripts; IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.entityLiving); @@ -393,10 +396,10 @@ public class ScriptPlayerEventHandler { @SubscribeEvent public void invoke(LivingEvent.LivingJumpEvent event) { - if(event.entityLiving == null || event.entityLiving.worldObj == null) + if (event.entityLiving == null || event.entityLiving.worldObj == null) return; - if(event.entityLiving.worldObj instanceof WorldServer) { + if (event.entityLiving.worldObj instanceof WorldServer) { if (event.entityLiving instanceof EntityPlayer) { PlayerDataScript handler = ScriptController.Instance.playerScripts; IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.entityLiving); @@ -407,10 +410,10 @@ public class ScriptPlayerEventHandler { @SubscribeEvent public void invoke(EntityStruckByLightningEvent event) { - if(event.entity == null || event.entity.worldObj == null) + if (event.entity == null || event.entity.worldObj == null) return; - if(event.entity.worldObj instanceof WorldServer) { + if (event.entity.worldObj instanceof WorldServer) { if (event.entity instanceof EntityPlayer) { PlayerDataScript handler = ScriptController.Instance.playerScripts; IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.entity); @@ -421,38 +424,39 @@ public class ScriptPlayerEventHandler { @SubscribeEvent public void invoke(PlaySoundAtEntityEvent event) { - if(event.entity == null || event.entity.worldObj == null) + if (event.entity == null || event.entity.worldObj == null) return; - if(event.entity.worldObj instanceof WorldServer) { + if (event.entity.worldObj instanceof WorldServer) { if (event.entity instanceof EntityPlayer) { PlayerDataScript handler = ScriptController.Instance.playerScripts; IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.entity); - EventHooks.onPlayerSound(handler,scriptPlayer,event.name,event.pitch,event.volume); + EventHooks.onPlayerSound(handler, scriptPlayer, event.name, event.pitch, event.volume); } } } @SubscribeEvent public void invoke(LivingDeathEvent event) { - if(event.entityLiving == null || event.entityLiving.worldObj == null) + if (event.entityLiving == null || event.entityLiving.worldObj == null) return; - if(event.entityLiving.worldObj instanceof WorldServer) { + if (event.entityLiving.worldObj instanceof WorldServer) { Entity source = NoppesUtilServer.GetDamageSource(event.source); PlayerDataScript handler = ScriptController.Instance.playerScripts; - if(event.entityLiving instanceof EntityPlayer) { + if (event.entityLiving instanceof EntityPlayer) { try { CustomEffectController.getInstance().killEffects((EntityPlayer) event.entityLiving); IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.entityLiving); - EventHooks.onPlayerDeath(handler,scriptPlayer, event.source, source); - } catch (Exception ignored) {} + EventHooks.onPlayerDeath(handler, scriptPlayer, event.source, source); + } catch (Exception ignored) { + } } - if(event.source.getEntity() instanceof EntityPlayer) { + if (event.source.getEntity() instanceof EntityPlayer) { IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.source.getEntity()); - EventHooks.onPlayerKills(handler,scriptPlayer, event.entityLiving); + EventHooks.onPlayerKills(handler, scriptPlayer, event.entityLiving); } } @@ -460,24 +464,24 @@ public class ScriptPlayerEventHandler { @SubscribeEvent public void invoke(LivingAttackEvent event) { - if(event.entityLiving == null || event.entityLiving.worldObj == null) + if (event.entityLiving == null || event.entityLiving.worldObj == null) return; - if(event.entityLiving.worldObj instanceof WorldServer) { + if (event.entityLiving.worldObj instanceof WorldServer) { boolean cancel = event.isCanceled(); Entity source = NoppesUtilServer.GetDamageSource(event.source); PlayerDataScript handler = ScriptController.Instance.playerScripts; - if(event.entityLiving instanceof EntityPlayer) { - noppes.npcs.scripted.event.PlayerEvent.AttackedEvent pevent = new noppes.npcs.scripted.event.PlayerEvent.AttackedEvent((IPlayer)NpcAPI.Instance().getIEntity((EntityPlayer)event.entityLiving), source, event.ammount, event.source); + if (event.entityLiving instanceof EntityPlayer) { + noppes.npcs.scripted.event.PlayerEvent.AttackedEvent pevent = new noppes.npcs.scripted.event.PlayerEvent.AttackedEvent((IPlayer) NpcAPI.Instance().getIEntity((EntityPlayer) event.entityLiving), source, event.ammount, event.source); cancel = EventHooks.onPlayerAttacked(handler, pevent); } - if(event.source.getEntity() instanceof EntityPlayer) { + if (event.source.getEntity() instanceof EntityPlayer) { float attackAmount = event.ammount; - if(ConfigMain.AttributesEnabled) + if (ConfigMain.AttributesEnabled) attackAmount = AttributeAttackUtil.calculateOutgoing((EntityPlayer) event.source.getEntity(), attackAmount); - noppes.npcs.scripted.event.PlayerEvent.AttackEvent pevent1 = new noppes.npcs.scripted.event.PlayerEvent.AttackEvent((IPlayer)NpcAPI.Instance().getIEntity((EntityPlayer)event.source.getEntity()), event.entityLiving, attackAmount, event.source); + noppes.npcs.scripted.event.PlayerEvent.AttackEvent pevent1 = new noppes.npcs.scripted.event.PlayerEvent.AttackEvent((IPlayer) NpcAPI.Instance().getIEntity((EntityPlayer) event.source.getEntity()), event.entityLiving, attackAmount, event.source); cancel = cancel || EventHooks.onPlayerAttack(handler, pevent1); } event.setCanceled(cancel); @@ -486,31 +490,31 @@ public class ScriptPlayerEventHandler { @SubscribeEvent public void invoke(LivingHurtEvent event) { - if(event.entityLiving == null || event.entityLiving.worldObj == null) + if (event.entityLiving == null || event.entityLiving.worldObj == null) return; - if(event.entityLiving.worldObj instanceof WorldServer) { + if (event.entityLiving.worldObj instanceof WorldServer) { boolean cancel = event.isCanceled(); Entity source = NoppesUtilServer.GetDamageSource(event.source); PlayerDataScript handler = ScriptController.Instance.playerScripts; // Player to Player Interaction - if(ConfigMain.AttributesEnabled){ - if(event.entityLiving instanceof EntityPlayer && source instanceof EntityPlayer){ + if (ConfigMain.AttributesEnabled) { + if (event.entityLiving instanceof EntityPlayer && source instanceof EntityPlayer) { event.ammount = AttributeAttackUtil.calculateDamagePlayerToPlayer((EntityPlayer) event.entityLiving, (EntityPlayer) source, event.ammount); - } else if (!(event.entityLiving instanceof EntityNPCInterface) && source instanceof EntityPlayer){ + } else if (!(event.entityLiving instanceof EntityNPCInterface) && source instanceof EntityPlayer) { event.ammount = AttributeAttackUtil.calculateOutgoing((EntityPlayer) source, event.ammount); } } - if(event.entityLiving instanceof EntityPlayer) { - noppes.npcs.scripted.event.PlayerEvent.DamagedEvent pevent = new noppes.npcs.scripted.event.PlayerEvent.DamagedEvent((IPlayer)NpcAPI.Instance().getIEntity((EntityPlayer)event.entityLiving), source, event.ammount, event.source); + if (event.entityLiving instanceof EntityPlayer) { + noppes.npcs.scripted.event.PlayerEvent.DamagedEvent pevent = new noppes.npcs.scripted.event.PlayerEvent.DamagedEvent((IPlayer) NpcAPI.Instance().getIEntity((EntityPlayer) event.entityLiving), source, event.ammount, event.source); cancel = EventHooks.onPlayerDamaged(handler, pevent); event.ammount = pevent.damage; } - if(source instanceof EntityPlayer) { - noppes.npcs.scripted.event.PlayerEvent.DamagedEntityEvent pevent1 = new noppes.npcs.scripted.event.PlayerEvent.DamagedEntityEvent((IPlayer)NpcAPI.Instance().getIEntity(source), event.entityLiving, event.ammount, event.source); + if (source instanceof EntityPlayer) { + noppes.npcs.scripted.event.PlayerEvent.DamagedEntityEvent pevent1 = new noppes.npcs.scripted.event.PlayerEvent.DamagedEntityEvent((IPlayer) NpcAPI.Instance().getIEntity(source), event.entityLiving, event.ammount, event.source); cancel = cancel || EventHooks.onPlayerDamagedEntity(handler, pevent1); event.ammount = pevent1.damage; } @@ -521,10 +525,10 @@ public class ScriptPlayerEventHandler { @SubscribeEvent public void invoke(PlayerEvent.PlayerRespawnEvent event) { - if(event.player == null || event.player.worldObj == null) + if (event.player == null || event.player.worldObj == null) return; - if(event.player.worldObj instanceof WorldServer) { + if (event.player.worldObj instanceof WorldServer) { PlayerDataScript handler = ScriptController.Instance.playerScripts; IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.player); EventHooks.onPlayerRespawn(handler, scriptPlayer); @@ -533,22 +537,21 @@ public class ScriptPlayerEventHandler { @SubscribeEvent public void invoke(PlayerEvent.PlayerLoggedInEvent event) { - if(event.player == null || event.player.worldObj == null) + if (event.player == null || event.player.worldObj == null) return; - if(event.player.worldObj instanceof WorldServer) { + if (event.player.worldObj instanceof WorldServer) { PlayerDataScript handler = ScriptController.Instance.playerScripts; IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.player); EventHooks.onPlayerLogin(handler, scriptPlayer); - PlayerData playerData = PlayerDataController.Instance.getPlayerData(event.player); + PlayerData playerData = PlayerDataController.Instance.getPlayerData(event.player); Quest quest = (Quest) playerData.questData.getTrackedQuest(); if (quest != null) { Party party = playerData.getPlayerParty(); - if(party != null && party.getQuest() != null && party.getQuest().getId() == quest.getId()){ + if (party != null && party.getQuest() != null && party.getQuest().getId() == quest.getId()) { NoppesUtilPlayer.sendPartyTrackedQuestData((EntityPlayerMP) event.player, party); - } - else { + } else { NoppesUtilPlayer.sendTrackedQuestData((EntityPlayerMP) event.player); } } @@ -559,10 +562,10 @@ public class ScriptPlayerEventHandler { @SubscribeEvent public void invoke(PlayerEvent.PlayerLoggedOutEvent event) { - if(event.player == null || event.player.worldObj == null) + if (event.player == null || event.player.worldObj == null) return; - if(event.player.worldObj instanceof WorldServer) { + if (event.player.worldObj instanceof WorldServer) { PlayerDataScript handler = ScriptController.Instance.playerScripts; IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.player); EventHooks.onPlayerLogout(handler, scriptPlayer); @@ -570,20 +573,20 @@ public class ScriptPlayerEventHandler { } @SubscribeEvent( - priority = EventPriority.HIGHEST + priority = EventPriority.HIGHEST ) public void invoke(net.minecraftforge.event.ServerChatEvent event) { - if(event.player == null || event.player.worldObj == null) + if (event.player == null || event.player.worldObj == null) return; - if(event.player.worldObj instanceof WorldServer && !event.player.equals(EntityNPCInterface.chateventPlayer)) { + if (event.player.worldObj instanceof WorldServer && !event.player.equals(EntityNPCInterface.chateventPlayer)) { PlayerDataScript handler = ScriptController.Instance.playerScripts; IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.player); String message = event.message; noppes.npcs.scripted.event.PlayerEvent.ChatEvent ev = new noppes.npcs.scripted.event.PlayerEvent.ChatEvent(scriptPlayer, event.message); EventHooks.onPlayerChat(handler, ev); event.setCanceled(ev.isCanceled()); - if(!message.equals(ev.message)) { + if (!message.equals(ev.message)) { ChatComponentTranslation chat = new ChatComponentTranslation("", new Object[0]); chat.appendSibling(ForgeHooks.newChatWithLinks(ev.message)); event.component = chat; diff --git a/src/main/java/noppes/npcs/Server.java b/src/main/java/noppes/npcs/Server.java index ff7f73b0c..f6e872d8b 100644 --- a/src/main/java/noppes/npcs/Server.java +++ b/src/main/java/noppes/npcs/Server.java @@ -12,57 +12,54 @@ import java.util.List; import java.util.Map; public class Server { - public static boolean fillBuffer(ByteBuf buffer, Enum enu, Object... obs) throws IOException{ - buffer.writeInt(enu.ordinal()); - for(Object ob : obs){ - if(ob == null) - continue; - if(ob instanceof Map){ - Map map = (Map) ob; + public static boolean fillBuffer(ByteBuf buffer, Enum enu, Object... obs) throws IOException { + buffer.writeInt(enu.ordinal()); + for (Object ob : obs) { + if (ob == null) + continue; + if (ob instanceof Map) { + Map map = (Map) ob; - buffer.writeInt(map.size()); - for(String key : map.keySet()){ - int value = map.get(key); - buffer.writeInt(value); - ByteBufUtils.writeString(buffer, key); - } - } - else if(ob instanceof MerchantRecipeList) - ((MerchantRecipeList)ob).func_151391_a(new PacketBuffer(buffer)); - else if(ob instanceof List){ - List list = (List) ob; - buffer.writeInt(list.size()); - for(String s : list) - ByteBufUtils.writeString(buffer, s); - } - else if(ob instanceof Enum) - buffer.writeInt(((Enum) ob).ordinal()); - else if(ob instanceof Integer) - buffer.writeInt((Integer) ob); - else if(ob instanceof Boolean) - buffer.writeBoolean((Boolean) ob); - else if(ob instanceof String) - ByteBufUtils.writeString(buffer, (String) ob); - else if(ob instanceof Float) - buffer.writeFloat((Float) ob); - else if(ob instanceof Long) - buffer.writeLong((Long) ob); - else if(ob instanceof Double) - buffer.writeDouble((Double) ob); + buffer.writeInt(map.size()); + for (String key : map.keySet()) { + int value = map.get(key); + buffer.writeInt(value); + ByteBufUtils.writeString(buffer, key); + } + } else if (ob instanceof MerchantRecipeList) + ((MerchantRecipeList) ob).func_151391_a(new PacketBuffer(buffer)); + else if (ob instanceof List) { + List list = (List) ob; + buffer.writeInt(list.size()); + for (String s : list) + ByteBufUtils.writeString(buffer, s); + } else if (ob instanceof Enum) + buffer.writeInt(((Enum) ob).ordinal()); + else if (ob instanceof Integer) + buffer.writeInt((Integer) ob); + else if (ob instanceof Boolean) + buffer.writeBoolean((Boolean) ob); + else if (ob instanceof String) + ByteBufUtils.writeString(buffer, (String) ob); + else if (ob instanceof Float) + buffer.writeFloat((Float) ob); + else if (ob instanceof Long) + buffer.writeLong((Long) ob); + else if (ob instanceof Double) + buffer.writeDouble((Double) ob); else if (ob instanceof byte[]) { // Write byte array length followed by bytes byte[] byteArray = (byte[]) ob; buffer.writeShort((short) byteArray.length); buffer.writeBytes(byteArray); - } - else if(ob instanceof NBTTagCompound) - ByteBufUtils.writeNBT(buffer, (NBTTagCompound) ob); - } - if(buffer.array().length >= 32767){ - LogWriter.error("Packet " + enu + " was too big to be send"); - LogWriter.script( "Issue occurred with the following Packet - " + enu + ":\n" + Arrays.toString(obs)); + } else if (ob instanceof NBTTagCompound) + ByteBufUtils.writeNBT(buffer, (NBTTagCompound) ob); + } + if (buffer.array().length >= 32767) { + LogWriter.error("Packet " + enu + " was too big to be send"); + LogWriter.script("Issue occurred with the following Packet - " + enu + ":\n" + Arrays.toString(obs)); return false; - } + } return true; - } + } } diff --git a/src/main/java/noppes/npcs/ServerEventsHandler.java b/src/main/java/noppes/npcs/ServerEventsHandler.java index 87cb4a3f9..5a8c05874 100644 --- a/src/main/java/noppes/npcs/ServerEventsHandler.java +++ b/src/main/java/noppes/npcs/ServerEventsHandler.java @@ -63,247 +63,242 @@ import java.util.List; public class ServerEventsHandler { - public static EntityVillager Merchant; - public static Entity mounted; + public static EntityVillager Merchant; + public static Entity mounted; - @SubscribeEvent - public void invoke(EntityInteractEvent event) { - ItemStack item = event.entityPlayer.getCurrentEquippedItem(); - if(item == null) - return; - boolean isRemote = event.entityPlayer.worldObj.isRemote; - boolean npcInteracted = event.target instanceof EntityNPCInterface; + @SubscribeEvent + public void invoke(EntityInteractEvent event) { + ItemStack item = event.entityPlayer.getCurrentEquippedItem(); + if (item == null) + return; + boolean isRemote = event.entityPlayer.worldObj.isRemote; + boolean npcInteracted = event.target instanceof EntityNPCInterface; - if(!isRemote && ConfigMain.OpsOnly && !MinecraftServer.getServer().getConfigurationManager().func_152596_g(event.entityPlayer.getGameProfile())){ - return; - } + if (!isRemote && ConfigMain.OpsOnly && !MinecraftServer.getServer().getConfigurationManager().func_152596_g(event.entityPlayer.getGameProfile())) { + return; + } - if(!isRemote && item.getItem() == CustomItems.soulstoneEmpty) { - if(event.target instanceof EntityLivingBase){ - ((ItemSoulstoneEmpty)item.getItem()).store((EntityLivingBase)event.target, item, event.entityPlayer); - if(ConfigDebug.PlayerLogging && FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER){ + if (!isRemote && item.getItem() == CustomItems.soulstoneEmpty) { + if (event.target instanceof EntityLivingBase) { + ((ItemSoulstoneEmpty) item.getItem()).store((EntityLivingBase) event.target, item, event.entityPlayer); + if (ConfigDebug.PlayerLogging && FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER) { LogWriter.script(String.format("[%s] (Player) %s PICKED ENTITY %s", "SOULSTONE", event.entityPlayer.getCommandSenderName(), event.target)); } } - } + } - if(item.getItem() == CustomItems.wand && npcInteracted && !isRemote){ - if (!CustomNpcsPermissions.hasPermission(event.entityPlayer, CustomNpcsPermissions.NPC_GUI)){ - return; - } - event.setCanceled(true); - NoppesUtilServer.sendOpenGui(event.entityPlayer, EnumGuiType.MainMenuDisplay, (EntityNPCInterface) event.target); - if(ConfigDebug.PlayerLogging && FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER){ - LogWriter.script(String.format("[%s] (Player) %s OPEN NPC %s (%s, %s, %s) [%s]", "WAND", event.entityPlayer.getCommandSenderName(), ((EntityNPCInterface)(event.target)).display.getName(), (int)(event.target).posX, (int)(event.target).posY, (int)(event.target).posZ, (event.target).worldObj.getWorldInfo().getWorldName())); - } - } - else if(item.getItem() == CustomItems.cloner && !isRemote && !(event.target instanceof EntityPlayer)){ - if(!CustomNpcsPermissions.hasPermission(event.entityPlayer, CustomNpcsPermissions.TOOL_CLONER)) + if (item.getItem() == CustomItems.wand && npcInteracted && !isRemote) { + if (!CustomNpcsPermissions.hasPermission(event.entityPlayer, CustomNpcsPermissions.NPC_GUI)) { return; - NBTTagCompound compound = new NBTTagCompound(); - if(!event.target.writeToNBTOptional(compound)) - return; - PlayerData data = PlayerDataController.Instance.getPlayerData(event.entityPlayer); - ServerCloneController.Instance.cleanTags(compound); - PacketHandler.Instance.sendToPlayer(new ClonerPacket(compound), (EntityPlayerMP)event.entityPlayer); - data.cloned = compound; - if (event.target instanceof EntityNPCInterface) { - NoppesUtilServer.setEditingNpc(event.entityPlayer, (EntityNPCInterface) event.target); - } - event.setCanceled(true); - } - else if(item.getItem() == CustomItems.scripter && !isRemote && npcInteracted){ - if(!CustomNpcsPermissions.hasPermission(event.entityPlayer, CustomNpcsPermissions.TOOL_SCRIPTER)) - return; - NoppesUtilServer.setEditingNpc(event.entityPlayer, (EntityNPCInterface)event.target); - event.setCanceled(true); - GuiOpenPacket.openGUI((EntityPlayerMP)event.entityPlayer, EnumGuiType.Script, 0, 0, 0); - if(ConfigDebug.PlayerLogging && FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER){ - LogWriter.script(String.format("[%s] (Player) %s OPEN NPC %s (%s, %s, %s) [%s]", "SCRIPTER", event.entityPlayer.getCommandSenderName(), ((EntityNPCInterface)(event.target)).display.getName(), (int)(event.target).posX, (int)(event.target).posY, (int)(event.target).posZ, (event.target).worldObj.getWorldInfo().getWorldName())); - } - } - else if(item.getItem() == CustomItems.mount){ - if(!CustomNpcsPermissions.hasPermission(event.entityPlayer, CustomNpcsPermissions.TOOL_MOUNTER)) - return; - event.setCanceled(true); - mounted = event.target; - if(isRemote) - CustomNpcs.proxy.openGui(MathHelper.floor_double(mounted.posX), MathHelper.floor_double(mounted.posY), MathHelper.floor_double(mounted.posZ), EnumGuiType.MobSpawnerMounter, event.entityPlayer); - } - else if(item.getItem() == CustomItems.wand && !isRemote && event.target instanceof EntityVillager){ - if(!CustomNpcsPermissions.hasPermission(event.entityPlayer, CustomNpcsPermissions.EDIT_VILLAGER)) - return; - event.setCanceled(true); - Merchant = (EntityVillager)event.target; + } + event.setCanceled(true); + NoppesUtilServer.sendOpenGui(event.entityPlayer, EnumGuiType.MainMenuDisplay, (EntityNPCInterface) event.target); + if (ConfigDebug.PlayerLogging && FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER) { + LogWriter.script(String.format("[%s] (Player) %s OPEN NPC %s (%s, %s, %s) [%s]", "WAND", event.entityPlayer.getCommandSenderName(), ((EntityNPCInterface) (event.target)).display.getName(), (int) (event.target).posX, (int) (event.target).posY, (int) (event.target).posZ, (event.target).worldObj.getWorldInfo().getWorldName())); + } + } else if (item.getItem() == CustomItems.cloner && !isRemote && !(event.target instanceof EntityPlayer)) { + if (!CustomNpcsPermissions.hasPermission(event.entityPlayer, CustomNpcsPermissions.TOOL_CLONER)) + return; + NBTTagCompound compound = new NBTTagCompound(); + if (!event.target.writeToNBTOptional(compound)) + return; + PlayerData data = PlayerDataController.Instance.getPlayerData(event.entityPlayer); + ServerCloneController.Instance.cleanTags(compound); + PacketHandler.Instance.sendToPlayer(new ClonerPacket(compound), (EntityPlayerMP) event.entityPlayer); + data.cloned = compound; + if (event.target instanceof EntityNPCInterface) { + NoppesUtilServer.setEditingNpc(event.entityPlayer, (EntityNPCInterface) event.target); + } + event.setCanceled(true); + } else if (item.getItem() == CustomItems.scripter && !isRemote && npcInteracted) { + if (!CustomNpcsPermissions.hasPermission(event.entityPlayer, CustomNpcsPermissions.TOOL_SCRIPTER)) + return; + NoppesUtilServer.setEditingNpc(event.entityPlayer, (EntityNPCInterface) event.target); + event.setCanceled(true); + GuiOpenPacket.openGUI((EntityPlayerMP) event.entityPlayer, EnumGuiType.Script, 0, 0, 0); + if (ConfigDebug.PlayerLogging && FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER) { + LogWriter.script(String.format("[%s] (Player) %s OPEN NPC %s (%s, %s, %s) [%s]", "SCRIPTER", event.entityPlayer.getCommandSenderName(), ((EntityNPCInterface) (event.target)).display.getName(), (int) (event.target).posX, (int) (event.target).posY, (int) (event.target).posZ, (event.target).worldObj.getWorldInfo().getWorldName())); + } + } else if (item.getItem() == CustomItems.mount) { + if (!CustomNpcsPermissions.hasPermission(event.entityPlayer, CustomNpcsPermissions.TOOL_MOUNTER)) + return; + event.setCanceled(true); + mounted = event.target; + if (isRemote) + CustomNpcs.proxy.openGui(MathHelper.floor_double(mounted.posX), MathHelper.floor_double(mounted.posY), MathHelper.floor_double(mounted.posZ), EnumGuiType.MobSpawnerMounter, event.entityPlayer); + } else if (item.getItem() == CustomItems.wand && !isRemote && event.target instanceof EntityVillager) { + if (!CustomNpcsPermissions.hasPermission(event.entityPlayer, CustomNpcsPermissions.EDIT_VILLAGER)) + return; + event.setCanceled(true); + Merchant = (EntityVillager) event.target; - if(!isRemote){ - EntityPlayerMP player = (EntityPlayerMP) event.entityPlayer; - player.openGui(CustomNpcs.instance, EnumGuiType.MerchantAdd.ordinal(), player.worldObj, 0, 0, 0); - MerchantRecipeList merchantrecipelist = Merchant.getRecipes(player); + if (!isRemote) { + EntityPlayerMP player = (EntityPlayerMP) event.entityPlayer; + player.openGui(CustomNpcs.instance, EnumGuiType.MerchantAdd.ordinal(), player.worldObj, 0, 0, 0); + MerchantRecipeList merchantrecipelist = Merchant.getRecipes(player); - if (merchantrecipelist != null) - { + if (merchantrecipelist != null) { PacketHandler.Instance.sendToPlayer(new VillagerListPacket(merchantrecipelist), player); - } - } - } - } + } + } + } + } - @SubscribeEvent - public void partyDamagedEvent(LivingAttackEvent event) { - if(!(event.source != null && event.source.getEntity() instanceof EntityPlayer) || !(event.entityLiving instanceof EntityPlayer) || FMLCommonHandler.instance().getEffectiveSide().isClient()) - return; + @SubscribeEvent + public void partyDamagedEvent(LivingAttackEvent event) { + if (!(event.source != null && event.source.getEntity() instanceof EntityPlayer) || !(event.entityLiving instanceof EntityPlayer) || FMLCommonHandler.instance().getEffectiveSide().isClient()) + return; // Check for Friendly Fire - if(ConfigMain.PartyFriendlyFireEnabled){ + if (ConfigMain.PartyFriendlyFireEnabled) { EntityPlayer sourcePlayer = (EntityPlayer) event.source.getEntity(); PlayerData playerData = PlayerDataController.Instance.getPlayerData(sourcePlayer); PlayerData targetData = PlayerDataController.Instance.getPlayerData((EntityPlayer) event.entityLiving); if (playerData.partyUUID != null && playerData.partyUUID.equals(targetData.partyUUID)) { Party party = PartyController.Instance().getParty(playerData.partyUUID); - if(party != null && !party.friendlyFire()) + if (party != null && !party.friendlyFire()) event.setCanceled(true); } } - } + } - @SubscribeEvent - public void invoke(LivingHurtEvent event) { - if(!(event.entityLiving instanceof EntityPlayer)) - return; + @SubscribeEvent + public void invoke(LivingHurtEvent event) { + if (!(event.entityLiving instanceof EntityPlayer)) + return; - EntityPlayer player = (EntityPlayer) event.entityLiving; - if(event.source.isUnblockable() || event.source.isFireDamage()) - return; - if(!player.isBlocking()) - return; - ItemStack item = player.getCurrentEquippedItem(); - if(item == null || !(item.getItem() instanceof ItemShield)) - return; - if(((ItemShield)item.getItem()).material.getDamageVsEntity() < player.getRNG().nextInt(9)) - return; - float damage = item.getItemDamage() + event.ammount; + EntityPlayer player = (EntityPlayer) event.entityLiving; + if (event.source.isUnblockable() || event.source.isFireDamage()) + return; + if (!player.isBlocking()) + return; + ItemStack item = player.getCurrentEquippedItem(); + if (item == null || !(item.getItem() instanceof ItemShield)) + return; + if (((ItemShield) item.getItem()).material.getDamageVsEntity() < player.getRNG().nextInt(9)) + return; + float damage = item.getItemDamage() + event.ammount; - item.damageItem((int) event.ammount, player); + item.damageItem((int) event.ammount, player); - if(damage > item.getMaxDamage()) - event.ammount = damage - item.getMaxDamage(); - else{ - event.ammount = 0; - event.setCanceled(true); - } - } + if (damage > item.getMaxDamage()) + event.ammount = damage - item.getMaxDamage(); + else { + event.ammount = 0; + event.setCanceled(true); + } + } - @SubscribeEvent - public void invoke(PlayerInteractEvent event) { - EntityPlayer player = event.entityPlayer; - Block block = player.worldObj.getBlock(event.x, event.y, event.z); - if(event.action == Action.LEFT_CLICK_BLOCK && player.getHeldItem() != null && player.getHeldItem().getItem() == CustomItems.teleporter){ - event.setCanceled(true); - } + @SubscribeEvent + public void invoke(PlayerInteractEvent event) { + EntityPlayer player = event.entityPlayer; + Block block = player.worldObj.getBlock(event.x, event.y, event.z); + if (event.action == Action.LEFT_CLICK_BLOCK && player.getHeldItem() != null && player.getHeldItem().getItem() == CustomItems.teleporter) { + event.setCanceled(true); + } - if(block == Blocks.crafting_table && event.action == Action.RIGHT_CLICK_BLOCK && !player.worldObj.isRemote){ + if (block == Blocks.crafting_table && event.action == Action.RIGHT_CLICK_BLOCK && !player.worldObj.isRemote) { PacketHandler.Instance.sendToPlayer(new SyncPacket( EnumSyncType.WORKBENCH_RECIPES, EnumSyncAction.RELOAD, -1, SyncController.workbenchNBT() ), (EntityPlayerMP) player); - } - if(block == CustomItems.carpentyBench && event.action == Action.RIGHT_CLICK_BLOCK && !player.worldObj.isRemote){ + } + if (block == CustomItems.carpentyBench && event.action == Action.RIGHT_CLICK_BLOCK && !player.worldObj.isRemote) { PacketHandler.Instance.sendToPlayer(new SyncPacket( EnumSyncType.CARPENTRY_RECIPES, EnumSyncAction.RELOAD, -1, SyncController.carpentryNBT() ), (EntityPlayerMP) player); - } - if((block == CustomItems.banner || block == CustomItems.wallBanner || block == CustomItems.sign) && event.action == Action.RIGHT_CLICK_BLOCK){ - ItemStack item = player.inventory.getCurrentItem(); - if(item == null || item.getItem() == null) - return; - int y = event.y; - int meta = player.worldObj.getBlockMetadata(event.x, event.y, event.z); - if(meta >= 7) - y--; - ITileIcon tile = (ITileIcon)player.worldObj.getTileEntity(event.x, y, event.z); - if(!tile.canEdit()){ - if(item.getItem() == CustomItems.wand && CustomNpcsPermissions.hasPermission(player, CustomNpcsPermissions.EDIT_BLOCKS)){ - tile.setTime(System.currentTimeMillis()); - if(player.worldObj.isRemote) - player.addChatComponentMessage(new ChatComponentTranslation("availability.editIcon")); - } - return; - } + } + if ((block == CustomItems.banner || block == CustomItems.wallBanner || block == CustomItems.sign) && event.action == Action.RIGHT_CLICK_BLOCK) { + ItemStack item = player.inventory.getCurrentItem(); + if (item == null || item.getItem() == null) + return; + int y = event.y; + int meta = player.worldObj.getBlockMetadata(event.x, event.y, event.z); + if (meta >= 7) + y--; + ITileIcon tile = (ITileIcon) player.worldObj.getTileEntity(event.x, y, event.z); + if (!tile.canEdit()) { + if (item.getItem() == CustomItems.wand && CustomNpcsPermissions.hasPermission(player, CustomNpcsPermissions.EDIT_BLOCKS)) { + tile.setTime(System.currentTimeMillis()); + if (player.worldObj.isRemote) + player.addChatComponentMessage(new ChatComponentTranslation("availability.editIcon")); + } + return; + } - if(!player.worldObj.isRemote){ - tile.setIcon(item.copy()); - player.worldObj.markBlockForUpdate(event.x, y, event.z); - event.setCanceled(true); - } - } - } + if (!player.worldObj.isRemote) { + tile.setIcon(item.copy()); + player.worldObj.markBlockForUpdate(event.x, y, event.z); + event.setCanceled(true); + } + } + } - @SubscribeEvent - public void invoke(LivingDeathEvent event) { - if(event.entityLiving.worldObj.isRemote) - return; - if(event.source.getEntity() != null){ - if(event.source.getEntity() instanceof EntityPlayer){ - doExcalibur((EntityPlayer) event.source.getEntity(),event.entityLiving); - } + @SubscribeEvent + public void invoke(LivingDeathEvent event) { + if (event.entityLiving.worldObj.isRemote) + return; + if (event.source.getEntity() != null) { + if (event.source.getEntity() instanceof EntityPlayer) { + doExcalibur((EntityPlayer) event.source.getEntity(), event.entityLiving); + } - if(event.source.getEntity() instanceof EntityNPCInterface){ - EntityNPCInterface npc = (EntityNPCInterface) event.source.getEntity(); - Line line = npc.advanced.getKillLine(); - if(line != null) - npc.saySurrounding(line.formatTarget(event.entityLiving)); + if (event.source.getEntity() instanceof EntityNPCInterface) { + EntityNPCInterface npc = (EntityNPCInterface) event.source.getEntity(); + Line line = npc.advanced.getKillLine(); + if (line != null) + npc.saySurrounding(line.formatTarget(event.entityLiving)); - EventHooks.onNPCKilledEntity(npc,event.entityLiving); - } + EventHooks.onNPCKilledEntity(npc, event.entityLiving); + } - EntityPlayer player = null; - if(event.source.getEntity() instanceof EntityPlayer) - player = (EntityPlayer) event.source.getEntity(); - else if(event.source.getEntity() instanceof EntityNPCInterface && ((EntityNPCInterface)event.source.getEntity()).advanced.role == EnumRoleType.Follower) - player = ((RoleFollower)((EntityNPCInterface)event.source.getEntity()).roleInterface).owner; - if(player != null){ - doQuest(player, event.entityLiving, true); + EntityPlayer player = null; + if (event.source.getEntity() instanceof EntityPlayer) + player = (EntityPlayer) event.source.getEntity(); + else if (event.source.getEntity() instanceof EntityNPCInterface && ((EntityNPCInterface) event.source.getEntity()).advanced.role == EnumRoleType.Follower) + player = ((RoleFollower) ((EntityNPCInterface) event.source.getEntity()).roleInterface).owner; + if (player != null) { + doQuest(player, event.entityLiving, true); - if(event.entityLiving instanceof EntityNPCInterface) - doFactionPoints(player, (EntityNPCInterface)event.entityLiving); - } - } - if(event.entityLiving instanceof EntityPlayer){ - PlayerData data = PlayerDataController.Instance.getPlayerData((EntityPlayer)event.entityLiving); - data.save(); - } - } + if (event.entityLiving instanceof EntityNPCInterface) + doFactionPoints(player, (EntityNPCInterface) event.entityLiving); + } + } + if (event.entityLiving instanceof EntityPlayer) { + PlayerData data = PlayerDataController.Instance.getPlayerData((EntityPlayer) event.entityLiving); + data.save(); + } + } - @SubscribeEvent - public void onPlayerClone(PlayerEvent.Clone event) { - if (event.entity.worldObj.isRemote) - return; + @SubscribeEvent + public void onPlayerClone(PlayerEvent.Clone event) { + if (event.entity.worldObj.isRemote) + return; - NBTTagCompound storedData = event.original.getEntityData().getCompoundTag("CNPCStoredData"); - if (!storedData.hasNoTags()) { - event.entityPlayer.getEntityData().setTag("CNPCStoredData", storedData); - } - } + NBTTagCompound storedData = event.original.getEntityData().getCompoundTag("CNPCStoredData"); + if (!storedData.hasNoTags()) { + event.entityPlayer.getEntityData().setTag("CNPCStoredData", storedData); + } + } - private void doExcalibur(EntityPlayer player, EntityLivingBase entity) { - ItemStack item = player.getCurrentEquippedItem(); - if(item == null || item.getItem() != CustomItems.excalibur) - return; - PacketHandler.Instance.sendToPlayer(new SoundManagementPacket(EnumSoundOperation.PLAY_MUSIC, "customnpcs:songs.excalibur"), (EntityPlayerMP)player); - player.addChatMessage(new ChatComponentTranslation("<" + StatCollector.translateToLocal(item.getItem().getUnlocalizedName() + ".name") + "> " + ItemExcalibur.quotes[player.getRNG().nextInt(ItemExcalibur.quotes.length)])); - } + private void doExcalibur(EntityPlayer player, EntityLivingBase entity) { + ItemStack item = player.getCurrentEquippedItem(); + if (item == null || item.getItem() != CustomItems.excalibur) + return; + PacketHandler.Instance.sendToPlayer(new SoundManagementPacket(EnumSoundOperation.PLAY_MUSIC, "customnpcs:songs.excalibur"), (EntityPlayerMP) player); + player.addChatMessage(new ChatComponentTranslation("<" + StatCollector.translateToLocal(item.getItem().getUnlocalizedName() + ".name") + "> " + ItemExcalibur.quotes[player.getRNG().nextInt(ItemExcalibur.quotes.length)])); + } - private void doFactionPoints(EntityPlayer player, EntityNPCInterface npc) { - npc.advanced.factions.addPoints(player); - } + private void doFactionPoints(EntityPlayer player, EntityNPCInterface npc) { + npc.advanced.factions.addPoints(player); + } - private void doQuest(EntityPlayer player, EntityLivingBase entity, boolean all) { + private void doQuest(EntityPlayer player, EntityLivingBase entity, boolean all) { PlayerData playerData = PlayerData.get(player); if (playerData == null) { return; @@ -315,15 +310,15 @@ public class ServerEventsHandler { } boolean checkCompletion = false; String entityName = EntityList.getEntityString(entity); - if(entity instanceof EntityPlayer) + if (entity instanceof EntityPlayer) entityName = "Player"; Party party = playerData.getPlayerParty(); Quest partyQuest = null; - if(party != null){ - if(party.getQuestData() != null){ + if (party != null) { + if (party.getQuestData() != null) { partyQuest = party.getQuestData().quest; - if(partyQuest != null && (partyQuest.type == EnumQuestType.Kill || partyQuest.type == EnumQuestType.AreaKill )) + if (partyQuest != null && (partyQuest.type == EnumQuestType.Kill || partyQuest.type == EnumQuestType.AreaKill)) doPartyQuest(player, party, entity); else partyQuest = null; @@ -331,41 +326,41 @@ public class ServerEventsHandler { } ArrayList activeQuestValues = new ArrayList<>(questData.activeQuests.values()); - for(QuestData data : activeQuestValues){ + for (QuestData data : activeQuestValues) { if (data.quest == null) { continue; } - if (data.quest.type != EnumQuestType.Kill && data.quest.type != EnumQuestType.AreaKill) - continue; - - if(partyQuest != null && partyQuest.getId() == data.quest.getId()) + if (data.quest.type != EnumQuestType.Kill && data.quest.type != EnumQuestType.AreaKill) continue; - if(data.quest.partyOptions.allowParty && data.quest.partyOptions.onlyParty) + if (partyQuest != null && partyQuest.getId() == data.quest.getId()) continue; - if(data.quest.type == EnumQuestType.AreaKill && all){ + if (data.quest.partyOptions.allowParty && data.quest.partyOptions.onlyParty) + continue; + + if (data.quest.type == EnumQuestType.AreaKill && all) { List list = player.worldObj.getEntitiesWithinAABB(EntityPlayer.class, entity.boundingBox.expand(10, 10, 10)); - for(EntityPlayer pl : list) - if(pl != player) + for (EntityPlayer pl : list) + if (pl != player) doQuest(pl, entity, false); } String name = entityName; - QuestKill quest = (QuestKill) data.quest.questInterface; - Class entityType = EntityNPCInterface.class; - if (quest.targetType == 2) { - try { - entityType = Class.forName(quest.customTargetType); - } catch (ClassNotFoundException notFoundException) { - continue; - } - } + QuestKill quest = (QuestKill) data.quest.questInterface; + Class entityType = EntityNPCInterface.class; + if (quest.targetType == 2) { + try { + entityType = Class.forName(quest.customTargetType); + } catch (ClassNotFoundException notFoundException) { + continue; + } + } - if (quest.targetType > 0 && !(entityType.isInstance(entity))) - continue; + if (quest.targetType > 0 && !(entityType.isInstance(entity))) + continue; if (entity.getCommandSenderName() != null && quest.targets != null && quest.targets.containsKey(entity.getCommandSenderName())) { name = entity.getCommandSenderName(); @@ -373,31 +368,31 @@ public class ServerEventsHandler { continue; } - checkCompletion = true; + checkCompletion = true; HashMap killed = quest.getKilled(data); - if (!killed.containsKey(name)) { - killed.put(name, 1); - } else if(killed.get(name) < quest.targets.get(name)) { - int amount = killed.get(name); - killed.put(name, amount + 1); - } - quest.setKilled(data, killed); + if (!killed.containsKey(name)) { + killed.put(name, 1); + } else if (killed.get(name) < quest.targets.get(name)) { + int amount = killed.get(name); + killed.put(name, amount + 1); + } + quest.setKilled(data, killed); playerData.updateClient = true; - } - if(!checkCompletion) - return; - - questData.checkQuestCompletion(playerData,EnumQuestType.Kill); - } - - private void doPartyQuest(EntityPlayer player, Party party, EntityLivingBase entity){ - PlayerData pdata = PlayerData.get(player); - QuestData data = party.getQuestData(); - if(data == null) + } + if (!checkCompletion) return; - if(pdata == null) + questData.checkQuestCompletion(playerData, EnumQuestType.Kill); + } + + private void doPartyQuest(EntityPlayer player, Party party, EntityLivingBase entity) { + PlayerData pdata = PlayerData.get(player); + QuestData data = party.getQuestData(); + if (data == null) + return; + + if (pdata == null) return; if (data.quest.type != EnumQuestType.Kill && data.quest.type != EnumQuestType.AreaKill) @@ -405,7 +400,7 @@ public class ServerEventsHandler { String name = EntityList.getEntityString(entity); QuestKill quest = (QuestKill) data.quest.questInterface; - if(data.quest.partyOptions.objectiveRequirement == EnumPartyObjectives.Leader && !party.getLeaderUUID().equals(player.getUniqueID())) + if (data.quest.partyOptions.objectiveRequirement == EnumPartyObjectives.Leader && !party.getLeaderUUID().equals(player.getUniqueID())) return; Class entityType = EntityNPCInterface.class; @@ -425,21 +420,20 @@ public class ServerEventsHandler { else if (!quest.targets.containsKey(name)) return; - if(data.quest.partyOptions.objectiveRequirement == EnumPartyObjectives.All){ + if (data.quest.partyOptions.objectiveRequirement == EnumPartyObjectives.All) { HashMap killed = quest.getPlayerKilled(data, player.getCommandSenderName()); if (!killed.containsKey(name)) { killed.put(name, 1); - } else if(killed.get(name) < quest.targets.get(name)) { + } else if (killed.get(name) < quest.targets.get(name)) { int amount = killed.get(name); killed.put(name, amount + 1); } quest.setPlayerKilled(data, killed, player.getCommandSenderName()); - } - else { + } else { HashMap killed = quest.getKilled(data); if (!killed.containsKey(name)) { killed.put(name, 1); - } else if(killed.get(name) < quest.targets.get(name)) { + } else if (killed.get(name) < quest.targets.get(name)) { int amount = killed.get(name); killed.put(name, amount + 1); } @@ -451,28 +445,28 @@ public class ServerEventsHandler { PartyController.Instance().checkQuestCompletion(party, EnumQuestType.Kill); } - @SubscribeEvent - public void world(PlayerEvent.SaveToFile event){ - PlayerData data = PlayerDataController.Instance.getPlayerData((EntityPlayer) event.entity); - data.save(); - } - - @SubscribeEvent - public void world(EntityJoinWorldEvent event){ - if(event.world.isRemote || !(event.entity instanceof EntityPlayer)) - return; - PlayerData data = PlayerDataController.Instance.getPlayerData((EntityPlayer) event.entity); - data.updateCompanion(event.world); - } - - @SubscribeEvent - public void populateChunk(PopulateChunkEvent.Post event){ - NPCSpawning.performWorldGenSpawning(event.world, event.chunkX, event.chunkZ, event.rand); - } + @SubscribeEvent + public void world(PlayerEvent.SaveToFile event) { + PlayerData data = PlayerDataController.Instance.getPlayerData((EntityPlayer) event.entity); + data.save(); + } @SubscribeEvent - public void playerTracking(PlayerEvent.StartTracking event){ - if(!(event.target instanceof EntityPlayerMP || event.target instanceof EntityNPCInterface) || event.target.worldObj.isRemote) + public void world(EntityJoinWorldEvent event) { + if (event.world.isRemote || !(event.entity instanceof EntityPlayer)) + return; + PlayerData data = PlayerDataController.Instance.getPlayerData((EntityPlayer) event.entity); + data.updateCompanion(event.world); + } + + @SubscribeEvent + public void populateChunk(PopulateChunkEvent.Post event) { + NPCSpawning.performWorldGenSpawning(event.world, event.chunkX, event.chunkZ, event.rand); + } + + @SubscribeEvent + public void playerTracking(PlayerEvent.StartTracking event) { + if (!(event.target instanceof EntityPlayerMP || event.target instanceof EntityNPCInterface) || event.target.worldObj.isRemote) return; AnimationData animationData = AnimationData.getData(event.target); @@ -490,7 +484,7 @@ public class ServerEventsHandler { MarkData data = MarkData.get((EntityNPCInterface) event.target); if (data.marks.isEmpty()) return; - PacketHandler.Instance.sendToPlayer(new MarkDataPacket(event.target.getEntityId(), data.getNBT()), (EntityPlayerMP)event.entityPlayer); + PacketHandler.Instance.sendToPlayer(new MarkDataPacket(event.target.getEntityId(), data.getNBT()), (EntityPlayerMP) event.entityPlayer); } } diff --git a/src/main/java/noppes/npcs/ServerTickHandler.java b/src/main/java/noppes/npcs/ServerTickHandler.java index 95d1332ba..6f05146a8 100644 --- a/src/main/java/noppes/npcs/ServerTickHandler.java +++ b/src/main/java/noppes/npcs/ServerTickHandler.java @@ -17,51 +17,51 @@ import java.net.InetAddress; import java.net.UnknownHostException; public class ServerTickHandler { - @SubscribeEvent - public void onServerTick(TickEvent.WorldTickEvent event){ - if(event.phase == Phase.START){ - NPCSpawning.findChunksForSpawning((WorldServer) event.world); - } - } + @SubscribeEvent + public void onServerTick(TickEvent.WorldTickEvent event) { + if (event.phase == Phase.START) { + NPCSpawning.findChunksForSpawning((WorldServer) event.world); + } + } - private String serverName = null; + private String serverName = null; - @SubscribeEvent - public void playerLogin(PlayerEvent.PlayerLoggedInEvent event){ + @SubscribeEvent + public void playerLogin(PlayerEvent.PlayerLoggedInEvent event) { EntityPlayerMP player = (EntityPlayerMP) event.player; - if(serverName == null){ - String e = "local"; - MinecraftServer server = MinecraftServer.getServer(); - if(server.isDedicatedServer()){ - try { - e = InetAddress.getByName(server.getServerHostname()).getCanonicalHostName(); - } catch (UnknownHostException e1) { - e = MinecraftServer.getServer().getServerHostname(); - } - if(server.getPort() != 25565) - e += ":" + server.getPort(); - } - if(e == null || e.startsWith("192.168") || e.contains("127.0.0.1") || e.startsWith("localhost")) - e = "local"; - serverName = e; - } - AnalyticsTracking.sendData(event.player, "join", serverName); + if (serverName == null) { + String e = "local"; + MinecraftServer server = MinecraftServer.getServer(); + if (server.isDedicatedServer()) { + try { + e = InetAddress.getByName(server.getServerHostname()).getCanonicalHostName(); + } catch (UnknownHostException e1) { + e = MinecraftServer.getServer().getServerHostname(); + } + if (server.getPort() != 25565) + e += ":" + server.getPort(); + } + if (e == null || e.startsWith("192.168") || e.contains("127.0.0.1") || e.startsWith("localhost")) + e = "local"; + serverName = e; + } + AnalyticsTracking.sendData(event.player, "join", serverName); - PlayerData playerData = PlayerDataController.Instance.getPlayerData(event.player); - if (playerData != null) { - playerData.onLogin(); - } + PlayerData playerData = PlayerDataController.Instance.getPlayerData(event.player); + if (playerData != null) { + playerData.onLogin(); + } SyncController.syncPlayer(player); SyncController.syncEffects(player); ProfileController.Instance.login(player); - } + } - @SubscribeEvent - public void playerLogout(PlayerEvent.PlayerLoggedOutEvent event) { - PlayerData playerData = PlayerDataController.Instance.getPlayerData(event.player); - if (playerData != null) { - playerData.onLogout(); - } - } + @SubscribeEvent + public void playerLogout(PlayerEvent.PlayerLoggedOutEvent event) { + PlayerData playerData = PlayerDataController.Instance.getPlayerData(event.player); + if (playerData != null) { + playerData.onLogout(); + } + } } diff --git a/src/main/java/noppes/npcs/TextBlock.java b/src/main/java/noppes/npcs/TextBlock.java index 91978b1a5..9bd094083 100644 --- a/src/main/java/noppes/npcs/TextBlock.java +++ b/src/main/java/noppes/npcs/TextBlock.java @@ -6,5 +6,5 @@ import java.util.ArrayList; import java.util.List; public class TextBlock { - public List lines = new ArrayList(); + public List lines = new ArrayList(); } diff --git a/src/main/java/noppes/npcs/VersionCompatibility.java b/src/main/java/noppes/npcs/VersionCompatibility.java index afa205d16..94a1b28d9 100644 --- a/src/main/java/noppes/npcs/VersionCompatibility.java +++ b/src/main/java/noppes/npcs/VersionCompatibility.java @@ -13,207 +13,207 @@ import java.util.Collection; import java.util.List; public class VersionCompatibility { - public static int ModRev = 22; + public static int ModRev = 22; - public static void CheckNpcCompatibility(EntityNPCInterface npc, NBTTagCompound compound){ - if(npc.npcVersion == ModRev) - return; - if(npc.npcVersion < 22) { - if (compound.hasKey("CanLeap")) { - boolean canLeap = compound.getBoolean("CanLeap"); - compound.setInteger("LeapType", !canLeap ? 0 : 1); - } - } - if(npc.npcVersion < 19) { - if (compound.hasKey("CanDrown")) { - compound.setInteger("DrowningType", (compound.getBoolean("CanDrown") ? 1 : 0)); - compound.removeTag("CanDrown"); - } - } - if(npc.npcVersion < 18){ - // Fix CloakTexture (Reorganization) - String cloakTexture = compound.getString("CloakTexture"); - cloakTexture = cloakTexture.replace("/cloak/Daybreak/", "/cloak/Guilds/Daybreak/"); - cloakTexture = cloakTexture.replace("/cloak/Created/", "/cloak/Extras/"); - cloakTexture = cloakTexture.replace("/cloak/Color Capes/", "/cloak/Color/"); - compound.setString("CloakTexture", cloakTexture); - } - if(npc.npcVersion < 17){ - // Fix DialogDarkenScreen - if(compound.hasKey("DialogDarkenScreen")){ - compound.removeTag("DialogDarkenScreen"); - } - } - if(npc.npcVersion < 12){ - CompatabilityFix(compound, npc.advanced.writeToNBT(new NBTTagCompound())); - CompatabilityFix(compound, npc.ais.writeToNBT(new NBTTagCompound())); - CompatabilityFix(compound, npc.stats.writeToNBT(new NBTTagCompound())); - CompatabilityFix(compound, npc.display.writeToNBT(new NBTTagCompound())); - CompatabilityFix(compound, npc.inventory.writeEntityToNBT(new NBTTagCompound())); - } - if(npc.npcVersion < 5){ - String texture = compound.getString("Texture"); - texture = texture.replace("/mob/customnpcs/", "customnpcs:textures/entity/"); - texture = texture.replace("/mob/", "customnpcs:textures/entity/"); - compound.setString("Texture", texture); - } - if(npc.npcVersion < 6 && compound.getTag("NpcInteractLines") instanceof NBTTagList){ - List interactLines = NBTTags.getStringList(compound.getTagList("NpcInteractLines", 10)); - Lines lines = new Lines(); - for(int i = 0; i < interactLines.size(); i++){ - Line line = new Line(); - line.text = (String) interactLines.toArray()[i]; - lines.lines.put(i, line); - } - compound.setTag("NpcInteractLines", lines.writeToNBT()); + public static void CheckNpcCompatibility(EntityNPCInterface npc, NBTTagCompound compound) { + if (npc.npcVersion == ModRev) + return; + if (npc.npcVersion < 22) { + if (compound.hasKey("CanLeap")) { + boolean canLeap = compound.getBoolean("CanLeap"); + compound.setInteger("LeapType", !canLeap ? 0 : 1); + } + } + if (npc.npcVersion < 19) { + if (compound.hasKey("CanDrown")) { + compound.setInteger("DrowningType", (compound.getBoolean("CanDrown") ? 1 : 0)); + compound.removeTag("CanDrown"); + } + } + if (npc.npcVersion < 18) { + // Fix CloakTexture (Reorganization) + String cloakTexture = compound.getString("CloakTexture"); + cloakTexture = cloakTexture.replace("/cloak/Daybreak/", "/cloak/Guilds/Daybreak/"); + cloakTexture = cloakTexture.replace("/cloak/Created/", "/cloak/Extras/"); + cloakTexture = cloakTexture.replace("/cloak/Color Capes/", "/cloak/Color/"); + compound.setString("CloakTexture", cloakTexture); + } + if (npc.npcVersion < 17) { + // Fix DialogDarkenScreen + if (compound.hasKey("DialogDarkenScreen")) { + compound.removeTag("DialogDarkenScreen"); + } + } + if (npc.npcVersion < 12) { + CompatabilityFix(compound, npc.advanced.writeToNBT(new NBTTagCompound())); + CompatabilityFix(compound, npc.ais.writeToNBT(new NBTTagCompound())); + CompatabilityFix(compound, npc.stats.writeToNBT(new NBTTagCompound())); + CompatabilityFix(compound, npc.display.writeToNBT(new NBTTagCompound())); + CompatabilityFix(compound, npc.inventory.writeEntityToNBT(new NBTTagCompound())); + } + if (npc.npcVersion < 5) { + String texture = compound.getString("Texture"); + texture = texture.replace("/mob/customnpcs/", "customnpcs:textures/entity/"); + texture = texture.replace("/mob/", "customnpcs:textures/entity/"); + compound.setString("Texture", texture); + } + if (npc.npcVersion < 6 && compound.getTag("NpcInteractLines") instanceof NBTTagList) { + List interactLines = NBTTags.getStringList(compound.getTagList("NpcInteractLines", 10)); + Lines lines = new Lines(); + for (int i = 0; i < interactLines.size(); i++) { + Line line = new Line(); + line.text = (String) interactLines.toArray()[i]; + lines.lines.put(i, line); + } + compound.setTag("NpcInteractLines", lines.writeToNBT()); - List worldLines = NBTTags.getStringList(compound.getTagList("NpcLines", 10)); - lines = new Lines(); - for(int i = 0; i < worldLines.size(); i++){ - Line line = new Line(); - line.text = (String) worldLines.toArray()[i]; - lines.lines.put(i, line); - } - compound.setTag("NpcLines", lines.writeToNBT()); + List worldLines = NBTTags.getStringList(compound.getTagList("NpcLines", 10)); + lines = new Lines(); + for (int i = 0; i < worldLines.size(); i++) { + Line line = new Line(); + line.text = (String) worldLines.toArray()[i]; + lines.lines.put(i, line); + } + compound.setTag("NpcLines", lines.writeToNBT()); - List attackLines = NBTTags.getStringList(compound.getTagList("NpcAttackLines", 10)); - lines = new Lines(); - for(int i = 0; i < attackLines.size(); i++){ - Line line = new Line(); - line.text = (String) attackLines.toArray()[i]; - lines.lines.put(i, line); - } - compound.setTag("NpcAttackLines", lines.writeToNBT()); + List attackLines = NBTTags.getStringList(compound.getTagList("NpcAttackLines", 10)); + lines = new Lines(); + for (int i = 0; i < attackLines.size(); i++) { + Line line = new Line(); + line.text = (String) attackLines.toArray()[i]; + lines.lines.put(i, line); + } + compound.setTag("NpcAttackLines", lines.writeToNBT()); - List killedLines = NBTTags.getStringList(compound.getTagList("NpcKilledLines", 10)); - lines = new Lines(); - for(int i = 0; i < killedLines.size(); i++){ - Line line = new Line(); - line.text = (String) killedLines.toArray()[i]; - lines.lines.put(i, line); - } - compound.setTag("NpcKilledLines", lines.writeToNBT()); + List killedLines = NBTTags.getStringList(compound.getTagList("NpcKilledLines", 10)); + lines = new Lines(); + for (int i = 0; i < killedLines.size(); i++) { + Line line = new Line(); + line.text = (String) killedLines.toArray()[i]; + lines.lines.put(i, line); + } + compound.setTag("NpcKilledLines", lines.writeToNBT()); - } - if(npc.npcVersion == 12){ - NBTTagList list = compound.getTagList("StartPos", 3); - if(list.tagCount() == 3){ - int z = ((NBTTagInt) list.removeTag(2)).func_150287_d(); - int y = ((NBTTagInt) list.removeTag(1)).func_150287_d(); - int x = ((NBTTagInt) list.removeTag(0)).func_150287_d(); + } + if (npc.npcVersion == 12) { + NBTTagList list = compound.getTagList("StartPos", 3); + if (list.tagCount() == 3) { + int z = ((NBTTagInt) list.removeTag(2)).func_150287_d(); + int y = ((NBTTagInt) list.removeTag(1)).func_150287_d(); + int x = ((NBTTagInt) list.removeTag(0)).func_150287_d(); - compound.setIntArray("StartPosNew", new int[]{x,y,z}); - } - } - if(npc.npcVersion == 13){ - boolean bo = compound.getBoolean("HealthRegen"); - compound.setInteger("HealthRegen", bo?1:0); - NBTTagCompound comp = compound.getCompoundTag("TransformStats"); - bo = comp.getBoolean("HealthRegen"); - comp.setInteger("HealthRegen", bo?1:0); - compound.setTag("TransformStats", comp); + compound.setIntArray("StartPosNew", new int[]{x, y, z}); + } + } + if (npc.npcVersion == 13) { + boolean bo = compound.getBoolean("HealthRegen"); + compound.setInteger("HealthRegen", bo ? 1 : 0); + NBTTagCompound comp = compound.getCompoundTag("TransformStats"); + bo = comp.getBoolean("HealthRegen"); + comp.setInteger("HealthRegen", bo ? 1 : 0); + compound.setTag("TransformStats", comp); - } - npc.npcVersion = ModRev; - } + } + npc.npcVersion = ModRev; + } - public static void CheckModelCompatibility(EntityNPCInterface npc, NBTTagCompound compound){ - if(npc.npcVersion == ModRev) - return; - NBTTagCompound modelData = compound.getCompoundTag("NpcModelData"); - if(npc.npcVersion < 20){ - // Convert Puppet Job - if (compound.hasKey("NpcJob")) { - if(compound.getInteger("NpcJob") == 9){ - // Remove Job - compound.setInteger("NpcJob", 0); + public static void CheckModelCompatibility(EntityNPCInterface npc, NBTTagCompound compound) { + if (npc.npcVersion == ModRev) + return; + NBTTagCompound modelData = compound.getCompoundTag("NpcModelData"); + if (npc.npcVersion < 20) { + // Convert Puppet Job + if (compound.hasKey("NpcJob")) { + if (compound.getInteger("NpcJob") == 9) { + // Remove Job + compound.setInteger("NpcJob", 0); - // Get Puppet Data - boolean moving = compound.getBoolean("PuppetMoving"); - boolean attacking = compound.getBoolean("PuppetAttacking"); - boolean standing = compound.getBoolean("PuppetStanding"); - NBTTagCompound head = compound.getCompoundTag("PuppetHead"); - NBTTagCompound body = compound.getCompoundTag("PuppetBody"); - NBTTagCompound larm = compound.getCompoundTag("PuppetLArm"); - NBTTagCompound rarm = compound.getCompoundTag("PuppetRArm"); - NBTTagCompound lleg = compound.getCompoundTag("PuppetLLeg"); - NBTTagCompound rleg = compound.getCompoundTag("PuppetRLeg"); + // Get Puppet Data + boolean moving = compound.getBoolean("PuppetMoving"); + boolean attacking = compound.getBoolean("PuppetAttacking"); + boolean standing = compound.getBoolean("PuppetStanding"); + NBTTagCompound head = compound.getCompoundTag("PuppetHead"); + NBTTagCompound body = compound.getCompoundTag("PuppetBody"); + NBTTagCompound larm = compound.getCompoundTag("PuppetLArm"); + NBTTagCompound rarm = compound.getCompoundTag("PuppetRArm"); + NBTTagCompound lleg = compound.getCompoundTag("PuppetLLeg"); + NBTTagCompound rleg = compound.getCompoundTag("PuppetRLeg"); - // Enable Rotations - modelData.setBoolean("EnableRotation", true); - // Make New Rotation and Write It - ModelRotate newRotation = new ModelRotate(); - newRotation.whileMoving = moving; - newRotation.whileAttacking = attacking; - newRotation.whileStanding = standing; - NBTTagCompound rotation = newRotation.writeToNBT(); - rotation.setTag("PuppetHead", head); - rotation.setTag("PuppetBody", body); - rotation.setTag("PuppetLArm", larm); - rotation.setTag("PuppetRArm", rarm); - rotation.setTag("PuppetLLeg", lleg); - rotation.setTag("PuppetRLeg", rleg); - modelData.setTag("ModelRotation", rotation); + // Enable Rotations + modelData.setBoolean("EnableRotation", true); + // Make New Rotation and Write It + ModelRotate newRotation = new ModelRotate(); + newRotation.whileMoving = moving; + newRotation.whileAttacking = attacking; + newRotation.whileStanding = standing; + NBTTagCompound rotation = newRotation.writeToNBT(); + rotation.setTag("PuppetHead", head); + rotation.setTag("PuppetBody", body); + rotation.setTag("PuppetLArm", larm); + rotation.setTag("PuppetRArm", rarm); + rotation.setTag("PuppetLLeg", lleg); + rotation.setTag("PuppetRLeg", rleg); + modelData.setTag("ModelRotation", rotation); - // Remove All Old Tags - compound.removeTag("PuppetMoving"); - compound.removeTag("PuppetAttacking"); - compound.removeTag("PuppetStanding"); - compound.removeTag("PuppetHead"); - compound.removeTag("PuppetBody"); - compound.removeTag("PuppetLArm"); - compound.removeTag("PuppetRArm"); - compound.removeTag("PuppetLLeg"); - compound.removeTag("PuppetRLeg"); - } - } - } - if(npc.npcVersion < 19) { - // Fix Leg MPM Dependency - if(modelData.hasKey("LegParts")){ - NBTTagCompound legParts = modelData.getCompoundTag("LegParts"); - if(legParts.hasKey("Texture")){ - legParts.setString("Texture", legParts.getString("Texture").replace("moreplayermodels:textures", "customnpcs:textures/parts")); - } - modelData.setTag("LegParts", legParts); - } + // Remove All Old Tags + compound.removeTag("PuppetMoving"); + compound.removeTag("PuppetAttacking"); + compound.removeTag("PuppetStanding"); + compound.removeTag("PuppetHead"); + compound.removeTag("PuppetBody"); + compound.removeTag("PuppetLArm"); + compound.removeTag("PuppetRArm"); + compound.removeTag("PuppetLLeg"); + compound.removeTag("PuppetRLeg"); + } + } + } + if (npc.npcVersion < 19) { + // Fix Leg MPM Dependency + if (modelData.hasKey("LegParts")) { + NBTTagCompound legParts = modelData.getCompoundTag("LegParts"); + if (legParts.hasKey("Texture")) { + legParts.setString("Texture", legParts.getString("Texture").replace("moreplayermodels:textures", "customnpcs:textures/parts")); + } + modelData.setTag("LegParts", legParts); + } - // Fix Part MPM Dependency - if(modelData.hasKey("Parts")){ - NBTTagList list = modelData.getTagList("Parts", 10); + // Fix Part MPM Dependency + if (modelData.hasKey("Parts")) { + NBTTagList list = modelData.getTagList("Parts", 10); - for (int i = 0; i < list.tagCount(); i++) { - NBTTagCompound item = list.getCompoundTagAt(i); + for (int i = 0; i < list.tagCount(); i++) { + NBTTagCompound item = list.getCompoundTagAt(i); - if(item.hasKey("Texture")){ - item.setString("Texture", item.getString("Texture").replace("moreplayermodels:textures", "customnpcs:textures/parts")); - } - list.func_150304_a(i, item); - } - modelData.setTag("Parts", list); - } - } - compound.setTag("NpcModelData", modelData); - } + if (item.hasKey("Texture")) { + item.setString("Texture", item.getString("Texture").replace("moreplayermodels:textures", "customnpcs:textures/parts")); + } + list.func_150304_a(i, item); + } + modelData.setTag("Parts", list); + } + } + compound.setTag("NpcModelData", modelData); + } - public static void CheckAvailabilityCompatibility(ICompatibilty compatibilty, NBTTagCompound compound){ - if(compatibilty.getVersion() == ModRev) - return; - CompatabilityFix(compound, compatibilty.writeToNBT(new NBTTagCompound())); + public static void CheckAvailabilityCompatibility(ICompatibilty compatibilty, NBTTagCompound compound) { + if (compatibilty.getVersion() == ModRev) + return; + CompatabilityFix(compound, compatibilty.writeToNBT(new NBTTagCompound())); - compatibilty.setVersion(ModRev); - } - private static void CompatabilityFix(NBTTagCompound compound, - NBTTagCompound check) { - Collection tags = check.func_150296_c(); - for(String name : tags){ - NBTBase nbt = check.getTag(name); - if(!compound.hasKey(name)){ - compound.setTag(name, nbt); - } - else if(nbt instanceof NBTTagCompound && compound.getTag(name) instanceof NBTTagCompound){ - CompatabilityFix(compound.getCompoundTag(name), (NBTTagCompound)nbt); - } - } - } + compatibilty.setVersion(ModRev); + } + + private static void CompatabilityFix(NBTTagCompound compound, + NBTTagCompound check) { + Collection tags = check.func_150296_c(); + for (String name : tags) { + NBTBase nbt = check.getTag(name); + if (!compound.hasKey(name)) { + compound.setTag(name, nbt); + } else if (nbt instanceof NBTTagCompound && compound.getTag(name) instanceof NBTTagCompound) { + CompatabilityFix(compound.getCompoundTag(name), (NBTTagCompound) nbt); + } + } + } } diff --git a/src/main/java/noppes/npcs/ai/CombatHandler.java b/src/main/java/noppes/npcs/ai/CombatHandler.java index 310ec79dd..2a2319c4f 100644 --- a/src/main/java/noppes/npcs/ai/CombatHandler.java +++ b/src/main/java/noppes/npcs/ai/CombatHandler.java @@ -14,138 +14,138 @@ import java.util.Map; public class CombatHandler { - private Map aggressors = new HashMap(); - private Map> recentDamages = new HashMap<>(); - private EntityNPCInterface npc; - private long startTime = 0; - private int combatResetTimer = 0; - public CombatHandler(EntityNPCInterface npc) { - this.npc = npc; - } + private Map aggressors = new HashMap(); + private Map> recentDamages = new HashMap<>(); + private EntityNPCInterface npc; + private long startTime = 0; + private int combatResetTimer = 0; - public void update(){ - if(npc.isKilled()){ - if(npc.isAttacking()){ - reset(); - } - return; - } - if(npc.getAttackTarget() != null && !npc.isAttacking()){ - start(); - } + public CombatHandler(EntityNPCInterface npc) { + this.npc = npc; + } - if(!shouldCombatContinue()){ - if(combatResetTimer++ > 40){ - reset(); - } - return; - } - combatResetTimer = 0; - } + public void update() { + if (npc.isKilled()) { + if (npc.isAttacking()) { + reset(); + } + return; + } + if (npc.getAttackTarget() != null && !npc.isAttacking()) { + start(); + } + + if (!shouldCombatContinue()) { + if (combatResetTimer++ > 40) { + reset(); + } + return; + } + combatResetTimer = 0; + } - private boolean shouldCombatContinue() { - if(npc.getAttackTarget() == null) - return false; - return isValidTarget(npc.getAttackTarget()); - } + private boolean shouldCombatContinue() { + if (npc.getAttackTarget() == null) + return false; + return isValidTarget(npc.getAttackTarget()); + } - public void damage(DamageSource source, float damageAmount) { - combatResetTimer = 0; - Entity e = NoppesUtilServer.GetDamageSource(source); + public void damage(DamageSource source, float damageAmount) { + combatResetTimer = 0; + Entity e = NoppesUtilServer.GetDamageSource(source); - if (e instanceof EntityLivingBase) { - EntityLivingBase el = (EntityLivingBase) e; + if (e instanceof EntityLivingBase) { + EntityLivingBase el = (EntityLivingBase) e; - // Update recent damages - LinkedList recentDamageList = recentDamages.computeIfAbsent(el, k -> new LinkedList<>()); - recentDamageList.addLast(damageAmount); - if (recentDamageList.size() > 15) { - recentDamageList.removeFirst(); - } + // Update recent damages + LinkedList recentDamageList = recentDamages.computeIfAbsent(el, k -> new LinkedList<>()); + recentDamageList.addLast(damageAmount); + if (recentDamageList.size() > 15) { + recentDamageList.removeFirst(); + } - // Update total aggressor damage - Float f = aggressors.get(el); - if (f == null) { - f = 0f; - } - aggressors.put(el, f + damageAmount); - } - } + // Update total aggressor damage + Float f = aggressors.get(el); + if (f == null) { + f = 0f; + } + aggressors.put(el, f + damageAmount); + } + } - public void start(){ - combatResetTimer = 0; - startTime = npc.worldObj.getWorldInfo().getWorldTotalTime(); - npc.setBoolFlag(true, 4); - } + public void start() { + combatResetTimer = 0; + startTime = npc.worldObj.getWorldInfo().getWorldTotalTime(); + npc.setBoolFlag(true, 4); + } - public void reset(){ - combatResetTimer = 0; - startTime = 0; - aggressors.clear(); - recentDamages.clear(); - npc.setBoolFlag(false, 4); - } + public void reset() { + combatResetTimer = 0; + startTime = 0; + aggressors.clear(); + recentDamages.clear(); + npc.setBoolFlag(false, 4); + } - public boolean checkTarget() { - if(aggressors.isEmpty() || npc.ticksExisted % 10 != 0) - return false; - EntityLivingBase target = npc.getAttackTarget(); - Float current = 0f; - if(isValidTarget(target)){ - current = aggressors.get(target); - if(current == null) - current = 0f; - } - else - target = null; - for (Map.Entry entry : aggressors.entrySet()){ - if(entry.getValue() > current && isValidTarget(entry.getKey())){ - current = entry.getValue(); - target = entry.getKey(); - } - } - return target == null; - } + public boolean checkTarget() { + if (aggressors.isEmpty() || npc.ticksExisted % 10 != 0) + return false; + EntityLivingBase target = npc.getAttackTarget(); + Float current = 0f; + if (isValidTarget(target)) { + current = aggressors.get(target); + if (current == null) + current = 0f; + } else + target = null; + for (Map.Entry entry : aggressors.entrySet()) { + if (entry.getValue() > current && isValidTarget(entry.getKey())) { + current = entry.getValue(); + target = entry.getKey(); + } + } + return target == null; + } - public boolean isValidTarget(EntityLivingBase target){ - if(target == null || !target.isEntityAlive()) - return false; + public boolean isValidTarget(EntityLivingBase target) { + if (target == null || !target.isEntityAlive()) + return false; - if(target instanceof EntityPlayer && (((EntityPlayer)target).capabilities.disableDamage || DBCAddon.instance.isKO(npc, (EntityPlayer) target))) - return false; + if (target instanceof EntityPlayer && (((EntityPlayer) target).capabilities.disableDamage || DBCAddon.instance.isKO(npc, (EntityPlayer) target))) + return false; - return npc.isInRange(target, npc.stats.aggroRange); - } + return npc.isInRange(target, npc.stats.aggroRange); + } - public float calculateThreatLevel(EntityLivingBase entity) { - float threatLevel = 0.0f; - LinkedList recentDamageList = recentDamages.get(entity); + public float calculateThreatLevel(EntityLivingBase entity) { + float threatLevel = 0.0f; + LinkedList recentDamageList = recentDamages.get(entity); - if (recentDamageList != null) { - long currentTime = npc.worldObj.getWorldInfo().getWorldTotalTime(); - for (Float damage : recentDamageList) { - float decayFactor = Math.max(0, 1 - (float) startTime / currentTime); + if (recentDamageList != null) { + long currentTime = npc.worldObj.getWorldInfo().getWorldTotalTime(); + for (Float damage : recentDamageList) { + float decayFactor = Math.max(0, 1 - (float) startTime / currentTime); - threatLevel += damage * decayFactor; - } - } + threatLevel += damage * decayFactor; + } + } - return threatLevel; - } + return threatLevel; + } - public boolean shouldChangeTarget(double chance) { - // Assuming randomNum is a random number between 0 and 100 - double randomNum = Math.random() * 100; // Generates a random number between 0 and 100 - return randomNum < chance; - } + public boolean shouldChangeTarget(double chance) { + // Assuming randomNum is a random number between 0 and 100 + double randomNum = Math.random() * 100; // Generates a random number between 0 and 100 + return randomNum < chance; + } - public boolean shouldSwitchTactically(EntityLivingBase originalTarget, EntityLivingBase newTarget, boolean reverse) { - float currentThreat = calculateThreatLevel(originalTarget); - float newThreat = calculateThreatLevel(newTarget); - if(reverse){ + public boolean shouldSwitchTactically(EntityLivingBase originalTarget, EntityLivingBase newTarget, boolean reverse) { + float currentThreat = calculateThreatLevel(originalTarget); + float newThreat = calculateThreatLevel(newTarget); + if (reverse) { return newThreat < currentThreat; } - return newThreat > currentThreat; - } + return newThreat > currentThreat; + } } diff --git a/src/main/java/noppes/npcs/ai/EntityAIAmbushTarget.java b/src/main/java/noppes/npcs/ai/EntityAIAmbushTarget.java index 46f3825ca..4ee229b0e 100644 --- a/src/main/java/noppes/npcs/ai/EntityAIAmbushTarget.java +++ b/src/main/java/noppes/npcs/ai/EntityAIAmbushTarget.java @@ -11,9 +11,8 @@ import noppes.npcs.entity.EntityNPCInterface; import java.util.Random; -public class EntityAIAmbushTarget extends EntityAIBase -{ - private EntityNPCInterface theEntity; +public class EntityAIAmbushTarget extends EntityAIBase { + private EntityNPCInterface theEntity; private EntityLivingBase targetEntity; private double shelterX; private double shelterY; @@ -25,8 +24,7 @@ public class EntityAIAmbushTarget extends EntityAIBase private int tick; private boolean attackFromBehind; - public EntityAIAmbushTarget(EntityNPCInterface par1EntityCreature, double par2, double par3, boolean par4) - { + public EntityAIAmbushTarget(EntityNPCInterface par1EntityCreature, double par2, double par3, boolean par4) { this.theEntity = par1EntityCreature; this.movementSpeed = par2; this.theWorld = par1EntityCreature.worldObj; @@ -38,33 +36,22 @@ public class EntityAIAmbushTarget extends EntityAIBase /** * Returns whether the EntityAIBase should begin execution. */ - public boolean shouldExecute() - { - this.targetEntity = this.theEntity.getAttackTarget(); + public boolean shouldExecute() { + this.targetEntity = this.theEntity.getAttackTarget(); - if (this.targetEntity == null) - { + if (this.targetEntity == null) { return false; - } - else if (this.targetEntity.getDistanceSqToEntity(this.theEntity) < this.distance || !this.theEntity.canSee(targetEntity)) - { - return false; - } - else if (delay > 0) - { - delay--; - return false; - } - else - { - Vec3 vec3 = this.findHidingSpot(); + } else if (this.targetEntity.getDistanceSqToEntity(this.theEntity) < this.distance || !this.theEntity.canSee(targetEntity)) { + return false; + } else if (delay > 0) { + delay--; + return false; + } else { + Vec3 vec3 = this.findHidingSpot(); - if (vec3 == null) - { + if (vec3 == null) { return false; - } - else - { + } else { this.shelterX = vec3.xCoord; this.shelterY = vec3.yCoord; this.shelterZ = vec3.zCoord; @@ -76,83 +63,68 @@ public class EntityAIAmbushTarget extends EntityAIBase /** * Returns whether an in-progress EntityAIBase should continue executing */ - public boolean continueExecuting() - { - boolean shouldHide = this.targetEntity.getDistanceSqToEntity(this.theEntity) > this.distance; - boolean isSeen = this.theEntity.canSee(targetEntity); - return (!this.theEntity.getNavigator().noPath() && shouldHide) || (!isSeen && (shouldHide || this.theEntity.ais.directLOS)); + public boolean continueExecuting() { + boolean shouldHide = this.targetEntity.getDistanceSqToEntity(this.theEntity) > this.distance; + boolean isSeen = this.theEntity.canSee(targetEntity); + return (!this.theEntity.getNavigator().noPath() && shouldHide) || (!isSeen && (shouldHide || this.theEntity.ais.directLOS)); } /** * Execute a one shot task or start executing a continuous task */ - public void startExecuting() - { + public void startExecuting() { this.theEntity.getNavigator().tryMoveToXYZ(this.shelterX, this.shelterY, this.shelterZ, this.movementSpeed); } /** * Resets the task */ - public void resetTask() - { + public void resetTask() { this.theEntity.getNavigator().clearPathEntity(); - if (this.theEntity.getAttackTarget() == null && this.targetEntity != null) - { - this.theEntity.setAttackTarget(targetEntity); + if (this.theEntity.getAttackTarget() == null && this.targetEntity != null) { + this.theEntity.setAttackTarget(targetEntity); } - if (this.targetEntity.getDistanceSqToEntity(this.theEntity) < this.distance) - { - this.delay = 60; + if (this.targetEntity.getDistanceSqToEntity(this.theEntity) < this.distance) { + this.delay = 60; } } /** * Updates the task */ - public void updateTask() - { - this.theEntity.getLookHelper().setLookPositionWithEntity(targetEntity, 30.0F, 30.0F); + public void updateTask() { + this.theEntity.getLookHelper().setLookPositionWithEntity(targetEntity, 30.0F, 30.0F); } - private Vec3 findHidingSpot() - { - Random random = this.theEntity.getRNG(); - Vec3 idealPos = null; + private Vec3 findHidingSpot() { + Random random = this.theEntity.getRNG(); + Vec3 idealPos = null; - for (int i = 1; i <= 8; i++) - { - for (int y = -2; y <= 2; y++) - { - for (int x = -i; x <= i; x++) - { - for (int z = -i; z <= i; z++) - { - double j = MathHelper.floor_double(this.theEntity.posX + x) + 0.5D; - double k = MathHelper.floor_double(this.theEntity.boundingBox.minY + y); - double l = MathHelper.floor_double(this.theEntity.posZ + z) + 0.5D; + for (int i = 1; i <= 8; i++) { + for (int y = -2; y <= 2; y++) { + for (int x = -i; x <= i; x++) { + for (int z = -i; z <= i; z++) { + double j = MathHelper.floor_double(this.theEntity.posX + x) + 0.5D; + double k = MathHelper.floor_double(this.theEntity.boundingBox.minY + y); + double l = MathHelper.floor_double(this.theEntity.posZ + z) + 0.5D; - if (this.theWorld.getBlock((int)j, (int)k, (int)l).isOpaqueCube() && !this.theWorld.getBlock((int)j, (int)k + 1, (int)l).isOpaqueCube() && !this.theWorld.getBlock((int)j, (int)k + 2, (int)l).isOpaqueCube()) - { - Vec3 vec1 = Vec3.createVectorHelper(this.targetEntity.posX, this.targetEntity.posY + (double)this.targetEntity.getEyeHeight(), this.targetEntity.posZ); - Vec3 vec2 = Vec3.createVectorHelper(j, k + (double)this.theEntity.getEyeHeight(), l); - MovingObjectPosition movingobjectposition = this.theWorld.rayTraceBlocks(vec1, vec2); - if (movingobjectposition != null) - { - if (this.shelterX != j && this.shelterY != k && this.shelterZ != l) - { - idealPos = Vec3.createVectorHelper(j, k, l); - } - } - } - } - } - } + if (this.theWorld.getBlock((int) j, (int) k, (int) l).isOpaqueCube() && !this.theWorld.getBlock((int) j, (int) k + 1, (int) l).isOpaqueCube() && !this.theWorld.getBlock((int) j, (int) k + 2, (int) l).isOpaqueCube()) { + Vec3 vec1 = Vec3.createVectorHelper(this.targetEntity.posX, this.targetEntity.posY + (double) this.targetEntity.getEyeHeight(), this.targetEntity.posZ); + Vec3 vec2 = Vec3.createVectorHelper(j, k + (double) this.theEntity.getEyeHeight(), l); + MovingObjectPosition movingobjectposition = this.theWorld.rayTraceBlocks(vec1, vec2); + if (movingobjectposition != null) { + if (this.shelterX != j && this.shelterY != k && this.shelterZ != l) { + idealPos = Vec3.createVectorHelper(j, k, l); + } + } + } + } + } + } - if (idealPos != null) - { - return idealPos; - } + if (idealPos != null) { + return idealPos; + } } delay = 60; return null; diff --git a/src/main/java/noppes/npcs/ai/EntityAIAnimation.java b/src/main/java/noppes/npcs/ai/EntityAIAnimation.java index 3cd3a2300..6ce7c4687 100644 --- a/src/main/java/noppes/npcs/ai/EntityAIAnimation.java +++ b/src/main/java/noppes/npcs/ai/EntityAIAnimation.java @@ -5,8 +5,7 @@ import noppes.npcs.constants.EnumAnimation; import noppes.npcs.constants.EnumMovingType; import noppes.npcs.entity.EntityNPCInterface; -public class EntityAIAnimation extends EntityAIBase -{ +public class EntityAIAnimation extends EntityAIBase { private EntityNPCInterface npc; private boolean isAttacking = false; @@ -15,53 +14,53 @@ public class EntityAIAnimation extends EntityAIBase private boolean hasPath = false; private int tick = 4; - public EntityAIAnimation(EntityNPCInterface npc){ + public EntityAIAnimation(EntityNPCInterface npc) { this.npc = npc; } @Override - public boolean shouldExecute(){ - isDead = !npc.isEntityAlive(); - if(isDead) - return npc.currentAnimation != EnumAnimation.LYING; + public boolean shouldExecute() { + isDead = !npc.isEntityAlive(); + if (isDead) + return npc.currentAnimation != EnumAnimation.LYING; - if(npc.stats.aimWhileShooting && npc.isAttacking()) - return npc.currentAnimation != EnumAnimation.AIMING; - if(npc.ais.animationType == EnumAnimation.NONE) - return npc.currentAnimation != EnumAnimation.NONE; - isAttacking = npc.isAttacking(); - if(npc.ais.returnToStart) - isAtStartpoint = npc.isVeryNearAssignedPlace(); - hasPath = !npc.getNavigator().noPath(); + if (npc.stats.aimWhileShooting && npc.isAttacking()) + return npc.currentAnimation != EnumAnimation.AIMING; + if (npc.ais.animationType == EnumAnimation.NONE) + return npc.currentAnimation != EnumAnimation.NONE; + isAttacking = npc.isAttacking(); + if (npc.ais.returnToStart) + isAtStartpoint = npc.isVeryNearAssignedPlace(); + hasPath = !npc.getNavigator().noPath(); - if(npc.ais.movingType == EnumMovingType.Standing && hasNavigation() && npc.currentAnimation.getWalkingAnimation() == 0){ - return npc.currentAnimation != EnumAnimation.NONE; - } + if (npc.ais.movingType == EnumMovingType.Standing && hasNavigation() && npc.currentAnimation.getWalkingAnimation() == 0) { + return npc.currentAnimation != EnumAnimation.NONE; + } - return npc.currentAnimation != npc.ais.animationType; + return npc.currentAnimation != npc.ais.animationType; } @Override - public void updateTask(){ - if(npc.stats.aimWhileShooting && npc.isAttacking()){ - setAnimation(EnumAnimation.AIMING); - return; - } - EnumAnimation type = npc.ais.animationType; - if(isDead) - type = EnumAnimation.LYING; - else if(npc.ais.movingType == EnumMovingType.Standing && npc.ais.animationType.getWalkingAnimation() == 0 && hasNavigation()) - type = EnumAnimation.NONE; - setAnimation(type); + public void updateTask() { + if (npc.stats.aimWhileShooting && npc.isAttacking()) { + setAnimation(EnumAnimation.AIMING); + return; + } + EnumAnimation type = npc.ais.animationType; + if (isDead) + type = EnumAnimation.LYING; + else if (npc.ais.movingType == EnumMovingType.Standing && npc.ais.animationType.getWalkingAnimation() == 0 && hasNavigation()) + type = EnumAnimation.NONE; + setAnimation(type); } - private void setAnimation(EnumAnimation animation){ - npc.setCurrentAnimation(animation); - npc.updateHitbox(); - npc.setPosition(npc.posX, npc.posY, npc.posZ); + private void setAnimation(EnumAnimation animation) { + npc.setCurrentAnimation(animation); + npc.updateHitbox(); + npc.setPosition(npc.posX, npc.posY, npc.posZ); } private boolean hasNavigation() { - return (isAttacking || npc.ais.returnToStart && !isAtStartpoint && !npc.isFollower() || hasPath); + return (isAttacking || npc.ais.returnToStart && !isAtStartpoint && !npc.isFollower() || hasPath); } } diff --git a/src/main/java/noppes/npcs/ai/EntityAIAttackTarget.java b/src/main/java/noppes/npcs/ai/EntityAIAttackTarget.java index 73e9f7ea3..967c3cf73 100644 --- a/src/main/java/noppes/npcs/ai/EntityAIAttackTarget.java +++ b/src/main/java/noppes/npcs/ai/EntityAIAttackTarget.java @@ -12,8 +12,7 @@ import noppes.npcs.config.ConfigMain; import noppes.npcs.constants.AiMutex; import noppes.npcs.entity.EntityNPCInterface; -public class EntityAIAttackTarget extends EntityAIBase -{ +public class EntityAIAttackTarget extends EntityAIBase { private World world; private EntityNPCInterface npc; private EntityLivingBase entityTarget; @@ -23,42 +22,41 @@ public class EntityAIAttackTarget extends EntityAIBase */ private int attackTick; - /** The PathEntity of our entity. */ + /** + * The PathEntity of our entity. + */ private PathEntity entityPathEntity; private int field_75445_i; - private boolean navOverride = false; + private boolean navOverride = false; - public EntityAIAttackTarget(EntityNPCInterface par1EntityLiving){ + public EntityAIAttackTarget(EntityNPCInterface par1EntityLiving) { this.attackTick = 0; this.npc = par1EntityLiving; this.world = par1EntityLiving.worldObj; - this.setMutexBits(this.navOverride ? AiMutex.PATHING : AiMutex.LOOK + AiMutex.PASSIVE); + this.setMutexBits(this.navOverride ? AiMutex.PATHING : AiMutex.LOOK + AiMutex.PASSIVE); } /** * Returns whether the EntityAIBase should begin execution. */ - public boolean shouldExecute(){ - EntityLivingBase entitylivingbase = this.npc.getAttackTarget(); + public boolean shouldExecute() { + EntityLivingBase entitylivingbase = this.npc.getAttackTarget(); - if (entitylivingbase == null){ + if (entitylivingbase == null) { return false; - } - else if (!entitylivingbase.isEntityAlive()){ + } else if (!entitylivingbase.isEntityAlive()) { + return false; + } else if (this.npc.inventory.getProjectile() != null && this.npc.ais.useRangeMelee == 0) { return false; - } - else if (this.npc.inventory.getProjectile() != null && this.npc.ais.useRangeMelee == 0){ - return false; } double var2 = this.npc.getDistanceSq(entitylivingbase.posX, entitylivingbase.boundingBox.minY, entitylivingbase.posZ); double var3 = this.npc.ais.distanceToMelee * this.npc.ais.distanceToMelee; - if (this.npc.ais.useRangeMelee == 1 && var2 > var3){ - return false; - } - else{ - this.entityTarget = entitylivingbase; + if (this.npc.ais.useRangeMelee == 1 && var2 > var3) { + return false; + } else { + this.entityTarget = entitylivingbase; this.npc.getEntityAttribute(SharedMonsterAttributes.followRange).setBaseValue(((EntityNPCInterface) this.npc).stats.aggroRange); this.entityPathEntity = this.npc.getNavigator().getPathToEntityLiving(entitylivingbase); this.npc.getEntityAttribute(SharedMonsterAttributes.followRange).setBaseValue(ConfigMain.NpcNavRange); @@ -69,62 +67,56 @@ public class EntityAIAttackTarget extends EntityAIBase /** * Returns whether an in-progress EntityAIBase should continue executing */ - public boolean continueExecuting() - { - this.entityTarget = this.npc.getAttackTarget(); + public boolean continueExecuting() { + this.entityTarget = this.npc.getAttackTarget(); - if(entityTarget == null || !entityTarget.isEntityAlive()) - return false; - - if(entityTarget instanceof EntityPlayer && DBCAddon.instance.isKO(npc, (EntityPlayer) this.entityTarget)) + if (entityTarget == null || !entityTarget.isEntityAlive()) return false; - if(npc.getDistanceToEntity(entityTarget) > npc.stats.aggroRange) - return false; - if (this.npc.ais.useRangeMelee == 1 && npc.getDistanceSqToEntity(entityTarget) > (this.npc.ais.distanceToMelee * this.npc.ais.distanceToMelee)) - return false; + if (entityTarget instanceof EntityPlayer && DBCAddon.instance.isKO(npc, (EntityPlayer) this.entityTarget)) + return false; - return this.npc.isWithinHomeDistance(MathHelper.floor_double(entityTarget.posX), MathHelper.floor_double(entityTarget.posY), MathHelper.floor_double(entityTarget.posZ)); + if (npc.getDistanceToEntity(entityTarget) > npc.stats.aggroRange) + return false; + if (this.npc.ais.useRangeMelee == 1 && npc.getDistanceSqToEntity(entityTarget) > (this.npc.ais.distanceToMelee * this.npc.ais.distanceToMelee)) + return false; + + return this.npc.isWithinHomeDistance(MathHelper.floor_double(entityTarget.posX), MathHelper.floor_double(entityTarget.posY), MathHelper.floor_double(entityTarget.posZ)); } /** * Execute a one shot task or start executing a continuous task */ - public void startExecuting(){ - if(!navOverride) - this.npc.getNavigator().setPath(this.entityPathEntity, 1.3D); + public void startExecuting() { + if (!navOverride) + this.npc.getNavigator().setPath(this.entityPathEntity, 1.3D); this.field_75445_i = 0; - if (this.npc.getRangedTask() != null && this.npc.ais.useRangeMelee == 2) - { - this.npc.getRangedTask().navOverride(true); + if (this.npc.getRangedTask() != null && this.npc.ais.useRangeMelee == 2) { + this.npc.getRangedTask().navOverride(true); } } /** * Resets the task */ - public void resetTask() - { - this.entityPathEntity = null; - this.entityTarget = null; - this.npc.setAttackTarget(null); + public void resetTask() { + this.entityPathEntity = null; + this.entityTarget = null; + this.npc.setAttackTarget(null); this.npc.getNavigator().clearPathEntity(); - if (this.npc.getRangedTask() != null && this.npc.ais.useRangeMelee == 2) - { - this.npc.getRangedTask().navOverride(false); + if (this.npc.getRangedTask() != null && this.npc.ais.useRangeMelee == 2) { + this.npc.getRangedTask().navOverride(false); } } /** * Updates the task */ - public void updateTask() - { + public void updateTask() { this.npc.getLookHelper().setLookPositionWithEntity(this.entityTarget, 30.0F, 30.0F); - if (!navOverride && --this.field_75445_i <= 0) - { + if (!navOverride && --this.field_75445_i <= 0) { this.field_75445_i = 4 + this.npc.getRNG().nextInt(7); this.npc.getNavigator().tryMoveToEntityLiving(this.entityTarget, 1.3f); } @@ -133,13 +125,12 @@ public class EntityAIAttackTarget extends EntityAIBase double distance = this.npc.getDistanceSq(this.entityTarget.posX, this.entityTarget.boundingBox.minY, this.entityTarget.posZ); double range = npc.stats.attackRange * npc.stats.attackRange + entityTarget.width; double minRange = this.npc.width * 2.0F * this.npc.width * 2.0F + entityTarget.width; - if(minRange > range) - range = minRange; - if (distance <= range && (npc.canSee(this.entityTarget) || distance < minRange)) - { + if (minRange > range) + range = minRange; + if (distance <= range && (npc.canSee(this.entityTarget) || distance < minRange)) { if (this.attackTick <= 0) { this.attackTick = this.npc.stats.attackSpeed; - if(this.npc.stats.swingWarmUp == 0) + if (this.npc.stats.swingWarmUp == 0) this.npc.attackEntityAsMob(this.entityTarget); this.npc.swingItem(); } else if (this.npc.stats.swingWarmUp > 0 && this.attackTick == this.npc.stats.attackSpeed - this.npc.stats.swingWarmUp) { @@ -149,8 +140,8 @@ public class EntityAIAttackTarget extends EntityAIBase } } - public void navOverride(boolean nav){ - this.navOverride = nav; + public void navOverride(boolean nav) { + this.navOverride = nav; this.setMutexBits(this.navOverride ? AiMutex.PATHING : AiMutex.LOOK + AiMutex.PASSIVE); } } diff --git a/src/main/java/noppes/npcs/ai/EntityAIAvoidTarget.java b/src/main/java/noppes/npcs/ai/EntityAIAvoidTarget.java index bb88bdd5d..a845d2488 100644 --- a/src/main/java/noppes/npcs/ai/EntityAIAvoidTarget.java +++ b/src/main/java/noppes/npcs/ai/EntityAIAvoidTarget.java @@ -13,26 +13,32 @@ import noppes.npcs.entity.EntityNPCInterface; import java.util.List; -public class EntityAIAvoidTarget extends EntityAIBase -{ - /** The entity we are attached to */ +public class EntityAIAvoidTarget extends EntityAIBase { + /** + * The entity we are attached to + */ private EntityNPCInterface theEntity; private Entity closestLivingEntity; private float distanceFromEntity; private float health; - /** The PathEntity of our entity */ + /** + * The PathEntity of our entity + */ private PathEntity entityPathEntity; - /** The PathNavigate of our entity */ + /** + * The PathNavigate of our entity + */ private PathNavigate entityPathNavigate; - /** The class of the entity we should avoid */ + /** + * The class of the entity we should avoid + */ private Class targetEntityClass; - public EntityAIAvoidTarget(EntityNPCInterface par1EntityNPC) - { + public EntityAIAvoidTarget(EntityNPCInterface par1EntityNPC) { this.theEntity = par1EntityNPC; this.distanceFromEntity = this.theEntity.stats.aggroRange; this.health = this.theEntity.getHealth(); @@ -43,64 +49,47 @@ public class EntityAIAvoidTarget extends EntityAIBase /** * Returns whether the EntityAIBase should begin execution. */ - public boolean shouldExecute() - { - EntityLivingBase target = this.theEntity.getAttackTarget(); + public boolean shouldExecute() { + EntityLivingBase target = this.theEntity.getAttackTarget(); - if (target == null) - { + if (target == null) { return false; } - targetEntityClass = target.getClass(); + targetEntityClass = target.getClass(); - if (this.targetEntityClass == EntityPlayer.class) - { - this.closestLivingEntity = this.theEntity.worldObj.getClosestPlayerToEntity(this.theEntity, (double)this.distanceFromEntity); + if (this.targetEntityClass == EntityPlayer.class) { + this.closestLivingEntity = this.theEntity.worldObj.getClosestPlayerToEntity(this.theEntity, (double) this.distanceFromEntity); - if (this.closestLivingEntity == null) - { + if (this.closestLivingEntity == null) { return false; } - } - else - { - List var1 = this.theEntity.worldObj.getEntitiesWithinAABB(this.targetEntityClass, this.theEntity.boundingBox.expand((double)this.distanceFromEntity, 3.0D, (double)this.distanceFromEntity)); + } else { + List var1 = this.theEntity.worldObj.getEntitiesWithinAABB(this.targetEntityClass, this.theEntity.boundingBox.expand((double) this.distanceFromEntity, 3.0D, (double) this.distanceFromEntity)); - if (var1.isEmpty()) - { + if (var1.isEmpty()) { return false; } - this.closestLivingEntity = (Entity)var1.get(0); + this.closestLivingEntity = (Entity) var1.get(0); } - if (!this.theEntity.getEntitySenses().canSee(this.closestLivingEntity) && this.theEntity.ais.directLOS) - { + if (!this.theEntity.getEntitySenses().canSee(this.closestLivingEntity) && this.theEntity.ais.directLOS) { return false; - } - else - { + } else { Vec3 var2 = RandomPositionGeneratorAlt.findRandomTargetBlockAwayFrom(this.theEntity, 16, 7, Vec3.createVectorHelper(this.closestLivingEntity.posX, this.closestLivingEntity.posY, this.closestLivingEntity.posZ)); boolean var3 = this.theEntity.inventory.getProjectile() == null || this.theEntity.ais.useRangeMelee == 2; boolean var4 = var3 ? this.health == this.theEntity.getHealth() : this.theEntity.getRangedTask() != null && !this.theEntity.getRangedTask().hasFired(); - if (var2 == null) - { + if (var2 == null) { return false; - } - else if (this.closestLivingEntity.getDistanceSq(var2.xCoord, var2.yCoord, var2.zCoord) < this.closestLivingEntity.getDistanceSqToEntity(this.theEntity)) - { + } else if (this.closestLivingEntity.getDistanceSq(var2.xCoord, var2.yCoord, var2.zCoord) < this.closestLivingEntity.getDistanceSqToEntity(this.theEntity)) { return false; - } - else if (this.theEntity.ais.tacticalVariant == EnumNavType.HitNRun && var4) - { - return false; - } - else - { + } else if (this.theEntity.ais.tacticalVariant == EnumNavType.HitNRun && var4) { + return false; + } else { this.entityPathEntity = this.entityPathNavigate.getPathToXYZ(var2.xCoord, var2.yCoord, var2.zCoord); return this.entityPathEntity == null ? false : this.entityPathEntity.isDestinationSame(var2); } @@ -110,24 +99,21 @@ public class EntityAIAvoidTarget extends EntityAIBase /** * Returns whether an in-progress EntityAIBase should continue executing */ - public boolean continueExecuting() - { + public boolean continueExecuting() { return !this.entityPathNavigate.noPath(); } /** * Execute a one shot task or start executing a continuous task */ - public void startExecuting() - { + public void startExecuting() { this.entityPathNavigate.setPath(this.entityPathEntity, 1.0D); } /** * Resets the task */ - public void resetTask() - { + public void resetTask() { this.closestLivingEntity = null; this.theEntity.setAttackTarget(null); } @@ -135,23 +121,17 @@ public class EntityAIAvoidTarget extends EntityAIBase /** * Updates the task */ - public void updateTask() - { - if (this.theEntity.getDistanceSqToEntity(this.closestLivingEntity) < 49.0D) - { + public void updateTask() { + if (this.theEntity.getDistanceSqToEntity(this.closestLivingEntity) < 49.0D) { this.theEntity.getNavigator().setSpeed(1.2D); - } - else - { + } else { this.theEntity.getNavigator().setSpeed(1.0D); } - if (this.theEntity.ais.tacticalVariant == EnumNavType.HitNRun) - { - float dist = this.theEntity.getDistanceToEntity(this.closestLivingEntity); - if (dist > this.distanceFromEntity || dist < this.theEntity.ais.tacticalRadius) - { - this.health = this.theEntity.getHealth(); - } + if (this.theEntity.ais.tacticalVariant == EnumNavType.HitNRun) { + float dist = this.theEntity.getDistanceToEntity(this.closestLivingEntity); + if (dist > this.distanceFromEntity || dist < this.theEntity.ais.tacticalRadius) { + this.health = this.theEntity.getHealth(); + } } } } diff --git a/src/main/java/noppes/npcs/ai/EntityAIBustDoor.java b/src/main/java/noppes/npcs/ai/EntityAIBustDoor.java index bb70645dd..63b61d9cd 100644 --- a/src/main/java/noppes/npcs/ai/EntityAIBustDoor.java +++ b/src/main/java/noppes/npcs/ai/EntityAIBustDoor.java @@ -5,28 +5,25 @@ import net.minecraft.entity.EntityLiving; import net.minecraft.entity.ai.EntityAIDoorInteract; import net.minecraft.init.Blocks; -public class EntityAIBustDoor extends EntityAIDoorInteract -{ +public class EntityAIBustDoor extends EntityAIDoorInteract { private int breakingTime; private int field_75358_j = -1; - public EntityAIBustDoor(EntityLiving par1EntityLiving){ + public EntityAIBustDoor(EntityLiving par1EntityLiving) { super(par1EntityLiving); } /** * Returns whether the EntityAIBase should begin execution. */ - public boolean shouldExecute() - { + public boolean shouldExecute() { return !super.shouldExecute() ? false : (!this.theEntity.worldObj.getGameRules().getGameRuleBooleanValue("mobGriefing") ? false : !this.field_151504_e.func_150015_f(this.theEntity.worldObj, this.entityPosX, this.entityPosY, this.entityPosZ)); } /** * Execute a one shot task or start executing a continuous task */ - public void startExecuting() - { + public void startExecuting() { super.startExecuting(); this.breakingTime = 0; } @@ -34,17 +31,15 @@ public class EntityAIBustDoor extends EntityAIDoorInteract /** * Returns whether an in-progress EntityAIBase should continue executing */ - public boolean continueExecuting() - { - double var1 = this.theEntity.getDistanceSq((double)this.entityPosX, (double)this.entityPosY, (double)this.entityPosZ); + public boolean continueExecuting() { + double var1 = this.theEntity.getDistanceSq((double) this.entityPosX, (double) this.entityPosY, (double) this.entityPosZ); return this.breakingTime <= 240 && !this.field_151504_e.func_150015_f(this.theEntity.worldObj, this.entityPosX, this.entityPosY, this.entityPosZ) && var1 < 4.0D; } /** * Resets the task */ - public void resetTask() - { + public void resetTask() { super.resetTask(); this.theEntity.worldObj.destroyBlockInWorldPartially(this.theEntity.getEntityId(), this.entityPosX, this.entityPosY, this.entityPosZ, -1); } @@ -52,27 +47,23 @@ public class EntityAIBustDoor extends EntityAIDoorInteract /** * Updates the task */ - public void updateTask() - { + public void updateTask() { super.updateTask(); - if (this.theEntity.getRNG().nextInt(20) == 0) - { + if (this.theEntity.getRNG().nextInt(20) == 0) { this.theEntity.worldObj.playAuxSFX(1010, this.entityPosX, this.entityPosY, this.entityPosZ, 0); this.theEntity.swingItem(); } ++this.breakingTime; - int var1 = (int)((float)this.breakingTime / 240.0F * 10.0F); + int var1 = (int) ((float) this.breakingTime / 240.0F * 10.0F); - if (var1 != this.field_75358_j) - { + if (var1 != this.field_75358_j) { this.theEntity.worldObj.destroyBlockInWorldPartially(this.theEntity.getEntityId(), this.entityPosX, this.entityPosY, this.entityPosZ, var1); this.field_75358_j = var1; } - if (this.breakingTime == 240) - { + if (this.breakingTime == 240) { this.theEntity.worldObj.setBlock(this.entityPosX, this.entityPosY, this.entityPosZ, Blocks.air); this.theEntity.worldObj.playAuxSFX(1012, this.entityPosX, this.entityPosY, this.entityPosZ, 0); this.theEntity.worldObj.playAuxSFX(2001, this.entityPosX, this.entityPosY, this.entityPosZ, Block.getIdFromBlock(this.field_151504_e)); diff --git a/src/main/java/noppes/npcs/ai/EntityAIDodgeShoot.java b/src/main/java/noppes/npcs/ai/EntityAIDodgeShoot.java index 3297f45cb..ef7b3f5ac 100644 --- a/src/main/java/noppes/npcs/ai/EntityAIDodgeShoot.java +++ b/src/main/java/noppes/npcs/ai/EntityAIDodgeShoot.java @@ -6,15 +6,13 @@ import net.minecraft.util.Vec3; import noppes.npcs.constants.AiMutex; import noppes.npcs.entity.EntityNPCInterface; -public class EntityAIDodgeShoot extends EntityAIBase -{ +public class EntityAIDodgeShoot extends EntityAIBase { private EntityNPCInterface entity; private double xPosition; private double yPosition; private double zPosition; - public EntityAIDodgeShoot(EntityNPCInterface par1EntityNPCInterface) - { + public EntityAIDodgeShoot(EntityNPCInterface par1EntityNPCInterface) { this.entity = par1EntityNPCInterface; this.setMutexBits(AiMutex.PASSIVE); } @@ -22,33 +20,23 @@ public class EntityAIDodgeShoot extends EntityAIBase /** * Returns whether the EntityAIBase should begin execution. */ - public boolean shouldExecute() - { - EntityLivingBase var1 = this.entity.getAttackTarget(); + public boolean shouldExecute() { + EntityLivingBase var1 = this.entity.getAttackTarget(); - if (var1 == null || !var1.isEntityAlive()) - { + if (var1 == null || !var1.isEntityAlive()) { return false; } - if (this.entity.inventory.getProjectile() == null) - { - return false; - } - else if (this.entity.getRangedTask() == null) - { - return false; - } - else - { + if (this.entity.inventory.getProjectile() == null) { + return false; + } else if (this.entity.getRangedTask() == null) { + return false; + } else { - Vec3 vec = this.entity.getRangedTask().hasFired() ? RandomPositionGeneratorAlt.findRandomTarget(this.entity, 4, 1) : null; + Vec3 vec = this.entity.getRangedTask().hasFired() ? RandomPositionGeneratorAlt.findRandomTarget(this.entity, 4, 1) : null; - if (vec == null) - { + if (vec == null) { return false; - } - else - { + } else { this.xPosition = vec.xCoord; this.yPosition = vec.yCoord; this.zPosition = vec.zCoord; @@ -60,25 +48,22 @@ public class EntityAIDodgeShoot extends EntityAIBase /** * Returns whether an in-progress EntityAIBase should continue executing */ - public boolean continueExecuting() - { + public boolean continueExecuting() { return !this.entity.getNavigator().noPath(); } /** * Execute a one shot task or start executing a continuous task */ - public void startExecuting() - { + public void startExecuting() { this.entity.getNavigator().tryMoveToXYZ(this.xPosition, this.yPosition, this.zPosition, 1.2D); } - + /** * Updates the task */ - public void updateTask() - { - if (this.entity.getAttackTarget() != null) - this.entity.getLookHelper().setLookPositionWithEntity(this.entity.getAttackTarget(), 30.0F, 30.0F); + public void updateTask() { + if (this.entity.getAttackTarget() != null) + this.entity.getLookHelper().setLookPositionWithEntity(this.entity.getAttackTarget(), 30.0F, 30.0F); } } diff --git a/src/main/java/noppes/npcs/ai/EntityAIFindShade.java b/src/main/java/noppes/npcs/ai/EntityAIFindShade.java index 5d24047ff..265b3c6ba 100644 --- a/src/main/java/noppes/npcs/ai/EntityAIFindShade.java +++ b/src/main/java/noppes/npcs/ai/EntityAIFindShade.java @@ -9,16 +9,14 @@ import noppes.npcs.constants.AiMutex; import java.util.Random; -public class EntityAIFindShade extends EntityAIBase -{ +public class EntityAIFindShade extends EntityAIBase { private EntityCreature theCreature; private double shelterX; private double shelterY; private double shelterZ; private World theWorld; - public EntityAIFindShade(EntityCreature par1EntityCreature) - { + public EntityAIFindShade(EntityCreature par1EntityCreature) { this.theCreature = par1EntityCreature; this.theWorld = par1EntityCreature.worldObj; this.setMutexBits(AiMutex.PASSIVE); @@ -27,26 +25,17 @@ public class EntityAIFindShade extends EntityAIBase /** * Returns whether the EntityAIBase should begin execution. */ - public boolean shouldExecute() - { - if (!this.theWorld.isDaytime()) - { + public boolean shouldExecute() { + if (!this.theWorld.isDaytime()) { return false; - } - else if (!this.theWorld.canBlockSeeTheSky(MathHelper.floor_double(this.theCreature.posX), (int)this.theCreature.boundingBox.minY, MathHelper.floor_double(this.theCreature.posZ))) - { + } else if (!this.theWorld.canBlockSeeTheSky(MathHelper.floor_double(this.theCreature.posX), (int) this.theCreature.boundingBox.minY, MathHelper.floor_double(this.theCreature.posZ))) { return false; - } - else - { + } else { Vec3 var1 = this.findPossibleShelter(); - if (var1 == null) - { + if (var1 == null) { return false; - } - else - { + } else { this.shelterX = var1.xCoord; this.shelterY = var1.yCoord; this.shelterZ = var1.zCoord; @@ -58,33 +47,28 @@ public class EntityAIFindShade extends EntityAIBase /** * Returns whether an in-progress EntityAIBase should continue executing */ - public boolean continueExecuting() - { + public boolean continueExecuting() { return !this.theCreature.getNavigator().noPath(); } /** * Execute a one shot task or start executing a continuous task */ - public void startExecuting() - { + public void startExecuting() { this.theCreature.getNavigator().tryMoveToXYZ(this.shelterX, this.shelterY, this.shelterZ, 1.0D); } - private Vec3 findPossibleShelter() - { + private Vec3 findPossibleShelter() { Random var1 = this.theCreature.getRNG(); - for (int var2 = 0; var2 < 10; ++var2) - { - int var3 = MathHelper.floor_double(this.theCreature.posX + (double)var1.nextInt(20) - 10.0D); - int var4 = MathHelper.floor_double(this.theCreature.boundingBox.minY + (double)var1.nextInt(6) - 3.0D); - int var5 = MathHelper.floor_double(this.theCreature.posZ + (double)var1.nextInt(20) - 10.0D); - + for (int var2 = 0; var2 < 10; ++var2) { + int var3 = MathHelper.floor_double(this.theCreature.posX + (double) var1.nextInt(20) - 10.0D); + int var4 = MathHelper.floor_double(this.theCreature.boundingBox.minY + (double) var1.nextInt(6) - 3.0D); + int var5 = MathHelper.floor_double(this.theCreature.posZ + (double) var1.nextInt(20) - 10.0D); + float light = this.theWorld.getLightBrightness(var3, var4, var5) - 0.5F; - if (!this.theWorld.canBlockSeeTheSky(var3, var4, var5) && light < 0.0F) - { - return Vec3.createVectorHelper((double)var3, (double)var4, (double)var5); + if (!this.theWorld.canBlockSeeTheSky(var3, var4, var5) && light < 0.0F) { + return Vec3.createVectorHelper((double) var3, (double) var4, (double) var5); } } diff --git a/src/main/java/noppes/npcs/ai/EntityAIFollow.java b/src/main/java/noppes/npcs/ai/EntityAIFollow.java index e1034c182..61cabd38f 100644 --- a/src/main/java/noppes/npcs/ai/EntityAIFollow.java +++ b/src/main/java/noppes/npcs/ai/EntityAIFollow.java @@ -8,72 +8,69 @@ import noppes.npcs.constants.AiMutex; import noppes.npcs.constants.EnumAnimation; import noppes.npcs.entity.EntityNPCInterface; -public class EntityAIFollow extends EntityAIBase -{ +public class EntityAIFollow extends EntityAIBase { private EntityNPCInterface npc; private EntityLivingBase owner; private double distance; - public int updateTick = 0; + public int updateTick = 0; - public EntityAIFollow(EntityNPCInterface npc){ + public EntityAIFollow(EntityNPCInterface npc) { this.npc = npc; this.setMutexBits(AiMutex.PASSIVE + AiMutex.LOOK); } @Override - public boolean shouldExecute(){ - if(!excute()) - return false; - return distance > npc.followRange(); + public boolean shouldExecute() { + if (!excute()) + return false; + return distance > npc.followRange(); } - public boolean excute(){ - if(!npc.isEntityAlive() || !npc.isFollower() || npc.isAttacking() || (owner = npc.getOwner()) == null || npc.ais.animationType == EnumAnimation.SITTING) - return false; - distance = npc.getDistanceSqToEntity(owner); - return true; + public boolean excute() { + if (!npc.isEntityAlive() || !npc.isFollower() || npc.isAttacking() || (owner = npc.getOwner()) == null || npc.ais.animationType == EnumAnimation.SITTING) + return false; + distance = npc.getDistanceSqToEntity(owner); + return true; } @Override - public void startExecuting(){ - updateTick = 10; + public void startExecuting() { + updateTick = 10; } @Override - public boolean continueExecuting(){ + public boolean continueExecuting() { return !this.npc.getNavigator().noPath() && distance > 4 && excute(); } + @Override - public void resetTask(){ + public void resetTask() { this.owner = null; this.npc.getNavigator().clearPathEntity(); } @Override - public void updateTask(){ - updateTick++; - if(updateTick < 10) - return; - updateTick = 0; - this.npc.getLookHelper().setLookPositionWithEntity(owner, 10.0F, (float)this.npc.getVerticalFaceSpeed()); + public void updateTask() { + updateTick++; + if (updateTick < 10) + return; + updateTick = 0; + this.npc.getLookHelper().setLookPositionWithEntity(owner, 10.0F, (float) this.npc.getVerticalFaceSpeed()); - double speed = 1 + distance / 150; - if(speed > 3) - speed = 3; + double speed = 1 + distance / 150; + if (speed > 3) + speed = 3; if (this.npc.getNavigator().tryMoveToEntityLiving(owner, speed) || distance < 225.0D) - return; + return; int i = MathHelper.floor_double(this.owner.posX) - 2; int j = MathHelper.floor_double(this.owner.posZ) - 2; int k = MathHelper.floor_double(this.owner.boundingBox.minY); - for (int l = 0; l <= 4; ++l) - { - for (int i1 = 0; i1 <= 4; ++i1) - { - if ((l < 1 || i1 < 1 || l > 3 || i1 > 3) && World.doesBlockHaveSolidTopSurface(npc.worldObj, i + l, k - 1, j + i1) && !npc.worldObj.getBlock(i + l, k, j + i1).isNormalCube() && !npc.worldObj.getBlock(i + l, k + 1, j + i1).isNormalCube()) - { - this.npc.setLocationAndAngles((double)((float)(i + l) + 0.5F), (double)k, (double)((float)(j + i1) + 0.5F), this.npc.rotationYaw, this.npc.rotationPitch); + for (int l = 0; l <= 4; ++l) { + for (int i1 = 0; i1 <= 4; ++i1) { + if ((l < 1 || i1 < 1 || l > 3 || i1 > 3) && World.doesBlockHaveSolidTopSurface(npc.worldObj, i + l, k - 1, j + i1) && !npc.worldObj.getBlock(i + l, k, j + i1).isNormalCube() && !npc.worldObj.getBlock(i + l, k + 1, j + i1).isNormalCube()) { + this.npc.setLocationAndAngles((double) ((float) (i + l) + 0.5F), (double) k, (double) ((float) (j + i1) + 0.5F), this.npc.rotationYaw, this.npc.rotationPitch); this.npc.getNavigator().clearPathEntity(); return; } diff --git a/src/main/java/noppes/npcs/ai/EntityAIJob.java b/src/main/java/noppes/npcs/ai/EntityAIJob.java index 9badc98d4..b51fc3f23 100644 --- a/src/main/java/noppes/npcs/ai/EntityAIJob.java +++ b/src/main/java/noppes/npcs/ai/EntityAIJob.java @@ -5,38 +5,36 @@ import noppes.npcs.entity.EntityNPCInterface; public class EntityAIJob extends EntityAIBase { - private EntityNPCInterface npc; - public EntityAIJob(EntityNPCInterface npc){ - this.npc = npc; - } - - @Override - public boolean shouldExecute() { - if(npc.isKilled() || npc.jobInterface == null) - return false; - return npc.jobInterface.aiShouldExecute(); - } - - public void startExecuting() - { - npc.jobInterface.aiStartExecuting(); + private EntityNPCInterface npc; + + public EntityAIJob(EntityNPCInterface npc) { + this.npc = npc; } - - @Override - public boolean continueExecuting() - { - if(npc.isKilled() || npc.jobInterface == null) - return false; - return npc.jobInterface.aiContinueExecute(); + + @Override + public boolean shouldExecute() { + if (npc.isKilled() || npc.jobInterface == null) + return false; + return npc.jobInterface.aiShouldExecute(); } - - public void updateTask() - { - npc.jobInterface.aiUpdateTask(); + + public void startExecuting() { + npc.jobInterface.aiStartExecuting(); + } + + @Override + public boolean continueExecuting() { + if (npc.isKilled() || npc.jobInterface == null) + return false; + return npc.jobInterface.aiContinueExecute(); + } + + public void updateTask() { + npc.jobInterface.aiUpdateTask(); } public void resetTask() { - if(npc.jobInterface != null) - npc.jobInterface.resetTask(); + if (npc.jobInterface != null) + npc.jobInterface.resetTask(); } } diff --git a/src/main/java/noppes/npcs/ai/EntityAILook.java b/src/main/java/noppes/npcs/ai/EntityAILook.java index 938c8816b..3448fc4ed 100644 --- a/src/main/java/noppes/npcs/ai/EntityAILook.java +++ b/src/main/java/noppes/npcs/ai/EntityAILook.java @@ -9,14 +9,14 @@ import noppes.npcs.entity.EntityNPCInterface; import java.util.Iterator; -public class EntityAILook extends EntityAIBase{ +public class EntityAILook extends EntityAIBase { private final EntityNPCInterface npc; private int idle = 0; private double lookX; private double lookZ; boolean rotatebody; - public EntityAILook(EntityNPCInterface npc){ + public EntityAILook(EntityNPCInterface npc) { this.npc = npc; this.setMutexBits(AiMutex.LOOK); } @@ -25,7 +25,7 @@ public class EntityAILook extends EntityAIBase{ * Returns whether the EntityAIBase should begin execution. */ @Override - public boolean shouldExecute(){ + public boolean shouldExecute() { return !npc.isAttacking() && npc.getNavigator().noPath() && !npc.isPlayerSleeping() && npc.isEntityAlive(); } @@ -33,68 +33,67 @@ public class EntityAILook extends EntityAIBase{ * Execute a one shot task or start executing a continuous task */ @Override - public void startExecuting(){ - rotatebody = npc.ais.standingType == EnumStandingType.RotateBody || npc.ais.standingType == EnumStandingType.HeadRotation; + public void startExecuting() { + rotatebody = npc.ais.standingType == EnumStandingType.RotateBody || npc.ais.standingType == EnumStandingType.HeadRotation; } /** * Resets the task */ @Override - public void resetTask(){ - rotatebody = false; + public void resetTask() { + rotatebody = false; } /** * Updates the task */ @Override - public void updateTask(){ - if(npc.ais.standingType == EnumStandingType.Stalking){ - EntityPlayer player = npc.worldObj.getClosestPlayerToEntity(npc, 16); - if(player == null) - rotatebody = true; - else - npc.getLookHelper().setLookPositionWithEntity(player, 10F, npc.getVerticalFaceSpeed()); - } - if(npc.isInteracting()){ - Iterator ita = npc.interactingEntities.iterator(); - EntityLivingBase closest = null; - double closestDistance = 12; - while(ita.hasNext()){ - EntityLivingBase entity = ita.next(); - double distance = entity.getDistanceSqToEntity(npc); - if(distance < closestDistance){ - closestDistance = entity.getDistanceSqToEntity(npc); - closest = entity; - } - else if(distance > 12) - ita.remove(); - } - if(closest != null){ - npc.getLookHelper().setLookPositionWithEntity(closest, 10F, npc.getVerticalFaceSpeed()); - return; - } + public void updateTask() { + if (npc.ais.standingType == EnumStandingType.Stalking) { + EntityPlayer player = npc.worldObj.getClosestPlayerToEntity(npc, 16); + if (player == null) + rotatebody = true; + else + npc.getLookHelper().setLookPositionWithEntity(player, 10F, npc.getVerticalFaceSpeed()); + } + if (npc.isInteracting()) { + Iterator ita = npc.interactingEntities.iterator(); + EntityLivingBase closest = null; + double closestDistance = 12; + while (ita.hasNext()) { + EntityLivingBase entity = ita.next(); + double distance = entity.getDistanceSqToEntity(npc); + if (distance < closestDistance) { + closestDistance = entity.getDistanceSqToEntity(npc); + closest = entity; + } else if (distance > 12) + ita.remove(); + } + if (closest != null) { + npc.getLookHelper().setLookPositionWithEntity(closest, 10F, npc.getVerticalFaceSpeed()); + return; + } - } + } - if(rotatebody){ - if(idle == 0 && npc.getRNG().nextFloat() < 0.02F){ - double var1 = (Math.PI * 2D) * this.npc.getRNG().nextDouble(); - if(npc.ais.standingType == EnumStandingType.HeadRotation) - var1 = Math.PI / 180 * npc.ais.orientation + Math.PI * 0.2 + Math.PI * 0.6 * this.npc.getRNG().nextDouble(); - this.lookX = Math.cos(var1); - this.lookZ = Math.sin(var1); - this.idle = 20 + this.npc.getRNG().nextInt(20); - } - if(idle > 0){ - idle--; - npc.getLookHelper().setLookPosition(npc.posX + lookX, npc.posY + npc.getEyeHeight(), npc.posZ + lookZ, 10F, npc.getVerticalFaceSpeed()); - } - } + if (rotatebody) { + if (idle == 0 && npc.getRNG().nextFloat() < 0.02F) { + double var1 = (Math.PI * 2D) * this.npc.getRNG().nextDouble(); + if (npc.ais.standingType == EnumStandingType.HeadRotation) + var1 = Math.PI / 180 * npc.ais.orientation + Math.PI * 0.2 + Math.PI * 0.6 * this.npc.getRNG().nextDouble(); + this.lookX = Math.cos(var1); + this.lookZ = Math.sin(var1); + this.idle = 20 + this.npc.getRNG().nextInt(20); + } + if (idle > 0) { + idle--; + npc.getLookHelper().setLookPosition(npc.posX + lookX, npc.posY + npc.getEyeHeight(), npc.posZ + lookZ, 10F, npc.getVerticalFaceSpeed()); + } + } - if(npc.ais.standingType == EnumStandingType.NoRotation){ - npc.rotationYawHead = npc.rotationYaw = npc.renderYawOffset = npc.ais.orientation; - } + if (npc.ais.standingType == EnumStandingType.NoRotation) { + npc.rotationYawHead = npc.rotationYaw = npc.renderYawOffset = npc.ais.orientation; + } } } diff --git a/src/main/java/noppes/npcs/ai/EntityAIMoveIndoors.java b/src/main/java/noppes/npcs/ai/EntityAIMoveIndoors.java index 47f4f3c86..45f4057af 100644 --- a/src/main/java/noppes/npcs/ai/EntityAIMoveIndoors.java +++ b/src/main/java/noppes/npcs/ai/EntityAIMoveIndoors.java @@ -9,16 +9,14 @@ import noppes.npcs.constants.AiMutex; import java.util.Random; -public class EntityAIMoveIndoors extends EntityAIBase -{ +public class EntityAIMoveIndoors extends EntityAIBase { private EntityCreature theCreature; private double shelterX; private double shelterY; private double shelterZ; private World theWorld; - public EntityAIMoveIndoors(EntityCreature par1EntityCreature) - { + public EntityAIMoveIndoors(EntityCreature par1EntityCreature) { this.theCreature = par1EntityCreature; this.theWorld = par1EntityCreature.worldObj; this.setMutexBits(AiMutex.PASSIVE); @@ -27,70 +25,55 @@ public class EntityAIMoveIndoors extends EntityAIBase /** * Returns whether the EntityAIBase should begin execution. */ - public boolean shouldExecute() - { - - int x = MathHelper.floor_double(this.theCreature.posX); - int y = (int)this.theCreature.boundingBox.minY; - int z = MathHelper.floor_double(this.theCreature.posZ); - if ((!this.theCreature.worldObj.isDaytime() || this.theCreature.worldObj.isRaining()) && !this.theCreature.worldObj.provider.hasNoSky) - { - if (!this.theWorld.canBlockSeeTheSky(x, y, z) && this.theWorld.getFullBlockLightValue(x, y, z) > 8) - { + public boolean shouldExecute() { + + int x = MathHelper.floor_double(this.theCreature.posX); + int y = (int) this.theCreature.boundingBox.minY; + int z = MathHelper.floor_double(this.theCreature.posZ); + if ((!this.theCreature.worldObj.isDaytime() || this.theCreature.worldObj.isRaining()) && !this.theCreature.worldObj.provider.hasNoSky) { + if (!this.theWorld.canBlockSeeTheSky(x, y, z) && this.theWorld.getFullBlockLightValue(x, y, z) > 8) { return false; + } else { + Vec3 var1 = this.findPossibleShelter(); + + if (var1 == null) { + return false; + } else { + this.shelterX = var1.xCoord; + this.shelterY = var1.yCoord; + this.shelterZ = var1.zCoord; + return true; + } } - else - { - Vec3 var1 = this.findPossibleShelter(); - - if (var1 == null) - { - return false; - } - else - { - this.shelterX = var1.xCoord; - this.shelterY = var1.yCoord; - this.shelterZ = var1.zCoord; - return true; - } - } + } else { + return false; } - else - { - return false; - } } /** * Returns whether an in-progress EntityAIBase should continue executing */ - public boolean continueExecuting() - { + public boolean continueExecuting() { return !this.theCreature.getNavigator().noPath(); } /** * Execute a one shot task or start executing a continuous task */ - public void startExecuting() - { + public void startExecuting() { this.theCreature.getNavigator().tryMoveToXYZ(this.shelterX, this.shelterY, this.shelterZ, 1.0D); } - private Vec3 findPossibleShelter() - { + private Vec3 findPossibleShelter() { Random var1 = this.theCreature.getRNG(); - for (int var2 = 0; var2 < 10; ++var2) - { - int var3 = MathHelper.floor_double(this.theCreature.posX + (double)var1.nextInt(20) - 10.0D); - int var4 = MathHelper.floor_double(this.theCreature.boundingBox.minY + (double)var1.nextInt(6) - 3.0D); - int var5 = MathHelper.floor_double(this.theCreature.posZ + (double)var1.nextInt(20) - 10.0D); + for (int var2 = 0; var2 < 10; ++var2) { + int var3 = MathHelper.floor_double(this.theCreature.posX + (double) var1.nextInt(20) - 10.0D); + int var4 = MathHelper.floor_double(this.theCreature.boundingBox.minY + (double) var1.nextInt(6) - 3.0D); + int var5 = MathHelper.floor_double(this.theCreature.posZ + (double) var1.nextInt(20) - 10.0D); - if (!this.theWorld.canBlockSeeTheSky(var3, var4, var5) && this.theWorld.getFullBlockLightValue(var3, var4, var5) > 8) - { - return Vec3.createVectorHelper((double)var3, (double)var4, (double)var5); + if (!this.theWorld.canBlockSeeTheSky(var3, var4, var5) && this.theWorld.getFullBlockLightValue(var3, var4, var5) > 8) { + return Vec3.createVectorHelper((double) var3, (double) var4, (double) var5); } } diff --git a/src/main/java/noppes/npcs/ai/EntityAIMovingPath.java b/src/main/java/noppes/npcs/ai/EntityAIMovingPath.java index ae7a7db85..7b8422a29 100644 --- a/src/main/java/noppes/npcs/ai/EntityAIMovingPath.java +++ b/src/main/java/noppes/npcs/ai/EntityAIMovingPath.java @@ -6,12 +6,11 @@ import noppes.npcs.entity.EntityNPCInterface; import java.util.List; -public class EntityAIMovingPath extends EntityAIBase -{ +public class EntityAIMovingPath extends EntityAIBase { private EntityNPCInterface npc; private int[] pos; - public EntityAIMovingPath(EntityNPCInterface par1EntityNPCInterface){ + public EntityAIMovingPath(EntityNPCInterface par1EntityNPCInterface) { this.npc = par1EntityNPCInterface; this.setMutexBits(AiMutex.PASSIVE); } @@ -20,16 +19,16 @@ public class EntityAIMovingPath extends EntityAIBase * Returns whether the EntityAIBase should begin execution. */ @Override - public boolean shouldExecute(){ + public boolean shouldExecute() { if (npc.isAttacking() || npc.isInteracting() || npc.getRNG().nextInt(40) != 0 && npc.ais.movingPause || !npc.getNavigator().noPath() || npc.isInteracting()) return false; List list = npc.ais.getMovingPath(); - if(list.size() < 2) - return false; + if (list.size() < 2) + return false; npc.ais.incrementMovingPath(); - pos = npc.ais.getCurrentMovingPath(); + pos = npc.ais.getCurrentMovingPath(); return true; } @@ -38,11 +37,11 @@ public class EntityAIMovingPath extends EntityAIBase * Returns whether an in-progress EntityAIBase should continue executing */ @Override - public boolean continueExecuting(){ - if(npc.isAttacking() || npc.isInteracting()){ - npc.ais.decreaseMovingPath(); - return false; - } + public boolean continueExecuting() { + if (npc.isAttacking() || npc.isInteracting()) { + npc.ais.decreaseMovingPath(); + return false; + } return !this.npc.getNavigator().noPath(); } @@ -50,7 +49,7 @@ public class EntityAIMovingPath extends EntityAIBase * Execute a one shot task or start executing a continuous task */ @Override - public void startExecuting(){ + public void startExecuting() { this.npc.getNavigator().tryMoveToXYZ(pos[0] + 0.5, pos[1], pos[2] + 0.5, 1.0D); } } diff --git a/src/main/java/noppes/npcs/ai/EntityAIOrbitTarget.java b/src/main/java/noppes/npcs/ai/EntityAIOrbitTarget.java index 2c40e13cb..4c72ec278 100644 --- a/src/main/java/noppes/npcs/ai/EntityAIOrbitTarget.java +++ b/src/main/java/noppes/npcs/ai/EntityAIOrbitTarget.java @@ -8,8 +8,7 @@ import noppes.npcs.entity.EntityNPCInterface; import java.util.Random; -public class EntityAIOrbitTarget extends EntityAIBase -{ +public class EntityAIOrbitTarget extends EntityAIBase { private EntityNPCInterface theEntity; private EntityLivingBase targetEntity; private double movePosX; @@ -26,8 +25,7 @@ public class EntityAIOrbitTarget extends EntityAIBase private float decayRate = 1.0F; private int tick = 0; - public EntityAIOrbitTarget(EntityNPCInterface par1EntityCreature, double par2, float par4, boolean par5) - { + public EntityAIOrbitTarget(EntityNPCInterface par1EntityCreature, double par2, float par4, boolean par5) { this.theEntity = par1EntityCreature; this.speed = par2; this.distance = par4; @@ -38,90 +36,78 @@ public class EntityAIOrbitTarget extends EntityAIBase /** * Returns whether the EntityAIBase should begin execution. */ - public boolean shouldExecute() - { - if (--delay > 0) - { - return false; - } - - this.targetEntity = this.theEntity.getAttackTarget(); - - if (this.targetEntity == null) - { + public boolean shouldExecute() { + if (--delay > 0) { return false; } - else - { - double d0 = this.theEntity.getDistanceToEntity(this.targetEntity); - return d0 >= this.distance / 2.0F && (this.theEntity.inventory.getProjectile() == null ? d0 <= this.distance : true); + + this.targetEntity = this.theEntity.getAttackTarget(); + + if (this.targetEntity == null) { + return false; + } else { + double d0 = this.theEntity.getDistanceToEntity(this.targetEntity); + return d0 >= this.distance / 2.0F && (this.theEntity.inventory.getProjectile() == null ? d0 <= this.distance : true); } } /** * Returns whether an in-progress EntityAIBase should continue executing */ - public boolean continueExecuting() - { - double d0 = this.targetEntity.getDistanceToEntity(this.theEntity); - return this.targetEntity.isEntityAlive() && d0 >= this.distance / 2.0F && d0 <= this.distance * 1.5F && !this.theEntity.isInWater() && this.canNavigate; + public boolean continueExecuting() { + double d0 = this.targetEntity.getDistanceToEntity(this.theEntity); + return this.targetEntity.isEntityAlive() && d0 >= this.distance / 2.0F && d0 <= this.distance * 1.5F && !this.theEntity.isInWater() && this.canNavigate; } /** * Resets the task */ - public void resetTask() - { - this.theEntity.getNavigator().clearPathEntity(); - this.delay = 60; - if (this.theEntity.getRangedTask() != null){ - this.theEntity.getRangedTask().navOverride(false); + public void resetTask() { + this.theEntity.getNavigator().clearPathEntity(); + this.delay = 60; + if (this.theEntity.getRangedTask() != null) { + this.theEntity.getRangedTask().navOverride(false); } } /** * Execute a one shot task or start executing a continuous task */ - public void startExecuting() - { - this.canNavigate = true; - Random random = this.theEntity.getRNG(); - this.direction = random.nextInt(10) > 5 ? 1 : -1; - this.decayRate = random.nextFloat() + (this.distance / 16.0F); + public void startExecuting() { + this.canNavigate = true; + Random random = this.theEntity.getRNG(); + this.direction = random.nextInt(10) > 5 ? 1 : -1; + this.decayRate = random.nextFloat() + (this.distance / 16.0F); this.targetDistance = this.theEntity.getDistanceToEntity(this.targetEntity); double d0 = this.theEntity.posX - this.targetEntity.posX; double d1 = this.theEntity.posZ - this.targetEntity.posZ; this.angle = (float) (Math.atan2(d1, d0) * 180.0F / Math.PI); - if (this.theEntity.getRangedTask() != null){ - this.theEntity.getRangedTask().navOverride(true); + if (this.theEntity.getRangedTask() != null) { + this.theEntity.getRangedTask().navOverride(true); } } - + /** * Updates the task */ - public void updateTask() - { - this.theEntity.getLookHelper().setLookPositionWithEntity(targetEntity, 30.0F, 30.0F); - if (this.theEntity.getNavigator().noPath() && this.tick >= 0) - { - if (this.theEntity.onGround && !this.theEntity.isInWater()) - { - double d0 = this.targetDistance * (double)(MathHelper.cos(angle / 180.0F * (float)Math.PI)); - double d1 = this.targetDistance * (double)(MathHelper.sin(angle / 180.0F * (float)Math.PI)); - this.movePosX = this.targetEntity.posX + d0; - this.movePosY = this.targetEntity.boundingBox.maxY; - this.movePosZ = this.targetEntity.posZ + d1; - this.theEntity.getNavigator().tryMoveToXYZ(this.movePosX, this.movePosY, this.movePosZ, this.speed); - this.angle += 15.0F * this.direction; - this.tick = MathHelper.ceiling_double_int(this.theEntity.getDistance(this.movePosX, this.movePosY, this.movePosZ) / (this.theEntity.getSpeed() / 20.0F)); - if (this.decay) - { - this.targetDistance -=decayRate; - } - } - } - if (this.tick >= 0) this.tick--; + public void updateTask() { + this.theEntity.getLookHelper().setLookPositionWithEntity(targetEntity, 30.0F, 30.0F); + if (this.theEntity.getNavigator().noPath() && this.tick >= 0) { + if (this.theEntity.onGround && !this.theEntity.isInWater()) { + double d0 = this.targetDistance * (double) (MathHelper.cos(angle / 180.0F * (float) Math.PI)); + double d1 = this.targetDistance * (double) (MathHelper.sin(angle / 180.0F * (float) Math.PI)); + this.movePosX = this.targetEntity.posX + d0; + this.movePosY = this.targetEntity.boundingBox.maxY; + this.movePosZ = this.targetEntity.posZ + d1; + this.theEntity.getNavigator().tryMoveToXYZ(this.movePosX, this.movePosY, this.movePosZ, this.speed); + this.angle += 15.0F * this.direction; + this.tick = MathHelper.ceiling_double_int(this.theEntity.getDistance(this.movePosX, this.movePosY, this.movePosZ) / (this.theEntity.getSpeed() / 20.0F)); + if (this.decay) { + this.targetDistance -= decayRate; + } + } + } + if (this.tick >= 0) this.tick--; } } diff --git a/src/main/java/noppes/npcs/ai/EntityAIPanic.java b/src/main/java/noppes/npcs/ai/EntityAIPanic.java index 6edc6c895..34de1eb75 100644 --- a/src/main/java/noppes/npcs/ai/EntityAIPanic.java +++ b/src/main/java/noppes/npcs/ai/EntityAIPanic.java @@ -5,16 +5,14 @@ import net.minecraft.entity.ai.EntityAIBase; import net.minecraft.util.Vec3; import noppes.npcs.constants.AiMutex; -public class EntityAIPanic extends EntityAIBase -{ +public class EntityAIPanic extends EntityAIBase { private EntityCreature theEntityCreature; private float speed; private double randPosX; private double randPosY; private double randPosZ; - public EntityAIPanic(EntityCreature par1EntityCreature, float par2) - { + public EntityAIPanic(EntityCreature par1EntityCreature, float par2) { this.theEntityCreature = par1EntityCreature; this.speed = par2; this.setMutexBits(AiMutex.PASSIVE); @@ -23,18 +21,15 @@ public class EntityAIPanic extends EntityAIBase /** * Returns whether the EntityAIBase should begin execution. */ - public boolean shouldExecute(){ - if (this.theEntityCreature.getAttackTarget() == null && !this.theEntityCreature.isBurning()){ + public boolean shouldExecute() { + if (this.theEntityCreature.getAttackTarget() == null && !this.theEntityCreature.isBurning()) { return false; - } - else - { + } else { Vec3 var1 = RandomPositionGeneratorAlt.findRandomTarget(this.theEntityCreature, 5, 4); - if (var1 == null){ + if (var1 == null) { return false; - } - else{ + } else { this.randPosX = var1.xCoord; this.randPosY = var1.yCoord; this.randPosZ = var1.zCoord; @@ -46,16 +41,16 @@ public class EntityAIPanic extends EntityAIBase /** * Execute a one shot task or start executing a continuous task */ - public void startExecuting(){ + public void startExecuting() { this.theEntityCreature.getNavigator().tryMoveToXYZ(this.randPosX, this.randPosY, this.randPosZ, this.speed); } /** * Returns whether an in-progress EntityAIBase should continue executing */ - public boolean continueExecuting(){ - if(this.theEntityCreature.getAttackTarget() == null) - return false; + public boolean continueExecuting() { + if (this.theEntityCreature.getAttackTarget() == null) + return false; return !this.theEntityCreature.getNavigator().noPath(); } -} \ No newline at end of file +} diff --git a/src/main/java/noppes/npcs/ai/EntityAIPounceTarget.java b/src/main/java/noppes/npcs/ai/EntityAIPounceTarget.java index 18e1c34f2..5dbe5f233 100644 --- a/src/main/java/noppes/npcs/ai/EntityAIPounceTarget.java +++ b/src/main/java/noppes/npcs/ai/EntityAIPounceTarget.java @@ -6,58 +6,58 @@ import net.minecraft.util.MathHelper; import noppes.npcs.entity.EntityNPCInterface; public class EntityAIPounceTarget extends EntityAIBase { - private EntityNPCInterface npc; - private EntityLivingBase leapTarget; - private float leapSpeed = 1.2F; + private EntityNPCInterface npc; + private EntityLivingBase leapTarget; + private float leapSpeed = 1.2F; - public EntityAIPounceTarget(EntityNPCInterface leapingEntity){ + public EntityAIPounceTarget(EntityNPCInterface leapingEntity) { this.npc = leapingEntity; this.setMutexBits(4); } @Override - public boolean shouldExecute(){ - if(!this.npc.onGround) - return false; - + public boolean shouldExecute() { + if (!this.npc.onGround) + return false; + this.leapTarget = this.npc.getAttackTarget(); - - if (this.leapTarget == null || !this.npc.getEntitySenses().canSee(leapTarget)) - return false; - + + if (this.leapTarget == null || !this.npc.getEntitySenses().canSee(leapTarget)) + return false; + return !npc.isInRange(leapTarget, 4) && npc.isInRange(leapTarget, 8) && this.npc.getRNG().nextInt(5) == 0; } @Override - public boolean continueExecuting(){ + public boolean continueExecuting() { return !this.npc.onGround; } @Override - public void startExecuting(){ - double varX = this.leapTarget.posX - this.npc.posX; - double varY = this.leapTarget.boundingBox.minY - this.npc.boundingBox.minY; - double varZ = this.leapTarget.posZ - this.npc.posZ; - float varF = MathHelper.sqrt_double(varX * varX + varZ * varZ); - float angle = this.getAngleForXYZ(varX, varY, varZ, varF); - float yaw = (float)(Math.atan2(varX, varZ) * 180.0D / Math.PI); - this.npc.motionX = (double)(MathHelper.sin(yaw / 180.0F * (float)Math.PI) * MathHelper.cos(angle / 180.0F * (float)Math.PI)); - this.npc.motionZ = (double)(MathHelper.cos(yaw / 180.0F * (float)Math.PI) * MathHelper.cos(angle / 180.0F * (float)Math.PI)); - this.npc.motionY = (double)(MathHelper.sin((angle + 1.0F) / 180.0F * (float)Math.PI)); + public void startExecuting() { + double varX = this.leapTarget.posX - this.npc.posX; + double varY = this.leapTarget.boundingBox.minY - this.npc.boundingBox.minY; + double varZ = this.leapTarget.posZ - this.npc.posZ; + float varF = MathHelper.sqrt_double(varX * varX + varZ * varZ); + float angle = this.getAngleForXYZ(varX, varY, varZ, varF); + float yaw = (float) (Math.atan2(varX, varZ) * 180.0D / Math.PI); + this.npc.motionX = (double) (MathHelper.sin(yaw / 180.0F * (float) Math.PI) * MathHelper.cos(angle / 180.0F * (float) Math.PI)); + this.npc.motionZ = (double) (MathHelper.cos(yaw / 180.0F * (float) Math.PI) * MathHelper.cos(angle / 180.0F * (float) Math.PI)); + this.npc.motionY = (double) (MathHelper.sin((angle + 1.0F) / 180.0F * (float) Math.PI)); this.npc.motionX *= this.leapSpeed; this.npc.motionZ *= this.leapSpeed; this.npc.motionY *= this.leapSpeed; } - + public float getAngleForXYZ(double varX, double varY, double varZ, double horiDist) { - float g = 0.1F; - float var1 = this.leapSpeed * this.leapSpeed; - double var2 = (g * horiDist); - double var3 = ((g * horiDist * horiDist) + (2 * varY * var1)); - double var4 = (var1 * var1) - (g * var3); - if (var4 < 0) return 90.0F; - float var6 = var1 - MathHelper.sqrt_double(var4); - float var7 = (float) (Math.atan2(var6 , var2) * 180.0D / Math.PI); - return var7; + float g = 0.1F; + float var1 = this.leapSpeed * this.leapSpeed; + double var2 = (g * horiDist); + double var3 = ((g * horiDist * horiDist) + (2 * varY * var1)); + double var4 = (var1 * var1) - (g * var3); + if (var4 < 0) return 90.0F; + float var6 = var1 - MathHelper.sqrt_double(var4); + float var7 = (float) (Math.atan2(var6, var2) * 180.0D / Math.PI); + return var7; } -} \ No newline at end of file +} diff --git a/src/main/java/noppes/npcs/ai/EntityAIRangedAttack.java b/src/main/java/noppes/npcs/ai/EntityAIRangedAttack.java index 0595872dd..51f28f709 100644 --- a/src/main/java/noppes/npcs/ai/EntityAIRangedAttack.java +++ b/src/main/java/noppes/npcs/ai/EntityAIRangedAttack.java @@ -9,9 +9,10 @@ import noppes.npcs.constants.EnumAnimation; import noppes.npcs.constants.EnumNavType; import noppes.npcs.entity.EntityNPCInterface; -public class EntityAIRangedAttack extends EntityAIBase -{ - /** The entity the AI instance has been applied to */ +public class EntityAIRangedAttack extends EntityAIBase { + /** + * The entity the AI instance has been applied to + */ private final EntityNPCInterface entityHost; /** @@ -31,16 +32,12 @@ public class EntityAIRangedAttack extends EntityAIBase private boolean hasFired = false; private boolean navOverride = false; - public EntityAIRangedAttack(IRangedAttackMob par1IRangedAttackMob) - { - if (!(par1IRangedAttackMob instanceof EntityLivingBase)) - { + public EntityAIRangedAttack(IRangedAttackMob par1IRangedAttackMob) { + if (!(par1IRangedAttackMob instanceof EntityLivingBase)) { throw new IllegalArgumentException("ArrowAttackGoal requires Mob implements RangedAttackMob"); - } - else - { + } else { this.rangedAttackEntityHost = par1IRangedAttackMob; - this.entityHost = (EntityNPCInterface)par1IRangedAttackMob; + this.entityHost = (EntityNPCInterface) par1IRangedAttackMob; this.rangedAttackTime = this.entityHost.stats.minDelay / 2; this.setMutexBits(this.navOverride ? AiMutex.PATHING : AiMutex.LOOK + AiMutex.PASSIVE); } @@ -49,23 +46,21 @@ public class EntityAIRangedAttack extends EntityAIBase /** * Returns whether the EntityAIBase should begin execution. */ - public boolean shouldExecute() - { - EntityLivingBase var1 = this.entityHost.getAttackTarget(); + public boolean shouldExecute() { + EntityLivingBase var1 = this.entityHost.getAttackTarget(); if (var1 == null || !var1.isEntityAlive()) return false; - if(entityHost.getDistanceToEntity(var1) > entityHost.stats.aggroRange) return false; + if (entityHost.getDistanceToEntity(var1) > entityHost.stats.aggroRange) return false; - if (this.entityHost.inventory.getProjectile() == null) return false; + if (this.entityHost.inventory.getProjectile() == null) return false; double var2 = this.entityHost.getDistanceSq(var1.posX, var1.boundingBox.minY, var1.posZ); double var3 = this.entityHost.ais.distanceToMelee * this.entityHost.ais.distanceToMelee; if (this.entityHost.ais.useRangeMelee >= 1 && var2 <= var3) return false; - else - { + else { this.attackTarget = var1; return true; } @@ -74,16 +69,14 @@ public class EntityAIRangedAttack extends EntityAIBase /** * Returns whether an in-progress EntityAIBase should continue executing */ - public boolean continueExecuting() - { + public boolean continueExecuting() { return this.shouldExecute() || !this.entityHost.getNavigator().noPath(); } /** * Resets the task */ - public void resetTask() - { + public void resetTask() { this.attackTarget = null; this.entityHost.setAttackTarget(null); this.entityHost.getNavigator().clearPathEntity(); @@ -95,77 +88,63 @@ public class EntityAIRangedAttack extends EntityAIBase /** * Updates the task */ - public void updateTask() - { - this.entityHost.getLookHelper().setLookPositionWithEntity(this.attackTarget, 30.0F, 30.0F); + public void updateTask() { + this.entityHost.getLookHelper().setLookPositionWithEntity(this.attackTarget, 30.0F, 30.0F); double var1 = this.entityHost.getDistanceSq(this.attackTarget.posX, this.attackTarget.boundingBox.minY, this.attackTarget.posZ); - float field_82642_h = this.entityHost.stats.rangedRange * this.entityHost.stats.rangedRange; + float field_82642_h = this.entityHost.stats.rangedRange * this.entityHost.stats.rangedRange; - if (!navOverride && this.entityHost.ais.directLOS) - { - if (this.entityHost.getEntitySenses().canSee(this.attackTarget)) - { - ++this.field_75318_f; - } - else - { - this.field_75318_f = 0; - } - int v = this.entityHost.ais.tacticalVariant == EnumNavType.Default ? 20 : 5; - if (var1 <= (double)field_82642_h && this.field_75318_f >= v) - { - this.entityHost.getNavigator().clearPathEntity(); - } - else - { - this.entityHost.getNavigator().tryMoveToEntityLiving(this.attackTarget, 1.0D); - } + if (!navOverride && this.entityHost.ais.directLOS) { + if (this.entityHost.getEntitySenses().canSee(this.attackTarget)) { + ++this.field_75318_f; + } else { + this.field_75318_f = 0; + } + int v = this.entityHost.ais.tacticalVariant == EnumNavType.Default ? 20 : 5; + if (var1 <= (double) field_82642_h && this.field_75318_f >= v) { + this.entityHost.getNavigator().clearPathEntity(); + } else { + this.entityHost.getNavigator().tryMoveToEntityLiving(this.attackTarget, 1.0D); + } } this.rangedAttackTime = Math.max(this.rangedAttackTime - 1, 0); - if (this.rangedAttackTime <= 0) - { - if (var1 <= (double)field_82642_h && (this.entityHost.getEntitySenses().canSee(this.attackTarget) || this.entityHost.ais.canFireIndirect == 2)) - { - if (this.field_70846_g++ <= this.entityHost.stats.burstCount) - { - this.rangedAttackTime = this.entityHost.stats.fireRate; - } - else - { - this.field_70846_g = 0; - this.hasFired = true; - this.rangedAttackTime = (this.entityHost.stats.maxDelay - MathHelper.floor_float(this.entityHost.getRNG().nextFloat() * (this.entityHost.stats.maxDelay - this.entityHost.stats.minDelay))); - } + if (this.rangedAttackTime <= 0) { + if (var1 <= (double) field_82642_h && (this.entityHost.getEntitySenses().canSee(this.attackTarget) || this.entityHost.ais.canFireIndirect == 2)) { + if (this.field_70846_g++ <= this.entityHost.stats.burstCount) { + this.rangedAttackTime = this.entityHost.stats.fireRate; + } else { + this.field_70846_g = 0; + this.hasFired = true; + this.rangedAttackTime = (this.entityHost.stats.maxDelay - MathHelper.floor_float(this.entityHost.getRNG().nextFloat() * (this.entityHost.stats.maxDelay - this.entityHost.stats.minDelay))); + } - if (this.field_70846_g > 1) - { - boolean indirect = false; + if (this.field_70846_g > 1) { + boolean indirect = false; - switch(this.entityHost.ais.canFireIndirect) - { - case 1 : indirect = var1 > (double)field_82642_h / 2; break; - case 2 : indirect = !this.entityHost.getEntitySenses().canSee(this.attackTarget); - } + switch (this.entityHost.ais.canFireIndirect) { + case 1: + indirect = var1 > (double) field_82642_h / 2; + break; + case 2: + indirect = !this.entityHost.getEntitySenses().canSee(this.attackTarget); + } - this.rangedAttackEntityHost.attackEntityWithRangedAttack(this.attackTarget, indirect ? 1 : 0); - if (this.entityHost.currentAnimation != EnumAnimation.AIMING) - { - this.entityHost.swingItem(); - } - } + this.rangedAttackEntityHost.attackEntityWithRangedAttack(this.attackTarget, indirect ? 1 : 0); + if (this.entityHost.currentAnimation != EnumAnimation.AIMING) { + this.entityHost.swingItem(); + } + } } } } - public boolean hasFired() - { - return this.hasFired; + public boolean hasFired() { + return this.hasFired; } - public void navOverride(boolean nav){ - this.navOverride = nav; + public void navOverride(boolean nav) { + this.navOverride = nav; this.setMutexBits(this.navOverride ? AiMutex.PATHING : AiMutex.LOOK + AiMutex.PASSIVE); } } diff --git a/src/main/java/noppes/npcs/ai/EntityAIReturn.java b/src/main/java/noppes/npcs/ai/EntityAIReturn.java index 936c2eb4c..748625edb 100644 --- a/src/main/java/noppes/npcs/ai/EntityAIReturn.java +++ b/src/main/java/noppes/npcs/ai/EntityAIReturn.java @@ -6,9 +6,8 @@ import noppes.npcs.config.ConfigMain; import noppes.npcs.constants.EnumMovingType; import noppes.npcs.entity.EntityNPCInterface; -public class EntityAIReturn extends EntityAIBase -{ - public static final int MaxTotalTicks = 600; +public class EntityAIReturn extends EntityAIBase { + public static final int MaxTotalTicks = 600; private final EntityNPCInterface npc; private int stuckTicks = 0; private int totalTicks = 0; @@ -19,8 +18,7 @@ public class EntityAIReturn extends EntityAIBase private double[] preAttackPos; private int stuckCount = 0; - public EntityAIReturn(EntityNPCInterface npc) - { + public EntityAIReturn(EntityNPCInterface npc) { this.npc = npc; this.setMutexBits(1); } @@ -29,131 +27,128 @@ public class EntityAIReturn extends EntityAIBase * Returns whether the EntityAIBase should begin execution. */ public boolean shouldExecute() { - if (!npc.ais.returnToStart){ - return false; - } + if (!npc.ais.returnToStart) { + return false; + } - if(npc.hasOwner() || npc.isKilled() || npc.isInteracting()){ - return false; - } + if (npc.hasOwner() || npc.isKilled() || npc.isInteracting()) { + return false; + } - if (npc.ais.findShelter == 0 && (!npc.worldObj.isDaytime() || npc.worldObj.isRaining()) && !npc.worldObj.provider.hasNoSky){ - if (npc.worldObj.canBlockSeeTheSky((int)npc.getStartXPos(), (int)npc.getStartYPos(), (int)npc.getStartZPos()) || npc.worldObj.getFullBlockLightValue((int)npc.getStartXPos(), (int)npc.getStartYPos(), (int)npc.getStartZPos()) <= 8){ + if (npc.ais.findShelter == 0 && (!npc.worldObj.isDaytime() || npc.worldObj.isRaining()) && !npc.worldObj.provider.hasNoSky) { + if (npc.worldObj.canBlockSeeTheSky((int) npc.getStartXPos(), (int) npc.getStartYPos(), (int) npc.getStartZPos()) || npc.worldObj.getFullBlockLightValue((int) npc.getStartXPos(), (int) npc.getStartYPos(), (int) npc.getStartZPos()) <= 8) { + return false; + } + } else if (npc.ais.findShelter == 1 && npc.worldObj.isDaytime()) { + if (npc.worldObj.canBlockSeeTheSky((int) npc.getStartXPos(), (int) npc.getStartYPos(), (int) npc.getStartZPos())) { return false; } } - else if (npc.ais.findShelter == 1 && npc.worldObj.isDaytime()){ - if (npc.worldObj.canBlockSeeTheSky((int)npc.getStartXPos(), (int)npc.getStartYPos(), (int)npc.getStartZPos())){ - return false; + + if (npc.isAttacking()) { + if (!wasAttacked) { + wasAttacked = true; + preAttackPos = new double[]{npc.posX, npc.posY, npc.posZ}; } - } + return false; + } - if(npc.isAttacking()){ - if(!wasAttacked){ - wasAttacked = true; - preAttackPos = new double[]{npc.posX, npc.posY, npc.posZ}; - } - return false; - } + if (npc.ais.movingType == EnumMovingType.MovingPath && npc.ais.getDistanceSqToPathPoint() < ConfigMain.NpcNavRange * ConfigMain.NpcNavRange) + return false; - if(npc.ais.movingType == EnumMovingType.MovingPath && npc.ais.getDistanceSqToPathPoint() < ConfigMain.NpcNavRange * ConfigMain.NpcNavRange) - return false; + if (npc.getNavigator().noPath() || (!npc.isAttacking() && wasAttacked)) { + return true; + } - if (npc.getNavigator().noPath() || (!npc.isAttacking() && wasAttacked)) { - return true; - } + if (npc.ais.movingType == EnumMovingType.Wandering) + return this.npc.getDistanceSq(npc.getStartXPos(), npc.getStartYPos(), npc.getStartZPos()) > npc.ais.walkingRange * npc.ais.walkingRange; - if(npc.ais.movingType == EnumMovingType.Wandering) - return this.npc.getDistanceSq(npc.getStartXPos(), npc.getStartYPos(), npc.getStartZPos()) > npc.ais.walkingRange * npc.ais.walkingRange; - - if(npc.ais.movingType == EnumMovingType.Standing) - return !this.npc.isVeryNearAssignedPlace(); + if (npc.ais.movingType == EnumMovingType.Standing) + return !this.npc.isVeryNearAssignedPlace(); return false; } - public boolean continueExecuting(){ + + public boolean continueExecuting() { return !npc.isFollower() && !npc.isKilled() && !npc.isAttacking() && !npc.isVeryNearAssignedPlace() && totalTicks <= MaxTotalTicks && !npc.isInteracting(); } - public void updateTask(){ - totalTicks++; - if(totalTicks > MaxTotalTicks){ - npc.setPosition(endPosX, endPosY, endPosZ); - npc.getNavigator().clearPathEntity(); - return; - } + public void updateTask() { + totalTicks++; + if (totalTicks > MaxTotalTicks) { + npc.setPosition(endPosX, endPosY, endPosZ); + npc.getNavigator().clearPathEntity(); + return; + } - if(stuckTicks > 0){ - stuckTicks--; - } - else if(npc.getNavigator().noPath()){ - stuckCount++; - stuckTicks = 10; - if(totalTicks > 30 && wasAttacked && isTooFar() || stuckCount > 5 ){ - npc.setPosition(endPosX, endPosY, endPosZ); - npc.getNavigator().clearPathEntity(); - } - else - navigate(stuckCount % 2 == 1); - } - else{ - stuckCount = 0; - } - } - private boolean isTooFar(){ - int allowedDistance = npc.stats.aggroRange * 2; - if(npc.ais.movingType == EnumMovingType.Wandering) - allowedDistance += npc.ais.walkingRange; - return npc.getDistanceSq(endPosX, endPosY, endPosZ) > allowedDistance * allowedDistance; + if (stuckTicks > 0) { + stuckTicks--; + } else if (npc.getNavigator().noPath()) { + stuckCount++; + stuckTicks = 10; + if (totalTicks > 30 && wasAttacked && isTooFar() || stuckCount > 5) { + npc.setPosition(endPosX, endPosY, endPosZ); + npc.getNavigator().clearPathEntity(); + } else + navigate(stuckCount % 2 == 1); + } else { + stuckCount = 0; + } } - public void startExecuting() - { - stuckTicks = 0; - totalTicks = 0; - stuckCount = 0; - navigate(false); + private boolean isTooFar() { + int allowedDistance = npc.stats.aggroRange * 2; + if (npc.ais.movingType == EnumMovingType.Wandering) + allowedDistance += npc.ais.walkingRange; + return npc.getDistanceSq(endPosX, endPosY, endPosZ) > allowedDistance * allowedDistance; } + + public void startExecuting() { + stuckTicks = 0; + totalTicks = 0; + stuckCount = 0; + navigate(false); + } + private void navigate(boolean towards) { - if(!wasAttacked){ - endPosX = npc.getStartXPos(); - endPosY = npc.getStartYPos(); - endPosZ = npc.getStartZPos(); - } - else{ - endPosX = preAttackPos[0]; - endPosY = preAttackPos[1]; - endPosZ = preAttackPos[2]; - } - double posX = endPosX; - double posY = endPosY; - double posZ = endPosZ; - double range = npc.getDistance(posX, posY, posZ); - if(range > ConfigMain.NpcNavRange || towards){ - int distance = (int) range; - if(distance > ConfigMain.NpcNavRange) - distance = ConfigMain.NpcNavRange / 2; - else - distance /= 2; - if(distance > 2){ - Vec3 start = Vec3.createVectorHelper(posX, posY, posZ); - Vec3 pos = RandomPositionGeneratorAlt.findRandomTargetBlockTowards(npc, distance, Math.min(distance / 2, 7), start); - if(pos != null){ - posX = pos.xCoord; - posY = pos.yCoord; - posZ = pos.zCoord; - } - } - } + if (!wasAttacked) { + endPosX = npc.getStartXPos(); + endPosY = npc.getStartYPos(); + endPosZ = npc.getStartZPos(); + } else { + endPosX = preAttackPos[0]; + endPosY = preAttackPos[1]; + endPosZ = preAttackPos[2]; + } + double posX = endPosX; + double posY = endPosY; + double posZ = endPosZ; + double range = npc.getDistance(posX, posY, posZ); + if (range > ConfigMain.NpcNavRange || towards) { + int distance = (int) range; + if (distance > ConfigMain.NpcNavRange) + distance = ConfigMain.NpcNavRange / 2; + else + distance /= 2; + if (distance > 2) { + Vec3 start = Vec3.createVectorHelper(posX, posY, posZ); + Vec3 pos = RandomPositionGeneratorAlt.findRandomTargetBlockTowards(npc, distance, Math.min(distance / 2, 7), start); + if (pos != null) { + posX = pos.xCoord; + posY = pos.yCoord; + posZ = pos.zCoord; + } + } + } - if (range > 1.1f) { - npc.getNavigator().clearPathEntity(); - npc.getNavigator().tryMoveToXYZ(posX, posY, posZ, 1); - } - } + if (range > 1.1f) { + npc.getNavigator().clearPathEntity(); + npc.getNavigator().tryMoveToXYZ(posX, posY, posZ, 1); + } + } - public void resetTask(){ - wasAttacked = false; + public void resetTask() { + wasAttacked = false; this.npc.getNavigator().clearPathEntity(); } } diff --git a/src/main/java/noppes/npcs/ai/EntityAIRole.java b/src/main/java/noppes/npcs/ai/EntityAIRole.java index 8758580e5..cfff7ff32 100644 --- a/src/main/java/noppes/npcs/ai/EntityAIRole.java +++ b/src/main/java/noppes/npcs/ai/EntityAIRole.java @@ -5,33 +5,32 @@ import noppes.npcs.entity.EntityNPCInterface; public class EntityAIRole extends EntityAIBase { - private EntityNPCInterface npc; - public EntityAIRole(EntityNPCInterface npc){ - this.npc = npc; - } - - @Override - public boolean shouldExecute() { - if(npc.isKilled() || npc.roleInterface == null) - return false; - return npc.roleInterface.aiShouldExecute(); - } - - public void startExecuting() - { - npc.roleInterface.aiStartExecuting(); + private EntityNPCInterface npc; + + public EntityAIRole(EntityNPCInterface npc) { + this.npc = npc; } - - @Override - public boolean continueExecuting() - { - if(npc.isKilled() || npc.roleInterface == null) - return false; - return npc.roleInterface.aiContinueExecute(); + + @Override + public boolean shouldExecute() { + if (npc.isKilled() || npc.roleInterface == null) + return false; + return npc.roleInterface.aiShouldExecute(); } - - public void updateTask(){ - if(npc.roleInterface != null) - npc.roleInterface.aiUpdateTask(); + + public void startExecuting() { + npc.roleInterface.aiStartExecuting(); + } + + @Override + public boolean continueExecuting() { + if (npc.isKilled() || npc.roleInterface == null) + return false; + return npc.roleInterface.aiContinueExecute(); + } + + public void updateTask() { + if (npc.roleInterface != null) + npc.roleInterface.aiUpdateTask(); } } diff --git a/src/main/java/noppes/npcs/ai/EntityAISprintToTarget.java b/src/main/java/noppes/npcs/ai/EntityAISprintToTarget.java index 08a7b3337..0d8d100c2 100644 --- a/src/main/java/noppes/npcs/ai/EntityAISprintToTarget.java +++ b/src/main/java/noppes/npcs/ai/EntityAISprintToTarget.java @@ -5,27 +5,29 @@ import net.minecraft.entity.ai.EntityAIBase; import noppes.npcs.constants.AiMutex; import noppes.npcs.entity.EntityNPCInterface; -public class EntityAISprintToTarget extends EntityAIBase -{ +public class EntityAISprintToTarget extends EntityAIBase { private EntityNPCInterface npc; - public EntityAISprintToTarget(EntityNPCInterface par1EntityLiving){ + public EntityAISprintToTarget(EntityNPCInterface par1EntityLiving) { this.npc = par1EntityLiving; this.setMutexBits(AiMutex.PASSIVE); } @Override - public boolean shouldExecute(){ + public boolean shouldExecute() { EntityLivingBase runTarget = this.npc.getAttackTarget(); - if (runTarget == null || this.npc.getNavigator().noPath()){ + if (runTarget == null || this.npc.getNavigator().noPath()) { return false; } - switch(this.npc.ais.onAttack){ - case 0 : return !this.npc.isInRange(runTarget, 8)? (!this.npc.onGround ? false : true) : false; - case 2 : return this.npc.isInRange(runTarget, 7)? (!this.npc.onGround ? false : true) : false; - default : return false; + switch (this.npc.ais.onAttack) { + case 0: + return !this.npc.isInRange(runTarget, 8) ? (!this.npc.onGround ? false : true) : false; + case 2: + return this.npc.isInRange(runTarget, 7) ? (!this.npc.onGround ? false : true) : false; + default: + return false; } } @@ -33,8 +35,7 @@ public class EntityAISprintToTarget extends EntityAIBase /** * Returns whether an in-progress EntityAIBase should continue executing */ - public boolean continueExecuting() - { + public boolean continueExecuting() { return this.npc.isEntityAlive() && this.npc.onGround && this.npc.hurtTime <= 0 && (this.npc.motionX != 0.0D && this.npc.motionZ != 0.0D); } @@ -42,7 +43,7 @@ public class EntityAISprintToTarget extends EntityAIBase * Execute a one shot task or start executing a continuous task */ @Override - public void startExecuting(){ + public void startExecuting() { this.npc.setSprinting(true); } @@ -50,7 +51,7 @@ public class EntityAISprintToTarget extends EntityAIBase * Resets the task */ @Override - public void resetTask(){ + public void resetTask() { this.npc.setSprinting(false); } } diff --git a/src/main/java/noppes/npcs/ai/EntityAIStalkTarget.java b/src/main/java/noppes/npcs/ai/EntityAIStalkTarget.java index 4c7e02ac4..1b64a12b7 100644 --- a/src/main/java/noppes/npcs/ai/EntityAIStalkTarget.java +++ b/src/main/java/noppes/npcs/ai/EntityAIStalkTarget.java @@ -9,9 +9,8 @@ import net.minecraft.world.World; import noppes.npcs.constants.AiMutex; import noppes.npcs.entity.EntityNPCInterface; -public class EntityAIStalkTarget extends EntityAIBase -{ - private EntityNPCInterface theEntity; +public class EntityAIStalkTarget extends EntityAIBase { + private EntityNPCInterface theEntity; private EntityLivingBase targetEntity; private Vec3 movePosition; private double distance; @@ -20,8 +19,7 @@ public class EntityAIStalkTarget extends EntityAIBase private int delay; private int tick = 0; - public EntityAIStalkTarget(EntityNPCInterface par1EntityCreature, double par2) - { + public EntityAIStalkTarget(EntityNPCInterface par1EntityCreature, double par2) { this.theEntity = par1EntityCreature; this.theWorld = par1EntityCreature.worldObj; this.distance = par2 * par2; @@ -33,176 +31,140 @@ public class EntityAIStalkTarget extends EntityAIBase /** * Returns whether the EntityAIBase should begin execution. */ - public boolean shouldExecute() - { - this.targetEntity = this.theEntity.getAttackTarget(); + public boolean shouldExecute() { + this.targetEntity = this.theEntity.getAttackTarget(); - if (this.targetEntity == null) - { + if (this.targetEntity == null) { return false; - } - else if (this.tick > 0) - { - this.tick--; - return false; - } - else - { - return this.targetEntity.getDistanceSqToEntity(this.theEntity) > this.distance; + } else if (this.tick > 0) { + this.tick--; + return false; + } else { + return this.targetEntity.getDistanceSqToEntity(this.theEntity) > this.distance; } } - + /** * Resets the task */ - public void resetTask() - { + public void resetTask() { this.theEntity.getNavigator().clearPathEntity(); - if (this.theEntity.getAttackTarget() == null && this.targetEntity != null) - { - this.theEntity.setAttackTarget(targetEntity); + if (this.theEntity.getAttackTarget() == null && this.targetEntity != null) { + this.theEntity.setAttackTarget(targetEntity); } - - if (this.theEntity.getRangedTask() != null) - { - this.theEntity.getRangedTask().navOverride(false); + + if (this.theEntity.getRangedTask() != null) { + this.theEntity.getRangedTask().navOverride(false); } } - - public void startExecuting() - { - if (this.theEntity.getRangedTask() != null) - { - this.theEntity.getRangedTask().navOverride(true); + + public void startExecuting() { + if (this.theEntity.getRangedTask() != null) { + this.theEntity.getRangedTask().navOverride(true); } } - + /** * Updates the task */ - public void updateTask() - { - this.theEntity.getLookHelper().setLookPositionWithEntity(targetEntity, 30.0F, 30.0F); - - if (this.theEntity.getNavigator().noPath() || this.overRide) - { - if (this.isLookingAway()) - { - this.movePosition = this.stalkTarget(); - if (this.movePosition != null) - { - this.theEntity.getNavigator().tryMoveToXYZ(this.movePosition.xCoord, this.movePosition.yCoord, this.movePosition.zCoord, 1.0D); - this.overRide = false; - } - else - { - this.tick = 100; - } - - } - else if (this.theEntity.canSee(targetEntity)) - { - this.movePosition = this.hideFromTarget(); - if (this.movePosition != null) - { - this.theEntity.getNavigator().tryMoveToXYZ(this.movePosition.xCoord, this.movePosition.yCoord, this.movePosition.zCoord, 1.33D); - this.overRide = false; - } - else - { - this.tick = 100; - } - } - } - - if (this.delay > 0) this.delay--; - - if (!this.isLookingAway() && this.theEntity.canSee(targetEntity) && this.delay == 0) - { - this.overRide = true; - this.delay = 60; - } - + public void updateTask() { + this.theEntity.getLookHelper().setLookPositionWithEntity(targetEntity, 30.0F, 30.0F); + + if (this.theEntity.getNavigator().noPath() || this.overRide) { + if (this.isLookingAway()) { + this.movePosition = this.stalkTarget(); + if (this.movePosition != null) { + this.theEntity.getNavigator().tryMoveToXYZ(this.movePosition.xCoord, this.movePosition.yCoord, this.movePosition.zCoord, 1.0D); + this.overRide = false; + } else { + this.tick = 100; + } + + } else if (this.theEntity.canSee(targetEntity)) { + this.movePosition = this.hideFromTarget(); + if (this.movePosition != null) { + this.theEntity.getNavigator().tryMoveToXYZ(this.movePosition.xCoord, this.movePosition.yCoord, this.movePosition.zCoord, 1.33D); + this.overRide = false; + } else { + this.tick = 100; + } + } + } + + if (this.delay > 0) this.delay--; + + if (!this.isLookingAway() && this.theEntity.canSee(targetEntity) && this.delay == 0) { + this.overRide = true; + this.delay = 60; + } + } - private Vec3 hideFromTarget() - { - Vec3 vec; - for (int i = 1; i <= 8; i++) - { - vec = findSecludedXYZ(i, false); - if (vec != null) { - return vec; - } - } - return null; + private Vec3 hideFromTarget() { + Vec3 vec; + for (int i = 1; i <= 8; i++) { + vec = findSecludedXYZ(i, false); + if (vec != null) { + return vec; + } + } + return null; } - - private Vec3 stalkTarget() - { - Vec3 vec; - for (int i = 8; i >= 1; i--) - { - vec = findSecludedXYZ(i, true); - if (vec != null) { - return vec; - } - } - return null; - } - - private Vec3 findSecludedXYZ(int radius, boolean nearest) - { - Vec3 idealPos = null; - boolean weight; - double dist = this.targetEntity.getDistanceSqToEntity(this.theEntity); - double u = 0, v = 0, w = 0; - - if (this.movePosition != null) - { - u = this.movePosition.xCoord; - v = this.movePosition.yCoord; - w = this.movePosition.zCoord; - } - for (int y = -2; y <= 2; y++) - { - for (int x = -radius; x <= radius; x++) - { - for (int z = -radius; z <= radius; z++) - { - double j = MathHelper.floor_double(this.theEntity.posX + x) + 0.5D; - double k = MathHelper.floor_double(this.theEntity.boundingBox.minY + y); - double l = MathHelper.floor_double(this.theEntity.posZ + z) + 0.5D; - - if (this.theWorld.getBlock((int)j, (int)k, (int)l).isOpaqueCube() && !this.theWorld.getBlock((int)j, (int)k + 1, (int)l).isOpaqueCube() && !this.theWorld.getBlock((int)j, (int)k + 2, (int)l).isOpaqueCube()) - { - Vec3 vec1 = Vec3.createVectorHelper(this.targetEntity.posX, this.targetEntity.posY + (double)this.targetEntity.getEyeHeight(), this.targetEntity.posZ); - Vec3 vec2 = Vec3.createVectorHelper(j, k + (double)this.theEntity.getEyeHeight(), l); - MovingObjectPosition movingobjectposition = this.theWorld.rayTraceBlocks(vec1, vec2); - if (movingobjectposition != null) - { - weight = nearest ? this.targetEntity.getDistanceSq(j, k, l) <= dist : true; - if (weight && (j != u || k != v || l != w)) - { - idealPos = Vec3.createVectorHelper(j, k, l); - if (nearest) dist = this.targetEntity.getDistanceSq(j, k, l); - } - } - } - } - } - } - return idealPos; + private Vec3 stalkTarget() { + Vec3 vec; + for (int i = 8; i >= 1; i--) { + vec = findSecludedXYZ(i, true); + if (vec != null) { + return vec; + } + } + return null; } - - private boolean isLookingAway() - { - Vec3 vec3 = this.targetEntity.getLook(1.0F).normalize(); - Vec3 vec31 = Vec3.createVectorHelper(this.theEntity.posX - this.targetEntity.posX, this.theEntity.boundingBox.minY + (double)(this.theEntity.height / 2.0F) - (this.targetEntity.posY + (double)this.targetEntity.getEyeHeight()), this.theEntity.posZ - this.targetEntity.posZ); + + private Vec3 findSecludedXYZ(int radius, boolean nearest) { + Vec3 idealPos = null; + boolean weight; + double dist = this.targetEntity.getDistanceSqToEntity(this.theEntity); + double u = 0, v = 0, w = 0; + + if (this.movePosition != null) { + u = this.movePosition.xCoord; + v = this.movePosition.yCoord; + w = this.movePosition.zCoord; + } + + for (int y = -2; y <= 2; y++) { + for (int x = -radius; x <= radius; x++) { + for (int z = -radius; z <= radius; z++) { + double j = MathHelper.floor_double(this.theEntity.posX + x) + 0.5D; + double k = MathHelper.floor_double(this.theEntity.boundingBox.minY + y); + double l = MathHelper.floor_double(this.theEntity.posZ + z) + 0.5D; + + if (this.theWorld.getBlock((int) j, (int) k, (int) l).isOpaqueCube() && !this.theWorld.getBlock((int) j, (int) k + 1, (int) l).isOpaqueCube() && !this.theWorld.getBlock((int) j, (int) k + 2, (int) l).isOpaqueCube()) { + Vec3 vec1 = Vec3.createVectorHelper(this.targetEntity.posX, this.targetEntity.posY + (double) this.targetEntity.getEyeHeight(), this.targetEntity.posZ); + Vec3 vec2 = Vec3.createVectorHelper(j, k + (double) this.theEntity.getEyeHeight(), l); + MovingObjectPosition movingobjectposition = this.theWorld.rayTraceBlocks(vec1, vec2); + if (movingobjectposition != null) { + weight = nearest ? this.targetEntity.getDistanceSq(j, k, l) <= dist : true; + if (weight && (j != u || k != v || l != w)) { + idealPos = Vec3.createVectorHelper(j, k, l); + if (nearest) dist = this.targetEntity.getDistanceSq(j, k, l); + } + } + } + } + } + } + return idealPos; + } + + private boolean isLookingAway() { + Vec3 vec3 = this.targetEntity.getLook(1.0F).normalize(); + Vec3 vec31 = Vec3.createVectorHelper(this.theEntity.posX - this.targetEntity.posX, this.theEntity.boundingBox.minY + (double) (this.theEntity.height / 2.0F) - (this.targetEntity.posY + (double) this.targetEntity.getEyeHeight()), this.theEntity.posZ - this.targetEntity.posZ); double d0 = vec31.lengthVector(); vec31 = vec31.normalize(); double d1 = vec3.dotProduct(vec31); return d1 < 0.6; } -} \ No newline at end of file +} diff --git a/src/main/java/noppes/npcs/ai/EntityAITransform.java b/src/main/java/noppes/npcs/ai/EntityAITransform.java index 10c2217cf..9f565bccc 100644 --- a/src/main/java/noppes/npcs/ai/EntityAITransform.java +++ b/src/main/java/noppes/npcs/ai/EntityAITransform.java @@ -6,21 +6,22 @@ import noppes.npcs.entity.EntityNPCInterface; public class EntityAITransform extends EntityAIBase { - private EntityNPCInterface npc; - public EntityAITransform(EntityNPCInterface npc){ - this.npc = npc; - setMutexBits(AiMutex.PASSIVE); - } - - @Override - public boolean shouldExecute() { - if(npc.isKilled() || npc.isAttacking() || npc.transform.editingModus) - return false; + private EntityNPCInterface npc; - return npc.worldObj.getWorldTime() % 24000 < 12000?npc.transform.isActive:!npc.transform.isActive; - } - - public void startExecuting(){ - npc.transform.transform(!npc.transform.isActive); + public EntityAITransform(EntityNPCInterface npc) { + this.npc = npc; + setMutexBits(AiMutex.PASSIVE); + } + + @Override + public boolean shouldExecute() { + if (npc.isKilled() || npc.isAttacking() || npc.transform.editingModus) + return false; + + return npc.worldObj.getWorldTime() % 24000 < 12000 ? npc.transform.isActive : !npc.transform.isActive; + } + + public void startExecuting() { + npc.transform.transform(!npc.transform.isActive); } } diff --git a/src/main/java/noppes/npcs/ai/EntityAIWander.java b/src/main/java/noppes/npcs/ai/EntityAIWander.java index 82e0aef0d..0092338c7 100644 --- a/src/main/java/noppes/npcs/ai/EntityAIWander.java +++ b/src/main/java/noppes/npcs/ai/EntityAIWander.java @@ -13,8 +13,7 @@ import noppes.npcs.entity.EntityNPCInterface; import java.util.Iterator; import java.util.List; -public class EntityAIWander extends EntityAIBase -{ +public class EntityAIWander extends EntityAIBase { private EntityNPCInterface entity; public final IEntitySelector selector; private double xPosition; @@ -22,36 +21,34 @@ public class EntityAIWander extends EntityAIBase private double zPosition; private EntityNPCInterface nearbyNPC; - public EntityAIWander(EntityNPCInterface npc){ + public EntityAIWander(EntityNPCInterface npc) { this.entity = npc; this.setMutexBits(AiMutex.PASSIVE); selector = new NPCInteractSelector(npc); } @Override - public boolean shouldExecute(){ - if (this.entity.getAge() >= 100 || !entity.getNavigator().noPath() || entity.isInteracting() || this.entity.getRNG().nextInt(80) != 0){ + public boolean shouldExecute() { + if (this.entity.getAge() >= 100 || !entity.getNavigator().noPath() || entity.isInteracting() || this.entity.getRNG().nextInt(80) != 0) { return false; } - if(entity.ais.npcInteracting && entity.getRNG().nextInt(4) == 1) - nearbyNPC = getNearbyNPC(); + if (entity.ais.npcInteracting && entity.getRNG().nextInt(4) == 1) + nearbyNPC = getNearbyNPC(); - if(nearbyNPC != null){ + if (nearbyNPC != null) { this.xPosition = MathHelper.floor_double(nearbyNPC.posX); this.yPosition = MathHelper.floor_double(nearbyNPC.posY); this.zPosition = MathHelper.floor_double(nearbyNPC.posZ); - nearbyNPC.addInteract(entity); - } - else{ - Vec3 vec = getVec(); - if (vec == null){ + nearbyNPC.addInteract(entity); + } else { + Vec3 vec = getVec(); + if (vec == null) { return false; - } - else{ + } else { this.xPosition = vec.xCoord; this.yPosition = vec.yCoord; - if(entity.canFly()) + if (entity.canFly()) this.yPosition = entity.getStartYPos() + entity.getRNG().nextFloat() * 0.75 * entity.ais.walkingRange; this.zPosition = vec.zCoord; } @@ -61,70 +58,70 @@ public class EntityAIWander extends EntityAIBase @Override public void updateTask() { - if(nearbyNPC != null){ - nearbyNPC.getNavigator().clearPathEntity(); - } + if (nearbyNPC != null) { + nearbyNPC.getNavigator().clearPathEntity(); + } } + private EntityNPCInterface getNearbyNPC() { - List list = entity.worldObj.getEntitiesWithinAABBExcludingEntity(entity, entity.boundingBox.expand(entity.ais.walkingRange, entity.ais.walkingRange > 7?7:entity.ais.walkingRange, entity.ais.walkingRange), selector); - Iterator ita = list.iterator(); - while(ita.hasNext()){ - EntityNPCInterface npc = ita.next(); - if(!npc.ais.stopAndInteract || npc.isAttacking() || !npc.isEntityAlive() || entity.faction.isAggressiveToNpc(npc)) - ita.remove(); - } + List list = entity.worldObj.getEntitiesWithinAABBExcludingEntity(entity, entity.boundingBox.expand(entity.ais.walkingRange, entity.ais.walkingRange > 7 ? 7 : entity.ais.walkingRange, entity.ais.walkingRange), selector); + Iterator ita = list.iterator(); + while (ita.hasNext()) { + EntityNPCInterface npc = ita.next(); + if (!npc.ais.stopAndInteract || npc.isAttacking() || !npc.isEntityAlive() || entity.faction.isAggressiveToNpc(npc)) + ita.remove(); + } - if(list.isEmpty()) - return null; + if (list.isEmpty()) + return null; - return list.get(entity.getRNG().nextInt(list.size())); - } + return list.get(entity.getRNG().nextInt(list.size())); + } - private Vec3 getVec(){ - if(entity.ais.walkingRange > 0){ + private Vec3 getVec() { + if (entity.ais.walkingRange > 0) { double distance = this.entity.getDistanceSq(this.entity.getStartXPos(), this.entity.getStartYPos(), this.entity.getStartZPos()); int range = (int) MathHelper.sqrt_double(this.entity.ais.walkingRange * this.entity.ais.walkingRange - distance); - if(range > ConfigMain.NpcNavRange) - range = ConfigMain.NpcNavRange; - if(range < 3){ + if (range > ConfigMain.NpcNavRange) + range = ConfigMain.NpcNavRange; + if (range < 3) { range = this.entity.ais.walkingRange; - if(range > ConfigMain.NpcNavRange) - range = ConfigMain.NpcNavRange; + if (range > ConfigMain.NpcNavRange) + range = ConfigMain.NpcNavRange; Vec3 start = Vec3.createVectorHelper(this.entity.getStartXPos(), this.entity.getStartYPos(), this.entity.getStartZPos()); - return RandomPositionGeneratorAlt.findRandomTargetBlockTowards(this.entity, range / 2, range / 2 > 7?7:range / 2, start); + return RandomPositionGeneratorAlt.findRandomTargetBlockTowards(this.entity, range / 2, range / 2 > 7 ? 7 : range / 2, start); + } else { + return RandomPositionGeneratorAlt.findRandomTarget(this.entity, range, range / 2 > 7 ? 7 : range / 2); } - else{ - return RandomPositionGeneratorAlt.findRandomTarget(this.entity, range, range / 2 > 7?7:range / 2); - } - } - return RandomPositionGeneratorAlt.findRandomTarget(this.entity, ConfigMain.NpcNavRange, 7); + } + return RandomPositionGeneratorAlt.findRandomTarget(this.entity, ConfigMain.NpcNavRange, 7); } @Override - public boolean continueExecuting(){ - if(nearbyNPC != null && (!selector.isEntityApplicable(nearbyNPC) || entity.getDistanceSqToEntity(nearbyNPC) < entity.width * 1.5)) - return false; + public boolean continueExecuting() { + if (nearbyNPC != null && (!selector.isEntityApplicable(nearbyNPC) || entity.getDistanceSqToEntity(nearbyNPC) < entity.width * 1.5)) + return false; return !this.entity.getNavigator().noPath() && this.entity.isEntityAlive() && !entity.isInteracting(); } @Override - public void startExecuting(){ + public void startExecuting() { this.entity.getNavigator().tryMoveToXYZ(this.xPosition, this.yPosition, this.zPosition, 1); } @Override public void resetTask() { - if(nearbyNPC != null && entity.getDistanceSqToEntity(nearbyNPC) < 12){ - Line line = new Line("........."); - line.hideText = true; - if(entity.getRNG().nextBoolean()) - entity.saySurrounding(line); - else - nearbyNPC.saySurrounding(line); + if (nearbyNPC != null && entity.getDistanceSqToEntity(nearbyNPC) < 12) { + Line line = new Line("........."); + line.hideText = true; + if (entity.getRNG().nextBoolean()) + entity.saySurrounding(line); + else + nearbyNPC.saySurrounding(line); - entity.addInteract(nearbyNPC); - nearbyNPC.addInteract(entity); - } - nearbyNPC = null; + entity.addInteract(nearbyNPC); + nearbyNPC.addInteract(entity); + } + nearbyNPC = null; } } diff --git a/src/main/java/noppes/npcs/ai/EntityAIWatchClosest.java b/src/main/java/noppes/npcs/ai/EntityAIWatchClosest.java index ae83cd1fc..d30ae3183 100644 --- a/src/main/java/noppes/npcs/ai/EntityAIWatchClosest.java +++ b/src/main/java/noppes/npcs/ai/EntityAIWatchClosest.java @@ -6,18 +6,19 @@ import net.minecraft.entity.player.EntityPlayer; import noppes.npcs.constants.AiMutex; import noppes.npcs.entity.EntityNPCInterface; -public class EntityAIWatchClosest extends EntityAIBase -{ +public class EntityAIWatchClosest extends EntityAIBase { private EntityNPCInterface theWatcher; - /** The closest entity which is being watched by this one. */ + /** + * The closest entity which is being watched by this one. + */ protected Entity closestEntity; private float field_75333_c; private int lookTime; private float field_75331_e; private Class watchedClass; - public EntityAIWatchClosest(EntityNPCInterface par1EntityLiving, Class par2Class, float par3){ + public EntityAIWatchClosest(EntityNPCInterface par1EntityLiving, Class par2Class, float par3) { this.theWatcher = par1EntityLiving; this.watchedClass = par2Class; this.field_75333_c = par3; @@ -29,26 +30,20 @@ public class EntityAIWatchClosest extends EntityAIBase * Returns whether the EntityAIBase should begin execution. */ @Override - public boolean shouldExecute(){ - if (this.theWatcher.getRNG().nextFloat() >= this.field_75331_e || theWatcher.isInteracting()){ + public boolean shouldExecute() { + if (this.theWatcher.getRNG().nextFloat() >= this.field_75331_e || theWatcher.isInteracting()) { return false; - } - else{ - if (this.theWatcher.getAttackTarget() != null) - { + } else { + if (this.theWatcher.getAttackTarget() != null) { this.closestEntity = this.theWatcher.getAttackTarget(); } - if (this.watchedClass == EntityPlayer.class) - { - this.closestEntity = this.theWatcher.worldObj.getClosestPlayerToEntity(this.theWatcher, (double)this.field_75333_c); - } - else - { - this.closestEntity = this.theWatcher.worldObj.findNearestEntityWithinAABB(this.watchedClass, this.theWatcher.boundingBox.expand((double)this.field_75333_c, 3.0D, (double)this.field_75333_c), this.theWatcher); - if (this.closestEntity != null) - { - return this.theWatcher.canSee(this.closestEntity); + if (this.watchedClass == EntityPlayer.class) { + this.closestEntity = this.theWatcher.worldObj.getClosestPlayerToEntity(this.theWatcher, (double) this.field_75333_c); + } else { + this.closestEntity = this.theWatcher.worldObj.findNearestEntityWithinAABB(this.watchedClass, this.theWatcher.boundingBox.expand((double) this.field_75333_c, 3.0D, (double) this.field_75333_c), this.theWatcher); + if (this.closestEntity != null) { + return this.theWatcher.canSee(this.closestEntity); } } @@ -60,18 +55,17 @@ public class EntityAIWatchClosest extends EntityAIBase * Returns whether an in-progress EntityAIBase should continue executing */ @Override - public boolean continueExecuting() - { - if(theWatcher.isInteracting() || theWatcher.isAttacking() || !this.closestEntity.isEntityAlive() || !theWatcher.isEntityAlive()) - return false; - return this.theWatcher.getDistanceSqToEntity(this.closestEntity) > (double)(this.field_75333_c * this.field_75333_c) ? false : this.lookTime > 0; + public boolean continueExecuting() { + if (theWatcher.isInteracting() || theWatcher.isAttacking() || !this.closestEntity.isEntityAlive() || !theWatcher.isEntityAlive()) + return false; + return this.theWatcher.getDistanceSqToEntity(this.closestEntity) > (double) (this.field_75333_c * this.field_75333_c) ? false : this.lookTime > 0; } /** * Execute a one shot task or start executing a continuous task */ @Override - public void startExecuting(){ + public void startExecuting() { this.lookTime = 60 + this.theWatcher.getRNG().nextInt(60); } @@ -79,7 +73,7 @@ public class EntityAIWatchClosest extends EntityAIBase * Resets the task */ @Override - public void resetTask(){ + public void resetTask() { this.closestEntity = null; } @@ -87,9 +81,8 @@ public class EntityAIWatchClosest extends EntityAIBase * Updates the task */ @Override - public void updateTask() - { - this.theWatcher.getLookHelper().setLookPosition(this.closestEntity.posX, this.closestEntity.posY + (double)this.closestEntity.getEyeHeight(), this.closestEntity.posZ, 10.0F, (float)this.theWatcher.getVerticalFaceSpeed()); + public void updateTask() { + this.theWatcher.getLookHelper().setLookPosition(this.closestEntity.posX, this.closestEntity.posY + (double) this.closestEntity.getEyeHeight(), this.closestEntity.posZ, 10.0F, (float) this.theWatcher.getVerticalFaceSpeed()); --this.lookTime; } } diff --git a/src/main/java/noppes/npcs/ai/EntityAIWaterNav.java b/src/main/java/noppes/npcs/ai/EntityAIWaterNav.java index d11a02e80..4e74356e0 100644 --- a/src/main/java/noppes/npcs/ai/EntityAIWaterNav.java +++ b/src/main/java/noppes/npcs/ai/EntityAIWaterNav.java @@ -3,12 +3,10 @@ package noppes.npcs.ai; import net.minecraft.entity.ai.EntityAIBase; import noppes.npcs.entity.EntityNPCInterface; -public class EntityAIWaterNav extends EntityAIBase -{ +public class EntityAIWaterNav extends EntityAIBase { private EntityNPCInterface theEntity; - public EntityAIWaterNav(EntityNPCInterface par1EntityNPCInterface) - { + public EntityAIWaterNav(EntityNPCInterface par1EntityNPCInterface) { this.theEntity = par1EntityNPCInterface; par1EntityNPCInterface.getNavigator().setCanSwim(true); } @@ -16,18 +14,13 @@ public class EntityAIWaterNav extends EntityAIBase /** * Returns whether the EntityAIBase should begin execution. */ - public boolean shouldExecute() - { - if (this.theEntity.isInWater() || this.theEntity.handleLavaMovement()) - { - if (this.theEntity.ais.canSwim) - { - return true; - } - else if (this.theEntity.isCollidedHorizontally) - { - return true; - } + public boolean shouldExecute() { + if (this.theEntity.isInWater() || this.theEntity.handleLavaMovement()) { + if (this.theEntity.ais.canSwim) { + return true; + } else if (this.theEntity.isCollidedHorizontally) { + return true; + } } return false; @@ -36,10 +29,8 @@ public class EntityAIWaterNav extends EntityAIBase /** * Updates the task */ - public void updateTask() - { - if (this.theEntity.getRNG().nextFloat() < 0.8F) - { + public void updateTask() { + if (this.theEntity.getRNG().nextFloat() < 0.8F) { this.theEntity.getJumpHelper().setJumping(); } } diff --git a/src/main/java/noppes/npcs/ai/EntityAIWorldLines.java b/src/main/java/noppes/npcs/ai/EntityAIWorldLines.java index 708564960..c08140aa4 100644 --- a/src/main/java/noppes/npcs/ai/EntityAIWorldLines.java +++ b/src/main/java/noppes/npcs/ai/EntityAIWorldLines.java @@ -9,20 +9,20 @@ public class EntityAIWorldLines extends EntityAIBase { private EntityNPCInterface npc; private int cooldown = 100; - public EntityAIWorldLines(EntityNPCInterface npc){ + public EntityAIWorldLines(EntityNPCInterface npc) { this.npc = npc; this.setMutexBits(AiMutex.PASSIVE); } @Override public boolean shouldExecute() { - if(cooldown > 0){ + if (cooldown > 0) { cooldown--; } return !npc.isAttacking() && !npc.isKilled() && npc.advanced.hasWorldLines() && npc.getRNG().nextInt(1800) == 1; } - public void startExecuting(){ + public void startExecuting() { cooldown = 100; npc.saySurrounding(npc.advanced.getWorldLine()); } diff --git a/src/main/java/noppes/npcs/ai/EntityAIZigZagTarget.java b/src/main/java/noppes/npcs/ai/EntityAIZigZagTarget.java index 0d95a394d..3e91cc84b 100644 --- a/src/main/java/noppes/npcs/ai/EntityAIZigZagTarget.java +++ b/src/main/java/noppes/npcs/ai/EntityAIZigZagTarget.java @@ -9,8 +9,7 @@ import net.minecraft.util.MathHelper; import net.minecraft.util.Vec3; import noppes.npcs.constants.AiMutex; -public class EntityAIZigZagTarget extends EntityAIBase -{ +public class EntityAIZigZagTarget extends EntityAIBase { private EntityCreature theEntity; private EntityLivingBase targetEntity; private double movePosX; @@ -22,8 +21,7 @@ public class EntityAIZigZagTarget extends EntityAIBase private double speed; private float tacticalRange; - public EntityAIZigZagTarget(EntityCreature par1EntityCreature, double par2, float par4) - { + public EntityAIZigZagTarget(EntityCreature par1EntityCreature, double par2, float par4) { this.theEntity = par1EntityCreature; this.speed = par2; this.tacticalRange = par4; @@ -33,44 +31,34 @@ public class EntityAIZigZagTarget extends EntityAIBase /** * Returns whether the EntityAIBase should begin execution. */ - public boolean shouldExecute() - { + public boolean shouldExecute() { this.targetEntity = this.theEntity.getAttackTarget(); - if (this.targetEntity == null) - { + if (this.targetEntity == null) { return false; - } - else if (this.targetEntity.getDistanceSqToEntity(this.theEntity) < (double)(this.tacticalRange * this.tacticalRange)) - { + } else if (this.targetEntity.getDistanceSqToEntity(this.theEntity) < (double) (this.tacticalRange * this.tacticalRange)) { return false; - } - else - { - PathEntity pathentity = this.theEntity.getNavigator().getPathToEntityLiving(targetEntity); + } else { + PathEntity pathentity = this.theEntity.getNavigator().getPathToEntityLiving(targetEntity); - if (pathentity != null) - { - if (pathentity.getCurrentPathLength() >= this.tacticalRange) - { - PathPoint pathpoint = pathentity.getPathPointFromIndex(MathHelper.floor_double(this.tacticalRange / 2.0D)); - this.entityPosX = pathpoint.xCoord; - this.entityPosY = pathpoint.yCoord; - this.entityPosZ = pathpoint.zCoord; - - Vec3 vec3 = RandomPositionGeneratorAlt.findRandomTargetBlockTowards(this.theEntity, (int) tacticalRange, 3, Vec3.createVectorHelper(this.entityPosX, this.entityPosY, this.entityPosZ)); - - if (vec3 != null) - { - if (this.targetEntity.getDistanceSq(vec3.xCoord, vec3.yCoord, vec3.zCoord) < this.targetEntity.getDistanceSq(entityPosX, entityPosY, entityPosZ)) - { - this.movePosX = vec3.xCoord; - this.movePosY = vec3.yCoord; - this.movePosZ = vec3.zCoord; - return true; - } - } - } + if (pathentity != null) { + if (pathentity.getCurrentPathLength() >= this.tacticalRange) { + PathPoint pathpoint = pathentity.getPathPointFromIndex(MathHelper.floor_double(this.tacticalRange / 2.0D)); + this.entityPosX = pathpoint.xCoord; + this.entityPosY = pathpoint.yCoord; + this.entityPosZ = pathpoint.zCoord; + + Vec3 vec3 = RandomPositionGeneratorAlt.findRandomTargetBlockTowards(this.theEntity, (int) tacticalRange, 3, Vec3.createVectorHelper(this.entityPosX, this.entityPosY, this.entityPosZ)); + + if (vec3 != null) { + if (this.targetEntity.getDistanceSq(vec3.xCoord, vec3.yCoord, vec3.zCoord) < this.targetEntity.getDistanceSq(entityPosX, entityPosY, entityPosZ)) { + this.movePosX = vec3.xCoord; + this.movePosY = vec3.yCoord; + this.movePosZ = vec3.zCoord; + return true; + } + } + } } } return false; @@ -79,24 +67,21 @@ public class EntityAIZigZagTarget extends EntityAIBase /** * Returns whether an in-progress EntityAIBase should continue executing */ - public boolean continueExecuting() - { - return !this.theEntity.getNavigator().noPath() && this.targetEntity.isEntityAlive() && this.targetEntity.getDistanceSqToEntity(this.theEntity) > (double)(this.tacticalRange * this.tacticalRange); + public boolean continueExecuting() { + return !this.theEntity.getNavigator().noPath() && this.targetEntity.isEntityAlive() && this.targetEntity.getDistanceSqToEntity(this.theEntity) > (double) (this.tacticalRange * this.tacticalRange); } /** * Execute a one shot task or start executing a continuous task */ - public void startExecuting() - { + public void startExecuting() { this.theEntity.getNavigator().tryMoveToXYZ(this.movePosX, this.movePosY, this.movePosZ, this.speed); } - + /** * Updates the task */ - public void updateTask() - { - this.theEntity.getLookHelper().setLookPositionWithEntity(targetEntity, 30.0F, 30.0F); + public void updateTask() { + this.theEntity.getLookHelper().setLookPositionWithEntity(targetEntity, 30.0F, 30.0F); } } diff --git a/src/main/java/noppes/npcs/ai/RandomPositionGeneratorAlt.java b/src/main/java/noppes/npcs/ai/RandomPositionGeneratorAlt.java index 8c5a6ce19..e07e60d9e 100644 --- a/src/main/java/noppes/npcs/ai/RandomPositionGeneratorAlt.java +++ b/src/main/java/noppes/npcs/ai/RandomPositionGeneratorAlt.java @@ -6,8 +6,7 @@ import net.minecraft.util.Vec3; import java.util.Random; -public class RandomPositionGeneratorAlt -{ +public class RandomPositionGeneratorAlt { /** * used to store a driection when the user passes a point to move towards or away from. WARNING: NEVER THREAD SAFE. * MULTIPLE findTowards and findAway calls, will share this var @@ -17,20 +16,18 @@ public class RandomPositionGeneratorAlt /** * finds a random target within par1(x,z) and par2 (y) blocks */ - public static Vec3 findRandomTarget(EntityCreature par0EntityCreature, int par1, int par2) - { + public static Vec3 findRandomTarget(EntityCreature par0EntityCreature, int par1, int par2) { /** * searches 10 blocks at random in a within par1(x,z) and par2 (y) distance, ignores those not in the direction * of par3Vec3, then points to the tile for which creature.getBlockPathWeight returns the highest number */ - return findRandomTargetBlock(par0EntityCreature, par1, par2, (Vec3)null); + return findRandomTargetBlock(par0EntityCreature, par1, par2, (Vec3) null); } /** * finds a random target within par1(x,z) and par2 (y) blocks in the direction of the point par3 */ - public static Vec3 findRandomTargetBlockTowards(EntityCreature par0EntityCreature, int par1, int par2, Vec3 par3Vec3) - { + public static Vec3 findRandomTargetBlockTowards(EntityCreature par0EntityCreature, int par1, int par2, Vec3 par3Vec3) { staticVector.xCoord = par3Vec3.xCoord - par0EntityCreature.posX; staticVector.yCoord = par3Vec3.yCoord - par0EntityCreature.posY; staticVector.zCoord = par3Vec3.zCoord - par0EntityCreature.posZ; @@ -44,8 +41,7 @@ public class RandomPositionGeneratorAlt /** * finds a random target within par1(x,z) and par2 (y) blocks in the reverse direction of the point par3 */ - public static Vec3 findRandomTargetBlockAwayFrom(EntityCreature par0EntityCreature, int par1, int par2, Vec3 par3Vec3) - { + public static Vec3 findRandomTargetBlockAwayFrom(EntityCreature par0EntityCreature, int par1, int par2, Vec3 par3Vec3) { staticVector.xCoord = par0EntityCreature.posX - par3Vec3.xCoord; staticVector.yCoord = par0EntityCreature.posY - par3Vec3.yCoord; staticVector.zCoord = par0EntityCreature.posZ - par3Vec3.zCoord; @@ -60,12 +56,11 @@ public class RandomPositionGeneratorAlt * searches 10 blocks at random in a within par1(x,z) and par2 (y) distance, ignores those not in the direction of * par3Vec3, then points to the tile for which creature.getBlockPathWeight returns the highest number */ - private static Vec3 findRandomTargetBlock(EntityCreature par0EntityCreature, int par1, int par2, Vec3 par3Vec3) - { - if(par1 <= 0) - par1 = 1; - if(par2 <= 0) - par2 = 1; + private static Vec3 findRandomTargetBlock(EntityCreature par0EntityCreature, int par1, int par2, Vec3 par3Vec3) { + if (par1 <= 0) + par1 = 1; + if (par2 <= 0) + par2 = 1; Random random = par0EntityCreature.getRNG(); boolean flag = false; int k = 0; @@ -74,41 +69,33 @@ public class RandomPositionGeneratorAlt float f = -99999.0F; boolean flag1; - if (par0EntityCreature.hasHome()) - { - double d0 = (double)(par0EntityCreature.getHomePosition().getDistanceSquared(MathHelper.floor_double(par0EntityCreature.posX), MathHelper.floor_double(par0EntityCreature.posY), MathHelper.floor_double(par0EntityCreature.posZ)) + 4.0F); - double d1 = (double)(par0EntityCreature.func_110174_bM() + (float)par1); + if (par0EntityCreature.hasHome()) { + double d0 = (double) (par0EntityCreature.getHomePosition().getDistanceSquared(MathHelper.floor_double(par0EntityCreature.posX), MathHelper.floor_double(par0EntityCreature.posY), MathHelper.floor_double(par0EntityCreature.posZ)) + 4.0F); + double d1 = (double) (par0EntityCreature.func_110174_bM() + (float) par1); flag1 = d0 < d1 * d1; - } - else - { + } else { flag1 = false; } - for (int l1 = 0; l1 < 10; ++l1) - { + for (int l1 = 0; l1 < 10; ++l1) { int j1 = random.nextInt(2 * par1) - par1; int i2 = random.nextInt(2 * par2) - par2; int k1 = random.nextInt(2 * par1) - par1; - if (par3Vec3 == null || (double)j1 * par3Vec3.xCoord + (double)k1 * par3Vec3.zCoord >= 0.0D) - { - if(random.nextBoolean()){ - j1 += MathHelper.floor_double(par0EntityCreature.posX); - i2 += MathHelper.floor_double(par0EntityCreature.posY); - k1 += MathHelper.floor_double(par0EntityCreature.posZ); - } - else{ - j1 += MathHelper.ceiling_double_int(par0EntityCreature.posX); - i2 += MathHelper.ceiling_double_int(par0EntityCreature.posY); - k1 += MathHelper.ceiling_double_int(par0EntityCreature.posZ); - } - if (!flag1 || par0EntityCreature.isWithinHomeDistance(j1, i2, k1)) - { + if (par3Vec3 == null || (double) j1 * par3Vec3.xCoord + (double) k1 * par3Vec3.zCoord >= 0.0D) { + if (random.nextBoolean()) { + j1 += MathHelper.floor_double(par0EntityCreature.posX); + i2 += MathHelper.floor_double(par0EntityCreature.posY); + k1 += MathHelper.floor_double(par0EntityCreature.posZ); + } else { + j1 += MathHelper.ceiling_double_int(par0EntityCreature.posX); + i2 += MathHelper.ceiling_double_int(par0EntityCreature.posY); + k1 += MathHelper.ceiling_double_int(par0EntityCreature.posZ); + } + if (!flag1 || par0EntityCreature.isWithinHomeDistance(j1, i2, k1)) { float f1 = par0EntityCreature.getBlockPathWeight(j1, i2, k1); - if (f1 > f) - { + if (f1 > f) { f = f1; k = j1; l = i2; @@ -119,13 +106,10 @@ public class RandomPositionGeneratorAlt } } - if (flag) - { - return Vec3.createVectorHelper((double)k, (double)l, (double)i1); - } - else - { + if (flag) { + return Vec3.createVectorHelper((double) k, (double) l, (double) i1); + } else { return null; } } -} \ No newline at end of file +} diff --git a/src/main/java/noppes/npcs/ai/pathfinder/FlyPathFinder.java b/src/main/java/noppes/npcs/ai/pathfinder/FlyPathFinder.java index 3cb10e62b..090986165 100644 --- a/src/main/java/noppes/npcs/ai/pathfinder/FlyPathFinder.java +++ b/src/main/java/noppes/npcs/ai/pathfinder/FlyPathFinder.java @@ -19,15 +19,22 @@ import java.util.EnumSet; import java.util.Map; import java.util.Set; -public class FlyPathFinder extends PathFinder -{ - /** Used to find obstacles */ +public class FlyPathFinder extends PathFinder { + /** + * Used to find obstacles + */ private IBlockAccess worldMap; - /** The path being generated */ + /** + * The path being generated + */ private PathHeap path = new PathHeap(); - /** The points in the path */ + /** + * The points in the path + */ protected final IntHashMap pointMap = new IntHashMap(); - /** Selection of path points to add to the path */ + /** + * Selection of path points to add to the path + */ private NPCPathPoint[] pathOptions = new NPCPathPoint[32]; private Entity theEntity; private final Map mapPathPriority = Maps.newEnumMap(PathNodeType.class); @@ -41,9 +48,8 @@ public class FlyPathFinder extends PathFinder private int drowningType; private boolean immuneToFire; - public FlyPathFinder(IBlockAccess _worldMap, boolean doorsAllowed, boolean closedDoors, boolean canPathWater, boolean canDrown, Entity entityIn) - { - super(_worldMap,doorsAllowed,closedDoors,canPathWater,canDrown); + public FlyPathFinder(IBlockAccess _worldMap, boolean doorsAllowed, boolean closedDoors, boolean canPathWater, boolean canDrown, Entity entityIn) { + super(_worldMap, doorsAllowed, closedDoors, canPathWater, canDrown); this.theEntity = entityIn; this.worldMap = _worldMap; @@ -56,75 +62,64 @@ public class FlyPathFinder extends PathFinder /** * Creates a path from one entity to another within a minimum distance */ - public NPCPath createEntityPathTo(Entity entityFrom, Entity entityTo, float distance) - { + public NPCPath createEntityPathTo(Entity entityFrom, Entity entityTo, float distance) { return this.createEntityPathTo(entityFrom, entityTo.posX, entityTo.boundingBox.minY, entityTo.posZ, distance); } /** * Creates a path from an entity to a specified location within a minimum distance */ - public NPCPath createEntityPathTo(Entity entityFrom, int xTo, int yTo, int zTo, float distance) - { - return this.createEntityPathTo(entityFrom, (double)((float)xTo + 0.5F), (double)((float)yTo + 0.5F), (double)((float)zTo + 0.5F), distance); + public NPCPath createEntityPathTo(Entity entityFrom, int xTo, int yTo, int zTo, float distance) { + return this.createEntityPathTo(entityFrom, (double) ((float) xTo + 0.5F), (double) ((float) yTo + 0.5F), (double) ((float) zTo + 0.5F), distance); } /** * Internal implementation of creating a path from an entity to a point */ - private NPCPath createEntityPathTo(Entity entityIn, double x, double y, double z, float distance) - { + private NPCPath createEntityPathTo(Entity entityIn, double x, double y, double z, float distance) { this.path.clearPath(); this.pointMap.clearMap(); - this.drowningType = ((EntityNPCInterface)theEntity).stats.drowningType; - this.immuneToFire = ((EntityNPCInterface)theEntity).stats.immuneToFire; + this.drowningType = ((EntityNPCInterface) theEntity).stats.drowningType; + this.immuneToFire = ((EntityNPCInterface) theEntity).stats.immuneToFire; NPCPathPoint pathpoint = this.getStart(); NPCPathPoint pathpoint1 = this.getPathPointToCoords(entityIn, x, y, z); - NPCPathPoint pathPoint2 = new NPCPathPoint((int)Math.ceil(entityIn.width),(int)Math.ceil(entityIn.height),(int)Math.ceil(entityIn.width)); + NPCPathPoint pathPoint2 = new NPCPathPoint((int) Math.ceil(entityIn.width), (int) Math.ceil(entityIn.height), (int) Math.ceil(entityIn.width)); NPCPath pathentity = addToPath(entityIn, pathpoint, pathpoint1, pathPoint2, distance); return pathentity; } - public NPCPathPoint getStart() - { + public NPCPathPoint getStart() { int i; - if (((EntityNPCInterface)theEntity).ais.canSwim && this.theEntity.isInWater()) - { - i = (int)this.theEntity.boundingBox.minY; + if (((EntityNPCInterface) theEntity).ais.canSwim && this.theEntity.isInWater()) { + i = (int) this.theEntity.boundingBox.minY; BlockPos.MutableBlockPos muteBlock = new BlockPos.MutableBlockPos(MathHelper.floor_double(this.theEntity.posX), i, MathHelper.floor_double(this.theEntity.posZ)); - for (Block block = this.worldMap.getBlock(muteBlock.getX(), muteBlock.getY(), muteBlock.getZ()); block == Blocks.flowing_water || block == Blocks.water; block = this.worldMap.getBlock(muteBlock.getX(), muteBlock.getY(), muteBlock.getZ())) - { + for (Block block = this.worldMap.getBlock(muteBlock.getX(), muteBlock.getY(), muteBlock.getZ()); block == Blocks.flowing_water || block == Blocks.water; block = this.worldMap.getBlock(muteBlock.getX(), muteBlock.getY(), muteBlock.getZ())) { ++i; muteBlock.setPos(MathHelper.floor_double(this.theEntity.posX), i, MathHelper.floor_double(this.theEntity.posZ)); } - } - else - { + } else { i = MathHelper.floor_double(this.theEntity.boundingBox.minY + 0.5D); } BlockPos blockpos1 = new BlockPos(this.theEntity); PathNodeType pathnodetype1 = this.getPathNodeType((EntityLiving) this.theEntity, blockpos1.getX(), i, blockpos1.getZ()); - if (this.getPathPriority(pathnodetype1) < 0.0F) - { + if (this.getPathPriority(pathnodetype1) < 0.0F) { Set set = Sets.newHashSet(); - set.add(new BlockPos(this.theEntity.boundingBox.minX, (double)i, this.theEntity.boundingBox.minZ)); - set.add(new BlockPos(this.theEntity.boundingBox.minX, (double)i, this.theEntity.boundingBox.maxZ)); - set.add(new BlockPos(this.theEntity.boundingBox.maxX, (double)i, this.theEntity.boundingBox.minZ)); - set.add(new BlockPos(this.theEntity.boundingBox.maxX, (double)i, this.theEntity.boundingBox.maxZ)); + set.add(new BlockPos(this.theEntity.boundingBox.minX, (double) i, this.theEntity.boundingBox.minZ)); + set.add(new BlockPos(this.theEntity.boundingBox.minX, (double) i, this.theEntity.boundingBox.maxZ)); + set.add(new BlockPos(this.theEntity.boundingBox.maxX, (double) i, this.theEntity.boundingBox.minZ)); + set.add(new BlockPos(this.theEntity.boundingBox.maxX, (double) i, this.theEntity.boundingBox.maxZ)); - for (BlockPos blockpos : set) - { - PathNodeType pathnodetype = this.getPathNodeType((EntityLiving)this.theEntity, blockpos); + for (BlockPos blockpos : set) { + PathNodeType pathnodetype = this.getPathNodeType((EntityLiving) this.theEntity, blockpos); - if (this.getPathPriority(pathnodetype) >= 0.0F) - { + if (this.getPathPriority(pathnodetype) >= 0.0F) { return openPoint(blockpos.getX(), blockpos.getY(), blockpos.getZ()); } } @@ -134,14 +129,12 @@ public class FlyPathFinder extends PathFinder } - public NPCPathPoint getPathPointToCoords(Entity entityIn, double x, double y, double z) - { + public NPCPathPoint getPathPointToCoords(Entity entityIn, double x, double y, double z) { return openPoint(MathHelper.floor_double(x), MathHelper.floor_double(y), MathHelper.floor_double(z)); } - private NPCPath addToPath(Entity p_75861_1_, NPCPathPoint p_75861_2_, NPCPathPoint p_75861_3_, NPCPathPoint p_75861_4_, float p_75861_5_) - { + private NPCPath addToPath(Entity p_75861_1_, NPCPathPoint p_75861_2_, NPCPathPoint p_75861_3_, NPCPathPoint p_75861_4_, float p_75861_5_) { p_75861_2_.totalPathDistance = 0.0F; p_75861_2_.distanceToNext = p_75861_2_.distanceToSquared(p_75861_3_); p_75861_2_.distanceToTarget = p_75861_2_.distanceToNext; @@ -150,8 +143,7 @@ public class FlyPathFinder extends PathFinder NPCPathPoint pathpoint3 = p_75861_2_; int x = 0; - while (!this.path.isPathEmpty()) - { + while (!this.path.isPathEmpty()) { x++; if (x >= 200) { @@ -160,36 +152,29 @@ public class FlyPathFinder extends PathFinder NPCPathPoint pathpoint4 = this.path.dequeue(); - if (pathpoint4.equals(p_75861_3_)) - { + if (pathpoint4.equals(p_75861_3_)) { return this.createEntityPath(p_75861_2_, p_75861_3_); } - if (pathpoint4.distanceToSquared(p_75861_3_) < pathpoint3.distanceToSquared(p_75861_3_)) - { + if (pathpoint4.distanceToSquared(p_75861_3_) < pathpoint3.distanceToSquared(p_75861_3_)) { pathpoint3 = pathpoint4; } pathpoint4.isFirst = true; int i = this.findPathOptions(p_75861_1_, pathpoint4, p_75861_4_, p_75861_3_, p_75861_5_); - for (int j = 0; j < i; ++j) - { + for (int j = 0; j < i; ++j) { NPCPathPoint pathpoint5 = this.pathOptions[j]; float f1 = pathpoint4.totalPathDistance + pathpoint4.distanceToSquared(pathpoint5); - if (!pathpoint5.isAssigned() || f1 < pathpoint5.totalPathDistance) - { + if (!pathpoint5.isAssigned() || f1 < pathpoint5.totalPathDistance) { pathpoint5.previous = pathpoint4; pathpoint5.totalPathDistance = f1; pathpoint5.distanceToNext = pathpoint5.distanceToSquared(p_75861_3_); - if (pathpoint5.isAssigned()) - { + if (pathpoint5.isAssigned()) { this.path.changeDistance(pathpoint5, pathpoint5.totalPathDistance + pathpoint5.distanceToNext); - } - else - { + } else { pathpoint5.distanceToTarget = pathpoint5.totalPathDistance + pathpoint5.distanceToNext; this.path.addPoint(pathpoint5); } @@ -197,12 +182,9 @@ public class FlyPathFinder extends PathFinder } } - if (pathpoint3 == p_75861_2_) - { + if (pathpoint3 == p_75861_2_) { return null; - } - else - { + } else { return this.createEntityPath(p_75861_2_, pathpoint3); } } @@ -211,13 +193,11 @@ public class FlyPathFinder extends PathFinder * populates pathOptions with available points and returns the number of options found (args: unused1, currentPoint, * unused2, targetPoint, maxDistance) */ - private int findPathOptions(Entity entity, NPCPathPoint currentPoint, NPCPathPoint p_75860_3_, NPCPathPoint targetPoint, float maxDistance) - { + private int findPathOptions(Entity entity, NPCPathPoint currentPoint, NPCPathPoint p_75860_3_, NPCPathPoint targetPoint, float maxDistance) { int i = 0; byte b0 = 0; - if (this.getVerticalOffset(entity, currentPoint.xCoord, currentPoint.yCoord + 1, currentPoint.zCoord, p_75860_3_) == 1) - { + if (this.getVerticalOffset(entity, currentPoint.xCoord, currentPoint.yCoord + 1, currentPoint.zCoord, p_75860_3_) == 1) { b0 = 1; } @@ -228,33 +208,27 @@ public class FlyPathFinder extends PathFinder NPCPathPoint pathpoint4 = this.getSafePoint(entity, currentPoint.xCoord, currentPoint.yCoord + 1, currentPoint.zCoord, p_75860_3_, b0); NPCPathPoint pathpoint5 = this.getSafePoint(entity, currentPoint.xCoord, currentPoint.yCoord - 1, currentPoint.zCoord, p_75860_3_, b0); - if (pathpoint0 != null && !pathpoint0.isFirst && pathpoint0.distanceTo(targetPoint) < maxDistance) - { + if (pathpoint0 != null && !pathpoint0.isFirst && pathpoint0.distanceTo(targetPoint) < maxDistance) { this.pathOptions[i++] = pathpoint0; } - if (pathpoint1 != null && !pathpoint1.isFirst && pathpoint1.distanceTo(targetPoint) < maxDistance) - { + if (pathpoint1 != null && !pathpoint1.isFirst && pathpoint1.distanceTo(targetPoint) < maxDistance) { this.pathOptions[i++] = pathpoint1; } - if (pathpoint2 != null && !pathpoint2.isFirst && pathpoint2.distanceTo(targetPoint) < maxDistance) - { + if (pathpoint2 != null && !pathpoint2.isFirst && pathpoint2.distanceTo(targetPoint) < maxDistance) { this.pathOptions[i++] = pathpoint2; } - if (pathpoint3 != null && !pathpoint3.isFirst && pathpoint3.distanceTo(targetPoint) < maxDistance) - { + if (pathpoint3 != null && !pathpoint3.isFirst && pathpoint3.distanceTo(targetPoint) < maxDistance) { this.pathOptions[i++] = pathpoint3; } - if (pathpoint4 != null && !pathpoint4.isFirst && pathpoint4.distanceTo(targetPoint) < maxDistance) - { + if (pathpoint4 != null && !pathpoint4.isFirst && pathpoint4.distanceTo(targetPoint) < maxDistance) { this.pathOptions[i++] = pathpoint4; } - if (pathpoint5 != null && !pathpoint5.isFirst && pathpoint5.distanceTo(targetPoint) < maxDistance) - { + if (pathpoint5 != null && !pathpoint5.isFirst && pathpoint5.distanceTo(targetPoint) < maxDistance) { this.pathOptions[i++] = pathpoint5; } @@ -265,122 +239,98 @@ public class FlyPathFinder extends PathFinder boolean flag4 = pathpoint4 != null && pathpoint4.costMalus != 1 && pathpoint4.costMalus != 2; boolean flag5 = pathpoint5 != null && pathpoint5.costMalus != 1 && pathpoint5.costMalus != 2; - if (flag && flag3) - { + if (flag && flag3) { NPCPathPoint pathpoint6 = this.getSafePoint(entity, currentPoint.xCoord - 1, currentPoint.yCoord, currentPoint.zCoord - 1, p_75860_3_, b0); - if (pathpoint6 != null && !pathpoint6.isFirst && pathpoint6.distanceTo(targetPoint) < maxDistance) - { + if (pathpoint6 != null && !pathpoint6.isFirst && pathpoint6.distanceTo(targetPoint) < maxDistance) { pathOptions[i++] = pathpoint6; } } - if (flag && flag2) - { + if (flag && flag2) { NPCPathPoint pathpoint6 = this.getSafePoint(entity, currentPoint.xCoord + 1, currentPoint.yCoord, currentPoint.zCoord - 1, p_75860_3_, b0); - if (pathpoint6 != null && !pathpoint6.isFirst && pathpoint6.distanceTo(targetPoint) < maxDistance) - { + if (pathpoint6 != null && !pathpoint6.isFirst && pathpoint6.distanceTo(targetPoint) < maxDistance) { pathOptions[i++] = pathpoint6; } } - if (flag1 && flag3) - { + if (flag1 && flag3) { NPCPathPoint pathpoint6 = this.getSafePoint(entity, currentPoint.xCoord - 1, currentPoint.yCoord, currentPoint.zCoord + 1, p_75860_3_, b0); - if (pathpoint6 != null && !pathpoint6.isFirst && pathpoint6.distanceTo(targetPoint) < maxDistance) - { + if (pathpoint6 != null && !pathpoint6.isFirst && pathpoint6.distanceTo(targetPoint) < maxDistance) { pathOptions[i++] = pathpoint6; } } - if (flag1 && flag2) - { + if (flag1 && flag2) { NPCPathPoint pathpoint6 = this.getSafePoint(entity, currentPoint.xCoord + 1, currentPoint.yCoord, currentPoint.zCoord + 1, p_75860_3_, b0); - if (pathpoint6 != null && !pathpoint6.isFirst && pathpoint6.distanceTo(targetPoint) < maxDistance) - { + if (pathpoint6 != null && !pathpoint6.isFirst && pathpoint6.distanceTo(targetPoint) < maxDistance) { pathOptions[i++] = pathpoint6; } } - if (flag && flag4) - { + if (flag && flag4) { NPCPathPoint pathpoint6 = this.getSafePoint(entity, currentPoint.xCoord, currentPoint.yCoord + 1, currentPoint.zCoord - 1, p_75860_3_, b0); - if (pathpoint6 != null && !pathpoint6.isFirst && pathpoint6.distanceTo(targetPoint) < maxDistance) - { + if (pathpoint6 != null && !pathpoint6.isFirst && pathpoint6.distanceTo(targetPoint) < maxDistance) { pathOptions[i++] = pathpoint6; } } - if (flag1 && flag4) - { + if (flag1 && flag4) { NPCPathPoint pathpoint6 = this.getSafePoint(entity, currentPoint.xCoord, currentPoint.yCoord + 1, currentPoint.zCoord + 1, p_75860_3_, b0); - if (pathpoint6 != null && !pathpoint6.isFirst && pathpoint6.distanceTo(targetPoint) < maxDistance) - { + if (pathpoint6 != null && !pathpoint6.isFirst && pathpoint6.distanceTo(targetPoint) < maxDistance) { pathOptions[i++] = pathpoint6; } } - if (flag2 && flag4) - { + if (flag2 && flag4) { NPCPathPoint pathpoint6 = this.getSafePoint(entity, currentPoint.xCoord + 1, currentPoint.yCoord + 1, currentPoint.zCoord, p_75860_3_, b0); - if (pathpoint6 != null && !pathpoint6.isFirst && pathpoint6.distanceTo(targetPoint) < maxDistance) - { + if (pathpoint6 != null && !pathpoint6.isFirst && pathpoint6.distanceTo(targetPoint) < maxDistance) { pathOptions[i++] = pathpoint6; } } - if (flag3 && flag4) - { + if (flag3 && flag4) { NPCPathPoint pathpoint6 = this.getSafePoint(entity, currentPoint.xCoord - 1, currentPoint.yCoord + 1, currentPoint.zCoord, p_75860_3_, b0); - if (pathpoint6 != null && !pathpoint6.isFirst && pathpoint6.distanceTo(targetPoint) < maxDistance) - { + if (pathpoint6 != null && !pathpoint6.isFirst && pathpoint6.distanceTo(targetPoint) < maxDistance) { pathOptions[i++] = pathpoint6; } } - if (flag && flag5) - { + if (flag && flag5) { NPCPathPoint pathpoint6 = this.getSafePoint(entity, currentPoint.xCoord, currentPoint.yCoord - 1, currentPoint.zCoord - 1, p_75860_3_, b0); - if (pathpoint6 != null && !pathpoint6.isFirst && pathpoint6.distanceTo(targetPoint) < maxDistance) - { + if (pathpoint6 != null && !pathpoint6.isFirst && pathpoint6.distanceTo(targetPoint) < maxDistance) { pathOptions[i++] = pathpoint6; } } - if (flag1 && flag5) - { + if (flag1 && flag5) { NPCPathPoint pathpoint6 = this.getSafePoint(entity, currentPoint.xCoord, currentPoint.yCoord - 1, currentPoint.zCoord + 1, p_75860_3_, b0); - if (pathpoint6 != null && !pathpoint6.isFirst && pathpoint6.distanceTo(targetPoint) < maxDistance) - { + if (pathpoint6 != null && !pathpoint6.isFirst && pathpoint6.distanceTo(targetPoint) < maxDistance) { pathOptions[i++] = pathpoint6; } } - if (flag2 && flag5) - { + if (flag2 && flag5) { NPCPathPoint pathpoint6 = this.getSafePoint(entity, currentPoint.xCoord + 1, currentPoint.yCoord - 1, currentPoint.zCoord, p_75860_3_, b0); - if (pathpoint6 != null && !pathpoint6.isFirst && pathpoint6.distanceTo(targetPoint) < maxDistance) - { + if (pathpoint6 != null && !pathpoint6.isFirst && pathpoint6.distanceTo(targetPoint) < maxDistance) { pathOptions[i++] = pathpoint6; } } - if (flag3 && flag5) - { + if (flag3 && flag5) { NPCPathPoint pathpoint6 = this.getSafePoint(entity, currentPoint.xCoord - 1, currentPoint.yCoord - 1, currentPoint.zCoord, p_75860_3_, b0); - if (pathpoint6 != null && !pathpoint6.isFirst && pathpoint6.distanceTo(targetPoint) < maxDistance) - { + if (pathpoint6 != null && !pathpoint6.isFirst && pathpoint6.distanceTo(targetPoint) < maxDistance) { pathOptions[i++] = pathpoint6; } } @@ -388,75 +338,62 @@ public class FlyPathFinder extends PathFinder return i; } - private NPCPathPoint getSafePoint(Entity entity, int x, int y, int z, NPCPathPoint p_75858_5_, int p_75858_6_) - { + private NPCPathPoint getSafePoint(Entity entity, int x, int y, int z, NPCPathPoint p_75858_5_, int p_75858_6_) { NPCPathPoint pathpoint1 = null; - PathNodeType pathNodeType1 = this.getPathNodeType(entity,x,y,z); + PathNodeType pathNodeType1 = this.getPathNodeType(entity, x, y, z); int i1 = this.nodeTypeToOffset(pathNodeType1); - if (i1 == 2) - { + if (i1 == 2) { pathpoint1 = this.openPoint(x, y, z); pathpoint1.costMalus = i1; pathpoint1.nodeType = pathNodeType1; return pathpoint1; - } - else - { - if (i1 == 1) - { + } else { + if (i1 == 1) { pathpoint1 = this.openPoint(x, y, z); pathpoint1.costMalus = i1; pathpoint1.nodeType = pathNodeType1; } - PathNodeType pathNodeType2 = this.getPathNodeType(entity, x,y + p_75858_6_, z); + PathNodeType pathNodeType2 = this.getPathNodeType(entity, x, y + p_75858_6_, z); int vertOffset2 = this.nodeTypeToOffset(pathNodeType2); - if (pathpoint1 == null && p_75858_6_ > 0 && i1 != -3 && i1 != -4 && vertOffset2 == 1) - { + if (pathpoint1 == null && p_75858_6_ > 0 && i1 != -3 && i1 != -4 && vertOffset2 == 1) { pathpoint1 = this.openPoint(x, y + p_75858_6_, z); pathpoint1.costMalus = vertOffset2; pathpoint1.nodeType = pathNodeType2; y += p_75858_6_; } - if (pathpoint1 != null) - { + if (pathpoint1 != null) { int j1 = 0; int k1 = 0; - while (y > 0) - { - PathNodeType pathNodeType3 = this.getPathNodeType(entity,x, y - 1, z); + while (y > 0) { + PathNodeType pathNodeType3 = this.getPathNodeType(entity, x, y - 1, z); k1 = this.nodeTypeToOffset(pathNodeType3); - if (this.isPathingInWater && k1 == -1) - { + if (this.isPathingInWater && k1 == -1) { return null; } - if (k1 != 1) - { + if (k1 != 1) { break; } - if (j1++ >= entity.getMaxSafePointTries()) - { + if (j1++ >= entity.getMaxSafePointTries()) { return null; } --y; - if (y > 0) - { + if (y > 0) { pathpoint1 = this.openPoint(x, y, z); pathpoint1.costMalus = k1; pathpoint1.nodeType = pathNodeType3; } } - if (k1 == -2) - { + if (k1 == -2) { return null; } } @@ -464,9 +401,8 @@ public class FlyPathFinder extends PathFinder } } - private PathNodeType getPathNodeType(Entity entity, int x, int y, int z) - { - return this.getPathNodeType((EntityLiving) entity, new BlockPos(x,y,z)); + private PathNodeType getPathNodeType(Entity entity, int x, int y, int z) { + return this.getPathNodeType((EntityLiving) entity, new BlockPos(x, y, z)); } public int nodeTypeToOffset(PathNodeType nodeType) { @@ -500,13 +436,11 @@ public class FlyPathFinder extends PathFinder return 1; } - protected NPCPathPoint openPoint(int x, int y, int z) - { + protected NPCPathPoint openPoint(int x, int y, int z) { int i = NPCPathPoint.makeHash(x, y, z); NPCPathPoint pathpoint = this.pointMap.lookup(i); - if (pathpoint == null) - { + if (pathpoint == null) { pathpoint = new NPCPathPoint(x, y, z); this.pointMap.addKey(i, pathpoint); } @@ -517,13 +451,11 @@ public class FlyPathFinder extends PathFinder /** * Returns a new FlyPathEntity for a given start and end point */ - private NPCPath createEntityPath(NPCPathPoint pathFrom, NPCPathPoint pathTo) - { + private NPCPath createEntityPath(NPCPathPoint pathFrom, NPCPathPoint pathTo) { int i = 1; NPCPathPoint pathpoint2; - for (pathpoint2 = pathTo; pathpoint2.previous != null; pathpoint2 = pathpoint2.previous) - { + for (pathpoint2 = pathTo; pathpoint2.previous != null; pathpoint2 = pathpoint2.previous) { ++i; } @@ -531,8 +463,7 @@ public class FlyPathFinder extends PathFinder pathpoint2 = pathTo; --i; - for (apathpoint[i] = pathTo; pathpoint2.previous != null; apathpoint[i] = pathpoint2) - { + for (apathpoint[i] = pathTo; pathpoint2.previous != null; apathpoint[i] = pathpoint2) { pathpoint2 = pathpoint2.previous; --i; } @@ -541,67 +472,49 @@ public class FlyPathFinder extends PathFinder } - public PathNodeType getPathNodeType(IBlockAccess blockaccessIn, int x, int y, int z, EntityLiving entitylivingIn, int xSize, int ySize, int zSize, boolean canBreakDoorsIn, boolean canEnterDoorsIn) - { + public PathNodeType getPathNodeType(IBlockAccess blockaccessIn, int x, int y, int z, EntityLiving entitylivingIn, int xSize, int ySize, int zSize, boolean canBreakDoorsIn, boolean canEnterDoorsIn) { EnumSet enumset = EnumSet.noneOf(PathNodeType.class); PathNodeType pathnodetype = PathNodeType.BLOCKED; BlockPos blockpos = new BlockPos(entitylivingIn); pathnodetype = this.getPathNodeType(blockaccessIn, x, y, z, xSize, ySize, zSize, canBreakDoorsIn, canEnterDoorsIn, enumset, pathnodetype, blockpos); - if (enumset.contains(PathNodeType.FENCE)) - { + if (enumset.contains(PathNodeType.FENCE)) { return PathNodeType.FENCE; - } - else - { + } else { PathNodeType pathnodetype1 = PathNodeType.BLOCKED; - for (PathNodeType pathnodetype2 : enumset) - { - if (getPathPriority(pathnodetype2) < 0.0F) - { + for (PathNodeType pathnodetype2 : enumset) { + if (getPathPriority(pathnodetype2) < 0.0F) { return pathnodetype2; } - if (getPathPriority(pathnodetype2) >= getPathPriority(pathnodetype1)) - { + if (getPathPriority(pathnodetype2) >= getPathPriority(pathnodetype1)) { pathnodetype1 = pathnodetype2; } } - if (pathnodetype == PathNodeType.OPEN && getPathPriority(pathnodetype1) == 0.0F) - { + if (pathnodetype == PathNodeType.OPEN && getPathPriority(pathnodetype1) == 0.0F) { return PathNodeType.OPEN; - } - else - { + } else { return pathnodetype1; } } } - public PathNodeType getPathNodeType(IBlockAccess blockaccessIn, int x, int y, int z) - { + public PathNodeType getPathNodeType(IBlockAccess blockaccessIn, int x, int y, int z) { PathNodeType pathnodetype = this.getPathNodeTypeRaw(blockaccessIn, x, y, z); - if (pathnodetype == PathNodeType.OPEN && y >= 1) - { + if (pathnodetype == PathNodeType.OPEN && y >= 1) { PathNodeType pathnodetype1 = this.getPathNodeTypeRaw(blockaccessIn, x, y - 1, z); - if (pathnodetype1 != PathNodeType.DAMAGE_FIRE && pathnodetype1 != PathNodeType.LAVA) - { - if (pathnodetype1 == PathNodeType.DAMAGE_CACTUS) - { + if (pathnodetype1 != PathNodeType.DAMAGE_FIRE && pathnodetype1 != PathNodeType.LAVA) { + if (pathnodetype1 == PathNodeType.DAMAGE_CACTUS) { pathnodetype = PathNodeType.DAMAGE_CACTUS; - } - else if (pathnodetype1 == PathNodeType.DAMAGE_OTHER) pathnodetype = PathNodeType.DAMAGE_OTHER; - else - { + } else if (pathnodetype1 == PathNodeType.DAMAGE_OTHER) pathnodetype = PathNodeType.DAMAGE_OTHER; + else { pathnodetype = pathnodetype1 != PathNodeType.WALKABLE && pathnodetype1 != PathNodeType.OPEN && pathnodetype1 != PathNodeType.WATER ? PathNodeType.WALKABLE : PathNodeType.OPEN; } - } - else - { + } else { pathnodetype = PathNodeType.DAMAGE_FIRE; } } @@ -610,36 +523,28 @@ public class FlyPathFinder extends PathFinder return pathnodetype; } - public PathNodeType getPathNodeType(IBlockAccess blockAccess, int x, int y, int z, int xSize, int ySize, int zSize, boolean canOpenDoorsIn, boolean canEnterDoorsIn, EnumSet p_193577_10_, PathNodeType p_193577_11_, BlockPos p_193577_12_) - { - for (int i = 0; i < xSize; ++i) - { - for (int j = 0; j < ySize; ++j) - { - for (int k = 0; k < zSize; ++k) - { + public PathNodeType getPathNodeType(IBlockAccess blockAccess, int x, int y, int z, int xSize, int ySize, int zSize, boolean canOpenDoorsIn, boolean canEnterDoorsIn, EnumSet p_193577_10_, PathNodeType p_193577_11_, BlockPos p_193577_12_) { + for (int i = 0; i < xSize; ++i) { + for (int j = 0; j < ySize; ++j) { + for (int k = 0; k < zSize; ++k) { int l = i + x; int i1 = j + y; int j1 = k + z; PathNodeType pathnodetype = this.getPathNodeType(blockAccess, l, i1, j1); - if (pathnodetype == PathNodeType.DOOR_WOOD_CLOSED && canOpenDoorsIn && canEnterDoorsIn) - { + if (pathnodetype == PathNodeType.DOOR_WOOD_CLOSED && canOpenDoorsIn && canEnterDoorsIn) { pathnodetype = PathNodeType.WALKABLE; } - if (pathnodetype == PathNodeType.DOOR_OPEN && !canEnterDoorsIn) - { + if (pathnodetype == PathNodeType.DOOR_OPEN && !canEnterDoorsIn) { pathnodetype = PathNodeType.BLOCKED; } - if (pathnodetype == PathNodeType.RAIL && !(blockAccess.getBlock(p_193577_12_.getX(), p_193577_12_.getY(), p_193577_12_.getZ()) instanceof BlockRailBase) && !(blockAccess.getBlock(p_193577_12_.down().getX(), p_193577_12_.down().getY(), p_193577_12_.down().getZ()) instanceof BlockRailBase)) - { + if (pathnodetype == PathNodeType.RAIL && !(blockAccess.getBlock(p_193577_12_.getX(), p_193577_12_.getY(), p_193577_12_.getZ()) instanceof BlockRailBase) && !(blockAccess.getBlock(p_193577_12_.down().getX(), p_193577_12_.down().getY(), p_193577_12_.down().getZ()) instanceof BlockRailBase)) { pathnodetype = PathNodeType.FENCE; } - if (i == 0 && j == 0 && k == 0) - { + if (i == 0 && j == 0 && k == 0) { p_193577_11_ = pathnodetype; } @@ -651,39 +556,29 @@ public class FlyPathFinder extends PathFinder return p_193577_11_; } - private PathNodeType getPathNodeType(EntityLiving p_192559_1_, BlockPos p_192559_2_) - { + private PathNodeType getPathNodeType(EntityLiving p_192559_1_, BlockPos p_192559_2_) { return this.getPathNodeType(p_192559_1_, p_192559_2_.getX(), p_192559_2_.getY(), p_192559_2_.getZ()); } - private PathNodeType getPathNodeType(EntityLiving p_192558_1_, int p_192558_2_, int p_192558_3_, int p_192558_4_) - { + private PathNodeType getPathNodeType(EntityLiving p_192558_1_, int p_192558_2_, int p_192558_3_, int p_192558_4_) { int entitySizeX = MathHelper.floor_double(this.theEntity.width + 1.0F); int entitySizeY = MathHelper.floor_double(this.theEntity.height + 1.0F); int entitySizeZ = MathHelper.floor_double(this.theEntity.width + 1.0F); - return this.getPathNodeType(this.worldMap, p_192558_2_, p_192558_3_, p_192558_4_, p_192558_1_, entitySizeX, entitySizeY, entitySizeZ, ((EntityCustomNpc)this.theEntity).ais.doorInteract == 0, ((EntityCustomNpc)this.theEntity).ais.doorInteract == 1); + return this.getPathNodeType(this.worldMap, p_192558_2_, p_192558_3_, p_192558_4_, p_192558_1_, entitySizeX, entitySizeY, entitySizeZ, ((EntityCustomNpc) this.theEntity).ais.doorInteract == 0, ((EntityCustomNpc) this.theEntity).ais.doorInteract == 1); } - public PathNodeType checkNeighborBlocks(IBlockAccess worldmap, int x, int y, int z, PathNodeType type) - { + public PathNodeType checkNeighborBlocks(IBlockAccess worldmap, int x, int y, int z, PathNodeType type) { BlockPos.PooledMutableBlockPos blockpos$pooledmutableblockpos = BlockPos.PooledMutableBlockPos.retain(); - if (type == PathNodeType.WALKABLE) - { - for (int i = -1; i <= 1; ++i) - { - for (int j = -1; j <= 1; ++j) - { - if (i != 0 || j != 0) - { + if (type == PathNodeType.WALKABLE) { + for (int i = -1; i <= 1; ++i) { + for (int j = -1; j <= 1; ++j) { + if (i != 0 || j != 0) { blockpos$pooledmutableblockpos.setPos(i + x, y, j + z); Block block = worldmap.getBlock(blockpos$pooledmutableblockpos.getX(), blockpos$pooledmutableblockpos.getY(), blockpos$pooledmutableblockpos.getZ()); - if (block == Blocks.cactus) - { + if (block == Blocks.cactus) { type = PathNodeType.DANGER_CACTUS; - } - else if (block == Blocks.fire && !immuneToFire) - { + } else if (block == Blocks.fire && !immuneToFire) { type = PathNodeType.DANGER_FIRE; } } @@ -695,70 +590,43 @@ public class FlyPathFinder extends PathFinder return type; } - protected PathNodeType getPathNodeTypeRaw(IBlockAccess worldmap, int p_189553_2_, int p_189553_3_, int p_189553_4_) - { + protected PathNodeType getPathNodeTypeRaw(IBlockAccess worldmap, int p_189553_2_, int p_189553_3_, int p_189553_4_) { BlockPos blockpos = new BlockPos(p_189553_2_, p_189553_3_, p_189553_4_); Block block = worldmap.getBlock(blockpos.getX(), blockpos.getY(), blockpos.getZ()); Material material = block.getMaterial(); - if (material == Material.air) - { + if (material == Material.air) { return PathNodeType.OPEN; - } - else if (block != Blocks.trapdoor && block != Blocks.waterlily) - { - if (block == Blocks.fire) - { + } else if (block != Blocks.trapdoor && block != Blocks.waterlily) { + if (block == Blocks.fire) { return immuneToFire ? PathNodeType.OPEN : PathNodeType.DAMAGE_FIRE; - } - else if (block == Blocks.cactus) - { + } else if (block == Blocks.cactus) { return PathNodeType.DAMAGE_CACTUS; - } - else if (block instanceof BlockDoor && material == Material.wood && !((BlockDoor)block).getBlocksMovement(this.worldMap, p_189553_2_, p_189553_3_, p_189553_4_)) - { + } else if (block instanceof BlockDoor && material == Material.wood && !((BlockDoor) block).getBlocksMovement(this.worldMap, p_189553_2_, p_189553_3_, p_189553_4_)) { return PathNodeType.DOOR_WOOD_CLOSED; - } - else if (block instanceof BlockDoor && material == Material.wood && !((BlockDoor)block).getBlocksMovement(this.worldMap, p_189553_2_, p_189553_3_, p_189553_4_)) - { + } else if (block instanceof BlockDoor && material == Material.wood && !((BlockDoor) block).getBlocksMovement(this.worldMap, p_189553_2_, p_189553_3_, p_189553_4_)) { return PathNodeType.DOOR_IRON_CLOSED; - } - else if (block instanceof BlockDoor && ((BlockDoor)block).getBlocksMovement(this.worldMap, p_189553_2_, p_189553_3_, p_189553_4_)) - { + } else if (block instanceof BlockDoor && ((BlockDoor) block).getBlocksMovement(this.worldMap, p_189553_2_, p_189553_3_, p_189553_4_)) { return PathNodeType.DOOR_OPEN; - } - else if (block instanceof BlockRailBase) - { + } else if (block instanceof BlockRailBase) { return PathNodeType.RAIL; - } - else if (!(block instanceof BlockFence) && !(block instanceof BlockWall) && (!(block instanceof BlockFenceGate))) - { - if (material == Material.water) - { - return ((EntityNPCInterface)this.theEntity).ais.canSwim ? PathNodeType.OPEN : PathNodeType.WATER; - } - else if (material == Material.lava) - { + } else if (!(block instanceof BlockFence) && !(block instanceof BlockWall) && (!(block instanceof BlockFenceGate))) { + if (material == Material.water) { + return ((EntityNPCInterface) this.theEntity).ais.canSwim ? PathNodeType.OPEN : PathNodeType.WATER; + } else if (material == Material.lava) { return immuneToFire ? PathNodeType.OPEN : PathNodeType.LAVA; - } - else - { + } else { return block.getBlocksMovement(worldmap, blockpos.getX(), blockpos.getY(), blockpos.getZ()) ? PathNodeType.OPEN : PathNodeType.BLOCKED; } - } - else - { + } else { return PathNodeType.FENCE; } - } - else - { + } else { return PathNodeType.TRAPDOOR; } } - public float getPathPriority(PathNodeType nodeType) - { + public float getPathPriority(PathNodeType nodeType) { Float f = this.mapPathPriority.get(nodeType); return f == null ? nodeType.getPriority() : f.floatValue(); } diff --git a/src/main/java/noppes/npcs/ai/pathfinder/FlyingMoveHelper.java b/src/main/java/noppes/npcs/ai/pathfinder/FlyingMoveHelper.java index 292b8158c..dd59a22de 100644 --- a/src/main/java/noppes/npcs/ai/pathfinder/FlyingMoveHelper.java +++ b/src/main/java/noppes/npcs/ai/pathfinder/FlyingMoveHelper.java @@ -6,7 +6,7 @@ import net.minecraft.util.MathHelper; import noppes.npcs.entity.EntityNPCFlying; import noppes.npcs.entity.EntityNPCInterface; -public class FlyingMoveHelper extends EntityMoveHelper{ +public class FlyingMoveHelper extends EntityMoveHelper { private final EntityNPCInterface entity; private double posX; @@ -15,7 +15,7 @@ public class FlyingMoveHelper extends EntityMoveHelper{ private double speed; public boolean update; - public FlyingMoveHelper(EntityNPCInterface entity){ + public FlyingMoveHelper(EntityNPCInterface entity) { super(entity); this.entity = entity; this.posX = entity.posX; @@ -28,15 +28,15 @@ public class FlyingMoveHelper extends EntityMoveHelper{ this.update = false; double speed = this.speed * this.entity.getEntityAttribute(SharedMonsterAttributes.movementSpeed).getAttributeValue(); - double verticalSpeed = this.speed * this.entity.ais.flySpeed/8.0D; - this.entity.setAIMoveSpeed((float)speed); + double verticalSpeed = this.speed * this.entity.ais.flySpeed / 8.0D; + this.entity.setAIMoveSpeed((float) speed); double d0 = this.posX - this.entity.posX; double d1 = this.posY - this.entity.posY; double d2 = this.posZ - this.entity.posZ; double d4 = d0 * d0 + d1 * d1 + d2 * d2; double d5 = MathHelper.sqrt_double(d4); - speed = Math.min(d5/5.0D,speed); + speed = Math.min(d5 / 5.0D, speed); // its here louis! // This is the hurt time that stuns the NPC!!!!!! @@ -45,7 +45,7 @@ public class FlyingMoveHelper extends EntityMoveHelper{ this.entity.motionX += (speed * (d0 / d5) - this.entity.motionX) * speed; this.entity.motionZ += (speed * (d2 / d5) - this.entity.motionZ) * speed; - if (((EntityNPCFlying)this.entity).flyLimitAllow || !this.entity.ais.hasFlyLimit) { + if (((EntityNPCFlying) this.entity).flyLimitAllow || !this.entity.ais.hasFlyLimit) { this.entity.motionY = verticalSpeed * (d1 / d5); if (this.entity.motionY > 0) { this.entity.motionY += 0.1D; @@ -53,33 +53,27 @@ public class FlyingMoveHelper extends EntityMoveHelper{ } this.entity.velocityChanged = true; - this.entity.rotationYaw = this.limitAngle(this.entity.rotationYaw,(float) ((Math.atan2(-d0, -d2) + Math.PI) * -(180F / Math.PI)),20.0F); + this.entity.rotationYaw = this.limitAngle(this.entity.rotationYaw, (float) ((Math.atan2(-d0, -d2) + Math.PI) * -(180F / Math.PI)), 20.0F); } } } - private float limitAngle(float angleIn, float lower, float upper) - { + private float limitAngle(float angleIn, float lower, float upper) { float f = MathHelper.wrapAngleTo180_float(lower - angleIn); - if (f > upper) - { + if (f > upper) { f = upper; } - if (f < -upper) - { + if (f < -upper) { f = -upper; } float f1 = angleIn + f; - if (f1 < 0.0F) - { + if (f1 < 0.0F) { f1 += 360.0F; - } - else if (f1 > 360.0F) - { + } else if (f1 > 360.0F) { f1 -= 360.0F; } @@ -89,8 +83,7 @@ public class FlyingMoveHelper extends EntityMoveHelper{ /** * Sets the speed and location to move to */ - public void setMoveTo(double p_75642_1_, double p_75642_3_, double p_75642_5_, double p_75642_7_) - { + public void setMoveTo(double p_75642_1_, double p_75642_3_, double p_75642_5_, double p_75642_7_) { this.posX = p_75642_1_; this.posY = p_75642_3_; this.posZ = p_75642_5_; @@ -98,13 +91,11 @@ public class FlyingMoveHelper extends EntityMoveHelper{ this.update = true; } - public boolean isUpdating() - { + public boolean isUpdating() { return this.update; } - public double getSpeed() - { + public double getSpeed() { return this.speed; } } diff --git a/src/main/java/noppes/npcs/ai/pathfinder/NPCPath.java b/src/main/java/noppes/npcs/ai/pathfinder/NPCPath.java index 39510e52a..b19b271f8 100644 --- a/src/main/java/noppes/npcs/ai/pathfinder/NPCPath.java +++ b/src/main/java/noppes/npcs/ai/pathfinder/NPCPath.java @@ -4,15 +4,18 @@ import net.minecraft.entity.Entity; import net.minecraft.pathfinding.PathEntity; import net.minecraft.util.Vec3; -public class NPCPath extends PathEntity{ +public class NPCPath extends PathEntity { public final NPCPathPoint[] points; - /** PathEntity Array Index the Entity is currently targeting */ + /** + * PathEntity Array Index the Entity is currently targeting + */ public int currentPathIndex; - /** The total length of the path */ + /** + * The total length of the path + */ public int pathLength; - public NPCPath(NPCPathPoint[] pointsIn) - { + public NPCPath(NPCPathPoint[] pointsIn) { super(pointsIn); this.points = pointsIn; this.pathLength = pointsIn.length; @@ -21,100 +24,81 @@ public class NPCPath extends PathEntity{ /** * Directs this path to the next point in its array */ - public void incrementPathIndex() - { + public void incrementPathIndex() { ++this.currentPathIndex; } /** * Returns true if this path has reached the end */ - public boolean isFinished() - { + public boolean isFinished() { return this.currentPathIndex >= this.pathLength; } /** * returns the last PathPoint of the Array */ - public NPCPathPoint getFinalPathPoint() - { + public NPCPathPoint getFinalPathPoint() { return this.pathLength > 0 ? this.points[this.pathLength - 1] : null; } /** * return the PathPoint located at the specified PathIndex, usually the current one */ - public NPCPathPoint getPathPointFromIndex(int p_75877_1_) - { + public NPCPathPoint getPathPointFromIndex(int p_75877_1_) { return this.points[p_75877_1_]; } - public int getCurrentPathLength() - { + public int getCurrentPathLength() { return this.pathLength; } - public void setCurrentPathLength(int p_75871_1_) - { + public void setCurrentPathLength(int p_75871_1_) { this.pathLength = p_75871_1_; } - public int getCurrentPathIndex() - { + public int getCurrentPathIndex() { return this.currentPathIndex; } - public void setCurrentPathIndex(int p_75872_1_) - { + public void setCurrentPathIndex(int p_75872_1_) { this.currentPathIndex = p_75872_1_; } /** * Gets the vector of the PathPoint associated with the given index. */ - public Vec3 getVectorFromIndex(Entity entity, int index) - { - double d0 = (double)this.points[index].xCoord + (double)((int)(entity.width + 1.0F)) * 0.5D; - double d1 = (double)this.points[index].yCoord + 0.05D; - double d2 = (double)this.points[index].zCoord + (double)((int)(entity.width + 1.0F)) * 0.5D; + public Vec3 getVectorFromIndex(Entity entity, int index) { + double d0 = (double) this.points[index].xCoord + (double) ((int) (entity.width + 1.0F)) * 0.5D; + double d1 = (double) this.points[index].yCoord + 0.05D; + double d2 = (double) this.points[index].zCoord + (double) ((int) (entity.width + 1.0F)) * 0.5D; return Vec3.createVectorHelper(d0, d1, d2); } /** * returns the current PathEntity target node as Vec3D */ - public Vec3 getPosition(Entity p_75878_1_) - { + public Vec3 getPosition(Entity p_75878_1_) { return this.getVectorFromIndex(p_75878_1_, this.currentPathIndex); } - public Vec3 getCurrentPos() - { + public Vec3 getCurrentPos() { NPCPathPoint pathpoint = this.points[this.currentPathIndex]; - return Vec3.createVectorHelper((double)pathpoint.xCoord, (double)pathpoint.yCoord, (double)pathpoint.zCoord); + return Vec3.createVectorHelper((double) pathpoint.xCoord, (double) pathpoint.yCoord, (double) pathpoint.zCoord); } /** * Returns true if the EntityPath are the same. Non instance related equals. */ - public boolean isSamePath(PathEntity pathEntity) - { + public boolean isSamePath(PathEntity pathEntity) { NPCPath NPCPath = (NPCPath) pathEntity; - if (NPCPath == null) - { + if (NPCPath == null) { return false; - } - else if (NPCPath.points.length != this.points.length) - { + } else if (NPCPath.points.length != this.points.length) { return false; - } - else - { - for (int i = 0; i < this.points.length; ++i) - { - if (this.points[i].xCoord != NPCPath.points[i].xCoord || this.points[i].yCoord != NPCPath.points[i].yCoord || this.points[i].zCoord != NPCPath.points[i].zCoord) - { + } else { + for (int i = 0; i < this.points.length; ++i) { + if (this.points[i].xCoord != NPCPath.points[i].xCoord || this.points[i].yCoord != NPCPath.points[i].yCoord || this.points[i].zCoord != NPCPath.points[i].zCoord) { return false; } } @@ -126,9 +110,8 @@ public class NPCPath extends PathEntity{ /** * Returns true if the final PathPoint in the PathEntity is equal to Vec3D coords. */ - public boolean isDestinationSame(Vec3 vec3) - { + public boolean isDestinationSame(Vec3 vec3) { NPCPathPoint pathpoint = this.getFinalPathPoint(); - return pathpoint == null ? false : pathpoint.xCoord == (int)vec3.xCoord && pathpoint.zCoord == (int)vec3.zCoord; + return pathpoint == null ? false : pathpoint.xCoord == (int) vec3.xCoord && pathpoint.zCoord == (int) vec3.zCoord; } } diff --git a/src/main/java/noppes/npcs/ai/pathfinder/NPCPathPoint.java b/src/main/java/noppes/npcs/ai/pathfinder/NPCPathPoint.java index b611b9651..cac80024c 100644 --- a/src/main/java/noppes/npcs/ai/pathfinder/NPCPathPoint.java +++ b/src/main/java/noppes/npcs/ai/pathfinder/NPCPathPoint.java @@ -3,105 +3,112 @@ package noppes.npcs.ai.pathfinder; import net.minecraft.pathfinding.PathPoint; import net.minecraft.util.MathHelper; -public class NPCPathPoint extends PathPoint -{ - /** The x coordinate of this point */ +public class NPCPathPoint extends PathPoint { + /** + * The x coordinate of this point + */ public final int xCoord; - /** The y coordinate of this point */ + /** + * The y coordinate of this point + */ public final int yCoord; - /** The z coordinate of this point */ + /** + * The z coordinate of this point + */ public final int zCoord; - /** A hash of the coordinates used to identify this point */ + /** + * A hash of the coordinates used to identify this point + */ public final int hash; - /** The index of this point in its assigned path */ + /** + * The index of this point in its assigned path + */ public int index = -1; - /** The distance along the path to this point */ + /** + * The distance along the path to this point + */ public float totalPathDistance; - /** The linear distance to the next point */ + /** + * The linear distance to the next point + */ public float distanceToNext; - /** The distance to the target */ + /** + * The distance to the target + */ public float distanceToTarget; - /** The point preceding this in its assigned path */ + /** + * The point preceding this in its assigned path + */ public NPCPathPoint previous; - /** Indicates this is the origin */ + /** + * Indicates this is the origin + */ public boolean isFirst; public float costMalus; public float cost; public float distanceFromOrigin; public PathNodeType nodeType = PathNodeType.BLOCKED; - public NPCPathPoint(int xIn, int yIn, int zIn) - { - super(xIn,yIn,zIn); + public NPCPathPoint(int xIn, int yIn, int zIn) { + super(xIn, yIn, zIn); this.xCoord = xIn; this.yCoord = yIn; this.zCoord = zIn; this.hash = makeHash(xIn, yIn, zIn); } - public static int makeHash(int xIn, int yIn, int zIn) - { + public static int makeHash(int xIn, int yIn, int zIn) { return yIn & 255 | (xIn & 32767) << 8 | (zIn & 32767) << 24 | (xIn < 0 ? Integer.MIN_VALUE : 0) | (zIn < 0 ? 32768 : 0); } /** * Returns the linear distance to another path point */ - public float distanceTo(NPCPathPoint point) - { - float f = (float)(point.xCoord - this.xCoord); - float f1 = (float)(point.yCoord - this.yCoord); - float f2 = (float)(point.zCoord - this.zCoord); + public float distanceTo(NPCPathPoint point) { + float f = (float) (point.xCoord - this.xCoord); + float f1 = (float) (point.yCoord - this.yCoord); + float f2 = (float) (point.zCoord - this.zCoord); return MathHelper.sqrt_float(f * f + f1 * f1 + f2 * f2); } /** * Returns the squared distance to another path point */ - public float distanceToSquared(NPCPathPoint point) - { - float f = (float)(point.xCoord - this.xCoord); - float f1 = (float)(point.yCoord - this.yCoord); - float f2 = (float)(point.zCoord - this.zCoord); + public float distanceToSquared(NPCPathPoint point) { + float f = (float) (point.xCoord - this.xCoord); + float f1 = (float) (point.yCoord - this.yCoord); + float f2 = (float) (point.zCoord - this.zCoord); return f * f + f1 * f1 + f2 * f2; } - public float distanceManhattan(NPCPathPoint point) - { - float f = (float)Math.abs(point.xCoord - this.xCoord); - float f1 = (float)Math.abs(point.yCoord - this.yCoord); - float f2 = (float)Math.abs(point.zCoord - this.zCoord); + public float distanceManhattan(NPCPathPoint point) { + float f = (float) Math.abs(point.xCoord - this.xCoord); + float f1 = (float) Math.abs(point.yCoord - this.yCoord); + float f2 = (float) Math.abs(point.zCoord - this.zCoord); return f + f1 + f2; } - public boolean equals(Object point) - { - if (!(point instanceof NPCPathPoint)) - { + public boolean equals(Object point) { + if (!(point instanceof NPCPathPoint)) { return false; - } - else - { - NPCPathPoint pathpoint = (NPCPathPoint)point; + } else { + NPCPathPoint pathpoint = (NPCPathPoint) point; return this.hash == pathpoint.hash && this.xCoord == pathpoint.xCoord && this.yCoord == pathpoint.yCoord && this.zCoord == pathpoint.zCoord; } } - public int hashCode() - { + public int hashCode() { return this.hash; } /** * Returns true if this point has already been assigned to a path */ - public boolean isAssigned() - { + public boolean isAssigned() { return this.index >= 0; } - public String toString() - { + public String toString() { return this.xCoord + ", " + this.yCoord + ", " + this.zCoord; } -} \ No newline at end of file +} diff --git a/src/main/java/noppes/npcs/ai/pathfinder/PathHeap.java b/src/main/java/noppes/npcs/ai/pathfinder/PathHeap.java index 991ccc507..35f985d50 100644 --- a/src/main/java/noppes/npcs/ai/pathfinder/PathHeap.java +++ b/src/main/java/noppes/npcs/ai/pathfinder/PathHeap.java @@ -2,22 +2,19 @@ package noppes.npcs.ai.pathfinder; public class PathHeap { private NPCPathPoint[] pathPoints = new NPCPathPoint[128]; - /** The number of points in this path */ + /** + * The number of points in this path + */ private int count; /** * Adds a point to the path */ - public NPCPathPoint addPoint(NPCPathPoint pathPoint) - { - if (pathPoint.index >= 0) - { + public NPCPathPoint addPoint(NPCPathPoint pathPoint) { + if (pathPoint.index >= 0) { throw new IllegalStateException("OW KNOWS!"); - } - else - { - if (this.count == this.pathPoints.length) - { + } else { + if (this.count == this.pathPoints.length) { NPCPathPoint[] apathpoint = new NPCPathPoint[this.count << 1]; System.arraycopy(this.pathPoints, 0, apathpoint, 0, this.count); this.pathPoints = apathpoint; @@ -33,22 +30,19 @@ public class PathHeap { /** * Clears the path */ - public void clearPath() - { + public void clearPath() { this.count = 0; } /** * Returns and removes the first point in the path */ - public NPCPathPoint dequeue() - { + public NPCPathPoint dequeue() { NPCPathPoint pathpoint = this.pathPoints[0]; this.pathPoints[0] = this.pathPoints[--this.count]; this.pathPoints[this.count] = null; - if (this.count > 0) - { + if (this.count > 0) { this.sortForward(0); } @@ -59,17 +53,13 @@ public class PathHeap { /** * Changes the provided point's distance to target */ - public void changeDistance(NPCPathPoint point, float distance) - { + public void changeDistance(NPCPathPoint point, float distance) { float f1 = point.distanceToTarget; point.distanceToTarget = distance; - if (distance < f1) - { + if (distance < f1) { this.sortBack(point.index); - } - else - { + } else { this.sortForward(point.index); } } @@ -77,18 +67,15 @@ public class PathHeap { /** * Sorts a point to the left */ - private void sortBack(int index) - { + private void sortBack(int index) { NPCPathPoint pathpoint = this.pathPoints[index]; int j; - for (float f = pathpoint.distanceToTarget; index > 0; index = j) - { + for (float f = pathpoint.distanceToTarget; index > 0; index = j) { j = index - 1 >> 1; NPCPathPoint pathpoint1 = this.pathPoints[j]; - if (f >= pathpoint1.distanceToTarget) - { + if (f >= pathpoint1.distanceToTarget) { break; } @@ -103,18 +90,15 @@ public class PathHeap { /** * Sorts a point to the right */ - private void sortForward(int index) - { + private void sortForward(int index) { NPCPathPoint pathpoint = this.pathPoints[index]; float f = pathpoint.distanceToTarget; - while (true) - { + while (true) { int j = 1 + (index << 1); int k = j + 1; - if (j >= this.count) - { + if (j >= this.count) { break; } @@ -123,32 +107,24 @@ public class PathHeap { NPCPathPoint pathpoint2; float f2; - if (k >= this.count) - { + if (k >= this.count) { pathpoint2 = null; f2 = Float.POSITIVE_INFINITY; - } - else - { + } else { pathpoint2 = this.pathPoints[k]; f2 = pathpoint2.distanceToTarget; } - if (f1 < f2) - { - if (f1 >= f) - { + if (f1 < f2) { + if (f1 >= f) { break; } this.pathPoints[index] = pathpoint1; pathpoint1.index = index; index = j; - } - else - { - if (f2 >= f) - { + } else { + if (f2 >= f) { break; } @@ -165,5 +141,7 @@ public class PathHeap { /** * Returns true if this path contains no points */ - public boolean isPathEmpty() { return this.count == 0; } + public boolean isPathEmpty() { + return this.count == 0; + } } diff --git a/src/main/java/noppes/npcs/ai/pathfinder/PathNavigateFlying.java b/src/main/java/noppes/npcs/ai/pathfinder/PathNavigateFlying.java index 346074152..df2e4c868 100644 --- a/src/main/java/noppes/npcs/ai/pathfinder/PathNavigateFlying.java +++ b/src/main/java/noppes/npcs/ai/pathfinder/PathNavigateFlying.java @@ -24,28 +24,44 @@ public class PathNavigateFlying extends PathNavigate { private EntityNPCInterface theEntity; private World worldObj; - /** The PathEntity being followed. */ + /** + * The PathEntity being followed. + */ protected NPCPath currentPath; private double speed; - /** The number of blocks (extra) +/- in each axis that get pulled out as cache for the pathfinder's search space */ + /** + * The number of blocks (extra) +/- in each axis that get pulled out as cache for the pathfinder's search space + */ private IAttributeInstance pathSearchRange; protected float maxDistanceToWaypoint = 0.5F; private boolean noSunPathfind; - /** Time, in number of ticks, following the current path */ + /** + * Time, in number of ticks, following the current path + */ private int totalTicks; - /** The time when the last position check was done (to detect successful movement) */ + /** + * The time when the last position check was done (to detect successful movement) + */ private int ticksAtLastPos; - /** Coordinates of the entity's position last time a check was done (part of monitoring getting 'stuck') */ + /** + * Coordinates of the entity's position last time a check was done (part of monitoring getting 'stuck') + */ private Vec3 lastPosCheck = Vec3.createVectorHelper(0.0D, 0.0D, 0.0D); private Vec3 timeoutCachedNode = Vec3.createVectorHelper(0.0D, 0.0D, 0.0D); private long timeoutTimer; private long lastTimeoutCheck; private double timeoutLimit; - /** Specifically, if a wooden door block is even considered to be passable by the pathfinder */ + /** + * Specifically, if a wooden door block is even considered to be passable by the pathfinder + */ private boolean canPassOpenWoodenDoors = true; - /** If door blocks are considered passable even when closed */ + /** + * If door blocks are considered passable even when closed + */ private boolean canPassClosedWoodenDoors; - /** If water blocks are avoided (at least by the pathfinder) */ + /** + * If water blocks are avoided (at least by the pathfinder) + */ private boolean avoidsWater; /** * If the entity can swim. Swimming AI enables this and the pathfinder will also cause the entity to swim straight @@ -61,139 +77,112 @@ public class PathNavigateFlying extends PathNavigate { public PathNavigateFlying(EntityLiving entityIN, World worldIn) { super(entityIN, worldIn); - this.theEntity = (EntityNPCInterface)entityIN; + this.theEntity = (EntityNPCInterface) entityIN; this.worldObj = worldIn; this.pathSearchRange = entityIN.getEntityAttribute(SharedMonsterAttributes.followRange); } - public void updatePath() - { - if (this.worldObj.getTotalWorldTime() - this.lastTimeUpdated > 20L) - { - if (this.targetPos != null) - { + public void updatePath() { + if (this.worldObj.getTotalWorldTime() - this.lastTimeUpdated > 20L) { + if (this.targetPos != null) { this.currentPath = null; this.currentPath = this.getPathToXYZ(this.targetPos.getX(), this.targetPos.getY(), this.targetPos.getZ()); this.lastTimeUpdated = this.worldObj.getTotalWorldTime(); this.tryUpdatePath = false; } - } - else - { + } else { this.tryUpdatePath = true; } } - public void setAvoidsWater(boolean p_75491_1_) - { + public void setAvoidsWater(boolean p_75491_1_) { this.avoidsWater = p_75491_1_; } - public boolean getAvoidsWater() - { + public boolean getAvoidsWater() { return this.avoidsWater; } - public void setBreakDoors(boolean p_75498_1_) - { + public void setBreakDoors(boolean p_75498_1_) { this.canPassClosedWoodenDoors = p_75498_1_; } /** * Sets if the entity can enter open doors */ - public void setEnterDoors(boolean p_75490_1_) - { + public void setEnterDoors(boolean p_75490_1_) { this.canPassOpenWoodenDoors = p_75490_1_; } /** * Returns true if the entity can break doors, false otherwise */ - public boolean getCanBreakDoors() - { + public boolean getCanBreakDoors() { return this.canPassClosedWoodenDoors; } /** * Sets if the path should avoid sunlight */ - public void setAvoidSun(boolean p_75504_1_) - { + public void setAvoidSun(boolean p_75504_1_) { this.noSunPathfind = p_75504_1_; } /** * Sets the speed */ - public void setSpeed(double p_75489_1_) - { + public void setSpeed(double p_75489_1_) { this.speed = p_75489_1_; } /** * Sets if the entity can swim */ - public void setCanSwim(boolean p_75495_1_) - { + public void setCanSwim(boolean p_75495_1_) { this.canSwim = p_75495_1_; } /** * Gets the maximum distance that the path finding will search in. */ - public float getPathSearchRange() - { - return (float)this.pathSearchRange.getAttributeValue(); + public float getPathSearchRange() { + return (float) this.pathSearchRange.getAttributeValue(); } /** * Returns the path to the given coordinates */ - public NPCPath getPathToXYZ(double x, double y, double z) - { + public NPCPath getPathToXYZ(double x, double y, double z) { BlockPos pos = new BlockPos(x, y, z); - if (!this.canNavigate()) - { + if (!this.canNavigate()) { return null; - } - else if (this.currentPath != null && !this.currentPath.isFinished() && pos.equals(this.targetPos)) - { + } else if (this.currentPath != null && !this.currentPath.isFinished() && pos.equals(this.targetPos)) { return this.currentPath; - } - else { + } else { this.targetPos = pos; - return this.getEntityPathToXYZ(this.theEntity, MathHelper.floor_double(x), (int)y, MathHelper.floor_double(z), this.getPathSearchRange(), this.canPassOpenWoodenDoors, this.canPassClosedWoodenDoors, this.avoidsWater, this.canSwim); + return this.getEntityPathToXYZ(this.theEntity, MathHelper.floor_double(x), (int) y, MathHelper.floor_double(z), this.getPathSearchRange(), this.canPassOpenWoodenDoors, this.canPassClosedWoodenDoors, this.avoidsWater, this.canSwim); } } /** * Try to find and set a path to XYZ. Returns true if successful. */ - public boolean tryMoveToXYZ(double p_75492_1_, double p_75492_3_, double p_75492_5_, double p_75492_7_) - { - NPCPath pathentity = this.getPathToXYZ((double)MathHelper.floor_double(p_75492_1_), (double)((int)p_75492_3_), (double)MathHelper.floor_double(p_75492_5_)); + public boolean tryMoveToXYZ(double p_75492_1_, double p_75492_3_, double p_75492_5_, double p_75492_7_) { + NPCPath pathentity = this.getPathToXYZ((double) MathHelper.floor_double(p_75492_1_), (double) ((int) p_75492_3_), (double) MathHelper.floor_double(p_75492_5_)); return this.setPath(pathentity, p_75492_7_); } /** * Returns the path to the given EntityLiving */ - public NPCPath getPathToEntityLiving(Entity entity) - { - if (!this.canNavigate()) - { + public NPCPath getPathToEntityLiving(Entity entity) { + if (!this.canNavigate()) { return null; - } - else - { + } else { BlockPos blockpos = new BlockPos(entity); - if (this.currentPath != null && !this.currentPath.isFinished() && blockpos.equals(this.targetPos)) - { + if (this.currentPath != null && !this.currentPath.isFinished() && blockpos.equals(this.targetPos)) { return this.currentPath; - } - else - { + } else { this.targetPos = blockpos; return this.getPathEntityToEntity(this.theEntity, entity, this.getPathSearchRange(), this.canPassOpenWoodenDoors, this.canPassClosedWoodenDoors, this.avoidsWater, this.canSwim); } @@ -203,8 +192,7 @@ public class PathNavigateFlying extends PathNavigate { /** * Try to find and set a path to EntityLiving. Returns true if successful. */ - public boolean tryMoveToEntityLiving(Entity p_75497_1_, double p_75497_2_) - { + public boolean tryMoveToEntityLiving(Entity p_75497_1_, double p_75497_2_) { NPCPath pathentity = this.getPathToEntityLiving(p_75497_1_); return pathentity != null && this.setPath(pathentity, p_75497_2_); } @@ -213,32 +201,23 @@ public class PathNavigateFlying extends PathNavigate { * sets the active path data if path is 100% unique compared to old path, checks to adjust path for sun avoiding * ents and stores end coords */ - public boolean setPath(@Nullable PathEntity pathEntity, double speed) - { + public boolean setPath(@Nullable PathEntity pathEntity, double speed) { NPCPath NPCPath = (NPCPath) pathEntity; - if (NPCPath == null) - { + if (NPCPath == null) { this.currentPath = null; return false; - } - else - { - if (!NPCPath.isSamePath(this.currentPath)) - { + } else { + if (!NPCPath.isSamePath(this.currentPath)) { this.currentPath = NPCPath; } - if (this.noSunPathfind) - { + if (this.noSunPathfind) { this.removeSunnyPath(); } - if (this.currentPath.getCurrentPathLength() == 0) - { + if (this.currentPath.getCurrentPathLength() == 0) { return false; - } - else - { + } else { this.speed = speed; Vec3 vec3 = this.getEntityPosition(); this.ticksAtLastPos = this.totalTicks; @@ -251,97 +230,78 @@ public class PathNavigateFlying extends PathNavigate { /** * gets the actively used PathEntity */ - public PathEntity getPath() - { + public PathEntity getPath() { return this.currentPath; } - private boolean isInLiquid() - { + private boolean isInLiquid() { return this.theEntity.isInWater() || this.theEntity.handleLavaMovement(); } - private boolean canNavigate() - { + private boolean canNavigate() { return !this.isInLiquid() || (this.canSwim && this.isInLiquid()); } - public void onUpdateNavigation() - { + public void onUpdateNavigation() { ++this.totalTicks; - if (this.tryUpdatePath) - { + if (this.tryUpdatePath) { this.updatePath(); } - if (!this.noPath()) - { - if (this.canNavigate()) - { - if (((EntityNPCInterface)this.theEntity).display.modelSize >= 5) + if (!this.noPath()) { + if (this.canNavigate()) { + if (((EntityNPCInterface) this.theEntity).display.modelSize >= 5) this.pathFollowBig(); else this.pathFollowSmall(); - } - else if (this.currentPath != null && this.currentPath.getCurrentPathIndex() < this.currentPath.getCurrentPathLength()) - { - if (!this.noPath()) - { + } else if (this.currentPath != null && this.currentPath.getCurrentPathIndex() < this.currentPath.getCurrentPathLength()) { + if (!this.noPath()) { Vec3 vec3d = this.currentPath.getVectorFromIndex(this.theEntity, this.currentPath.getCurrentPathIndex()); Vec3 vec3 = this.currentPath.getPosition(this.theEntity); if (MathHelper.floor_double(this.theEntity.posX) == MathHelper.floor_double(vec3d.xCoord) && MathHelper.floor_double(this.theEntity.posY) == MathHelper.floor_double(vec3d.yCoord) && MathHelper.floor_double(this.theEntity.posZ) == MathHelper.floor_double(vec3d.zCoord)) - if (vec3 != null) - { + if (vec3 != null) { this.currentPath.setCurrentPathIndex(this.currentPath.getCurrentPathIndex() + 1); this.theEntity.getMoveHelper().setMoveTo(vec3.xCoord, vec3.yCoord, vec3.zCoord, this.speed); } } } - if (!this.noPath()) - { + if (!this.noPath()) { Vec3 vec3 = this.currentPath.getPosition(this.theEntity); - if (vec3 != null) - { + if (vec3 != null) { this.theEntity.getMoveHelper().setMoveTo(vec3.xCoord, vec3.yCoord, vec3.zCoord, this.speed); } } } } - private void pathFollowBig() - { + private void pathFollowBig() { Vec3 vec3 = this.getEntityPosition(); int i = this.currentPath.getCurrentPathLength(); float f = this.theEntity.width * this.theEntity.width; int k; - for (k = this.currentPath.getCurrentPathIndex(); k < i; ++k) - { - if (vec3.squareDistanceTo(this.currentPath.getVectorFromIndex(this.theEntity, k)) < (double)f) - { + for (k = this.currentPath.getCurrentPathIndex(); k < i; ++k) { + if (vec3.squareDistanceTo(this.currentPath.getVectorFromIndex(this.theEntity, k)) < (double) f) { this.currentPath.setCurrentPathIndex(k + 1); } } k = MathHelper.floor_double(this.theEntity.width + 1.0F); int l = MathHelper.floor_double(this.theEntity.height + 1.0F); - this.trimPath(vec3,i,k,l); + this.trimPath(vec3, i, k, l); this.checkForStuck(vec3); } - private void pathFollowSmall() - { + private void pathFollowSmall() { Vec3 vec3 = this.getEntityPosition(); int i = this.currentPath.getCurrentPathLength(); - for (int j = this.currentPath.getCurrentPathIndex(); j < this.currentPath.getCurrentPathLength(); ++j) - { - if ((double)this.currentPath.getPathPointFromIndex(j).yCoord != Math.floor(vec3.yCoord)) - { + for (int j = this.currentPath.getCurrentPathIndex(); j < this.currentPath.getCurrentPathLength(); ++j) { + if ((double) this.currentPath.getPathPointFromIndex(j).yCoord != Math.floor(vec3.yCoord)) { i = j; break; } @@ -350,27 +310,24 @@ public class PathNavigateFlying extends PathNavigate { this.maxDistanceToWaypoint = this.theEntity.width > 0.75F ? this.theEntity.width / 2.0F : 0.75F - this.theEntity.width / 2.0F; Vec3 vec3d1 = this.currentPath.getCurrentPos(); - if (MathHelper.abs((float)(this.theEntity.posX - (vec3d1.xCoord + 0.5D))) < this.maxDistanceToWaypoint && MathHelper.abs((float)(this.theEntity.posZ - (vec3d1.zCoord + 0.5D))) < this.maxDistanceToWaypoint && Math.abs(this.theEntity.posY - vec3d1.yCoord) < 1.0D) - { + if (MathHelper.abs((float) (this.theEntity.posX - (vec3d1.xCoord + 0.5D))) < this.maxDistanceToWaypoint && MathHelper.abs((float) (this.theEntity.posZ - (vec3d1.zCoord + 0.5D))) < this.maxDistanceToWaypoint && Math.abs(this.theEntity.posY - vec3d1.yCoord) < 1.0D) { this.currentPath.setCurrentPathIndex(this.currentPath.getCurrentPathIndex() + 1); } int k = MathHelper.ceiling_double_int(this.theEntity.width); int l = MathHelper.ceiling_double_int(this.theEntity.height + 1.0F); - this.trimPath(vec3,i,k,l); + this.trimPath(vec3, i, k, l); this.checkForStuck(vec3); } public void trimPath(Vec3 position, int pathLength, int width, int height) { - for (int j1 = pathLength - 1; j1 >= this.currentPath.getCurrentPathIndex(); --j1) - { + for (int j1 = pathLength - 1; j1 >= this.currentPath.getCurrentPathIndex(); --j1) { Vec3 pathPoint = this.currentPath.getVectorFromIndex(this.theEntity, j1); if (position.distanceTo(pathPoint) > 6) continue; - if (this.isDirectPathBetweenPoints(position, pathPoint, width, height)) - { + if (this.isDirectPathBetweenPoints(position, pathPoint, width, height)) { this.currentPath.setCurrentPathIndex(j1); break; } @@ -381,8 +338,7 @@ public class PathNavigateFlying extends PathNavigate { /** * If null path or reached the end */ - public boolean noPath() - { + public boolean noPath() { return this.currentPath == null || this.currentPath.isFinished(); } @@ -390,37 +346,30 @@ public class PathNavigateFlying extends PathNavigate { * sets active PathEntity to null */ @Override - public void clearPathEntity() - { + public void clearPathEntity() { this.currentPath = null; } - private Vec3 getEntityPosition() - { + private Vec3 getEntityPosition() { return Vec3.createVectorHelper(this.theEntity.posX, this.getPathableYPos(), this.theEntity.posZ); } /** * Gets the safe pathing Y position for the entity depending on if it can path swim or not */ - private double getPathableYPos() - { + private double getPathableYPos() { return this.theEntity.boundingBox.minY + 0.05D; } /** * Trims path data from the end to the first sun covered block */ - private void removeSunnyPath() - { - if (!this.worldObj.canBlockSeeTheSky(MathHelper.floor_double(this.theEntity.posX), (int)(this.theEntity.boundingBox.minY + 0.5D), MathHelper.floor_double(this.theEntity.posZ))) - { - for (int i = 0; i < this.currentPath.getCurrentPathLength(); ++i) - { + private void removeSunnyPath() { + if (!this.worldObj.canBlockSeeTheSky(MathHelper.floor_double(this.theEntity.posX), (int) (this.theEntity.boundingBox.minY + 0.5D), MathHelper.floor_double(this.theEntity.posZ))) { + for (int i = 0; i < this.currentPath.getCurrentPathLength(); ++i) { PathPoint pathpoint = this.currentPath.getPathPointFromIndex(i); - if (this.worldObj.canBlockSeeTheSky(pathpoint.xCoord, pathpoint.yCoord, pathpoint.zCoord)) - { + if (this.worldObj.canBlockSeeTheSky(pathpoint.xCoord, pathpoint.yCoord, pathpoint.zCoord)) { this.currentPath.setCurrentPathLength(i - 1); return; } @@ -432,22 +381,18 @@ public class PathNavigateFlying extends PathNavigate { * Returns true when an entity of specified size could safely walk in a straight line between the two points. Args: * pos1, pos2, entityXSize, entityYSize, entityZSize */ - private boolean isDirectPathBetweenPoints(Vec3 startPos, Vec3 endPos, int width, int height) - { - Vec3 pos17 = Vec3.createVectorHelper(startPos.xCoord,startPos.yCoord, startPos.zCoord); - Vec3 pos18 = Vec3.createVectorHelper(endPos.xCoord,endPos.yCoord, endPos.zCoord); + private boolean isDirectPathBetweenPoints(Vec3 startPos, Vec3 endPos, int width, int height) { + Vec3 pos17 = Vec3.createVectorHelper(startPos.xCoord, startPos.yCoord, startPos.zCoord); + Vec3 pos18 = Vec3.createVectorHelper(endPos.xCoord, endPos.yCoord, endPos.zCoord); if (this.rayTraceBlocks(pos17, pos18, true, false, false, width, height)) return false; return true; } - public boolean rayTraceBlocks(Vec3 p_147447_1_, Vec3 p_147447_2_, boolean p_147447_3_, boolean p_147447_4_, boolean p_147447_5_, int width, int height) - { - if (!Double.isNaN(p_147447_1_.xCoord) && !Double.isNaN(p_147447_1_.yCoord) && !Double.isNaN(p_147447_1_.zCoord)) - { - if (!Double.isNaN(p_147447_2_.xCoord) && !Double.isNaN(p_147447_2_.yCoord) && !Double.isNaN(p_147447_2_.zCoord)) - { + public boolean rayTraceBlocks(Vec3 p_147447_1_, Vec3 p_147447_2_, boolean p_147447_3_, boolean p_147447_4_, boolean p_147447_5_, int width, int height) { + if (!Double.isNaN(p_147447_1_.xCoord) && !Double.isNaN(p_147447_1_.yCoord) && !Double.isNaN(p_147447_1_.zCoord)) { + if (!Double.isNaN(p_147447_2_.xCoord) && !Double.isNaN(p_147447_2_.yCoord) && !Double.isNaN(p_147447_2_.zCoord)) { int i = MathHelper.floor_double(p_147447_2_.xCoord); int j = MathHelper.floor_double(p_147447_2_.yCoord); int k = MathHelper.floor_double(p_147447_2_.zCoord); @@ -457,12 +402,10 @@ public class PathNavigateFlying extends PathNavigate { Block block = this.worldObj.getBlock(l, i1, j1); int k1 = this.worldObj.getBlockMetadata(l, i1, j1); - if ((!p_147447_4_ || block.getCollisionBoundingBoxFromPool(this.worldObj, l, i1, j1) != null) && block.canCollideCheck(k1, p_147447_3_)) - { + if ((!p_147447_4_ || block.getCollisionBoundingBoxFromPool(this.worldObj, l, i1, j1) != null) && block.canCollideCheck(k1, p_147447_3_)) { MovingObjectPosition movingobjectposition = block.collisionRayTrace(this.worldObj, l, i1, j1, p_147447_1_, p_147447_2_); - if (movingobjectposition != null && movingobjectposition.typeOfHit != MovingObjectPosition.MovingObjectType.MISS) - { + if (movingobjectposition != null && movingobjectposition.typeOfHit != MovingObjectPosition.MovingObjectType.MISS) { return true; } } @@ -470,15 +413,12 @@ public class PathNavigateFlying extends PathNavigate { MovingObjectPosition movingobjectposition2 = null; k1 = 200; - while (k1-- >= 0) - { - if (Double.isNaN(p_147447_1_.xCoord) || Double.isNaN(p_147447_1_.yCoord) || Double.isNaN(p_147447_1_.zCoord)) - { + while (k1-- >= 0) { + if (Double.isNaN(p_147447_1_.xCoord) || Double.isNaN(p_147447_1_.yCoord) || Double.isNaN(p_147447_1_.zCoord)) { return false; } - if (l == i && i1 == j && j1 == k) - { + if (l == i && i1 == j && j1 == k) { if (p_147447_5_) { return movingobjectposition2 != null && movingobjectposition2.typeOfHit != MovingObjectPosition.MovingObjectType.MISS; } @@ -492,42 +432,27 @@ public class PathNavigateFlying extends PathNavigate { double d1 = 999.0D; double d2 = 999.0D; - if (i > l) - { - d0 = (double)l + 1.0D; - } - else if (i < l) - { - d0 = (double)l + 0.0D; - } - else - { + if (i > l) { + d0 = (double) l + 1.0D; + } else if (i < l) { + d0 = (double) l + 0.0D; + } else { flag6 = false; } - if (j > i1) - { - d1 = (double)i1 + 1.0D; - } - else if (j < i1) - { - d1 = (double)i1 + 0.0D; - } - else - { + if (j > i1) { + d1 = (double) i1 + 1.0D; + } else if (j < i1) { + d1 = (double) i1 + 0.0D; + } else { flag3 = false; } - if (k > j1) - { - d2 = (double)j1 + 1.0D; - } - else if (k < j1) - { - d2 = (double)j1 + 0.0D; - } - else - { + if (k > j1) { + d2 = (double) j1 + 1.0D; + } else if (k < j1) { + d2 = (double) j1 + 0.0D; + } else { flag4 = false; } @@ -538,62 +463,45 @@ public class PathNavigateFlying extends PathNavigate { double d7 = p_147447_2_.yCoord - p_147447_1_.yCoord; double d8 = p_147447_2_.zCoord - p_147447_1_.zCoord; - if (flag6) - { + if (flag6) { d3 = (d0 - p_147447_1_.xCoord) / d6; } - if (flag3) - { + if (flag3) { d4 = (d1 - p_147447_1_.yCoord) / d7; } - if (flag4) - { + if (flag4) { d5 = (d2 - p_147447_1_.zCoord) / d8; } boolean flag5 = false; byte b0; - if (d3 < d4 && d3 < d5) - { - if (i > l) - { + if (d3 < d4 && d3 < d5) { + if (i > l) { b0 = 4; - } - else - { + } else { b0 = 5; } p_147447_1_.xCoord = d0; p_147447_1_.yCoord += d7 * d3; p_147447_1_.zCoord += d8 * d3; - } - else if (d4 < d5) - { - if (j > i1) - { + } else if (d4 < d5) { + if (j > i1) { b0 = 0; - } - else - { + } else { b0 = 1; } p_147447_1_.xCoord += d6 * d4; p_147447_1_.yCoord = d1; p_147447_1_.zCoord += d8 * d4; - } - else - { - if (k > j1) - { + } else { + if (k > j1) { b0 = 2; - } - else - { + } else { b0 = 3; } @@ -603,26 +511,23 @@ public class PathNavigateFlying extends PathNavigate { } Vec3 vec32 = Vec3.createVectorHelper(p_147447_1_.xCoord, p_147447_1_.yCoord, p_147447_1_.zCoord); - l = (int)(vec32.xCoord = (double)MathHelper.floor_double(p_147447_1_.xCoord)); + l = (int) (vec32.xCoord = (double) MathHelper.floor_double(p_147447_1_.xCoord)); - if (b0 == 5) - { + if (b0 == 5) { --l; ++vec32.xCoord; } - i1 = (int)(vec32.yCoord = (double)MathHelper.floor_double(p_147447_1_.yCoord)); + i1 = (int) (vec32.yCoord = (double) MathHelper.floor_double(p_147447_1_.yCoord)); - if (b0 == 1) - { + if (b0 == 1) { --i1; ++vec32.yCoord; } - j1 = (int)(vec32.zCoord = (double)MathHelper.floor_double(p_147447_1_.zCoord)); + j1 = (int) (vec32.zCoord = (double) MathHelper.floor_double(p_147447_1_.zCoord)); - if (b0 == 3) - { + if (b0 == 3) { --j1; ++vec32.zCoord; } @@ -650,7 +555,7 @@ public class PathNavigateFlying extends PathNavigate { boolean collideCheck = (!p_147447_4_ || block2.getCollisionBoundingBoxFromPool(this.worldObj, l, i1, j1) != null) && block2.canCollideCheck(meta2, p_147447_3_); boolean noCollisionBlock = block2 == Blocks.air || block2.getMaterial() == Material.lava && this.theEntity.isImmuneToFire() || - block2.getMaterial() == Material.water && this.theEntity.stats.drowningType == 2; + block2.getMaterial() == Material.water && this.theEntity.stats.drowningType == 2; if (collideCheck && !noCollisionBlock) { if (!block2.getBlocksMovement(this.worldObj, l, i1, j1)) { @@ -688,24 +593,17 @@ public class PathNavigateFlying extends PathNavigate { return movingobjectposition2 != null && movingobjectposition2.typeOfHit != MovingObjectPosition.MovingObjectType.MISS; } return false; - } - else - { + } else { return false; } - } - else - { + } else { return false; } } - protected void checkForStuck(Vec3 positionVec3) - { - if (this.totalTicks - this.ticksAtLastPos > 100) - { - if (positionVec3.squareDistanceTo(this.lastPosCheck) < 2.25D) - { + protected void checkForStuck(Vec3 positionVec3) { + if (this.totalTicks - this.ticksAtLastPos > 100) { + if (positionVec3.squareDistanceTo(this.lastPosCheck) < 2.25D) { this.clearPathEntity(); } @@ -713,24 +611,20 @@ public class PathNavigateFlying extends PathNavigate { this.lastPosCheck = positionVec3; } - if (this.currentPath != null && !this.currentPath.isFinished()) - { + if (this.currentPath != null && !this.currentPath.isFinished()) { Vec3 vec3d = this.currentPath.getCurrentPos(); - if (vec3d.equals(this.timeoutCachedNode)) - { + if (vec3d.equals(this.timeoutCachedNode)) { this.timeoutTimer += System.currentTimeMillis() - this.lastTimeoutCheck; - } - else - { + } else { this.timeoutCachedNode = vec3d; double d0 = positionVec3.distanceTo(this.timeoutCachedNode); - this.timeoutLimit = this.theEntity.getAIMoveSpeed() > 0.0F ? d0 / (double)this.theEntity.getAIMoveSpeed() * 1000.0D : 0.0D; + this.timeoutLimit = this.theEntity.getAIMoveSpeed() > 0.0F ? d0 / (double) this.theEntity.getAIMoveSpeed() * 1000.0D : 0.0D; } - if (this.timeoutLimit > 0.0D && (double)this.timeoutTimer > this.timeoutLimit * 3.0D) - { - this.timeoutCachedNode = Vec3.createVectorHelper(0.0D, 0.0D, 0.0D);; + if (this.timeoutLimit > 0.0D && (double) this.timeoutTimer > this.timeoutLimit * 3.0D) { + this.timeoutCachedNode = Vec3.createVectorHelper(0.0D, 0.0D, 0.0D); + ; this.timeoutTimer = 0L; this.timeoutLimit = 0.0D; this.clearPathEntity(); @@ -740,16 +634,15 @@ public class PathNavigateFlying extends PathNavigate { } } - public ChunkCache createChunkCache(World world, BlockPos blockFrom, BlockPos blockTo){ + public ChunkCache createChunkCache(World world, BlockPos blockFrom, BlockPos blockTo) { return new ChunkCache(world, blockFrom.getX(), blockFrom.getY(), blockFrom.getZ(), blockTo.getX(), blockTo.getY(), blockTo.getZ(), 0); } - public NPCPath getPathEntityToEntity(Entity entityFrom, Entity entityTo, float distance, boolean openDoors, boolean breakDoors, boolean pathWater, boolean canSwim) - { + public NPCPath getPathEntityToEntity(Entity entityFrom, Entity entityTo, float distance, boolean openDoors, boolean breakDoors, boolean pathWater, boolean canSwim) { float f = this.getPathSearchRange(); this.theEntity.worldObj.theProfiler.startSection("pathfind"); BlockPos blockpos1 = (new BlockPos(this.theEntity)).up(); - int i = (int)(f + 16.0F); + int i = (int) (f + 16.0F); ChunkCache chunkcache = createChunkCache(this.worldObj, blockpos1.add(-i, -i, -i), blockpos1.add(i, i, i)); this.pathFinder = new FlyPathFinder(chunkcache, openDoors, breakDoors, pathWater, canSwim, this.theEntity); NPCPath pathentity = this.pathFinder.createEntityPathTo(entityFrom, entityTo, distance); @@ -757,12 +650,11 @@ public class PathNavigateFlying extends PathNavigate { return pathentity; } - public NPCPath getEntityPathToXYZ(Entity entityFrom, int x, int y, int z, float distance, boolean openDoors, boolean breakDoors, boolean pathWater, boolean canSwim) - { + public NPCPath getEntityPathToXYZ(Entity entityFrom, int x, int y, int z, float distance, boolean openDoors, boolean breakDoors, boolean pathWater, boolean canSwim) { float f = this.getPathSearchRange(); this.theEntity.worldObj.theProfiler.startSection("pathfind"); BlockPos blockpos1 = (new BlockPos(this.theEntity)).up(); - int i = (int)(f + 16.0F); + int i = (int) (f + 16.0F); ChunkCache chunkcache = createChunkCache(this.worldObj, blockpos1.add(-i, -i, -i), blockpos1.add(i, i, i)); this.pathFinder = new FlyPathFinder(chunkcache, openDoors, breakDoors, pathWater, canSwim, this.theEntity); NPCPath pathentity = this.pathFinder.createEntityPathTo(entityFrom, this.targetPos.getX(), this.targetPos.getY(), this.targetPos.getZ(), f); diff --git a/src/main/java/noppes/npcs/ai/pathfinder/PathNodeType.java b/src/main/java/noppes/npcs/ai/pathfinder/PathNodeType.java index f49fe3c59..a7eed5618 100644 --- a/src/main/java/noppes/npcs/ai/pathfinder/PathNodeType.java +++ b/src/main/java/noppes/npcs/ai/pathfinder/PathNodeType.java @@ -1,7 +1,6 @@ package noppes.npcs.ai.pathfinder; -public enum PathNodeType -{ +public enum PathNodeType { BLOCKED(-1.0F), OPEN(0.0F), WALKABLE(0.0F), @@ -22,13 +21,11 @@ public enum PathNodeType private final float priority; - private PathNodeType(float priorityIn) - { + private PathNodeType(float priorityIn) { this.priority = priorityIn; } - public float getPriority() - { + public float getPriority() { return this.priority; } -} \ No newline at end of file +} diff --git a/src/main/java/noppes/npcs/ai/selector/NPCAttackSelector.java b/src/main/java/noppes/npcs/ai/selector/NPCAttackSelector.java index ea355009c..5483f1e3f 100644 --- a/src/main/java/noppes/npcs/ai/selector/NPCAttackSelector.java +++ b/src/main/java/noppes/npcs/ai/selector/NPCAttackSelector.java @@ -17,68 +17,68 @@ import noppes.npcs.roles.JobGuard; import noppes.npcs.roles.RoleCompanion; import noppes.npcs.roles.companion.CompanionGuard; -public class NPCAttackSelector implements IEntitySelector -{ - private EntityNPCInterface npc; +public class NPCAttackSelector implements IEntitySelector { + private EntityNPCInterface npc; + + public NPCAttackSelector(EntityNPCInterface npc) { + this.npc = npc; + } - public NPCAttackSelector(EntityNPCInterface npc){ - this.npc = npc; - } /** * Return whether the specified entity is applicable to this filter. */ - @Override - public boolean isEntityApplicable(Entity entity){ - if(!entity.isEntityAlive() || entity == npc || npc.getDistanceToEntity(entity) > npc.stats.aggroRange || !(entity instanceof EntityLivingBase) || ((EntityLivingBase)entity).getHealth() < 1) - return false; + @Override + public boolean isEntityApplicable(Entity entity) { + if (!entity.isEntityAlive() || entity == npc || npc.getDistanceToEntity(entity) > npc.stats.aggroRange || !(entity instanceof EntityLivingBase) || ((EntityLivingBase) entity).getHealth() < 1) + return false; if (this.npc.ais.directLOS && !this.npc.getEntitySenses().canSee(entity)) - return false; + return false; - if(!npc.stats.attackInvisible &&((EntityLivingBase)entity).isPotionActive(Potion.invisibility) && npc.getDistanceSqToEntity(entity) < 9) - return false; + if (!npc.stats.attackInvisible && ((EntityLivingBase) entity).isPotionActive(Potion.invisibility) && npc.getDistanceSqToEntity(entity) < 9) + return false; - //prevent the npc from going on an endless killing spree - if(!npc.isFollower() && npc.ais.returnToStart){ - int allowedDistance = npc.stats.aggroRange * 2; - if(npc.ais.movingType == EnumMovingType.Wandering) - allowedDistance += npc.ais.walkingRange; - double distance = entity.getDistanceSq(npc.getStartXPos(), npc.getStartYPos(), npc.getStartZPos()); - if(npc.ais.movingType == EnumMovingType.MovingPath){ - int[] arr = npc.ais.getCurrentMovingPath(); - distance = entity.getDistanceSq(arr[0], arr[1], arr[2]); - } + //prevent the npc from going on an endless killing spree + if (!npc.isFollower() && npc.ais.returnToStart) { + int allowedDistance = npc.stats.aggroRange * 2; + if (npc.ais.movingType == EnumMovingType.Wandering) + allowedDistance += npc.ais.walkingRange; + double distance = entity.getDistanceSq(npc.getStartXPos(), npc.getStartYPos(), npc.getStartZPos()); + if (npc.ais.movingType == EnumMovingType.MovingPath) { + int[] arr = npc.ais.getCurrentMovingPath(); + distance = entity.getDistanceSq(arr[0], arr[1], arr[2]); + } - if(distance > allowedDistance * allowedDistance) - return false; - } + if (distance > allowedDistance * allowedDistance) + return false; + } - if(npc.advanced.job == EnumJobType.Guard && ((JobGuard)npc.jobInterface).isEntityApplicable(entity)) - return true; + if (npc.advanced.job == EnumJobType.Guard && ((JobGuard) npc.jobInterface).isEntityApplicable(entity)) + return true; - if(npc.advanced.role == EnumRoleType.Companion){ - RoleCompanion role = (RoleCompanion)npc.roleInterface; - if(role.job == EnumCompanionJobs.GUARD && ((CompanionGuard)role.jobInterface).isEntityApplicable(entity)) - return true; - } - if(entity instanceof EntityPlayerMP){ - if(npc.faction.isAggressiveToPlayer((EntityPlayer) entity)){ - if(PixelmonHelper.Enabled && npc.advanced.job == EnumJobType.Spawner) - return PixelmonHelper.canBattle((EntityPlayerMP)entity, npc); + if (npc.advanced.role == EnumRoleType.Companion) { + RoleCompanion role = (RoleCompanion) npc.roleInterface; + if (role.job == EnumCompanionJobs.GUARD && ((CompanionGuard) role.jobInterface).isEntityApplicable(entity)) + return true; + } + if (entity instanceof EntityPlayerMP) { + if (npc.faction.isAggressiveToPlayer((EntityPlayer) entity)) { + if (PixelmonHelper.Enabled && npc.advanced.job == EnumJobType.Spawner) + return PixelmonHelper.canBattle((EntityPlayerMP) entity, npc); - if(DBCAddon.instance.isKO(npc, (EntityPlayer) entity)) + if (DBCAddon.instance.isKO(npc, (EntityPlayer) entity)) return false; - return !((EntityPlayerMP)entity).capabilities.disableDamage; - } - return false; - } + return !((EntityPlayerMP) entity).capabilities.disableDamage; + } + return false; + } - if(entity instanceof EntityNPCInterface){ - if(((EntityNPCInterface)entity).isKilled()) - return false; - if(npc.advanced.attackOtherFactions) - return npc.faction.isAggressiveToNpc((EntityNPCInterface)entity); - } + if (entity instanceof EntityNPCInterface) { + if (((EntityNPCInterface) entity).isKilled()) + return false; + if (npc.advanced.attackOtherFactions) + return npc.faction.isAggressiveToNpc((EntityNPCInterface) entity); + } return false; } diff --git a/src/main/java/noppes/npcs/ai/selector/NPCInteractSelector.java b/src/main/java/noppes/npcs/ai/selector/NPCInteractSelector.java index a23c5e8b9..b0a536dcc 100644 --- a/src/main/java/noppes/npcs/ai/selector/NPCInteractSelector.java +++ b/src/main/java/noppes/npcs/ai/selector/NPCInteractSelector.java @@ -5,18 +5,20 @@ import net.minecraft.entity.Entity; import noppes.npcs.entity.EntityNPCInterface; public class NPCInteractSelector implements IEntitySelector { - private EntityNPCInterface npc; - public NPCInteractSelector(EntityNPCInterface npc){ - this.npc = npc; - } - @Override - public boolean isEntityApplicable(Entity entity) { - if(entity == npc || !(entity instanceof EntityNPCInterface) || !npc.isEntityAlive()) - return false; - EntityNPCInterface selected = (EntityNPCInterface) entity; - if(selected.isAttacking() || npc.getFaction().isAggressiveToNpc(selected) || !npc.ais.stopAndInteract) - return false; - return true; - } + private EntityNPCInterface npc; + + public NPCInteractSelector(EntityNPCInterface npc) { + this.npc = npc; + } + + @Override + public boolean isEntityApplicable(Entity entity) { + if (entity == npc || !(entity instanceof EntityNPCInterface) || !npc.isEntityAlive()) + return false; + EntityNPCInterface selected = (EntityNPCInterface) entity; + if (selected.isAttacking() || npc.getFaction().isAggressiveToNpc(selected) || !npc.ais.stopAndInteract) + return false; + return true; + } } diff --git a/src/main/java/noppes/npcs/ai/target/EntityAIClearTarget.java b/src/main/java/noppes/npcs/ai/target/EntityAIClearTarget.java index 9bd237cb6..1ac4fd45b 100644 --- a/src/main/java/noppes/npcs/ai/target/EntityAIClearTarget.java +++ b/src/main/java/noppes/npcs/ai/target/EntityAIClearTarget.java @@ -4,22 +4,22 @@ import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.ai.EntityAITarget; import noppes.npcs.entity.EntityNPCInterface; -public class EntityAIClearTarget extends EntityAITarget -{ - private EntityNPCInterface npc; - private EntityLivingBase target; - public EntityAIClearTarget(EntityNPCInterface npc){ - super(npc, false); - this.npc = npc; +public class EntityAIClearTarget extends EntityAITarget { + private EntityNPCInterface npc; + private EntityLivingBase target; + + public EntityAIClearTarget(EntityNPCInterface npc) { + super(npc, false); + this.npc = npc; } @Override - public boolean shouldExecute(){ + public boolean shouldExecute() { target = npc.getAttackTarget(); if (target == null) return false; - if(npc.getOwner() != null && !npc.isInRange(npc.getOwner(), npc.stats.aggroRange * 2)){ + if (npc.getOwner() != null && !npc.isInRange(npc.getOwner(), npc.stats.aggroRange * 2)) { return true; } @@ -27,10 +27,10 @@ public class EntityAIClearTarget extends EntityAITarget } @Override - public void startExecuting(){ + public void startExecuting() { this.taskOwner.setAttackTarget(null); - if(target == taskOwner.getAITarget()) - this.taskOwner.setRevengeTarget(null); + if (target == taskOwner.getAITarget()) + this.taskOwner.setRevengeTarget(null); super.startExecuting(); } } diff --git a/src/main/java/noppes/npcs/ai/target/EntityAIClosestTarget.java b/src/main/java/noppes/npcs/ai/target/EntityAIClosestTarget.java index 1221086d4..b6f83ac44 100644 --- a/src/main/java/noppes/npcs/ai/target/EntityAIClosestTarget.java +++ b/src/main/java/noppes/npcs/ai/target/EntityAIClosestTarget.java @@ -14,28 +14,26 @@ import noppes.npcs.entity.EntityNPCInterface; import java.util.Collections; import java.util.List; -public class EntityAIClosestTarget extends EntityAITarget -{ +public class EntityAIClosestTarget extends EntityAITarget { private final Class targetClass; private final int targetChance; - /** Instance of EntityAINearestAttackableTargetSorter. */ + /** + * Instance of EntityAINearestAttackableTargetSorter. + */ private final EntityAINearestAttackableTarget.Sorter theNearestAttackableTargetSorter; private final IEntitySelector field_82643_g; private EntityLivingBase targetEntity; - public EntityAIClosestTarget(EntityCreature par1EntityCreature, Class par2Class, int par3, boolean par4) - { + public EntityAIClosestTarget(EntityCreature par1EntityCreature, Class par2Class, int par3, boolean par4) { this(par1EntityCreature, par2Class, par3, par4, false); } - public EntityAIClosestTarget(EntityCreature par1EntityCreature, Class par2Class, int par3, boolean par4, boolean par5) - { - this(par1EntityCreature, par2Class, par3, par4, par5, (IEntitySelector)null); + public EntityAIClosestTarget(EntityCreature par1EntityCreature, Class par2Class, int par3, boolean par4, boolean par5) { + this(par1EntityCreature, par2Class, par3, par4, par5, (IEntitySelector) null); } - public EntityAIClosestTarget(EntityCreature par1EntityCreature, Class par2Class, int par3, boolean par4, boolean par5, IEntitySelector par6IEntitySelector) - { + public EntityAIClosestTarget(EntityCreature par1EntityCreature, Class par2Class, int par3, boolean par4, boolean par5, IEntitySelector par6IEntitySelector) { super(par1EntityCreature, par4, par5); this.targetClass = par2Class; this.targetChance = par3; @@ -47,26 +45,19 @@ public class EntityAIClosestTarget extends EntityAITarget /** * Returns whether the EntityAIBase should begin execution. */ - public boolean shouldExecute() - { - if (this.targetChance > 0 && this.taskOwner.getRNG().nextInt(this.targetChance) != 0) - { + public boolean shouldExecute() { + if (this.targetChance > 0 && this.taskOwner.getRNG().nextInt(this.targetChance) != 0) { return false; - } - else - { + } else { taskOwner.getEntityAttribute(SharedMonsterAttributes.followRange).setBaseValue(((EntityNPCInterface) taskOwner).stats.aggroRange); double d0 = this.getTargetDistance(); - List list = this.taskOwner.worldObj.selectEntitiesWithinAABB(this.targetClass, this.taskOwner.boundingBox.expand(d0, MathHelper.ceiling_double_int(d0 / 2.0D), d0), this.field_82643_g); + List list = this.taskOwner.worldObj.selectEntitiesWithinAABB(this.targetClass, this.taskOwner.boundingBox.expand(d0, MathHelper.ceiling_double_int(d0 / 2.0D), d0), this.field_82643_g); Collections.sort(list, this.theNearestAttackableTargetSorter); taskOwner.getEntityAttribute(SharedMonsterAttributes.followRange).setBaseValue(ConfigMain.NpcNavRange); - if (list.isEmpty()) - { + if (list.isEmpty()) { return false; - } - else - { - this.targetEntity = (EntityLivingBase)list.get(0); + } else { + this.targetEntity = (EntityLivingBase) list.get(0); return true; } } @@ -75,16 +66,13 @@ public class EntityAIClosestTarget extends EntityAITarget /** * Execute a one shot task or start executing a continuous task */ - public void startExecuting() - { + public void startExecuting() { this.taskOwner.setAttackTarget(this.targetEntity); - if (this.targetEntity instanceof EntityMob) - { - if (((EntityMob) this.targetEntity).getAttackTarget() == null) - { - ((EntityMob)this.targetEntity).setAttackTarget(this.taskOwner); - ((EntityMob)this.targetEntity).setTarget(this.taskOwner); - } + if (this.targetEntity instanceof EntityMob) { + if (((EntityMob) this.targetEntity).getAttackTarget() == null) { + ((EntityMob) this.targetEntity).setAttackTarget(this.taskOwner); + ((EntityMob) this.targetEntity).setTarget(this.taskOwner); + } } super.startExecuting(); } diff --git a/src/main/java/noppes/npcs/ai/target/EntityAIOwnerHurtByTarget.java b/src/main/java/noppes/npcs/ai/target/EntityAIOwnerHurtByTarget.java index 8ce7a8345..bc93b716b 100644 --- a/src/main/java/noppes/npcs/ai/target/EntityAIOwnerHurtByTarget.java +++ b/src/main/java/noppes/npcs/ai/target/EntityAIOwnerHurtByTarget.java @@ -5,13 +5,12 @@ import net.minecraft.entity.ai.EntityAITarget; import noppes.npcs.constants.AiMutex; import noppes.npcs.entity.EntityNPCInterface; -public class EntityAIOwnerHurtByTarget extends EntityAITarget -{ +public class EntityAIOwnerHurtByTarget extends EntityAITarget { EntityNPCInterface npc; EntityLivingBase theOwnerAttacker; private int field_142051_e; - public EntityAIOwnerHurtByTarget(EntityNPCInterface npc){ + public EntityAIOwnerHurtByTarget(EntityNPCInterface npc) { super(npc, false); this.npc = npc; this.setMutexBits(AiMutex.PASSIVE); @@ -20,17 +19,15 @@ public class EntityAIOwnerHurtByTarget extends EntityAITarget /** * Returns whether the EntityAIBase should begin execution. */ - public boolean shouldExecute(){ - if (!this.npc.isFollower() || !(npc.roleInterface != null && npc.roleInterface.defendOwner())){ + public boolean shouldExecute() { + if (!this.npc.isFollower() || !(npc.roleInterface != null && npc.roleInterface.defendOwner())) { return false; - } - else{ + } else { EntityLivingBase entitylivingbase = this.npc.getOwner(); - if (entitylivingbase == null){ + if (entitylivingbase == null) { return false; - } - else{ + } else { this.theOwnerAttacker = entitylivingbase.getAITarget(); int i = entitylivingbase.func_142015_aE(); return i != this.field_142051_e && this.isSuitableTarget(this.theOwnerAttacker, false); @@ -41,14 +38,14 @@ public class EntityAIOwnerHurtByTarget extends EntityAITarget /** * Execute a one shot task or start executing a continuous task */ - public void startExecuting(){ + public void startExecuting() { this.taskOwner.setAttackTarget(this.theOwnerAttacker); EntityLivingBase entitylivingbase = this.npc.getOwner(); - if (entitylivingbase != null){ + if (entitylivingbase != null) { this.field_142051_e = entitylivingbase.func_142015_aE(); } super.startExecuting(); } -} \ No newline at end of file +} diff --git a/src/main/java/noppes/npcs/ai/target/EntityAIOwnerHurtTarget.java b/src/main/java/noppes/npcs/ai/target/EntityAIOwnerHurtTarget.java index c8b315306..174d5d2c0 100644 --- a/src/main/java/noppes/npcs/ai/target/EntityAIOwnerHurtTarget.java +++ b/src/main/java/noppes/npcs/ai/target/EntityAIOwnerHurtTarget.java @@ -5,14 +5,12 @@ import net.minecraft.entity.ai.EntityAITarget; import noppes.npcs.constants.AiMutex; import noppes.npcs.entity.EntityNPCInterface; -public class EntityAIOwnerHurtTarget extends EntityAITarget -{ +public class EntityAIOwnerHurtTarget extends EntityAITarget { EntityNPCInterface npc; EntityLivingBase theTarget; private int field_142050_e; - public EntityAIOwnerHurtTarget(EntityNPCInterface npc) - { + public EntityAIOwnerHurtTarget(EntityNPCInterface npc) { super(npc, false); this.npc = npc; this.setMutexBits(AiMutex.PASSIVE); @@ -21,22 +19,15 @@ public class EntityAIOwnerHurtTarget extends EntityAITarget /** * Returns whether the EntityAIBase should begin execution. */ - public boolean shouldExecute() - { - if (!this.npc.isFollower() || !(npc.roleInterface != null && npc.roleInterface.defendOwner())) - { + public boolean shouldExecute() { + if (!this.npc.isFollower() || !(npc.roleInterface != null && npc.roleInterface.defendOwner())) { return false; - } - else - { + } else { EntityLivingBase entitylivingbase = this.npc.getOwner(); - if (entitylivingbase == null) - { + if (entitylivingbase == null) { return false; - } - else - { + } else { this.theTarget = entitylivingbase.getLastAttacker(); int i = entitylivingbase.getLastAttackerTime(); return i != this.field_142050_e && this.isSuitableTarget(this.theTarget, false); @@ -47,16 +38,14 @@ public class EntityAIOwnerHurtTarget extends EntityAITarget /** * Execute a one shot task or start executing a continuous task */ - public void startExecuting() - { + public void startExecuting() { this.taskOwner.setAttackTarget(this.theTarget); EntityLivingBase entitylivingbase = this.npc.getOwner(); - if (entitylivingbase != null) - { + if (entitylivingbase != null) { this.field_142050_e = entitylivingbase.getLastAttackerTime(); } super.startExecuting(); } -} \ No newline at end of file +} diff --git a/src/main/java/noppes/npcs/blocks/BlockBanner.java b/src/main/java/noppes/npcs/blocks/BlockBanner.java index 6f4fa0b53..4435b9c2f 100644 --- a/src/main/java/noppes/npcs/blocks/BlockBanner.java +++ b/src/main/java/noppes/npcs/blocks/BlockBanner.java @@ -30,42 +30,44 @@ import java.util.List; import static kamkeel.npcs.util.ColorUtil.colorTableInts; import static noppes.npcs.items.ItemNpcTool.BRUSH_COLOR_TAG; -public class BlockBanner extends BlockContainer{ +public class BlockBanner extends BlockContainer { - public int renderId = -1; + public int renderId = -1; - public BlockBanner() { + public BlockBanner() { super(Material.rock); setBlockBounds(0, 0, 0, 1, 2, 1); - } - @Override - public boolean onBlockActivated(World par1World, int i, int j, int k, EntityPlayer player, int par6, float par7, float par8, float par9){ - ItemStack item = player.inventory.getCurrentItem(); - if(item == null) - return false; + } - if(item.getItem() != null && item.getItem() instanceof ItemNpcTool && item.getItemDamage() == 0) + @Override + public boolean onBlockActivated(World par1World, int i, int j, int k, EntityPlayer player, int par6, float par7, float par8, float par9) { + ItemStack item = player.inventory.getCurrentItem(); + if (item == null) return false; - int meta = par1World.getBlockMetadata(i, j, k); - if(meta >= 7) - j--; - TileBanner tile = (TileBanner) par1World.getTileEntity(i, j, k); - if(tile.canEdit()) - return true; - else if(TileColorable.allowColorChange(item) != TileColorable.ColorChangeType.DYE) - return false; + if (item.getItem() != null && item.getItem() instanceof ItemNpcTool && item.getItemDamage() == 0) + return false; + + int meta = par1World.getBlockMetadata(i, j, k); + if (meta >= 7) + j--; + TileBanner tile = (TileBanner) par1World.getTileEntity(i, j, k); + if (tile.canEdit()) + return true; + else if (TileColorable.allowColorChange(item) != TileColorable.ColorChangeType.DYE) + return false; int color = colorTableInts[BlockColored.func_150031_c(item.getItemDamage())]; - if(tile.color != color){ - NoppesUtilServer.consumeItemStack(1, player); - tile.color = color; - par1World.markBlockForUpdate(i, j, k); - } - return true; + if (tile.color != color) { + NoppesUtilServer.consumeItemStack(1, player); + tile.color = color; + par1World.markBlockForUpdate(i, j, k); + } + return true; } + @Override - public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List){ + public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) { par3List.add(new ItemStack(par1, 1, 0)); par3List.add(new ItemStack(par1, 1, 1)); par3List.add(new ItemStack(par1, 1, 2)); @@ -74,94 +76,90 @@ public class BlockBanner extends BlockContainer{ } @Override - public int damageDropped(int par1) - { + public int damageDropped(int par1) { return par1 % 7; } @Override - public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z){ + public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z) { int meta = world.getBlockMetadata(x, y, z); - if(meta >= 7) + if (meta >= 7) setBlockBounds(0, -1, 0, 1, 1, 1); else setBlockBounds(0, 0, 0, 1, 2, 1); } @Override - public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLivingBase par5EntityLivingBase, ItemStack par6ItemStack) - { - if(!par1World.isAirBlock(par2, par3 + 1, par4)){ - par1World.setBlockToAir(par2, par3, par4); - } - else{ + public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLivingBase par5EntityLivingBase, ItemStack par6ItemStack) { + if (!par1World.isAirBlock(par2, par3 + 1, par4)) { + par1World.setBlockToAir(par2, par3, par4); + } else { - int l = MathHelper.floor_double((double)(par5EntityLivingBase.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3; - l %= 4; + int l = MathHelper.floor_double((double) (par5EntityLivingBase.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3; + l %= 4; - TileBanner tile = (TileBanner) par1World.getTileEntity(par2, par3, par4); + TileBanner tile = (TileBanner) par1World.getTileEntity(par2, par3, par4); tile.rotation = l; tile.color = colorTableInts[15 - par6ItemStack.getItemDamage()]; - if(par6ItemStack.hasTagCompound() && par6ItemStack.getTagCompound().hasKey(BRUSH_COLOR_TAG)){ + if (par6ItemStack.hasTagCompound() && par6ItemStack.getTagCompound().hasKey(BRUSH_COLOR_TAG)) { tile.color = par6ItemStack.getTagCompound().getInteger(BRUSH_COLOR_TAG); } - tile.time = System.currentTimeMillis(); + tile.time = System.currentTimeMillis(); - par1World.setBlockMetadataWithNotify(par2, par3, par4, par6ItemStack.getItemDamage() , 2); - par1World.setBlock(par2, par3 + 1, par4, this, par6ItemStack.getItemDamage() + 7, 2); + par1World.setBlockMetadataWithNotify(par2, par3, par4, par6ItemStack.getItemDamage(), 2); + par1World.setBlock(par2, par3 + 1, par4, this, par6ItemStack.getItemDamage() + 7, 2); - if(par5EntityLivingBase instanceof EntityPlayer && par1World.isRemote) - ((EntityPlayer)par5EntityLivingBase).addChatComponentMessage(new ChatComponentTranslation("availability.editIcon")); - } + if (par5EntityLivingBase instanceof EntityPlayer && par1World.isRemote) + ((EntityPlayer) par5EntityLivingBase).addChatComponentMessage(new ChatComponentTranslation("availability.editIcon")); + } } @Override - public boolean isOpaqueCube(){ - return false; - } + public boolean isOpaqueCube() { + return false; + } @Override - public boolean renderAsNormalBlock(){ - return false; - } + public boolean renderAsNormalBlock() { + return false; + } + @Override - public int getRenderType(){ - return renderId; - } + public int getRenderType() { + return renderId; + } @Override @SideOnly(Side.CLIENT) - public void registerBlockIcons(IIconRegister par1IconRegister) - { + public void registerBlockIcons(IIconRegister par1IconRegister) { } + @Override @SideOnly(Side.CLIENT) - public IIcon getIcon(int p_149691_1_, int meta) - { - meta %= 7; - if(meta == 1) + public IIcon getIcon(int p_149691_1_, int meta) { + meta %= 7; + if (meta == 1) return Blocks.stone.getIcon(p_149691_1_, 0); - else if(meta == 2) + else if (meta == 2) return Blocks.iron_block.getIcon(p_149691_1_, 0); - else if(meta == 3) + else if (meta == 3) return Blocks.gold_block.getIcon(p_149691_1_, 0); - else if(meta == 4) + else if (meta == 4) return Blocks.diamond_block.getIcon(p_149691_1_, 0); return Blocks.planks.getIcon(p_149691_1_, 0); } - @Override - public TileEntity createNewTileEntity(World var1, int var2) { - if(var2 < 7) - return new TileBanner(); - return null; - } + @Override + public TileEntity createNewTileEntity(World var1, int var2) { + if (var2 < 7) + return new TileBanner(); + return null; + } - @Override - public void onBlockHarvested(World p_149681_1_, int p_149681_2_, int p_149681_3_, int p_149681_4_, int p_149681_5_, EntityPlayer p_149681_6_) - { + @Override + public void onBlockHarvested(World p_149681_1_, int p_149681_2_, int p_149681_3_, int p_149681_4_, int p_149681_5_, EntityPlayer p_149681_6_) { if (p_149681_5_ >= 7 && p_149681_1_.getBlock(p_149681_2_, p_149681_3_ - 1, p_149681_4_) == this) p_149681_1_.setBlockToAir(p_149681_2_, p_149681_3_ - 1, p_149681_4_); @@ -172,7 +170,7 @@ public class BlockBanner extends BlockContainer{ @Override public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) { int meta = world.getBlockMetadata(x, y, z); - if(meta >= 7) + if (meta >= 7) y--; TileEntity tileentity = world.getTileEntity(x, y, z); diff --git a/src/main/java/noppes/npcs/blocks/BlockBarrel.java b/src/main/java/noppes/npcs/blocks/BlockBarrel.java index fd4fc3a63..cae237605 100644 --- a/src/main/java/noppes/npcs/blocks/BlockBarrel.java +++ b/src/main/java/noppes/npcs/blocks/BlockBarrel.java @@ -16,14 +16,14 @@ import noppes.npcs.constants.EnumGuiType; import java.util.List; -public class BlockBarrel extends BlockRotated{ +public class BlockBarrel extends BlockRotated { - public BlockBarrel() { + public BlockBarrel() { super(Blocks.planks); - } - - @Override - public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List){ + } + + @Override + public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) { par3List.add(new ItemStack(par1, 1, 0)); par3List.add(new ItemStack(par1, 1, 1)); par3List.add(new ItemStack(par1, 1, 2)); @@ -32,42 +32,43 @@ public class BlockBarrel extends BlockRotated{ par3List.add(new ItemStack(par1, 1, 5)); } - @Override - public int damageDropped(int par1){ + @Override + public int damageDropped(int par1) { return par1; } - - public int maxRotation(){ - return 8; + + public int maxRotation() { + return 8; } - - @Override - public boolean onBlockActivated(World par1World, int i, int j, int k, EntityPlayer player, int par6, float par7, float par8, float par9){ - if(par1World.isRemote) - return true; - - par1World.playSoundEffect(i, j + 0.5D, k, "random.chestopen", 0.5F, par1World.rand.nextFloat() * 0.1F + 0.9F); - player.openGui(CustomNpcs.instance, EnumGuiType.Crate.ordinal(), par1World, i, j, k); - return true; + + @Override + public boolean onBlockActivated(World par1World, int i, int j, int k, EntityPlayer player, int par6, float par7, float par8, float par9) { + if (par1World.isRemote) + return true; + + par1World.playSoundEffect(i, j + 0.5D, k, "random.chestopen", 0.5F, par1World.rand.nextFloat() * 0.1F + 0.9F); + player.openGui(CustomNpcs.instance, EnumGuiType.Crate.ordinal(), par1World, i, j, k); + return true; } - @Override - public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLivingBase par5EntityLivingBase, ItemStack par6ItemStack){ + @Override + public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLivingBase par5EntityLivingBase, ItemStack par6ItemStack) { super.onBlockPlacedBy(par1World, par2, par3, par4, par5EntityLivingBase, par6ItemStack); - - par1World.setBlockMetadataWithNotify(par2, par3, par4, par6ItemStack.getItemDamage() , 2); + + par1World.setBlockMetadataWithNotify(par2, par3, par4, par6ItemStack.getItemDamage(), 2); } - @Override - public TileEntity createNewTileEntity(World var1, int var2) { - return new TileBarrel(); - } - @Override - public void breakBlock(World world, int x, int y, int z, Block block, int p_149749_6_){ - TileNpcContainer tile = (TileNpcContainer)world.getTileEntity(x, y, z); + @Override + public TileEntity createNewTileEntity(World var1, int var2) { + return new TileBarrel(); + } + + @Override + public void breakBlock(World world, int x, int y, int z, Block block, int p_149749_6_) { + TileNpcContainer tile = (TileNpcContainer) world.getTileEntity(x, y, z); if (tile == null) - return; + return; tile.dropItems(world, x, y, z); world.func_147453_f(x, y, z, block); diff --git a/src/main/java/noppes/npcs/blocks/BlockBeam.java b/src/main/java/noppes/npcs/blocks/BlockBeam.java index f9efb8077..34c436b08 100644 --- a/src/main/java/noppes/npcs/blocks/BlockBeam.java +++ b/src/main/java/noppes/npcs/blocks/BlockBeam.java @@ -13,14 +13,14 @@ import noppes.npcs.blocks.tiles.TileVariant; import java.util.List; -public class BlockBeam extends BlockRotated{ +public class BlockBeam extends BlockRotated { - public BlockBeam() { + public BlockBeam() { super(Blocks.planks); - } + } @Override - public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List){ + public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) { par3List.add(new ItemStack(par1, 1, 0)); par3List.add(new ItemStack(par1, 1, 1)); par3List.add(new ItemStack(par1, 1, 2)); @@ -30,41 +30,39 @@ public class BlockBeam extends BlockRotated{ } @Override - public int damageDropped(int par1){ + public int damageDropped(int par1) { return par1; } + @Override - public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z){ - TileEntity tileentity = world.getTileEntity(x, y, z); - if(!(tileentity instanceof TileVariant)){ - super.setBlockBoundsBasedOnState(world, x, y, z); - return; - } - TileVariant tile = (TileVariant) tileentity; - if(tile.rotation == 0){ - setBlockBounds(0.33f, 0.33f, 0.25f, 0.67f, 0.67f, 1f ); - } - else if(tile.rotation == 2){ - setBlockBounds(0.33f, 0.33f, 0, 0.67f, 0.67f, 0.75f ); - } - else if(tile.rotation == 3){ - setBlockBounds(0.25f, 0.33f, 0.33f, 1f, 0.67f, 0.67f ); - } - else if(tile.rotation == 1){ - setBlockBounds(0, 0.33f, 0.33f, 0.75f, 0.67f, 0.67f ); - } + public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z) { + TileEntity tileentity = world.getTileEntity(x, y, z); + if (!(tileentity instanceof TileVariant)) { + super.setBlockBoundsBasedOnState(world, x, y, z); + return; + } + TileVariant tile = (TileVariant) tileentity; + if (tile.rotation == 0) { + setBlockBounds(0.33f, 0.33f, 0.25f, 0.67f, 0.67f, 1f); + } else if (tile.rotation == 2) { + setBlockBounds(0.33f, 0.33f, 0, 0.67f, 0.67f, 0.75f); + } else if (tile.rotation == 3) { + setBlockBounds(0.25f, 0.33f, 0.33f, 1f, 0.67f, 0.67f); + } else if (tile.rotation == 1) { + setBlockBounds(0, 0.33f, 0.33f, 0.75f, 0.67f, 0.67f); + } } @Override - public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLivingBase par5EntityLivingBase, ItemStack par6ItemStack){ + public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLivingBase par5EntityLivingBase, ItemStack par6ItemStack) { super.onBlockPlacedBy(par1World, par2, par3, par4, par5EntityLivingBase, par6ItemStack); - par1World.setBlockMetadataWithNotify(par2, par3, par4, par6ItemStack.getItemDamage() , 2); + par1World.setBlockMetadataWithNotify(par2, par3, par4, par6ItemStack.getItemDamage(), 2); } - @Override - public TileEntity createNewTileEntity(World var1, int var2) { - return new TileBeam(); - } + @Override + public TileEntity createNewTileEntity(World var1, int var2) { + return new TileBeam(); + } } diff --git a/src/main/java/noppes/npcs/blocks/BlockBigSign.java b/src/main/java/noppes/npcs/blocks/BlockBigSign.java index dc82988d9..78f2c39e3 100644 --- a/src/main/java/noppes/npcs/blocks/BlockBigSign.java +++ b/src/main/java/noppes/npcs/blocks/BlockBigSign.java @@ -23,104 +23,106 @@ import noppes.npcs.blocks.tiles.TileBigSign; import noppes.npcs.blocks.tiles.TileVariant; import noppes.npcs.constants.EnumGuiType; -public class BlockBigSign extends BlockContainer{ +public class BlockBigSign extends BlockContainer { - public int renderId = -1; + public int renderId = -1; - public BlockBigSign() { + public BlockBigSign() { super(Material.wood); - } + } @Override - public int damageDropped(int par1){ + public int damageDropped(int par1) { return par1; } - public AxisAlignedBB getCollisionBoundingBoxFromPool(World p_149668_1_, int p_149668_2_, int p_149668_3_, int p_149668_4_){ - return null; + public AxisAlignedBB getCollisionBoundingBoxFromPool(World p_149668_1_, int p_149668_2_, int p_149668_3_, int p_149668_4_) { + return null; } + @Override - public boolean onBlockActivated(World par1World, int i, int j, int k, EntityPlayer player, int par6, float par7, float par8, float par9){ - if(par1World.isRemote) - return false; - ItemStack currentItem = player.inventory.getCurrentItem(); - if (currentItem != null && currentItem.getItem() == CustomItems.wand && CustomNpcsPermissions.hasPermission(player, CustomNpcsPermissions.EDIT_BIGSIGN)) { - TileBigSign tile = (TileBigSign) par1World.getTileEntity(i, j, k); - tile.canEdit = true; - NoppesUtilServer.sendOpenGui(player, EnumGuiType.BigSign, null, i, j, k); - return true; - } - return false; + public boolean onBlockActivated(World par1World, int i, int j, int k, EntityPlayer player, int par6, float par7, float par8, float par9) { + if (par1World.isRemote) + return false; + ItemStack currentItem = player.inventory.getCurrentItem(); + if (currentItem != null && currentItem.getItem() == CustomItems.wand && CustomNpcsPermissions.hasPermission(player, CustomNpcsPermissions.EDIT_BIGSIGN)) { + TileBigSign tile = (TileBigSign) par1World.getTileEntity(i, j, k); + tile.canEdit = true; + NoppesUtilServer.sendOpenGui(player, EnumGuiType.BigSign, null, i, j, k); + return true; + } + return false; } + @Override - public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLivingBase par5EntityLivingBase, ItemStack par6ItemStack){ - int l = MathHelper.floor_double((double)(par5EntityLivingBase.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3; + public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLivingBase par5EntityLivingBase, ItemStack par6ItemStack) { + int l = MathHelper.floor_double((double) (par5EntityLivingBase.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3; l %= 4; TileBigSign tile = (TileBigSign) par1World.getTileEntity(par2, par3, par4); - tile.rotation = l; + tile.rotation = l; - par1World.setBlockMetadataWithNotify(par2, par3, par4, par6ItemStack.getItemDamage() , 2); + par1World.setBlockMetadataWithNotify(par2, par3, par4, par6ItemStack.getItemDamage(), 2); - if(par5EntityLivingBase instanceof EntityPlayer && par1World.isRemote){ - CustomNpcs.proxy.openGui(par2, par3, par4, EnumGuiType.BigSign, (EntityPlayer) par5EntityLivingBase); - } + if (par5EntityLivingBase instanceof EntityPlayer && par1World.isRemote) { + CustomNpcs.proxy.openGui(par2, par3, par4, EnumGuiType.BigSign, (EntityPlayer) par5EntityLivingBase); + } } @Override - public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z){ - TileEntity tileentity = world.getTileEntity(x, y, z); - if(!(tileentity instanceof TileVariant)){ - super.setBlockBoundsBasedOnState(world, x, y, z); - return; - } - TileVariant tile = (TileVariant) tileentity; + public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z) { + TileEntity tileentity = world.getTileEntity(x, y, z); + if (!(tileentity instanceof TileVariant)) { + super.setBlockBoundsBasedOnState(world, x, y, z); + return; + } + TileVariant tile = (TileVariant) tileentity; int meta = tile.getBlockMetadata(); - float xStart = 0; - float zStart = 0; - float xEnd = 1; - float zEnd = 1; - if(tile.rotation == 0) - zStart = 0.87f; - else if(tile.rotation == 2) - zEnd = 0.13f; - else if(tile.rotation == 3) - xStart = 0.87f; - else if(tile.rotation == 1) - xEnd = 0.13f; + float xStart = 0; + float zStart = 0; + float xEnd = 1; + float zEnd = 1; + if (tile.rotation == 0) + zStart = 0.87f; + else if (tile.rotation == 2) + zEnd = 0.13f; + else if (tile.rotation == 3) + xStart = 0.87f; + else if (tile.rotation == 1) + xEnd = 0.13f; setBlockBounds(xStart, 0, zStart, xEnd, 1, zEnd); } @Override - public boolean isOpaqueCube(){ - return false; - } + public boolean isOpaqueCube() { + return false; + } @Override - public boolean renderAsNormalBlock(){ - return false; - } + public boolean renderAsNormalBlock() { + return false; + } + @Override - public int getRenderType(){ - return renderId; - } + public int getRenderType() { + return renderId; + } @Override @SideOnly(Side.CLIENT) - public void registerBlockIcons(IIconRegister par1IconRegister) - { + public void registerBlockIcons(IIconRegister par1IconRegister) { } + @Override @SideOnly(Side.CLIENT) - public IIcon getIcon(int p_149691_1_, int meta) - { + public IIcon getIcon(int p_149691_1_, int meta) { return Blocks.planks.getIcon(p_149691_1_, meta); } - @Override - public TileEntity createNewTileEntity(World var1, int var2) { - return new TileBigSign(); - } + @Override + public TileEntity createNewTileEntity(World var1, int var2) { + return new TileBigSign(); + } } diff --git a/src/main/java/noppes/npcs/blocks/BlockBlood.java b/src/main/java/noppes/npcs/blocks/BlockBlood.java index addec578e..061af0679 100644 --- a/src/main/java/noppes/npcs/blocks/BlockBlood.java +++ b/src/main/java/noppes/npcs/blocks/BlockBlood.java @@ -16,80 +16,80 @@ import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import noppes.npcs.CustomItems; -public class BlockBlood extends Block{ - +public class BlockBlood extends Block { + @SideOnly(Side.CLIENT) private IIcon blockIcon2; @SideOnly(Side.CLIENT) private IIcon blockIcon3; - + private final int renderId = RenderingRegistry.getNextAvailableRenderId(); - - public BlockBlood(){ + + public BlockBlood() { super(Material.rock); - this.setBlockUnbreakable(); - setCreativeTab(CustomItems.tabMisc); - setBlockBounds(0.01f, 0.01f, 0.01f, 0.99f, 0.99f, 0.99f); - this.setLightLevel(0.08f); + this.setBlockUnbreakable(); + setCreativeTab(CustomItems.tabMisc); + setBlockBounds(0.01f, 0.01f, 0.01f, 0.99f, 0.99f, 0.99f); + this.setLightLevel(0.08f); } @Override @SideOnly(Side.CLIENT) - public IIcon getIcon(int side, int metadata){ - metadata += side; - if(metadata % 3 == 1) - return blockIcon2; - if(metadata % 3 == 2) - return blockIcon3; - return this.blockIcon; + public IIcon getIcon(int side, int metadata) { + metadata += side; + if (metadata % 3 == 1) + return blockIcon2; + if (metadata % 3 == 2) + return blockIcon3; + return this.blockIcon; } - + @Override - public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int i, int j, int k){ - return null; + public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int i, int j, int k) { + return null; } - + @Override - public AxisAlignedBB getSelectedBoundingBoxFromPool(World par1World, int par2, int par3, int par4){ - return AxisAlignedBB.getBoundingBox(par2, par3, par4 , par2, par3, par4 ); + public AxisAlignedBB getSelectedBoundingBoxFromPool(World par1World, int par2, int par3, int par4) { + return AxisAlignedBB.getBoundingBox(par2, par3, par4, par2, par3, par4); } - + @Override - public boolean renderAsNormalBlock(){ + public boolean renderAsNormalBlock() { return false; - } - + } + @SideOnly(Side.CLIENT) @Override - public void registerBlockIcons(IIconRegister par1IconRegister){ + public void registerBlockIcons(IIconRegister par1IconRegister) { this.blockIcon = par1IconRegister.registerIcon(this.getTextureName()); this.blockIcon2 = par1IconRegister.registerIcon(getTextureName() + "2"); this.blockIcon3 = par1IconRegister.registerIcon(getTextureName() + "3"); } @Override - public boolean shouldSideBeRendered(IBlockAccess world, int par2, int par3, int par4, int par5){ + public boolean shouldSideBeRendered(IBlockAccess world, int par2, int par3, int par4, int par5) { Block block = world.getBlock(par2, par3, par4); return block != Blocks.air && block.renderAsNormalBlock(); //only render the side if a block is adjacent } - + @Override - public boolean isOpaqueCube(){ + public boolean isOpaqueCube() { return false; } - @Override - public int getRenderBlockPass(){ + @Override + public int getRenderBlockPass() { return 1; } - + @Override - public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLivingBase par5EntityLiving, ItemStack item){ - int var6 = MathHelper.floor_double((double)(par5EntityLiving.rotationYaw / 90.0F) + 0.5D) & 3; + public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLivingBase par5EntityLiving, ItemStack item) { + int var6 = MathHelper.floor_double((double) (par5EntityLiving.rotationYaw / 90.0F) + 0.5D) & 3; par1World.setBlockMetadataWithNotify(par2, par3, par4, var6, 2); //add metadata based on player rotation } - - public int getRenderType(){ - return renderId; + + public int getRenderType() { + return renderId; } } diff --git a/src/main/java/noppes/npcs/blocks/BlockBook.java b/src/main/java/noppes/npcs/blocks/BlockBook.java index da673fe96..affe1286a 100644 --- a/src/main/java/noppes/npcs/blocks/BlockBook.java +++ b/src/main/java/noppes/npcs/blocks/BlockBook.java @@ -14,35 +14,35 @@ import noppes.npcs.CustomItems; import noppes.npcs.CustomNpcsPermissions; import noppes.npcs.blocks.tiles.TileBook; -public class BlockBook extends BlockRotated{ +public class BlockBook extends BlockRotated { - public BlockBook() { + public BlockBook() { super(Blocks.planks); setBlockBounds(0, 0, 0, 1, 0.2f, 1); - } + } @Override - public boolean onBlockActivated(World par1World, int i, int j, int k, EntityPlayer player, int par6, float par7, float par8, float par9){ - if(par1World.isRemote) - return true; - TileEntity tile = par1World.getTileEntity(i, j, k); - if(!(tile instanceof TileBook)) - return false; - ItemStack currentItem = player.inventory.getCurrentItem(); - if (currentItem != null && currentItem.getItem() == CustomItems.wand && CustomNpcsPermissions.hasPermission(player, CustomNpcsPermissions.EDIT_BOOK)) { - ((TileBook)tile).book.func_150996_a(Items.writable_book); - } - PacketHandler.Instance.sendToPlayer(new GuiOpenBookPacket(i, j, k, ((TileBook)tile).book.writeToNBT(new NBTTagCompound())), (EntityPlayerMP) player); + public boolean onBlockActivated(World par1World, int i, int j, int k, EntityPlayer player, int par6, float par7, float par8, float par9) { + if (par1World.isRemote) + return true; + TileEntity tile = par1World.getTileEntity(i, j, k); + if (!(tile instanceof TileBook)) + return false; + ItemStack currentItem = player.inventory.getCurrentItem(); + if (currentItem != null && currentItem.getItem() == CustomItems.wand && CustomNpcsPermissions.hasPermission(player, CustomNpcsPermissions.EDIT_BOOK)) { + ((TileBook) tile).book.func_150996_a(Items.writable_book); + } + PacketHandler.Instance.sendToPlayer(new GuiOpenBookPacket(i, j, k, ((TileBook) tile).book.writeToNBT(new NBTTagCompound())), (EntityPlayerMP) player); return true; } @Override - public String getUnlocalizedName(){ - return "item.book"; + public String getUnlocalizedName() { + return "item.book"; } - @Override - public TileEntity createNewTileEntity(World var1, int var2) { - return new TileBook(); - } + @Override + public TileEntity createNewTileEntity(World var1, int var2) { + return new TileBook(); + } } diff --git a/src/main/java/noppes/npcs/blocks/BlockBorder.java b/src/main/java/noppes/npcs/blocks/BlockBorder.java index 52c6b2c94..3781b9c72 100644 --- a/src/main/java/noppes/npcs/blocks/BlockBorder.java +++ b/src/main/java/noppes/npcs/blocks/BlockBorder.java @@ -18,86 +18,85 @@ import noppes.npcs.CustomNpcs; import noppes.npcs.blocks.tiles.TileBorder; import noppes.npcs.constants.EnumGuiType; -public class BlockBorder extends BlockContainer{ - public int renderId = -1; +public class BlockBorder extends BlockContainer { + public int renderId = -1; - public BlockBorder() { - super(Material.rock); - setBlockUnbreakable(); - } + public BlockBorder() { + super(Material.rock); + setBlockUnbreakable(); + } - @Override + @Override @SideOnly(Side.CLIENT) - public IIcon getIcon(int side, int meta) - { - if(side == 1){ - return this.blockIcon; - } - return Blocks.iron_block.getIcon(side, meta); + public IIcon getIcon(int side, int meta) { + if (side == 1) { + return this.blockIcon; + } + return Blocks.iron_block.getIcon(side, meta); } - @Override - public boolean onBlockActivated(World par1World, int i, int j, int k, EntityPlayer player, int par6, float par7, float par8, float par9) - { - ItemStack currentItem = player.inventory.getCurrentItem(); - if (currentItem != null && currentItem.getItem() == CustomItems.wand) { - CustomNpcs.proxy.openGui(i, j, k, EnumGuiType.Border, player); - return true; - } - return false; + + @Override + public boolean onBlockActivated(World par1World, int i, int j, int k, EntityPlayer player, int par6, float par7, float par8, float par9) { + ItemStack currentItem = player.inventory.getCurrentItem(); + if (currentItem != null && currentItem.getItem() == CustomItems.wand) { + CustomNpcs.proxy.openGui(i, j, k, EnumGuiType.Border, player); + return true; + } + return false; } - - @Override - public void onBlockPlacedBy(World par1World, int x, int y, int z, EntityLivingBase par5EntityLivingBase, ItemStack par6ItemStack){ - int l = MathHelper.floor_double((double)(par5EntityLivingBase.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3; + + @Override + public void onBlockPlacedBy(World par1World, int x, int y, int z, EntityLivingBase par5EntityLivingBase, ItemStack par6ItemStack) { + int l = MathHelper.floor_double((double) (par5EntityLivingBase.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3; l %= 4; TileBorder tile = (TileBorder) par1World.getTileEntity(x, y, z); - TileBorder adjacent = getTile(par1World, x - 1, y, z); - if(adjacent == null) - adjacent = getTile(par1World, x, y, z - 1); - if(adjacent == null) - adjacent = getTile(par1World, x, y, z + 1); - if(adjacent == null) - adjacent = getTile(par1World, x + 1, y, z); - - if(adjacent != null){ - NBTTagCompound compound = new NBTTagCompound(); - adjacent.writeExtraNBT(compound); - tile.readExtraNBT(compound); - } - - tile.rotation = l; - - if(par5EntityLivingBase instanceof EntityPlayer && par1World.isRemote){ - CustomNpcs.proxy.openGui(x, y, z, EnumGuiType.Border, (EntityPlayer) par5EntityLivingBase); - } + TileBorder adjacent = getTile(par1World, x - 1, y, z); + if (adjacent == null) + adjacent = getTile(par1World, x, y, z - 1); + if (adjacent == null) + adjacent = getTile(par1World, x, y, z + 1); + if (adjacent == null) + adjacent = getTile(par1World, x + 1, y, z); + + if (adjacent != null) { + NBTTagCompound compound = new NBTTagCompound(); + adjacent.writeExtraNBT(compound); + tile.readExtraNBT(compound); + } + + tile.rotation = l; + + if (par5EntityLivingBase instanceof EntityPlayer && par1World.isRemote) { + CustomNpcs.proxy.openGui(x, y, z, EnumGuiType.Border, (EntityPlayer) par5EntityLivingBase); + } } - - private TileBorder getTile(World world, int x, int y, int z){ - TileEntity tile = world.getTileEntity(x, y, z); - if(tile != null && tile instanceof TileBorder) - return (TileBorder) tile; - return null; + + private TileBorder getTile(World world, int x, int y, int z) { + TileEntity tile = world.getTileEntity(x, y, z); + if (tile != null && tile instanceof TileBorder) + return (TileBorder) tile; + return null; } - - @Override - public int getRenderType(){ - return renderId; - } - @Override - public boolean isOpaqueCube(){ - return false; - } + @Override + public int getRenderType() { + return renderId; + } - @Override - public boolean renderAsNormalBlock(){ - return false; - } + @Override + public boolean isOpaqueCube() { + return false; + } - @Override - public TileEntity createNewTileEntity(World var1, int var2) { - return new TileBorder(); - } + @Override + public boolean renderAsNormalBlock() { + return false; + } + + @Override + public TileEntity createNewTileEntity(World var1, int var2) { + return new TileBorder(); + } } diff --git a/src/main/java/noppes/npcs/blocks/BlockCampfire.java b/src/main/java/noppes/npcs/blocks/BlockCampfire.java index 9b858ae96..11b520b2e 100644 --- a/src/main/java/noppes/npcs/blocks/BlockCampfire.java +++ b/src/main/java/noppes/npcs/blocks/BlockCampfire.java @@ -21,100 +21,99 @@ import org.lwjgl.opengl.GL11; import java.util.Random; -public class BlockCampfire extends BlockLightable{ +public class BlockCampfire extends BlockLightable { - public BlockCampfire(boolean lit) { + public BlockCampfire(boolean lit) { super(Blocks.cobblestone, lit); setBlockBounds(0, 0, 0, 1, 0.5f, 1); - if(lit) - setLightLevel(0.9375F); - } - - @Override - public TileEntity createNewTileEntity(World var1, int var2) { - return new TileCampfire(); - } - - @Override - public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9){ - ItemStack item = player.inventory.getCurrentItem(); - if(item == null) - return true; - int meta = world.getBlockMetadata(x, y, z); - - if((item.getItem() == Items.flint || item.getItem() == Items.flint_and_steel) && unlitBlock() == this){ - super.onBlockActivated(world, x, y, z, player, par6, par7, par8, par9); - CustomNpcs.proxy.spawnParticle("largesmoke", x + 0.5f, y + 0.5f, z + 0.5f, 0.0D, 0.0D, 0.0D, 2); - if(item.getItem() == Items.flint) - NoppesUtilServer.consumeItemStack(1, player); - else - item.damageItem(1, player); - return true; - } - - if(item.getItem() == Item.getItemFromBlock(Blocks.sand) && litBlock() == this){ - super.onBlockActivated(world, x, y, z, player, par6, par7, par8, par9); - } - - return true; + if (lit) + setLightLevel(0.9375F); } - @Override - public int maxRotation(){ - return 8; + @Override + public TileEntity createNewTileEntity(World var1, int var2) { + return new TileCampfire(); + } + + @Override + public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9) { + ItemStack item = player.inventory.getCurrentItem(); + if (item == null) + return true; + int meta = world.getBlockMetadata(x, y, z); + + if ((item.getItem() == Items.flint || item.getItem() == Items.flint_and_steel) && unlitBlock() == this) { + super.onBlockActivated(world, x, y, z, player, par6, par7, par8, par9); + CustomNpcs.proxy.spawnParticle("largesmoke", x + 0.5f, y + 0.5f, z + 0.5f, 0.0D, 0.0D, 0.0D, 2); + if (item.getItem() == Items.flint) + NoppesUtilServer.consumeItemStack(1, player); + else + item.damageItem(1, player); + return true; + } + + if (item.getItem() == Item.getItemFromBlock(Blocks.sand) && litBlock() == this) { + super.onBlockActivated(world, x, y, z, player, par6, par7, par8, par9); + } + + return true; + } + + @Override + public int maxRotation() { + return 8; } @SideOnly(Side.CLIENT) @Override - public void registerBlockIcons(IIconRegister par1IconRegister){ + public void registerBlockIcons(IIconRegister par1IconRegister) { this.blockIcon = par1IconRegister.registerIcon(this.getTextureName()); } @Override @SideOnly(Side.CLIENT) - public IIcon getIcon(int p_149691_1_, int meta){ + public IIcon getIcon(int p_149691_1_, int meta) { return this.blockIcon; } @Override @SideOnly(Side.CLIENT) - public void randomDisplayTick(World world, int x, int y, int z, Random random){ + public void randomDisplayTick(World world, int x, int y, int z, Random random) { int meta = world.getBlockMetadata(x, y, z); - if(meta == 1) - return; + if (meta == 1) + return; - if(random.nextInt(36) == 0){ - world.playSound(x + 0.5F, y + 0.5F, z + 0.5F, "fire.fire", 1.0F + random.nextFloat(), 0.3F + random.nextFloat() * 0.7f , false); - } + if (random.nextInt(36) == 0) { + world.playSound(x + 0.5F, y + 0.5F, z + 0.5F, "fire.fire", 1.0F + random.nextFloat(), 0.3F + random.nextFloat() * 0.7f, false); + } - TileCampfire tile = (TileCampfire) world.getTileEntity(x, y, z); + TileCampfire tile = (TileCampfire) world.getTileEntity(x, y, z); - float xOffset = 0.5f, yOffset = 0.7f, zOffset = 0.5f; + float xOffset = 0.5f, yOffset = 0.7f, zOffset = 0.5f; - double d0 = (double)((float)x + xOffset); - double d1 = (double)((float)y + yOffset); - double d2 = (double)((float)z + zOffset); + double d0 = (double) ((float) x + xOffset); + double d1 = (double) ((float) y + yOffset); + double d2 = (double) ((float) z + zOffset); GL11.glPushMatrix(); - if(ConfigClient.LegacyCampfire){ + if (ConfigClient.LegacyCampfire) { CustomNpcs.proxy.spawnParticle("largesmoke", d0, d1, d2, 0.0D, 0.0D, 0.0D, 2); CustomNpcs.proxy.spawnParticle("flame", d0, d1, d2, 0.0D, 0.0D, 0.0D, 4); - } - else { + } else { tile.updateEntity(); } GL11.glPopMatrix(); } - @Override - public Block unlitBlock() { - return CustomItems.campfire_unlit; - } + @Override + public Block unlitBlock() { + return CustomItems.campfire_unlit; + } - @Override - public Block litBlock() { - return CustomItems.campfire; - } + @Override + public Block litBlock() { + return CustomItems.campfire; + } } diff --git a/src/main/java/noppes/npcs/blocks/BlockCandle.java b/src/main/java/noppes/npcs/blocks/BlockCandle.java index 10502b7b6..401b36897 100644 --- a/src/main/java/noppes/npcs/blocks/BlockCandle.java +++ b/src/main/java/noppes/npcs/blocks/BlockCandle.java @@ -15,155 +15,153 @@ import noppes.npcs.blocks.tiles.TileVariant; import java.util.Random; -public class BlockCandle extends BlockLightable{ +public class BlockCandle extends BlockLightable { - public BlockCandle(boolean lit) { + public BlockCandle(boolean lit) { super(Blocks.stone, lit); setBlockBounds(0.3f, 0, 0.3f, 0.7f, 0.5f, 0.7f); - } - - @Override - public int maxRotation(){ - return 8; } - @Override - public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z){ - TileEntity tileentity = world.getTileEntity(x, y, z); - if(!(tileentity instanceof TileVariant)){ - super.setBlockBoundsBasedOnState(world, x, y, z); - return; - } - TileVariant tile = (TileVariant) tileentity; - if(tile.variant == 2){ - float xOffset = 0; - float yOffset = 0; - if(tile.rotation == 0) - yOffset = 0.2f; - else if(tile.rotation == 4) - yOffset = -0.2f; - else if(tile.rotation == 6) - xOffset = 0.2f; - else if(tile.rotation == 2) - xOffset = -0.2f; + @Override + public int maxRotation() { + return 8; + } + + @Override + public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z) { + TileEntity tileentity = world.getTileEntity(x, y, z); + if (!(tileentity instanceof TileVariant)) { + super.setBlockBoundsBasedOnState(world, x, y, z); + return; + } + TileVariant tile = (TileVariant) tileentity; + if (tile.variant == 2) { + float xOffset = 0; + float yOffset = 0; + if (tile.rotation == 0) + yOffset = 0.2f; + else if (tile.rotation == 4) + yOffset = -0.2f; + else if (tile.rotation == 6) + xOffset = 0.2f; + else if (tile.rotation == 2) + xOffset = -0.2f; setBlockBounds(0.2f + xOffset, 0.4f, 0.2f + yOffset, 0.8f + xOffset, 0.9f, 0.8f + yOffset); - } - else if(tile.variant == 1) + } else if (tile.variant == 1) setBlockBounds(0.1f, 0.1f, 0.1f, 0.9f, 0.8f, 0.9f); - else + else setBlockBounds(0.3f, 0, 0.3f, 0.7f, 0.5f, 0.7f); } @Override - public int onBlockPlaced(World world, int x, int y, int z, int side, float p_149660_6_, float p_149660_7_, float p_149660_8_, int meta){ + public int onBlockPlaced(World world, int x, int y, int z, int side, float p_149660_6_, float p_149660_7_, float p_149660_8_, int meta) { return side; } @Override public void onPostBlockPlaced(World world, int x, int y, int z, int meta) { - TileCandle tile = (TileCandle) world.getTileEntity(x, y, z); - if(meta == 1) - tile.variant = 0; - else if(meta == 0) - tile.variant = 1; - else{ - tile.variant = 2; - if(meta == 2) - tile.rotation = 0; - else if(meta == 3) - tile.rotation = 4; - else if(meta == 4) - tile.rotation = 6; - else if(meta == 5) - tile.rotation = 2; - } - world.setBlockMetadataWithNotify(x, y, z, 0, 4); + TileCandle tile = (TileCandle) world.getTileEntity(x, y, z); + if (meta == 1) + tile.variant = 0; + else if (meta == 0) + tile.variant = 1; + else { + tile.variant = 2; + if (meta == 2) + tile.rotation = 0; + else if (meta == 3) + tile.rotation = 4; + else if (meta == 4) + tile.rotation = 6; + else if (meta == 5) + tile.rotation = 2; + } + world.setBlockMetadataWithNotify(x, y, z, 0, 4); } + @SideOnly(Side.CLIENT) @Override - public void registerBlockIcons(IIconRegister par1IconRegister){ + public void registerBlockIcons(IIconRegister par1IconRegister) { this.blockIcon = par1IconRegister.registerIcon(this.getTextureName()); } @Override @SideOnly(Side.CLIENT) - public IIcon getIcon(int p_149691_1_, int meta){ + public IIcon getIcon(int p_149691_1_, int meta) { return this.blockIcon; } - @Override - public TileEntity createNewTileEntity(World var1, int var2) { - return new TileCandle(); - } - - @SideOnly(Side.CLIENT) - public void randomDisplayTick(World world, int x, int y, int z, Random p_149734_5_){ - if(this == unlitBlock()) - return; - TileCandle tile = (TileCandle) world.getTileEntity(x, y, z); - - if(tile.variant == 1){ - if(tile.rotation % 2 == 0){ - world.spawnParticle("smoke", x + 0.5f, y + 0.66f, z + 0.13f, 0.0D, 0.0D, 0.0D); - world.spawnParticle("flame", x + 0.5f, y + 0.65f, z + 0.13f, 0.0D, 0.0D, 0.0D); - - world.spawnParticle("smoke", x + 0.5f, y + 0.66f, z + 0.87f, 0.0D, 0.0D, 0.0D); - world.spawnParticle("flame", x + 0.5f, y + 0.65f, z + 0.87f, 0.0D, 0.0D, 0.0D); - - world.spawnParticle("smoke", x + 0.13f, y + 0.66f, z + 0.5f, 0.0D, 0.0D, 0.0D); - world.spawnParticle("flame", x + 0.13f, y + 0.65f, z + 0.5f, 0.0D, 0.0D, 0.0D); - - world.spawnParticle("smoke", x + 0.87f, y + 0.66f, z + 0.5f, 0.0D, 0.0D, 0.0D); - world.spawnParticle("flame", x + 0.87f, y + 0.65f, z + 0.5f, 0.0D, 0.0D, 0.0D); - } - else{ - world.spawnParticle("smoke", x + 0.24f, y + 0.66f, z + 0.24f, 0.0D, 0.0D, 0.0D); - world.spawnParticle("flame", x + 0.24f, y + 0.65f, z + 0.24f, 0.0D, 0.0D, 0.0D); - - world.spawnParticle("smoke", x + 0.76f, y + 0.66f, z + 0.76f, 0.0D, 0.0D, 0.0D); - world.spawnParticle("flame", x + 0.76f, y + 0.65f, z + 0.76f, 0.0D, 0.0D, 0.0D); - - world.spawnParticle("smoke", x + 0.24f, y + 0.66f, z + 0.76f, 0.0D, 0.0D, 0.0D); - world.spawnParticle("flame", x + 0.24f, y + 0.65f, z + 0.76f, 0.0D, 0.0D, 0.0D); - - world.spawnParticle("smoke", x + 0.76f, y + 0.66f, z + 0.24f, 0.0D, 0.0D, 0.0D); - world.spawnParticle("flame", x + 0.76f, y + 0.65f, z + 0.24f, 0.0D, 0.0D, 0.0D); - } - - } - else{ - float xOffset = 0.5f, yOffset = 0.45f, zOffset = 0.5f; - - if(tile.variant == 2){ - yOffset = 1.05f; - if(tile.rotation == 0) - zOffset += 0.12f; - if(tile.rotation == 4) - zOffset -= 0.12f; - if(tile.rotation == 6) - xOffset += 0.12f; - if(tile.rotation == 2) - xOffset -= 0.12f; - } - double d0 = (double)((float)x + xOffset); - double d1 = (double)((float)y + yOffset); - double d2 = (double)((float)z + zOffset); - - world.spawnParticle("smoke", d0, d1, d2, 0.0D, 0.0D, 0.0D); - world.spawnParticle("flame", d0, d1, d2, 0.0D, 0.0D, 0.0D); - } + @Override + public TileEntity createNewTileEntity(World var1, int var2) { + return new TileCandle(); } - @Override - public Block unlitBlock() { - return CustomItems.candle_unlit; - } + @SideOnly(Side.CLIENT) + public void randomDisplayTick(World world, int x, int y, int z, Random p_149734_5_) { + if (this == unlitBlock()) + return; + TileCandle tile = (TileCandle) world.getTileEntity(x, y, z); - @Override - public Block litBlock() { - return CustomItems.candle; - } + if (tile.variant == 1) { + if (tile.rotation % 2 == 0) { + world.spawnParticle("smoke", x + 0.5f, y + 0.66f, z + 0.13f, 0.0D, 0.0D, 0.0D); + world.spawnParticle("flame", x + 0.5f, y + 0.65f, z + 0.13f, 0.0D, 0.0D, 0.0D); + + world.spawnParticle("smoke", x + 0.5f, y + 0.66f, z + 0.87f, 0.0D, 0.0D, 0.0D); + world.spawnParticle("flame", x + 0.5f, y + 0.65f, z + 0.87f, 0.0D, 0.0D, 0.0D); + + world.spawnParticle("smoke", x + 0.13f, y + 0.66f, z + 0.5f, 0.0D, 0.0D, 0.0D); + world.spawnParticle("flame", x + 0.13f, y + 0.65f, z + 0.5f, 0.0D, 0.0D, 0.0D); + + world.spawnParticle("smoke", x + 0.87f, y + 0.66f, z + 0.5f, 0.0D, 0.0D, 0.0D); + world.spawnParticle("flame", x + 0.87f, y + 0.65f, z + 0.5f, 0.0D, 0.0D, 0.0D); + } else { + world.spawnParticle("smoke", x + 0.24f, y + 0.66f, z + 0.24f, 0.0D, 0.0D, 0.0D); + world.spawnParticle("flame", x + 0.24f, y + 0.65f, z + 0.24f, 0.0D, 0.0D, 0.0D); + + world.spawnParticle("smoke", x + 0.76f, y + 0.66f, z + 0.76f, 0.0D, 0.0D, 0.0D); + world.spawnParticle("flame", x + 0.76f, y + 0.65f, z + 0.76f, 0.0D, 0.0D, 0.0D); + + world.spawnParticle("smoke", x + 0.24f, y + 0.66f, z + 0.76f, 0.0D, 0.0D, 0.0D); + world.spawnParticle("flame", x + 0.24f, y + 0.65f, z + 0.76f, 0.0D, 0.0D, 0.0D); + + world.spawnParticle("smoke", x + 0.76f, y + 0.66f, z + 0.24f, 0.0D, 0.0D, 0.0D); + world.spawnParticle("flame", x + 0.76f, y + 0.65f, z + 0.24f, 0.0D, 0.0D, 0.0D); + } + + } else { + float xOffset = 0.5f, yOffset = 0.45f, zOffset = 0.5f; + + if (tile.variant == 2) { + yOffset = 1.05f; + if (tile.rotation == 0) + zOffset += 0.12f; + if (tile.rotation == 4) + zOffset -= 0.12f; + if (tile.rotation == 6) + xOffset += 0.12f; + if (tile.rotation == 2) + xOffset -= 0.12f; + } + double d0 = (double) ((float) x + xOffset); + double d1 = (double) ((float) y + yOffset); + double d2 = (double) ((float) z + zOffset); + + world.spawnParticle("smoke", d0, d1, d2, 0.0D, 0.0D, 0.0D); + world.spawnParticle("flame", d0, d1, d2, 0.0D, 0.0D, 0.0D); + } + } + + @Override + public Block unlitBlock() { + return CustomItems.candle_unlit; + } + + @Override + public Block litBlock() { + return CustomItems.candle; + } } diff --git a/src/main/java/noppes/npcs/blocks/BlockCarpentryBench.java b/src/main/java/noppes/npcs/blocks/BlockCarpentryBench.java index 32bd246ba..03f985961 100644 --- a/src/main/java/noppes/npcs/blocks/BlockCarpentryBench.java +++ b/src/main/java/noppes/npcs/blocks/BlockCarpentryBench.java @@ -22,42 +22,38 @@ import noppes.npcs.constants.EnumGuiType; import java.util.List; -public class BlockCarpentryBench extends BlockContainer -{ - public int renderId = -1; - public BlockCarpentryBench() - { +public class BlockCarpentryBench extends BlockContainer { + public int renderId = -1; + + public BlockCarpentryBench() { super(Material.rock); setStepSound(soundTypePiston); } @Override - public int getLightValue(IBlockAccess world, int x, int y, int z) - { + public int getLightValue(IBlockAccess world, int x, int y, int z) { Block block = world.getBlock(x, y, z); int meta = world.getBlockMetadata(x, y, z); - if (block != this) - { + if (block != this) { return block.getLightValue(world, x, y, z); } - if(meta >= 4) + if (meta >= 4) return 5; return getLightValue(); } @Override - public boolean onBlockActivated(World par1World, int i, int j, int k, EntityPlayer player, int par6, float par7, float par8, float par9) - { - if(!par1World.isRemote){ + public boolean onBlockActivated(World par1World, int i, int j, int k, EntityPlayer player, int par6, float par7, float par8, float par9) { + if (!par1World.isRemote) { int meta = par1World.getBlockMetadata(i, j, k); - if(meta >= 4){ + if (meta >= 4) { player.openGui(CustomNpcs.instance, EnumGuiType.PlayerAnvil.ordinal(), par1World, i, j, k); } else { player.openGui(CustomNpcs.instance, EnumGuiType.PlayerCarpentryBench.ordinal(), par1World, i, j, k); } - } - return true; + } + return true; } @Override @@ -71,6 +67,7 @@ public class BlockCarpentryBench extends BlockContainer { return renderId; } + /** * If this block doesn't render as an ordinary block it will return False (examples: signs, buttons, stairs, etc) */ @@ -82,35 +79,32 @@ public class BlockCarpentryBench extends BlockContainer @Override @SideOnly(Side.CLIENT) - public IIcon getIcon(int side, int meta) - { - if(meta >= 4){ + public IIcon getIcon(int side, int meta) { + if (meta >= 4) { return Blocks.anvil.getIcon(side, 0); } return Blocks.planks.getIcon(side, 0); } @Override - public int damageDropped(int par1) - { - return par1/4; + public int damageDropped(int par1) { + return par1 / 4; } @Override - public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List){ + public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) { par3List.add(new ItemStack(par1, 1, 0)); par3List.add(new ItemStack(par1, 1, 1)); } @Override - public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLivingBase par5EntityLiving, ItemStack item) - { - int var6 = MathHelper.floor_double((double)(par5EntityLiving.rotationYaw / 90.0F) + 0.5D) & 3; + public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLivingBase par5EntityLiving, ItemStack item) { + int var6 = MathHelper.floor_double((double) (par5EntityLiving.rotationYaw / 90.0F) + 0.5D) & 3; par1World.setBlockMetadataWithNotify(par2, par3, par4, var6 + item.getItemDamage() * 4, 2); } - @Override - public TileEntity createNewTileEntity(World var1, int var2) { - return new TileBlockAnvil(); - } + @Override + public TileEntity createNewTileEntity(World var1, int var2) { + return new TileBlockAnvil(); + } } diff --git a/src/main/java/noppes/npcs/blocks/BlockChair.java b/src/main/java/noppes/npcs/blocks/BlockChair.java index 4c63d0588..fbb77e716 100644 --- a/src/main/java/noppes/npcs/blocks/BlockChair.java +++ b/src/main/java/noppes/npcs/blocks/BlockChair.java @@ -19,17 +19,17 @@ import noppes.npcs.items.ItemNpcTool; import java.util.List; -public class BlockChair extends BlockRotated{ +public class BlockChair extends BlockRotated { - public BlockChair() { + public BlockChair() { super(Blocks.planks); setBlockBounds(0.1f, 0, 0.1f, 0.9f, 1, 0.9f); - } + } @Override - public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLivingBase par5EntityLivingBase, ItemStack par6ItemStack){ - super.onBlockPlacedBy(par1World, par2, par3, par4, par5EntityLivingBase, par6ItemStack); - par1World.setBlockMetadataWithNotify(par2, par3, par4, par6ItemStack.getItemDamage() , 2); + public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLivingBase par5EntityLivingBase, ItemStack par6ItemStack) { + super.onBlockPlacedBy(par1World, par2, par3, par4, par5EntityLivingBase, par6ItemStack); + par1World.setBlockMetadataWithNotify(par2, par3, par4, par6ItemStack.getItemDamage(), 2); } public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, int y, int z) { @@ -37,7 +37,7 @@ public class BlockChair extends BlockRotated{ if (te instanceof TileChair && ((TileChair) te).isPushed()) { // Use the rotation to set a vertical slab hitbox on the pushed side. int rotation = ((TileVariant) te).rotation; - switch(rotation) { + switch (rotation) { case 0: // North: slab from z to z+0.3. return AxisAlignedBB.getBoundingBox(x + 0.1, y, z, x + 0.9, y + 1, z + 0.3); case 1: // East: slab from x+0.7 to x+1. @@ -88,10 +88,8 @@ public class BlockChair extends BlockRotated{ } - - @Override - public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List){ + public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) { par3List.add(new ItemStack(par1, 1, 0)); par3List.add(new ItemStack(par1, 1, 1)); par3List.add(new ItemStack(par1, 1, 2)); @@ -101,19 +99,19 @@ public class BlockChair extends BlockRotated{ } @Override - public int damageDropped(int par1){ + public int damageDropped(int par1) { return par1; } - @Override - public TileEntity createNewTileEntity(World var1, int var2) { - return new TileChair(); - } + @Override + public TileEntity createNewTileEntity(World var1, int var2) { + return new TileChair(); + } - @Override - public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int p_149727_6_, float p_149727_7_, float p_149727_8_, float p_149727_9_){ + @Override + public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int p_149727_6_, float p_149727_7_, float p_149727_8_, float p_149727_9_) { ItemStack item = player.inventory.getCurrentItem(); - if(item != null && item.getItem() != null && item.getItem() instanceof ItemNpcTool) + if (item != null && item.getItem() != null && item.getItem() instanceof ItemNpcTool) return false; return MountBlock(world, x, y, z, player); diff --git a/src/main/java/noppes/npcs/blocks/BlockCouchWood.java b/src/main/java/noppes/npcs/blocks/BlockCouchWood.java index 587fe938c..1edf0be15 100644 --- a/src/main/java/noppes/npcs/blocks/BlockCouchWood.java +++ b/src/main/java/noppes/npcs/blocks/BlockCouchWood.java @@ -21,23 +21,24 @@ import noppes.npcs.blocks.tiles.TileCouchWood; import java.util.List; -public class BlockCouchWood extends BlockContainer{ +public class BlockCouchWood extends BlockContainer { - public int renderId = -1; + public int renderId = -1; public BlockCouchWood() { super(Material.wood); - } - @Override - public boolean onBlockActivated(World par1World, int i, int j, int k, EntityPlayer player, int par6, float par7, float par8, float par9){ - ItemStack item = player.inventory.getCurrentItem(); - if(item == null) - return BlockChair.MountBlock(par1World, i, j, k, player); - return true; } @Override - public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List){ + public boolean onBlockActivated(World par1World, int i, int j, int k, EntityPlayer player, int par6, float par7, float par8, float par9) { + ItemStack item = player.inventory.getCurrentItem(); + if (item == null) + return BlockChair.MountBlock(par1World, i, j, k, player); + return true; + } + + @Override + public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) { par3List.add(new ItemStack(par1, 1, 0)); par3List.add(new ItemStack(par1, 1, 1)); par3List.add(new ItemStack(par1, 1, 2)); @@ -47,104 +48,101 @@ public class BlockCouchWood extends BlockContainer{ } @Override - public int damageDropped(int par1) - { + public int damageDropped(int par1) { return par1; } - public AxisAlignedBB getCollisionBoundingBoxFromPool(World p_149668_1_, int x, int y, int z){ + + public AxisAlignedBB getCollisionBoundingBoxFromPool(World p_149668_1_, int x, int y, int z) { return AxisAlignedBB.getBoundingBox(x, y, z, x + 1, y + 0.5, z + 1); } @Override - public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLivingBase par5EntityLivingBase, ItemStack par6ItemStack) - { - int l = MathHelper.floor_double((double)(par5EntityLivingBase.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3; + public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLivingBase par5EntityLivingBase, ItemStack par6ItemStack) { + int l = MathHelper.floor_double((double) (par5EntityLivingBase.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3; l %= 4; TileCouchWood tile = (TileCouchWood) par1World.getTileEntity(par2, par3, par4); - tile.rotation = l; + tile.rotation = l; par1World.setBlockMetadataWithNotify(par2, par3, par4, par6ItemStack.getItemDamage(), 2); - updateModel(par1World, par2, par3, par4, tile); + updateModel(par1World, par2, par3, par4, tile); onNeighborBlockChange(par1World, par2 + 1, par3, par4, this); onNeighborBlockChange(par1World, par2 - 1, par3, par4, this); onNeighborBlockChange(par1World, par2, par3, par4 + 1, this); onNeighborBlockChange(par1World, par2, par3, par4 - 1, this); - updateModel(par1World, par2, par3, par4, tile); + updateModel(par1World, par2, par3, par4, tile); par1World.markBlockForUpdate(par2, par3, par4); } @Override public void onNeighborBlockChange(World worldObj, int x, int y, int z, Block block) { - if(worldObj.isRemote || block != this) - return; - TileEntity tile = worldObj.getTileEntity(x, y, z); - if(tile == null || !(tile instanceof TileCouchWood)) - return; - updateModel(worldObj, x, y, z, (TileCouchWood) tile); - worldObj.markBlockForUpdate(x, y, z); + if (worldObj.isRemote || block != this) + return; + TileEntity tile = worldObj.getTileEntity(x, y, z); + if (tile == null || !(tile instanceof TileCouchWood)) + return; + updateModel(worldObj, x, y, z, (TileCouchWood) tile); + worldObj.markBlockForUpdate(x, y, z); } - private void updateModel(World world, int x, int y, int z, TileCouchWood tile){ - if(world.isRemote) - return; - int meta = tile.getBlockMetadata(); - if(tile.rotation == 0){ - tile.hasLeft = compareTiles(tile, x - 1, y, z, world, meta); - tile.hasRight = compareTiles(tile, x + 1, y, z, world, meta); - } - else if(tile.rotation == 2){ - tile.hasLeft = compareTiles(tile, x + 1, y, z, world, meta); - tile.hasRight = compareTiles(tile, x - 1, y, z, world, meta); - } - else if(tile.rotation == 1){ - tile.hasLeft = compareTiles(tile, x, y, z - 1, world, meta); - tile.hasRight = compareTiles(tile, x, y, z + 1, world, meta); - } - else if(tile.rotation == 3){ - tile.hasLeft = compareTiles(tile, x, y, z + 1, world, meta); - tile.hasRight = compareTiles(tile, x, y, z - 1, world, meta); - } + private void updateModel(World world, int x, int y, int z, TileCouchWood tile) { + if (world.isRemote) + return; + int meta = tile.getBlockMetadata(); + if (tile.rotation == 0) { + tile.hasLeft = compareTiles(tile, x - 1, y, z, world, meta); + tile.hasRight = compareTiles(tile, x + 1, y, z, world, meta); + } else if (tile.rotation == 2) { + tile.hasLeft = compareTiles(tile, x + 1, y, z, world, meta); + tile.hasRight = compareTiles(tile, x - 1, y, z, world, meta); + } else if (tile.rotation == 1) { + tile.hasLeft = compareTiles(tile, x, y, z - 1, world, meta); + tile.hasRight = compareTiles(tile, x, y, z + 1, world, meta); + } else if (tile.rotation == 3) { + tile.hasLeft = compareTiles(tile, x, y, z + 1, world, meta); + tile.hasRight = compareTiles(tile, x, y, z - 1, world, meta); + } } - private boolean compareTiles(TileCouchWood tile, int x, int y, int z, World world, int meta){ - int meta2 = world.getBlockMetadata(x, y, z); - if(meta2 != meta) - return false; - TileEntity tile2 = world.getTileEntity(x, y, z); - if(tile2 == null || !(tile2 instanceof TileCouchWood)) - return false; - TileCouchWood couch = (TileCouchWood) tile2; - return tile.rotation == couch.rotation; + + private boolean compareTiles(TileCouchWood tile, int x, int y, int z, World world, int meta) { + int meta2 = world.getBlockMetadata(x, y, z); + if (meta2 != meta) + return false; + TileEntity tile2 = world.getTileEntity(x, y, z); + if (tile2 == null || !(tile2 instanceof TileCouchWood)) + return false; + TileCouchWood couch = (TileCouchWood) tile2; + return tile.rotation == couch.rotation; } @Override - public boolean isOpaqueCube(){ - return false; - } + public boolean isOpaqueCube() { + return false; + } @Override - public boolean renderAsNormalBlock(){ - return false; - } + public boolean renderAsNormalBlock() { + return false; + } + @Override - public int getRenderType(){ - return renderId; - } + public int getRenderType() { + return renderId; + } @Override @SideOnly(Side.CLIENT) - public void registerBlockIcons(IIconRegister par1IconRegister) - { + public void registerBlockIcons(IIconRegister par1IconRegister) { } + @Override @SideOnly(Side.CLIENT) - public IIcon getIcon(int p_149691_1_, int meta) - { + public IIcon getIcon(int p_149691_1_, int meta) { return Blocks.planks.getIcon(p_149691_1_, meta); } - @Override - public TileEntity createNewTileEntity(World var1, int var2) { - return new TileCouchWood(); - } + @Override + public TileEntity createNewTileEntity(World var1, int var2) { + return new TileCouchWood(); + } } diff --git a/src/main/java/noppes/npcs/blocks/BlockCouchWool.java b/src/main/java/noppes/npcs/blocks/BlockCouchWool.java index d78bdfc7f..e4dab7c57 100644 --- a/src/main/java/noppes/npcs/blocks/BlockCouchWool.java +++ b/src/main/java/noppes/npcs/blocks/BlockCouchWool.java @@ -31,35 +31,36 @@ import static noppes.npcs.items.ItemNpcTool.BRUSH_COLOR_TAG; public class BlockCouchWool extends BlockContainer { - public int renderId = -1; + public int renderId = -1; public BlockCouchWool() { super(Material.wood); - } - @Override - public boolean onBlockActivated(World par1World, int i, int j, int k, EntityPlayer player, int par6, float par7, float par8, float par9){ - ItemStack item = player.inventory.getCurrentItem(); - TileColorable.ColorChangeType colorChangeType = TileColorable.allowColorChange(item); - if(colorChangeType == TileColorable.ColorChangeType.NONE) - return BlockChair.MountBlock(par1World, i, j, k, player); - else if(colorChangeType == TileColorable.ColorChangeType.PAINTBRUSH) - return false; - - int meta = par1World.getBlockMetadata(i, j, k); - if(meta >= 7) - j--; - TileColorable tile = (TileColorable) par1World.getTileEntity(i, j, k); - int color = colorTableInts[BlockColored.func_150031_c(item.getItemDamage())]; - if(tile.color != color){ - NoppesUtilServer.consumeItemStack(1, player); - tile.color = color; - par1World.markBlockForUpdate(i, j, k); - } - return true; } @Override - public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List){ + public boolean onBlockActivated(World par1World, int i, int j, int k, EntityPlayer player, int par6, float par7, float par8, float par9) { + ItemStack item = player.inventory.getCurrentItem(); + TileColorable.ColorChangeType colorChangeType = TileColorable.allowColorChange(item); + if (colorChangeType == TileColorable.ColorChangeType.NONE) + return BlockChair.MountBlock(par1World, i, j, k, player); + else if (colorChangeType == TileColorable.ColorChangeType.PAINTBRUSH) + return false; + + int meta = par1World.getBlockMetadata(i, j, k); + if (meta >= 7) + j--; + TileColorable tile = (TileColorable) par1World.getTileEntity(i, j, k); + int color = colorTableInts[BlockColored.func_150031_c(item.getItemDamage())]; + if (tile.color != color) { + NoppesUtilServer.consumeItemStack(1, player); + tile.color = color; + par1World.markBlockForUpdate(i, j, k); + } + return true; + } + + @Override + public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) { par3List.add(new ItemStack(par1, 1, 0)); par3List.add(new ItemStack(par1, 1, 1)); par3List.add(new ItemStack(par1, 1, 2)); @@ -69,134 +70,132 @@ public class BlockCouchWool extends BlockContainer { } @Override - public int damageDropped(int par1) - { + public int damageDropped(int par1) { return par1; } - public AxisAlignedBB getCollisionBoundingBoxFromPool(World p_149668_1_, int x, int y, int z){ + + public AxisAlignedBB getCollisionBoundingBoxFromPool(World p_149668_1_, int x, int y, int z) { return AxisAlignedBB.getBoundingBox(x, y, z, x + 1, y + 0.5, z + 1); } @Override - public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLivingBase par5EntityLivingBase, ItemStack itemStack) - { - int l = MathHelper.floor_double((double)(par5EntityLivingBase.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3; + public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLivingBase par5EntityLivingBase, ItemStack itemStack) { + int l = MathHelper.floor_double((double) (par5EntityLivingBase.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3; l %= 4; TileCouchWool tile = (TileCouchWool) par1World.getTileEntity(par2, par3, par4); tile.rotation = l; tile.color = colorTableInts[15 - itemStack.getItemDamage()]; - if(itemStack.hasTagCompound() && itemStack.getTagCompound().hasKey(BRUSH_COLOR_TAG)){ + if (itemStack.hasTagCompound() && itemStack.getTagCompound().hasKey(BRUSH_COLOR_TAG)) { tile.color = itemStack.getTagCompound().getInteger(BRUSH_COLOR_TAG); } par1World.setBlockMetadataWithNotify(par2, par3, par4, itemStack.getItemDamage(), 2); - updateModel(par1World, par2, par3, par4, tile); + updateModel(par1World, par2, par3, par4, tile); onNeighborBlockChange(par1World, par2 + 1, par3, par4, this); onNeighborBlockChange(par1World, par2 - 1, par3, par4, this); onNeighborBlockChange(par1World, par2, par3, par4 + 1, this); onNeighborBlockChange(par1World, par2, par3, par4 - 1, this); - updateModel(par1World, par2, par3, par4, tile); + updateModel(par1World, par2, par3, par4, tile); par1World.markBlockForUpdate(par2, par3, par4); } @Override public void onNeighborBlockChange(World worldObj, int x, int y, int z, Block block) { - if(worldObj.isRemote || block != this) - return; - TileEntity tile = worldObj.getTileEntity(x, y, z); - if(tile == null || !(tile instanceof TileCouchWool)) - return; - updateModel(worldObj, x, y, z, (TileCouchWool) tile); - worldObj.markBlockForUpdate(x, y, z); + if (worldObj.isRemote || block != this) + return; + TileEntity tile = worldObj.getTileEntity(x, y, z); + if (tile == null || !(tile instanceof TileCouchWool)) + return; + updateModel(worldObj, x, y, z, (TileCouchWool) tile); + worldObj.markBlockForUpdate(x, y, z); } - private void updateModel(World world, int x, int y, int z, TileCouchWool tile){ - if(world.isRemote) - return; - int meta = tile.getBlockMetadata(); - if(tile.rotation == 0){ - tile.hasCornerLeft = compareCornerTiles(tile, x, y, z - 1, world, meta, true); - tile.hasCornerRight = compareCornerTiles(tile, x, y, z - 1, world, meta, false); - tile.hasLeft = compareTiles(tile, x - 1, y, z, world, meta); - tile.hasRight = compareTiles(tile, x + 1, y, z, world, meta); - } - else if(tile.rotation == 2){ - tile.hasCornerLeft = compareCornerTiles(tile, x, y, z + 1, world, meta, true); - tile.hasCornerRight = compareCornerTiles(tile, x, y, z + 1, world, meta, false); - tile.hasLeft = compareTiles(tile, x + 1, y, z, world, meta); - tile.hasRight = compareTiles(tile, x - 1, y, z, world, meta); - } - else if(tile.rotation == 1){ - tile.hasCornerLeft = compareCornerTiles(tile, x + 1, y, z, world, meta, true); - tile.hasCornerRight = compareCornerTiles(tile, x + 1, y, z, world, meta, false); - tile.hasLeft = compareTiles(tile, x, y, z - 1, world, meta); - tile.hasRight = compareTiles(tile, x, y, z + 1, world, meta); - } - else if(tile.rotation == 3){ - tile.hasCornerLeft = compareCornerTiles(tile, x - 1, y, z, world, meta, true); - tile.hasCornerRight = compareCornerTiles(tile, x - 1, y, z, world, meta, false); - tile.hasLeft = compareTiles(tile, x, y, z + 1, world, meta); - tile.hasRight = compareTiles(tile, x, y, z - 1, world, meta); - } + private void updateModel(World world, int x, int y, int z, TileCouchWool tile) { + if (world.isRemote) + return; + int meta = tile.getBlockMetadata(); + if (tile.rotation == 0) { + tile.hasCornerLeft = compareCornerTiles(tile, x, y, z - 1, world, meta, true); + tile.hasCornerRight = compareCornerTiles(tile, x, y, z - 1, world, meta, false); + tile.hasLeft = compareTiles(tile, x - 1, y, z, world, meta); + tile.hasRight = compareTiles(tile, x + 1, y, z, world, meta); + } else if (tile.rotation == 2) { + tile.hasCornerLeft = compareCornerTiles(tile, x, y, z + 1, world, meta, true); + tile.hasCornerRight = compareCornerTiles(tile, x, y, z + 1, world, meta, false); + tile.hasLeft = compareTiles(tile, x + 1, y, z, world, meta); + tile.hasRight = compareTiles(tile, x - 1, y, z, world, meta); + } else if (tile.rotation == 1) { + tile.hasCornerLeft = compareCornerTiles(tile, x + 1, y, z, world, meta, true); + tile.hasCornerRight = compareCornerTiles(tile, x + 1, y, z, world, meta, false); + tile.hasLeft = compareTiles(tile, x, y, z - 1, world, meta); + tile.hasRight = compareTiles(tile, x, y, z + 1, world, meta); + } else if (tile.rotation == 3) { + tile.hasCornerLeft = compareCornerTiles(tile, x - 1, y, z, world, meta, true); + tile.hasCornerRight = compareCornerTiles(tile, x - 1, y, z, world, meta, false); + tile.hasLeft = compareTiles(tile, x, y, z + 1, world, meta); + tile.hasRight = compareTiles(tile, x, y, z - 1, world, meta); + } } - private boolean compareCornerTiles(TileCouchWool tile, int x, int y, int z, World world, int meta, boolean isLeft){ - int meta2 = world.getBlockMetadata(x, y, z); + + private boolean compareCornerTiles(TileCouchWool tile, int x, int y, int z, World world, int meta, boolean isLeft) { + int meta2 = world.getBlockMetadata(x, y, z); // if(meta2 != meta) // return false; - TileEntity tile2 = world.getTileEntity(x , y, z); - int rotation = (tile.rotation + (!isLeft?1:3)) % 4; - return tile2 != null & tile2 instanceof TileCouchWool && ((TileCouchWool)tile2).rotation == rotation; + TileEntity tile2 = world.getTileEntity(x, y, z); + int rotation = (tile.rotation + (!isLeft ? 1 : 3)) % 4; + return tile2 != null & tile2 instanceof TileCouchWool && ((TileCouchWool) tile2).rotation == rotation; } - private boolean compareTiles(TileCouchWool tile, int x, int y, int z, World world, int meta){ - int meta2 = world.getBlockMetadata(x, y, z); + + private boolean compareTiles(TileCouchWool tile, int x, int y, int z, World world, int meta) { + int meta2 = world.getBlockMetadata(x, y, z); // if(meta2 != meta) // return false; - TileEntity tile2 = world.getTileEntity(x, y, z); - if(tile2 == null || !(tile2 instanceof TileCouchWool)) - return false; - TileCouchWool couch = (TileCouchWool) tile2; - int rotation = couch.rotation; - if(tile.rotation == rotation) - return true; - if(couch.hasCornerLeft) - rotation += 3; - else if(couch.hasCornerRight) - rotation += 1; - rotation %= 4; - return tile.rotation == rotation; + TileEntity tile2 = world.getTileEntity(x, y, z); + if (tile2 == null || !(tile2 instanceof TileCouchWool)) + return false; + TileCouchWool couch = (TileCouchWool) tile2; + int rotation = couch.rotation; + if (tile.rotation == rotation) + return true; + if (couch.hasCornerLeft) + rotation += 3; + else if (couch.hasCornerRight) + rotation += 1; + rotation %= 4; + return tile.rotation == rotation; } @Override - public boolean isOpaqueCube(){ - return false; - } + public boolean isOpaqueCube() { + return false; + } @Override - public boolean renderAsNormalBlock(){ - return false; - } + public boolean renderAsNormalBlock() { + return false; + } + @Override - public int getRenderType(){ - return renderId; - } + public int getRenderType() { + return renderId; + } @Override @SideOnly(Side.CLIENT) - public void registerBlockIcons(IIconRegister par1IconRegister) - { + public void registerBlockIcons(IIconRegister par1IconRegister) { } + @Override @SideOnly(Side.CLIENT) - public IIcon getIcon(int p_149691_1_, int meta) - { + public IIcon getIcon(int p_149691_1_, int meta) { return Blocks.planks.getIcon(p_149691_1_, meta); } - @Override - public TileEntity createNewTileEntity(World var1, int var2) { - return new TileCouchWool(); - } + @Override + public TileEntity createNewTileEntity(World var1, int var2) { + return new TileCouchWool(); + } @Override public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) { diff --git a/src/main/java/noppes/npcs/blocks/BlockCrate.java b/src/main/java/noppes/npcs/blocks/BlockCrate.java index dcbdaef16..ddd832dbf 100644 --- a/src/main/java/noppes/npcs/blocks/BlockCrate.java +++ b/src/main/java/noppes/npcs/blocks/BlockCrate.java @@ -16,23 +16,25 @@ import noppes.npcs.constants.EnumGuiType; import java.util.List; -public class BlockCrate extends BlockRotated{ +public class BlockCrate extends BlockRotated { - public BlockCrate() { + public BlockCrate() { super(Blocks.planks); //setBlockBounds(0f, 0, 0f, 1f, 0.75f, 1f); - } - @Override - public boolean onBlockActivated(World par1World, int i, int j, int k, EntityPlayer player, int par6, float par7, float par8, float par9){ - if(par1World.isRemote) - return true; - - par1World.playSoundEffect(i, j + 0.5D, k, "random.chestopen", 0.5F, par1World.rand.nextFloat() * 0.1F + 0.9F); - player.openGui(CustomNpcs.instance, EnumGuiType.Crate.ordinal(), par1World, i, j, k); - return true; } - @Override - public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List){ + + @Override + public boolean onBlockActivated(World par1World, int i, int j, int k, EntityPlayer player, int par6, float par7, float par8, float par9) { + if (par1World.isRemote) + return true; + + par1World.playSoundEffect(i, j + 0.5D, k, "random.chestopen", 0.5F, par1World.rand.nextFloat() * 0.1F + 0.9F); + player.openGui(CustomNpcs.instance, EnumGuiType.Crate.ordinal(), par1World, i, j, k); + return true; + } + + @Override + public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) { par3List.add(new ItemStack(par1, 1, 0)); par3List.add(new ItemStack(par1, 1, 1)); par3List.add(new ItemStack(par1, 1, 2)); @@ -41,28 +43,28 @@ public class BlockCrate extends BlockRotated{ par3List.add(new ItemStack(par1, 1, 5)); } - @Override - public int damageDropped(int par1){ + @Override + public int damageDropped(int par1) { return par1; } - @Override - public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLivingBase par5EntityLivingBase, ItemStack par6ItemStack){ - super.onBlockPlacedBy(par1World, par2, par3, par4, par5EntityLivingBase, par6ItemStack); - par1World.setBlockMetadataWithNotify(par2, par3, par4, par6ItemStack.getItemDamage() , 2); + @Override + public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLivingBase par5EntityLivingBase, ItemStack par6ItemStack) { + super.onBlockPlacedBy(par1World, par2, par3, par4, par5EntityLivingBase, par6ItemStack); + par1World.setBlockMetadataWithNotify(par2, par3, par4, par6ItemStack.getItemDamage(), 2); } - @Override - public TileEntity createNewTileEntity(World var1, int var2) { - return new TileCrate(); - } + @Override + public TileEntity createNewTileEntity(World var1, int var2) { + return new TileCrate(); + } - @Override - public void breakBlock(World world, int x, int y, int z, Block block, int p_149749_6_){ - TileNpcContainer tile = (TileNpcContainer)world.getTileEntity(x, y, z); + @Override + public void breakBlock(World world, int x, int y, int z, Block block, int p_149749_6_) { + TileNpcContainer tile = (TileNpcContainer) world.getTileEntity(x, y, z); if (tile == null) - return; + return; tile.dropItems(world, x, y, z); world.func_147453_f(x, y, z, block); diff --git a/src/main/java/noppes/npcs/blocks/BlockCrystal.java b/src/main/java/noppes/npcs/blocks/BlockCrystal.java index eae17c497..d6227b173 100644 --- a/src/main/java/noppes/npcs/blocks/BlockCrystal.java +++ b/src/main/java/noppes/npcs/blocks/BlockCrystal.java @@ -12,58 +12,59 @@ import net.minecraft.world.IBlockAccess; import java.util.List; -public class BlockCrystal extends BlockBreakable{ - - public BlockCrystal() { - super("customnpcs:npcCrystal",Material.glass, false); - setLightLevel(0.8f); - } +public class BlockCrystal extends BlockBreakable { + + public BlockCrystal() { + super("customnpcs:npcCrystal", Material.glass, false); + setLightLevel(0.8f); + } @Override - public boolean isOpaqueCube(){ + public boolean isOpaqueCube() { return false; } - - @Override - public boolean renderAsNormalBlock(){ - return false; - } @Override - public int getRenderBlockPass(){ + public boolean renderAsNormalBlock() { + return false; + } + + @Override + public int getRenderBlockPass() { return 1; } @Override - public int damageDropped(int meta){ + public int damageDropped(int meta) { return meta; } @Override @SideOnly(Side.CLIENT) - public void getSubBlocks(Item item, CreativeTabs tab, List list){ - for (int i = 0; i < 16; ++i){ - list.add(new ItemStack(item, 1, i)); + public void getSubBlocks(Item item, CreativeTabs tab, List list) { + for (int i = 0; i < 16; ++i) { + list.add(new ItemStack(item, 1, i)); } } @Override @SideOnly(Side.CLIENT) - public int colorMultiplier(IBlockAccess world, int x, int y, int z){ + public int colorMultiplier(IBlockAccess world, int x, int y, int z) { return getRenderColor(world.getBlockMetadata(x, y, z)); } @Override @SideOnly(Side.CLIENT) - public int getRenderColor(int meta){ + public int getRenderColor(int meta) { return MapColor.getMapColorForBlockColored(meta).colorValue; } - public MapColor getMapColor(int p_149728_1_){ + public MapColor getMapColor(int p_149728_1_) { return MapColor.getMapColorForBlockColored(p_149728_1_); } - @Override - public String getUnlocalizedName(){ - return "item.npcCrystal"; + + @Override + public String getUnlocalizedName() { + return "item.npcCrystal"; } } diff --git a/src/main/java/noppes/npcs/blocks/BlockLantern.java b/src/main/java/noppes/npcs/blocks/BlockLantern.java index fa7db3c4f..bf0b2f74d 100644 --- a/src/main/java/noppes/npcs/blocks/BlockLantern.java +++ b/src/main/java/noppes/npcs/blocks/BlockLantern.java @@ -13,95 +13,94 @@ import noppes.npcs.CustomItems; import noppes.npcs.blocks.tiles.TileLamp; import noppes.npcs.blocks.tiles.TileVariant; -public class BlockLantern extends BlockLightable{ +public class BlockLantern extends BlockLightable { - public BlockLantern(boolean lit) { + public BlockLantern(boolean lit) { super(Blocks.iron_block, lit); setBlockBounds(0.3f, 0, 0.3f, 0.7f, 0.6f, 0.7f); - } - - @Override - public int maxRotation(){ - return 8; } @Override - public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z){ - TileEntity tileentity = world.getTileEntity(x, y, z); - if(!(tileentity instanceof TileVariant)){ - super.setBlockBoundsBasedOnState(world, x, y, z); - return; - } - TileVariant tile = (TileVariant) tileentity; - if(tile.variant == 2){ - float xOffset = 0; - float yOffset = 0; - if(tile.rotation == 0) - yOffset = 0.2f; - else if(tile.rotation == 4) - yOffset = -0.2f; - else if(tile.rotation == 6) - xOffset = 0.2f; - else if(tile.rotation == 2) - xOffset = -0.2f; + public int maxRotation() { + return 8; + } + + @Override + public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z) { + TileEntity tileentity = world.getTileEntity(x, y, z); + if (!(tileentity instanceof TileVariant)) { + super.setBlockBoundsBasedOnState(world, x, y, z); + return; + } + TileVariant tile = (TileVariant) tileentity; + if (tile.variant == 2) { + float xOffset = 0; + float yOffset = 0; + if (tile.rotation == 0) + yOffset = 0.2f; + else if (tile.rotation == 4) + yOffset = -0.2f; + else if (tile.rotation == 6) + xOffset = 0.2f; + else if (tile.rotation == 2) + xOffset = -0.2f; setBlockBounds(0.3f + xOffset, 0.2f, 0.3f + yOffset, 0.7f + xOffset, 0.7f, 0.7f + yOffset); - } - else + } else setBlockBounds(0.3f, 0, 0.3f, 0.7f, 0.6f, 0.7f); } @Override - public int onBlockPlaced(World world, int x, int y, int z, int side, float p_149660_6_, float p_149660_7_, float p_149660_8_, int meta){ + public int onBlockPlaced(World world, int x, int y, int z, int side, float p_149660_6_, float p_149660_7_, float p_149660_8_, int meta) { return side; } @Override public void onPostBlockPlaced(World world, int x, int y, int z, int meta) { - TileLamp tile = (TileLamp) world.getTileEntity(x, y, z); - if(meta == 1) - tile.variant = 0; - else if(meta == 0) - tile.variant = 1; - else{ - tile.variant = 2; - if(meta == 2) - tile.rotation = 0; - else if(meta == 3) - tile.rotation = 4; - else if(meta == 4) - tile.rotation = 6; - else if(meta == 5) - tile.rotation = 2; - } - world.setBlockMetadataWithNotify(x, y, z, 0, 4); + TileLamp tile = (TileLamp) world.getTileEntity(x, y, z); + if (meta == 1) + tile.variant = 0; + else if (meta == 0) + tile.variant = 1; + else { + tile.variant = 2; + if (meta == 2) + tile.rotation = 0; + else if (meta == 3) + tile.rotation = 4; + else if (meta == 4) + tile.rotation = 6; + else if (meta == 5) + tile.rotation = 2; + } + world.setBlockMetadataWithNotify(x, y, z, 0, 4); } @SideOnly(Side.CLIENT) @Override - public void registerBlockIcons(IIconRegister par1IconRegister){ + public void registerBlockIcons(IIconRegister par1IconRegister) { this.blockIcon = par1IconRegister.registerIcon(this.getTextureName()); } @Override @SideOnly(Side.CLIENT) - public IIcon getIcon(int p_149691_1_, int meta){ + public IIcon getIcon(int p_149691_1_, int meta) { return this.blockIcon; } - @Override - public TileEntity createNewTileEntity(World var1, int var2) { - return new TileLamp(); - } + @Override + public TileEntity createNewTileEntity(World var1, int var2) { + return new TileLamp(); + } - @Override - public Block unlitBlock() { - return CustomItems.lantern_unlit; - } + @Override + public Block unlitBlock() { + return CustomItems.lantern_unlit; + } - @Override - public Block litBlock() { - return CustomItems.lantern; - } + @Override + public Block litBlock() { + return CustomItems.lantern; + } } diff --git a/src/main/java/noppes/npcs/blocks/BlockLightable.java b/src/main/java/noppes/npcs/blocks/BlockLightable.java index 7c478b300..9858f243f 100644 --- a/src/main/java/noppes/npcs/blocks/BlockLightable.java +++ b/src/main/java/noppes/npcs/blocks/BlockLightable.java @@ -14,19 +14,20 @@ import java.util.Random; public abstract class BlockLightable extends BlockRotated { - protected BlockLightable(Block block, boolean lit) { - super(block); + protected BlockLightable(Block block, boolean lit) { + super(block); if (lit) this.setLightLevel(1.0F); - } + } - public abstract Block unlitBlock(); - public abstract Block litBlock(); + public abstract Block unlitBlock(); + + public abstract Block litBlock(); @Override - public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9){ + public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9) { // Get the current tile entity and store its NBT TileEntity oldTile = world.getTileEntity(x, y, z); NBTTagCompound compound = new NBTTagCompound(); @@ -41,7 +42,7 @@ public abstract class BlockLightable extends BlockRotated { // Get the new tile and load the stored NBT TileEntity newTile = world.getTileEntity(x, y, z); - if(newTile != null){ + if (newTile != null) { newTile.readFromNBT(compound); newTile.markDirty(); } @@ -53,18 +54,18 @@ public abstract class BlockLightable extends BlockRotated { } @Override - public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_){ + public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) { return Item.getItemFromBlock(litBlock()); } @Override @SideOnly(Side.CLIENT) - public Item getItem(World p_149694_1_, int p_149694_2_, int p_149694_3_, int p_149694_4_){ + public Item getItem(World p_149694_1_, int p_149694_2_, int p_149694_3_, int p_149694_4_) { return Item.getItemFromBlock(litBlock()); } @Override - protected ItemStack createStackedBlock(int p_149644_1_){ + protected ItemStack createStackedBlock(int p_149644_1_) { return new ItemStack(litBlock()); } diff --git a/src/main/java/noppes/npcs/blocks/BlockMailbox.java b/src/main/java/noppes/npcs/blocks/BlockMailbox.java index df28b6364..3f92ea96b 100644 --- a/src/main/java/noppes/npcs/blocks/BlockMailbox.java +++ b/src/main/java/noppes/npcs/blocks/BlockMailbox.java @@ -23,32 +23,30 @@ import noppes.npcs.constants.EnumGuiType; import java.util.ArrayList; import java.util.List; -public class BlockMailbox extends BlockContainer{ +public class BlockMailbox extends BlockContainer { - public int renderId = -1; + public int renderId = -1; - public BlockMailbox() { + public BlockMailbox() { super(Material.iron); - } + } @Override - public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) - { + public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) { par3List.add(new ItemStack(par1, 1, 0)); par3List.add(new ItemStack(par1, 1, 1)); } @Override - public boolean onBlockActivated(World par1World, int i, int j, int k, EntityPlayer player, int par6, float par7, float par8, float par9){ - if(!par1World.isRemote){ - GuiOpenPacket.openGUI((EntityPlayerMP)player, EnumGuiType.PlayerMailbox, i, j, k); - } - return true; + public boolean onBlockActivated(World par1World, int i, int j, int k, EntityPlayer player, int par6, float par7, float par8, float par9) { + if (!par1World.isRemote) { + GuiOpenPacket.openGUI((EntityPlayerMP) player, EnumGuiType.PlayerMailbox, i, j, k); + } + return true; } @Override - public ArrayList getDrops(World world, int x, int y, int z, int metadata, int fortune) - { + public ArrayList getDrops(World world, int x, int y, int z, int metadata, int fortune) { ArrayList ret = new ArrayList(); int damage = this.getDamageValue(world, x, y, z); ret.add(new ItemStack(this, 1, damage)); @@ -56,48 +54,46 @@ public class BlockMailbox extends BlockContainer{ } @Override - public int damageDropped(int par1) - { + public int damageDropped(int par1) { return par1 >> 2; } @Override - public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLivingBase par5EntityLivingBase, ItemStack par6ItemStack) - { - int l = MathHelper.floor_double((double)(par5EntityLivingBase.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3; + public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLivingBase par5EntityLivingBase, ItemStack par6ItemStack) { + int l = MathHelper.floor_double((double) (par5EntityLivingBase.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3; l %= 4; par1World.setBlockMetadataWithNotify(par2, par3, par4, l | par6ItemStack.getItemDamage() << 2, 2); } @Override - public boolean isOpaqueCube(){ - return false; - } + public boolean isOpaqueCube() { + return false; + } @Override - public boolean renderAsNormalBlock(){ - return false; - } + public boolean renderAsNormalBlock() { + return false; + } + @Override - public int getRenderType(){ - return renderId; - } + public int getRenderType() { + return renderId; + } @Override @SideOnly(Side.CLIENT) - public void registerBlockIcons(IIconRegister par1IconRegister) - { + public void registerBlockIcons(IIconRegister par1IconRegister) { } + @SideOnly(Side.CLIENT) - public IIcon getIcon(int p_149691_1_, int p_149691_2_) - { + public IIcon getIcon(int p_149691_1_, int p_149691_2_) { return Blocks.soul_sand.getBlockTextureFromSide(p_149691_1_); } - @Override - public TileEntity createNewTileEntity(World var1, int var2) { - return new TileMailbox(); - } + @Override + public TileEntity createNewTileEntity(World var1, int var2) { + return new TileMailbox(); + } } diff --git a/src/main/java/noppes/npcs/blocks/BlockNpcRedstone.java b/src/main/java/noppes/npcs/blocks/BlockNpcRedstone.java index 70c5488a3..e97096c72 100644 --- a/src/main/java/noppes/npcs/blocks/BlockNpcRedstone.java +++ b/src/main/java/noppes/npcs/blocks/BlockNpcRedstone.java @@ -18,28 +18,28 @@ import noppes.npcs.CustomNpcsPermissions; import noppes.npcs.blocks.tiles.TileRedstoneBlock; import noppes.npcs.constants.EnumGuiType; -public class BlockNpcRedstone extends BlockContainer{ - public BlockNpcRedstone(){ +public class BlockNpcRedstone extends BlockContainer { + public BlockNpcRedstone() { super(Material.rock); } @Override - public boolean onBlockActivated(World par1World, int i, int j, int k, EntityPlayer player, int par6, float par7, float par8, float par9){ - if(par1World.isRemote) - return false; - ItemStack currentItem = player.inventory.getCurrentItem(); - if (currentItem != null && currentItem.getItem() == CustomItems.wand && CustomNpcsPermissions.hasPermission(player, CustomNpcsPermissions.EDIT_REDSTONE)) { - TileEntity tile = par1World.getTileEntity(i, j, k); - NBTTagCompound compound = new NBTTagCompound(); - tile.writeToNBT(compound); - PacketHandler.Instance.sendToPlayer(new GuiRedstonePacket(compound), (EntityPlayerMP)player); + public boolean onBlockActivated(World par1World, int i, int j, int k, EntityPlayer player, int par6, float par7, float par8, float par9) { + if (par1World.isRemote) + return false; + ItemStack currentItem = player.inventory.getCurrentItem(); + if (currentItem != null && currentItem.getItem() == CustomItems.wand && CustomNpcsPermissions.hasPermission(player, CustomNpcsPermissions.EDIT_REDSTONE)) { + TileEntity tile = par1World.getTileEntity(i, j, k); + NBTTagCompound compound = new NBTTagCompound(); + tile.writeToNBT(compound); + PacketHandler.Instance.sendToPlayer(new GuiRedstonePacket(compound), (EntityPlayerMP) player); return true; - } - return false; + } + return false; } @Override - public void onBlockAdded(World par1World, int par2, int par3, int par4){ + public void onBlockAdded(World par1World, int par2, int par3, int par4) { par1World.notifyBlocksOfNeighborChange(par2, par3, par4, this); par1World.notifyBlocksOfNeighborChange(par2, par3 - 1, par4, this); par1World.notifyBlocksOfNeighborChange(par2, par3 + 1, par4, this); @@ -50,46 +50,46 @@ public class BlockNpcRedstone extends BlockContainer{ } @Override - public void onBlockPlacedBy(World world, int i, int j, int k, EntityLivingBase entityliving, ItemStack item){ - if(entityliving instanceof EntityPlayer && world.isRemote){ - CustomNpcs.proxy.openGui(i, j, k, EnumGuiType.RedstoneBlock, (EntityPlayer) entityliving); - } + public void onBlockPlacedBy(World world, int i, int j, int k, EntityLivingBase entityliving, ItemStack item) { + if (entityliving instanceof EntityPlayer && world.isRemote) { + CustomNpcs.proxy.openGui(i, j, k, EnumGuiType.RedstoneBlock, (EntityPlayer) entityliving); + } } @Override public void onBlockDestroyedByPlayer(World par1World, int par2, int par3, int par4, int par5) { - onBlockAdded(par1World, par2, par3, par4); + onBlockAdded(par1World, par2, par3, par4); } @Override - public int colorMultiplier(IBlockAccess par1IBlockAccess, int par2, int par3, int par4){ - if(isActivated(par1IBlockAccess, par2, par3, par4) > 0) - return 0xFF6B68; - else - return super.colorMultiplier(par1IBlockAccess, par2, par3, par4); + public int colorMultiplier(IBlockAccess par1IBlockAccess, int par2, int par3, int par4) { + if (isActivated(par1IBlockAccess, par2, par3, par4) > 0) + return 0xFF6B68; + else + return super.colorMultiplier(par1IBlockAccess, par2, par3, par4); } @Override - public int isProvidingWeakPower(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5){ + public int isProvidingWeakPower(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5) { return isActivated(par1IBlockAccess, par2, par3, par4); } @Override - public int isProvidingStrongPower(IBlockAccess par1World, int par2, int par3, int par4, int par5){ + public int isProvidingStrongPower(IBlockAccess par1World, int par2, int par3, int par4, int par5) { return isActivated(par1World, par2, par3, par4); } @Override - public boolean canProvidePower(){ + public boolean canProvidePower() { return true; } - public int isActivated(IBlockAccess par1IBlockAccess, int par2, int par3, int par4){ - return par1IBlockAccess.getBlockMetadata(par2, par3, par4) == 1?15 : 0; - } + public int isActivated(IBlockAccess par1IBlockAccess, int par2, int par3, int par4) { + return par1IBlockAccess.getBlockMetadata(par2, par3, par4) == 1 ? 15 : 0; + } - @Override - public TileEntity createNewTileEntity(World var1, int var2) { - return new TileRedstoneBlock(); - } + @Override + public TileEntity createNewTileEntity(World var1, int var2) { + return new TileRedstoneBlock(); + } } diff --git a/src/main/java/noppes/npcs/blocks/BlockPedestal.java b/src/main/java/noppes/npcs/blocks/BlockPedestal.java index 06b907a09..6d9978ad8 100644 --- a/src/main/java/noppes/npcs/blocks/BlockPedestal.java +++ b/src/main/java/noppes/npcs/blocks/BlockPedestal.java @@ -20,40 +20,39 @@ import noppes.npcs.blocks.tiles.TileVariant; import java.util.List; -public class BlockPedestal extends BlockTrigger{ +public class BlockPedestal extends BlockTrigger { - public BlockPedestal() { + public BlockPedestal() { super(Blocks.stone); - } - - @Override - public boolean onBlockActivated(World par1World, int i, int j, int k, EntityPlayer player, int side, float hitX, float hitY, float hitZ){ - if(par1World.isRemote) - return true; - - TilePedestal tile = (TilePedestal) par1World.getTileEntity(i, j, k); - - ItemStack item = player.getCurrentEquippedItem(); - ItemStack weapon = tile.getStackInSlot(0); - if(item == null && weapon != null){ - tile.setInventorySlotContents(0, null); - player.inventory.setInventorySlotContents(player.inventory.currentItem, weapon); - par1World.markBlockForUpdate(i, j, k); - updateSurrounding(par1World, i, j, k); - } - else if(item == null || item.getItem() == null || item.getItem() instanceof ItemBlock) - return true; - else if(item != null && weapon == null){ - tile.setInventorySlotContents(0, item); - player.inventory.setInventorySlotContents(player.inventory.currentItem, null); - par1World.markBlockForUpdate(i, j, k); - updateSurrounding(par1World, i, j, k); - } - return true; } @Override - public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List){ + public boolean onBlockActivated(World par1World, int i, int j, int k, EntityPlayer player, int side, float hitX, float hitY, float hitZ) { + if (par1World.isRemote) + return true; + + TilePedestal tile = (TilePedestal) par1World.getTileEntity(i, j, k); + + ItemStack item = player.getCurrentEquippedItem(); + ItemStack weapon = tile.getStackInSlot(0); + if (item == null && weapon != null) { + tile.setInventorySlotContents(0, null); + player.inventory.setInventorySlotContents(player.inventory.currentItem, weapon); + par1World.markBlockForUpdate(i, j, k); + updateSurrounding(par1World, i, j, k); + } else if (item == null || item.getItem() == null || item.getItem() instanceof ItemBlock) + return true; + else if (item != null && weapon == null) { + tile.setInventorySlotContents(0, item); + player.inventory.setInventorySlotContents(player.inventory.currentItem, null); + par1World.markBlockForUpdate(i, j, k); + updateSurrounding(par1World, i, j, k); + } + return true; + } + + @Override + public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) { par3List.add(new ItemStack(par1, 1, 0)); par3List.add(new ItemStack(par1, 1, 1)); par3List.add(new ItemStack(par1, 1, 2)); @@ -62,58 +61,57 @@ public class BlockPedestal extends BlockTrigger{ } @Override - public int damageDropped(int par1){ + public int damageDropped(int par1) { return par1; } - @Override - public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z){ - TileEntity tileentity = world.getTileEntity(x, y, z); - if(!(tileentity instanceof TileVariant)){ - super.setBlockBoundsBasedOnState(world, x, y, z); - return; - } - TileVariant tile = (TileVariant) tileentity; - if(tile.rotation % 2 == 0){ - setBlockBounds(0f, 0, 0.2f, 1, 0.5f, 0.8f ); - } - else{ - setBlockBounds(0.2f, 0, 0, 0.8f, 0.5f, 1 ); - } - } @Override - public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLivingBase par5EntityLivingBase, ItemStack par6ItemStack){ + public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z) { + TileEntity tileentity = world.getTileEntity(x, y, z); + if (!(tileentity instanceof TileVariant)) { + super.setBlockBoundsBasedOnState(world, x, y, z); + return; + } + TileVariant tile = (TileVariant) tileentity; + if (tile.rotation % 2 == 0) { + setBlockBounds(0f, 0, 0.2f, 1, 0.5f, 0.8f); + } else { + setBlockBounds(0.2f, 0, 0, 0.8f, 0.5f, 1); + } + } + + @Override + public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLivingBase par5EntityLivingBase, ItemStack par6ItemStack) { super.onBlockPlacedBy(par1World, par2, par3, par4, par5EntityLivingBase, par6ItemStack); - par1World.setBlockMetadataWithNotify(par2, par3, par4, par6ItemStack.getItemDamage() , 2); + par1World.setBlockMetadataWithNotify(par2, par3, par4, par6ItemStack.getItemDamage(), 2); } @Override @SideOnly(Side.CLIENT) - public IIcon getIcon(int p_149691_1_, int meta) - { - meta %= 7; - if(meta == 1) + public IIcon getIcon(int p_149691_1_, int meta) { + meta %= 7; + if (meta == 1) return Blocks.stone.getIcon(p_149691_1_, 0); - else if(meta == 2) + else if (meta == 2) return Blocks.iron_block.getIcon(p_149691_1_, 0); - else if(meta == 3) + else if (meta == 3) return Blocks.gold_block.getIcon(p_149691_1_, 0); - else if(meta == 4) + else if (meta == 4) return Blocks.diamond_block.getIcon(p_149691_1_, 0); return Blocks.planks.getIcon(p_149691_1_, 0); } - @Override - public TileEntity createNewTileEntity(World var1, int var2) { - return new TilePedestal(); - } + @Override + public TileEntity createNewTileEntity(World var1, int var2) { + return new TilePedestal(); + } - @Override - public void breakBlock(World world, int x, int y, int z, Block block, int p_149749_6_){ - TileNpcContainer tile = (TileNpcContainer)world.getTileEntity(x, y, z); + @Override + public void breakBlock(World world, int x, int y, int z, Block block, int p_149749_6_) { + TileNpcContainer tile = (TileNpcContainer) world.getTileEntity(x, y, z); if (tile == null) - return; + return; tile.dropItems(world, x, y, z); world.func_147453_f(x, y, z, block); diff --git a/src/main/java/noppes/npcs/blocks/BlockPlaceholder.java b/src/main/java/noppes/npcs/blocks/BlockPlaceholder.java index d5a6a7123..e0141e680 100644 --- a/src/main/java/noppes/npcs/blocks/BlockPlaceholder.java +++ b/src/main/java/noppes/npcs/blocks/BlockPlaceholder.java @@ -14,45 +14,44 @@ import net.minecraft.world.World; import java.util.List; -public class BlockPlaceholder extends Block{ - - private IIcon[] icons = new IIcon[16]; +public class BlockPlaceholder extends Block { - public BlockPlaceholder() { + private IIcon[] icons = new IIcon[16]; + + public BlockPlaceholder() { super(Material.rock); - } - - @Override - public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLivingBase par5EntityLivingBase, ItemStack par6ItemStack){ - super.onBlockPlacedBy(par1World, par2, par3, par4, par5EntityLivingBase, par6ItemStack); - par1World.setBlockMetadataWithNotify(par2, par3, par4, par6ItemStack.getItemDamage() , 2); - } - - @Override - public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List){ - for(int i = 0; i < 16; i++) - par3List.add(new ItemStack(par1, 1, i)); } - @Override - public int damageDropped(int par1){ + @Override + public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLivingBase par5EntityLivingBase, ItemStack par6ItemStack) { + super.onBlockPlacedBy(par1World, par2, par3, par4, par5EntityLivingBase, par6ItemStack); + par1World.setBlockMetadataWithNotify(par2, par3, par4, par6ItemStack.getItemDamage(), 2); + } + + @Override + public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) { + for (int i = 0; i < 16; i++) + par3List.add(new ItemStack(par1, 1, i)); + } + + @Override + public int damageDropped(int par1) { return par1; } @Override @SideOnly(Side.CLIENT) - public void registerBlockIcons(IIconRegister par1IconRegister){ - for(int i = 0; i < 16; i++){ - icons[i] = par1IconRegister.registerIcon("customnpcs:placeholder_" + i); - } + public void registerBlockIcons(IIconRegister par1IconRegister) { + for (int i = 0; i < 16; i++) { + icons[i] = par1IconRegister.registerIcon("customnpcs:placeholder_" + i); + } } - + @Override @SideOnly(Side.CLIENT) - public IIcon getIcon(int p_149691_1_, int meta) - { - if(meta < icons.length) - return icons[meta]; + public IIcon getIcon(int p_149691_1_, int meta) { + if (meta < icons.length) + return icons[meta]; return icons[0]; } diff --git a/src/main/java/noppes/npcs/blocks/BlockRotated.java b/src/main/java/noppes/npcs/blocks/BlockRotated.java index cfd1f945e..735e088eb 100644 --- a/src/main/java/noppes/npcs/blocks/BlockRotated.java +++ b/src/main/java/noppes/npcs/blocks/BlockRotated.java @@ -16,59 +16,62 @@ import net.minecraftforge.common.util.ForgeDirection; import noppes.npcs.blocks.tiles.TileVariant; public abstract class BlockRotated extends BlockContainer { - private Block block; - protected BlockRotated(Block block) { - super(block.getMaterial()); - this.block = block; - } + private Block block; - public int renderId = -1; + protected BlockRotated(Block block) { + super(block.getMaterial()); + this.block = block; + } + + public int renderId = -1; @Override - public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLivingBase par5EntityLivingBase, ItemStack par6ItemStack){ - int l = MathHelper.floor_double((double)(par5EntityLivingBase.rotationYaw * maxRotation() / 360.0F) + 0.5D) & (maxRotation() - 1); + public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLivingBase par5EntityLivingBase, ItemStack par6ItemStack) { + int l = MathHelper.floor_double((double) (par5EntityLivingBase.rotationYaw * maxRotation() / 360.0F) + 0.5D) & (maxRotation() - 1); l %= maxRotation(); - TileVariant tile = (TileVariant) par1World.getTileEntity(par2, par3, par4); - tile.rotation = l; + TileVariant tile = (TileVariant) par1World.getTileEntity(par2, par3, par4); + tile.rotation = l; } - public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, int y, int z){ - setBlockBoundsBasedOnState(world, x, y, z); - return super.getCollisionBoundingBoxFromPool(world, x, y, z); + public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, int y, int z) { + setBlockBoundsBasedOnState(world, x, y, z); + return super.getCollisionBoundingBoxFromPool(world, x, y, z); } - public int maxRotation(){ - return 4; + public int maxRotation() { + return 4; } @Override - public boolean isOpaqueCube(){ - return false; - } + public boolean isOpaqueCube() { + return false; + } @Override - public boolean renderAsNormalBlock(){ - return false; - } + public boolean renderAsNormalBlock() { + return false; + } + @Override - public int getRenderType(){ - return renderId; - } + public int getRenderType() { + return renderId; + } + @Override - public boolean isSideSolid(IBlockAccess world, int x, int y, int z, ForgeDirection side){ - return true; + public boolean isSideSolid(IBlockAccess world, int x, int y, int z, ForgeDirection side) { + return true; } @Override @SideOnly(Side.CLIENT) - public void registerBlockIcons(IIconRegister par1IconRegister) - { + public void registerBlockIcons(IIconRegister par1IconRegister) { } + @Override @SideOnly(Side.CLIENT) - public IIcon getIcon(int p_149691_1_, int meta){ + public IIcon getIcon(int p_149691_1_, int meta) { return block.getIcon(p_149691_1_, meta); } diff --git a/src/main/java/noppes/npcs/blocks/BlockScripted.java b/src/main/java/noppes/npcs/blocks/BlockScripted.java index c34283704..8d5f0fa72 100644 --- a/src/main/java/noppes/npcs/blocks/BlockScripted.java +++ b/src/main/java/noppes/npcs/blocks/BlockScripted.java @@ -45,7 +45,7 @@ public class BlockScripted extends BlockContainer { TileScripted tile = (TileScripted) world.getTileEntity(x, y, z); if (tile != null && tile.isPassible && (tile.blockModel == null || tile.blockModel == Blocks.air)) return AABB_EMPTY; - return AABB.getOffsetBoundingBox(x,y,z); + return AABB.getOffsetBoundingBox(x, y, z); } @Override @@ -53,12 +53,11 @@ public class BlockScripted extends BlockContainer { TileScripted tile = (TileScripted) world.getTileEntity(x, y, z); if (tile != null && tile.isPassible) return AABB_EMPTY; - return AABB.getOffsetBoundingBox(x,y,z); + return AABB.getOffsetBoundingBox(x, y, z); } @Override - public boolean getBlocksMovement(IBlockAccess worldIn, int x, int y, int z) - { + public boolean getBlocksMovement(IBlockAccess worldIn, int x, int y, int z) { TileScripted tile = (TileScripted) worldIn.getTileEntity(x, y, z); return tile != null && tile.isPassible; } @@ -118,6 +117,7 @@ public class BlockScripted extends BlockContainer { public int getRenderType() { return renderId; } + @Override public boolean isOpaqueCube() { return false; @@ -235,7 +235,7 @@ public class BlockScripted extends BlockContainer { int power = 0; for (EnumFacing enumfacing : EnumFacing.values()) { int p = world.getIndirectPowerLevelTo(x + enumfacing.getFrontOffsetX(), - y + enumfacing.getFrontOffsetZ(), z + enumfacing.getFrontOffsetZ(), enumfacing.ordinal()); + y + enumfacing.getFrontOffsetZ(), z + enumfacing.getFrontOffsetZ(), enumfacing.ordinal()); if (p > power) power = p; } diff --git a/src/main/java/noppes/npcs/blocks/BlockShelf.java b/src/main/java/noppes/npcs/blocks/BlockShelf.java index 1fda4c516..eb9e3f4f5 100644 --- a/src/main/java/noppes/npcs/blocks/BlockShelf.java +++ b/src/main/java/noppes/npcs/blocks/BlockShelf.java @@ -14,26 +14,26 @@ import noppes.npcs.blocks.tiles.TileVariant; import java.util.List; -public class BlockShelf extends BlockRotated{ +public class BlockShelf extends BlockRotated { - public BlockShelf() { + public BlockShelf() { super(Blocks.planks); - } - - @Override - public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLivingBase par5EntityLivingBase, ItemStack par6ItemStack){ - super.onBlockPlacedBy(par1World, par2, par3, par4, par5EntityLivingBase, par6ItemStack); - par1World.setBlockMetadataWithNotify(par2, par3, par4, par6ItemStack.getItemDamage() , 2); } @Override - public AxisAlignedBB getCollisionBoundingBoxFromPool(World p_149668_1_, int x, int y, int z){ - setBlockBoundsBasedOnState(p_149668_1_, x, y, z); + public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLivingBase par5EntityLivingBase, ItemStack par6ItemStack) { + super.onBlockPlacedBy(par1World, par2, par3, par4, par5EntityLivingBase, par6ItemStack); + par1World.setBlockMetadataWithNotify(par2, par3, par4, par6ItemStack.getItemDamage(), 2); + } + + @Override + public AxisAlignedBB getCollisionBoundingBoxFromPool(World p_149668_1_, int x, int y, int z) { + setBlockBoundsBasedOnState(p_149668_1_, x, y, z); return AxisAlignedBB.getBoundingBox(x + minX, y + 0.9f, z + minZ, x + maxX, y + 1, z + maxZ); } @Override - public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List){ + public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) { par3List.add(new ItemStack(par1, 1, 0)); par3List.add(new ItemStack(par1, 1, 1)); par3List.add(new ItemStack(par1, 1, 2)); @@ -41,37 +41,38 @@ public class BlockShelf extends BlockRotated{ par3List.add(new ItemStack(par1, 1, 4)); par3List.add(new ItemStack(par1, 1, 5)); } + @Override - public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z){ - TileEntity tileentity = world.getTileEntity(x, y, z); - if(!(tileentity instanceof TileVariant)){ - super.setBlockBoundsBasedOnState(world, x, y, z); - return; - } - TileVariant tile = (TileVariant) tileentity; - float xStart = 0; - float zStart = 0; - float xEnd = 1; - float zEnd = 1; - if(tile.rotation == 0) - zStart = 0.3f; - else if(tile.rotation == 2) - zEnd = 0.7f; - else if(tile.rotation == 3) - xStart = 0.3f; - else if(tile.rotation == 1) - xEnd = 0.7f; + public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z) { + TileEntity tileentity = world.getTileEntity(x, y, z); + if (!(tileentity instanceof TileVariant)) { + super.setBlockBoundsBasedOnState(world, x, y, z); + return; + } + TileVariant tile = (TileVariant) tileentity; + float xStart = 0; + float zStart = 0; + float xEnd = 1; + float zEnd = 1; + if (tile.rotation == 0) + zStart = 0.3f; + else if (tile.rotation == 2) + zEnd = 0.7f; + else if (tile.rotation == 3) + xStart = 0.3f; + else if (tile.rotation == 1) + xEnd = 0.7f; setBlockBounds(xStart, 0.44f, zStart, xEnd, 1, zEnd); } @Override - public int damageDropped(int par1){ + public int damageDropped(int par1) { return par1; } - @Override - public TileEntity createNewTileEntity(World var1, int var2) { - return new TileShelf(); - } + @Override + public TileEntity createNewTileEntity(World var1, int var2) { + return new TileShelf(); + } } diff --git a/src/main/java/noppes/npcs/blocks/BlockShortLamp.java b/src/main/java/noppes/npcs/blocks/BlockShortLamp.java index 0e2a8480b..3ae158d32 100644 --- a/src/main/java/noppes/npcs/blocks/BlockShortLamp.java +++ b/src/main/java/noppes/npcs/blocks/BlockShortLamp.java @@ -43,7 +43,7 @@ public class BlockShortLamp extends BlockContainer { public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) { ItemStack item = player.inventory.getCurrentItem(); - if(TileColorable.allowColorChange(item) != TileColorable.ColorChangeType.DYE) + if (TileColorable.allowColorChange(item) != TileColorable.ColorChangeType.DYE) return false; int meta = world.getBlockMetadata(x, y, z); TileColorable tile = (TileColorable) world.getTileEntity(x, y, z); @@ -78,13 +78,13 @@ public class BlockShortLamp extends BlockContainer { @Override public void onBlockPlacedBy(World world, int x, int y, int z, - EntityLivingBase entity, ItemStack stack) { - int l = MathHelper.floor_double((double)(entity.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3; + EntityLivingBase entity, ItemStack stack) { + int l = MathHelper.floor_double((double) (entity.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3; l %= 4; TileColorable tile = (TileColorable) world.getTileEntity(x, y, z); tile.rotation = l; tile.color = colorTableInts[15 - stack.getItemDamage()]; - if(stack.hasTagCompound() && stack.getTagCompound().hasKey(BRUSH_COLOR_TAG)){ + if (stack.hasTagCompound() && stack.getTagCompound().hasKey(BRUSH_COLOR_TAG)) { tile.color = stack.getTagCompound().getInteger(BRUSH_COLOR_TAG); } @@ -97,17 +97,17 @@ public class BlockShortLamp extends BlockContainer { } @Override - public boolean isOpaqueCube(){ + public boolean isOpaqueCube() { return false; } @Override - public boolean renderAsNormalBlock(){ + public boolean renderAsNormalBlock() { return false; } @Override - public int getRenderType(){ + public int getRenderType() { return renderId; } @@ -120,13 +120,13 @@ public class BlockShortLamp extends BlockContainer { @Override @SideOnly(Side.CLIENT) public IIcon getIcon(int side, int meta) { - if(meta == 1) + if (meta == 1) return Blocks.stone.getIcon(side, 0); - else if(meta == 2) + else if (meta == 2) return Blocks.iron_block.getIcon(side, 0); - else if(meta == 3) + else if (meta == 3) return Blocks.gold_block.getIcon(side, 0); - else if(meta == 4) + else if (meta == 4) return Blocks.diamond_block.getIcon(side, 0); return Blocks.planks.getIcon(side, 0); } diff --git a/src/main/java/noppes/npcs/blocks/BlockSign.java b/src/main/java/noppes/npcs/blocks/BlockSign.java index 2233f6bc1..456cd0b33 100644 --- a/src/main/java/noppes/npcs/blocks/BlockSign.java +++ b/src/main/java/noppes/npcs/blocks/BlockSign.java @@ -17,33 +17,32 @@ import noppes.npcs.blocks.tiles.TileVariant; import java.util.List; -public class BlockSign extends BlockRotated{ +public class BlockSign extends BlockRotated { - public BlockSign() { + public BlockSign() { super(Blocks.planks); - } + } @Override - public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLivingBase par5EntityLivingBase, ItemStack par6ItemStack) - { - int l = MathHelper.floor_double((double)(par5EntityLivingBase.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3; + public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLivingBase par5EntityLivingBase, ItemStack par6ItemStack) { + int l = MathHelper.floor_double((double) (par5EntityLivingBase.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3; l %= 4; TileSign tile = (TileSign) par1World.getTileEntity(par2, par3, par4); - tile.rotation = l; - tile.time = System.currentTimeMillis(); - par1World.setBlockMetadataWithNotify(par2, par3, par4, par6ItemStack.getItemDamage() , 2); - if(par5EntityLivingBase instanceof EntityPlayer && par1World.isRemote) - ((EntityPlayer)par5EntityLivingBase).addChatComponentMessage(new ChatComponentTranslation("availability.editIcon")); + tile.rotation = l; + tile.time = System.currentTimeMillis(); + par1World.setBlockMetadataWithNotify(par2, par3, par4, par6ItemStack.getItemDamage(), 2); + if (par5EntityLivingBase instanceof EntityPlayer && par1World.isRemote) + ((EntityPlayer) par5EntityLivingBase).addChatComponentMessage(new ChatComponentTranslation("availability.editIcon")); } @Override - public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ){ - TileBanner tile = (TileBanner) world.getTileEntity(x, y, z); - return tile.canEdit(); + public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) { + TileBanner tile = (TileBanner) world.getTileEntity(x, y, z); + return tile.canEdit(); } @Override - public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List){ + public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) { par3List.add(new ItemStack(par1, 1, 0)); par3List.add(new ItemStack(par1, 1, 1)); par3List.add(new ItemStack(par1, 1, 2)); @@ -53,26 +52,26 @@ public class BlockSign extends BlockRotated{ } @Override - public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z){ - TileEntity tileentity = world.getTileEntity(x, y, z); - if(!(tileentity instanceof TileVariant)){ - super.setBlockBoundsBasedOnState(world, x, y, z); - return; - } - TileVariant tile = (TileVariant) tileentity; - if(tile.rotation % 2 == 1) + public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z) { + TileEntity tileentity = world.getTileEntity(x, y, z); + if (!(tileentity instanceof TileVariant)) { + super.setBlockBoundsBasedOnState(world, x, y, z); + return; + } + TileVariant tile = (TileVariant) tileentity; + if (tile.rotation % 2 == 1) setBlockBounds(0, 0.3f, 0.3f, 1, 1, 0.7f); - else + else setBlockBounds(0.3f, 0.3f, 0, 0.7f, 1, 1); } @Override - public int damageDropped(int par1){ + public int damageDropped(int par1) { return par1; } - @Override - public TileEntity createNewTileEntity(World var1, int var2) { - return new TileSign(); - } + @Override + public TileEntity createNewTileEntity(World var1, int var2) { + return new TileSign(); + } } diff --git a/src/main/java/noppes/npcs/blocks/BlockStool.java b/src/main/java/noppes/npcs/blocks/BlockStool.java index 45314103f..2b839bc93 100644 --- a/src/main/java/noppes/npcs/blocks/BlockStool.java +++ b/src/main/java/noppes/npcs/blocks/BlockStool.java @@ -21,22 +21,22 @@ import noppes.npcs.blocks.tiles.TileVariant; import java.util.List; -public class BlockStool extends BlockContainer{ +public class BlockStool extends BlockContainer { - public int renderId = -1; + public int renderId = -1; - public BlockStool() { + public BlockStool() { super(Material.wood); setBlockBounds(0.1f, 0, 0.1f, 0.9f, 0.6f, 0.9f); - } + } @Override - public AxisAlignedBB getCollisionBoundingBoxFromPool(World p_149668_1_, int x, int y, int z){ + public AxisAlignedBB getCollisionBoundingBoxFromPool(World p_149668_1_, int x, int y, int z) { return AxisAlignedBB.getBoundingBox(x + 0.1f, y, z + 0.1f, x + 0.9f, y + 0.5f, z + 0.9f); } @Override - public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List){ + public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) { par3List.add(new ItemStack(par1, 1, 0)); par3List.add(new ItemStack(par1, 1, 1)); par3List.add(new ItemStack(par1, 1, 2)); @@ -46,58 +46,57 @@ public class BlockStool extends BlockContainer{ } @Override - public int damageDropped(int par1) - { + public int damageDropped(int par1) { return par1; } - @Override - public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int p_149727_6_, float p_149727_7_, float p_149727_8_, float p_149727_9_){ + @Override + public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int p_149727_6_, float p_149727_7_, float p_149727_8_, float p_149727_9_) { return BlockChair.MountBlock(world, x, y, z, player); } @Override - public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLivingBase par5EntityLivingBase, ItemStack par6ItemStack){ - int l = MathHelper.floor_double((double)(par5EntityLivingBase.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3; + public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLivingBase par5EntityLivingBase, ItemStack par6ItemStack) { + int l = MathHelper.floor_double((double) (par5EntityLivingBase.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3; l %= 4; - TileVariant tile = (TileVariant) par1World.getTileEntity(par2, par3, par4); - tile.rotation = l; + TileVariant tile = (TileVariant) par1World.getTileEntity(par2, par3, par4); + tile.rotation = l; - par1World.setBlockMetadataWithNotify(par2, par3, par4, par6ItemStack.getItemDamage() , 2); + par1World.setBlockMetadataWithNotify(par2, par3, par4, par6ItemStack.getItemDamage(), 2); } @Override - public boolean isOpaqueCube(){ - return false; - } + public boolean isOpaqueCube() { + return false; + } @Override - public boolean renderAsNormalBlock(){ - return false; - } + public boolean renderAsNormalBlock() { + return false; + } + @Override - public int getRenderType(){ - return renderId; - } + public int getRenderType() { + return renderId; + } @Override @SideOnly(Side.CLIENT) - public void registerBlockIcons(IIconRegister par1IconRegister) - { + public void registerBlockIcons(IIconRegister par1IconRegister) { } + @Override @SideOnly(Side.CLIENT) - public IIcon getIcon(int p_149691_1_, int meta) - { + public IIcon getIcon(int p_149691_1_, int meta) { return Blocks.planks.getIcon(p_149691_1_, meta); } - @Override - public TileEntity createNewTileEntity(World var1, int var2) { - return new TileStool(); - } + @Override + public TileEntity createNewTileEntity(World var1, int var2) { + return new TileStool(); + } } diff --git a/src/main/java/noppes/npcs/blocks/BlockTable.java b/src/main/java/noppes/npcs/blocks/BlockTable.java index 1169bc49b..5bdb4f0f3 100644 --- a/src/main/java/noppes/npcs/blocks/BlockTable.java +++ b/src/main/java/noppes/npcs/blocks/BlockTable.java @@ -13,12 +13,12 @@ import java.util.List; public class BlockTable extends BlockRotated { - public BlockTable() { + public BlockTable() { super(Blocks.planks); - } + } @Override - public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List){ + public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) { par3List.add(new ItemStack(par1, 1, 0)); par3List.add(new ItemStack(par1, 1, 1)); par3List.add(new ItemStack(par1, 1, 2)); @@ -28,18 +28,18 @@ public class BlockTable extends BlockRotated { } @Override - public int damageDropped(int par1){ + public int damageDropped(int par1) { return par1; } @Override - public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLivingBase par5EntityLivingBase, ItemStack par6ItemStack){ - super.onBlockPlacedBy(par1World, par2, par3, par4, par5EntityLivingBase, par6ItemStack); - par1World.setBlockMetadataWithNotify(par2, par3, par4, par6ItemStack.getItemDamage() , 2); + public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLivingBase par5EntityLivingBase, ItemStack par6ItemStack) { + super.onBlockPlacedBy(par1World, par2, par3, par4, par5EntityLivingBase, par6ItemStack); + par1World.setBlockMetadataWithNotify(par2, par3, par4, par6ItemStack.getItemDamage(), 2); } - @Override - public TileEntity createNewTileEntity(World var1, int var2) { - return new TileTable(); - } + @Override + public TileEntity createNewTileEntity(World var1, int var2) { + return new TileTable(); + } } diff --git a/src/main/java/noppes/npcs/blocks/BlockTallLamp.java b/src/main/java/noppes/npcs/blocks/BlockTallLamp.java index 96bb0314a..20c5852cf 100644 --- a/src/main/java/noppes/npcs/blocks/BlockTallLamp.java +++ b/src/main/java/noppes/npcs/blocks/BlockTallLamp.java @@ -31,37 +31,39 @@ import static noppes.npcs.items.ItemNpcTool.BRUSH_COLOR_TAG; public class BlockTallLamp extends BlockContainer { - public int renderId = -1; + public int renderId = -1; - public BlockTallLamp() { + public BlockTallLamp() { super(Material.wood); setBlockBounds(0, 0, 0, 1, 2, 1); setLightLevel(1); - } - @Override - public boolean onBlockActivated(World par1World, int i, int j, int k, EntityPlayer player, int par6, float par7, float par8, float par9){ - ItemStack item = player.inventory.getCurrentItem(); - if(TileColorable.allowColorChange(item) != TileColorable.ColorChangeType.DYE) - return false; - int meta = par1World.getBlockMetadata(i, j, k); - if(meta >= 7) - j--; - TileColorable tile = (TileColorable) par1World.getTileEntity(i, j, k); - int color = colorTableInts[BlockColored.func_150031_c(item.getItemDamage())]; - if(tile.color != color){ - NoppesUtilServer.consumeItemStack(1, player); - tile.color = color; - par1World.markBlockForUpdate(i, j, k); - } - return true; - } - public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, int y, int z){ - setBlockBoundsBasedOnState(world, x, y, z); - return super.getCollisionBoundingBoxFromPool(world, x, y, z); } @Override - public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List){ + public boolean onBlockActivated(World par1World, int i, int j, int k, EntityPlayer player, int par6, float par7, float par8, float par9) { + ItemStack item = player.inventory.getCurrentItem(); + if (TileColorable.allowColorChange(item) != TileColorable.ColorChangeType.DYE) + return false; + int meta = par1World.getBlockMetadata(i, j, k); + if (meta >= 7) + j--; + TileColorable tile = (TileColorable) par1World.getTileEntity(i, j, k); + int color = colorTableInts[BlockColored.func_150031_c(item.getItemDamage())]; + if (tile.color != color) { + NoppesUtilServer.consumeItemStack(1, player); + tile.color = color; + par1World.markBlockForUpdate(i, j, k); + } + return true; + } + + public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, int y, int z) { + setBlockBoundsBasedOnState(world, x, y, z); + return super.getCollisionBoundingBoxFromPool(world, x, y, z); + } + + @Override + public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) { par3List.add(new ItemStack(par1, 1, 0)); par3List.add(new ItemStack(par1, 1, 1)); par3List.add(new ItemStack(par1, 1, 2)); @@ -70,7 +72,7 @@ public class BlockTallLamp extends BlockContainer { } @Override - public int damageDropped(int par1){ + public int damageDropped(int par1) { return par1 % 7; } @@ -80,83 +82,80 @@ public class BlockTallLamp extends BlockContainer { } @Override - public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLivingBase par5EntityLivingBase, ItemStack par6ItemStack) - { - if(!par1World.isAirBlock(par2, par3 + 1, par4)){ - par1World.setBlockToAir(par2, par3, par4); - } - else{ + public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLivingBase par5EntityLivingBase, ItemStack par6ItemStack) { + if (!par1World.isAirBlock(par2, par3 + 1, par4)) { + par1World.setBlockToAir(par2, par3, par4); + } else { - int l = MathHelper.floor_double((double)(par5EntityLivingBase.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3; - l %= 4; + int l = MathHelper.floor_double((double) (par5EntityLivingBase.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3; + l %= 4; - TileColorable tile = (TileColorable) par1World.getTileEntity(par2, par3, par4); - tile.rotation = l; - tile.color = colorTableInts[15 - par6ItemStack.getItemDamage()]; - if(par6ItemStack.hasTagCompound() && par6ItemStack.getTagCompound().hasKey(BRUSH_COLOR_TAG)){ + TileColorable tile = (TileColorable) par1World.getTileEntity(par2, par3, par4); + tile.rotation = l; + tile.color = colorTableInts[15 - par6ItemStack.getItemDamage()]; + if (par6ItemStack.hasTagCompound() && par6ItemStack.getTagCompound().hasKey(BRUSH_COLOR_TAG)) { tile.color = par6ItemStack.getTagCompound().getInteger(BRUSH_COLOR_TAG); } - par1World.setBlockMetadataWithNotify(par2, par3, par4, par6ItemStack.getItemDamage() , 2); - par1World.setBlock(par2, par3 + 1, par4, this, par6ItemStack.getItemDamage() + 7, 2); - } + par1World.setBlockMetadataWithNotify(par2, par3, par4, par6ItemStack.getItemDamage(), 2); + par1World.setBlock(par2, par3 + 1, par4, this, par6ItemStack.getItemDamage() + 7, 2); + } } @Override - public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z){ + public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z) { int meta = world.getBlockMetadata(x, y, z); - if(meta >= 7) + if (meta >= 7) setBlockBounds(0, -1, 0, 1, 1, 1); else setBlockBounds(0, 0, 0, 1, 2, 1); } @Override - public boolean isOpaqueCube(){ - return false; - } + public boolean isOpaqueCube() { + return false; + } @Override - public boolean renderAsNormalBlock(){ - return false; - } + public boolean renderAsNormalBlock() { + return false; + } + @Override - public int getRenderType(){ - return renderId; - } + public int getRenderType() { + return renderId; + } @Override @SideOnly(Side.CLIENT) - public void registerBlockIcons(IIconRegister par1IconRegister) - {} + public void registerBlockIcons(IIconRegister par1IconRegister) { + } @Override @SideOnly(Side.CLIENT) - public IIcon getIcon(int p_149691_1_, int meta) - { - meta %= 7; - if(meta == 1) + public IIcon getIcon(int p_149691_1_, int meta) { + meta %= 7; + if (meta == 1) return Blocks.stone.getIcon(p_149691_1_, 0); - else if(meta == 2) + else if (meta == 2) return Blocks.iron_block.getIcon(p_149691_1_, 0); - else if(meta == 3) + else if (meta == 3) return Blocks.gold_block.getIcon(p_149691_1_, 0); - else if(meta == 4) + else if (meta == 4) return Blocks.diamond_block.getIcon(p_149691_1_, 0); return Blocks.planks.getIcon(p_149691_1_, 0); } - @Override - public TileEntity createNewTileEntity(World var1, int var2) { - if(var2 < 7) - return new TileTallLamp(); - else - return null; - } + @Override + public TileEntity createNewTileEntity(World var1, int var2) { + if (var2 < 7) + return new TileTallLamp(); + else + return null; + } - @Override - public void onBlockHarvested(World p_149681_1_, int p_149681_2_, int p_149681_3_, int p_149681_4_, int p_149681_5_, EntityPlayer p_149681_6_) - { + @Override + public void onBlockHarvested(World p_149681_1_, int p_149681_2_, int p_149681_3_, int p_149681_4_, int p_149681_5_, EntityPlayer p_149681_6_) { if (p_149681_5_ >= 7 && p_149681_1_.getBlock(p_149681_2_, p_149681_3_ - 1, p_149681_4_) == this) p_149681_1_.setBlockToAir(p_149681_2_, p_149681_3_ - 1, p_149681_4_); @@ -167,7 +166,7 @@ public class BlockTallLamp extends BlockContainer { @Override public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) { int meta = world.getBlockMetadata(x, y, z); - if(meta >= 7) + if (meta >= 7) y--; TileEntity tileentity = world.getTileEntity(x, y, z); diff --git a/src/main/java/noppes/npcs/blocks/BlockTombstone.java b/src/main/java/noppes/npcs/blocks/BlockTombstone.java index 987761666..060f20fa3 100644 --- a/src/main/java/noppes/npcs/blocks/BlockTombstone.java +++ b/src/main/java/noppes/npcs/blocks/BlockTombstone.java @@ -28,104 +28,106 @@ import noppes.npcs.constants.EnumGuiType; import java.util.List; -public class BlockTombstone extends BlockContainer{ +public class BlockTombstone extends BlockContainer { - public int renderId = -1; + public int renderId = -1; - public BlockTombstone() { + public BlockTombstone() { super(Material.rock); - } + } @Override - public int damageDropped(int par1){ + public int damageDropped(int par1) { return par1; } @Override - public boolean onBlockActivated(World par1World, int i, int j, int k, EntityPlayer player, int par6, float par7, float par8, float par9){ - if(par1World.isRemote) - return false; - ItemStack currentItem = player.inventory.getCurrentItem(); - if (currentItem != null && currentItem.getItem() == CustomItems.wand && CustomNpcsPermissions.hasPermission(player, CustomNpcsPermissions.EDIT_TOMBSTONE)) { - TileBigSign tile = (TileBigSign) par1World.getTileEntity(i, j, k); - if(tile.getBlockMetadata() >= 2) - return false; - tile.canEdit = true; - NoppesUtilServer.sendOpenGui(player, EnumGuiType.BigSign, null, i, j, k); - return true; - } - return false; + public boolean onBlockActivated(World par1World, int i, int j, int k, EntityPlayer player, int par6, float par7, float par8, float par9) { + if (par1World.isRemote) + return false; + ItemStack currentItem = player.inventory.getCurrentItem(); + if (currentItem != null && currentItem.getItem() == CustomItems.wand && CustomNpcsPermissions.hasPermission(player, CustomNpcsPermissions.EDIT_TOMBSTONE)) { + TileBigSign tile = (TileBigSign) par1World.getTileEntity(i, j, k); + if (tile.getBlockMetadata() >= 2) + return false; + tile.canEdit = true; + NoppesUtilServer.sendOpenGui(player, EnumGuiType.BigSign, null, i, j, k); + return true; + } + return false; } + @Override - public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLivingBase par5EntityLivingBase, ItemStack par6ItemStack){ - int l = MathHelper.floor_double((double)(par5EntityLivingBase.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3; + public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLivingBase par5EntityLivingBase, ItemStack par6ItemStack) { + int l = MathHelper.floor_double((double) (par5EntityLivingBase.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3; l %= 4; TileBigSign tile = (TileBigSign) par1World.getTileEntity(par2, par3, par4); - tile.rotation = l; + tile.rotation = l; - par1World.setBlockMetadataWithNotify(par2, par3, par4, par6ItemStack.getItemDamage() , 2); + par1World.setBlockMetadataWithNotify(par2, par3, par4, par6ItemStack.getItemDamage(), 2); - if(par5EntityLivingBase instanceof EntityPlayer && par1World.isRemote && par6ItemStack.getItemDamage() < 2){ - CustomNpcs.proxy.openGui(par2, par3, par4, EnumGuiType.BigSign, (EntityPlayer) par5EntityLivingBase); - } + if (par5EntityLivingBase instanceof EntityPlayer && par1World.isRemote && par6ItemStack.getItemDamage() < 2) { + CustomNpcs.proxy.openGui(par2, par3, par4, EnumGuiType.BigSign, (EntityPlayer) par5EntityLivingBase); + } } - public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, int y, int z){ - setBlockBoundsBasedOnState(world, x, y, z); - return super.getCollisionBoundingBoxFromPool(world, x, y, z); + + public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, int y, int z) { + setBlockBoundsBasedOnState(world, x, y, z); + return super.getCollisionBoundingBoxFromPool(world, x, y, z); } @Override - public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z){ - TileEntity tileentity = world.getTileEntity(x, y, z); - if(!(tileentity instanceof TileVariant)){ - super.setBlockBoundsBasedOnState(world, x, y, z); - return; - } - TileVariant tile = (TileVariant) tileentity; - if(tile.rotation % 2 == 0) + public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z) { + TileEntity tileentity = world.getTileEntity(x, y, z); + if (!(tileentity instanceof TileVariant)) { + super.setBlockBoundsBasedOnState(world, x, y, z); + return; + } + TileVariant tile = (TileVariant) tileentity; + if (tile.rotation % 2 == 0) setBlockBounds(0, 0, 0.3f, 1, 1, 0.7f); - else + else setBlockBounds(0.3f, 0, 0, 0.7f, 1, 1); } @Override - public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List){ + public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) { par3List.add(new ItemStack(par1, 1, 0)); par3List.add(new ItemStack(par1, 1, 1)); par3List.add(new ItemStack(par1, 1, 2)); } @Override - public boolean isOpaqueCube(){ - return false; - } + public boolean isOpaqueCube() { + return false; + } @Override - public boolean renderAsNormalBlock(){ - return false; - } + public boolean renderAsNormalBlock() { + return false; + } + @Override - public int getRenderType(){ - return renderId; - } + public int getRenderType() { + return renderId; + } @Override @SideOnly(Side.CLIENT) - public void registerBlockIcons(IIconRegister par1IconRegister) - { + public void registerBlockIcons(IIconRegister par1IconRegister) { } + @Override @SideOnly(Side.CLIENT) - public IIcon getIcon(int p_149691_1_, int meta) - { + public IIcon getIcon(int p_149691_1_, int meta) { return Blocks.stone.getIcon(p_149691_1_, meta); } - @Override - public TileEntity createNewTileEntity(World var1, int var2) { - return new TileTombstone(); - } + @Override + public TileEntity createNewTileEntity(World var1, int var2) { + return new TileTombstone(); + } } diff --git a/src/main/java/noppes/npcs/blocks/BlockTrigger.java b/src/main/java/noppes/npcs/blocks/BlockTrigger.java index 7805ca6f8..3f1823d05 100644 --- a/src/main/java/noppes/npcs/blocks/BlockTrigger.java +++ b/src/main/java/noppes/npcs/blocks/BlockTrigger.java @@ -5,31 +5,31 @@ import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import noppes.npcs.blocks.tiles.TileVariant; -public abstract class BlockTrigger extends BlockRotated{ +public abstract class BlockTrigger extends BlockRotated { - protected BlockTrigger(Block block) { - super(block); - } + protected BlockTrigger(Block block) { + super(block); + } - @Override - public boolean canProvidePower(){ + @Override + public boolean canProvidePower() { return true; } - @Override - public int isProvidingStrongPower(IBlockAccess world, int x, int y, int z, int p_149748_5_){ + @Override + public int isProvidingStrongPower(IBlockAccess world, int x, int y, int z, int p_149748_5_) { return this.isProvidingWeakPower(world, x, y, z, p_149748_5_); } - @Override - public int isProvidingWeakPower(IBlockAccess world, int x, int y, int z, int p_149709_5_){ - TileVariant tile = (TileVariant)world.getTileEntity(x, y, z); - if(tile != null) - return tile.powerProvided(); + @Override + public int isProvidingWeakPower(IBlockAccess world, int x, int y, int z, int p_149709_5_) { + TileVariant tile = (TileVariant) world.getTileEntity(x, y, z); + if (tile != null) + return tile.powerProvided(); return 0; } - public void updateSurrounding(World par1World, int par2, int par3, int par4){ + public void updateSurrounding(World par1World, int par2, int par3, int par4) { par1World.notifyBlocksOfNeighborChange(par2, par3, par4, this); par1World.notifyBlocksOfNeighborChange(par2, par3 - 1, par4, this); par1World.notifyBlocksOfNeighborChange(par2, par3 + 1, par4, this); diff --git a/src/main/java/noppes/npcs/blocks/BlockWallBanner.java b/src/main/java/noppes/npcs/blocks/BlockWallBanner.java index be07389d8..3e4aeec6e 100644 --- a/src/main/java/noppes/npcs/blocks/BlockWallBanner.java +++ b/src/main/java/noppes/npcs/blocks/BlockWallBanner.java @@ -26,64 +26,63 @@ import java.util.List; import static kamkeel.npcs.util.ColorUtil.colorTableInts; import static noppes.npcs.items.ItemNpcTool.BRUSH_COLOR_TAG; -public class BlockWallBanner extends BlockContainer{ +public class BlockWallBanner extends BlockContainer { - public int renderId = -1; + public int renderId = -1; - public BlockWallBanner() { + public BlockWallBanner() { super(Material.rock); - } - @Override - public boolean onBlockActivated(World par1World, int i, int j, int k, EntityPlayer player, int par6, float par7, float par8, float par9){ - ItemStack item = player.inventory.getCurrentItem(); - if(item == null) - return false; + } - if(item.getItem() != null && item.getItem() instanceof ItemNpcTool && item.getItemDamage() == 0) + @Override + public boolean onBlockActivated(World par1World, int i, int j, int k, EntityPlayer player, int par6, float par7, float par8, float par9) { + ItemStack item = player.inventory.getCurrentItem(); + if (item == null) return false; - TileWallBanner tile = (TileWallBanner) par1World.getTileEntity(i, j, k); - if(tile.canEdit()) - return true; - else if(TileColorable.allowColorChange(item) != TileColorable.ColorChangeType.DYE) + if (item.getItem() != null && item.getItem() instanceof ItemNpcTool && item.getItemDamage() == 0) + return false; + + TileWallBanner tile = (TileWallBanner) par1World.getTileEntity(i, j, k); + if (tile.canEdit()) + return true; + else if (TileColorable.allowColorChange(item) != TileColorable.ColorChangeType.DYE) return false; int color = colorTableInts[BlockColored.func_150031_c(item.getItemDamage())]; - if(tile.color != color){ - NoppesUtilServer.consumeItemStack(1, player); - tile.color = color; - par1World.markBlockForUpdate(i, j, k); - } - return true; + if (tile.color != color) { + NoppesUtilServer.consumeItemStack(1, player); + tile.color = color; + par1World.markBlockForUpdate(i, j, k); + } + return true; } @Override - public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLivingBase par5EntityLivingBase, ItemStack par6ItemStack) - { - int l = MathHelper.floor_double((double)(par5EntityLivingBase.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3; + public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLivingBase par5EntityLivingBase, ItemStack par6ItemStack) { + int l = MathHelper.floor_double((double) (par5EntityLivingBase.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3; l %= 4; - TileWallBanner tile = (TileWallBanner) par1World.getTileEntity(par2, par3, par4); + TileWallBanner tile = (TileWallBanner) par1World.getTileEntity(par2, par3, par4); tile.rotation = l; tile.color = colorTableInts[15 - par6ItemStack.getItemDamage()]; - if(par6ItemStack.hasTagCompound() && par6ItemStack.getTagCompound().hasKey(BRUSH_COLOR_TAG)){ + if (par6ItemStack.hasTagCompound() && par6ItemStack.getTagCompound().hasKey(BRUSH_COLOR_TAG)) { tile.color = par6ItemStack.getTagCompound().getInteger(BRUSH_COLOR_TAG); } - tile.time = System.currentTimeMillis(); + tile.time = System.currentTimeMillis(); par1World.setBlockMetadataWithNotify(par2, par3, par4, par6ItemStack.getItemDamage(), 2); - if(par5EntityLivingBase instanceof EntityPlayer && par1World.isRemote) - ((EntityPlayer)par5EntityLivingBase).addChatComponentMessage(new ChatComponentTranslation("availability.editIcon")); + if (par5EntityLivingBase instanceof EntityPlayer && par1World.isRemote) + ((EntityPlayer) par5EntityLivingBase).addChatComponentMessage(new ChatComponentTranslation("availability.editIcon")); } - public AxisAlignedBB getCollisionBoundingBoxFromPool(World p_149668_1_, int p_149668_2_, int p_149668_3_, int p_149668_4_) - { - return null; + public AxisAlignedBB getCollisionBoundingBoxFromPool(World p_149668_1_, int p_149668_2_, int p_149668_3_, int p_149668_4_) { + return null; } @Override - public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List){ + public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) { par3List.add(new ItemStack(par1, 1, 0)); par3List.add(new ItemStack(par1, 1, 1)); par3List.add(new ItemStack(par1, 1, 2)); @@ -93,51 +92,50 @@ public class BlockWallBanner extends BlockContainer{ @Override - public int damageDropped(int par1) - { + public int damageDropped(int par1) { return par1; } @Override - public boolean isOpaqueCube(){ - return false; - } + public boolean isOpaqueCube() { + return false; + } @Override - public boolean renderAsNormalBlock(){ - return false; - } + public boolean renderAsNormalBlock() { + return false; + } + @Override - public int getRenderType(){ - return renderId; - } + public int getRenderType() { + return renderId; + } @Override @SideOnly(Side.CLIENT) - public void registerBlockIcons(IIconRegister par1IconRegister) - { + public void registerBlockIcons(IIconRegister par1IconRegister) { } + @Override @SideOnly(Side.CLIENT) - public IIcon getIcon(int p_149691_1_, int meta) - { - meta %= 7; - if(meta == 1) + public IIcon getIcon(int p_149691_1_, int meta) { + meta %= 7; + if (meta == 1) return Blocks.stone.getIcon(p_149691_1_, 0); - else if(meta == 2) + else if (meta == 2) return Blocks.iron_block.getIcon(p_149691_1_, 0); - else if(meta == 3) + else if (meta == 3) return Blocks.gold_block.getIcon(p_149691_1_, 0); - else if(meta == 4) + else if (meta == 4) return Blocks.diamond_block.getIcon(p_149691_1_, 0); return Blocks.planks.getIcon(p_149691_1_, 0); } - @Override - public TileEntity createNewTileEntity(World var1, int var2) { - return new TileWallBanner(); - } + @Override + public TileEntity createNewTileEntity(World var1, int var2) { + return new TileWallBanner(); + } @Override public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) { diff --git a/src/main/java/noppes/npcs/blocks/BlockWaypoint.java b/src/main/java/noppes/npcs/blocks/BlockWaypoint.java index 7920b46d9..7e0fd2601 100644 --- a/src/main/java/noppes/npcs/blocks/BlockWaypoint.java +++ b/src/main/java/noppes/npcs/blocks/BlockWaypoint.java @@ -17,39 +17,38 @@ import noppes.npcs.CustomNpcsPermissions; import noppes.npcs.blocks.tiles.TileWaypoint; import noppes.npcs.constants.EnumGuiType; -public class BlockWaypoint extends BlockContainer{ +public class BlockWaypoint extends BlockContainer { - public BlockWaypoint() { + public BlockWaypoint() { super(Material.iron); this.setCreativeTab(CustomItems.tab); - } - - @Override - public boolean onBlockActivated(World par1World, int i, int j, int k, EntityPlayer player, int par6, float par7, float par8, float par9) - { - if(par1World.isRemote) - return false; - ItemStack currentItem = player.inventory.getCurrentItem(); - if (currentItem != null && currentItem.getItem() == CustomItems.wand && CustomNpcsPermissions.hasPermission(player, CustomNpcsPermissions.EDIT_WAYPOINT)) { - TileEntity tile = par1World.getTileEntity(i, j, k); - NBTTagCompound compound = new NBTTagCompound(); - tile.writeToNBT(compound); - PacketHandler.Instance.sendToPlayer(new GuiWaypointPacket(compound), (EntityPlayerMP)player); - return true; - } - return false; } @Override - public void onBlockPlacedBy(World world, int i, int j, int k, EntityLivingBase entityliving, ItemStack item){ - if(entityliving instanceof EntityPlayer && world.isRemote){ - CustomNpcs.proxy.openGui(i, j, k, EnumGuiType.Waypoint, (EntityPlayer) entityliving); - } + public boolean onBlockActivated(World par1World, int i, int j, int k, EntityPlayer player, int par6, float par7, float par8, float par9) { + if (par1World.isRemote) + return false; + ItemStack currentItem = player.inventory.getCurrentItem(); + if (currentItem != null && currentItem.getItem() == CustomItems.wand && CustomNpcsPermissions.hasPermission(player, CustomNpcsPermissions.EDIT_WAYPOINT)) { + TileEntity tile = par1World.getTileEntity(i, j, k); + NBTTagCompound compound = new NBTTagCompound(); + tile.writeToNBT(compound); + PacketHandler.Instance.sendToPlayer(new GuiWaypointPacket(compound), (EntityPlayerMP) player); + return true; + } + return false; } - @Override - public TileEntity createNewTileEntity(World var1, int var2) { - return new TileWaypoint(); - } + @Override + public void onBlockPlacedBy(World world, int i, int j, int k, EntityLivingBase entityliving, ItemStack item) { + if (entityliving instanceof EntityPlayer && world.isRemote) { + CustomNpcs.proxy.openGui(i, j, k, EnumGuiType.Waypoint, (EntityPlayer) entityliving); + } + } + + @Override + public TileEntity createNewTileEntity(World var1, int var2) { + return new TileWaypoint(); + } } diff --git a/src/main/java/noppes/npcs/blocks/BlockWeaponRack.java b/src/main/java/noppes/npcs/blocks/BlockWeaponRack.java index 41554f83a..16adf7c98 100644 --- a/src/main/java/noppes/npcs/blocks/BlockWeaponRack.java +++ b/src/main/java/noppes/npcs/blocks/BlockWeaponRack.java @@ -19,48 +19,49 @@ import noppes.npcs.blocks.tiles.TileWeaponRack; import java.util.List; -public class BlockWeaponRack extends BlockTrigger{ +public class BlockWeaponRack extends BlockTrigger { - public BlockWeaponRack() { + public BlockWeaponRack() { super(Blocks.planks); - } - @Override - public boolean onBlockActivated(World par1World, int i, int j, int k, EntityPlayer player, int side, float hitX, float hitY, float hitZ){ - if(par1World.isRemote) - return true; - int meta = par1World.getBlockMetadata(i, j, k); - if(meta >= 7) - j--; - TileWeaponRack tile = (TileWeaponRack) par1World.getTileEntity(i, j, k); - float hit = hitX; - if(tile.rotation == 2) - hit = 1 - hitX; - if(tile.rotation == 3) - hit = 1 - hitZ; - if(tile.rotation == 1) - hit = hitZ; - - int selected = 2 - (int) (hit / 0.34); - ItemStack item = player.getCurrentEquippedItem(); - ItemStack weapon = tile.getStackInSlot(selected); - if(item == null && weapon != null){ - tile.setInventorySlotContents(selected, null); - player.inventory.setInventorySlotContents(player.inventory.currentItem, weapon); - par1World.markBlockForUpdate(i, j, k); - updateSurrounding(par1World, i, j, k); - } - else if(item == null || item.getItem() == null || item.getItem() instanceof ItemBlock) - return true; - else if(item != null && weapon == null){ - tile.setInventorySlotContents(selected, item); - player.inventory.setInventorySlotContents(player.inventory.currentItem, null); - par1World.markBlockForUpdate(i, j, k); - updateSurrounding(par1World, i, j, k); - } - return true; } + @Override - public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List){ + public boolean onBlockActivated(World par1World, int i, int j, int k, EntityPlayer player, int side, float hitX, float hitY, float hitZ) { + if (par1World.isRemote) + return true; + int meta = par1World.getBlockMetadata(i, j, k); + if (meta >= 7) + j--; + TileWeaponRack tile = (TileWeaponRack) par1World.getTileEntity(i, j, k); + float hit = hitX; + if (tile.rotation == 2) + hit = 1 - hitX; + if (tile.rotation == 3) + hit = 1 - hitZ; + if (tile.rotation == 1) + hit = hitZ; + + int selected = 2 - (int) (hit / 0.34); + ItemStack item = player.getCurrentEquippedItem(); + ItemStack weapon = tile.getStackInSlot(selected); + if (item == null && weapon != null) { + tile.setInventorySlotContents(selected, null); + player.inventory.setInventorySlotContents(player.inventory.currentItem, weapon); + par1World.markBlockForUpdate(i, j, k); + updateSurrounding(par1World, i, j, k); + } else if (item == null || item.getItem() == null || item.getItem() instanceof ItemBlock) + return true; + else if (item != null && weapon == null) { + tile.setInventorySlotContents(selected, item); + player.inventory.setInventorySlotContents(player.inventory.currentItem, null); + par1World.markBlockForUpdate(i, j, k); + updateSurrounding(par1World, i, j, k); + } + return true; + } + + @Override + public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) { par3List.add(new ItemStack(par1, 1, 0)); par3List.add(new ItemStack(par1, 1, 1)); par3List.add(new ItemStack(par1, 1, 2)); @@ -70,73 +71,72 @@ public class BlockWeaponRack extends BlockTrigger{ } @Override - public int damageDropped(int par1){ + public int damageDropped(int par1) { return par1 % 7; } @Override - public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLivingBase par5EntityLivingBase, ItemStack par6ItemStack){ - if(!par1World.isAirBlock(par2, par3 + 1, par4)){ - par1World.setBlockToAir(par2, par3, par4); - } - else{ - int l = MathHelper.floor_double((double)(par5EntityLivingBase.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3; - l %= 4; + public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLivingBase par5EntityLivingBase, ItemStack par6ItemStack) { + if (!par1World.isAirBlock(par2, par3 + 1, par4)) { + par1World.setBlockToAir(par2, par3, par4); + } else { + int l = MathHelper.floor_double((double) (par5EntityLivingBase.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3; + l %= 4; - TileVariant tile = (TileVariant) par1World.getTileEntity(par2, par3, par4); - tile.rotation = l; + TileVariant tile = (TileVariant) par1World.getTileEntity(par2, par3, par4); + tile.rotation = l; - par1World.setBlockMetadataWithNotify(par2, par3, par4, par6ItemStack.getItemDamage() , 2); - par1World.setBlock(par2, par3 + 1, par4, this, par6ItemStack.getItemDamage() + 7, 2); - } + par1World.setBlockMetadataWithNotify(par2, par3, par4, par6ItemStack.getItemDamage(), 2); + par1World.setBlock(par2, par3 + 1, par4, this, par6ItemStack.getItemDamage() + 7, 2); + } } - public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, int y, int z){ - setBlockBoundsBasedOnState(world, x, y, z); - return super.getCollisionBoundingBoxFromPool(world, x, y, z); + + public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, int y, int z) { + setBlockBoundsBasedOnState(world, x, y, z); + return super.getCollisionBoundingBoxFromPool(world, x, y, z); } @Override - public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z){ + public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z) { int meta = world.getBlockMetadata(x, y, z); - if(meta >= 7) - y--; - TileEntity tileentity = world.getTileEntity(x, y, z); - if(!(tileentity instanceof TileVariant)){ - super.setBlockBoundsBasedOnState(world, x, y, z); - return; - } - TileVariant tile = (TileVariant) tileentity; - float xStart = 0; - float zStart = 0; - float xEnd = 1; - float zEnd = 1; - if(tile.rotation == 0) - zStart = 0.7f; - else if(tile.rotation == 2) - zEnd = 0.3f; - else if(tile.rotation == 3) - xStart = 0.7f; - else if(tile.rotation == 1) - xEnd = 0.3f; - if(meta >= 7) + if (meta >= 7) + y--; + TileEntity tileentity = world.getTileEntity(x, y, z); + if (!(tileentity instanceof TileVariant)) { + super.setBlockBoundsBasedOnState(world, x, y, z); + return; + } + TileVariant tile = (TileVariant) tileentity; + float xStart = 0; + float zStart = 0; + float xEnd = 1; + float zEnd = 1; + if (tile.rotation == 0) + zStart = 0.7f; + else if (tile.rotation == 2) + zEnd = 0.3f; + else if (tile.rotation == 3) + xStart = 0.7f; + else if (tile.rotation == 1) + xEnd = 0.3f; + if (meta >= 7) setBlockBounds(xStart, -1, zStart, xEnd, 0.8f, zEnd); else setBlockBounds(xStart, 0, zStart, xEnd, 1.8f, zEnd); } - @Override - public TileEntity createNewTileEntity(World var1, int var2) { - if(var2 < 7) - return new TileWeaponRack(); - else - return null; - } + @Override + public TileEntity createNewTileEntity(World var1, int var2) { + if (var2 < 7) + return new TileWeaponRack(); + else + return null; + } - @Override - public void onBlockHarvested(World p_149681_1_, int p_149681_2_, int p_149681_3_, int p_149681_4_, int p_149681_5_, EntityPlayer p_149681_6_) - { + @Override + public void onBlockHarvested(World p_149681_1_, int p_149681_2_, int p_149681_3_, int p_149681_4_, int p_149681_5_, EntityPlayer p_149681_6_) { if (p_149681_5_ >= 7 && p_149681_1_.getBlock(p_149681_2_, p_149681_3_ - 1, p_149681_4_) == this) p_149681_1_.setBlockToAir(p_149681_2_, p_149681_3_ - 1, p_149681_4_); @@ -144,11 +144,11 @@ public class BlockWeaponRack extends BlockTrigger{ p_149681_1_.setBlockToAir(p_149681_2_, p_149681_3_ + 1, p_149681_4_); } - @Override - public void breakBlock(World world, int x, int y, int z, Block block, int p_149749_6_){ - TileNpcContainer tile = (TileNpcContainer)world.getTileEntity(x, y, z); + @Override + public void breakBlock(World world, int x, int y, int z, Block block, int p_149749_6_) { + TileNpcContainer tile = (TileNpcContainer) world.getTileEntity(x, y, z); if (tile == null) - return; + return; tile.dropItems(world, x, y, z); world.func_147453_f(x, y, z, block); diff --git a/src/main/java/noppes/npcs/blocks/tiles/TileBanner.java b/src/main/java/noppes/npcs/blocks/tiles/TileBanner.java index 9c1300f8d..82608b642 100644 --- a/src/main/java/noppes/npcs/blocks/tiles/TileBanner.java +++ b/src/main/java/noppes/npcs/blocks/tiles/TileBanner.java @@ -7,11 +7,11 @@ import noppes.npcs.constants.EnumBannerVariant; public class TileBanner extends TileColorable implements ITileIcon { - public ItemStack icon; + public ItemStack icon; public EnumBannerVariant bannerTrim = EnumBannerVariant.Normal; - public long time = 0; + public long time = 0; - public void readFromNBT(NBTTagCompound compound){ + public void readFromNBT(NBTTagCompound compound) { super.readFromNBT(compound); icon = ItemStack.loadItemStackFromNBT(compound.getCompoundTag("BannerIcon")); @@ -23,30 +23,30 @@ public class TileBanner extends TileColorable implements ITileIcon { } } - public void writeToNBT(NBTTagCompound compound){ - super.writeToNBT(compound); - if(icon != null) - compound.setTag("BannerIcon", icon.writeToNBT(new NBTTagCompound())); + public void writeToNBT(NBTTagCompound compound) { + super.writeToNBT(compound); + if (icon != null) + compound.setTag("BannerIcon", icon.writeToNBT(new NBTTagCompound())); compound.setInteger("BannerVariant", bannerTrim.ordinal()); } - @Override - public AxisAlignedBB getRenderBoundingBox(){ - return AxisAlignedBB.getBoundingBox(xCoord, yCoord, zCoord, xCoord + 1, yCoord + 2, zCoord + 1); + @Override + public AxisAlignedBB getRenderBoundingBox() { + return AxisAlignedBB.getBoundingBox(xCoord, yCoord, zCoord, xCoord + 1, yCoord + 2, zCoord + 1); } @Override - public boolean canEdit(){ - return System.currentTimeMillis() - time < 20000; - } + public boolean canEdit() { + return System.currentTimeMillis() - time < 20000; + } @Override - public void setTime(long time){ + public void setTime(long time) { this.time = time; } @Override - public void setIcon(ItemStack stack){ + public void setIcon(ItemStack stack) { this.icon = stack; } diff --git a/src/main/java/noppes/npcs/blocks/tiles/TileBarrel.java b/src/main/java/noppes/npcs/blocks/tiles/TileBarrel.java index c286ea239..e9b3f0b7c 100644 --- a/src/main/java/noppes/npcs/blocks/tiles/TileBarrel.java +++ b/src/main/java/noppes/npcs/blocks/tiles/TileBarrel.java @@ -1,11 +1,10 @@ package noppes.npcs.blocks.tiles; +public class TileBarrel extends TileNpcContainer { -public class TileBarrel extends TileNpcContainer{ - - @Override - public String getName() { - return "tile.npcBarrel.name"; - } + @Override + public String getName() { + return "tile.npcBarrel.name"; + } } diff --git a/src/main/java/noppes/npcs/blocks/tiles/TileBigSign.java b/src/main/java/noppes/npcs/blocks/tiles/TileBigSign.java index 4f27af0a2..253d17a68 100644 --- a/src/main/java/noppes/npcs/blocks/tiles/TileBigSign.java +++ b/src/main/java/noppes/npcs/blocks/tiles/TileBigSign.java @@ -8,50 +8,50 @@ import net.minecraft.tileentity.TileEntity; import noppes.npcs.TextBlock; public class TileBigSign extends TileEntity { - - public int rotation; - public boolean canEdit = true; - public boolean hasChanged = true; + + public int rotation; + public boolean canEdit = true; + public boolean hasChanged = true; private String signText = ""; public TextBlock block; - public void readFromNBT(NBTTagCompound compound){ + public void readFromNBT(NBTTagCompound compound) { super.readFromNBT(compound); rotation = compound.getInteger("SignRotation"); setText(compound.getString("SignText")); } - public void writeToNBT(NBTTagCompound compound){ - super.writeToNBT(compound); - compound.setInteger("SignRotation", rotation); - compound.setString("SignText", signText); + public void writeToNBT(NBTTagCompound compound) { + super.writeToNBT(compound); + compound.setInteger("SignRotation", rotation); + compound.setString("SignText", signText); } - - public boolean canUpdate(){ + + public boolean canUpdate() { return false; } - public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt){ - NBTTagCompound compound = pkt.func_148857_g(); - readFromNBT(compound); + public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) { + NBTTagCompound compound = pkt.func_148857_g(); + readFromNBT(compound); } - - public void setText(String text){ - this.signText = text; - hasChanged = true; + + public void setText(String text) { + this.signText = text; + hasChanged = true; } - - public String getText(){ - return signText; + + public String getText() { + return signText; } - + @Override - public Packet getDescriptionPacket(){ - NBTTagCompound compound = new NBTTagCompound(); - writeToNBT(compound); - S35PacketUpdateTileEntity packet = new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, 0, compound); - return packet; + public Packet getDescriptionPacket() { + NBTTagCompound compound = new NBTTagCompound(); + writeToNBT(compound); + S35PacketUpdateTileEntity packet = new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, 0, compound); + return packet; } } diff --git a/src/main/java/noppes/npcs/blocks/tiles/TileBlockAnvil.java b/src/main/java/noppes/npcs/blocks/tiles/TileBlockAnvil.java index f2fe76ca9..59c2bb1f9 100644 --- a/src/main/java/noppes/npcs/blocks/tiles/TileBlockAnvil.java +++ b/src/main/java/noppes/npcs/blocks/tiles/TileBlockAnvil.java @@ -7,9 +7,10 @@ public class TileBlockAnvil extends TileEntity { public boolean firstTick = true; - public TileBlockAnvil(){} + public TileBlockAnvil() { + } - public boolean canUpdate(){ + public boolean canUpdate() { return true; } diff --git a/src/main/java/noppes/npcs/blocks/tiles/TileBook.java b/src/main/java/noppes/npcs/blocks/tiles/TileBook.java index 0c0bf7e0f..7001de94e 100644 --- a/src/main/java/noppes/npcs/blocks/tiles/TileBook.java +++ b/src/main/java/noppes/npcs/blocks/tiles/TileBook.java @@ -6,16 +6,17 @@ import net.minecraft.nbt.NBTTagCompound; public class TileBook extends TileVariant { - public ItemStack book = new ItemStack(Items.writable_book); - public void readFromNBT(NBTTagCompound compound){ + public ItemStack book = new ItemStack(Items.writable_book); + + public void readFromNBT(NBTTagCompound compound) { super.readFromNBT(compound); book = ItemStack.loadItemStackFromNBT(compound.getCompoundTag("Items")); - if(book == null) - book = new ItemStack(Items.writable_book); + if (book == null) + book = new ItemStack(Items.writable_book); } - public void writeToNBT(NBTTagCompound compound){ - super.writeToNBT(compound); - compound.setTag("Items", book.writeToNBT(new NBTTagCompound())); + public void writeToNBT(NBTTagCompound compound) { + super.writeToNBT(compound); + compound.setTag("Items", book.writeToNBT(new NBTTagCompound())); } } diff --git a/src/main/java/noppes/npcs/blocks/tiles/TileBorder.java b/src/main/java/noppes/npcs/blocks/tiles/TileBorder.java index 32b9b80e8..2e3cafbea 100644 --- a/src/main/java/noppes/npcs/blocks/tiles/TileBorder.java +++ b/src/main/java/noppes/npcs/blocks/tiles/TileBorder.java @@ -16,20 +16,20 @@ import noppes.npcs.controllers.data.Availability; import java.util.List; -public class TileBorder extends TileEntity implements IEntitySelector{ - public Availability availability = new Availability(); - public AxisAlignedBB boundingbox; - public int rotation = 0; - public int height = 10; - public String message = "availability.areaNotAvailble"; +public class TileBorder extends TileEntity implements IEntitySelector { + public Availability availability = new Availability(); + public AxisAlignedBB boundingbox; + public int rotation = 0; + public int height = 10; + public String message = "availability.areaNotAvailble"; @Override - public void readFromNBT(NBTTagCompound compound){ + public void readFromNBT(NBTTagCompound compound) { super.readFromNBT(compound); readExtraNBT(compound); } - - public void readExtraNBT(NBTTagCompound compound){ + + public void readExtraNBT(NBTTagCompound compound) { availability.readFromNBT(compound.getCompoundTag("BorderAvailability")); rotation = compound.getInteger("BorderRotation"); height = compound.getInteger("BorderHeight"); @@ -37,78 +37,76 @@ public class TileBorder extends TileEntity implements IEntitySelector{ } @Override - public void writeToNBT(NBTTagCompound compound){ - super.writeToNBT(compound); - writeExtraNBT(compound); + public void writeToNBT(NBTTagCompound compound) { + super.writeToNBT(compound); + writeExtraNBT(compound); } - - public void writeExtraNBT(NBTTagCompound compound){ - compound.setTag("BorderAvailability", availability.writeToNBT(new NBTTagCompound())); - compound.setInteger("BorderRotation", rotation); - compound.setInteger("BorderHeight", height); - compound.setString("BorderMessage", message); + + public void writeExtraNBT(NBTTagCompound compound) { + compound.setTag("BorderAvailability", availability.writeToNBT(new NBTTagCompound())); + compound.setInteger("BorderRotation", rotation); + compound.setInteger("BorderHeight", height); + compound.setString("BorderMessage", message); } - + @Override public void updateEntity() { - if(worldObj.isRemote) - return; - AxisAlignedBB box = AxisAlignedBB.getBoundingBox(xCoord, yCoord, zCoord, xCoord + 1, yCoord + height + 1, zCoord + 1); - List list = worldObj.selectEntitiesWithinAABB(Entity.class, box, this); - for(Entity entity : list){ - if(entity instanceof EntityEnderPearl){ - EntityEnderPearl pearl = (EntityEnderPearl) entity; - if(pearl.getThrower() instanceof EntityPlayer && !availability.isAvailable((EntityPlayer)pearl.getThrower())) - entity.isDead = true; - continue; - } - EntityPlayer player = (EntityPlayer) entity; - if(availability.isAvailable(player)) - continue; - int posX = this.xCoord; - int posZ = this.zCoord; - int posY = this.yCoord; - if(rotation == 0){ - posZ--; - } - else if(rotation == 2){ - posZ++; - } - else if(rotation == 1){ - posX++; - } - else if(rotation == 3){ - posX--; - } - while(!worldObj.isAirBlock(posX, posY, posZ)){ - posY++; - } - player.setPositionAndUpdate(posX + 0.5, posY, posZ + 0.5); - if(!message.isEmpty()) - player.addChatComponentMessage(new ChatComponentTranslation(message)); - } + if (worldObj.isRemote) + return; + AxisAlignedBB box = AxisAlignedBB.getBoundingBox(xCoord, yCoord, zCoord, xCoord + 1, yCoord + height + 1, zCoord + 1); + List list = worldObj.selectEntitiesWithinAABB(Entity.class, box, this); + for (Entity entity : list) { + if (entity instanceof EntityEnderPearl) { + EntityEnderPearl pearl = (EntityEnderPearl) entity; + if (pearl.getThrower() instanceof EntityPlayer && !availability.isAvailable((EntityPlayer) pearl.getThrower())) + entity.isDead = true; + continue; + } + EntityPlayer player = (EntityPlayer) entity; + if (availability.isAvailable(player)) + continue; + int posX = this.xCoord; + int posZ = this.zCoord; + int posY = this.yCoord; + if (rotation == 0) { + posZ--; + } else if (rotation == 2) { + posZ++; + } else if (rotation == 1) { + posX++; + } else if (rotation == 3) { + posX--; + } + while (!worldObj.isAirBlock(posX, posY, posZ)) { + posY++; + } + player.setPositionAndUpdate(posX + 0.5, posY, posZ + 0.5); + if (!message.isEmpty()) + player.addChatComponentMessage(new ChatComponentTranslation(message)); + } } - public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt){ - NBTTagCompound compound = pkt.func_148857_g(); - rotation = compound.getInteger("Rotation"); + + public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) { + NBTTagCompound compound = pkt.func_148857_g(); + rotation = compound.getInteger("Rotation"); } - + @Override - public Packet getDescriptionPacket(){ - NBTTagCompound compound = new NBTTagCompound(); - compound.setInteger("Rotation", rotation); - S35PacketUpdateTileEntity packet = new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, 0, compound); - return packet; - + public Packet getDescriptionPacket() { + NBTTagCompound compound = new NBTTagCompound(); + compound.setInteger("Rotation", rotation); + S35PacketUpdateTileEntity packet = new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, 0, compound); + return packet; + } - + @Override - public boolean canUpdate(){ + public boolean canUpdate() { return true; } - @Override - public boolean isEntityApplicable(Entity var1) { - return var1 instanceof EntityPlayerMP || var1 instanceof EntityEnderPearl; - } + @Override + public boolean isEntityApplicable(Entity var1) { + return var1 instanceof EntityPlayerMP || var1 instanceof EntityEnderPearl; + } } diff --git a/src/main/java/noppes/npcs/blocks/tiles/TileCampfire.java b/src/main/java/noppes/npcs/blocks/tiles/TileCampfire.java index 87bd7539b..5fdd2fddd 100644 --- a/src/main/java/noppes/npcs/blocks/tiles/TileCampfire.java +++ b/src/main/java/noppes/npcs/blocks/tiles/TileCampfire.java @@ -14,12 +14,9 @@ public class TileCampfire extends TileVariant { private boolean previousTickLit = false; @Override - public void updateEntity() - { - if (getWorldObj().isRemote) - { - if (isLit()) - { + public void updateEntity() { + if (getWorldObj().isRemote) { + if (isLit()) { if (!previousTickLit || distributedInterval(50L)) rainAndSky = isBeingRainedOn(); @@ -30,31 +27,27 @@ public class TileCampfire extends TileVariant { } } - public boolean distributedInterval(long interval) - { + public boolean distributedInterval(long interval) { if (hasWorldObj()) return (getWorldObj().getTotalWorldTime() + (long) (xCoord + yCoord + zCoord)) % interval == 0L; else return false; } - protected void addParticles() - { + protected void addParticles() { CustomNpcs.proxy.generateBigSmokeParticles(getWorldObj(), xCoord, yCoord, zCoord, false); - if (rainAndSky) - { + if (rainAndSky) { for (int i = 0; i < RAND.nextInt(3); ++i) getWorldObj().spawnParticle("smoke", xCoord + RAND.nextDouble(), yCoord + 0.9, zCoord + RAND.nextDouble(), 0.0, 0.0, 0.0); } } - public boolean isBeingRainedOn() - { + + public boolean isBeingRainedOn() { return getWorldObj().isRaining() && getWorldObj().getPrecipitationHeight(xCoord, zCoord) <= yCoord + 1 && getWorldObj().getBiomeGenForCoords(xCoord, zCoord).canSpawnLightningBolt(); } - public boolean isLit() - { + public boolean isLit() { Block block = this.getBlockType(); return block == CustomItems.campfire; } diff --git a/src/main/java/noppes/npcs/blocks/tiles/TileChair.java b/src/main/java/noppes/npcs/blocks/tiles/TileChair.java index 93fc8be3d..69b42f174 100644 --- a/src/main/java/noppes/npcs/blocks/tiles/TileChair.java +++ b/src/main/java/noppes/npcs/blocks/tiles/TileChair.java @@ -4,11 +4,11 @@ import net.minecraft.util.AxisAlignedBB; public class TileChair extends TileVariant { - public boolean isPushed(){ + public boolean isPushed() { return this.variant == 1; } - public void push(){ + public void push() { // Variant 14 is not pushed, 1 is pushed this.variant = this.variant == 14 ? 1 : 14; this.markDirty(); @@ -16,10 +16,10 @@ public class TileChair extends TileVariant { } @Override - public AxisAlignedBB getRenderBoundingBox(){ - if (isPushed()){ + public AxisAlignedBB getRenderBoundingBox() { + if (isPushed()) { // When pushed, return a thicker vertical slab based on rotation. - switch(this.rotation) { + switch (this.rotation) { case 0: // North. return AxisAlignedBB.getBoundingBox(xCoord + 0.1, yCoord, zCoord, xCoord + 0.9, yCoord + 1, zCoord + 0.3); case 1: // East. diff --git a/src/main/java/noppes/npcs/blocks/tiles/TileColorable.java b/src/main/java/noppes/npcs/blocks/tiles/TileColorable.java index e85efd0b5..560435a8a 100644 --- a/src/main/java/noppes/npcs/blocks/tiles/TileColorable.java +++ b/src/main/java/noppes/npcs/blocks/tiles/TileColorable.java @@ -11,30 +11,30 @@ public class TileColorable extends TileVariant { public int color = 0xFFFFFF; - public void readFromNBT(NBTTagCompound compound){ + public void readFromNBT(NBTTagCompound compound) { super.readFromNBT(compound); color = compound.getInteger(BRUSH_COLOR_TAG); } - public void writeToNBT(NBTTagCompound compound){ - super.writeToNBT(compound); - compound.setInteger(BRUSH_COLOR_TAG, color); + public void writeToNBT(NBTTagCompound compound) { + super.writeToNBT(compound); + compound.setInteger(BRUSH_COLOR_TAG, color); } - public void setColor(int color){ + public void setColor(int color) { this.color = color; this.markDirty(); this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord); } - public static ColorChangeType allowColorChange(ItemStack stack){ - if(stack == null || stack.getItem() == null) + public static ColorChangeType allowColorChange(ItemStack stack) { + if (stack == null || stack.getItem() == null) return ColorChangeType.NONE; - if(stack.getItem() == Items.dye) + if (stack.getItem() == Items.dye) return ColorChangeType.DYE; - if(ItemNpcTool.isPaintbrush(stack)) + if (ItemNpcTool.isPaintbrush(stack)) return ColorChangeType.PAINTBRUSH; return ColorChangeType.NONE; diff --git a/src/main/java/noppes/npcs/blocks/tiles/TileCouchWood.java b/src/main/java/noppes/npcs/blocks/tiles/TileCouchWood.java index 113a95346..7b60afa7a 100644 --- a/src/main/java/noppes/npcs/blocks/tiles/TileCouchWood.java +++ b/src/main/java/noppes/npcs/blocks/tiles/TileCouchWood.java @@ -4,19 +4,19 @@ import net.minecraft.nbt.NBTTagCompound; public class TileCouchWood extends TileVariant { - public boolean hasLeft = false; - public boolean hasRight = false; + public boolean hasLeft = false; + public boolean hasRight = false; - public void readFromNBT(NBTTagCompound compound){ + public void readFromNBT(NBTTagCompound compound) { super.readFromNBT(compound); hasLeft = compound.getBoolean("CouchLeft"); hasRight = compound.getBoolean("CouchRight"); } - public void writeToNBT(NBTTagCompound compound){ - super.writeToNBT(compound); - compound.setBoolean("CouchLeft", hasLeft); - compound.setBoolean("CouchRight", hasRight); + public void writeToNBT(NBTTagCompound compound) { + super.writeToNBT(compound); + compound.setBoolean("CouchLeft", hasLeft); + compound.setBoolean("CouchRight", hasRight); } } diff --git a/src/main/java/noppes/npcs/blocks/tiles/TileCouchWool.java b/src/main/java/noppes/npcs/blocks/tiles/TileCouchWool.java index f3fcc5183..8966281ec 100644 --- a/src/main/java/noppes/npcs/blocks/tiles/TileCouchWool.java +++ b/src/main/java/noppes/npcs/blocks/tiles/TileCouchWool.java @@ -4,12 +4,12 @@ import net.minecraft.nbt.NBTTagCompound; public class TileCouchWool extends TileColorable { - public boolean hasLeft = false; - public boolean hasRight = false; - public boolean hasCornerLeft = false; - public boolean hasCornerRight = false; + public boolean hasLeft = false; + public boolean hasRight = false; + public boolean hasCornerLeft = false; + public boolean hasCornerRight = false; - public void readFromNBT(NBTTagCompound compound){ + public void readFromNBT(NBTTagCompound compound) { super.readFromNBT(compound); hasLeft = compound.getBoolean("CouchLeft"); hasRight = compound.getBoolean("CouchRight"); @@ -17,11 +17,11 @@ public class TileCouchWool extends TileColorable { hasCornerRight = compound.getBoolean("CouchCornerRight"); } - public void writeToNBT(NBTTagCompound compound){ - super.writeToNBT(compound); - compound.setBoolean("CouchLeft", hasLeft); - compound.setBoolean("CouchRight", hasRight); - compound.setBoolean("CouchCornerLeft", hasCornerLeft); - compound.setBoolean("CouchCornerRight", hasCornerRight); + public void writeToNBT(NBTTagCompound compound) { + super.writeToNBT(compound); + compound.setBoolean("CouchLeft", hasLeft); + compound.setBoolean("CouchRight", hasRight); + compound.setBoolean("CouchCornerLeft", hasCornerLeft); + compound.setBoolean("CouchCornerRight", hasCornerRight); } } diff --git a/src/main/java/noppes/npcs/blocks/tiles/TileCrate.java b/src/main/java/noppes/npcs/blocks/tiles/TileCrate.java index 5cebcaf07..7f3314161 100644 --- a/src/main/java/noppes/npcs/blocks/tiles/TileCrate.java +++ b/src/main/java/noppes/npcs/blocks/tiles/TileCrate.java @@ -1,10 +1,10 @@ package noppes.npcs.blocks.tiles; -public class TileCrate extends TileNpcContainer{ +public class TileCrate extends TileNpcContainer { + + @Override + public String getName() { + return "tile.npcCrate.name"; + } - @Override - public String getName() { - return "tile.npcCrate.name"; - } - } diff --git a/src/main/java/noppes/npcs/blocks/tiles/TileLamp.java b/src/main/java/noppes/npcs/blocks/tiles/TileLamp.java index f8e8c72a3..a4eb40291 100644 --- a/src/main/java/noppes/npcs/blocks/tiles/TileLamp.java +++ b/src/main/java/noppes/npcs/blocks/tiles/TileLamp.java @@ -1,7 +1,6 @@ package noppes.npcs.blocks.tiles; - public class TileLamp extends TileVariant { } diff --git a/src/main/java/noppes/npcs/blocks/tiles/TileMailbox.java b/src/main/java/noppes/npcs/blocks/tiles/TileMailbox.java index 3f25e0bbc..1b6a56c11 100644 --- a/src/main/java/noppes/npcs/blocks/tiles/TileMailbox.java +++ b/src/main/java/noppes/npcs/blocks/tiles/TileMailbox.java @@ -4,8 +4,8 @@ import net.minecraft.tileentity.TileEntity; public class TileMailbox extends TileEntity { - - public boolean canUpdate(){ + + public boolean canUpdate() { return false; } } diff --git a/src/main/java/noppes/npcs/blocks/tiles/TileNpcContainer.java b/src/main/java/noppes/npcs/blocks/tiles/TileNpcContainer.java index 69b39f360..3373fbae9 100644 --- a/src/main/java/noppes/npcs/blocks/tiles/TileNpcContainer.java +++ b/src/main/java/noppes/npcs/blocks/tiles/TileNpcContainer.java @@ -14,46 +14,39 @@ public abstract class TileNpcContainer extends TileVariant implements IInventory public String customName = ""; public int playerUsing = 0; - public TileNpcContainer(){ - chestContents = new ItemStack[getSizeInventory()]; + public TileNpcContainer() { + chestContents = new ItemStack[getSizeInventory()]; } - @Override - public void readFromNBT(NBTTagCompound compound) - { + @Override + public void readFromNBT(NBTTagCompound compound) { super.readFromNBT(compound); NBTTagList nbttaglist = compound.getTagList("Items", 10); this.chestContents = new ItemStack[this.getSizeInventory()]; - if (compound.hasKey("CustomName", 8)) - { + if (compound.hasKey("CustomName", 8)) { this.customName = compound.getString("CustomName"); } - for (int i = 0; i < nbttaglist.tagCount(); ++i) - { + for (int i = 0; i < nbttaglist.tagCount(); ++i) { NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i); int j = nbttagcompound1.getByte("Slot") & 255; - if (j >= 0 && j < this.chestContents.length) - { + if (j >= 0 && j < this.chestContents.length) { this.chestContents[j] = ItemStack.loadItemStackFromNBT(nbttagcompound1); } } } - @Override - public void writeToNBT(NBTTagCompound compound) - { + @Override + public void writeToNBT(NBTTagCompound compound) { super.writeToNBT(compound); NBTTagList nbttaglist = new NBTTagList(); - for (int i = 0; i < this.chestContents.length; ++i) - { - if (this.chestContents[i] != null) - { + for (int i = 0; i < this.chestContents.length; ++i) { + if (this.chestContents[i] != null) { NBTTagCompound nbttagcompound1 = new NBTTagCompound(); - nbttagcompound1.setByte("Slot", (byte)i); + nbttagcompound1.setByte("Slot", (byte) i); this.chestContents[i].writeToNBT(nbttagcompound1); nbttaglist.appendTag(nbttagcompound1); } @@ -61,162 +54,146 @@ public abstract class TileNpcContainer extends TileVariant implements IInventory compound.setTag("Items", nbttaglist); - if (this.hasCustomInventoryName()) - { + if (this.hasCustomInventoryName()) { compound.setString("CustomName", this.customName); } } - public boolean receiveClientEvent(int p_145842_1_, int p_145842_2_) - { - if (p_145842_1_ == 1) - { + public boolean receiveClientEvent(int p_145842_1_, int p_145842_2_) { + if (p_145842_1_ == 1) { this.playerUsing = p_145842_2_; return true; - } - else - { + } else { return super.receiveClientEvent(p_145842_1_, p_145842_2_); } } - @Override - public int getSizeInventory() { - return 54; - } + @Override + public int getSizeInventory() { + return 54; + } - @Override - public ItemStack getStackInSlot(int var1) { + @Override + public ItemStack getStackInSlot(int var1) { return this.chestContents[var1]; - } + } - @Override - public ItemStack decrStackSize(int par1, int par2) { - if (this.chestContents[par1] != null) - { + @Override + public ItemStack decrStackSize(int par1, int par2) { + if (this.chestContents[par1] != null) { ItemStack itemstack; - if (this.chestContents[par1].stackSize <= par2) - { + if (this.chestContents[par1].stackSize <= par2) { itemstack = this.chestContents[par1]; this.chestContents[par1] = null; this.markDirty(); return itemstack; - } - else - { + } else { itemstack = this.chestContents[par1].splitStack(par2); - if (this.chestContents[par1].stackSize == 0) - { + if (this.chestContents[par1].stackSize == 0) { this.chestContents[par1] = null; } this.markDirty(); return itemstack; } - } - else - { + } else { return null; } - } + } - @Override - public ItemStack getStackInSlotOnClosing(int par1) { - if (this.chestContents[par1] != null) - { + @Override + public ItemStack getStackInSlotOnClosing(int par1) { + if (this.chestContents[par1] != null) { ItemStack itemstack = this.chestContents[par1]; this.chestContents[par1] = null; return itemstack; - } - else - { + } else { return null; } - } + } - @Override - public void setInventorySlotContents(int par1, ItemStack par2ItemStack) { + @Override + public void setInventorySlotContents(int par1, ItemStack par2ItemStack) { this.chestContents[par1] = par2ItemStack; - if (par2ItemStack != null && par2ItemStack.stackSize > this.getInventoryStackLimit()) - { + if (par2ItemStack != null && par2ItemStack.stackSize > this.getInventoryStackLimit()) { par2ItemStack.stackSize = this.getInventoryStackLimit(); } this.markDirty(); - } + } - @Override - public String getInventoryName() { - return hasCustomInventoryName()?customName:getName(); - } + @Override + public String getInventoryName() { + return hasCustomInventoryName() ? customName : getName(); + } - public abstract String getName(); + public abstract String getName(); - @Override - public boolean hasCustomInventoryName() { - return !customName.isEmpty(); - } + @Override + public boolean hasCustomInventoryName() { + return !customName.isEmpty(); + } - @Override - public int getInventoryStackLimit() { + @Override + public int getInventoryStackLimit() { return 64; - } + } - @Override - public boolean isUseableByPlayer(EntityPlayer player) { - return player.isDead || this.worldObj.getTileEntity(this.xCoord, this.yCoord, this.zCoord) != this ? false : player.getDistanceSq((double)this.xCoord + 0.5D, (double)this.yCoord + 0.5D, (double)this.zCoord + 0.5D) <= 64.0D; - } + @Override + public boolean isUseableByPlayer(EntityPlayer player) { + return player.isDead || this.worldObj.getTileEntity(this.xCoord, this.yCoord, this.zCoord) != this ? false : player.getDistanceSq((double) this.xCoord + 0.5D, (double) this.yCoord + 0.5D, (double) this.zCoord + 0.5D) <= 64.0D; + } - @Override - public void openInventory() { - playerUsing++; - } + @Override + public void openInventory() { + playerUsing++; + } - @Override - public void closeInventory() { - playerUsing--; - } + @Override + public void closeInventory() { + playerUsing--; + } - @Override - public boolean isItemValidForSlot(int var1, ItemStack var2) { - return true; - } + @Override + public boolean isItemValidForSlot(int var1, ItemStack var2) { + return true; + } - public void dropItems(World world, int x, int y, int z) { - for (int i1 = 0; i1 < this.getSizeInventory(); ++i1){ + public void dropItems(World world, int x, int y, int z) { + for (int i1 = 0; i1 < this.getSizeInventory(); ++i1) { ItemStack itemstack = this.getStackInSlot(i1); if (itemstack == null) - continue; + continue; float f = world.rand.nextFloat() * 0.8F + 0.1F; float f1 = world.rand.nextFloat() * 0.8F + 0.1F; EntityItem entityitem; - for (float f2 = world.rand.nextFloat() * 0.8F + 0.1F; itemstack.stackSize > 0; world.spawnEntityInWorld(entityitem)){ + for (float f2 = world.rand.nextFloat() * 0.8F + 0.1F; itemstack.stackSize > 0; world.spawnEntityInWorld(entityitem)) { int j1 = world.rand.nextInt(21) + 10; - if (j1 > itemstack.stackSize){ + if (j1 > itemstack.stackSize) { j1 = itemstack.stackSize; } itemstack.stackSize -= j1; - entityitem = new EntityItem(world, (double)((float)x + f), (double)((float)y + f1), (double)((float)z + f2), new ItemStack(itemstack.getItem(), j1, itemstack.getItemDamage())); + entityitem = new EntityItem(world, (double) ((float) x + f), (double) ((float) y + f1), (double) ((float) z + f2), new ItemStack(itemstack.getItem(), j1, itemstack.getItemDamage())); float f3 = 0.05F; - entityitem.motionX = (double)((float)world.rand.nextGaussian() * f3); - entityitem.motionY = (double)((float)world.rand.nextGaussian() * f3 + 0.2F); - entityitem.motionZ = (double)((float)world.rand.nextGaussian() * f3); + entityitem.motionX = (double) ((float) world.rand.nextGaussian() * f3); + entityitem.motionY = (double) ((float) world.rand.nextGaussian() * f3 + 0.2F); + entityitem.motionZ = (double) ((float) world.rand.nextGaussian() * f3); - if (itemstack.hasTagCompound()){ - entityitem.getEntityItem().setTagCompound((NBTTagCompound)itemstack.getTagCompound().copy()); + if (itemstack.hasTagCompound()) { + entityitem.getEntityItem().setTagCompound((NBTTagCompound) itemstack.getTagCompound().copy()); } } } - } + } } diff --git a/src/main/java/noppes/npcs/blocks/tiles/TilePedestal.java b/src/main/java/noppes/npcs/blocks/tiles/TilePedestal.java index 2e029cdf8..f12f2b631 100644 --- a/src/main/java/noppes/npcs/blocks/tiles/TilePedestal.java +++ b/src/main/java/noppes/npcs/blocks/tiles/TilePedestal.java @@ -8,30 +8,30 @@ import net.minecraft.util.AxisAlignedBB; public class TilePedestal extends TileNpcContainer { - @Override - public String getName() { - return "tile.npcPedestal.name"; - } - - @Override - public int getSizeInventory() { - return 1; - } - - @Override - public AxisAlignedBB getRenderBoundingBox(){ - return AxisAlignedBB.getBoundingBox(xCoord, yCoord, zCoord, xCoord + 1, yCoord + 2, zCoord + 1); + @Override + public String getName() { + return "tile.npcPedestal.name"; } @Override - public Packet getDescriptionPacket(){ - NBTTagCompound compound = new NBTTagCompound(); - writeToNBT(compound); - S35PacketUpdateTileEntity packet = new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, 0, compound); - return packet; + public int getSizeInventory() { + return 1; } - - public int powerProvided(){ - return getStackInSlot(0) == null?0:15; + + @Override + public AxisAlignedBB getRenderBoundingBox() { + return AxisAlignedBB.getBoundingBox(xCoord, yCoord, zCoord, xCoord + 1, yCoord + 2, zCoord + 1); + } + + @Override + public Packet getDescriptionPacket() { + NBTTagCompound compound = new NBTTagCompound(); + writeToNBT(compound); + S35PacketUpdateTileEntity packet = new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, 0, compound); + return packet; + } + + public int powerProvided() { + return getStackInSlot(0) == null ? 0 : 15; } } diff --git a/src/main/java/noppes/npcs/blocks/tiles/TileRedstoneBlock.java b/src/main/java/noppes/npcs/blocks/tiles/TileRedstoneBlock.java index 6abba95af..630e30143 100644 --- a/src/main/java/noppes/npcs/blocks/tiles/TileRedstoneBlock.java +++ b/src/main/java/noppes/npcs/blocks/tiles/TileRedstoneBlock.java @@ -12,129 +12,130 @@ import noppes.npcs.controllers.data.Availability; import java.util.List; public class TileRedstoneBlock extends TileEntity { - public int onRange = 6; - public int offRange = 10; + public int onRange = 6; + public int offRange = 10; - public int onRangeX = 6; - public int onRangeY = 6; - public int onRangeZ = 6; + public int onRangeX = 6; + public int onRangeY = 6; + public int onRangeZ = 6; - public int offRangeX = 10; - public int offRangeY = 10; - public int offRangeZ = 10; - - public boolean isDetailed = false; + public int offRangeX = 10; + public int offRangeY = 10; + public int offRangeZ = 10; - public Availability availability = new Availability(); - - public boolean isActivated = false; - - private int ticks = 10; - - @Override - public void updateEntity(){ - if(this.worldObj.isRemote) - return; - ticks--; - if(ticks > 0) - return; - ticks = 20; - Block block = worldObj.getBlock(this.xCoord, this.yCoord, this.zCoord); - if(block == null || block instanceof BlockNpcRedstone == false){ - return; - } + public boolean isDetailed = false; - if(CustomNpcs.FreezeNPCs){ - if(isActivated) - setActive(block,false); - return; - } - if(!isActivated){ - int x = isDetailed?onRangeX:onRange; - int y = isDetailed?onRangeY:onRange; - int z = isDetailed?onRangeZ:onRange; - List list = getPlayerList(x,y,z); - if(list.isEmpty()) - return; - for(EntityPlayer player : list){ - if(availability.isAvailable(player)){ - setActive(block,true); - return; - } - } - } - else{ - int x = isDetailed?offRangeX:offRange; - int y = isDetailed?offRangeY:offRange; - int z = isDetailed?offRangeZ:offRange; - List list = getPlayerList(x,y,z); - for(EntityPlayer player : list){ - if(availability.isAvailable(player)) - return; - } - setActive(block,false); - } - - } - private void setActive(Block block, boolean bo){ - isActivated = bo; - worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, isActivated?1:0,2); - worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); - block.onBlockAdded(worldObj, xCoord, yCoord, zCoord); - } - private List getPlayerList(int x, int y, int z){ - return worldObj.getEntitiesWithinAABB(EntityPlayer.class, AxisAlignedBB.getBoundingBox(xCoord, yCoord, zCoord, xCoord + 1, yCoord + 1, zCoord + 1).expand(x, y, z)); - } - - @Override - public void readFromNBT(NBTTagCompound compound){ - super.readFromNBT(compound); - onRange = compound.getInteger("BlockOnRange"); - offRange = compound.getInteger("BlockOffRange"); - - isDetailed = compound.getBoolean("BlockIsDetailed"); - if(compound.hasKey("BlockOnRangeX")){ - isDetailed = true; - onRangeX = compound.getInteger("BlockOnRangeX"); - onRangeY = compound.getInteger("BlockOnRangeY"); - onRangeZ = compound.getInteger("BlockOnRangeZ"); + public Availability availability = new Availability(); + + public boolean isActivated = false; + + private int ticks = 10; + + @Override + public void updateEntity() { + if (this.worldObj.isRemote) + return; + ticks--; + if (ticks > 0) + return; + ticks = 20; + Block block = worldObj.getBlock(this.xCoord, this.yCoord, this.zCoord); + if (block == null || block instanceof BlockNpcRedstone == false) { + return; + } + + if (CustomNpcs.FreezeNPCs) { + if (isActivated) + setActive(block, false); + return; + } + if (!isActivated) { + int x = isDetailed ? onRangeX : onRange; + int y = isDetailed ? onRangeY : onRange; + int z = isDetailed ? onRangeZ : onRange; + List list = getPlayerList(x, y, z); + if (list.isEmpty()) + return; + for (EntityPlayer player : list) { + if (availability.isAvailable(player)) { + setActive(block, true); + return; + } + } + } else { + int x = isDetailed ? offRangeX : offRange; + int y = isDetailed ? offRangeY : offRange; + int z = isDetailed ? offRangeZ : offRange; + List list = getPlayerList(x, y, z); + for (EntityPlayer player : list) { + if (availability.isAvailable(player)) + return; + } + setActive(block, false); + } - offRangeX = compound.getInteger("BlockOffRangeX"); - offRangeY = compound.getInteger("BlockOffRangeY"); - offRangeZ = compound.getInteger("BlockOffRangeZ"); - } - - isActivated = compound.getBoolean("BlockActivated"); - - availability.readFromNBT(compound); - - if(worldObj != null) - setActive(getBlockType(), isActivated); } - @Override - public void writeToNBT(NBTTagCompound compound){ - super.writeToNBT(compound); - compound.setInteger("BlockOnRange", onRange); - compound.setInteger("BlockOffRange", offRange); - compound.setBoolean("BlockActivated", isActivated); - compound.setBoolean("BlockIsDetailed", isDetailed); - - if(isDetailed){ - compound.setInteger("BlockOnRangeX", onRangeX); - compound.setInteger("BlockOnRangeY", onRangeY); - compound.setInteger("BlockOnRangeZ", onRangeZ); - - compound.setInteger("BlockOffRangeX", offRangeX); - compound.setInteger("BlockOffRangeY", offRangeY); - compound.setInteger("BlockOffRangeZ", offRangeZ); - } - - - availability.writeToNBT(compound); + private void setActive(Block block, boolean bo) { + isActivated = bo; + worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, isActivated ? 1 : 0, 2); + worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); + block.onBlockAdded(worldObj, xCoord, yCoord, zCoord); } - - public boolean canUpdate(){ + + private List getPlayerList(int x, int y, int z) { + return worldObj.getEntitiesWithinAABB(EntityPlayer.class, AxisAlignedBB.getBoundingBox(xCoord, yCoord, zCoord, xCoord + 1, yCoord + 1, zCoord + 1).expand(x, y, z)); + } + + @Override + public void readFromNBT(NBTTagCompound compound) { + super.readFromNBT(compound); + onRange = compound.getInteger("BlockOnRange"); + offRange = compound.getInteger("BlockOffRange"); + + isDetailed = compound.getBoolean("BlockIsDetailed"); + if (compound.hasKey("BlockOnRangeX")) { + isDetailed = true; + onRangeX = compound.getInteger("BlockOnRangeX"); + onRangeY = compound.getInteger("BlockOnRangeY"); + onRangeZ = compound.getInteger("BlockOnRangeZ"); + + offRangeX = compound.getInteger("BlockOffRangeX"); + offRangeY = compound.getInteger("BlockOffRangeY"); + offRangeZ = compound.getInteger("BlockOffRangeZ"); + } + + isActivated = compound.getBoolean("BlockActivated"); + + availability.readFromNBT(compound); + + if (worldObj != null) + setActive(getBlockType(), isActivated); + } + + @Override + public void writeToNBT(NBTTagCompound compound) { + super.writeToNBT(compound); + compound.setInteger("BlockOnRange", onRange); + compound.setInteger("BlockOffRange", offRange); + compound.setBoolean("BlockActivated", isActivated); + compound.setBoolean("BlockIsDetailed", isDetailed); + + if (isDetailed) { + compound.setInteger("BlockOnRangeX", onRangeX); + compound.setInteger("BlockOnRangeY", onRangeY); + compound.setInteger("BlockOnRangeZ", onRangeZ); + + compound.setInteger("BlockOffRangeX", offRangeX); + compound.setInteger("BlockOffRangeY", offRangeY); + compound.setInteger("BlockOffRangeZ", offRangeZ); + } + + + availability.writeToNBT(compound); + } + + public boolean canUpdate() { return true; } } diff --git a/src/main/java/noppes/npcs/blocks/tiles/TileScripted.java b/src/main/java/noppes/npcs/blocks/tiles/TileScripted.java index 78ad090ec..ce535cc2d 100644 --- a/src/main/java/noppes/npcs/blocks/tiles/TileScripted.java +++ b/src/main/java/noppes/npcs/blocks/tiles/TileScripted.java @@ -34,7 +34,7 @@ import java.util.Map.Entry; public class TileScripted extends TileEntity implements IScriptBlockHandler { public List scripts = new ArrayList<>(); - public Map tempData = new HashMap<>(); + public Map tempData = new HashMap<>(); private NBTTagCompound customTileData; @@ -82,38 +82,39 @@ public class TileScripted extends TileEntity implements IScriptBlockHandler { public TextPlane text5 = new TextPlane(); public TextPlane text6 = new TextPlane(); - public IBlock getBlock(){ - if(blockDummy == null) - blockDummy = new BlockScriptedWrapper(worldObj, this.getBlockType(), xCoord,yCoord,zCoord); + public IBlock getBlock() { + if (blockDummy == null) + blockDummy = new BlockScriptedWrapper(worldObj, this.getBlockType(), xCoord, yCoord, zCoord); return blockDummy; } @Override - public void readFromNBT(NBTTagCompound compound){ + public void readFromNBT(NBTTagCompound compound) { super.readFromNBT(compound); setNBT(compound); setDisplayNBT(compound); timers.readFromNBT(compound); } - public void setNBT(NBTTagCompound compound){ + public void setNBT(NBTTagCompound compound) { scripts = NBTTags.GetScriptOld(compound.getTagList("Scripts", 10), this); scriptLanguage = compound.getString("ScriptLanguage"); enabled = compound.getBoolean("ScriptEnabled"); activePowering = powering = compound.getInteger("BlockPowering"); prevPower = compound.getInteger("BlockPrevPower"); - if(compound.hasKey("BlockHardness")){ + if (compound.hasKey("BlockHardness")) { blockHardness = compound.getFloat("BlockHardness"); blockResistance = compound.getFloat("BlockResistance"); } } - public void setDisplayNBT(NBTTagCompound compound){ + + public void setDisplayNBT(NBTTagCompound compound) { itemModel = ItemStack.loadItemStackFromNBT(compound.getCompoundTag("ScriptBlockModel")); - if(itemModel==null || itemModel.stackSize == 0) + if (itemModel == null || itemModel.stackSize == 0) itemModel = new ItemStack(Item.getItemFromBlock(CustomItems.scripted)); - if(compound.hasKey("ScriptBlockModelBlock")) + if (compound.hasKey("ScriptBlockModelBlock")) blockModel = Block.getBlockFromName(compound.getString("ScriptBlockModelBlock")); renderTileUpdate = null; renderTile = null; @@ -131,36 +132,36 @@ public class TileScripted extends TileEntity implements IScriptBlockHandler { scaleY = compound.getFloat("ScaleY"); scaleZ = compound.getFloat("ScaleZ"); - if(scaleX <= 0) + if (scaleX <= 0) scaleX = 1; - if(scaleY <= 0) + if (scaleY <= 0) scaleY = 1; - if(scaleZ <= 0) + if (scaleZ <= 0) scaleZ = 1; - if(compound.hasKey("Text1")) + if (compound.hasKey("Text1")) text1.setNBT(compound.getCompoundTag("Text1")); - if(compound.hasKey("Text2")) + if (compound.hasKey("Text2")) text2.setNBT(compound.getCompoundTag("Text2")); - if(compound.hasKey("Text3")) + if (compound.hasKey("Text3")) text3.setNBT(compound.getCompoundTag("Text3")); - if(compound.hasKey("Text4")) + if (compound.hasKey("Text4")) text4.setNBT(compound.getCompoundTag("Text4")); - if(compound.hasKey("Text5")) + if (compound.hasKey("Text5")) text5.setNBT(compound.getCompoundTag("Text5")); - if(compound.hasKey("Text6")) + if (compound.hasKey("Text6")) text6.setNBT(compound.getCompoundTag("Text6")); } @Override - public void writeToNBT(NBTTagCompound compound){ + public void writeToNBT(NBTTagCompound compound) { super.writeToNBT(compound); getNBT(compound); getDisplayNBT(compound); timers.writeToNBT(compound); } - public NBTTagCompound getNBT(NBTTagCompound compound){ + public NBTTagCompound getNBT(NBTTagCompound compound) { compound.setTag("Scripts", NBTTags.NBTScript(scripts)); compound.setString("ScriptLanguage", scriptLanguage); compound.setBoolean("ScriptEnabled", enabled); @@ -171,10 +172,10 @@ public class TileScripted extends TileEntity implements IScriptBlockHandler { return compound; } - public void getDisplayNBT(NBTTagCompound compound){ + public void getDisplayNBT(NBTTagCompound compound) { NBTTagCompound itemcompound = new NBTTagCompound(); itemModel.writeToNBT(itemcompound); - if(blockModel != null){ + if (blockModel != null) { compound.setString("ScriptBlockModelBlock", Block.blockRegistry.getNameForObject(blockModel)); } compound.setTag("ScriptBlockModel", itemcompound); @@ -205,25 +206,24 @@ public class TileScripted extends TileEntity implements IScriptBlockHandler { @Override public void updateEntity() { - if(renderTileUpdate != null){ - try{ + if (renderTileUpdate != null) { + try { renderTileUpdate.tick(); - } - catch(Exception e){ + } catch (Exception e) { renderTileUpdate = null; } } ticksExisted++; - if (prevPower != newPower && powering <= 0){ + if (prevPower != newPower && powering <= 0) { EventHooks.onScriptBlockRedstonePower(this, prevPower, newPower); prevPower = newPower; } timers.update(); - if(ticksExisted >= 10){ + if (ticksExisted >= 10) { EventHooks.onScriptBlockUpdate(this); ticksExisted = 0; - if(needsClientUpdate){ + if (needsClientUpdate) { worldObj.func_147451_t(xCoord, yCoord, zCoord); worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord, CustomItems.scripted); @@ -267,33 +267,31 @@ public class TileScripted extends TileEntity implements IScriptBlockHandler { return super.shouldRenderInPass(arg0); } - public void handleUpdateTag(NBTTagCompound tag){ + public void handleUpdateTag(NBTTagCompound tag) { int light = lightValue; setDisplayNBT(tag); - if(light != lightValue) - checkLight(worldObj,xCoord,yCoord,zCoord); + if (light != lightValue) + checkLight(worldObj, xCoord, yCoord, zCoord); worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); } - public boolean checkLight(World world, int x, int y, int z) - { + public boolean checkLight(World world, int x, int y, int z) { boolean flag = false; - if (!world.provider.hasNoSky) - { - flag |= world.updateLightByType(EnumSkyBlock.Sky, x,y,z); + if (!world.provider.hasNoSky) { + flag |= world.updateLightByType(EnumSkyBlock.Sky, x, y, z); } - flag = flag | world.updateLightByType(EnumSkyBlock.Block, x,y,z); + flag = flag | world.updateLightByType(EnumSkyBlock.Block, x, y, z); return flag; } @Override public Packet getDescriptionPacket() { - return new S35PacketUpdateTileEntity(xCoord,yCoord,zCoord, 0, getUpdateTag()); + return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, 0, getUpdateTag()); } - public NBTTagCompound getUpdateTag(){ + public NBTTagCompound getUpdateTag() { NBTTagCompound compound = new NBTTagCompound(); compound.setInteger("x", xCoord); compound.setInteger("y", yCoord); @@ -303,10 +301,10 @@ public class TileScripted extends TileEntity implements IScriptBlockHandler { } public void setItemModel(ItemStack item, Block b) { - if(item == null || item.stackSize==0){ + if (item == null || item.stackSize == 0) { item = new ItemStack(CustomItems.scripted); } - if(NoppesUtilPlayer.compareItems(item, itemModel, false, false) && b != blockModel) + if (NoppesUtilPlayer.compareItems(item, itemModel, false, false) && b != blockModel) return; metadata = item.getItemDamage(); @@ -317,24 +315,24 @@ public class TileScripted extends TileEntity implements IScriptBlockHandler { needsClientUpdate = true; } - public void setLightValue(int value){ - if(value == lightValue) + public void setLightValue(int value) { + if (value == lightValue) return; lightValue = ValueUtil.clamp(value, 0, 15); needsClientUpdate = true; } - public void setRedstonePower(int strength){ - if(powering == strength) + public void setRedstonePower(int strength) { + if (powering == strength) return; //using activePowering to prevent the RedstonePower script event from going crazy prevPower = activePowering = ValueUtil.clamp(strength, 0, 15); - worldObj.notifyBlockChange(xCoord,yCoord,zCoord, getBlockType()); + worldObj.notifyBlockChange(xCoord, yCoord, zCoord, getBlockType()); powering = activePowering; } - public void setScale(float x, float y, float z){ - if(scaleX == x && scaleY == y && scaleZ == z) + public void setScale(float x, float y, float z) { + if (scaleX == x && scaleY == y && scaleZ == z) return; scaleX = ValueUtil.clamp(x, 0, 10); scaleY = ValueUtil.clamp(y, 0, 10); @@ -342,8 +340,8 @@ public class TileScripted extends TileEntity implements IScriptBlockHandler { needsClientUpdate = true; } - public void setRotation(int x, int y, int z){ - if(rotationX == x && rotationY == y && rotationZ == z) + public void setRotation(int x, int y, int z) { + if (rotationX == x && rotationY == y && rotationZ == z) return; rotationX = ValueUtil.clamp(x, 0, 359); rotationY = ValueUtil.clamp(y, 0, 359); @@ -353,22 +351,22 @@ public class TileScripted extends TileEntity implements IScriptBlockHandler { @Override public void callScript(EnumScriptType type, Event event) { - if(!isEnabled()) + if (!isEnabled()) return; - if(ScriptController.Instance.lastLoaded > lastInited){ + if (ScriptController.Instance.lastLoaded > lastInited) { lastInited = ScriptController.Instance.lastLoaded; - if(type != EnumScriptType.INIT) + if (type != EnumScriptType.INIT) EventHooks.onScriptBlockInit(this); } - for(ScriptContainer script : scripts){ + for (ScriptContainer script : scripts) { script.run(type, event); } } @Override public void callScript(String hookName, Event event) { - callScript(EnumScriptType.valueOf(hookName),event); + callScript(EnumScriptType.valueOf(hookName), event); } @Override @@ -388,7 +386,7 @@ public class TileScripted extends TileEntity implements IScriptBlockHandler { @Override public String noticeString() { - return "x: "+xCoord+", y: "+yCoord+", z: "+zCoord; + return "x: " + xCoord + ", y: " + yCoord + ", z: " + zCoord; } @Override @@ -412,12 +410,12 @@ public class TileScripted extends TileEntity implements IScriptBlockHandler { } @Override - public Map getConsoleText(){ + public Map getConsoleText() { Map map = new TreeMap<>(); int tab = 0; - for(ScriptContainer script : getScripts()){ + for (ScriptContainer script : getScripts()) { tab++; - for(Entry entry : script.console.entrySet()){ + for (Entry entry : script.console.entrySet()) { map.put(entry.getKey(), " tab " + tab + ":\n" + entry.getValue()); } } @@ -426,22 +424,20 @@ public class TileScripted extends TileEntity implements IScriptBlockHandler { @Override public void clearConsole() { - for(ScriptContainer script : getScripts()){ + for (ScriptContainer script : getScripts()) { script.console.clear(); } } @SideOnly(Side.CLIENT) @Override - public AxisAlignedBB getRenderBoundingBox(){ + public AxisAlignedBB getRenderBoundingBox() { return AxisAlignedBB.getBoundingBox(0.0, 0.0, 0.0, 1.0, 1.0, 1.0) - .offset(xCoord,yCoord,zCoord); + .offset(xCoord, yCoord, zCoord); } - public NBTTagCompound getTileData() - { - if (this.customTileData == null) - { + public NBTTagCompound getTileData() { + if (this.customTileData == null) { this.customTileData = new NBTTagCompound(); } return this.customTileData; @@ -465,93 +461,108 @@ public class TileScripted extends TileEntity implements IScriptBlockHandler { public String getText() { return text; } + @Override public void setText(String text) { - if(this.text.equals(text)) + if (this.text.equals(text)) return; this.text = text; textHasChanged = true; needsClientUpdate = true; } + @Override public int getRotationX() { return rotationX; } + @Override public int getRotationY() { return rotationY; } + @Override public int getRotationZ() { return rotationZ; } + @Override public void setRotationX(int x) { x = ValueUtil.clamp(x % 360, 0, 359); - if(rotationX == x) + if (rotationX == x) return; rotationX = x; needsClientUpdate = true; } + @Override public void setRotationY(int y) { y = ValueUtil.clamp(y % 360, 0, 359); - if(rotationY == y) + if (rotationY == y) return; rotationY = y; needsClientUpdate = true; } + @Override public void setRotationZ(int z) { z = ValueUtil.clamp(z % 360, 0, 359); - if(rotationZ == z) + if (rotationZ == z) return; rotationZ = z; needsClientUpdate = true; } + @Override public float getOffsetX() { return offsetX; } + @Override public float getOffsetY() { return offsetY; } + @Override public float getOffsetZ() { return offsetZ; } + @Override public void setOffsetX(float x) { x = ValueUtil.clamp(x, -1, 1); - if(offsetX == x) + if (offsetX == x) return; offsetX = x; needsClientUpdate = true; } + @Override public void setOffsetY(float y) { y = ValueUtil.clamp(y, -1, 1); - if(offsetY == y) + if (offsetY == y) return; offsetY = y; needsClientUpdate = true; } + @Override public void setOffsetZ(float z) { z = ValueUtil.clamp(z, -1, 1); - if(offsetZ == z) + if (offsetZ == z) return; offsetZ = z; needsClientUpdate = true; } + @Override public float getScale() { return scale; } + @Override public void setScale(float scale) { - if(this.scale == scale) + if (this.scale == scale) return; this.scale = scale; needsClientUpdate = true; diff --git a/src/main/java/noppes/npcs/blocks/tiles/TileShortLamp.java b/src/main/java/noppes/npcs/blocks/tiles/TileShortLamp.java index ec3b2b8c6..334980af3 100644 --- a/src/main/java/noppes/npcs/blocks/tiles/TileShortLamp.java +++ b/src/main/java/noppes/npcs/blocks/tiles/TileShortLamp.java @@ -5,7 +5,7 @@ import net.minecraft.util.AxisAlignedBB; public class TileShortLamp extends TileColorable { @Override - public AxisAlignedBB getRenderBoundingBox(){ + public AxisAlignedBB getRenderBoundingBox() { return AxisAlignedBB.getBoundingBox(xCoord + 0.25f, yCoord, zCoord + 0.25f, xCoord + 0.75f, yCoord + 1, zCoord + 0.75f); } diff --git a/src/main/java/noppes/npcs/blocks/tiles/TileSign.java b/src/main/java/noppes/npcs/blocks/tiles/TileSign.java index 9782676a2..8d767b9b8 100644 --- a/src/main/java/noppes/npcs/blocks/tiles/TileSign.java +++ b/src/main/java/noppes/npcs/blocks/tiles/TileSign.java @@ -9,24 +9,24 @@ public class TileSign extends TileVariant implements ITileIcon { public ItemStack icon; public long time = 0; - public void readFromNBT(NBTTagCompound compound){ + public void readFromNBT(NBTTagCompound compound) { super.readFromNBT(compound); icon = ItemStack.loadItemStackFromNBT(compound.getCompoundTag("BannerIcon")); } - public void writeToNBT(NBTTagCompound compound){ + public void writeToNBT(NBTTagCompound compound) { super.writeToNBT(compound); - if(icon != null) + if (icon != null) compound.setTag("BannerIcon", icon.writeToNBT(new NBTTagCompound())); } @Override - public AxisAlignedBB getRenderBoundingBox(){ + public AxisAlignedBB getRenderBoundingBox() { return AxisAlignedBB.getBoundingBox(xCoord, yCoord, zCoord, xCoord + 1, yCoord + 2, zCoord + 1); } - public boolean canEdit(){ - return System.currentTimeMillis() - time < 20000; + public boolean canEdit() { + return System.currentTimeMillis() - time < 20000; } @Override diff --git a/src/main/java/noppes/npcs/blocks/tiles/TileTable.java b/src/main/java/noppes/npcs/blocks/tiles/TileTable.java index d90a5905c..237f54543 100644 --- a/src/main/java/noppes/npcs/blocks/tiles/TileTable.java +++ b/src/main/java/noppes/npcs/blocks/tiles/TileTable.java @@ -1,7 +1,6 @@ package noppes.npcs.blocks.tiles; - public class TileTable extends TileVariant { diff --git a/src/main/java/noppes/npcs/blocks/tiles/TileTallLamp.java b/src/main/java/noppes/npcs/blocks/tiles/TileTallLamp.java index c2d4e733f..9aee245b0 100644 --- a/src/main/java/noppes/npcs/blocks/tiles/TileTallLamp.java +++ b/src/main/java/noppes/npcs/blocks/tiles/TileTallLamp.java @@ -5,8 +5,8 @@ import net.minecraft.util.AxisAlignedBB; public class TileTallLamp extends TileColorable { - @Override - public AxisAlignedBB getRenderBoundingBox(){ - return AxisAlignedBB.getBoundingBox(xCoord, yCoord, zCoord, xCoord + 1, yCoord + 2, zCoord + 1); + @Override + public AxisAlignedBB getRenderBoundingBox() { + return AxisAlignedBB.getBoundingBox(xCoord, yCoord, zCoord, xCoord + 1, yCoord + 2, zCoord + 1); } } diff --git a/src/main/java/noppes/npcs/blocks/tiles/TileTombstone.java b/src/main/java/noppes/npcs/blocks/tiles/TileTombstone.java index 38c6518a9..fc74dc79b 100644 --- a/src/main/java/noppes/npcs/blocks/tiles/TileTombstone.java +++ b/src/main/java/noppes/npcs/blocks/tiles/TileTombstone.java @@ -1,5 +1,5 @@ package noppes.npcs.blocks.tiles; -public class TileTombstone extends TileBigSign{ - +public class TileTombstone extends TileBigSign { + } diff --git a/src/main/java/noppes/npcs/blocks/tiles/TileVariant.java b/src/main/java/noppes/npcs/blocks/tiles/TileVariant.java index e6c57c968..81abe288f 100644 --- a/src/main/java/noppes/npcs/blocks/tiles/TileVariant.java +++ b/src/main/java/noppes/npcs/blocks/tiles/TileVariant.java @@ -15,10 +15,10 @@ public class TileVariant extends TileEntity { public static int variantVersion = 1; int version = variantVersion; - public int variant = 14; - public int rotation; + public int variant = 14; + public int rotation; - public void readFromNBT(NBTTagCompound compound){ + public void readFromNBT(NBTTagCompound compound) { super.readFromNBT(compound); version = compound.getInteger("CNPCVersion"); FixTileData(version, compound, this); @@ -26,65 +26,65 @@ public class TileVariant extends TileEntity { rotation = compound.getInteger("CNPCRotation"); } - public void writeToNBT(NBTTagCompound compound){ - super.writeToNBT(compound); + public void writeToNBT(NBTTagCompound compound) { + super.writeToNBT(compound); compound.setInteger("CNPCVersion", version); - compound.setInteger("CNPCVariant", variant); - compound.setInteger("CNPCRotation", rotation); + compound.setInteger("CNPCVariant", variant); + compound.setInteger("CNPCRotation", rotation); } - public boolean canUpdate(){ + public boolean canUpdate() { return false; } - public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt){ - NBTTagCompound compound = pkt.func_148857_g(); - readFromNBT(compound); + public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) { + NBTTagCompound compound = pkt.func_148857_g(); + readFromNBT(compound); } @Override - public Packet getDescriptionPacket(){ - NBTTagCompound compound = new NBTTagCompound(); - writeToNBT(compound); - compound.removeTag("Items"); - S35PacketUpdateTileEntity packet = new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, 0, compound); - return packet; + public Packet getDescriptionPacket() { + NBTTagCompound compound = new NBTTagCompound(); + writeToNBT(compound); + compound.removeTag("Items"); + S35PacketUpdateTileEntity packet = new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, 0, compound); + return packet; } - @Override - public AxisAlignedBB getRenderBoundingBox(){ - return AxisAlignedBB.getBoundingBox(xCoord, yCoord, zCoord, xCoord + 1, yCoord + 1, zCoord + 1); + @Override + public AxisAlignedBB getRenderBoundingBox() { + return AxisAlignedBB.getBoundingBox(xCoord, yCoord, zCoord, xCoord + 1, yCoord + 1, zCoord + 1); } - public int powerProvided(){ - return 0; - } + public int powerProvided() { + return 0; + } - public static void FixTileData(int version, NBTTagCompound compound, TileEntity tileEntity){ - if(version == variantVersion) + public static void FixTileData(int version, NBTTagCompound compound, TileEntity tileEntity) { + if (version == variantVersion) return; boolean fixMade = false; - if(version < 1){ - if(compound.hasKey("BannerColor")){ + if (version < 1) { + if (compound.hasKey("BannerColor")) { int bannerColor = compound.getInteger("BannerColor"); - if(isColorTile(tileEntity)){ + if (isColorTile(tileEntity)) { compound.setInteger(BRUSH_COLOR_TAG, ColorUtil.colorTableInts[bannerColor]); } compound.setInteger("CNPCVariant", bannerColor); fixMade = true; } - if(compound.hasKey("BannerRotation")){ + if (compound.hasKey("BannerRotation")) { compound.setInteger("CNPCRotation", compound.getInteger("BannerRotation")); fixMade = true; } } - if(fixMade) + if (fixMade) tileEntity.markDirty(); } - public static boolean isColorTile(TileEntity tileEntity){ + public static boolean isColorTile(TileEntity tileEntity) { return tileEntity instanceof TileColorable; } } diff --git a/src/main/java/noppes/npcs/blocks/tiles/TileWallBanner.java b/src/main/java/noppes/npcs/blocks/tiles/TileWallBanner.java index 030289604..67c07d02e 100644 --- a/src/main/java/noppes/npcs/blocks/tiles/TileWallBanner.java +++ b/src/main/java/noppes/npcs/blocks/tiles/TileWallBanner.java @@ -5,9 +5,9 @@ import net.minecraft.util.AxisAlignedBB; public class TileWallBanner extends TileBanner { - @Override - public AxisAlignedBB getRenderBoundingBox(){ - return AxisAlignedBB.getBoundingBox(xCoord, yCoord - 1, zCoord, xCoord + 1, yCoord + 1, zCoord + 1); + @Override + public AxisAlignedBB getRenderBoundingBox() { + return AxisAlignedBB.getBoundingBox(xCoord, yCoord - 1, zCoord, xCoord + 1, yCoord + 1, zCoord + 1); } - + } diff --git a/src/main/java/noppes/npcs/blocks/tiles/TileWaypoint.java b/src/main/java/noppes/npcs/blocks/tiles/TileWaypoint.java index 2869540c5..d9d85f89b 100644 --- a/src/main/java/noppes/npcs/blocks/tiles/TileWaypoint.java +++ b/src/main/java/noppes/npcs/blocks/tiles/TileWaypoint.java @@ -25,11 +25,11 @@ public class TileWaypoint extends TileEntity { public int range = 10; @Override - public void updateEntity(){ - if(worldObj.isRemote || name.isEmpty()) + public void updateEntity() { + if (worldObj.isRemote || name.isEmpty()) return; ticks--; - if(ticks > 0) + if (ticks > 0) return; ticks = 10; @@ -40,19 +40,19 @@ public class TileWaypoint extends TileEntity { recentlyChecked.retainAll(listMax); recentlyChecked.addAll(toCheck); - if(toCheck.isEmpty()) + if (toCheck.isEmpty()) return; - for(EntityPlayer player : toCheck){ + for (EntityPlayer player : toCheck) { PlayerData playerData = PlayerDataController.Instance.getPlayerData(player); PlayerQuestData questData = playerData.questData; Party party = playerData.getPlayerParty(); Quest partyQuest = null; - if(party != null && party.getQuestData() != null && party.getQuestData().quest != null && party.getQuestData().quest.type == EnumQuestType.Location){ + if (party != null && party.getQuestData() != null && party.getQuestData().quest != null && party.getQuestData().quest.type == EnumQuestType.Location) { QuestData partyQuestData = party.getQuestData(); partyQuest = partyQuestData.quest; QuestLocation partyQuestLocation = (QuestLocation) partyQuestData.quest.questInterface; boolean isPartyLeader = player.getUniqueID().equals(party.getLeaderUUID()); - if(partyQuestLocation.setFoundParty(party, player, name, isPartyLeader)){ + if (partyQuestLocation.setFoundParty(party, player, name, isPartyLeader)) { player.addChatMessage(new ChatComponentTranslation(name + " " + StatCollector.translateToLocal("quest.found"))); PartyController.Instance().pingPartyQuestObjectiveUpdate(party); PartyController.Instance().checkQuestCompletion(party, EnumQuestType.Location); @@ -60,18 +60,18 @@ public class TileWaypoint extends TileEntity { } ArrayList activeQuestValues = new ArrayList<>(questData.activeQuests.values()); - for(QuestData data : activeQuestValues){ - if(data.quest.type != EnumQuestType.Location) + for (QuestData data : activeQuestValues) { + if (data.quest.type != EnumQuestType.Location) continue; - if(partyQuest != null && partyQuest.id == data.quest.getId()) + if (partyQuest != null && partyQuest.id == data.quest.getId()) continue; - if(data.quest.partyOptions.allowParty && data.quest.partyOptions.onlyParty) + if (data.quest.partyOptions.allowParty && data.quest.partyOptions.onlyParty) continue; QuestLocation quest = (QuestLocation) data.quest.questInterface; - if(quest.setFound(data, name)){ + if (quest.setFound(data, name)) { player.addChatMessage(new ChatComponentTranslation(name + " " + StatCollector.translateToLocal("quest.found"))); questData.checkQuestCompletion(playerData, EnumQuestType.Location); } @@ -79,7 +79,7 @@ public class TileWaypoint extends TileEntity { } } - private List getPlayerList(int x, int y, int z){ + private List getPlayerList(int x, int y, int z) { return worldObj.getEntitiesWithinAABB(EntityPlayer.class, AxisAlignedBB.getBoundingBox(xCoord, yCoord, zCoord, xCoord + 1, yCoord + 1, zCoord + 1).expand(x, y, z)); } @@ -88,14 +88,14 @@ public class TileWaypoint extends TileEntity { super.readFromNBT(compound); name = compound.getString("LocationName"); range = compound.getInteger("LocationRange"); - if(range < 2) + if (range < 2) range = 2; } @Override public void writeToNBT(NBTTagCompound compound) { super.writeToNBT(compound); - if(!name.isEmpty()) + if (!name.isEmpty()) compound.setString("LocationName", name); compound.setInteger("LocationRange", range); } diff --git a/src/main/java/noppes/npcs/blocks/tiles/TileWeaponRack.java b/src/main/java/noppes/npcs/blocks/tiles/TileWeaponRack.java index ef157881d..f1920775d 100644 --- a/src/main/java/noppes/npcs/blocks/tiles/TileWeaponRack.java +++ b/src/main/java/noppes/npcs/blocks/tiles/TileWeaponRack.java @@ -10,39 +10,42 @@ import net.minecraft.util.AxisAlignedBB; public class TileWeaponRack extends TileNpcContainer { - @Override - public boolean isItemValidForSlot(int var1, ItemStack itemstack) { - if(itemstack != null && itemstack.getItem() instanceof ItemBlock) - return false; - return super.isItemValidForSlot(var1, itemstack); - } - @Override - public int getSizeInventory() { - return 3; - } - - @Override - public AxisAlignedBB getRenderBoundingBox(){ - return AxisAlignedBB.getBoundingBox(xCoord, yCoord, zCoord, xCoord + 1, yCoord + 2, zCoord + 1); + @Override + public boolean isItemValidForSlot(int var1, ItemStack itemstack) { + if (itemstack != null && itemstack.getItem() instanceof ItemBlock) + return false; + return super.isItemValidForSlot(var1, itemstack); } - @Override - public String getName() { - return "tile.npcWeaponRack.name"; - } @Override - public Packet getDescriptionPacket(){ - NBTTagCompound compound = new NBTTagCompound(); - writeToNBT(compound); - S35PacketUpdateTileEntity packet = new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, 0, compound); - return packet; + public int getSizeInventory() { + return 3; } - public int powerProvided(){ - int power = 0; - for(int i = 0; i < 3; i++){ - if(getStackInSlot(i) != null) - power += 5; - } - return power; + + @Override + public AxisAlignedBB getRenderBoundingBox() { + return AxisAlignedBB.getBoundingBox(xCoord, yCoord, zCoord, xCoord + 1, yCoord + 2, zCoord + 1); + } + + @Override + public String getName() { + return "tile.npcWeaponRack.name"; + } + + @Override + public Packet getDescriptionPacket() { + NBTTagCompound compound = new NBTTagCompound(); + writeToNBT(compound); + S35PacketUpdateTileEntity packet = new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, 0, compound); + return packet; + } + + public int powerProvided() { + int power = 0; + for (int i = 0; i < 3; i++) { + if (getStackInSlot(i) != null) + power += 5; + } + return power; } } diff --git a/src/main/java/noppes/npcs/client/AnalyticsTracking.java b/src/main/java/noppes/npcs/client/AnalyticsTracking.java index 0d9b6659e..ba745346d 100644 --- a/src/main/java/noppes/npcs/client/AnalyticsTracking.java +++ b/src/main/java/noppes/npcs/client/AnalyticsTracking.java @@ -8,47 +8,46 @@ import java.net.HttpURLConnection; import java.net.URL; import java.util.UUID; -public class AnalyticsTracking{ +public class AnalyticsTracking { - public static void sendData(final EntityPlayer player, final String event, final String data){ - Runnable r = new Runnable() { - - @Override - public void run() { - try { - UUID uuid = player.getUniqueID(); - - String analyticsPostData = "v=1" + - "&tid=UA-29079943-5" + - "&cid=" + uuid.toString() + - "&t=event" + - "&ec=customnpcs_1.7d" + - "&ea=" + event + - "&el=" + data + - "&ev=300"; + public static void sendData(final EntityPlayer player, final String event, final String data) { + Runnable r = new Runnable() { + + @Override + public void run() { + try { + UUID uuid = player.getUniqueID(); + + String analyticsPostData = "v=1" + + "&tid=UA-29079943-5" + + "&cid=" + uuid.toString() + + "&t=event" + + "&ec=customnpcs_1.7d" + + "&ea=" + event + + "&el=" + data + + "&ev=300"; + + URL url = new URL("http://www.google-analytics.com/collect"); + HttpURLConnection connection = (HttpURLConnection) url.openConnection(); + connection.setConnectTimeout(10000); + connection.setReadTimeout(10000); + connection.setDoOutput(true); + connection.setUseCaches(false); + connection.setRequestMethod("POST"); + connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded"); + connection.setRequestProperty("Content-Length", Integer.toString(analyticsPostData.getBytes().length)); + OutputStream dataOutput = connection.getOutputStream(); + dataOutput.write(analyticsPostData.getBytes()); + dataOutput.close(); + connection.getInputStream().close(); + } catch (IOException e) { + + } + + } + }; + Thread t = new Thread(r); + t.start(); + } - URL url = new URL("http://www.google-analytics.com/collect"); - HttpURLConnection connection = (HttpURLConnection) url.openConnection(); - connection.setConnectTimeout(10000); - connection.setReadTimeout(10000); - connection.setDoOutput(true); - connection.setUseCaches(false); - connection.setRequestMethod("POST"); - connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded"); - connection.setRequestProperty("Content-Length", Integer.toString(analyticsPostData.getBytes().length)); - OutputStream dataOutput = connection.getOutputStream(); - dataOutput.write(analyticsPostData.getBytes()); - dataOutput.close(); - connection.getInputStream().close(); - } - catch (IOException e) { - - } - - } - }; - Thread t = new Thread(r); - t.start(); - } - } diff --git a/src/main/java/noppes/npcs/client/AssetsBrowser.java b/src/main/java/noppes/npcs/client/AssetsBrowser.java index c7418684d..1fc83c868 100644 --- a/src/main/java/noppes/npcs/client/AssetsBrowser.java +++ b/src/main/java/noppes/npcs/client/AssetsBrowser.java @@ -16,59 +16,61 @@ import java.util.zip.ZipEntry; import java.util.zip.ZipFile; public class AssetsBrowser { - public boolean isRoot; - private int depth; - private String folder; - public HashSet folders = new HashSet(); - public HashSet files = new HashSet(); - private String[] extensions; + public boolean isRoot; + private int depth; + private String folder; + public HashSet folders = new HashSet(); + public HashSet files = new HashSet(); + private String[] extensions; - public AssetsBrowser(String folder, String[] extensions){ - this.extensions = extensions; - this.setFolder(folder); - } - public void setFolder(String folder){ - if(!folder.endsWith("/")) - folder += "/"; - isRoot = folder.length() <= 1; - this.folder = "/assets" + folder; - depth = StringUtils.countMatches(this.folder, "/"); - getFiles(); - } - public AssetsBrowser(String[] extensions){ - this.extensions = extensions; - } + public AssetsBrowser(String folder, String[] extensions) { + this.extensions = extensions; + this.setFolder(folder); + } - private void getFiles() { - folders.clear(); - files.clear(); + public void setFolder(String folder) { + if (!folder.endsWith("/")) + folder += "/"; + isRoot = folder.length() <= 1; + this.folder = "/assets" + folder; + depth = StringUtils.countMatches(this.folder, "/"); + getFiles(); + } - ResourcePackRepository repos = Minecraft.getMinecraft().getResourcePackRepository(); + public AssetsBrowser(String[] extensions) { + this.extensions = extensions; + } + + private void getFiles() { + folders.clear(); + files.clear(); + + ResourcePackRepository repos = Minecraft.getMinecraft().getResourcePackRepository(); SimpleReloadableResourceManager simplemanager = (SimpleReloadableResourceManager) Minecraft.getMinecraft().getResourceManager(); Map map = ObfuscationReflectionHelper.getPrivateValue(SimpleReloadableResourceManager.class, simplemanager, 2); HashSet set = new HashSet(); - for(String name: map.keySet()){ - if(!(map.get(name) instanceof FallbackResourceManager)) - continue; - FallbackResourceManager manager = (FallbackResourceManager) map.get(name); - List list = ObfuscationReflectionHelper.getPrivateValue(FallbackResourceManager.class, manager, 0); - for(IResourcePack pack : list){ - if(pack instanceof AbstractResourcePack){ - AbstractResourcePack p = (AbstractResourcePack) pack; - File file = NPCResourceHelper.getPackFile(p); - if(file != null) - set.add(file.getAbsolutePath()); - } - } + for (String name : map.keySet()) { + if (!(map.get(name) instanceof FallbackResourceManager)) + continue; + FallbackResourceManager manager = (FallbackResourceManager) map.get(name); + List list = ObfuscationReflectionHelper.getPrivateValue(FallbackResourceManager.class, manager, 0); + for (IResourcePack pack : list) { + if (pack instanceof AbstractResourcePack) { + AbstractResourcePack p = (AbstractResourcePack) pack; + File file = NPCResourceHelper.getPackFile(p); + if (file != null) + set.add(file.getAbsolutePath()); + } + } } - for(String file : set){ - progressFile(new File(file)); + for (String file : set) { + progressFile(new File(file)); } for (ModContainer mod : Loader.instance().getModList()) { - if(mod.getSource().exists()) - progressFile(mod.getSource()); + if (mod.getSource().exists()) + progressFile(mod.getSource()); } // List list = repos.getRepositoryEntries(); // System.out.println(repos.rprDefaultResourcePack); @@ -85,101 +87,98 @@ public class AssetsBrowser { // progressFile(file); // } // checkFolder(new File(CustomNpcs.Dir,"assets"),CustomNpcs.Dir.getAbsolutePath().length()); - //TODO fix - } - private void progressFile(File file){ - try { - if (!file.isDirectory() && (file.getName().endsWith(".jar") || file.getName().endsWith(".zip"))) - { - ZipFile zip = new ZipFile(file); - Enumeration entries = zip.entries(); - while(entries.hasMoreElements()){ - ZipEntry zipentry = entries.nextElement(); - String entryName = zipentry.getName(); - checkFile(entryName); + //TODO fix + } - } - zip.close(); - } - else if(file.isDirectory()){ - int length = file.getAbsolutePath().length(); - checkFolder(file,length); - } - } catch (Exception e) { - e.printStackTrace(); - } - } + private void progressFile(File file) { + try { + if (!file.isDirectory() && (file.getName().endsWith(".jar") || file.getName().endsWith(".zip"))) { + ZipFile zip = new ZipFile(file); + Enumeration entries = zip.entries(); + while (entries.hasMoreElements()) { + ZipEntry zipentry = entries.nextElement(); + String entryName = zipentry.getName(); + checkFile(entryName); - private void checkFolder(File file, int length){ - File[] files = file.listFiles(); - if(files == null){ - return; - } - for(File f : files){ - String name = f.getAbsolutePath().substring(length); - name = name.replace("\\", "/"); - if(!name.startsWith("/")) - name = "/" + name; - if(f.isDirectory() && (folder.startsWith(name) || name.startsWith(folder))){ - checkFile(name + "/"); - checkFolder(f, length); - } - else - checkFile(name); - } - } + } + zip.close(); + } else if (file.isDirectory()) { + int length = file.getAbsolutePath().length(); + checkFolder(file, length); + } + } catch (Exception e) { + e.printStackTrace(); + } + } - private void checkFile(String name){ - if(!name.startsWith("/")) - name = "/" + name; - if(!name.startsWith(this.folder)){ - return; + private void checkFolder(File file, int length) { + File[] files = file.listFiles(); + if (files == null) { + return; + } + for (File f : files) { + String name = f.getAbsolutePath().substring(length); + name = name.replace("\\", "/"); + if (!name.startsWith("/")) + name = "/" + name; + if (f.isDirectory() && (folder.startsWith(name) || name.startsWith(folder))) { + checkFile(name + "/"); + checkFolder(f, length); + } else + checkFile(name); + } + } + + private void checkFile(String name) { + if (!name.startsWith("/")) + name = "/" + name; + if (!name.startsWith(this.folder)) { + return; } String[] split = name.split("/"); int count = split.length; - if(count == depth + 1){ - if(validExtension(name)) - files.add(split[depth]); + if (count == depth + 1) { + if (validExtension(name)) + files.add(split[depth]); + } else if (depth + 1 < count) { + folders.add(split[depth]); } - else if(depth + 1 < count){ - folders.add(split[depth]); + } + + private boolean validExtension(String entryName) { + int index = entryName.indexOf("."); + if (index < 0) + return false; + String extension = entryName.substring(index + 1); + for (String ex : extensions) { + if (ex.equalsIgnoreCase(extension)) + return true; } - } + return false; + } - private boolean validExtension(String entryName) { - int index = entryName.indexOf("."); - if(index < 0) - return false; - String extension = entryName.substring(index + 1); - for(String ex : extensions){ - if(ex.equalsIgnoreCase(extension)) - return true; - } - return false; - } + public String getAsset(String asset) { + String[] split = folder.split("/"); + if (split.length < 3) + return null; + String texture = split[2] + ":"; + texture += folder.substring(texture.length() + 8) + asset; + return texture; + } - public String getAsset(String asset) { - String[] split = folder.split("/"); - if(split.length < 3) - return null; - String texture = split[2] + ":"; - texture += folder.substring(texture.length() + 8) + asset; - return texture; - } - - public static String getRoot(String asset) { - String mod = "minecraft"; - int index = asset.indexOf(":"); - if(index > 0){ - mod = asset.substring(0,index); - asset = asset.substring(index + 1); - } - if(asset.startsWith("/")) - asset = asset.substring(1); - String location = "/" + mod + "/" + asset; - index = location.lastIndexOf("/"); - if(index > 0) - location = location.substring(0,index); - return location; - } + public static String getRoot(String asset) { + String mod = "minecraft"; + int index = asset.indexOf(":"); + if (index > 0) { + mod = asset.substring(0, index); + asset = asset.substring(index + 1); + } + if (asset.startsWith("/")) + asset = asset.substring(1); + String location = "/" + mod + "/" + asset; + index = location.lastIndexOf("/"); + if (index > 0) + location = location.substring(0, index); + return location; + } } diff --git a/src/main/java/noppes/npcs/client/ClientCacheHandler.java b/src/main/java/noppes/npcs/client/ClientCacheHandler.java index 7cd74cfa7..298bedc06 100644 --- a/src/main/java/noppes/npcs/client/ClientCacheHandler.java +++ b/src/main/java/noppes/npcs/client/ClientCacheHandler.java @@ -1,6 +1,5 @@ package noppes.npcs.client; -import kamkeel.npcs.util.ByteBufUtils; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.ResourceLocation; import noppes.npcs.client.controllers.MusicController; @@ -18,7 +17,6 @@ import noppes.npcs.controllers.data.PlayerData; import noppes.npcs.controllers.data.SkinOverlay; import noppes.npcs.util.CacheHashMap; -import java.io.IOException; import java.util.HashMap; import java.util.UUID; @@ -74,7 +72,7 @@ public class ClientCacheHandler { // Clear Quest Tracker HudComponent component = ClientHudManager.getInstance().getHudComponents().get(EnumHudComponent.QuestTracker); - if(component != null){ + if (component != null) { component.loadData(new NBTTagCompound()); component.hasData = false; } diff --git a/src/main/java/noppes/npcs/client/ClientEventHandler.java b/src/main/java/noppes/npcs/client/ClientEventHandler.java index 7780a4d0a..44586ac78 100644 --- a/src/main/java/noppes/npcs/client/ClientEventHandler.java +++ b/src/main/java/noppes/npcs/client/ClientEventHandler.java @@ -35,7 +35,7 @@ import java.util.*; public class ClientEventHandler { public static final RenderCNPCPlayer renderCNPCSelf = new RenderCNPCPlayer(); public static final RenderCNPCPlayer renderCNPCPlayer = new RenderCNPCPlayer(); - public static HashMap disabledButtonTimes = new HashMap<>(); + public static HashMap disabledButtonTimes = new HashMap<>(); public static float partialHandTicks; public static boolean firstPersonAnimation; public static ModelBiped firstPersonModel; @@ -48,11 +48,11 @@ public class ClientEventHandler { public static EntityNPCInterface renderingNpc; public static EntityPlayer renderingPlayer; - public static HashMap partNames = new HashMap<>(); - public static HashMap,Field[]> declaredFieldCache = new HashMap<>(); + public static HashMap partNames = new HashMap<>(); + public static HashMap, Field[]> declaredFieldCache = new HashMap<>(); private static final HashSet processedPlayerRenderers = new HashSet<>(); - public static final HashMap originalValues = new HashMap<>(); + public static final HashMap originalValues = new HashMap<>(); public static ModelBase playerModel; private Class renderPlayerJBRA; @@ -71,7 +71,7 @@ public class ClientEventHandler { return; ArrayList removeList = new ArrayList<>(); - for (Map.Entry entry : disabledButtonTimes.entrySet()) { + for (Map.Entry entry : disabledButtonTimes.entrySet()) { if (entry.getValue() > 0) { if (entry.getKey() == event.button || entry.getKey() == -1) { event.setCanceled(true); @@ -88,13 +88,13 @@ public class ClientEventHandler { } @SubscribeEvent - public void onOverlayRender(RenderGameOverlayEvent.Post event){ - if(event.type == RenderGameOverlayEvent.ElementType.ALL) { + public void onOverlayRender(RenderGameOverlayEvent.Post event) { + if (event.type == RenderGameOverlayEvent.ElementType.ALL) { for (OverlayCustom overlayCustom : ClientCacheHandler.customOverlays.values()) { overlayCustom.renderGameOverlay(event.partialTicks); } - if(ClientHudManager.getInstance().getHudComponents().isEmpty()){ + if (ClientHudManager.getInstance().getHudComponents().isEmpty()) { ClientHudManager.getInstance().registerHud(EnumHudComponent.QuestTracker, new QuestTrackingComponent(Minecraft.getMinecraft())); ClientHudManager.getInstance().registerHud(EnumHudComponent.QuestCompass, new CompassHudComponent(Minecraft.getMinecraft())); } @@ -142,16 +142,16 @@ public class ClientEventHandler { if (event.entity instanceof EntityNPCInterface) { MarkData markData = MarkData.get((EntityNPCInterface) event.entity); EntityPlayer player = Minecraft.getMinecraft().thePlayer; - if(PlayerData.get(player) != null){ - for(MarkData.Mark m : markData.marks){ - if(m.getType() != MarkType.NONE && m.availability.isAvailable(player)){ + if (PlayerData.get(player) != null) { + for (MarkData.Mark m : markData.marks) { + if (m.getType() != MarkType.NONE && m.availability.isAvailable(player)) { MarkRenderer.render(event.entity, event.x, event.y, event.z, m); break; } } } } else if (event.entity instanceof EntityPlayer) { - for (Map.Entry entry : ClientEventHandler.originalValues.entrySet()) { + for (Map.Entry entry : ClientEventHandler.originalValues.entrySet()) { ModelRenderer renderer = entry.getKey(); FramePart part = entry.getValue(); renderer.rotateAngleX = part.rotation[0]; @@ -173,9 +173,9 @@ public class ClientEventHandler { ClientEventHandler.renderingPlayer = event.entityPlayer; } - @SubscribeEvent(priority= EventPriority.LOWEST) - public void pre(RenderPlayerEvent.Pre event){ - if(!(event.entity instanceof AbstractClientPlayer)) + @SubscribeEvent(priority = EventPriority.LOWEST) + public void pre(RenderPlayerEvent.Pre event) { + if (!(event.entity instanceof AbstractClientPlayer)) return; } @@ -185,7 +185,7 @@ public class ClientEventHandler { ClientEventHandler.renderingPlayer = null; if (renderPlayerJBRA != null && hasOverlays(player)) { - if(renderPlayerJBRA.isInstance(event.renderer)) + if (renderPlayerJBRA.isInstance(event.renderer)) return; if (!(event.renderer instanceof RenderCNPCPlayer)) { @@ -330,7 +330,7 @@ public class ClientEventHandler { try { Class ModelBipedBody = Class.forName("JinRyuu.JRMCore.entity.ModelBipedBody"); Object model = renderer.baseModel; - if(!(model instanceof ModelBiped)) + if (!(model instanceof ModelBiped)) return null; Field[] declared; @@ -338,7 +338,7 @@ public class ClientEventHandler { declared = ClientEventHandler.declaredFieldCache.get(ModelBipedBody); } else { declared = ModelBipedBody.getDeclaredFields(); - ClientEventHandler.declaredFieldCache.put(ModelBipedBody,declared); + ClientEventHandler.declaredFieldCache.put(ModelBipedBody, declared); } Set> entrySet = ClientEventHandler.partNames.entrySet(); for (Field f : declared) { @@ -350,11 +350,13 @@ public class ClientEventHandler { if (partName.equals(f.getName()) && renderer == f.get(model)) { return entry.getKey(); } - } catch (IllegalAccessException ignored) {} + } catch (IllegalAccessException ignored) { + } } } } - } catch (Exception ignored) {} + } catch (Exception ignored) { + } return null; } diff --git a/src/main/java/noppes/npcs/client/ClientProxy.java b/src/main/java/noppes/npcs/client/ClientProxy.java index 1e1607567..ffd0e64f2 100644 --- a/src/main/java/noppes/npcs/client/ClientProxy.java +++ b/src/main/java/noppes/npcs/client/ClientProxy.java @@ -84,58 +84,58 @@ import java.io.IOException; import java.util.Random; public class ClientProxy extends CommonProxy { - public static KeyBinding NPCButton; + public static KeyBinding NPCButton; public static final Random RAND = new Random(); - public static FontContainer Font; + public static FontContainer Font; - public void load() { - Font = new FontContainer(ConfigClient.FontType, ConfigClient.FontSize); - createFolders(); - new MusicController(); - new ScriptSoundController(); + public void load() { + Font = new FontContainer(ConfigClient.FontType, ConfigClient.FontSize); + createFolders(); + new MusicController(); + new ScriptSoundController(); - RenderingRegistry.registerEntityRenderingHandler(EntityNpcPony.class, new RenderNPCPony()); - RenderingRegistry.registerEntityRenderingHandler(EntityNpcCrystal.class, new RenderNpcCrystal(new ModelNpcCrystal(0.5F))); - RenderingRegistry.registerEntityRenderingHandler(EntityNpcDragon.class, new RenderNpcDragon(new ModelNpcDragon(0.0F), 0.5F)); - RenderingRegistry.registerEntityRenderingHandler(EntityNpcSlime.class, new RenderNpcSlime(new ModelNpcSlime(16), new ModelNpcSlime(0), 0.25F)); - RenderingRegistry.registerEntityRenderingHandler(EntityProjectile.class, new RenderProjectile()); + RenderingRegistry.registerEntityRenderingHandler(EntityNpcPony.class, new RenderNPCPony()); + RenderingRegistry.registerEntityRenderingHandler(EntityNpcCrystal.class, new RenderNpcCrystal(new ModelNpcCrystal(0.5F))); + RenderingRegistry.registerEntityRenderingHandler(EntityNpcDragon.class, new RenderNpcDragon(new ModelNpcDragon(0.0F), 0.5F)); + RenderingRegistry.registerEntityRenderingHandler(EntityNpcSlime.class, new RenderNpcSlime(new ModelNpcSlime(16), new ModelNpcSlime(0), 0.25F)); + RenderingRegistry.registerEntityRenderingHandler(EntityProjectile.class, new RenderProjectile()); - RenderingRegistry.registerEntityRenderingHandler(EntityCustomNpc.class, new RenderCustomNpc()); + RenderingRegistry.registerEntityRenderingHandler(EntityCustomNpc.class, new RenderCustomNpc()); - RenderingRegistry.registerEntityRenderingHandler(EntityNPCGolem.class, new RenderNPCHumanMale( - new ModelNPCGolem(0), new ModelNPCGolem(1F), new ModelNPCGolem(0.5F))); - FMLCommonHandler.instance().bus().register(new ClientTickHandler()); + RenderingRegistry.registerEntityRenderingHandler(EntityNPCGolem.class, new RenderNPCHumanMale( + new ModelNPCGolem(0), new ModelNPCGolem(1F), new ModelNPCGolem(0.5F))); + FMLCommonHandler.instance().bus().register(new ClientTickHandler()); - ClientRegistry.bindTileEntitySpecialRenderer(TileBlockAnvil.class, new BlockCarpentryBenchRenderer()); - ClientRegistry.bindTileEntitySpecialRenderer(TileMailbox.class, new BlockMailboxRenderer()); + ClientRegistry.bindTileEntitySpecialRenderer(TileBlockAnvil.class, new BlockCarpentryBenchRenderer()); + ClientRegistry.bindTileEntitySpecialRenderer(TileMailbox.class, new BlockMailboxRenderer()); ClientRegistry.bindTileEntitySpecialRenderer(TileScripted.class, new BlockScriptedRenderer()); MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(CustomItems.scripted), new ScriptedBlockItemRenderer()); RenderingRegistry.registerBlockHandler(new BlockBorderRenderer()); - if(!ConfigItem.DisableExtraBlock){ - ClientRegistry.bindTileEntitySpecialRenderer(TileBanner.class, new BlockBannerRenderer()); - ClientRegistry.bindTileEntitySpecialRenderer(TileWallBanner.class, new BlockWallBannerRenderer()); - ClientRegistry.bindTileEntitySpecialRenderer(TileTallLamp.class, new BlockTallLampRenderer()); + if (!ConfigItem.DisableExtraBlock) { + ClientRegistry.bindTileEntitySpecialRenderer(TileBanner.class, new BlockBannerRenderer()); + ClientRegistry.bindTileEntitySpecialRenderer(TileWallBanner.class, new BlockWallBannerRenderer()); + ClientRegistry.bindTileEntitySpecialRenderer(TileTallLamp.class, new BlockTallLampRenderer()); ClientRegistry.bindTileEntitySpecialRenderer(TileShortLamp.class, new BlockShortLampRenderer()); - ClientRegistry.bindTileEntitySpecialRenderer(TileChair.class, new BlockChairRenderer()); - ClientRegistry.bindTileEntitySpecialRenderer(TileWeaponRack.class, new BlockWeaponRackRenderer()); - ClientRegistry.bindTileEntitySpecialRenderer(TileCrate.class, new BlockCrateRenderer()); - ClientRegistry.bindTileEntitySpecialRenderer(TileCouchWool.class, new BlockCouchWoolRenderer()); - ClientRegistry.bindTileEntitySpecialRenderer(TileCouchWood.class, new BlockCouchWoodRenderer()); - ClientRegistry.bindTileEntitySpecialRenderer(TileTable.class, new BlockTableRenderer()); - ClientRegistry.bindTileEntitySpecialRenderer(TileCandle.class, new BlockCandleRenderer()); - ClientRegistry.bindTileEntitySpecialRenderer(TileLamp.class, new BlockLanternRenderer()); - ClientRegistry.bindTileEntitySpecialRenderer(TileStool.class, new BlockStoolRenderer()); - ClientRegistry.bindTileEntitySpecialRenderer(TileBigSign.class, new BlockBigSignRenderer()); - ClientRegistry.bindTileEntitySpecialRenderer(TileBarrel.class, new BlockBarrelRenderer()); - ClientRegistry.bindTileEntitySpecialRenderer(TileCampfire.class, new BlockCampfireRenderer()); - ClientRegistry.bindTileEntitySpecialRenderer(TileTombstone.class, new BlockTombstoneRenderer()); - ClientRegistry.bindTileEntitySpecialRenderer(TileShelf.class, new BlockShelfRenderer()); - ClientRegistry.bindTileEntitySpecialRenderer(TileSign.class, new BlockSignRenderer()); - ClientRegistry.bindTileEntitySpecialRenderer(TileBeam.class, new BlockBeamRenderer()); - ClientRegistry.bindTileEntitySpecialRenderer(TileBook.class, new BlockBookRenderer()); - ClientRegistry.bindTileEntitySpecialRenderer(TilePedestal.class, new BlockPedestalRenderer()); - RenderingRegistry.registerBlockHandler(new BlockBloodRenderer()); + ClientRegistry.bindTileEntitySpecialRenderer(TileChair.class, new BlockChairRenderer()); + ClientRegistry.bindTileEntitySpecialRenderer(TileWeaponRack.class, new BlockWeaponRackRenderer()); + ClientRegistry.bindTileEntitySpecialRenderer(TileCrate.class, new BlockCrateRenderer()); + ClientRegistry.bindTileEntitySpecialRenderer(TileCouchWool.class, new BlockCouchWoolRenderer()); + ClientRegistry.bindTileEntitySpecialRenderer(TileCouchWood.class, new BlockCouchWoodRenderer()); + ClientRegistry.bindTileEntitySpecialRenderer(TileTable.class, new BlockTableRenderer()); + ClientRegistry.bindTileEntitySpecialRenderer(TileCandle.class, new BlockCandleRenderer()); + ClientRegistry.bindTileEntitySpecialRenderer(TileLamp.class, new BlockLanternRenderer()); + ClientRegistry.bindTileEntitySpecialRenderer(TileStool.class, new BlockStoolRenderer()); + ClientRegistry.bindTileEntitySpecialRenderer(TileBigSign.class, new BlockBigSignRenderer()); + ClientRegistry.bindTileEntitySpecialRenderer(TileBarrel.class, new BlockBarrelRenderer()); + ClientRegistry.bindTileEntitySpecialRenderer(TileCampfire.class, new BlockCampfireRenderer()); + ClientRegistry.bindTileEntitySpecialRenderer(TileTombstone.class, new BlockTombstoneRenderer()); + ClientRegistry.bindTileEntitySpecialRenderer(TileShelf.class, new BlockShelfRenderer()); + ClientRegistry.bindTileEntitySpecialRenderer(TileSign.class, new BlockSignRenderer()); + ClientRegistry.bindTileEntitySpecialRenderer(TileBeam.class, new BlockBeamRenderer()); + ClientRegistry.bindTileEntitySpecialRenderer(TileBook.class, new BlockBookRenderer()); + ClientRegistry.bindTileEntitySpecialRenderer(TilePedestal.class, new BlockPedestalRenderer()); + RenderingRegistry.registerBlockHandler(new BlockBloodRenderer()); // Tile Item Renderers MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(CustomItems.couchWool), new ItemCouchWoolRenderer()); @@ -143,83 +143,83 @@ public class ClientProxy extends CommonProxy { MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(CustomItems.wallBanner), new ItemBannerWallRenderer()); MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(CustomItems.shortLamp), new ItemShortLampRenderer()); MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(CustomItems.tallLamp), new ItemTallLampRenderer()); - } - Minecraft mc = Minecraft.getMinecraft(); + } + Minecraft mc = Minecraft.getMinecraft(); - NPCButton = new KeyBinding("NPC Inventory", Keyboard.KEY_N, "key.categories.customnpc"); + NPCButton = new KeyBinding("NPC Inventory", Keyboard.KEY_N, "key.categories.customnpc"); - ClientRegistry.registerKeyBinding(NPCButton); - mc.gameSettings.loadOptions(); + ClientRegistry.registerKeyBinding(NPCButton); + mc.gameSettings.loadOptions(); - new PresetController(CustomNpcs.Dir); + new PresetController(CustomNpcs.Dir); - if(ConfigMain.EnableUpdateChecker){ - VersionChecker checker = new VersionChecker(); - checker.start(); - } + if (ConfigMain.EnableUpdateChecker) { + VersionChecker checker = new VersionChecker(); + checker.start(); + } - ClientCloneController.Instance = new ClientCloneController(); - ClientTagMapController.Instance = new ClientTagMapController(); + ClientCloneController.Instance = new ClientCloneController(); + ClientTagMapController.Instance = new ClientTagMapController(); - MinecraftForge.EVENT_BUS.register(new ClientEventHandler()); + MinecraftForge.EVENT_BUS.register(new ClientEventHandler()); - if(ConfigClient.InventoryGuiEnabled){ - MinecraftForge.EVENT_BUS.register(new TabRegistry()); - if (TabRegistry.getTabList().isEmpty()){ - TabRegistry.registerTab(new InventoryTabVanilla()); - } - TabRegistry.registerTab(new InventoryTabCustomNpc()); - } - } + if (ConfigClient.InventoryGuiEnabled) { + MinecraftForge.EVENT_BUS.register(new TabRegistry()); + if (TabRegistry.getTabList().isEmpty()) { + TabRegistry.registerTab(new InventoryTabVanilla()); + } + TabRegistry.registerTab(new InventoryTabCustomNpc()); + } + } - public FakePlayer getCommandPlayer(IWorld world) { - return (FakePlayer)(new EntityCustomNpc(world.getMCWorld())).getFakePlayer(); - } + public FakePlayer getCommandPlayer(IWorld world) { + return (FakePlayer) (new EntityCustomNpc(world.getMCWorld())).getFakePlayer(); + } - private void createFolders() { - File file = new File(CustomNpcs.Dir,"assets/customnpcs"); - if(!file.exists()) - file.mkdirs(); + private void createFolders() { + File file = new File(CustomNpcs.Dir, "assets/customnpcs"); + if (!file.exists()) + file.mkdirs(); - File check = new File(file,"sounds"); - if(!check.exists()) - check.mkdir(); + File check = new File(file, "sounds"); + if (!check.exists()) + check.mkdir(); - File json = new File(file, "sounds.json"); - if(!json.exists()){ - try { - json.createNewFile(); - BufferedWriter writer = new BufferedWriter(new FileWriter(json)); - writer.write("{\n\n}"); - writer.close(); - } catch (IOException e) { - } - } + File json = new File(file, "sounds.json"); + if (!json.exists()) { + try { + json.createNewFile(); + BufferedWriter writer = new BufferedWriter(new FileWriter(json)); + writer.write("{\n\n}"); + writer.close(); + } catch (IOException e) { + } + } - check = new File(file,"textures"); - if(!check.exists()) - check.mkdir(); + check = new File(file, "textures"); + if (!check.exists()) + check.mkdir(); - File cache = new File(check,"cache"); - if(!cache.exists()) - cache.mkdir(); - ((IReloadableResourceManager)Minecraft.getMinecraft().getResourceManager()).registerReloadListener(new CustomNpcResourceListener()); - } + File cache = new File(check, "cache"); + if (!cache.exists()) + cache.mkdir(); + ((IReloadableResourceManager) Minecraft.getMinecraft().getResourceManager()).registerReloadListener(new CustomNpcResourceListener()); + } - @Override - public PlayerData getPlayerData(EntityPlayer player) { - if (player.getUniqueID() == Minecraft.getMinecraft().thePlayer.getUniqueID()) { - if(ClientCacheHandler.playerData != null){ + @Override + public PlayerData getPlayerData(EntityPlayer player) { + if (player.getUniqueID() == Minecraft.getMinecraft().thePlayer.getUniqueID()) { + if (ClientCacheHandler.playerData != null) { if (ClientCacheHandler.playerData.player != player) { ClientCacheHandler.playerData.player = player; } return ClientCacheHandler.playerData; } - } + } return null; - } + } public AnimationData getClientAnimationData(Entity entity) { if (entity instanceof EntityPlayer) { @@ -230,44 +230,43 @@ public class ClientProxy extends CommonProxy { return null; } - @Override - public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { + @Override + public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { - if (ID > EnumGuiType.values().length) - return null; - EnumGuiType gui = EnumGuiType.values()[ID]; - EntityNPCInterface npc = NoppesUtil.getLastNpc(); - Container container = this.getContainer(gui, player, x, y, z, npc); - return getGui(npc, gui, container, x, y, z); - } + if (ID > EnumGuiType.values().length) + return null; + EnumGuiType gui = EnumGuiType.values()[ID]; + EntityNPCInterface npc = NoppesUtil.getLastNpc(); + Container container = this.getContainer(gui, player, x, y, z, npc); + return getGui(npc, gui, container, x, y, z); + } + private GuiScreen getGui(EntityNPCInterface npc, EnumGuiType gui, Container container, int x, int y, int z) { + if (gui == EnumGuiType.MainMenuDisplay) { + if (npc != null) + return new GuiNpcDisplay(npc); + else + Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("Unable to find npc")); + } else if (gui == EnumGuiType.MainMenuStats) + return new GuiNpcStats(npc); - private GuiScreen getGui(EntityNPCInterface npc, EnumGuiType gui, Container container, int x, int y, int z) { - if (gui == EnumGuiType.MainMenuDisplay) { - if (npc != null) - return new GuiNpcDisplay(npc); - else - Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("Unable to find npc")); - } else if (gui == EnumGuiType.MainMenuStats) - return new GuiNpcStats(npc); + else if (gui == EnumGuiType.MainMenuInv) + return new GuiNPCInv(npc, (ContainerNPCInv) container); - else if (gui == EnumGuiType.MainMenuInv) - return new GuiNPCInv(npc, (ContainerNPCInv) container); + else if (gui == EnumGuiType.MainMenuAdvanced) + return new GuiNpcAdvanced(npc); - else if (gui == EnumGuiType.MainMenuAdvanced) - return new GuiNpcAdvanced(npc); + else if (gui == EnumGuiType.QuestReward) + return new GuiNpcQuestReward(npc, (ContainerNpcQuestReward) container); - else if (gui == EnumGuiType.QuestReward) - return new GuiNpcQuestReward(npc, (ContainerNpcQuestReward) container); + else if (gui == EnumGuiType.QuestItem) + return new GuiNpcQuestTypeItem(npc, (ContainerNpcQuestTypeItem) container); - else if (gui == EnumGuiType.QuestItem) - return new GuiNpcQuestTypeItem(npc, (ContainerNpcQuestTypeItem) container); + else if (gui == EnumGuiType.MovingPath) + return new GuiNpcPather(npc); - else if (gui == EnumGuiType.MovingPath) - return new GuiNpcPather(npc); - - else if (gui == EnumGuiType.ManageFactions) + else if (gui == EnumGuiType.ManageFactions) return new GuiNPCManageFactions(npc); else if (gui == EnumGuiType.ManageCustomForms) @@ -276,150 +275,149 @@ public class ClientProxy extends CommonProxy { else if (gui == EnumGuiType.ManageCustomAuras) return DBCClient.Instance.manageCustomAuras(npc); - else if (gui == EnumGuiType.ManageTags) - return new GuiNPCManageTags(npc); + else if (gui == EnumGuiType.ManageTags) + return new GuiNPCManageTags(npc); - else if (gui == EnumGuiType.ManageAnimations) { - EntityCustomNpc animNpc; - boolean save; - if (npc != null) { - animNpc = new EntityCustomNpc(npc.worldObj); - animNpc.copyDataFrom(npc, true); - animNpc.display.showName = 1; - animNpc.display.showBossBar = 0; - save = true; - } else { - animNpc = new EntityCustomNpc(Minecraft.getMinecraft().theWorld); - animNpc.display.texture = "customnpcs:textures/entity/humanmale/AnimationBody.png"; - save = false; - } - return new GuiNPCManageAnimations(animNpc, save); - } - else if (gui == EnumGuiType.ManageLinked) - return new GuiNPCManageLinked(npc); + else if (gui == EnumGuiType.ManageAnimations) { + EntityCustomNpc animNpc; + boolean save; + if (npc != null) { + animNpc = new EntityCustomNpc(npc.worldObj); + animNpc.copyDataFrom(npc, true); + animNpc.display.showName = 1; + animNpc.display.showBossBar = 0; + save = true; + } else { + animNpc = new EntityCustomNpc(Minecraft.getMinecraft().theWorld); + animNpc.display.texture = "customnpcs:textures/entity/humanmale/AnimationBody.png"; + save = false; + } + return new GuiNPCManageAnimations(animNpc, save); + } else if (gui == EnumGuiType.ManageLinked) + return new GuiNPCManageLinked(npc); else if (gui == EnumGuiType.ManageMagic) return new GuiNpcManageMagic(npc); - else if (gui == EnumGuiType.ManageTransport) - return new GuiNPCManageTransporters(npc); + else if (gui == EnumGuiType.ManageTransport) + return new GuiNPCManageTransporters(npc); - else if (gui == EnumGuiType.ManageRecipes) - return new GuiNpcManageRecipes(npc, (ContainerManageRecipes) container); + else if (gui == EnumGuiType.ManageRecipes) + return new GuiNpcManageRecipes(npc, (ContainerManageRecipes) container); - else if (gui == EnumGuiType.ManageDialogs) - return new GuiNPCManageDialogs(npc); + else if (gui == EnumGuiType.ManageDialogs) + return new GuiNPCManageDialogs(npc); - else if (gui == EnumGuiType.ManageQuests) - return new GuiNPCManageQuest(npc); + else if (gui == EnumGuiType.ManageQuests) + return new GuiNPCManageQuest(npc); - else if (gui == EnumGuiType.ManageBanks) - return new GuiNPCManageBanks(npc, (ContainerManageBanks) container); + else if (gui == EnumGuiType.ManageBanks) + return new GuiNPCManageBanks(npc, (ContainerManageBanks) container); else if (gui == EnumGuiType.ManageEffects) return new GuiNPCManageEffects(npc); - else if (gui == EnumGuiType.MainMenuGlobal) - return new GuiNPCGlobalMainMenu(npc); + else if (gui == EnumGuiType.MainMenuGlobal) + return new GuiNPCGlobalMainMenu(npc); - else if (gui == EnumGuiType.MainMenuAI) - return new GuiNpcAI(npc); + else if (gui == EnumGuiType.MainMenuAI) + return new GuiNpcAI(npc); - else if (gui == EnumGuiType.PlayerFollowerHire) - return new GuiNpcFollowerHire(npc, (ContainerNPCFollowerHire) container); + else if (gui == EnumGuiType.PlayerFollowerHire) + return new GuiNpcFollowerHire(npc, (ContainerNPCFollowerHire) container); - else if (gui == EnumGuiType.PlayerFollower) - return new GuiNpcFollower(npc, (ContainerNPCFollower) container); + else if (gui == EnumGuiType.PlayerFollower) + return new GuiNpcFollower(npc, (ContainerNPCFollower) container); - else if (gui == EnumGuiType.PlayerTrader) - return new GuiNPCTrader(npc, (ContainerNPCTrader) container); + else if (gui == EnumGuiType.PlayerTrader) + return new GuiNPCTrader(npc, (ContainerNPCTrader) container); - else if (gui == EnumGuiType.PlayerBankSmall || gui == EnumGuiType.PlayerBankUnlock || gui == EnumGuiType.PlayerBankUprade || gui == EnumGuiType.PlayerBankLarge) - return new GuiNPCBankChest(npc, (ContainerNPCBankInterface) container); + else if (gui == EnumGuiType.PlayerBankSmall || gui == EnumGuiType.PlayerBankUnlock || gui == EnumGuiType.PlayerBankUprade || gui == EnumGuiType.PlayerBankLarge) + return new GuiNPCBankChest(npc, (ContainerNPCBankInterface) container); - else if (gui == EnumGuiType.PlayerTransporter) - return new GuiTransportSelection(npc); + else if (gui == EnumGuiType.PlayerTransporter) + return new GuiTransportSelection(npc); - else if (gui == EnumGuiType.Script) - return new GuiScript(npc); + else if (gui == EnumGuiType.Script) + return new GuiScript(npc); - else if (gui == EnumGuiType.ScriptItem) - return new GuiScriptItem(); + else if (gui == EnumGuiType.ScriptItem) + return new GuiScriptItem(); - else if (gui == EnumGuiType.PlayerCarpentryBench) - return new GuiNpcCarpentryBench((ContainerCarpentryBench) container); + else if (gui == EnumGuiType.PlayerCarpentryBench) + return new GuiNpcCarpentryBench((ContainerCarpentryBench) container); else if (gui == EnumGuiType.PlayerAnvil) return new GuiNpcAnvil((ContainerAnvilRepair) container); - else if (gui == EnumGuiType.SetupFollower) - return new GuiNpcFollowerSetup(npc, (ContainerNPCFollowerSetup) container); + else if (gui == EnumGuiType.SetupFollower) + return new GuiNpcFollowerSetup(npc, (ContainerNPCFollowerSetup) container); - else if (gui == EnumGuiType.SetupItemGiver) - return new GuiNpcItemGiver(npc, (ContainerNpcItemGiver) container); + else if (gui == EnumGuiType.SetupItemGiver) + return new GuiNpcItemGiver(npc, (ContainerNpcItemGiver) container); - else if (gui == EnumGuiType.SetupTrader) - return new GuiNpcTraderSetup(npc, (ContainerNPCTraderSetup) container); + else if (gui == EnumGuiType.SetupTrader) + return new GuiNpcTraderSetup(npc, (ContainerNPCTraderSetup) container); - else if (gui == EnumGuiType.SetupTransporter) - return new GuiNpcTransporter(npc); + else if (gui == EnumGuiType.SetupTransporter) + return new GuiNpcTransporter(npc); - else if (gui == EnumGuiType.SetupBank) - return new GuiNpcBankSetup(npc); + else if (gui == EnumGuiType.SetupBank) + return new GuiNpcBankSetup(npc); - else if (gui == EnumGuiType.NpcRemote && Minecraft.getMinecraft().currentScreen == null) - return new GuiNpcRemoteEditor(); + else if (gui == EnumGuiType.NpcRemote && Minecraft.getMinecraft().currentScreen == null) + return new GuiNpcRemoteEditor(); - else if (gui == EnumGuiType.ScriptEvent && Minecraft.getMinecraft().currentScreen == null) - return new GuiScriptGlobal(); + else if (gui == EnumGuiType.ScriptEvent && Minecraft.getMinecraft().currentScreen == null) + return new GuiScriptGlobal(); - else if (gui == EnumGuiType.PlayerMailman) - return new GuiMailmanWrite((ContainerMail) container, x == 1, y == 1); + else if (gui == EnumGuiType.PlayerMailman) + return new GuiMailmanWrite((ContainerMail) container, x == 1, y == 1); - else if (gui == EnumGuiType.PlayerMailbox) - return new GuiMailbox(); + else if (gui == EnumGuiType.PlayerMailbox) + return new GuiMailbox(); - else if (gui == EnumGuiType.MerchantAdd) - return new GuiMerchantAdd(); + else if (gui == EnumGuiType.MerchantAdd) + return new GuiMerchantAdd(); - else if (gui == EnumGuiType.Crate) - return new GuiCrate((ContainerCrate) container); + else if (gui == EnumGuiType.Crate) + return new GuiCrate((ContainerCrate) container); - else if(gui == EnumGuiType.NpcDimensions) - return new GuiNpcDimension(); + else if (gui == EnumGuiType.NpcDimensions) + return new GuiNpcDimension(); - else if(gui == EnumGuiType.Border) - return new GuiBorderBlock(x, y, z); + else if (gui == EnumGuiType.Border) + return new GuiBorderBlock(x, y, z); - else if(gui == EnumGuiType.BigSign) - return new GuiBigSign(x, y, z); + else if (gui == EnumGuiType.BigSign) + return new GuiBigSign(x, y, z); - else if (gui == EnumGuiType.RedstoneBlock) - return new GuiNpcRedstoneBlock(x, y, z); + else if (gui == EnumGuiType.RedstoneBlock) + return new GuiNpcRedstoneBlock(x, y, z); - else if(gui == EnumGuiType.Cloner) - return new GuiNpcMobSpawner(x, y, z); + else if (gui == EnumGuiType.Cloner) + return new GuiNpcMobSpawner(x, y, z); - else if(gui == EnumGuiType.MobSpawnerMounter) - return new GuiNpcMobSpawnerMounter(x, y, z); + else if (gui == EnumGuiType.MobSpawnerMounter) + return new GuiNpcMobSpawnerMounter(x, y, z); - else if (gui == EnumGuiType.Waypoint) - return new GuiNpcWaypoint(x, y, z); + else if (gui == EnumGuiType.Waypoint) + return new GuiNpcWaypoint(x, y, z); - else if (gui == EnumGuiType.Companion) - return new GuiNpcCompanionStats(npc); + else if (gui == EnumGuiType.Companion) + return new GuiNpcCompanionStats(npc); - else if (gui == EnumGuiType.CompanionTalent) - return new GuiNpcCompanionTalents(npc); + else if (gui == EnumGuiType.CompanionTalent) + return new GuiNpcCompanionTalents(npc); - else if (gui == EnumGuiType.CompanionInv) - return new GuiNpcCompanionInv(npc, (ContainerNPCCompanion) container); + else if (gui == EnumGuiType.CompanionInv) + return new GuiNpcCompanionInv(npc, (ContainerNPCCompanion) container); - else if (gui == EnumGuiType.CustomGui) - return new GuiCustom((ContainerCustomGui)container); + else if (gui == EnumGuiType.CustomGui) + return new GuiCustom((ContainerCustomGui) container); - else if (gui == EnumGuiType.ScriptBlock) - return new GuiScriptBlock(x,y,z); + else if (gui == EnumGuiType.ScriptBlock) + return new GuiScriptBlock(x, y, z); else if (gui == EnumGuiType.Paintbrush) return new GuiNpcPaintbrush(); @@ -427,234 +425,227 @@ public class ClientProxy extends CommonProxy { else if (gui == EnumGuiType.GlobalRemote) return new GuiNPCGlobalMainMenu(null); - return null; - } - - @Override - public void openGui(int i, int j, int k, EnumGuiType gui, EntityPlayer player) { - Minecraft minecraft = Minecraft.getMinecraft(); - if(minecraft.thePlayer != player) - return; - - GuiScreen guiscreen = getGui(null, gui, null, i, j, k); - - - if (guiscreen != null) { - minecraft.displayGuiScreen(guiscreen); - } - } - - @Override - public void openGui(EntityNPCInterface npc, EnumGuiType gui) { - openGui(npc, gui, 0, 0, 0); - } - - public void openGui(EntityNPCInterface npc, EnumGuiType gui, int x, int y, int z) { - Minecraft minecraft = Minecraft.getMinecraft(); - - Container container = this.getContainer(gui, minecraft.thePlayer, x, y, z, npc); - GuiScreen guiscreen = getGui(npc, gui,container, x, y, z); - - if (guiscreen != null) { - minecraft.displayGuiScreen(guiscreen); - } - } - - public void openGui(EntityPlayer player, Object guiscreen) { - Minecraft minecraft = Minecraft.getMinecraft(); - if(!player.worldObj.isRemote || !(guiscreen instanceof GuiScreen)) - return; - - if (guiscreen != null) { - minecraft.displayGuiScreen((GuiScreen)guiscreen); - } - - } - - @Override - public void spawnParticle(EntityLivingBase player, String string, Object... ob) { - if(string.equals("Spell")){ - int color = (Integer) ob[0]; - int number = (Integer) ob[1]; - for(int i = 0; i < number; i++){ - Random rand = player.worldObj.rand; - double x = (rand.nextDouble() - 0.5D) * (double)player.width; - double y = player.getEyeHeight(); - double z = (rand.nextDouble() - 0.5D) * (double)player.width; - - double f = (rand.nextDouble() - 0.5D) * 2D; - double f1 = -rand.nextDouble(); - double f2 = (rand.nextDouble() - 0.5D) * 2D; - - Minecraft.getMinecraft().effectRenderer.addEffect(new EntityElementalStaffFX(player, x, y, z, f, f1, f2, color)); - } - } - else if(string.equals("ModelData")){ - ModelData data = (ModelData) ob[0]; - ModelPartData particles = (ModelPartData) ob[1]; - EntityCustomNpc npc = (EntityCustomNpc) player; - Minecraft minecraft = Minecraft.getMinecraft(); - double height = npc.getYOffset() + data.getBodyY(); - Random rand = npc.getRNG(); - if(particles.type == 0){ - for(int i = 0; i< 2; i++){ - EntityEnderFX fx = new EntityEnderFX(npc, (rand.nextDouble() - 0.5D) * (double)player.width, (rand.nextDouble() * (double)player.height) - height - 0.25D, (rand.nextDouble() - 0.5D) * (double)player.width, (rand.nextDouble() - 0.5D) * 2D, -rand.nextDouble(), (rand.nextDouble() - 0.5D) * 2D, particles); - minecraft.effectRenderer.addEffect(fx); - } - - } - else if(particles.type == 1){ - for(int i = 0; i < 2; i++){ - double x = player.posX + (rand.nextDouble() - 0.5D) * 0.9; - double y = (player.posY + rand.nextDouble() * 1.9) - 0.25D - height; - double z = player.posZ + (rand.nextDouble() - 0.5D) * 0.9; - - - double f = (rand.nextDouble() - 0.5D) * 2D; - double f1 = -rand.nextDouble(); - double f2 = (rand.nextDouble() - 0.5D) * 2D; - - minecraft.effectRenderer.addEffect(new EntityRainbowFX(player.worldObj, x, y, z, f, f1, f2)); - } - } - } - } - private ModelSkirtArmor model = new ModelSkirtArmor(); - - public ModelBiped getSkirtModel() { - return model; - } - - public boolean hasClient() { - return true; - } - - public EntityPlayer getPlayer() { - return Minecraft.getMinecraft().thePlayer; - } - - - @Override - public void registerItem(Item item) { - if (item instanceof ItemScripted || item instanceof ItemLinked) { - MinecraftForgeClient.registerItemRenderer(item, new ItemCustomRenderer()); - } else if (item instanceof ItemNpcTool) { - MinecraftForgeClient.registerItemRenderer(item, new ItemToolRenderer()); - }else { - MinecraftForgeClient.registerItemRenderer(item, new NpcItemRenderer()); - } - } - - public static void bindTexture(ResourceLocation location) { - try{ - if(location == null) - return; - TextureManager texturemanager = Minecraft.getMinecraft().getTextureManager(); - if(location != null) - texturemanager.bindTexture((ResourceLocation) location); - } - catch(NullPointerException ex){ - - } - catch(ReportedException ex){ - - } - } - - @Override - public void spawnParticle(String particle, double x, double y, double z, - double motionX, double motionY, double motionZ, float scale) { - - RenderGlobal render = Minecraft.getMinecraft().renderGlobal; - - EntityFX fx = render.doSpawnParticle(particle, x, y, z, motionX, motionY, motionZ); - if(fx == null) - return; - - if (particle.equals("flame")){ - ObfuscationReflectionHelper.setPrivateValue(EntityFlameFX.class, (EntityFlameFX)fx, scale, 0); - } - else if (particle.equals("smoke")){ - ObfuscationReflectionHelper.setPrivateValue(EntitySmokeFX.class, (EntitySmokeFX)fx, scale, 0); - } - } + return null; + } @Override - public void generateBigSmokeParticles(World world, int x, int y, int z, boolean signalFire) - { - if (RAND.nextFloat() < 0.11F) - { + public void openGui(int i, int j, int k, EnumGuiType gui, EntityPlayer player) { + Minecraft minecraft = Minecraft.getMinecraft(); + if (minecraft.thePlayer != player) + return; + + GuiScreen guiscreen = getGui(null, gui, null, i, j, k); + + + if (guiscreen != null) { + minecraft.displayGuiScreen(guiscreen); + } + } + + @Override + public void openGui(EntityNPCInterface npc, EnumGuiType gui) { + openGui(npc, gui, 0, 0, 0); + } + + public void openGui(EntityNPCInterface npc, EnumGuiType gui, int x, int y, int z) { + Minecraft minecraft = Minecraft.getMinecraft(); + + Container container = this.getContainer(gui, minecraft.thePlayer, x, y, z, npc); + GuiScreen guiscreen = getGui(npc, gui, container, x, y, z); + + if (guiscreen != null) { + minecraft.displayGuiScreen(guiscreen); + } + } + + public void openGui(EntityPlayer player, Object guiscreen) { + Minecraft minecraft = Minecraft.getMinecraft(); + if (!player.worldObj.isRemote || !(guiscreen instanceof GuiScreen)) + return; + + if (guiscreen != null) { + minecraft.displayGuiScreen((GuiScreen) guiscreen); + } + + } + + @Override + public void spawnParticle(EntityLivingBase player, String string, Object... ob) { + if (string.equals("Spell")) { + int color = (Integer) ob[0]; + int number = (Integer) ob[1]; + for (int i = 0; i < number; i++) { + Random rand = player.worldObj.rand; + double x = (rand.nextDouble() - 0.5D) * (double) player.width; + double y = player.getEyeHeight(); + double z = (rand.nextDouble() - 0.5D) * (double) player.width; + + double f = (rand.nextDouble() - 0.5D) * 2D; + double f1 = -rand.nextDouble(); + double f2 = (rand.nextDouble() - 0.5D) * 2D; + + Minecraft.getMinecraft().effectRenderer.addEffect(new EntityElementalStaffFX(player, x, y, z, f, f1, f2, color)); + } + } else if (string.equals("ModelData")) { + ModelData data = (ModelData) ob[0]; + ModelPartData particles = (ModelPartData) ob[1]; + EntityCustomNpc npc = (EntityCustomNpc) player; + Minecraft minecraft = Minecraft.getMinecraft(); + double height = npc.getYOffset() + data.getBodyY(); + Random rand = npc.getRNG(); + if (particles.type == 0) { + for (int i = 0; i < 2; i++) { + EntityEnderFX fx = new EntityEnderFX(npc, (rand.nextDouble() - 0.5D) * (double) player.width, (rand.nextDouble() * (double) player.height) - height - 0.25D, (rand.nextDouble() - 0.5D) * (double) player.width, (rand.nextDouble() - 0.5D) * 2D, -rand.nextDouble(), (rand.nextDouble() - 0.5D) * 2D, particles); + minecraft.effectRenderer.addEffect(fx); + } + + } else if (particles.type == 1) { + for (int i = 0; i < 2; i++) { + double x = player.posX + (rand.nextDouble() - 0.5D) * 0.9; + double y = (player.posY + rand.nextDouble() * 1.9) - 0.25D - height; + double z = player.posZ + (rand.nextDouble() - 0.5D) * 0.9; + + + double f = (rand.nextDouble() - 0.5D) * 2D; + double f1 = -rand.nextDouble(); + double f2 = (rand.nextDouble() - 0.5D) * 2D; + + minecraft.effectRenderer.addEffect(new EntityRainbowFX(player.worldObj, x, y, z, f, f1, f2)); + } + } + } + } + + private ModelSkirtArmor model = new ModelSkirtArmor(); + + public ModelBiped getSkirtModel() { + return model; + } + + public boolean hasClient() { + return true; + } + + public EntityPlayer getPlayer() { + return Minecraft.getMinecraft().thePlayer; + } + + + @Override + public void registerItem(Item item) { + if (item instanceof ItemScripted || item instanceof ItemLinked) { + MinecraftForgeClient.registerItemRenderer(item, new ItemCustomRenderer()); + } else if (item instanceof ItemNpcTool) { + MinecraftForgeClient.registerItemRenderer(item, new ItemToolRenderer()); + } else { + MinecraftForgeClient.registerItemRenderer(item, new NpcItemRenderer()); + } + } + + public static void bindTexture(ResourceLocation location) { + try { + if (location == null) + return; + TextureManager texturemanager = Minecraft.getMinecraft().getTextureManager(); + if (location != null) + texturemanager.bindTexture((ResourceLocation) location); + } catch (NullPointerException ex) { + + } catch (ReportedException ex) { + + } + } + + @Override + public void spawnParticle(String particle, double x, double y, double z, + double motionX, double motionY, double motionZ, float scale) { + + RenderGlobal render = Minecraft.getMinecraft().renderGlobal; + + EntityFX fx = render.doSpawnParticle(particle, x, y, z, motionX, motionY, motionZ); + if (fx == null) + return; + + if (particle.equals("flame")) { + ObfuscationReflectionHelper.setPrivateValue(EntityFlameFX.class, (EntityFlameFX) fx, scale, 0); + } else if (particle.equals("smoke")) { + ObfuscationReflectionHelper.setPrivateValue(EntitySmokeFX.class, (EntitySmokeFX) fx, scale, 0); + } + } + + @Override + public void generateBigSmokeParticles(World world, int x, int y, int z, boolean signalFire) { + if (RAND.nextFloat() < 0.11F) { float[] colours = new float[0]; for (int i = 0; i < RAND.nextInt(2) + 1; ++i) Minecraft.getMinecraft().effectRenderer.addEffect(new EntityBigSmokeFX(world, x, y, z, signalFire, colours)); } } - @Override - public String getAchievementDesc(Achievement achievement) { - return achievement.getDescription(); - } + @Override + public String getAchievementDesc(Achievement achievement) { + return achievement.getDescription(); + } - @Override - public boolean isGUIOpen(){ - return Minecraft.getMinecraft().currentScreen != null; - } + @Override + public boolean isGUIOpen() { + return Minecraft.getMinecraft().currentScreen != null; + } - public static class FontContainer { - public StringCache textFont = null; - public boolean useCustomFont = true; + public static class FontContainer { + public StringCache textFont = null; + public boolean useCustomFont = true; - private FontContainer(){ + private FontContainer() { - } + } - public FontContainer(String fontType, int fontSize) { - textFont = new StringCache(); - textFont.setDefaultFont("Arial", fontSize, true); - useCustomFont = !fontType.equalsIgnoreCase("minecraft"); - try { - if(!useCustomFont || fontType.isEmpty() || fontType.equalsIgnoreCase("default")) - textFont.setCustomFont(new ResourceLocation("customnpcs","OpenSans.ttf"), fontSize, true); - else - textFont.setDefaultFont(fontType, fontSize, true); - } catch (Exception e) { - LogWriter.info("Failed loading font so using Arial"); - } - } + public FontContainer(String fontType, int fontSize) { + textFont = new StringCache(); + textFont.setDefaultFont("Arial", fontSize, true); + useCustomFont = !fontType.equalsIgnoreCase("minecraft"); + try { + if (!useCustomFont || fontType.isEmpty() || fontType.equalsIgnoreCase("default")) + textFont.setCustomFont(new ResourceLocation("customnpcs", "OpenSans.ttf"), fontSize, true); + else + textFont.setDefaultFont(fontType, fontSize, true); + } catch (Exception e) { + LogWriter.info("Failed loading font so using Arial"); + } + } - public int height(){ - if(useCustomFont) - return textFont.fontHeight; - return Minecraft.getMinecraft().fontRenderer.FONT_HEIGHT; - } + public int height() { + if (useCustomFont) + return textFont.fontHeight; + return Minecraft.getMinecraft().fontRenderer.FONT_HEIGHT; + } - public int width(String text){ - if(useCustomFont) - return textFont.getStringWidth(text); - return Minecraft.getMinecraft().fontRenderer.getStringWidth(text); - } + public int width(String text) { + if (useCustomFont) + return textFont.getStringWidth(text); + return Minecraft.getMinecraft().fontRenderer.getStringWidth(text); + } - public FontContainer copy() { - FontContainer font = new FontContainer(); - font.textFont = textFont; - font.useCustomFont = useCustomFont; - return font; - } + public FontContainer copy() { + FontContainer font = new FontContainer(); + font.textFont = textFont; + font.useCustomFont = useCustomFont; + return font; + } - public void drawString(String text, int x, int y, int color) { - if(useCustomFont){ - textFont.renderString(text, x, y, color, true); - textFont.renderString(text, x, y, color, false); - } - else{ - Minecraft.getMinecraft().fontRenderer.drawStringWithShadow(text, x, y, color); - } - } + public void drawString(String text, int x, int y, int color) { + if (useCustomFont) { + textFont.renderString(text, x, y, color, true); + textFont.renderString(text, x, y, color, false); + } else { + Minecraft.getMinecraft().fontRenderer.drawStringWithShadow(text, x, y, color); + } + } - public String getName() { - if(!useCustomFont) - return "Minecraft"; - return textFont.usedFont().getFontName(); - } - } + public String getName() { + if (!useCustomFont) + return "Minecraft"; + return textFont.usedFont().getFontName(); + } + } } diff --git a/src/main/java/noppes/npcs/client/ClientTickHandler.java b/src/main/java/noppes/npcs/client/ClientTickHandler.java index f372e4a78..46af7df1a 100644 --- a/src/main/java/noppes/npcs/client/ClientTickHandler.java +++ b/src/main/java/noppes/npcs/client/ClientTickHandler.java @@ -34,40 +34,39 @@ import java.util.ArrayList; import static noppes.npcs.client.ClientEventHandler.renderCNPCPlayer; -public class ClientTickHandler{ - private World prevWorld; - private int prevWidth = 0; - private int prevHeight = 0; - private boolean otherContainer = false; - private int buttonPressed = -1; - private long buttonTime = 0L; - private final int[] ignoreKeys = new int[]{157, 29, 54, 42, 184, 56, 220, 219}; +public class ClientTickHandler { + private World prevWorld; + private int prevWidth = 0; + private int prevHeight = 0; + private boolean otherContainer = false; + private int buttonPressed = -1; + private long buttonTime = 0L; + private final int[] ignoreKeys = new int[]{157, 29, 54, 42, 184, 56, 220, 219}; - @SubscribeEvent(priority = EventPriority.LOWEST) - public void onClientTick(TickEvent.ClientTickEvent event){ - Minecraft mc = Minecraft.getMinecraft(); - if ((this.prevWorld == null || mc.theWorld == null) && this.prevWorld != mc.theWorld) { + @SubscribeEvent(priority = EventPriority.LOWEST) + public void onClientTick(TickEvent.ClientTickEvent event) { + Minecraft mc = Minecraft.getMinecraft(); + if ((this.prevWorld == null || mc.theWorld == null) && this.prevWorld != mc.theWorld) { if (mc.theWorld == null) { ClientCacheHandler.clearCache(); } - this.prevWorld = mc.theWorld; - } - if(event.phase == Phase.END) { - if (mc.thePlayer != null && mc.theWorld != null && !mc.isGamePaused() && ClientEventHandler.hasOverlays(mc.thePlayer)) { - renderCNPCPlayer.itemRenderer.updateEquippedItem(); - } - return; - } - if(mc.thePlayer != null && mc.thePlayer.openContainer instanceof ContainerPlayer){ - if(otherContainer){ + this.prevWorld = mc.theWorld; + } + if (event.phase == Phase.END) { + if (mc.thePlayer != null && mc.theWorld != null && !mc.isGamePaused() && ClientEventHandler.hasOverlays(mc.thePlayer)) { + renderCNPCPlayer.itemRenderer.updateEquippedItem(); + } + return; + } + if (mc.thePlayer != null && mc.thePlayer.openContainer instanceof ContainerPlayer) { + if (otherContainer) { PacketClient.sendClient(new CheckPlayerValue(CheckPlayerValue.Type.CheckQuestCompletion)); - otherContainer = false; - } - } - else - otherContainer = true; - CustomNpcs.ticks++; - RenderNPCInterface.LastTextureTick++; + otherContainer = false; + } + } else + otherContainer = true; + CustomNpcs.ticks++; + RenderNPCInterface.LastTextureTick++; if (MusicController.Instance.isPlaying() && MusicController.Instance.getEntity() != null) { Entity entity = MusicController.Instance.getEntity(); @@ -80,101 +79,101 @@ public class ClientTickHandler{ } MusicController.Instance.onUpdate(); - ScriptSoundController.Instance.onUpdate(); - if(Minecraft.getMinecraft().thePlayer!=null && (prevWidth!=mc.displayWidth || prevHeight!=mc.displayHeight)){ - prevWidth = mc.displayWidth; - prevHeight = mc.displayHeight; - PacketClient.sendClient(new ScreenSizePacket(mc.displayWidth,mc.displayHeight)); - } + ScriptSoundController.Instance.onUpdate(); + if (Minecraft.getMinecraft().thePlayer != null && (prevWidth != mc.displayWidth || prevHeight != mc.displayHeight)) { + prevWidth = mc.displayWidth; + prevHeight = mc.displayHeight; + PacketClient.sendClient(new ScreenSizePacket(mc.displayWidth, mc.displayHeight)); + } - if(mc.theWorld == null) + if (mc.theWorld == null) return; - if(mc.theWorld.getTotalWorldTime() % 20 == 0) { // Update every second + if (mc.theWorld.getTotalWorldTime() % 20 == 0) { // Update every second updateCompassMarks(); } - } + } - @SubscribeEvent - public void onMouse(InputEvent.MouseInputEvent event){ - if(Mouse.getEventButton() == -1 && Mouse.getEventDWheel() == 0) - return; + @SubscribeEvent + public void onMouse(InputEvent.MouseInputEvent event) { + if (Mouse.getEventButton() == -1 && Mouse.getEventDWheel() == 0) + return; - InputDevicePacket.sendMouse(Mouse.getEventButton(),Mouse.getEventDWheel(),Mouse.isButtonDown(Mouse.getEventButton())); - } + InputDevicePacket.sendMouse(Mouse.getEventButton(), Mouse.getEventDWheel(), Mouse.isButtonDown(Mouse.getEventButton())); + } - @SubscribeEvent - public void onKey(InputEvent.KeyInputEvent event){ - if(ClientProxy.NPCButton.isPressed()){ - Minecraft mc = Minecraft.getMinecraft(); - if(mc.currentScreen == null){ + @SubscribeEvent + public void onKey(InputEvent.KeyInputEvent event) { + if (ClientProxy.NPCButton.isPressed()) { + Minecraft mc = Minecraft.getMinecraft(); + if (mc.currentScreen == null) { InventoryTabCustomNpc.tabHelper(); - } - else if(mc.currentScreen instanceof GuiCNPCInventory) - mc.setIngameFocus(); - } + } else if (mc.currentScreen instanceof GuiCNPCInventory) + mc.setIngameFocus(); + } - if(!Keyboard.isRepeatEvent()) { - int key = Keyboard.getEventKey(); - boolean keyDown = Keyboard.isKeyDown(key); + if (!Keyboard.isRepeatEvent()) { + int key = Keyboard.getEventKey(); + boolean keyDown = Keyboard.isKeyDown(key); InputDevicePacket.sendKeyboard(key, keyDown); - } - } + } + } - private boolean isIgnoredKey(int key) { - int[] var2 = this.ignoreKeys; - int var3 = var2.length; + private boolean isIgnoredKey(int key) { + int[] var2 = this.ignoreKeys; + int var3 = var2.length; - for(int var4 = 0; var4 < var3; ++var4) { - int i = var2[var4]; - if(i == key) { - return true; - } - } + for (int var4 = 0; var4 < var3; ++var4) { + int i = var2[var4]; + if (i == key) { + return true; + } + } - return false; - } + return false; + } private final int SCAN_RANGE = 128; + private void updateCompassMarks() { Minecraft mc = Minecraft.getMinecraft(); EntityPlayer player = mc.thePlayer; - if(player == null || mc.theWorld == null) + if (player == null || mc.theWorld == null) return; - if(ClientHudManager.getInstance() == null || ClientHudManager.getInstance().getHudComponents() == null) + if (ClientHudManager.getInstance() == null || ClientHudManager.getInstance().getHudComponents() == null) return; // Update compass HudComponent compass = ClientHudManager.getInstance() .getHudComponents().get(EnumHudComponent.QuestCompass); - if(!(compass instanceof CompassHudComponent)) + if (!(compass instanceof CompassHudComponent)) return; - if(!compass.enabled) + if (!compass.enabled) return; ArrayList marks = new ArrayList<>(); // Scan entities in loaded chunks - for(Object entity : mc.theWorld.loadedEntityList) { - if(entity instanceof EntityNPCInterface) { + for (Object entity : mc.theWorld.loadedEntityList) { + if (entity instanceof EntityNPCInterface) { EntityNPCInterface npc = (EntityNPCInterface) entity; - if(npc.dimension != player.dimension) + if (npc.dimension != player.dimension) continue; // Check distance - if(player.getDistanceToEntity(npc) > SCAN_RANGE) + if (player.getDistanceToEntity(npc) > SCAN_RANGE) continue; // Get marks MarkData markData = MarkData.get(npc); - for(MarkData.Mark mark : markData.marks) { - if(mark.getType() != MarkType.NONE && + for (MarkData.Mark mark : markData.marks) { + if (mark.getType() != MarkType.NONE && mark.availability.isAvailable(player)) { marks.add(new CompassHudComponent.MarkTargetEntry( npc.posX, diff --git a/src/main/java/noppes/npcs/client/CustomNpcResourceListener.java b/src/main/java/noppes/npcs/client/CustomNpcResourceListener.java index 1fcd9c9e1..8aeeff628 100644 --- a/src/main/java/noppes/npcs/client/CustomNpcResourceListener.java +++ b/src/main/java/noppes/npcs/client/CustomNpcResourceListener.java @@ -16,68 +16,67 @@ import java.awt.image.BufferedImage; import java.io.File; public class CustomNpcResourceListener implements - IResourceManagerReloadListener { + IResourceManagerReloadListener { - public static int DefaultTextColor = 0x404040; - @Override - public void onResourceManagerReload(IResourceManager var1) { - if(var1 instanceof SimpleReloadableResourceManager){ - createTextureCache(new File(CustomNpcs.Dir,"assets/customnpcs/textures/cache")); - - SimpleReloadableResourceManager simplemanager = (SimpleReloadableResourceManager)var1; - - FolderResourcePack pack = new FolderResourcePack(CustomNpcs.Dir); - simplemanager.reloadResourcePack(pack); - - try{ - DefaultTextColor = Integer.parseInt(StatCollector.translateToLocal("customnpcs.defaultTextColor"),16); - } - catch(NumberFormatException e){ - DefaultTextColor = 0x404040; - } - } - } + public static int DefaultTextColor = 0x404040; - - private void createTextureCache(File dir){ - if(dir == null) - return; - enlargeTexture("planks_oak", dir); - enlargeTexture("planks_big_oak", dir); - enlargeTexture("planks_birch", dir); - enlargeTexture("planks_jungle", dir); - enlargeTexture("planks_spruce", dir); - enlargeTexture("planks_acacia", dir); - enlargeTexture("iron_block", dir); - enlargeTexture("diamond_block", dir); - enlargeTexture("stone", dir); - enlargeTexture("gold_block", dir); - enlargeTexture("wool_colored_white", dir); - } - - private void enlargeTexture(String texture, File dir){ - try{ - IResourceManager manager = Minecraft.getMinecraft().getResourceManager(); - ResourceLocation location = new ResourceLocation("textures/blocks/" + texture +".png"); - BufferedImage bufferedimage = ImageIO.read(manager.getResource(location).getInputStream()); - int i = bufferedimage.getWidth(); - int j = bufferedimage.getHeight(); - - BufferedImage image = new BufferedImage(i * 4, j * 2, BufferedImage.TYPE_INT_RGB); - Graphics g = image.getGraphics(); - g.drawImage(bufferedimage, 0, 0, null); - g.drawImage(bufferedimage, i, 0, null); - g.drawImage(bufferedimage, i * 2, 0, null); - g.drawImage(bufferedimage, i * 3, 0, null); - g.drawImage(bufferedimage, 0, i, null); - g.drawImage(bufferedimage, i, j, null); - g.drawImage(bufferedimage, i * 2, j, null); - g.drawImage(bufferedimage, i * 3, j, null); - ImageIO.write(image, "png", new File(dir,texture + ".png")); - } - catch(Exception e){ - LogWriter.error("Failed caching texture: " + texture, e); - } - } + @Override + public void onResourceManagerReload(IResourceManager var1) { + if (var1 instanceof SimpleReloadableResourceManager) { + createTextureCache(new File(CustomNpcs.Dir, "assets/customnpcs/textures/cache")); + + SimpleReloadableResourceManager simplemanager = (SimpleReloadableResourceManager) var1; + + FolderResourcePack pack = new FolderResourcePack(CustomNpcs.Dir); + simplemanager.reloadResourcePack(pack); + + try { + DefaultTextColor = Integer.parseInt(StatCollector.translateToLocal("customnpcs.defaultTextColor"), 16); + } catch (NumberFormatException e) { + DefaultTextColor = 0x404040; + } + } + } + + + private void createTextureCache(File dir) { + if (dir == null) + return; + enlargeTexture("planks_oak", dir); + enlargeTexture("planks_big_oak", dir); + enlargeTexture("planks_birch", dir); + enlargeTexture("planks_jungle", dir); + enlargeTexture("planks_spruce", dir); + enlargeTexture("planks_acacia", dir); + enlargeTexture("iron_block", dir); + enlargeTexture("diamond_block", dir); + enlargeTexture("stone", dir); + enlargeTexture("gold_block", dir); + enlargeTexture("wool_colored_white", dir); + } + + private void enlargeTexture(String texture, File dir) { + try { + IResourceManager manager = Minecraft.getMinecraft().getResourceManager(); + ResourceLocation location = new ResourceLocation("textures/blocks/" + texture + ".png"); + BufferedImage bufferedimage = ImageIO.read(manager.getResource(location).getInputStream()); + int i = bufferedimage.getWidth(); + int j = bufferedimage.getHeight(); + + BufferedImage image = new BufferedImage(i * 4, j * 2, BufferedImage.TYPE_INT_RGB); + Graphics g = image.getGraphics(); + g.drawImage(bufferedimage, 0, 0, null); + g.drawImage(bufferedimage, i, 0, null); + g.drawImage(bufferedimage, i * 2, 0, null); + g.drawImage(bufferedimage, i * 3, 0, null); + g.drawImage(bufferedimage, 0, i, null); + g.drawImage(bufferedimage, i, j, null); + g.drawImage(bufferedimage, i * 2, j, null); + g.drawImage(bufferedimage, i * 3, j, null); + ImageIO.write(image, "png", new File(dir, texture + ".png")); + } catch (Exception e) { + LogWriter.error("Failed caching texture: " + texture, e); + } + } } diff --git a/src/main/java/noppes/npcs/client/EntityUtil.java b/src/main/java/noppes/npcs/client/EntityUtil.java index 2aadea2a4..05fa1a773 100644 --- a/src/main/java/noppes/npcs/client/EntityUtil.java +++ b/src/main/java/noppes/npcs/client/EntityUtil.java @@ -10,96 +10,96 @@ import noppes.npcs.entity.EntityNPCInterface; public class EntityUtil { - public static void Copy(EntityLivingBase copied, EntityLivingBase entity){ - entity.worldObj = copied.worldObj; + public static void Copy(EntityLivingBase copied, EntityLivingBase entity) { + entity.worldObj = copied.worldObj; - entity.deathTime = copied.deathTime; - entity.distanceWalkedModified = copied.distanceWalkedModified; - entity.prevDistanceWalkedModified = copied.distanceWalkedModified; - entity.onGround = copied.onGround; - entity.distanceWalkedOnStepModified = copied.distanceWalkedOnStepModified; + entity.deathTime = copied.deathTime; + entity.distanceWalkedModified = copied.distanceWalkedModified; + entity.prevDistanceWalkedModified = copied.distanceWalkedModified; + entity.onGround = copied.onGround; + entity.distanceWalkedOnStepModified = copied.distanceWalkedOnStepModified; - entity.moveForward = copied.moveForward; - entity.moveStrafing = copied.moveStrafing; + entity.moveForward = copied.moveForward; + entity.moveStrafing = copied.moveStrafing; - entity.setPosition(copied.posX, copied.posY, copied.posZ); - entity.boundingBox.setBB(copied.boundingBox); + entity.setPosition(copied.posX, copied.posY, copied.posZ); + entity.boundingBox.setBB(copied.boundingBox); - entity.prevPosX = copied.prevPosX; - entity.prevPosY = copied.prevPosY; - entity.prevPosZ = copied.prevPosZ; + entity.prevPosX = copied.prevPosX; + entity.prevPosY = copied.prevPosY; + entity.prevPosZ = copied.prevPosZ; - entity.motionX = copied.motionX; - entity.motionY = copied.motionY; - entity.motionZ = copied.motionZ; + entity.motionX = copied.motionX; + entity.motionY = copied.motionY; + entity.motionZ = copied.motionZ; - entity.rotationYaw = copied.rotationYaw; - entity.rotationPitch = copied.rotationPitch; - entity.prevRotationYaw = copied.prevRotationYaw; - entity.prevRotationPitch = copied.prevRotationPitch; - entity.rotationYawHead = copied.rotationYawHead; - entity.prevRotationYawHead = copied.prevRotationYawHead; - entity.prevRenderYawOffset = copied.prevRenderYawOffset; - entity.cameraPitch = copied.cameraPitch; - entity.prevCameraPitch = copied.prevCameraPitch; + entity.rotationYaw = copied.rotationYaw; + entity.rotationPitch = copied.rotationPitch; + entity.prevRotationYaw = copied.prevRotationYaw; + entity.prevRotationPitch = copied.prevRotationPitch; + entity.rotationYawHead = copied.rotationYawHead; + entity.prevRotationYawHead = copied.prevRotationYawHead; + entity.prevRenderYawOffset = copied.prevRenderYawOffset; + entity.cameraPitch = copied.cameraPitch; + entity.prevCameraPitch = copied.prevCameraPitch; - entity.renderYawOffset = copied.renderYawOffset; + entity.renderYawOffset = copied.renderYawOffset; - entity.lastTickPosX = copied.lastTickPosX; - entity.lastTickPosY = copied.lastTickPosY; - entity.lastTickPosZ = copied.lastTickPosZ; + entity.lastTickPosX = copied.lastTickPosX; + entity.lastTickPosY = copied.lastTickPosY; + entity.lastTickPosZ = copied.lastTickPosZ; - entity.limbSwingAmount = copied.limbSwingAmount; - entity.prevLimbSwingAmount = copied.prevLimbSwingAmount; - entity.limbSwing = copied.limbSwing; + entity.limbSwingAmount = copied.limbSwingAmount; + entity.prevLimbSwingAmount = copied.prevLimbSwingAmount; + entity.limbSwing = copied.limbSwing; - entity.swingProgress = copied.swingProgress; - entity.prevSwingProgress = copied.prevSwingProgress; - entity.isSwingInProgress = copied.isSwingInProgress; - entity.swingProgressInt = copied.swingProgressInt; + entity.swingProgress = copied.swingProgress; + entity.prevSwingProgress = copied.prevSwingProgress; + entity.isSwingInProgress = copied.isSwingInProgress; + entity.swingProgressInt = copied.swingProgressInt; - entity.ticksExisted = copied.ticksExisted; + entity.ticksExisted = copied.ticksExisted; - if(entity instanceof EntityPlayer && copied instanceof EntityPlayer){ - EntityPlayer ePlayer = (EntityPlayer) entity; - EntityPlayer cPlayer = (EntityPlayer) copied; + if (entity instanceof EntityPlayer && copied instanceof EntityPlayer) { + EntityPlayer ePlayer = (EntityPlayer) entity; + EntityPlayer cPlayer = (EntityPlayer) copied; - ePlayer.cameraYaw = cPlayer.cameraYaw; - ePlayer.prevCameraYaw = cPlayer.prevCameraYaw; + ePlayer.cameraYaw = cPlayer.cameraYaw; + ePlayer.prevCameraYaw = cPlayer.prevCameraYaw; - ePlayer.field_71091_bM = cPlayer.field_71091_bM; - ePlayer.field_71096_bN = cPlayer.field_71096_bN; - ePlayer.field_71097_bO = cPlayer.field_71097_bO; - ePlayer.field_71094_bP = cPlayer.field_71094_bP; - ePlayer.field_71095_bQ = cPlayer.field_71095_bQ; - ePlayer.field_71085_bR = cPlayer.field_71085_bR; - } + ePlayer.field_71091_bM = cPlayer.field_71091_bM; + ePlayer.field_71096_bN = cPlayer.field_71096_bN; + ePlayer.field_71097_bO = cPlayer.field_71097_bO; + ePlayer.field_71094_bP = cPlayer.field_71094_bP; + ePlayer.field_71095_bQ = cPlayer.field_71095_bQ; + ePlayer.field_71085_bR = cPlayer.field_71085_bR; + } - if(entity instanceof EntityDragon){ - entity.rotationYaw += 180; - } - if(entity instanceof EntityChicken){ - ((EntityChicken)entity).destPos = copied.onGround?0:1; - } + if (entity instanceof EntityDragon) { + entity.rotationYaw += 180; + } + if (entity instanceof EntityChicken) { + ((EntityChicken) entity).destPos = copied.onGround ? 0 : 1; + } - for(int i = 0; i < 5; i++){ - entity.setCurrentItemOrArmor(i, copied.getEquipmentInSlot(i)); - } + for (int i = 0; i < 5; i++) { + entity.setCurrentItemOrArmor(i, copied.getEquipmentInSlot(i)); + } - GeckoAddon.instance.geckoCopyData(copied, entity); + GeckoAddon.instance.geckoCopyData(copied, entity); DBCAddon.instance.dbcCopyData(copied, entity); - if(copied instanceof EntityNPCInterface && entity instanceof EntityNPCInterface){ - EntityNPCInterface npc = (EntityNPCInterface) copied; - EntityNPCInterface target = (EntityNPCInterface) entity; + if (copied instanceof EntityNPCInterface && entity instanceof EntityNPCInterface) { + EntityNPCInterface npc = (EntityNPCInterface) copied; + EntityNPCInterface target = (EntityNPCInterface) entity; - target.textureLocation = npc.textureLocation; - target.display = npc.display; - target.inventory = npc.inventory; + target.textureLocation = npc.textureLocation; + target.display = npc.display; + target.inventory = npc.inventory; - target.currentAnimation = npc.currentAnimation; + target.currentAnimation = npc.currentAnimation; - target.setDataWatcher(npc.getDataWatcher()); - } - } + target.setDataWatcher(npc.getDataWatcher()); + } + } } diff --git a/src/main/java/noppes/npcs/client/ImageDownloadAlt.java b/src/main/java/noppes/npcs/client/ImageDownloadAlt.java index 3a5b9ae6f..c53706b9d 100644 --- a/src/main/java/noppes/npcs/client/ImageDownloadAlt.java +++ b/src/main/java/noppes/npcs/client/ImageDownloadAlt.java @@ -22,8 +22,7 @@ import java.net.URL; import java.util.concurrent.atomic.AtomicInteger; @SideOnly(Side.CLIENT) -public class ImageDownloadAlt extends SimpleTexture -{ +public class ImageDownloadAlt extends SimpleTexture { private static final Logger logger = LogManager.getLogger(); private static final AtomicInteger threadDownloadCounter = new AtomicInteger(0); private final File cacheFile; @@ -33,22 +32,17 @@ public class ImageDownloadAlt extends SimpleTexture private Thread imageThread; private boolean textureUploaded; - public ImageDownloadAlt(File file, String url, ResourceLocation resource, IImageBuffer buffer) - { + public ImageDownloadAlt(File file, String url, ResourceLocation resource, IImageBuffer buffer) { super(resource); this.cacheFile = file; this.imageUrl = url; this.imageBuffer = buffer; } - private void checkTextureUploaded() - { - if (!this.textureUploaded) - { - if (this.bufferedImage != null) - { - if (this.textureLocation != null) - { + private void checkTextureUploaded() { + if (!this.textureUploaded) { + if (this.bufferedImage != null) { + if (this.textureLocation != null) { this.deleteGlTexture(); } @@ -58,74 +52,57 @@ public class ImageDownloadAlt extends SimpleTexture } } - public int getGlTextureId() - { + public int getGlTextureId() { this.checkTextureUploaded(); return super.getGlTextureId(); } - public void setBufferedImage(BufferedImage p_147641_1_) - { + public void setBufferedImage(BufferedImage p_147641_1_) { this.bufferedImage = p_147641_1_; - if (this.imageBuffer != null) - { + if (this.imageBuffer != null) { this.imageBuffer.func_152634_a(); } } - public BufferedImage getBufferedImage(){ + public BufferedImage getBufferedImage() { return this.bufferedImage; } - public void loadTexture(IResourceManager resourceManager) throws IOException - { - if (this.bufferedImage == null && this.textureLocation != null) - { + public void loadTexture(IResourceManager resourceManager) throws IOException { + if (this.bufferedImage == null && this.textureLocation != null) { super.loadTexture(resourceManager); } - if (this.imageThread == null) - { - if (this.cacheFile != null && this.cacheFile.isFile()) - { - logger.debug("Loading http texture from local cache ({})", new Object[] {this.cacheFile}); + if (this.imageThread == null) { + if (this.cacheFile != null && this.cacheFile.isFile()) { + logger.debug("Loading http texture from local cache ({})", new Object[]{this.cacheFile}); - try - { + try { this.bufferedImage = ImageIO.read(this.cacheFile); - if (this.imageBuffer != null) - { + if (this.imageBuffer != null) { this.setBufferedImage(this.imageBuffer.parseUserSkin(this.bufferedImage)); } - } - catch (IOException ioexception) - { + } catch (IOException ioexception) { logger.error("Couldn\'t load skin " + this.cacheFile, ioexception); this.loadTextureFromServer(); } - } - else - { + } else { this.loadTextureFromServer(); } } } - protected void loadTextureFromServer() - { - this.imageThread = new Thread("Texture Downloader #" + threadDownloadCounter.incrementAndGet()) - { - public void run() - { + protected void loadTextureFromServer() { + this.imageThread = new Thread("Texture Downloader #" + threadDownloadCounter.incrementAndGet()) { + public void run() { HttpURLConnection connection = null; - ImageDownloadAlt.logger.debug("Downloading http texture from {} to {}", new Object[] {ImageDownloadAlt.this.imageUrl, ImageDownloadAlt.this.cacheFile}); + ImageDownloadAlt.logger.debug("Downloading http texture from {} to {}", new Object[]{ImageDownloadAlt.this.imageUrl, ImageDownloadAlt.this.cacheFile}); - try - { + try { URL url = new URL(ImageDownloadAlt.this.imageUrl); - connection = (HttpURLConnection)(url).openConnection(Minecraft.getMinecraft().getProxy()); + connection = (HttpURLConnection) (url).openConnection(Minecraft.getMinecraft().getProxy()); connection.setDoInput(true); connection.setDoOutput(false); connection.setRequestProperty("Content-Type", "image/png"); @@ -140,40 +117,29 @@ public class ImageDownloadAlt extends SimpleTexture connection.connect(); - if (connection.getResponseCode() / 100 != 2) - { + if (connection.getResponseCode() / 100 != 2) { return; } BufferedImage bufferedimage; - if (ImageDownloadAlt.this.cacheFile != null) - { + if (ImageDownloadAlt.this.cacheFile != null) { FileUtils.copyInputStreamToFile(connection.getInputStream(), ImageDownloadAlt.this.cacheFile); bufferedimage = ImageIO.read(ImageDownloadAlt.this.cacheFile); - } - else - { + } else { bufferedimage = ImageIO.read(connection.getInputStream()); } - if (ImageDownloadAlt.this.imageBuffer != null) - { + if (ImageDownloadAlt.this.imageBuffer != null) { bufferedimage = ImageDownloadAlt.this.imageBuffer.parseUserSkin(bufferedimage); } ImageDownloadAlt.this.setBufferedImage(bufferedimage); - } - catch (MalformedURLException ignored) { - } - catch (Exception exception) - { + } catch (MalformedURLException ignored) { + } catch (Exception exception) { ImageDownloadAlt.logger.error("Couldn\'t download http texture", exception); - } - finally - { - if (connection != null) - { + } finally { + if (connection != null) { connection.disconnect(); } } diff --git a/src/main/java/noppes/npcs/client/MessageAchievement.java b/src/main/java/noppes/npcs/client/MessageAchievement.java index 464ca1a43..1b4f1a848 100644 --- a/src/main/java/noppes/npcs/client/MessageAchievement.java +++ b/src/main/java/noppes/npcs/client/MessageAchievement.java @@ -7,28 +7,27 @@ import net.minecraft.util.ChatComponentText; import net.minecraft.util.IChatComponent; import noppes.npcs.CustomItems; -public class MessageAchievement extends Achievement{ +public class MessageAchievement extends Achievement { - private String description; - private String message; + private String description; + private String message; - public MessageAchievement(Item item, String message, String description) { - super("",message, 0, 0, item, null); - this.description = description; - this.message = message; - } - - public MessageAchievement(String message, String description) { - this(CustomItems.letter==null ? Items.paper : CustomItems.letter, message, description); - } - - @Override - public IChatComponent func_150951_e() - { - return new ChatComponentText(message); + public MessageAchievement(Item item, String message, String description) { + super("", message, 0, 0, item, null); + this.description = description; + this.message = message; } - public String getDescription() - { - return description; + + public MessageAchievement(String message, String description) { + this(CustomItems.letter == null ? Items.paper : CustomItems.letter, message, description); + } + + @Override + public IChatComponent func_150951_e() { + return new ChatComponentText(message); + } + + public String getDescription() { + return description; } } diff --git a/src/main/java/noppes/npcs/client/NoppesUtil.java b/src/main/java/noppes/npcs/client/NoppesUtil.java index a74969863..3a343291e 100644 --- a/src/main/java/noppes/npcs/client/NoppesUtil.java +++ b/src/main/java/noppes/npcs/client/NoppesUtil.java @@ -17,7 +17,10 @@ import net.minecraft.util.Util; import noppes.npcs.CustomNpcs; import noppes.npcs.client.gui.player.GuiDialogInteract; import noppes.npcs.client.gui.player.GuiQuestCompletion; -import noppes.npcs.client.gui.util.*; +import noppes.npcs.client.gui.util.GuiContainerNPCInterface; +import noppes.npcs.client.gui.util.GuiNPCInterface; +import noppes.npcs.client.gui.util.IPlayerDataInfo; +import noppes.npcs.client.gui.util.IScrollData; import noppes.npcs.constants.EnumGuiType; import noppes.npcs.constants.EnumScrollData; import noppes.npcs.controllers.data.Dialog; @@ -36,50 +39,52 @@ import java.util.Vector; public class NoppesUtil { - public static void requestOpenGUI(EnumGuiType gui) { - requestOpenGUI(gui, 0, 0, 0); - } + public static void requestOpenGUI(EnumGuiType gui) { + requestOpenGUI(gui, 0, 0, 0); + } - public static void requestOpenGUI(EnumGuiType gui, int i, int j, int k) { + public static void requestOpenGUI(EnumGuiType gui, int i, int j, int k) { PacketClient.sendClient(new GuiRequestPacket(gui.ordinal(), i, j, k)); - } + } public static void updateSkinOverlayData(EntityPlayer player, NBTTagCompound compound) { - HashMap skinOverlays = new HashMap<>(); - HashMap oldOverlays = new HashMap<>(); - NBTTagList skinOverlayList = compound.getTagList("SkinOverlayData",10); - if (ClientCacheHandler.skinOverlays.containsKey(player.getUniqueID())) { - oldOverlays = ClientCacheHandler.skinOverlays.get(player.getUniqueID()); - } + HashMap skinOverlays = new HashMap<>(); + HashMap oldOverlays = new HashMap<>(); + NBTTagList skinOverlayList = compound.getTagList("SkinOverlayData", 10); + if (ClientCacheHandler.skinOverlays.containsKey(player.getUniqueID())) { + oldOverlays = ClientCacheHandler.skinOverlays.get(player.getUniqueID()); + } - for (int i = 0; i < skinOverlayList.tagCount(); i++) { - int tagID = skinOverlayList.getCompoundTagAt(i).getInteger("SkinOverlayID"); - SkinOverlay overlay = (SkinOverlay) SkinOverlay.overlayFromNBT(skinOverlayList.getCompoundTagAt(i)); - if (oldOverlays.containsKey(tagID)) { - overlay.ticks = oldOverlays.get(tagID).ticks; - } - skinOverlays.put(tagID,overlay); - } - ClientCacheHandler.skinOverlays.put(player.getUniqueID(), skinOverlays); - } + for (int i = 0; i < skinOverlayList.tagCount(); i++) { + int tagID = skinOverlayList.getCompoundTagAt(i).getInteger("SkinOverlayID"); + SkinOverlay overlay = (SkinOverlay) SkinOverlay.overlayFromNBT(skinOverlayList.getCompoundTagAt(i)); + if (oldOverlays.containsKey(tagID)) { + overlay.ticks = oldOverlays.get(tagID).ticks; + } + skinOverlays.put(tagID, overlay); + } + ClientCacheHandler.skinOverlays.put(player.getUniqueID(), skinOverlays); + } public static void clickSound() { Minecraft.getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation("gui.button.press"), 1.0F)); - } + } - private static EntityNPCInterface lastNpc; - public static EntityNPCInterface getLastNpc() { - return lastNpc; - } - public static void setLastNpc(EntityNPCInterface npc) { - lastNpc = npc; - } + private static EntityNPCInterface lastNpc; - public static void openGUI(EntityPlayer player, Object guiscreen) { - CustomNpcs.proxy.openGui(player, guiscreen); - } + public static EntityNPCInterface getLastNpc() { + return lastNpc; + } - public static void openFolder(File dir){ + public static void setLastNpc(EntityNPCInterface npc) { + lastNpc = npc; + } + + public static void openGUI(EntityPlayer player, Object guiscreen) { + CustomNpcs.proxy.openGui(player, guiscreen); + } + + public static void openFolder(File dir) { if (dir == null || !dir.exists() || !dir.isDirectory()) { // Log an error or simply return if there's nothing to open return; @@ -87,158 +92,148 @@ public class NoppesUtil { String s = dir.getAbsolutePath(); - if (Util.getOSType() == Util.EnumOS.OSX) - { - try - { + if (Util.getOSType() == Util.EnumOS.OSX) { + try { //logger.info(s); - Runtime.getRuntime().exec(new String[] {"/usr/bin/open", s}); + Runtime.getRuntime().exec(new String[]{"/usr/bin/open", s}); return; - } - catch (IOException ioexception1) - { + } catch (IOException ioexception1) { //logger.error("Couldn\'t open file", ioexception1); } - } - else if (Util.getOSType() == Util.EnumOS.WINDOWS) - { - String s1 = String.format("cmd.exe /C start \"Open file\" \"%s\"", new Object[] {s}); + } else if (Util.getOSType() == Util.EnumOS.WINDOWS) { + String s1 = String.format("cmd.exe /C start \"Open file\" \"%s\"", new Object[]{s}); - try - { + try { Runtime.getRuntime().exec(s1); return; - } - catch (IOException ioexception) - { + } catch (IOException ioexception) { //logger.error("Couldn\'t open file", ioexception); } } boolean flag = false; - try - { + try { Class oclass = Class.forName("java.awt.Desktop"); - Object object = oclass.getMethod("getDesktop", new Class[0]).invoke((Object)null, new Object[0]); - oclass.getMethod("browse", new Class[] {URI.class}).invoke(object, new Object[] {dir.toURI()}); - } - catch (Throwable throwable) - { + Object object = oclass.getMethod("getDesktop", new Class[0]).invoke((Object) null, new Object[0]); + oclass.getMethod("browse", new Class[]{URI.class}).invoke(object, new Object[]{dir.toURI()}); + } catch (Throwable throwable) { //logger.error("Couldn\'t open link", throwable); flag = true; } - if (flag) - { + if (flag) { //logger.info("Opening via system class!"); Sys.openURL("file://" + s); } - } + } - public static void setScrollList(ByteBuf buffer) { - GuiScreen gui = Minecraft.getMinecraft().currentScreen; - if(gui instanceof GuiNPCInterface && ((GuiNPCInterface)gui).hasSubGui()) - gui = ((GuiNPCInterface)gui).getSubGui(); - if(gui == null || !(gui instanceof IScrollData)) - return; - Vector data = new Vector(); - String line; + public static void setScrollList(ByteBuf buffer) { + GuiScreen gui = Minecraft.getMinecraft().currentScreen; + if (gui instanceof GuiNPCInterface && ((GuiNPCInterface) gui).hasSubGui()) + gui = ((GuiNPCInterface) gui).getSubGui(); + if (gui == null || !(gui instanceof IScrollData)) + return; + Vector data = new Vector(); + String line; EnumScrollData dataType = EnumScrollData.values()[buffer.readInt()]; - try { - int size = buffer.readInt(); - for(int i = 0; i < size; i++){ - data.add(ByteBufUtils.readString(buffer)); - } - } catch (Exception e) { + try { + int size = buffer.readInt(); + for (int i = 0; i < size; i++) { + data.add(ByteBufUtils.readString(buffer)); + } + } catch (Exception e) { - } + } - ((IScrollData)gui).setData(data,null, dataType); - } + ((IScrollData) gui).setData(data, null, dataType); + } - private static HashMap data = new HashMap(); - public static void setScrollData(ByteBuf buffer) { - GuiScreen gui = Minecraft.getMinecraft().currentScreen; - if(gui == null) - return; + private static HashMap data = new HashMap(); + + public static void setScrollData(ByteBuf buffer) { + GuiScreen gui = Minecraft.getMinecraft().currentScreen; + if (gui == null) + return; EnumScrollData dataType = EnumScrollData.values()[buffer.readInt()]; - try { - int size = buffer.readInt(); - for(int i = 0; i < size; i++){ - int id = buffer.readInt(); - String name = ByteBufUtils.readString(buffer); - data.put(name, id); - } - } catch (Exception e) { - } - if(gui instanceof GuiNPCInterface && ((GuiNPCInterface)gui).hasSubGui()){ - gui = (GuiScreen) ((GuiNPCInterface)gui).getSubGui(); - } - if(gui instanceof GuiContainerNPCInterface && ((GuiContainerNPCInterface)gui).hasSubGui()){ - gui = (GuiScreen) ((GuiContainerNPCInterface)gui).getSubGui(); - } - if(gui instanceof IScrollData) - ((IScrollData)gui).setData(new Vector(data.keySet()), data, dataType); - data = new HashMap(); - } + try { + int size = buffer.readInt(); + for (int i = 0; i < size; i++) { + int id = buffer.readInt(); + String name = ByteBufUtils.readString(buffer); + data.put(name, id); + } + } catch (Exception e) { + } + if (gui instanceof GuiNPCInterface && ((GuiNPCInterface) gui).hasSubGui()) { + gui = (GuiScreen) ((GuiNPCInterface) gui).getSubGui(); + } + if (gui instanceof GuiContainerNPCInterface && ((GuiContainerNPCInterface) gui).hasSubGui()) { + gui = (GuiScreen) ((GuiContainerNPCInterface) gui).getSubGui(); + } + if (gui instanceof IScrollData) + ((IScrollData) gui).setData(new Vector(data.keySet()), data, dataType); + data = new HashMap(); + } - public static void guiQuestCompletion(EntityPlayer player, NBTTagCompound read) { - Quest quest = new Quest(); - quest.readNBT(read); - if (!quest.completeText.isEmpty()) { - NoppesUtil.openGUI(player, new GuiQuestCompletion(quest)); - } - } + public static void guiQuestCompletion(EntityPlayer player, NBTTagCompound read) { + Quest quest = new Quest(); + quest.readNBT(read); + if (!quest.completeText.isEmpty()) { + NoppesUtil.openGUI(player, new GuiQuestCompletion(quest)); + } + } - public static void openDialog(NBTTagCompound compound, EntityNPCInterface npc, EntityPlayer player){ - Dialog dialog = new Dialog(); - dialog.readNBT(compound); - GuiScreen gui = Minecraft.getMinecraft().currentScreen; - if(gui == null || !(gui instanceof GuiDialogInteract)) - CustomNpcs.proxy.openGui(player, new GuiDialogInteract(npc, dialog)); - else{ - GuiDialogInteract dia = (GuiDialogInteract) gui; - dia.appendDialog(dialog); - } - } - public static void saveRedstoneBlock(EntityPlayer player, NBTTagCompound compound){ - int x = compound.getInteger("x"); - int y = compound.getInteger("y"); - int z = compound.getInteger("z"); + public static void openDialog(NBTTagCompound compound, EntityNPCInterface npc, EntityPlayer player) { + Dialog dialog = new Dialog(); + dialog.readNBT(compound); + GuiScreen gui = Minecraft.getMinecraft().currentScreen; + if (gui == null || !(gui instanceof GuiDialogInteract)) + CustomNpcs.proxy.openGui(player, new GuiDialogInteract(npc, dialog)); + else { + GuiDialogInteract dia = (GuiDialogInteract) gui; + dia.appendDialog(dialog); + } + } - TileEntity tile = player.worldObj.getTileEntity(x, y, z); - tile.readFromNBT(compound); + public static void saveRedstoneBlock(EntityPlayer player, NBTTagCompound compound) { + int x = compound.getInteger("x"); + int y = compound.getInteger("y"); + int z = compound.getInteger("z"); - CustomNpcs.proxy.openGui(x, y, z, EnumGuiType.RedstoneBlock, player); - } - public static void saveWayPointBlock(EntityPlayer player, NBTTagCompound compound){ - int x = compound.getInteger("x"); - int y = compound.getInteger("y"); - int z = compound.getInteger("z"); + TileEntity tile = player.worldObj.getTileEntity(x, y, z); + tile.readFromNBT(compound); - TileEntity tile = player.worldObj.getTileEntity(x, y, z); - tile.readFromNBT(compound); + CustomNpcs.proxy.openGui(x, y, z, EnumGuiType.RedstoneBlock, player); + } - CustomNpcs.proxy.openGui(x, y, z, EnumGuiType.Waypoint, player); - } + public static void saveWayPointBlock(EntityPlayer player, NBTTagCompound compound) { + int x = compound.getInteger("x"); + int y = compound.getInteger("y"); + int z = compound.getInteger("z"); - public static void isGUIOpen(boolean isGUIOpen) { + TileEntity tile = player.worldObj.getTileEntity(x, y, z); + tile.readFromNBT(compound); + + CustomNpcs.proxy.openGui(x, y, z, EnumGuiType.Waypoint, player); + } + + public static void isGUIOpen(boolean isGUIOpen) { PacketClient.sendClient(new IsGuiOpenInform(isGUIOpen)); - } + } /** * Handles the incoming large packet with full player data. * The packet writes: - * - player name (String) - * - questCategories, questActive, questFinished (maps) - * - dialogCategories, dialogRead (maps) - * - transportCategories, transportLocations (maps) - * - bankData, factionData (maps) - * + * - player name (String) + * - questCategories, questActive, questFinished (maps) + * - dialogCategories, dialogRead (maps) + * - transportCategories, transportLocations (maps) + * - bankData, factionData (maps) + *

* The existing PlayerDataController functions are used on the server side; * here we simply update the active SubGuiPlayerDataNew if present. */ @@ -257,14 +252,14 @@ public class NoppesUtil { magicData.readToNBT(ByteBufUtils.readNBT(data)); GuiScreen gui = Minecraft.getMinecraft().currentScreen; - if(gui == null) + if (gui == null) return; - if(gui instanceof GuiNPCInterface && ((GuiNPCInterface)gui).hasSubGui()){ - gui = (GuiScreen) ((GuiNPCInterface)gui).getSubGui(); + if (gui instanceof GuiNPCInterface && ((GuiNPCInterface) gui).hasSubGui()) { + gui = (GuiScreen) ((GuiNPCInterface) gui).getSubGui(); } - if(gui instanceof GuiContainerNPCInterface && ((GuiContainerNPCInterface)gui).hasSubGui()){ - gui = (GuiScreen) ((GuiContainerNPCInterface)gui).getSubGui(); + if (gui instanceof GuiContainerNPCInterface && ((GuiContainerNPCInterface) gui).hasSubGui()) { + gui = (GuiScreen) ((GuiContainerNPCInterface) gui).getSubGui(); } if (gui instanceof IPlayerDataInfo) { IPlayerDataInfo info = (IPlayerDataInfo) gui; diff --git a/src/main/java/noppes/npcs/client/RenderChatMessages.java b/src/main/java/noppes/npcs/client/RenderChatMessages.java index 3d3b0355f..b1ac5f0dc 100644 --- a/src/main/java/noppes/npcs/client/RenderChatMessages.java +++ b/src/main/java/noppes/npcs/client/RenderChatMessages.java @@ -15,46 +15,46 @@ import org.lwjgl.opengl.GL11; import java.util.Map; import java.util.TreeMap; -public class RenderChatMessages implements IChatMessages{ - private Map messages = new TreeMap(); +public class RenderChatMessages implements IChatMessages { + private Map messages = new TreeMap(); - private int boxLength = 46; - private float scale = 0.5f; + private int boxLength = 46; + private float scale = 0.5f; - private String lastMessage = ""; - private long lastMessageTime = 0; + private String lastMessage = ""; + private long lastMessageTime = 0; - @Override - public void addMessage(String message, EntityNPCInterface npc){ - if(!ConfigClient.EnableChatBubbles) - return; - long time = System.currentTimeMillis(); - if(message.equals(lastMessage) && lastMessageTime + 5000 > time){ - return; - } - Map messages = new TreeMap(this.messages); - messages.put(time, new TextBlockClient(message, (int) (boxLength * 4), true, Minecraft.getMinecraft().thePlayer, npc)); + @Override + public void addMessage(String message, EntityNPCInterface npc) { + if (!ConfigClient.EnableChatBubbles) + return; + long time = System.currentTimeMillis(); + if (message.equals(lastMessage) && lastMessageTime + 5000 > time) { + return; + } + Map messages = new TreeMap(this.messages); + messages.put(time, new TextBlockClient(message, (int) (boxLength * 4), true, Minecraft.getMinecraft().thePlayer, npc)); - if(messages.size() > 3){ - messages.remove(messages.keySet().iterator().next()); - } - this.messages = messages; - lastMessage = message; - lastMessageTime = time; - } + if (messages.size() > 3) { + messages.remove(messages.keySet().iterator().next()); + } + this.messages = messages; + lastMessage = message; + lastMessageTime = time; + } @Override public void renderMessages(double par3, double par5, double par7, float scale, boolean inRange) { - Map messages = getMessages(); - if(messages.isEmpty()) + Map messages = getMessages(); + if (messages.isEmpty()) return; - if(inRange) + if (inRange) render(par3, par5, par7, scale, false); render(par3, par5, par7, scale, true); } - public void render(double par3, double par5, double par7, float textscale, boolean depth){ - FontRenderer font = Minecraft.getMinecraft().fontRenderer; + public void render(double par3, double par5, double par7, float textscale, boolean depth) { + FontRenderer font = Minecraft.getMinecraft().fontRenderer; float var13 = 1.6F; float var14 = 0.016666668F * var13; GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS); @@ -64,13 +64,13 @@ public class RenderChatMessages implements IChatMessages{ size += block.lines.size(); int fontHeight; - if(ConfigClient.ChatBubblesFontType) + if (ConfigClient.ChatBubblesFontType) fontHeight = ClientProxy.Font.height(); else fontHeight = font.FONT_HEIGHT; int textYSize = (int) (size * fontHeight * scale); - GL11.glTranslatef((float)par3 + 0.0F, (float)par5 + textYSize * textscale * var14, (float)par7); + GL11.glTranslatef((float) par3 + 0.0F, (float) par5 + textYSize * textscale * var14, (float) par7); GL11.glScalef(textscale, textscale, textscale); GL11.glNormal3f(0.0F, 1.0F, 0.0F); GL11.glRotatef(-RenderManager.instance.playerViewY, 0.0F, 1F, 0.0F); @@ -123,10 +123,10 @@ public class RenderChatMessages implements IChatMessages{ GL11.glScalef(scale, scale, scale); int index = 0; - for(TextBlockClient block : messages.values()){ - for(IChatComponent chat : block.lines){ + for (TextBlockClient block : messages.values()) { + for (IChatComponent chat : block.lines) { String message = chat.getFormattedText(); - if(ConfigClient.ChatBubblesFontType) + if (ConfigClient.ChatBubblesFontType) ClientProxy.Font.drawString(message, -ClientProxy.Font.width(message) / 2, index * fontHeight, black); else font.drawString(message, -font.getStringWidth(message) / 2, index * fontHeight, black); @@ -144,48 +144,45 @@ public class RenderChatMessages implements IChatMessages{ GL11.glPopAttrib(); } - private void drawRect(int par0, int par1, int par2, int par3, int par4, double par5) - { + private void drawRect(int par0, int par1, int par2, int par3, int par4, double par5) { int j1; - if (par0 < par2) - { + if (par0 < par2) { j1 = par0; par0 = par2; par2 = j1; } - if (par1 < par3) - { + if (par1 < par3) { j1 = par1; par1 = par3; par3 = j1; } - float f = (float)(par4 >> 24 & 255) / 255.0F; - float f1 = (float)(par4 >> 16 & 255) / 255.0F; - float f2 = (float)(par4 >> 8 & 255) / 255.0F; - float f3 = (float)(par4 & 255) / 255.0F; + float f = (float) (par4 >> 24 & 255) / 255.0F; + float f1 = (float) (par4 >> 16 & 255) / 255.0F; + float f2 = (float) (par4 >> 8 & 255) / 255.0F; + float f3 = (float) (par4 & 255) / 255.0F; Tessellator tessellator = Tessellator.instance; GL11.glColor4f(f1, f2, f3, f); tessellator.startDrawingQuads(); - tessellator.addVertex((double)par0, (double)par3, par5); - tessellator.addVertex((double)par2, (double)par3, par5); - tessellator.addVertex((double)par2, (double)par1, par5); - tessellator.addVertex((double)par0, (double)par1, par5); + tessellator.addVertex((double) par0, (double) par3, par5); + tessellator.addVertex((double) par2, (double) par3, par5); + tessellator.addVertex((double) par2, (double) par1, par5); + tessellator.addVertex((double) par0, (double) par1, par5); tessellator.draw(); } - private Map getMessages(){ - Map messages = new TreeMap(); - long time = System.currentTimeMillis(); - for(long timestamp : this.messages.keySet()){ - if(time > timestamp + 10000) - continue; - TextBlockClient message = this.messages.get(timestamp); - messages.put(timestamp, message); - } - this.messages = messages; - return messages; - } + private Map getMessages() { + Map messages = new TreeMap(); + long time = System.currentTimeMillis(); + for (long timestamp : this.messages.keySet()) { + if (time > timestamp + 10000) + continue; + TextBlockClient message = this.messages.get(timestamp); + messages.put(timestamp, message); + } + this.messages = messages; + return messages; + } } diff --git a/src/main/java/noppes/npcs/client/TextBlockClient.java b/src/main/java/noppes/npcs/client/TextBlockClient.java index aa7c3a02f..05c4e8126 100644 --- a/src/main/java/noppes/npcs/client/TextBlockClient.java +++ b/src/main/java/noppes/npcs/client/TextBlockClient.java @@ -9,76 +9,75 @@ import noppes.npcs.NoppesStringUtils; import noppes.npcs.TextBlock; import noppes.npcs.controllers.data.Dialog; -public class TextBlockClient extends TextBlock{ - private ChatStyle style; - public int color = 0xe0e0e0; - public int titleColor = 0xe0e0e0; - public int titlePos = 0; - private String name; - private ICommandSender sender; +public class TextBlockClient extends TextBlock { + private ChatStyle style; + public int color = 0xe0e0e0; + public int titleColor = 0xe0e0e0; + public int titlePos = 0; + private String name; + private ICommandSender sender; - public TextBlockClient(ICommandSender sender, Dialog dialog, Object... obs) { - this(dialog.text, dialog.textWidth, false, obs); - this.color = dialog.color; - this.titleColor = dialog.titleColor; - this.titlePos = dialog.titlePos; - this.sender = sender; - } + public TextBlockClient(ICommandSender sender, Dialog dialog, Object... obs) { + this(dialog.text, dialog.textWidth, false, obs); + this.color = dialog.color; + this.titleColor = dialog.titleColor; + this.titlePos = dialog.titlePos; + this.sender = sender; + } - public TextBlockClient(String name, String text, int lineWidth, int color, Object... obs) { - this(text, lineWidth, false, obs); - this.color = color; - this.name = name; - } - - public String getName(){ - if(sender != null) - return sender.getCommandSenderName(); - return name; - } - - public TextBlockClient(String text, int lineWidth, boolean mcFont, Object... obs){ - style = new ChatStyle(); - text = NoppesStringUtils.formatText(text, obs); - - String line = ""; - text = text.replace("\n", " \n "); - text = text.replace("\r", " \r "); - String[] words = text.split(" "); - - FontRenderer font = Minecraft.getMinecraft().fontRenderer; - for(String word : words){ - if(word.isEmpty()) - continue; - if(word.length() == 1){ - char c = word.charAt(0); - if(c == '\r' || c == '\n'){ - addLine(line); - line = ""; - continue; - } - } - String newLine; - if(line.isEmpty()) - newLine = word; - else - newLine = line + " " + word; + public TextBlockClient(String name, String text, int lineWidth, int color, Object... obs) { + this(text, lineWidth, false, obs); + this.color = color; + this.name = name; + } - if((mcFont?font.getStringWidth(newLine): ClientProxy.Font.width(newLine)) > lineWidth){ - addLine(line); - line = word.trim(); - } - else{ - line = newLine; - } - } - if(!line.isEmpty()) - addLine(line); - } + public String getName() { + if (sender != null) + return sender.getCommandSenderName(); + return name; + } - private void addLine(String text){ - ChatComponentText line = new ChatComponentText(text); - line.setChatStyle(style); - lines.add(line); - } + public TextBlockClient(String text, int lineWidth, boolean mcFont, Object... obs) { + style = new ChatStyle(); + text = NoppesStringUtils.formatText(text, obs); + + String line = ""; + text = text.replace("\n", " \n "); + text = text.replace("\r", " \r "); + String[] words = text.split(" "); + + FontRenderer font = Minecraft.getMinecraft().fontRenderer; + for (String word : words) { + if (word.isEmpty()) + continue; + if (word.length() == 1) { + char c = word.charAt(0); + if (c == '\r' || c == '\n') { + addLine(line); + line = ""; + continue; + } + } + String newLine; + if (line.isEmpty()) + newLine = word; + else + newLine = line + " " + word; + + if ((mcFont ? font.getStringWidth(newLine) : ClientProxy.Font.width(newLine)) > lineWidth) { + addLine(line); + line = word.trim(); + } else { + line = newLine; + } + } + if (!line.isEmpty()) + addLine(line); + } + + private void addLine(String text) { + ChatComponentText line = new ChatComponentText(text); + line.setChatStyle(style); + lines.add(line); + } } diff --git a/src/main/java/noppes/npcs/client/TranslateUtil.java b/src/main/java/noppes/npcs/client/TranslateUtil.java index 88b23ca6e..1383fe39d 100644 --- a/src/main/java/noppes/npcs/client/TranslateUtil.java +++ b/src/main/java/noppes/npcs/client/TranslateUtil.java @@ -14,40 +14,40 @@ import java.net.URL; import java.net.URLEncoder; public class TranslateUtil { - private static final String TranslateUrl = "http://translate.google.com/translate_a/t?client=t&text=%s&hl=en&sl=%s&tl=%s&ie=UTF-8&oe=UTF-8&multires=1&otf=1&pc=1&trs=1&ssel=3&tsel=6&sc=1"; - private static final String AudioUrl = "http://translate.google.com/translate_tts?q=%s&tl=%s"; + private static final String TranslateUrl = "http://translate.google.com/translate_a/t?client=t&text=%s&hl=en&sl=%s&tl=%s&ie=UTF-8&oe=UTF-8&multires=1&otf=1&pc=1&trs=1&ssel=3&tsel=6&sc=1"; + private static final String AudioUrl = "http://translate.google.com/translate_tts?q=%s&tl=%s"; - public static String Translate(String text){ + public static String Translate(String text) { - try { - String urlStr = String.format(TranslateUrl, URLEncoder.encode(text,"utf8"), "auto", "nl"); - URL url = new URL(urlStr); - HttpURLConnection connection = (HttpURLConnection) url.openConnection(); + try { + String urlStr = String.format(TranslateUrl, URLEncoder.encode(text, "utf8"), "auto", "nl"); + URL url = new URL(urlStr); + HttpURLConnection connection = (HttpURLConnection) url.openConnection(); - connection.setDoOutput(true); - connection.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows; U; Windows NT 6.1; en-GB; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13 (.NET CLR 3.5.30729)"); - connection.setRequestProperty("X-HTTP-Method-Override", "GET"); - //connection.setRequestProperty("referer", "accounterlive.com"); - connection.connect(); - BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream())); - String line = reader.readLine(); - reader.close(); - connection.disconnect(); - if(line != null){ - String parsed = parseJson(line); - if(parsed != null) - return parsed; - } - } catch (UnsupportedEncodingException e) { - e.printStackTrace(); - } catch (MalformedURLException e) { - e.printStackTrace(); - } catch (IOException e) { - e.printStackTrace(); - } + connection.setDoOutput(true); + connection.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows; U; Windows NT 6.1; en-GB; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13 (.NET CLR 3.5.30729)"); + connection.setRequestProperty("X-HTTP-Method-Override", "GET"); + //connection.setRequestProperty("referer", "accounterlive.com"); + connection.connect(); + BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream())); + String line = reader.readLine(); + reader.close(); + connection.disconnect(); + if (line != null) { + String parsed = parseJson(line); + if (parsed != null) + return parsed; + } + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } catch (MalformedURLException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } - return text; - } + return text; + } // public static void PlayAudio(String text){ // try { @@ -80,16 +80,16 @@ public class TranslateUtil { // } // } - private static String parseJson(String line) { - JsonParser parser = new JsonParser(); - JsonElement element = parser.parse(line); - while(element.isJsonArray()){ - JsonArray array = (JsonArray) element; - if(array.size() == 0) - return null; - element = array.get(0); - } - // System.out.println(element.getAsString()); - return element.getAsString(); - } + private static String parseJson(String line) { + JsonParser parser = new JsonParser(); + JsonElement element = parser.parse(line); + while (element.isJsonArray()) { + JsonArray array = (JsonArray) element; + if (array.size() == 0) + return null; + element = array.get(0); + } + // System.out.println(element.getAsString()); + return element.getAsString(); + } } diff --git a/src/main/java/noppes/npcs/client/VersionChecker.java b/src/main/java/noppes/npcs/client/VersionChecker.java index 19ec426f6..6164f336d 100644 --- a/src/main/java/noppes/npcs/client/VersionChecker.java +++ b/src/main/java/noppes/npcs/client/VersionChecker.java @@ -6,32 +6,33 @@ import net.minecraft.event.ClickEvent; import net.minecraft.event.ClickEvent.Action; import net.minecraft.util.ChatComponentTranslation; -public class VersionChecker extends Thread{ - private int revision = 15; - public VersionChecker(){ - - } - public void run(){ - String name = '\u00A7'+ "cCustomNPC+" + '\u00A7' + "f"; - String link = '\u00A7'+"9"+'\u00A7' + "nClick here"; - String text = name +" installed. For more info " + link; - +public class VersionChecker extends Thread { + private int revision = 15; + + public VersionChecker() { + + } + + public void run() { + String name = '\u00A7' + "cCustomNPC+" + '\u00A7' + "f"; + String link = '\u00A7' + "9" + '\u00A7' + "nClick here"; + String text = name + " installed. For more info " + link; + EntityPlayer player; - try{ - player = Minecraft.getMinecraft().thePlayer; - } - catch(NoSuchMethodError e){ - return; - } - while((player = Minecraft.getMinecraft().thePlayer) == null){ - try { - Thread.sleep(2000); - } catch (InterruptedException e) { - e.printStackTrace(); - } + try { + player = Minecraft.getMinecraft().thePlayer; + } catch (NoSuchMethodError e) { + return; + } + while ((player = Minecraft.getMinecraft().thePlayer) == null) { + try { + Thread.sleep(2000); + } catch (InterruptedException e) { + e.printStackTrace(); + } } ChatComponentTranslation message = new ChatComponentTranslation(text); message.getChatStyle().setChatClickEvent(new ClickEvent(Action.OPEN_URL, "https://www.curseforge.com/minecraft/mc-mods/customnpc-plus")); player.addChatMessage(message); - } + } } diff --git a/src/main/java/noppes/npcs/client/controllers/ClientCloneController.java b/src/main/java/noppes/npcs/client/controllers/ClientCloneController.java index bfce34457..81f174170 100644 --- a/src/main/java/noppes/npcs/client/controllers/ClientCloneController.java +++ b/src/main/java/noppes/npcs/client/controllers/ClientCloneController.java @@ -10,46 +10,45 @@ import java.io.File; import java.util.HashSet; import java.util.UUID; -public class ClientCloneController extends ServerCloneController{ - public static ClientCloneController Instance; +public class ClientCloneController extends ServerCloneController { + public static ClientCloneController Instance; - @Override - public File getDir(){ - File dir = new File(CustomNpcs.Dir,"clones"); - if(!dir.exists()) - dir.mkdir(); - return dir; - } + @Override + public File getDir() { + File dir = new File(CustomNpcs.Dir, "clones"); + if (!dir.exists()) + dir.mkdir(); + return dir; + } - @Override - public boolean addToTagMap(NBTTagCompound nbttagcompound, String name, int tab){ - HashSet tagUUIDs = new HashSet(); - if(nbttagcompound.hasKey("TagUUIDs")){ - NBTTagList nbtTagList = nbttagcompound.getTagList("TagUUIDs",8); - for (int i = 0; i < nbtTagList.tagCount(); i++) { - tagUUIDs.add(UUID.fromString(nbtTagList.getStringTagAt(i))); - } - } + @Override + public boolean addToTagMap(NBTTagCompound nbttagcompound, String name, int tab) { + HashSet tagUUIDs = new HashSet(); + if (nbttagcompound.hasKey("TagUUIDs")) { + NBTTagList nbtTagList = nbttagcompound.getTagList("TagUUIDs", 8); + for (int i = 0; i < nbtTagList.tagCount(); i++) { + tagUUIDs.add(UUID.fromString(nbtTagList.getStringTagAt(i))); + } + } TagMap tagMap = ClientTagMapController.Instance.getTagMap(tab); - if(!tagUUIDs.isEmpty()){ + if (!tagUUIDs.isEmpty()) { tagMap.putClone(name, tagUUIDs); - } - else { + } else { tagMap.removeClone(name); } ClientTagMapController.Instance.saveTagMap(tagMap); return true; } - @Override - public boolean removeFromTagMap(String name, int tab){ - TagMap tagMap = ClientTagMapController.Instance.getTagMap(tab); - if(tagMap.removeClone(name)){ - ClientTagMapController.Instance.saveTagMap(tagMap); - return true; - } - return false; - } + @Override + public boolean removeFromTagMap(String name, int tab) { + TagMap tagMap = ClientTagMapController.Instance.getTagMap(tab); + if (tagMap.removeClone(name)) { + ClientTagMapController.Instance.saveTagMap(tagMap); + return true; + } + return false; + } } diff --git a/src/main/java/noppes/npcs/client/controllers/ClientTagMapController.java b/src/main/java/noppes/npcs/client/controllers/ClientTagMapController.java index 9a2083745..a7954f5c5 100644 --- a/src/main/java/noppes/npcs/client/controllers/ClientTagMapController.java +++ b/src/main/java/noppes/npcs/client/controllers/ClientTagMapController.java @@ -6,13 +6,13 @@ import noppes.npcs.controllers.ServerTagMapController; import java.io.File; public class ClientTagMapController extends ServerTagMapController { - public static ClientTagMapController Instance; + public static ClientTagMapController Instance; - @Override - public File getDir(){ - File dir = new File(CustomNpcs.Dir,"clones"); - if(!dir.exists()) - dir.mkdir(); - return dir; - } + @Override + public File getDir() { + File dir = new File(CustomNpcs.Dir, "clones"); + if (!dir.exists()) + dir.mkdir(); + return dir; + } } diff --git a/src/main/java/noppes/npcs/client/controllers/MusicController.java b/src/main/java/noppes/npcs/client/controllers/MusicController.java index 779aab1ec..e3a2213b8 100644 --- a/src/main/java/noppes/npcs/client/controllers/MusicController.java +++ b/src/main/java/noppes/npcs/client/controllers/MusicController.java @@ -11,7 +11,7 @@ import java.util.HashSet; import java.util.Map; public class MusicController { - public static MusicController Instance; + public static MusicController Instance; private final HashMap sounds = new HashMap<>(); private int playDelay; public ScriptClientSound playingSound; @@ -19,9 +19,9 @@ public class MusicController { private Entity entity; private int offRange; - public MusicController(){ - Instance = this; - } + public MusicController() { + Instance = this; + } public void onUpdate() { if (this.playingSound != null @@ -54,33 +54,34 @@ public class MusicController { } } - public void stopMusic(){ + public void stopMusic() { SoundHandler soundHandler = Minecraft.getMinecraft().getSoundHandler(); if (soundHandler != null) { try { soundHandler.stopSounds(); - } catch (Exception ignored) {} + } catch (Exception ignored) { + } } if (this.playingSound != null) { this.playingSound.stopSound(); this.playingSound = null; } - } + } - public void playMusicJukebox(String music, Entity entity, int offRange){ + public void playMusicJukebox(String music, Entity entity, int offRange) { if (this.playDelay > 0) { return; } this.playDelay = 20; if (this.isPlaying(music)) { - return; - } + return; + } this.stopMusic(); ScriptClientSound clientSound = new ScriptClientSound(music); clientSound.setEntity(entity); - clientSound.setVolume(Math.max(1, offRange/16.0F)); + clientSound.setVolume(Math.max(1, offRange / 16.0F)); clientSound.setAttenuationType(ISound.AttenuationType.LINEAR); clientSound.setRepeat(true); this.playingSound = clientSound; @@ -94,9 +95,9 @@ public class MusicController { } catch (Exception e) { this.stopAllSounds(); } - } + } - public void playMusicBackground(String music, Entity entity, int offRange) { + public void playMusicBackground(String music, Entity entity, int offRange) { if (this.playDelay > 0) { return; } @@ -121,7 +122,7 @@ public class MusicController { } catch (Exception e) { this.stopAllSounds(); } - } + } public void playSound(String music, float x, float y, float z) { if (this.playDelay > 0) { @@ -145,7 +146,7 @@ public class MusicController { this.sounds.put(clientSound.sound, clientSound); } - public boolean isPlaying(String music) { + public boolean isPlaying(String music) { if (this.sounds.containsKey(music)) return true; if (this.playingSound != null && this.playingSound.sound.equals(music)) { @@ -157,7 +158,7 @@ public class MusicController { } else { return false; } - } + } public boolean isPlaying() { return this.playingSound != null; diff --git a/src/main/java/noppes/npcs/client/controllers/Preset.java b/src/main/java/noppes/npcs/client/controllers/Preset.java index 97c801ffa..015eb9d99 100644 --- a/src/main/java/noppes/npcs/client/controllers/Preset.java +++ b/src/main/java/noppes/npcs/client/controllers/Preset.java @@ -7,181 +7,181 @@ import noppes.npcs.entity.data.ModelPartData; import java.util.HashMap; public class Preset { - - public ModelData data = new ModelData(); - public String name; - public NBTTagCompound writeToNBT(){ - NBTTagCompound compound = new NBTTagCompound(); - compound.setString("PresetName", name); - compound.setTag("PresetData", data.writeToNBT()); - return compound; - } - - public void readFromNBT(NBTTagCompound compound){ - name = compound.getString("PresetName"); - data.readFromNBT(compound.getCompoundTag("PresetData")); - } - - public static void FillDefault(HashMap presets){ - ModelData data = new ModelData(); - Preset preset = new Preset(); - preset.name = "Elf Male"; - preset.data = data; - data.modelScale.legs.setScale(0.85f,1.15f); - data.modelScale.arms.setScale(0.85f,1.15f); - data.modelScale.body.setScale(0.85f,1.15f); - data.modelScale.head.setScale(0.85f,0.95f); - presets.put("elf male", preset); - - data = new ModelData(); - preset = new Preset(); - preset.name = "Elf Female"; - preset.data = data; - data.breasts = 2; - data.modelScale.legs.setScale(0.8f,1.05f); - data.modelScale.arms.setScale(0.8f,1.05f); - data.modelScale.body.setScale(0.8f,1.05f); - data.modelScale.head.setScale(0.8f,0.85f); - presets.put("elf female", preset); + public ModelData data = new ModelData(); + public String name; - data = new ModelData(); - preset = new Preset(); - preset.name = "Dwarf Male"; - preset.data = data; - data.modelScale.legs.setScale(1.1f,0.7f, 0.9f); - data.modelScale.arms.setScale(0.9f,0.7f); - data.modelScale.body.setScale(1.2f, 0.7f, 1.5f); - data.modelScale.head.setScale(0.85f,0.85f); - presets.put("dwarf male", preset); + public NBTTagCompound writeToNBT() { + NBTTagCompound compound = new NBTTagCompound(); + compound.setString("PresetName", name); + compound.setTag("PresetData", data.writeToNBT()); + return compound; + } - data = new ModelData(); - preset = new Preset(); - preset.name = "Dwarf Female"; - preset.data = data; - data.breasts = 2; - data.modelScale.legs.setScale(0.9f,0.65f); - data.modelScale.arms.setScale(0.9f,0.65f); - data.modelScale.body.setScale(1f, 0.65f, 1.1f); - data.modelScale.head.setScale(0.85f,0.85f); - presets.put("dwarf female", preset); + public void readFromNBT(NBTTagCompound compound) { + name = compound.getString("PresetName"); + data.readFromNBT(compound.getCompoundTag("PresetData")); + } - data = new ModelData(); - preset = new Preset(); - preset.name = "Orc Male"; - preset.data = data; - data.modelScale.legs.setScale(1.2f,1.05f); - data.modelScale.arms.setScale(1.2f,1.05f); - data.modelScale.body.setScale(1.4f, 1.1f, 1.5f); - data.modelScale.head.setScale(1.2f,1.1f); - presets.put("orc male", preset); + public static void FillDefault(HashMap presets) { + ModelData data = new ModelData(); + Preset preset = new Preset(); + preset.name = "Elf Male"; + preset.data = data; + data.modelScale.legs.setScale(0.85f, 1.15f); + data.modelScale.arms.setScale(0.85f, 1.15f); + data.modelScale.body.setScale(0.85f, 1.15f); + data.modelScale.head.setScale(0.85f, 0.95f); + presets.put("elf male", preset); - data = new ModelData(); - preset = new Preset(); - preset.name = "Orc Female"; - preset.data = data; - data.breasts = 2; - data.modelScale.legs.setScale(1.1f,1); - data.modelScale.arms.setScale(1.1f,1); - data.modelScale.body.setScale(1.1f, 1f, 1.25f); - presets.put("orc female", preset); + data = new ModelData(); + preset = new Preset(); + preset.name = "Elf Female"; + preset.data = data; + data.breasts = 2; + data.modelScale.legs.setScale(0.8f, 1.05f); + data.modelScale.arms.setScale(0.8f, 1.05f); + data.modelScale.body.setScale(0.8f, 1.05f); + data.modelScale.head.setScale(0.8f, 0.85f); + presets.put("elf female", preset); - data = new ModelData(); - preset = new Preset(); - preset.name = "Human Male"; - preset.data = data; - presets.put("human male", preset); + data = new ModelData(); + preset = new Preset(); + preset.name = "Dwarf Male"; + preset.data = data; + data.modelScale.legs.setScale(1.1f, 0.7f, 0.9f); + data.modelScale.arms.setScale(0.9f, 0.7f); + data.modelScale.body.setScale(1.2f, 0.7f, 1.5f); + data.modelScale.head.setScale(0.85f, 0.85f); + presets.put("dwarf male", preset); - data = new ModelData(); - preset = new Preset(); - preset.name = "Human Female"; - preset.data = data; - data.breasts = 2; - data.modelScale.head.setScale(0.95f,0.95f); - data.modelScale.legs.setScale(0.92f,0.92f); - data.modelScale.arms.setScale(0.80f,0.92f); - data.modelScale.body.setScale(0.92f, 0.92f); - presets.put("human female", preset); + data = new ModelData(); + preset = new Preset(); + preset.name = "Dwarf Female"; + preset.data = data; + data.breasts = 2; + data.modelScale.legs.setScale(0.9f, 0.65f); + data.modelScale.arms.setScale(0.9f, 0.65f); + data.modelScale.body.setScale(1f, 0.65f, 1.1f); + data.modelScale.head.setScale(0.85f, 0.85f); + presets.put("dwarf female", preset); - data = new ModelData(); - preset = new Preset(); - preset.name = "Cat Male"; - preset.data = data; - ModelPartData ears = data.getOrCreatePart("ears"); - ears.setTexture("ears/type1", 0); - ears.color = 0xD9A64E; - ModelPartData snout = data.getOrCreatePart("snout"); - snout.setTexture("snout/small1", 0); - snout.color = 0xD9A64E; - ModelPartData tail = data.getOrCreatePart("tail"); - tail.setTexture("tail/tail1", 0); - tail.color = 0xD9A64E; - presets.put("cat male", preset); + data = new ModelData(); + preset = new Preset(); + preset.name = "Orc Male"; + preset.data = data; + data.modelScale.legs.setScale(1.2f, 1.05f); + data.modelScale.arms.setScale(1.2f, 1.05f); + data.modelScale.body.setScale(1.4f, 1.1f, 1.5f); + data.modelScale.head.setScale(1.2f, 1.1f); + presets.put("orc male", preset); - data = new ModelData(); - preset = new Preset(); - preset.name = "Cat Female"; - preset.data = data; - ears = data.getOrCreatePart("ears"); - ears.setTexture("ears/type1", 0); - ears.color = 0xD9A64E; - snout = data.getOrCreatePart("snout"); - snout.setTexture("snout/small1", 0); - snout.color = 0xD9A64E; - tail = data.getOrCreatePart("tail"); - tail.setTexture("tail/tail1", 0); - tail.color = 0xD9A64E; - data.breasts = 2; - data.modelScale.head.setScale(0.95f,0.95f); - data.modelScale.legs.setScale(0.92f,0.92f); - data.modelScale.arms.setScale(0.80f,0.92f); - data.modelScale.body.setScale(0.92f, 0.92f); - presets.put("cat female", preset); + data = new ModelData(); + preset = new Preset(); + preset.name = "Orc Female"; + preset.data = data; + data.breasts = 2; + data.modelScale.legs.setScale(1.1f, 1); + data.modelScale.arms.setScale(1.1f, 1); + data.modelScale.body.setScale(1.1f, 1f, 1.25f); + presets.put("orc female", preset); - data = new ModelData(); - preset = new Preset(); - preset.name = "Wolf Male"; - preset.data = data; - ears = data.getOrCreatePart("ears"); - ears.setTexture("ears/type1", 0); - ears.color = 0x5E5855; - snout = data.getOrCreatePart("snout"); - snout.setTexture("snout/large1", 2); - snout.color = 0x5E5855; - tail = data.getOrCreatePart("tail"); - tail.setTexture("tail/tail2", 0); - tail.color = 0x5E5855; - presets.put("wolf male", preset); + data = new ModelData(); + preset = new Preset(); + preset.name = "Human Male"; + preset.data = data; + presets.put("human male", preset); - data = new ModelData(); - preset = new Preset(); - preset.name = "Wolf Female"; - preset.data = data; - ears = data.getOrCreatePart("ears"); - ears.setTexture("ears/type1", 0); - ears.color = 0x5E5855; - snout = data.getOrCreatePart("snout"); - snout.setTexture("snout/large1", 2); - snout.color = 0x5E5855; - tail = data.getOrCreatePart("tail"); - tail.setTexture("tail/tail2", 0); - tail.color = 0x5E5855; - data.breasts = 2; - data.modelScale.head.setScale(0.95f,0.95f); - data.modelScale.legs.setScale(0.92f,0.92f); - data.modelScale.arms.setScale(0.80f,0.92f); - data.modelScale.body.setScale(0.92f, 0.92f); - presets.put("wolf female", preset); + data = new ModelData(); + preset = new Preset(); + preset.name = "Human Female"; + preset.data = data; + data.breasts = 2; + data.modelScale.head.setScale(0.95f, 0.95f); + data.modelScale.legs.setScale(0.92f, 0.92f); + data.modelScale.arms.setScale(0.80f, 0.92f); + data.modelScale.body.setScale(0.92f, 0.92f); + presets.put("human female", preset); - data = new ModelData(); - preset = new Preset(); - preset.name = "Enderchibi"; - preset.data = data; - data.modelScale.legs.setScale(0.65f,0.75f); - data.modelScale.arms.setScale(0.50f,1.45f); - ModelPartData part = data.getOrCreatePart("particles"); - part.setTexture("particle/type1", 1); - part.color = 0xFF0000; - presets.put("enderchibi", preset); - } + data = new ModelData(); + preset = new Preset(); + preset.name = "Cat Male"; + preset.data = data; + ModelPartData ears = data.getOrCreatePart("ears"); + ears.setTexture("ears/type1", 0); + ears.color = 0xD9A64E; + ModelPartData snout = data.getOrCreatePart("snout"); + snout.setTexture("snout/small1", 0); + snout.color = 0xD9A64E; + ModelPartData tail = data.getOrCreatePart("tail"); + tail.setTexture("tail/tail1", 0); + tail.color = 0xD9A64E; + presets.put("cat male", preset); + + data = new ModelData(); + preset = new Preset(); + preset.name = "Cat Female"; + preset.data = data; + ears = data.getOrCreatePart("ears"); + ears.setTexture("ears/type1", 0); + ears.color = 0xD9A64E; + snout = data.getOrCreatePart("snout"); + snout.setTexture("snout/small1", 0); + snout.color = 0xD9A64E; + tail = data.getOrCreatePart("tail"); + tail.setTexture("tail/tail1", 0); + tail.color = 0xD9A64E; + data.breasts = 2; + data.modelScale.head.setScale(0.95f, 0.95f); + data.modelScale.legs.setScale(0.92f, 0.92f); + data.modelScale.arms.setScale(0.80f, 0.92f); + data.modelScale.body.setScale(0.92f, 0.92f); + presets.put("cat female", preset); + + data = new ModelData(); + preset = new Preset(); + preset.name = "Wolf Male"; + preset.data = data; + ears = data.getOrCreatePart("ears"); + ears.setTexture("ears/type1", 0); + ears.color = 0x5E5855; + snout = data.getOrCreatePart("snout"); + snout.setTexture("snout/large1", 2); + snout.color = 0x5E5855; + tail = data.getOrCreatePart("tail"); + tail.setTexture("tail/tail2", 0); + tail.color = 0x5E5855; + presets.put("wolf male", preset); + + data = new ModelData(); + preset = new Preset(); + preset.name = "Wolf Female"; + preset.data = data; + ears = data.getOrCreatePart("ears"); + ears.setTexture("ears/type1", 0); + ears.color = 0x5E5855; + snout = data.getOrCreatePart("snout"); + snout.setTexture("snout/large1", 2); + snout.color = 0x5E5855; + tail = data.getOrCreatePart("tail"); + tail.setTexture("tail/tail2", 0); + tail.color = 0x5E5855; + data.breasts = 2; + data.modelScale.head.setScale(0.95f, 0.95f); + data.modelScale.legs.setScale(0.92f, 0.92f); + data.modelScale.arms.setScale(0.80f, 0.92f); + data.modelScale.body.setScale(0.92f, 0.92f); + presets.put("wolf female", preset); + + data = new ModelData(); + preset = new Preset(); + preset.name = "Enderchibi"; + preset.data = data; + data.modelScale.legs.setScale(0.65f, 0.75f); + data.modelScale.arms.setScale(0.50f, 1.45f); + ModelPartData part = data.getOrCreatePart("particles"); + part.setTexture("particle/type1", 1); + part.color = 0xFF0000; + presets.put("enderchibi", preset); + } } diff --git a/src/main/java/noppes/npcs/client/controllers/PresetController.java b/src/main/java/noppes/npcs/client/controllers/PresetController.java index 9c10caff7..2e9d8605e 100644 --- a/src/main/java/noppes/npcs/client/controllers/PresetController.java +++ b/src/main/java/noppes/npcs/client/controllers/PresetController.java @@ -12,112 +12,109 @@ import java.util.HashMap; public class PresetController { - public HashMap presets = new HashMap(); - - private File dir; - public static PresetController instance; - - public PresetController(File dir){ - instance = this; - this.dir = dir; - load(); - } + public HashMap presets = new HashMap(); - public Preset getPreset(String username) { - if(presets.isEmpty()) - load(); - return presets.get(username.toLowerCase()); - } - - public void load(){ - NBTTagCompound compound = loadPreset(); - HashMap presets = new HashMap(); - if(compound != null){ - NBTTagList list = compound.getTagList("Presets", 10); - for(int i = 0; i < list.tagCount(); i++){ - NBTTagCompound comp = list.getCompoundTagAt(i); - Preset preset = new Preset(); - preset.readFromNBT(comp); - presets.put(preset.name.toLowerCase(), preset); - } - } - Preset.FillDefault(presets); - this.presets = presets; - } + private File dir; + public static PresetController instance; - private NBTTagCompound loadPreset(){ - String filename = "presets.dat"; - try { - File file = new File(dir, filename); - if(!file.exists()){ - return null; - } - return CompressedStreamTools.readCompressed(new FileInputStream(file)); - } catch (Exception e) { - LogWriter.except(e); - } - try { - File file = new File(dir, filename+"_old"); - if(!file.exists()){ - return null; - } - return CompressedStreamTools.readCompressed(new FileInputStream(file)); - - } catch (Exception e) { - LogWriter.except(e); - } - return null; - } - - public void save(){ - NBTTagCompound compound = new NBTTagCompound(); - NBTTagList list = new NBTTagList(); - for(Preset preset : presets.values()){ - list.appendTag(preset.writeToNBT()); - } - - compound.setTag("Presets", list); - savePreset(compound); - } + public PresetController(File dir) { + instance = this; + this.dir = dir; + load(); + } - private void savePreset(NBTTagCompound compound){ - String filename = "presets.dat"; - try { - File file = new File(dir, filename+"_new"); - File file1 = new File(dir, filename+"_old"); + public Preset getPreset(String username) { + if (presets.isEmpty()) + load(); + return presets.get(username.toLowerCase()); + } + + public void load() { + NBTTagCompound compound = loadPreset(); + HashMap presets = new HashMap(); + if (compound != null) { + NBTTagList list = compound.getTagList("Presets", 10); + for (int i = 0; i < list.tagCount(); i++) { + NBTTagCompound comp = list.getCompoundTagAt(i); + Preset preset = new Preset(); + preset.readFromNBT(comp); + presets.put(preset.name.toLowerCase(), preset); + } + } + Preset.FillDefault(presets); + this.presets = presets; + } + + private NBTTagCompound loadPreset() { + String filename = "presets.dat"; + try { + File file = new File(dir, filename); + if (!file.exists()) { + return null; + } + return CompressedStreamTools.readCompressed(new FileInputStream(file)); + } catch (Exception e) { + LogWriter.except(e); + } + try { + File file = new File(dir, filename + "_old"); + if (!file.exists()) { + return null; + } + return CompressedStreamTools.readCompressed(new FileInputStream(file)); + + } catch (Exception e) { + LogWriter.except(e); + } + return null; + } + + public void save() { + NBTTagCompound compound = new NBTTagCompound(); + NBTTagList list = new NBTTagList(); + for (Preset preset : presets.values()) { + list.appendTag(preset.writeToNBT()); + } + + compound.setTag("Presets", list); + savePreset(compound); + } + + private void savePreset(NBTTagCompound compound) { + String filename = "presets.dat"; + try { + File file = new File(dir, filename + "_new"); + File file1 = new File(dir, filename + "_old"); File file2 = new File(dir, filename); CompressedStreamTools.writeCompressed(compound, new FileOutputStream(file)); - if(file1.exists()) - { + if (file1.exists()) { file1.delete(); } file2.renameTo(file1); - if(file2.exists()) - { + if (file2.exists()) { file2.delete(); } file.renameTo(file2); - if(file.exists()) - { + if (file.exists()) { file.delete(); } - } catch (Exception e) { - LogWriter.except(e); - } - } + } catch (Exception e) { + LogWriter.except(e); + } + } - public void addPreset(Preset preset) { - while(presets.containsKey(preset.name.toLowerCase())){ - preset.name += "_"; - } - presets.put(preset.name.toLowerCase(), preset); - save(); - } + public void addPreset(Preset preset) { + while (presets.containsKey(preset.name.toLowerCase())) { + preset.name += "_"; + } + presets.put(preset.name.toLowerCase(), preset); + save(); + } - public void removePreset(String preset) { - if(preset == null) - return; - presets.remove(preset.toLowerCase()); - save(); - } + public void removePreset(String preset) { + if (preset == null) + return; + presets.remove(preset.toLowerCase()); + save(); + } } diff --git a/src/main/java/noppes/npcs/client/controllers/ScriptSoundController.java b/src/main/java/noppes/npcs/client/controllers/ScriptSoundController.java index a01b5f450..94da31ed1 100644 --- a/src/main/java/noppes/npcs/client/controllers/ScriptSoundController.java +++ b/src/main/java/noppes/npcs/client/controllers/ScriptSoundController.java @@ -33,7 +33,7 @@ public class ScriptSoundController { soundHandler.stopSound(sound); sounds.get(id).stopSound(); } - sounds.put(id,sound); + sounds.put(id, sound); soundHandler.playSound(sound); } diff --git a/src/main/java/noppes/npcs/client/fx/CustomFX.java b/src/main/java/noppes/npcs/client/fx/CustomFX.java index e4b7f2d1c..7a296d8e8 100644 --- a/src/main/java/noppes/npcs/client/fx/CustomFX.java +++ b/src/main/java/noppes/npcs/client/fx/CustomFX.java @@ -66,7 +66,7 @@ public class CustomFX extends EntityFX { protected int timeSinceStart; public int animRate; public boolean animLoop; - public int animStart,animEnd; + public int animStart, animEnd; protected int animPosX; protected int animPosY; @@ -96,21 +96,21 @@ public class CustomFX extends EntityFX { customFX.HEXColorRate = particle.HEXColorRate; customFX.HEXColorStart = particle.HEXColorStart; customFX.particleRed = (customFX.HEXColor >> 16 & 255) / 255f; - customFX.particleGreen = (customFX.HEXColor >> 8 & 255) / 255f; + customFX.particleGreen = (customFX.HEXColor >> 8 & 255) / 255f; customFX.particleBlue = (customFX.HEXColor & 255) / 255f; customFX.scaleX1 = particle.scaleX1; customFX.scaleX2 = particle.scaleX2; customFX.scaleXRate = Math.abs(particle.scaleXRate); customFX.scaleXRateStart = particle.scaleXRateStart; - if(customFX.scaleX1 > customFX.scaleX2) + if (customFX.scaleX1 > customFX.scaleX2) customFX.scaleXRate *= -1; customFX.scaleY1 = particle.scaleY1; customFX.scaleY2 = particle.scaleY2; customFX.scaleYRate = Math.abs(particle.scaleYRate); customFX.scaleYRateStart = particle.scaleYRateStart; - if(customFX.scaleY1 > customFX.scaleY2) + if (customFX.scaleY1 > customFX.scaleY2) customFX.scaleYRate *= -1; customFX.alpha1 = particle.alpha1; @@ -118,7 +118,7 @@ public class CustomFX extends EntityFX { customFX.alphaRate = Math.abs(particle.alphaRate); customFX.alphaRateStart = particle.alphaRateStart; customFX.particleAlpha = customFX.alpha1; - if(customFX.alpha1 > customFX.alpha2) + if (customFX.alpha1 > customFX.alpha2) customFX.alphaRate *= -1; customFX.rotationX1 = particle.rotationX1; @@ -126,7 +126,7 @@ public class CustomFX extends EntityFX { customFX.rotationXRate = Math.abs(particle.rotationXRate); customFX.rotationXRateStart = particle.rotationXRateStart; customFX.rotationX = customFX.rotationX1; - if(customFX.rotationX1 > customFX.rotationX2) + if (customFX.rotationX1 > customFX.rotationX2) customFX.rotationXRate *= -1; customFX.rotationY1 = particle.rotationY1; @@ -134,7 +134,7 @@ public class CustomFX extends EntityFX { customFX.rotationYRate = Math.abs(particle.rotationYRate); customFX.rotationYRateStart = particle.rotationYRateStart; customFX.rotationY = customFX.rotationY1; - if(customFX.rotationY1 > customFX.rotationY2) + if (customFX.rotationY1 > customFX.rotationY2) customFX.rotationYRate *= -1; customFX.rotationZ1 = particle.rotationZ1; @@ -142,10 +142,10 @@ public class CustomFX extends EntityFX { customFX.rotationZRate = Math.abs(particle.rotationZRate); customFX.rotationZRateStart = particle.rotationZRateStart; customFX.rotationZ = customFX.rotationZ1; - if(customFX.rotationZ1 > customFX.rotationZ2) + if (customFX.rotationZ1 > customFX.rotationZ2) customFX.rotationZRate *= -1; - customFX.particleGravity = particle.gravity/0.04F; + customFX.particleGravity = particle.gravity / 0.04F; customFX.particleMaxAge = particle.maxAge; customFX.motionX = particle.motionX; @@ -163,7 +163,7 @@ public class CustomFX extends EntityFX { customFX.animLoop = particle.animLoop; customFX.animStart = particle.animStart; customFX.animEnd = particle.animEnd; - if(customFX.animEnd < customFX.animStart) + if (customFX.animEnd < customFX.animStart) customFX.animEnd = customFX.animStart + customFX.particleMaxAge; customFX.facePlayer = particle.facePlayer; @@ -180,8 +180,7 @@ public class CustomFX extends EntityFX { ++this.timeSinceStart; - if (this.timeSinceStart == this.particleMaxAge) - { + if (this.timeSinceStart == this.particleMaxAge) { this.setDead(); } @@ -189,7 +188,7 @@ public class CustomFX extends EntityFX { this.prevPosY = this.posY; this.prevPosZ = this.posZ; - this.motionY -= 0.04D * (double)this.particleGravity; + this.motionY -= 0.04D * (double) this.particleGravity; this.moveEntity(this.motionX, this.motionY, this.motionZ); if (animRate > 0 && timeSinceStart % animRate == 0 && timeSinceStart > 0 && timeSinceStart >= animStart && timeSinceStart <= animEnd && (animLoop || animPosY <= imageData.getTotalHeight())) { @@ -204,16 +203,15 @@ public class CustomFX extends EntityFX { } particleRed = (HEXColor >> 16 & 255) / 255f; - particleGreen = (HEXColor >> 8 & 255) / 255f; + particleGreen = (HEXColor >> 8 & 255) / 255f; particleBlue = (HEXColor & 255) / 255f; - if(timeSinceStart >= HEXColorStart) + if (timeSinceStart >= HEXColorStart) HEXColor = lerpColor(HEXColor, HEXColor2, HEXColorRate); } @Override - public void renderParticle(Tessellator tessellator, float partialTick, float cosYaw, float cosPitch, float sinYaw, float sinSinPitch, float cosSinPitch) - { + public void renderParticle(Tessellator tessellator, float partialTick, float cosYaw, float cosPitch, float sinYaw, float sinSinPitch, float cosSinPitch) { if (!this.imageLoaded()) { return; } @@ -224,46 +222,46 @@ public class CustomFX extends EntityFX { setDead(); } - if(entity != null){ - startX = (float)(entity.prevPosX + (entity.posX - entity.prevPosX) * (double)partialTick); - startY = (float)(entity.prevPosY + (entity.posY - entity.prevPosY) * (double)partialTick); - startZ = (float)(entity.prevPosZ + (entity.posZ - entity.prevPosZ) * (double)partialTick); + if (entity != null) { + startX = (float) (entity.prevPosX + (entity.posX - entity.prevPosX) * (double) partialTick); + startY = (float) (entity.prevPosY + (entity.posY - entity.prevPosY) * (double) partialTick); + startZ = (float) (entity.prevPosZ + (entity.posZ - entity.prevPosZ) * (double) partialTick); } - float scaleXChange = this.scaleXRate / (float)particleMaxAge; - if((this.scaleXRate < 0 && this.scaleX1+scaleXChange < this.scaleX2) || (this.scaleXRate > 0 && this.scaleX1+scaleXChange > this.scaleX2)) + float scaleXChange = this.scaleXRate / (float) particleMaxAge; + if ((this.scaleXRate < 0 && this.scaleX1 + scaleXChange < this.scaleX2) || (this.scaleXRate > 0 && this.scaleX1 + scaleXChange > this.scaleX2)) this.scaleX1 = this.scaleX2; - else if(timeSinceStart >= this.scaleXRateStart) + else if (timeSinceStart >= this.scaleXRateStart) this.scaleX1 += scaleXChange; - float scaleYChange = this.scaleYRate / (float)particleMaxAge; - if((this.scaleYRate < 0 && this.scaleY1+scaleYChange < this.scaleY2) || (this.scaleYRate > 0 && this.scaleY1+scaleYChange > this.scaleY2)) + float scaleYChange = this.scaleYRate / (float) particleMaxAge; + if ((this.scaleYRate < 0 && this.scaleY1 + scaleYChange < this.scaleY2) || (this.scaleYRate > 0 && this.scaleY1 + scaleYChange > this.scaleY2)) this.scaleY1 = this.scaleY2; - else if(timeSinceStart >= this.scaleYRateStart) + else if (timeSinceStart >= this.scaleYRateStart) this.scaleY1 += scaleYChange; - float alphaChange = this.alphaRate / (float)particleMaxAge; - if((this.alphaRate < 0 && particleAlpha+alphaChange < this.alpha2) || (this.alphaRate > 0 && particleAlpha+alphaChange > this.alpha2)) + float alphaChange = this.alphaRate / (float) particleMaxAge; + if ((this.alphaRate < 0 && particleAlpha + alphaChange < this.alpha2) || (this.alphaRate > 0 && particleAlpha + alphaChange > this.alpha2)) particleAlpha = this.alpha2; - else if(timeSinceStart >= this.alphaRateStart) + else if (timeSinceStart >= this.alphaRateStart) particleAlpha += alphaChange; - float rotationXChange = this.rotationXRate / (float)particleMaxAge; - if((this.rotationXRate < 0 && rotationX+rotationXChange < this.rotationX2) || (this.rotationXRate > 0 && rotationX+rotationXChange > this.rotationX2)) + float rotationXChange = this.rotationXRate / (float) particleMaxAge; + if ((this.rotationXRate < 0 && rotationX + rotationXChange < this.rotationX2) || (this.rotationXRate > 0 && rotationX + rotationXChange > this.rotationX2)) rotationX = this.rotationX2; - else if(timeSinceStart >= this.rotationXRateStart) + else if (timeSinceStart >= this.rotationXRateStart) rotationX += rotationXChange; - float rotationYChange = this.rotationYRate / (float)particleMaxAge; - if((this.rotationYRate < 0 && rotationY+rotationYChange < this.rotationY2) || (this.rotationYRate > 0 && rotationY+rotationYChange > this.rotationY2)) + float rotationYChange = this.rotationYRate / (float) particleMaxAge; + if ((this.rotationYRate < 0 && rotationY + rotationYChange < this.rotationY2) || (this.rotationYRate > 0 && rotationY + rotationYChange > this.rotationY2)) rotationY = this.rotationY2; - else if(timeSinceStart >= this.rotationYRateStart) + else if (timeSinceStart >= this.rotationYRateStart) rotationY += rotationYChange; - float rotationZChange = this.rotationZRate / (float)particleMaxAge; - if((this.rotationZRate < 0 && rotationZ+rotationZChange < this.rotationZ2) || (this.rotationZRate > 0 && rotationZ+rotationZChange > this.rotationZ2)) + float rotationZChange = this.rotationZRate / (float) particleMaxAge; + if ((this.rotationZRate < 0 && rotationZ + rotationZChange < this.rotationZ2) || (this.rotationZRate > 0 && rotationZ + rotationZChange > this.rotationZ2)) rotationZ = this.rotationZ2; - else if(timeSinceStart >= this.rotationZRateStart) + else if (timeSinceStart >= this.rotationZRateStart) rotationZ += rotationZChange; renderParticleSide(true, tessellator, partialTick); @@ -274,81 +272,77 @@ public class CustomFX extends EntityFX { tessellator.startDrawingQuads(); } - public void renderParticleSide(boolean front, Tessellator tessellator, float partialTick){ + public void renderParticleSide(boolean front, Tessellator tessellator, float partialTick) { int totalWidth = imageData.getTotalWidth(); int totalHeight = imageData.getTotalHeight(); - float u1 = (float)offsetX/(float)totalWidth + (float)animPosX/(float)totalWidth; - float u2 = u1 + (float)width/(float)totalWidth; - float v1 = (float)offsetY/(float)totalHeight + (float)animPosY/(float)totalHeight; - float v2 = v1 + (float)height/(float)totalHeight; + float u1 = (float) offsetX / (float) totalWidth + (float) animPosX / (float) totalWidth; + float u2 = u1 + (float) width / (float) totalWidth; + float v1 = (float) offsetY / (float) totalHeight + (float) animPosY / (float) totalHeight; + float v2 = v1 + (float) height / (float) totalHeight; EntityPlayer player = Minecraft.getMinecraft().thePlayer; - float posX = (float)((prevPosX + (this.posX - prevPosX) * (double)partialTick) - interpPosX) + startX; - float posY = (float)((prevPosY + (this.posY - prevPosY) * (double)partialTick) - interpPosY) + startY; - float posZ = (float)((prevPosZ + (this.posZ - prevPosZ) * (double)partialTick) - interpPosZ) + startZ; + float posX = (float) ((prevPosX + (this.posX - prevPosX) * (double) partialTick) - interpPosX) + startX; + float posY = (float) ((prevPosY + (this.posY - prevPosY) * (double) partialTick) - interpPosY) + startY; + float posZ = (float) ((prevPosZ + (this.posZ - prevPosZ) * (double) partialTick) - interpPosZ) + startZ; GL11.glPushMatrix(); - renderPosX = startX + posX + this.posX; - renderPosY = startY + posY + this.posY; - renderPosZ = startZ + posZ + this.posZ; + renderPosX = startX + posX + this.posX; + renderPosY = startY + posY + this.posY; + renderPosZ = startZ + posZ + this.posZ; - GL11.glTranslated(posX,posY,posZ); - if(facePlayer) { - GL11.glRotated(180 - player.rotationYaw, 0.0, 1.0, 0.0); - GL11.glRotated(-player.rotationPitch + 90, 1.0, 0.0, 0.0); + GL11.glTranslated(posX, posY, posZ); + if (facePlayer) { + GL11.glRotated(180 - player.rotationYaw, 0.0, 1.0, 0.0); + GL11.glRotated(-player.rotationPitch + 90, 1.0, 0.0, 0.0); - GL11.glRotated(rotationX, 1.0, 0.0, 0.0); - GL11.glRotated(rotationZ, 0.0, 1.0, 0.0); - GL11.glRotated(rotationY + (!front ? 180 : 0), 0.0, 0.0, 1.0); - } else { - GL11.glRotated(rotationX, 1.0, 0.0, 0.0); - GL11.glRotated(rotationY, 0.0, 1.0, 0.0); - GL11.glRotated(rotationZ + (!front ? 180 : 0), 0.0, 0.0, 1.0); - } + GL11.glRotated(rotationX, 1.0, 0.0, 0.0); + GL11.glRotated(rotationZ, 0.0, 1.0, 0.0); + GL11.glRotated(rotationY + (!front ? 180 : 0), 0.0, 0.0, 1.0); + } else { + GL11.glRotated(rotationX, 1.0, 0.0, 0.0); + GL11.glRotated(rotationY, 0.0, 1.0, 0.0); + GL11.glRotated(rotationZ + (!front ? 180 : 0), 0.0, 0.0, 1.0); + } - tessellator.startDrawingQuads(); - if (!this.glows) { - tessellator.setBrightness(this.getBrightnessForRender(partialTick)); - } else { - tessellator.setBrightness(240); - } + tessellator.startDrawingQuads(); + if (!this.glows) { + tessellator.setBrightness(this.getBrightnessForRender(partialTick)); + } else { + tessellator.setBrightness(240); + } - float textureXScale = 1.0F, textureYScale = 1.0F; - if (totalWidth > totalHeight) { - textureYScale = (float) totalHeight/totalWidth; - GL11.glScalef(1/textureYScale/2,1/textureYScale/2,1/textureYScale/2); - } else if(totalHeight > totalWidth) { - textureXScale = (float) totalWidth/totalHeight; - GL11.glScalef(1/textureXScale/2,1/textureXScale/2,1/textureXScale/2); - } - textureXScale *= scaleX1/10.0F; - textureYScale *= scaleY1/10.0F; + float textureXScale = 1.0F, textureYScale = 1.0F; + if (totalWidth > totalHeight) { + textureYScale = (float) totalHeight / totalWidth; + GL11.glScalef(1 / textureYScale / 2, 1 / textureYScale / 2, 1 / textureYScale / 2); + } else if (totalHeight > totalWidth) { + textureXScale = (float) totalWidth / totalHeight; + GL11.glScalef(1 / textureXScale / 2, 1 / textureXScale / 2, 1 / textureXScale / 2); + } + textureXScale *= scaleX1 / 10.0F; + textureYScale *= scaleY1 / 10.0F; - tessellator.setColorOpaque_F(1, 1, 1); - tessellator.setColorRGBA_F(particleRed, particleGreen, particleBlue, particleAlpha); - tessellator.addVertexWithUV( textureXScale * (u2-u1)/2, 0, textureYScale * (v2-v1)/2, u2, v2); - tessellator.addVertexWithUV( textureXScale * (u2-u1)/2, 0, textureYScale * -(v2-v1)/2, u2, v1); - tessellator.addVertexWithUV( textureXScale * -(u2-u1)/2, 0, textureYScale * -(v2-v1)/2, u1, v1); - tessellator.addVertexWithUV( textureXScale * -(u2-u1)/2, 0, textureYScale * (v2-v1)/2, u1, v2); - tessellator.draw(); + tessellator.setColorOpaque_F(1, 1, 1); + tessellator.setColorRGBA_F(particleRed, particleGreen, particleBlue, particleAlpha); + tessellator.addVertexWithUV(textureXScale * (u2 - u1) / 2, 0, textureYScale * (v2 - v1) / 2, u2, v2); + tessellator.addVertexWithUV(textureXScale * (u2 - u1) / 2, 0, textureYScale * -(v2 - v1) / 2, u2, v1); + tessellator.addVertexWithUV(textureXScale * -(u2 - u1) / 2, 0, textureYScale * -(v2 - v1) / 2, u1, v1); + tessellator.addVertexWithUV(textureXScale * -(u2 - u1) / 2, 0, textureYScale * (v2 - v1) / 2, u1, v2); + tessellator.draw(); GL11.glPopMatrix(); } @SideOnly(Side.CLIENT) - public int getBrightnessForRender(float p_70070_1_) - { + public int getBrightnessForRender(float p_70070_1_) { int i = MathHelper.floor_double(renderPosX); int j = MathHelper.floor_double(renderPosZ); - if (this.worldObj.blockExists(i, 0, j)) - { + if (this.worldObj.blockExists(i, 0, j)) { double d0 = (this.boundingBox.maxY - this.boundingBox.minY) * 0.66D; - int k = MathHelper.floor_double(renderPosY - (double)this.yOffset + d0); + int k = MathHelper.floor_double(renderPosY - (double) this.yOffset + d0); return this.worldObj.getLightBrightnessForSkyBlocks(i, k, j, 0); - } - else - { + } else { return 0; } } @@ -366,11 +360,11 @@ public class CustomFX extends EntityFX { float rg = ag + ratio * (bg - ag); float rb = ab + ratio * (bb - ab); - return (int)(((int)rr << 16) + ((int)rg << 8) + (rb)); + return (int) (((int) rr << 16) + ((int) rg << 8) + (rb)); } - public int getFXLayer(){ - return 0; + public int getFXLayer() { + return 0; } public boolean imageLoaded() { diff --git a/src/main/java/noppes/npcs/client/fx/EntityBigSmokeFX.java b/src/main/java/noppes/npcs/client/fx/EntityBigSmokeFX.java index 18942eee7..742690d1d 100644 --- a/src/main/java/noppes/npcs/client/fx/EntityBigSmokeFX.java +++ b/src/main/java/noppes/npcs/client/fx/EntityBigSmokeFX.java @@ -15,14 +15,15 @@ import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.entity.EntityEvent.EntityConstructing; import org.lwjgl.opengl.GL11; -public class EntityBigSmokeFX extends EntityFX -{ +public class EntityBigSmokeFX extends EntityFX { - /** there are 12 smoke textures. */ + /** + * there are 12 smoke textures. + */ public static final int TEXTURE_COUNT = 12; public static final ResourceLocation[] TEXTURES = new ResourceLocation[TEXTURE_COUNT]; - static - { + + static { for (int i = 0; i < TEXTURE_COUNT; i++) TEXTURES[i] = new ResourceLocation("customnpcs" + ":" + "textures/particle/big_smoke_" + i + ".png"); } @@ -71,8 +72,7 @@ public class EntityBigSmokeFX extends EntityFX } @Override - public void renderParticle(Tessellator tess, float partialTicks, float rotX, float rotXZ, float rotZ, float rotYZ, float rotXY) - { + public void renderParticle(Tessellator tess, float partialTicks, float rotX, float rotXZ, float rotZ, float rotYZ, float rotXY) { rotX = ActiveRenderInfo.rotationX; rotXZ = ActiveRenderInfo.rotationXZ; rotZ = ActiveRenderInfo.rotationZ; @@ -120,8 +120,7 @@ public class EntityBigSmokeFX extends EntityFX } @Override - public int getFXLayer() - { + public int getFXLayer() { return 3; } @@ -156,7 +155,6 @@ public class EntityBigSmokeFX extends EntityFX } - /** * Allows you to change various aspects of campfire smoke particles:
* - {@link #particleRed}, {@link #particleGreen}, and {@link #particleBlue} are the float r, g, b values of the smoke.
@@ -176,8 +174,7 @@ public class EntityBigSmokeFX extends EntityFX * This event is {@link Cancelable}. If canceled, the entity will be removed.
*/ @Cancelable - public static class EntityBigSmokeFXConstructingEvent extends EntityConstructing - { + public static class EntityBigSmokeFXConstructingEvent extends EntityConstructing { public final int[] campfirePosition; public float particleRed; @@ -192,11 +189,10 @@ public class EntityBigSmokeFX extends EntityFX public float alphaFadePerTick; public int particleMaxAge; - public EntityBigSmokeFXConstructingEvent(EntityBigSmokeFX entity, int x, int y, int z) - { + public EntityBigSmokeFXConstructingEvent(EntityBigSmokeFX entity, int x, int y, int z) { super(entity); - campfirePosition = new int[] { x, y, z }; + campfirePosition = new int[]{x, y, z}; particleRed = entity.particleRed; particleGreen = entity.particleGreen; diff --git a/src/main/java/noppes/npcs/client/fx/EntityElementalStaffFX.java b/src/main/java/noppes/npcs/client/fx/EntityElementalStaffFX.java index 3eae1f1d1..2fc6aa0e2 100644 --- a/src/main/java/noppes/npcs/client/fx/EntityElementalStaffFX.java +++ b/src/main/java/noppes/npcs/client/fx/EntityElementalStaffFX.java @@ -1,6 +1,6 @@ // Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov. // Jad home page: http://www.kpdus.com/jad.html -// Decompiler options: packimports(3) braces deadcode +// Decompiler options: packimports(3) braces deadcode package noppes.npcs.client.fx; @@ -13,61 +13,59 @@ import net.minecraft.util.MathHelper; // Referenced classes of package net.minecraft.src: // EntityFX, World, Tessellator -public class EntityElementalStaffFX extends EntityPortalFX -{ - double x,y,z; - EntityLivingBase player; - public EntityElementalStaffFX(EntityLivingBase player, double d, double d1, double d2, - double f1, double f2, double f3, int color) - { +public class EntityElementalStaffFX extends EntityPortalFX { + double x, y, z; + EntityLivingBase player; + + public EntityElementalStaffFX(EntityLivingBase player, double d, double d1, double d2, + double f1, double f2, double f3, int color) { super(player.worldObj, player.posX + d, player.posY + d1, player.posZ + d2, f1, f2, f3); - - + + this.player = player; - + x = d; y = d1; z = d2; float[] colors; - if(color <= 15) - colors = EntitySheep.fleeceColorTable[color]; + if (color <= 15) + colors = EntitySheep.fleeceColorTable[color]; else - colors = new float[]{((color>>16)&0xFF) / 255f, ((color>>8)&0xFF) / 255f,(color&0xFF) / 255f}; + colors = new float[]{((color >> 16) & 0xFF) / 255f, ((color >> 8) & 0xFF) / 255f, (color & 0xFF) / 255f}; particleRed = colors[0]; particleGreen = colors[1]; particleBlue = colors[2]; - particleMaxAge = (int)(16D / (Math.random() * 0.80000000000000004D + 0.20000000000000001D)); + particleMaxAge = (int) (16D / (Math.random() * 0.80000000000000004D + 0.20000000000000001D)); noClip = false; } - public void onUpdate() - { - if(player.isDead){ - this.setDead(); - return; - } - + public void onUpdate() { + if (player.isDead) { + this.setDead(); + return; + } + this.prevPosX = this.posX; this.prevPosY = this.posY; this.prevPosZ = this.posZ; - float var1 = (float)this.particleAge / (float)this.particleMaxAge; + float var1 = (float) this.particleAge / (float) this.particleMaxAge; float var2 = var1; var1 = -var1 + var1 * var1 * 2.0F; var1 = 1.0F - var1; - double dx = -MathHelper.sin((float) ((player.rotationYaw / 180F) * Math.PI)) * MathHelper.cos((float) ((player.rotationPitch / 180F) * Math.PI)); - double dz = MathHelper.cos((float) ((player.rotationYaw / 180F) * Math.PI)) * MathHelper.cos((float) ((player.rotationPitch / 180F) * Math.PI)); - - this.posX = player.posX + x + dx + this.motionX * (double)var1; - this.posY = player.posY + y + this.motionY * (double)var1 + (double)(1.0F - var2) - player.rotationPitch/40; - this.posZ = player.posZ + z + dz + this.motionZ * (double)var1; + double dx = -MathHelper.sin((float) ((player.rotationYaw / 180F) * Math.PI)) * MathHelper.cos((float) ((player.rotationPitch / 180F) * Math.PI)); + double dz = MathHelper.cos((float) ((player.rotationYaw / 180F) * Math.PI)) * MathHelper.cos((float) ((player.rotationPitch / 180F) * Math.PI)); - if (this.particleAge++ >= this.particleMaxAge) - { + this.posX = player.posX + x + dx + this.motionX * (double) var1; + this.posY = player.posY + y + this.motionY * (double) var1 + (double) (1.0F - var2) - player.rotationPitch / 40; + this.posZ = player.posZ + z + dz + this.motionZ * (double) var1; + + if (this.particleAge++ >= this.particleMaxAge) { this.setDead(); } } - public void setDead(){ - super.setDead(); + + public void setDead() { + super.setDead(); } } diff --git a/src/main/java/noppes/npcs/client/fx/EntityEnderFX.java b/src/main/java/noppes/npcs/client/fx/EntityEnderFX.java index 318651521..a7b830e69 100644 --- a/src/main/java/noppes/npcs/client/fx/EntityEnderFX.java +++ b/src/main/java/noppes/npcs/client/fx/EntityEnderFX.java @@ -8,7 +8,7 @@ import noppes.npcs.entity.EntityCustomNpc; import noppes.npcs.entity.data.ModelPartData; import org.lwjgl.opengl.GL11; -public class EntityEnderFX extends EntityPortalFX{ +public class EntityEnderFX extends EntityPortalFX { private float portalParticleScale; private int particleNumber; @@ -18,57 +18,56 @@ public class EntityEnderFX extends EntityPortalFX{ private boolean move = true; private float startX = 0, startY = 0, startZ = 0; - public EntityEnderFX(EntityCustomNpc npc, double par2, double par4, - double par6, double par8, double par10, double par12, ModelPartData data) { - super(npc.worldObj, par2, par4, par6, par8, par10, par12); + public EntityEnderFX(EntityCustomNpc npc, double par2, double par4, + double par6, double par8, double par10, double par12, ModelPartData data) { + super(npc.worldObj, par2, par4, par6, par8, par10, par12); - this.npc = npc; - particleNumber = npc.getRNG().nextInt(2); + this.npc = npc; + particleNumber = npc.getRNG().nextInt(2); portalParticleScale = particleScale = rand.nextFloat() * 0.2F + 0.5F; particleRed = (data.color >> 16 & 255) / 255f; - particleGreen = (data.color >> 8 & 255) / 255f; + particleGreen = (data.color >> 8 & 255) / 255f; particleBlue = (data.color & 255) / 255f; - if(npc.getRNG().nextInt(3) == 1){ - move = false; + if (npc.getRNG().nextInt(3) == 1) { + move = false; this.startX = (float) npc.posX; this.startY = (float) npc.posY; this.startZ = (float) npc.posZ; } - if(data.playerTexture) - location = npc.textureLocation; + if (data.playerTexture) + location = npc.textureLocation; else - location = new ResourceLocation(data.texture); - } + location = new ResourceLocation(data.texture); + } - @Override - public void renderParticle(Tessellator par1Tessellator, float par2, float par3, float par4, float par5, float par6, float par7) - { - if(move){ - startX = (float)(npc.prevPosX + (npc.posX - npc.prevPosX) * (double)par2); - startY = (float)(npc.prevPosY + (npc.posY - npc.prevPosY) * (double)par2); - startZ = (float)(npc.prevPosZ + (npc.posZ - npc.prevPosZ) * (double)par2); - } + @Override + public void renderParticle(Tessellator par1Tessellator, float par2, float par3, float par4, float par5, float par6, float par7) { + if (move) { + startX = (float) (npc.prevPosX + (npc.posX - npc.prevPosX) * (double) par2); + startY = (float) (npc.prevPosY + (npc.posY - npc.prevPosY) * (double) par2); + startZ = (float) (npc.prevPosZ + (npc.posZ - npc.prevPosZ) * (double) par2); + } Tessellator tessellator = Tessellator.instance; tessellator.draw(); - float scale = ((float)particleAge + par2) / (float)particleMaxAge; + float scale = ((float) particleAge + par2) / (float) particleMaxAge; scale = 1.0F - scale; scale *= scale; scale = 1.0F - scale; particleScale = portalParticleScale * scale; - ClientProxy.bindTexture(location); + ClientProxy.bindTexture(location); float f = 0.875f; float f1 = f + 0.125f; float f2 = 0.75f - (particleNumber * 0.25f); float f3 = f2 + 0.25f; float f4 = 0.1F * particleScale; - float f5 = (float)(((prevPosX + (posX - prevPosX) * (double)par2) - interpPosX) + startX); - float f6 = (float)(((prevPosY + (posY - prevPosY) * (double)par2) - interpPosY) + startY); - float f7 = (float)(((prevPosZ + (posZ - prevPosZ) * (double)par2) - interpPosZ) + startZ); + float f5 = (float) (((prevPosX + (posX - prevPosX) * (double) par2) - interpPosX) + startX); + float f6 = (float) (((prevPosY + (posY - prevPosY) * (double) par2) - interpPosY) + startY); + float f7 = (float) (((prevPosZ + (posZ - prevPosZ) * (double) par2) - interpPosZ) + startZ); GL11.glColor4f(1, 1, 1, 1.0F); tessellator.startDrawingQuads(); @@ -85,7 +84,7 @@ public class EntityEnderFX extends EntityPortalFX{ tessellator.startDrawingQuads(); } - public int getFXLayer(){ - return 0; + public int getFXLayer() { + return 0; } } diff --git a/src/main/java/noppes/npcs/client/fx/EntityRainbowFX.java b/src/main/java/noppes/npcs/client/fx/EntityRainbowFX.java index 0050adc96..4da90572f 100644 --- a/src/main/java/noppes/npcs/client/fx/EntityRainbowFX.java +++ b/src/main/java/noppes/npcs/client/fx/EntityRainbowFX.java @@ -5,9 +5,7 @@ import net.minecraft.client.renderer.Tessellator; import net.minecraft.world.World; - -public class EntityRainbowFX extends EntityFX -{ +public class EntityRainbowFX extends EntityFX { public static float colorTable[][] = { { @@ -26,27 +24,25 @@ public class EntityRainbowFX extends EntityFX 0F, 0, 1.0f }, { - 0,4375F, 0, 1.0f + 0, 4375F, 0, 1.0f }, { 0.5625F, 0, 1.0f } }; - public EntityRainbowFX(World world, double d, double d1, double d2, - double f, double f1, double f2) - { + + public EntityRainbowFX(World world, double d, double d1, double d2, + double f, double f1, double f2) { this(world, d, d1, d2, 1.0F, f, f1, f2); } - public EntityRainbowFX(World world, double d, double d1, double d2, - float f, double f1, double f2, double f3) - { + public EntityRainbowFX(World world, double d, double d1, double d2, + float f, double f1, double f2, double f3) { super(world, d, d1, d2, 0.0D, 0.0D, 0.0D); motionX *= 0.10000000149011612D; motionY *= 0.10000000149011612D; motionZ *= 0.10000000149011612D; - if(f1 == 0.0F) - { + if (f1 == 0.0F) { f1 = 1.0F; } int i = world.rand.nextInt(colorTable.length); @@ -56,47 +52,40 @@ public class EntityRainbowFX extends EntityFX particleScale *= 0.75F; particleScale *= f; reddustParticleScale = particleScale; - particleMaxAge = (int)(16D / (Math.random() * 0.80000000000000004D + 0.20000000000000001D)); + particleMaxAge = (int) (16D / (Math.random() * 0.80000000000000004D + 0.20000000000000001D)); particleMaxAge *= f; noClip = false; } - public void renderParticle(Tessellator tessellator, float f, float f1, float f2, float f3, float f4, float f5) - { - float f6 = (((float)particleAge + f) / (float)particleMaxAge) * 32F; - if(f6 < 0.0F) - { + public void renderParticle(Tessellator tessellator, float f, float f1, float f2, float f3, float f4, float f5) { + float f6 = (((float) particleAge + f) / (float) particleMaxAge) * 32F; + if (f6 < 0.0F) { f6 = 0.0F; } - if(f6 > 1.0F) - { + if (f6 > 1.0F) { f6 = 1.0F; } particleScale = reddustParticleScale * f6; super.renderParticle(tessellator, f, f1, f2, f3, f4, f5); } - public void onUpdate() - { + public void onUpdate() { prevPosX = posX; prevPosY = posY; prevPosZ = posZ; - if(particleAge++ >= particleMaxAge) - { + if (particleAge++ >= particleMaxAge) { setDead(); } setParticleTextureIndex(7 - (particleAge * 8) / particleMaxAge); moveEntity(motionX, motionY, motionZ); - if(posY == prevPosY) - { + if (posY == prevPosY) { motionX *= 1.1000000000000001D; motionZ *= 1.1000000000000001D; } motionX *= 0.95999997854232788D; motionY *= 0.95999997854232788D; motionZ *= 0.95999997854232788D; - if(onGround) - { + if (onGround) { motionX *= 0.69999998807907104D; motionZ *= 0.69999998807907104D; } diff --git a/src/main/java/noppes/npcs/client/gui/EventGuiScriptList.java b/src/main/java/noppes/npcs/client/gui/EventGuiScriptList.java index 4c3ffb308..81bc4edde 100644 --- a/src/main/java/noppes/npcs/client/gui/EventGuiScriptList.java +++ b/src/main/java/noppes/npcs/client/gui/EventGuiScriptList.java @@ -10,26 +10,27 @@ import noppes.npcs.controllers.ScriptContainer; import java.util.ArrayList; import java.util.List; -public class EventGuiScriptList extends SubGuiInterface{ +public class EventGuiScriptList extends SubGuiInterface { private GuiCustomScroll scroll1; private GuiCustomScroll scroll2; private ScriptContainer container; private List scripts; - public EventGuiScriptList(List scripts, ScriptContainer container){ + public EventGuiScriptList(List scripts, ScriptContainer container) { this.container = container; setBackground("menubg.png"); xSize = 346; ySize = 216; - if(scripts == null) + if (scripts == null) scripts = new ArrayList(); this.scripts = scripts; } + @Override - public void initGui(){ + public void initGui() { super.initGui(); - if(scroll1 == null){ - scroll1 = new GuiCustomScroll(this,0); + if (scroll1 == null) { + scroll1 = new GuiCustomScroll(this, 0); scroll1.setSize(140, 180); } scroll1.guiLeft = guiLeft + 4; @@ -37,8 +38,8 @@ public class EventGuiScriptList extends SubGuiInterface{ this.addScroll(scroll1); addLabel(new GuiNpcLabel(1, "script.availableScripts", guiLeft + 4, guiTop + 4)); - if(scroll2 == null){ - scroll2 = new GuiCustomScroll(this,1); + if (scroll2 == null) { + scroll2 = new GuiCustomScroll(this, 1); scroll2.setSize(140, 180); } scroll2.guiLeft = guiLeft + 200; @@ -59,42 +60,43 @@ public class EventGuiScriptList extends SubGuiInterface{ addButton(new GuiNpcButton(66, guiLeft + 260, guiTop + 194, 60, 20, "gui.done")); } - protected void actionPerformed(GuiButton guibutton){ + protected void actionPerformed(GuiButton guibutton) { GuiNpcButton button = (GuiNpcButton) guibutton; - if(button.id == 1){ - if(scroll1.hasSelected()){ + if (button.id == 1) { + if (scroll1.hasSelected()) { container.scripts.add(scroll1.getSelected()); scroll1.selected = -1; scroll2.selected = -1; initGui(); } } - if(button.id == 2){ - if(scroll2.hasSelected()){ + if (button.id == 2) { + if (scroll2.hasSelected()) { container.scripts.remove(scroll2.getSelected()); scroll2.selected = -1; initGui(); } } - if(button.id == 3){ + if (button.id == 3) { container.scripts.clear(); - for(String script : scripts){ + for (String script : scripts) { container.scripts.add(script); } scroll1.selected = -1; scroll2.selected = -1; initGui(); } - if(button.id == 4){ + if (button.id == 4) { container.scripts.clear(); scroll1.selected = -1; scroll2.selected = -1; initGui(); } - if(button.id == 66){ + if (button.id == 66) { close(); } } + @Override public void save() { diff --git a/src/main/java/noppes/npcs/client/gui/GuiBorderBlock.java b/src/main/java/noppes/npcs/client/gui/GuiBorderBlock.java index d9c4d1717..cf5549c70 100644 --- a/src/main/java/noppes/npcs/client/gui/GuiBorderBlock.java +++ b/src/main/java/noppes/npcs/client/gui/GuiBorderBlock.java @@ -8,55 +8,58 @@ import net.minecraft.nbt.NBTTagCompound; import noppes.npcs.blocks.tiles.TileBorder; import noppes.npcs.client.gui.util.*; -public class GuiBorderBlock extends GuiNPCInterface implements IGuiData{ +public class GuiBorderBlock extends GuiNPCInterface implements IGuiData { - private TileBorder tile; + private TileBorder tile; public GuiBorderBlock(int x, int y, int z) { - super(); - tile = (TileBorder) player.worldObj.getTileEntity(x, y, z); + super(); + tile = (TileBorder) player.worldObj.getTileEntity(x, y, z); PacketClient.sendClient(new TileEntityGetPacket(x, y, z)); - } - public void initGui() - { - super.initGui(); - - this.addButton(new GuiNpcButton(4, guiLeft + 40, guiTop + 40, 120, 20, "Availability Options")); - - addLabel(new GuiNpcLabel(0,"Height", guiLeft+ 1, guiTop + 76, 0xffffff)); - addTextField(new GuiNpcTextField(0, this, fontRendererObj, guiLeft+ 60, guiTop + 71,40,20, tile.height + "")); - getTextField(0).integersOnly = true; - getTextField(0).setMinMaxDefault(0, 500, 6); - - addLabel(new GuiNpcLabel(1,"Message", guiLeft+ 1, guiTop + 100, 0xffffff)); - addTextField(new GuiNpcTextField(1, this, fontRendererObj, guiLeft+ 60, guiTop + 95,200,20, tile.message)); - - addButton(new GuiNpcButton(0, guiLeft + 40, guiTop + 190,120,20, "Done")); } - protected void actionPerformed(GuiButton guibutton) { - int id = guibutton.id; - if(id == 0) - close(); - if (id == 4) { - save(); - setSubGui(new SubGuiNpcAvailability(tile.availability)); - } - } - @Override - public void save() { - if(tile == null) - return; - tile.height = getTextField(0).getInteger(); - tile.message = getTextField(1).getText(); - NBTTagCompound compound = new NBTTagCompound(); - tile.writeToNBT(compound); + public void initGui() { + super.initGui(); + + this.addButton(new GuiNpcButton(4, guiLeft + 40, guiTop + 40, 120, 20, "Availability Options")); + + addLabel(new GuiNpcLabel(0, "Height", guiLeft + 1, guiTop + 76, 0xffffff)); + addTextField(new GuiNpcTextField(0, this, fontRendererObj, guiLeft + 60, guiTop + 71, 40, 20, tile.height + "")); + getTextField(0).integersOnly = true; + getTextField(0).setMinMaxDefault(0, 500, 6); + + addLabel(new GuiNpcLabel(1, "Message", guiLeft + 1, guiTop + 100, 0xffffff)); + addTextField(new GuiNpcTextField(1, this, fontRendererObj, guiLeft + 60, guiTop + 95, 200, 20, tile.message)); + + addButton(new GuiNpcButton(0, guiLeft + 40, guiTop + 190, 120, 20, "Done")); + } + + protected void actionPerformed(GuiButton guibutton) { + int id = guibutton.id; + if (id == 0) + close(); + if (id == 4) { + save(); + setSubGui(new SubGuiNpcAvailability(tile.availability)); + } + } + + @Override + public void save() { + if (tile == null) + return; + tile.height = getTextField(0).getInteger(); + tile.message = getTextField(1).getText(); + + NBTTagCompound compound = new NBTTagCompound(); + tile.writeToNBT(compound); PacketClient.sendClient(new TileEntitySavePacket(compound)); - } - @Override - public void setGuiData(NBTTagCompound compound) { - tile.readFromNBT(compound); - } + } + + @Override + public void setGuiData(NBTTagCompound compound) { + tile.readFromNBT(compound); + } } diff --git a/src/main/java/noppes/npcs/client/gui/GuiMagicCycleMap.java b/src/main/java/noppes/npcs/client/gui/GuiMagicCycleMap.java index 522bf2a62..d58b890df 100644 --- a/src/main/java/noppes/npcs/client/gui/GuiMagicCycleMap.java +++ b/src/main/java/noppes/npcs/client/gui/GuiMagicCycleMap.java @@ -1,19 +1,19 @@ package noppes.npcs.client.gui; -import noppes.npcs.client.ClientCacheHandler; -import noppes.npcs.client.gui.util.GuiDiagram; -import noppes.npcs.client.gui.util.GuiNPCInterface; -import noppes.npcs.client.renderer.ImageData; -import noppes.npcs.controllers.MagicController; -import noppes.npcs.controllers.data.Magic; -import noppes.npcs.controllers.data.MagicAssociation; -import noppes.npcs.controllers.data.MagicCycle; -import noppes.npcs.constants.EnumDiagramLayout; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.renderer.RenderHelper; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; +import noppes.npcs.client.ClientCacheHandler; +import noppes.npcs.client.gui.util.GuiDiagram; +import noppes.npcs.client.gui.util.GuiNPCInterface; +import noppes.npcs.client.renderer.ImageData; +import noppes.npcs.constants.EnumDiagramLayout; +import noppes.npcs.controllers.MagicController; +import noppes.npcs.controllers.data.Magic; +import noppes.npcs.controllers.data.MagicAssociation; +import noppes.npcs.controllers.data.MagicCycle; import org.lwjgl.opengl.GL11; import java.util.ArrayList; @@ -183,6 +183,7 @@ public class GuiMagicCycleMap extends GuiDiagram { // Inner class wrapping a Magic as a DiagramIcon. private class MagicIcon extends DiagramIcon { public Magic magic; + public MagicIcon(Magic magic) { super(magic.id, 0, 0); this.magic = magic; diff --git a/src/main/java/noppes/npcs/client/gui/GuiMerchantAdd.java b/src/main/java/noppes/npcs/client/gui/GuiMerchantAdd.java index d39a6531a..1d1cfa1ad 100644 --- a/src/main/java/noppes/npcs/client/gui/GuiMerchantAdd.java +++ b/src/main/java/noppes/npcs/client/gui/GuiMerchantAdd.java @@ -25,18 +25,19 @@ import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; @SideOnly(Side.CLIENT) -public class GuiMerchantAdd extends GuiContainer -{ +public class GuiMerchantAdd extends GuiContainer { private static final ResourceLocation merchantGuiTextures = new ResourceLocation("textures/gui/container/villager.png"); - /** Instance of IMerchant interface. */ + /** + * Instance of IMerchant interface. + */ private IMerchant theIMerchant; private MerchantButton nextRecipeButtonIndex; private MerchantButton previousRecipeButtonIndex; private int currentRecipeIndex; private String field_94082_v; - public GuiMerchantAdd() - { + + public GuiMerchantAdd() { super(new ContainerMerchantAdd(Minecraft.getMinecraft().thePlayer, ServerEventsHandler.Merchant, Minecraft.getMinecraft().theWorld)); this.theIMerchant = ServerEventsHandler.Merchant; this.field_94082_v = I18n.format("entity.Villager.name"); @@ -45,16 +46,15 @@ public class GuiMerchantAdd extends GuiContainer /** * Adds the buttons (and other controls) to the screen in question. */ - public void initGui() - { + public void initGui() { super.initGui(); int i = (this.width - this.xSize) / 2; int j = (this.height - this.ySize) / 2; this.buttonList.add(this.nextRecipeButtonIndex = new MerchantButton(1, i + 120 + 27, j + 24 - 1, true)); this.buttonList.add(this.previousRecipeButtonIndex = new MerchantButton(2, i + 36 - 19, j + 24 - 1, false)); - this.buttonList.add(new GuiNpcButton(4, i + xSize, j + 20, 60, 20, "gui.remove")); - this.buttonList.add(new GuiNpcButton(5, i + xSize, j + 50, 60, 20, "gui.add")); + this.buttonList.add(new GuiNpcButton(4, i + xSize, j + 20, 60, 20, "gui.remove")); + this.buttonList.add(new GuiNpcButton(5, i + xSize, j + 50, 60, 20, "gui.add")); this.nextRecipeButtonIndex.enabled = false; this.previousRecipeButtonIndex.enabled = false; } @@ -62,8 +62,7 @@ public class GuiMerchantAdd extends GuiContainer /** * Draw the foreground layer for the GuiContainer (everything in front of the items) */ - protected void drawGuiContainerForegroundLayer(int par1, int par2) - { + protected void drawGuiContainerForegroundLayer(int par1, int par2) { this.fontRendererObj.drawString(this.field_94082_v, this.xSize / 2 - this.fontRendererObj.getStringWidth(this.field_94082_v) / 2, 6, CustomNpcResourceListener.DefaultTextColor); this.fontRendererObj.drawString(I18n.format("container.inventory"), 8, this.ySize - 96 + 2, CustomNpcResourceListener.DefaultTextColor); } @@ -71,14 +70,12 @@ public class GuiMerchantAdd extends GuiContainer /** * Called from the main game loop to update the screen. */ - public void updateScreen() - { + public void updateScreen() { super.updateScreen(); Minecraft mc = Minecraft.getMinecraft(); MerchantRecipeList merchantrecipelist = this.theIMerchant.getRecipes(mc.thePlayer); - if (merchantrecipelist != null) - { + if (merchantrecipelist != null) { this.nextRecipeButtonIndex.enabled = this.currentRecipeIndex < merchantrecipelist.size() - 1; this.previousRecipeButtonIndex.enabled = this.currentRecipeIndex > 0; } @@ -87,72 +84,62 @@ public class GuiMerchantAdd extends GuiContainer /** * Fired when a control is clicked. This is the equivalent of ActionListener.actionPerformed(ActionEvent e). */ - protected void actionPerformed(GuiButton par1GuiButton) - { + protected void actionPerformed(GuiButton par1GuiButton) { boolean flag = false; Minecraft mc = Minecraft.getMinecraft(); - if (par1GuiButton == this.nextRecipeButtonIndex) - { + if (par1GuiButton == this.nextRecipeButtonIndex) { ++this.currentRecipeIndex; flag = true; - } - else if (par1GuiButton == this.previousRecipeButtonIndex) - { + } else if (par1GuiButton == this.previousRecipeButtonIndex) { --this.currentRecipeIndex; flag = true; } - if(par1GuiButton.id == 4){ + if (par1GuiButton.id == 4) { MerchantRecipeList merchantrecipelist = this.theIMerchant.getRecipes(mc.thePlayer); - if(currentRecipeIndex < merchantrecipelist.size()){ - merchantrecipelist.remove(currentRecipeIndex); - if(currentRecipeIndex > 0) - currentRecipeIndex--; + if (currentRecipeIndex < merchantrecipelist.size()) { + merchantrecipelist.remove(currentRecipeIndex); + if (currentRecipeIndex > 0) + currentRecipeIndex--; PacketClient.sendClient(new MerchantUpdatePacket(ServerEventsHandler.Merchant.getEntityId(), merchantrecipelist)); } } - if(par1GuiButton.id == 5){ - ItemStack item1 = this.inventorySlots.getSlot(0).getStack(); - ItemStack item2 = this.inventorySlots.getSlot(1).getStack(); - ItemStack sold = this.inventorySlots.getSlot(2).getStack(); - if(item1 == null && item2 != null){ - item1 = item2; - item2 = null; - } + if (par1GuiButton.id == 5) { + ItemStack item1 = this.inventorySlots.getSlot(0).getStack(); + ItemStack item2 = this.inventorySlots.getSlot(1).getStack(); + ItemStack sold = this.inventorySlots.getSlot(2).getStack(); + if (item1 == null && item2 != null) { + item1 = item2; + item2 = null; + } - if(item1 != null && sold != null){ - item1 = item1.copy(); - sold = sold.copy(); - if(item2 != null) - item2 = item2.copy(); - MerchantRecipe recipe = new MerchantRecipe(item1, item2, sold); - recipe.func_82783_a(Integer.MAX_VALUE - 8); + if (item1 != null && sold != null) { + item1 = item1.copy(); + sold = sold.copy(); + if (item2 != null) + item2 = item2.copy(); + MerchantRecipe recipe = new MerchantRecipe(item1, item2, sold); + recipe.func_82783_a(Integer.MAX_VALUE - 8); MerchantRecipeList merchantrecipelist = this.theIMerchant.getRecipes(mc.thePlayer); merchantrecipelist.add(recipe); PacketClient.sendClient(new MerchantUpdatePacket(ServerEventsHandler.Merchant.getEntityId(), merchantrecipelist)); - } + } } - if (flag) - { - ((ContainerMerchantAdd)this.inventorySlots).setCurrentRecipeIndex(this.currentRecipeIndex); + if (flag) { + ((ContainerMerchantAdd) this.inventorySlots).setCurrentRecipeIndex(this.currentRecipeIndex); ByteBuf bytebuf = Unpooled.buffer(); - try - { + try { bytebuf.writeInt(this.currentRecipeIndex); this.mc.getNetHandler().addToSendQueue(new C17PacketCustomPayload("MC|TrSel", bytebuf)); - } - catch (Exception exception) - { + } catch (Exception exception) { //field_147039_u.error("Couldn\'t send trade info", exception); - } - finally - { + } finally { bytebuf.release(); } } @@ -161,9 +148,8 @@ public class GuiMerchantAdd extends GuiContainer /** * Draw the background layer for the GuiContainer (everything behind the items) */ - @Override - protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) - { + @Override + protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) { Minecraft mc = Minecraft.getMinecraft(); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); mc.getTextureManager().bindTexture(merchantGuiTextures); @@ -172,13 +158,11 @@ public class GuiMerchantAdd extends GuiContainer this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize); MerchantRecipeList merchantrecipelist = this.theIMerchant.getRecipes(mc.thePlayer); - if (merchantrecipelist != null && !merchantrecipelist.isEmpty()) - { + if (merchantrecipelist != null && !merchantrecipelist.isEmpty()) { int i1 = this.currentRecipeIndex; - MerchantRecipe merchantrecipe = (MerchantRecipe)merchantrecipelist.get(i1); + MerchantRecipe merchantrecipe = (MerchantRecipe) merchantrecipelist.get(i1); - if (merchantrecipe.isRecipeDisabled()) - { + if (merchantrecipe.isRecipeDisabled()) { mc.getTextureManager().bindTexture(merchantGuiTextures); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GL11.glDisable(GL11.GL_LIGHTING); @@ -191,19 +175,17 @@ public class GuiMerchantAdd extends GuiContainer /** * Draws the screen and all the components in it. */ - @Override - public void drawScreen(int par1, int par2, float par3) - { + @Override + public void drawScreen(int par1, int par2, float par3) { super.drawScreen(par1, par2, par3); Minecraft mc = Minecraft.getMinecraft(); MerchantRecipeList merchantrecipelist = this.theIMerchant.getRecipes(mc.thePlayer); - if (merchantrecipelist != null && !merchantrecipelist.isEmpty()) - { + if (merchantrecipelist != null && !merchantrecipelist.isEmpty()) { int k = (this.width - this.xSize) / 2; int l = (this.height - this.ySize) / 2; int i1 = this.currentRecipeIndex; - MerchantRecipe merchantrecipe = (MerchantRecipe)merchantrecipelist.get(i1); + MerchantRecipe merchantrecipe = (MerchantRecipe) merchantrecipelist.get(i1); GL11.glPushMatrix(); ItemStack itemstack = merchantrecipe.getItemToBuy(); ItemStack itemstack1 = merchantrecipe.getSecondItemToBuy(); @@ -217,10 +199,9 @@ public class GuiMerchantAdd extends GuiContainer itemRender.renderItemAndEffectIntoGUI(this.fontRendererObj, mc.getTextureManager(), itemstack, k + 36, l + 24); itemRender.renderItemOverlayIntoGUI(this.fontRendererObj, mc.getTextureManager(), itemstack, k + 36, l + 24); - if (itemstack1 != null) - { - itemRender.renderItemAndEffectIntoGUI(this.fontRendererObj, mc.getTextureManager(), itemstack1, k + 62, l + 24); - itemRender.renderItemOverlayIntoGUI(this.fontRendererObj, mc.getTextureManager(), itemstack1, k + 62, l + 24); + if (itemstack1 != null) { + itemRender.renderItemAndEffectIntoGUI(this.fontRendererObj, mc.getTextureManager(), itemstack1, k + 62, l + 24); + itemRender.renderItemOverlayIntoGUI(this.fontRendererObj, mc.getTextureManager(), itemstack1, k + 62, l + 24); } itemRender.renderItemAndEffectIntoGUI(this.fontRendererObj, mc.getTextureManager(), itemstack2, k + 120, l + 24); @@ -228,16 +209,11 @@ public class GuiMerchantAdd extends GuiContainer itemRender.zLevel = 0.0F; GL11.glDisable(GL11.GL_LIGHTING); - if (this.func_146978_c(36, 24, 16, 16, par1, par2)) - { + if (this.func_146978_c(36, 24, 16, 16, par1, par2)) { this.renderToolTip(itemstack, par1, par2); - } - else if (itemstack1 != null && this.func_146978_c(62, 24, 16, 16, par1, par2)) - { + } else if (itemstack1 != null && this.func_146978_c(62, 24, 16, 16, par1, par2)) { this.renderToolTip(itemstack1, par1, par2); - } - else if (this.func_146978_c(120, 24, 16, 16, par1, par2)) - { + } else if (this.func_146978_c(120, 24, 16, 16, par1, par2)) { this.renderToolTip(itemstack2, par1, par2); } @@ -251,53 +227,44 @@ public class GuiMerchantAdd extends GuiContainer /** * Gets the Instance of IMerchant interface. */ - public IMerchant getIMerchant() - { + public IMerchant getIMerchant() { return this.theIMerchant; } - static ResourceLocation func_110417_h() - { + static ResourceLocation func_110417_h() { return merchantGuiTextures; } + @SideOnly(Side.CLIENT) - static class MerchantButton extends GuiButton - { - private final boolean field_146157_o; + static class MerchantButton extends GuiButton { + private final boolean field_146157_o; - public MerchantButton(int par1, int par2, int par3, boolean par4) - { - super(par1, par2, par3, 12, 19, ""); - this.field_146157_o = par4; - } + public MerchantButton(int par1, int par2, int par3, boolean par4) { + super(par1, par2, par3, 12, 19, ""); + this.field_146157_o = par4; + } - @Override - public void drawButton(Minecraft p_146112_1_, int p_146112_2_, int p_146112_3_) - { - if (this.visible) - { - p_146112_1_.getTextureManager().bindTexture(GuiMerchantAdd.merchantGuiTextures); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - boolean flag = p_146112_2_ >= this.xPosition && p_146112_3_ >= this.yPosition && p_146112_2_ < this.xPosition + this.width && p_146112_3_ < this.yPosition + this.height; - int k = 0; - int l = 176; + @Override + public void drawButton(Minecraft p_146112_1_, int p_146112_2_, int p_146112_3_) { + if (this.visible) { + p_146112_1_.getTextureManager().bindTexture(GuiMerchantAdd.merchantGuiTextures); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + boolean flag = p_146112_2_ >= this.xPosition && p_146112_3_ >= this.yPosition && p_146112_2_ < this.xPosition + this.width && p_146112_3_ < this.yPosition + this.height; + int k = 0; + int l = 176; - if (!this.enabled) - { - l += this.width * 2; - } - else if (flag) - { - l += this.width; - } - - if (!this.field_146157_o) - { - k += this.height; - } - - this.drawTexturedModalRect(this.xPosition, this.yPosition, l, k, this.width, this.height); + if (!this.enabled) { + l += this.width * 2; + } else if (flag) { + l += this.width; } + + if (!this.field_146157_o) { + k += this.height; + } + + this.drawTexturedModalRect(this.xPosition, this.yPosition, l, k, this.width, this.height); } } + } } diff --git a/src/main/java/noppes/npcs/client/gui/GuiNPCFactionSelection.java b/src/main/java/noppes/npcs/client/gui/GuiNPCFactionSelection.java index 450dfb846..45b402e72 100644 --- a/src/main/java/noppes/npcs/client/gui/GuiNPCFactionSelection.java +++ b/src/main/java/noppes/npcs/client/gui/GuiNPCFactionSelection.java @@ -13,87 +13,83 @@ import java.util.HashMap; import java.util.Vector; -public class GuiNPCFactionSelection extends GuiNPCInterface implements IScrollData -{ - private GuiNPCStringSlot slot; - private GuiScreen parent; - private HashMap data = new HashMap(); - private int factionId; - public GuiSelectionListener listener; - public GuiNPCFactionSelection(EntityNPCInterface npc,GuiScreen parent,int dialog) - { - super(npc); - drawDefaultBackground = false; - title = "Select Faction Category"; - this.parent = parent; - this.factionId = dialog; +public class GuiNPCFactionSelection extends GuiNPCInterface implements IScrollData { + private GuiNPCStringSlot slot; + private GuiScreen parent; + private HashMap data = new HashMap(); + private int factionId; + public GuiSelectionListener listener; + + public GuiNPCFactionSelection(EntityNPCInterface npc, GuiScreen parent, int dialog) { + super(npc); + drawDefaultBackground = false; + title = "Select Faction Category"; + this.parent = parent; + this.factionId = dialog; PacketClient.sendClient(new FactionsGetPacket()); - if(parent instanceof GuiSelectionListener){ - listener = (GuiSelectionListener) parent; - } + if (parent instanceof GuiSelectionListener) { + listener = (GuiSelectionListener) parent; + } } - public void initGui() - { + public void initGui() { super.initGui(); Vector list = new Vector(); - slot = new GuiNPCStringSlot(list,this,false,18); + slot = new GuiNPCStringSlot(list, this, false, 18); slot.registerScrollButtons(4, 5); - this.addButton(new GuiNpcButton(2, width / 2 -100, height - 41,98, 20, "gui.back")); - this.addButton(new GuiNpcButton(4, width / 2 + 2, height - 41,98, 20, "gui.select")); + this.addButton(new GuiNpcButton(2, width / 2 - 100, height - 41, 98, 20, "gui.back")); + this.addButton(new GuiNpcButton(4, width / 2 + 2, height - 41, 98, 20, "gui.select")); } - public void drawScreen(int i, int j, float f) - { - slot.drawScreen(i, j, f); + public void drawScreen(int i, int j, float f) { + slot.drawScreen(i, j, f); super.drawScreen(i, j, f); } - protected void actionPerformed(GuiButton guibutton) - { - int id = guibutton.id; - if(id == 2) - { - close(); - NoppesUtil.openGUI(player, parent); + protected void actionPerformed(GuiButton guibutton) { + int id = guibutton.id; + if (id == 2) { + close(); + NoppesUtil.openGUI(player, parent); } - if(id == 4) - { - doubleClicked(); + if (id == 4) { + doubleClicked(); } } - public void doubleClicked() { - if(slot.selected == null || slot.selected.isEmpty()) - return; - factionId = data.get(slot.selected); - close(); - NoppesUtil.openGUI(player, parent); - } - public void save() { - if(factionId >= 0){ - if(listener != null) - listener.selected(factionId, slot.selected); - } - } + public void doubleClicked() { + if (slot.selected == null || slot.selected.isEmpty()) + return; + factionId = data.get(slot.selected); + close(); + NoppesUtil.openGUI(player, parent); - @Override - public void setData(Vector list, HashMap data, EnumScrollData type) { - this.data = data; - this.slot.setList(list); - if(factionId >= 0) - for(String name : data.keySet()) - if(data.get(name) == factionId) - slot.selected = name; - } + } - @Override - public void setSelected(String selected) { + public void save() { + if (factionId >= 0) { + if (listener != null) + listener.selected(factionId, slot.selected); + } + } - } + @Override + public void setData(Vector list, HashMap data, EnumScrollData type) { + this.data = data; + this.slot.setList(list); + if (factionId >= 0) + for (String name : data.keySet()) + if (data.get(name) == factionId) + slot.selected = name; + } + + @Override + public void setSelected(String selected) { + + } } diff --git a/src/main/java/noppes/npcs/client/gui/GuiNPCLinesEdit.java b/src/main/java/noppes/npcs/client/gui/GuiNPCLinesEdit.java index d97a33a13..e140434a0 100644 --- a/src/main/java/noppes/npcs/client/gui/GuiNPCLinesEdit.java +++ b/src/main/java/noppes/npcs/client/gui/GuiNPCLinesEdit.java @@ -13,56 +13,52 @@ import noppes.npcs.entity.EntityNPCInterface; import java.util.HashMap; -public class GuiNPCLinesEdit extends GuiNPCInterface2 implements IGuiData, ISubGuiListener, ITextfieldListener -{ - private Lines lines; +public class GuiNPCLinesEdit extends GuiNPCInterface2 implements IGuiData, ISubGuiListener, ITextfieldListener { + private Lines lines; private int selectedId = -1; private GuiSoundSelection gui; - public GuiNPCLinesEdit(EntityNPCInterface npc, Lines lines) - { - super(npc); - this.lines = lines; + public GuiNPCLinesEdit(EntityNPCInterface npc, Lines lines) { + super(npc); + this.lines = lines; PacketClient.sendClient(new MainmenuAdvancedGetPacket()); } - public void initGui() - { + public void initGui() { super.initGui(); - for(int i = 0; i < 8; i++){ - String text = ""; - String sound = ""; - if(lines.lines.containsKey(i)){ + for (int i = 0; i < 8; i++) { + String text = ""; + String sound = ""; + if (lines.lines.containsKey(i)) { Line line = lines.lines.get(i); text = line.getText(); sound = line.getSound(); - } - addTextField(new GuiNpcTextField(i,this, fontRendererObj, guiLeft + 4, guiTop + 4 + i * 24, 200, 20,text)); - addTextField(new GuiNpcTextField(i + 8,this, fontRendererObj, guiLeft + 208, guiTop + 4 + i * 24, 146, 20,sound)); - addButton(new GuiNpcButton(i, guiLeft + 358, guiTop + 4 + i * 24, 60, 20, "gui.select")); + } + addTextField(new GuiNpcTextField(i, this, fontRendererObj, guiLeft + 4, guiTop + 4 + i * 24, 200, 20, text)); + addTextField(new GuiNpcTextField(i + 8, this, fontRendererObj, guiLeft + 208, guiTop + 4 + i * 24, 146, 20, sound)); + addButton(new GuiNpcButton(i, guiLeft + 358, guiTop + 4 + i * 24, 60, 20, "gui.select")); } } - protected void actionPerformed(GuiButton guibutton) - { + protected void actionPerformed(GuiButton guibutton) { GuiNpcButton button = (GuiNpcButton) guibutton; selectedId = button.id + 8; setSubGui(new GuiSoundSelection(getTextField(selectedId).getText())); } - @Override - public void setGuiData(NBTTagCompound compound) { - npc.advanced.readToNBT(compound); - initGui(); - } + @Override + public void setGuiData(NBTTagCompound compound) { + npc.advanced.readToNBT(compound); + initGui(); + } - private void saveLines(){ - HashMap lines = new HashMap(); - for(int i = 0; i < 8; i++){ + private void saveLines() { + HashMap lines = new HashMap(); + for (int i = 0; i < 8; i++) { GuiNpcTextField tf = getTextField(i); GuiNpcTextField tf2 = getTextField(i + 8); - if(!tf.isEmpty() || !tf2.isEmpty()){ + if (!tf.isEmpty() || !tf2.isEmpty()) { Line line = new Line(); line.setText(tf.getText()); line.setSound(tf2.getText()); @@ -73,16 +69,16 @@ public class GuiNPCLinesEdit extends GuiNPCInterface2 implements IGuiData, ISubG this.lines.lines = lines; } - public void save() { - saveLines(); + public void save() { + saveLines(); PacketClient.sendClient(new MainmenuAdvancedSavePacket(npc.advanced.writeToNBT(new NBTTagCompound()))); - } + } @Override public void subGuiClosed(SubGuiInterface subgui) { GuiSoundSelection gss = (GuiSoundSelection) subgui; - if(gss.selectedResource != null) { + if (gss.selectedResource != null) { getTextField(selectedId).setText(gss.selectedResource.toString()); saveLines(); initGui(); diff --git a/src/main/java/noppes/npcs/client/gui/GuiNPCTransportCategoryEdit.java b/src/main/java/noppes/npcs/client/gui/GuiNPCTransportCategoryEdit.java index 129f4bd0b..aac0f10fe 100644 --- a/src/main/java/noppes/npcs/client/gui/GuiNPCTransportCategoryEdit.java +++ b/src/main/java/noppes/npcs/client/gui/GuiNPCTransportCategoryEdit.java @@ -12,56 +12,51 @@ import noppes.npcs.client.gui.util.GuiNpcLabel; import noppes.npcs.client.gui.util.GuiNpcTextField; import noppes.npcs.entity.EntityNPCInterface; -public class GuiNPCTransportCategoryEdit extends GuiNPCInterface -{ - private GuiScreen parent; - private String name; - private int id; - public GuiNPCTransportCategoryEdit(EntityNPCInterface npc,GuiScreen parent, String name, int id) - { - super(npc); - this.parent = parent; - this.name = name; - this.id = id; - title = "Npc Transport Category"; +public class GuiNPCTransportCategoryEdit extends GuiNPCInterface { + private GuiScreen parent; + private String name; + private int id; + + public GuiNPCTransportCategoryEdit(EntityNPCInterface npc, GuiScreen parent, String name, int id) { + super(npc); + this.parent = parent; + this.name = name; + this.id = id; + title = "Npc Transport Category"; } - public void initGui() - { + public void initGui() { super.initGui(); - this.addTextField(new GuiNpcTextField(1, this, this.fontRendererObj, width / 2 - 40, 100, 140, 20, name)); - addLabel(new GuiNpcLabel(1,"Title:", width / 2 - 100+4, 105, 0xffffff)); + this.addTextField(new GuiNpcTextField(1, this, this.fontRendererObj, width / 2 - 40, 100, 140, 20, name)); + addLabel(new GuiNpcLabel(1, "Title:", width / 2 - 100 + 4, 105, 0xffffff)); - this.addButton(new GuiNpcButton(2, width / 2 - 100, 210,98, 20, "gui.back")); - this.addButton(new GuiNpcButton(3, width / 2 +2, 210,98, 20, "Save")); + this.addButton(new GuiNpcButton(2, width / 2 - 100, 210, 98, 20, "gui.back")); + this.addButton(new GuiNpcButton(3, width / 2 + 2, 210, 98, 20, "Save")); } - public void drawScreen(int i, int j, float f) - { + public void drawScreen(int i, int j, float f) { super.drawScreen(i, j, f); } - protected void actionPerformed(GuiButton guibutton) - { - int id = guibutton.id; - if(id == 2) - { - NoppesUtil.openGUI(player, parent); + protected void actionPerformed(GuiButton guibutton) { + int id = guibutton.id; + if (id == 2) { + NoppesUtil.openGUI(player, parent); PacketClient.sendClient(new TransportCategoriesGetPacket()); } - if(id == 3) - { - save(); - NoppesUtil.openGUI(player, parent); + if (id == 3) { + save(); + NoppesUtil.openGUI(player, parent); PacketClient.sendClient(new TransportCategoriesGetPacket()); } } - public void save() { - String name = getTextField(1).getText(); - if(name.trim().isEmpty()) - return; + + public void save() { + String name = getTextField(1).getText(); + if (name.trim().isEmpty()) + return; PacketClient.sendClient(new TransportCategorySavePacket(name, id)); - } + } } diff --git a/src/main/java/noppes/npcs/client/gui/GuiNpcDimension.java b/src/main/java/noppes/npcs/client/gui/GuiNpcDimension.java index 7f6a88a72..309eca9b5 100644 --- a/src/main/java/noppes/npcs/client/gui/GuiNpcDimension.java +++ b/src/main/java/noppes/npcs/client/gui/GuiNpcDimension.java @@ -13,22 +13,23 @@ import noppes.npcs.constants.EnumScrollData; import java.util.HashMap; import java.util.Vector; -public class GuiNpcDimension extends GuiNPCInterface implements IScrollData{ +public class GuiNpcDimension extends GuiNPCInterface implements IScrollData { private GuiCustomScroll scroll; private HashMap data = new HashMap(); - public GuiNpcDimension() { - super(); + + public GuiNpcDimension() { + super(); xSize = 256; setBackground("menubg.png"); PacketClient.sendClient(new DimensionsGetPacket()); - } - public void initGui() - { + } + + public void initGui() { super.initGui(); - if(scroll == null){ - scroll = new GuiCustomScroll(this,0); - scroll.setSize(165, 208); + if (scroll == null) { + scroll = new GuiCustomScroll(this, 0); + scroll.setSize(165, 208); } scroll.guiLeft = guiLeft + 4; scroll.guiTop = guiTop + 4; @@ -39,57 +40,57 @@ public class GuiNpcDimension extends GuiNPCInterface implements IScrollData{ this.addLabel(new GuiNpcLabel(0, title, guiLeft + x, guiTop - 8)); - this.addButton(new GuiNpcButton(4, guiLeft + 170, guiTop + 72,82,20, "remote.tp")); + this.addButton(new GuiNpcButton(4, guiLeft + 170, guiTop + 72, 82, 20, "remote.tp")); } @Override - public void confirmClicked(boolean flag, int i) - { - if(flag){ + public void confirmClicked(boolean flag, int i) { + if (flag) { PacketClient.sendClient(new RemoteDeletePacket(data.get(scroll.getSelected()))); - } - NoppesUtil.openGUI(player, this); + } + NoppesUtil.openGUI(player, this); } - protected void actionPerformed(GuiButton guibutton) - { - int id = guibutton.id; - if(!data.containsKey(scroll.getSelected())) - return; + protected void actionPerformed(GuiButton guibutton) { + int id = guibutton.id; - if(id == 4){ + if (!data.containsKey(scroll.getSelected())) + return; + + if (id == 4) { PacketClient.sendClient(new DimensionTeleportPacket(data.get(scroll.getSelected()))); - close(); - } - } - - @Override - public void mouseClicked(int i, int j, int k) - { - super.mouseClicked(i, j, k); - scroll.mouseClicked(i, j, k); - } - @Override - public void keyTyped(char c, int i) - { - if (i == 1 || isInventoryKey(i)) - { close(); } } - @Override - public void save() { + + @Override + public void mouseClicked(int i, int j, int k) { + super.mouseClicked(i, j, k); + scroll.mouseClicked(i, j, k); + } + + @Override + public void keyTyped(char c, int i) { + if (i == 1 || isInventoryKey(i)) { + close(); + } + } + + @Override + public void save() { - } - @Override - public void setData(Vector list, HashMap data, EnumScrollData type) { - scroll.setList(list); - this.data = data; - } - @Override - public void setSelected(String selected) { - getButton(3).setDisplayText(selected); - } + } + + @Override + public void setData(Vector list, HashMap data, EnumScrollData type) { + scroll.setList(list); + this.data = data; + } + + @Override + public void setSelected(String selected) { + getButton(3).setDisplayText(selected); + } } diff --git a/src/main/java/noppes/npcs/client/gui/GuiNpcMobSpawner.java b/src/main/java/noppes/npcs/client/gui/GuiNpcMobSpawner.java index 8393eefa6..8c07cb55a 100644 --- a/src/main/java/noppes/npcs/client/gui/GuiNpcMobSpawner.java +++ b/src/main/java/noppes/npcs/client/gui/GuiNpcMobSpawner.java @@ -21,517 +21,511 @@ import java.lang.reflect.Modifier; import java.util.*; public class GuiNpcMobSpawner extends GuiNPCInterface implements IGuiData { - public static HashMap tags = new HashMap<>(); - public static HashMap tagNames = new HashMap<>(); - public static HashSet tagFilters = new HashSet<>(); - public static byte displayTags = 0; + public static HashMap tags = new HashMap<>(); + public static HashMap tagNames = new HashMap<>(); + public static HashSet tagFilters = new HashSet<>(); + public static byte displayTags = 0; - // 0 - Any, 1 - All, 2 - Not Any, 3 - Not All - public static byte filterCondition = 0; + // 0 - Any, 1 - All, 2 - Not Any, 3 - Not All + public static byte filterCondition = 0; - public static byte ascending = 0; + public static byte ascending = 0; - // 0 - By Name, 1 - By Date - public static byte sortType = 0; + // 0 - By Name, 1 - By Date + public static byte sortType = 0; - public TagMap tagMap; + public TagMap tagMap; - private final GuiCustomScrollCloner scroll = new GuiCustomScrollCloner(this,0); - private final GuiCustomScroll filterScroll = new GuiCustomScroll(this,1); + private final GuiCustomScrollCloner scroll = new GuiCustomScrollCloner(this, 0); + private final GuiCustomScroll filterScroll = new GuiCustomScroll(this, 1); - private int posX,posY,posZ; + private int posX, posY, posZ; - private List list; - private List rawList; - private List tagList; + private List list; + private List rawList; + private List tagList; - private static int showingClones = 0; + private static int showingClones = 0; - private static String search = ""; - private static String tagSearch = ""; + private static String search = ""; + private static String tagSearch = ""; - private int activeTab = 1; + private int activeTab = 1; - public GuiNpcMobSpawner(int i, int j, int k) { - super(); - xSize = 354; - posX = i; - posY = j; - posZ = k; + public GuiNpcMobSpawner(int i, int j, int k) { + super(); + xSize = 354; + posX = i; + posY = j; + posZ = k; - this.closeOnEsc = true; + this.closeOnEsc = true; - setBackground("menubg.png"); + setBackground("menubg.png"); PacketClient.sendClient(new CloneAllTagsPacket()); - } - public void initGui() - { - super.initGui(); - guiTop += 10; - guiLeft += 30; + } - scroll.clear(); - scroll.setSize(293, 188); - scroll.guiLeft = guiLeft + 4; - scroll.guiTop = guiTop + 26; - filterScroll.clear(); - filterScroll.setSize(140, 166); - filterScroll.guiLeft = guiLeft + 4; - filterScroll.guiTop = guiTop + 19; - filterScroll.multipleSelection = true; - filterScroll.setSelectedList(tagFilters); + public void initGui() { + super.initGui(); + guiTop += 10; + guiLeft += 30; - GuiMenuTopButton button; - addTopButton(button = new GuiMenuTopButton(3,guiLeft + 4, guiTop - 17, "spawner.clones")); - button.active = showingClones == 0; - addTopButton(button = new GuiMenuTopButton(5, button, "gui.server")); - button.active = showingClones == 2; - addTopButton(button = new GuiMenuTopButton(4, button, "spawner.entities")); - button.active = showingClones == 1; - addTopButton(button = new GuiMenuTopButton(16, guiLeft + (xSize - 67), guiTop - 17, "gui.filters")); - button.active = showingClones == 3; - addTopButton(button = new GuiMenuTopButton(17, guiLeft + (xSize - 22), guiTop - 17, "X")); + scroll.clear(); + scroll.setSize(293, 188); + scroll.guiLeft = guiLeft + 4; + scroll.guiTop = guiTop + 26; + filterScroll.clear(); + filterScroll.setSize(140, 166); + filterScroll.guiLeft = guiLeft + 4; + filterScroll.guiTop = guiTop + 19; + filterScroll.multipleSelection = true; + filterScroll.setSelectedList(tagFilters); - if (showingClones < 3){ - addScroll(scroll); - addTextField(new GuiNpcTextField(1, this, fontRendererObj, guiLeft + 4, guiTop + 4, 293, 20, search)); - addButton(new GuiNpcButton(1, guiLeft + 298, guiTop + 6, 52, 20, "item.monsterPlacer.name")); - addButton(new GuiNpcButton(2, guiLeft + 298, guiTop + 140, 52, 20, "spawner.mobspawner")); + GuiMenuTopButton button; + addTopButton(button = new GuiMenuTopButton(3, guiLeft + 4, guiTop - 17, "spawner.clones")); + button.active = showingClones == 0; + addTopButton(button = new GuiMenuTopButton(5, button, "gui.server")); + button.active = showingClones == 2; + addTopButton(button = new GuiMenuTopButton(4, button, "spawner.entities")); + button.active = showingClones == 1; + addTopButton(button = new GuiMenuTopButton(16, guiLeft + (xSize - 67), guiTop - 17, "gui.filters")); + button.active = showingClones == 3; + addTopButton(button = new GuiMenuTopButton(17, guiLeft + (xSize - 22), guiTop - 17, "X")); - if(showingClones == 0 || showingClones == 2){ + if (showingClones < 3) { + addScroll(scroll); + addTextField(new GuiNpcTextField(1, this, fontRendererObj, guiLeft + 4, guiTop + 4, 293, 20, search)); + addButton(new GuiNpcButton(1, guiLeft + 298, guiTop + 6, 52, 20, "item.monsterPlacer.name")); + addButton(new GuiNpcButton(2, guiLeft + 298, guiTop + 140, 52, 20, "spawner.mobspawner")); - addSideButton(new GuiMenuSideButton(21,guiLeft - 70, this.guiTop + 2, 70,22, "1")); - addSideButton(new GuiMenuSideButton(22,guiLeft - 70, this.guiTop + 23, 70,22, "2")); - addSideButton(new GuiMenuSideButton(23,guiLeft - 70, this.guiTop + 44, 70,22, "3")); - addSideButton(new GuiMenuSideButton(24,guiLeft - 70, this.guiTop + 65, 70,22, "4")); - addSideButton(new GuiMenuSideButton(25,guiLeft - 70, this.guiTop + 86, 70,22, "5")); - addSideButton(new GuiMenuSideButton(26,guiLeft - 70, this.guiTop + 107, 35,22, "6")); - addSideButton(new GuiMenuSideButton(27,guiLeft - 35, this.guiTop + 107, 35,22, "7")); - addSideButton(new GuiMenuSideButton(28,guiLeft - 70, this.guiTop + 128, 35,22, "8")); - addSideButton(new GuiMenuSideButton(29,guiLeft - 35, this.guiTop + 128, 35,22, "9")); - addSideButton(new GuiMenuSideButton(30,guiLeft - 70, this.guiTop + 149, 35,22, "10")); - addSideButton(new GuiMenuSideButton(31,guiLeft - 35, this.guiTop + 149, 35,22, "11")); - addSideButton(new GuiMenuSideButton(32,guiLeft - 70, this.guiTop + 170, 35,22, "12")); - addSideButton(new GuiMenuSideButton(33,guiLeft - 35, this.guiTop + 170, 35,22, "13")); - addSideButton(new GuiMenuSideButton(34,guiLeft - 70, this.guiTop + 191, 35,22, "14")); - addSideButton(new GuiMenuSideButton(35,guiLeft - 35, this.guiTop + 191, 35,22, "15")); + if (showingClones == 0 || showingClones == 2) { - addButton(new GuiNpcButton(6, guiLeft + 298, guiTop + 190, 52, 20, "gui.remove")); + addSideButton(new GuiMenuSideButton(21, guiLeft - 70, this.guiTop + 2, 70, 22, "1")); + addSideButton(new GuiMenuSideButton(22, guiLeft - 70, this.guiTop + 23, 70, 22, "2")); + addSideButton(new GuiMenuSideButton(23, guiLeft - 70, this.guiTop + 44, 70, 22, "3")); + addSideButton(new GuiMenuSideButton(24, guiLeft - 70, this.guiTop + 65, 70, 22, "4")); + addSideButton(new GuiMenuSideButton(25, guiLeft - 70, this.guiTop + 86, 70, 22, "5")); + addSideButton(new GuiMenuSideButton(26, guiLeft - 70, this.guiTop + 107, 35, 22, "6")); + addSideButton(new GuiMenuSideButton(27, guiLeft - 35, this.guiTop + 107, 35, 22, "7")); + addSideButton(new GuiMenuSideButton(28, guiLeft - 70, this.guiTop + 128, 35, 22, "8")); + addSideButton(new GuiMenuSideButton(29, guiLeft - 35, this.guiTop + 128, 35, 22, "9")); + addSideButton(new GuiMenuSideButton(30, guiLeft - 70, this.guiTop + 149, 35, 22, "10")); + addSideButton(new GuiMenuSideButton(31, guiLeft - 35, this.guiTop + 149, 35, 22, "11")); + addSideButton(new GuiMenuSideButton(32, guiLeft - 70, this.guiTop + 170, 35, 22, "12")); + addSideButton(new GuiMenuSideButton(33, guiLeft - 35, this.guiTop + 170, 35, 22, "13")); + addSideButton(new GuiMenuSideButton(34, guiLeft - 70, this.guiTop + 191, 35, 22, "14")); + addSideButton(new GuiMenuSideButton(35, guiLeft - 35, this.guiTop + 191, 35, 22, "15")); - getSideButton(20 + activeTab).active = true; - showClones(); - } - else { - showEntities(); - } - } else { - // Show Filters - addLabel(new GuiNpcLabel(1, StatCollector.translateToLocal("cloner.tagFilters"), guiLeft + 7, guiTop + 7)); - addScroll(filterScroll); - addTextField(new GuiNpcTextField(2, this, fontRendererObj, guiLeft + 4, guiTop + 190, 140, 20, tagSearch)); + addButton(new GuiNpcButton(6, guiLeft + 298, guiTop + 190, 52, 20, "gui.remove")); - addLabel(new GuiNpcLabel(2, StatCollector.translateToLocal("cloner.tagVisibility"), guiLeft + 150, guiTop + 27)); - addButton(new GuiNpcButton(12, guiLeft + 215, guiTop + 20, new String[]{"display.show", "display.all", "display.hide"}, displayTags)); + getSideButton(20 + activeTab).active = true; + showClones(); + } else { + showEntities(); + } + } else { + // Show Filters + addLabel(new GuiNpcLabel(1, StatCollector.translateToLocal("cloner.tagFilters"), guiLeft + 7, guiTop + 7)); + addScroll(filterScroll); + addTextField(new GuiNpcTextField(2, this, fontRendererObj, guiLeft + 4, guiTop + 190, 140, 20, tagSearch)); - addLabel(new GuiNpcLabel(3, StatCollector.translateToLocal("filter.contains"), guiLeft + 150, guiTop + 50)); - addButton(new GuiNpcButton(13, guiLeft + 215, guiTop + 43, new String[]{"filter.any", "filter.all", "filter.notany", "filter.notall"}, filterCondition)); + addLabel(new GuiNpcLabel(2, StatCollector.translateToLocal("cloner.tagVisibility"), guiLeft + 150, guiTop + 27)); + addButton(new GuiNpcButton(12, guiLeft + 215, guiTop + 20, new String[]{"display.show", "display.all", "display.hide"}, displayTags)); - addButton(new GuiNpcButton(11, guiLeft + 150, guiTop + 66, 130, 20, "gui.deselectAll")); + addLabel(new GuiNpcLabel(3, StatCollector.translateToLocal("filter.contains"), guiLeft + 150, guiTop + 50)); + addButton(new GuiNpcButton(13, guiLeft + 215, guiTop + 43, new String[]{"filter.any", "filter.all", "filter.notany", "filter.notall"}, filterCondition)); + + addButton(new GuiNpcButton(11, guiLeft + 150, guiTop + 66, 130, 20, "gui.deselectAll")); - addLabel(new GuiNpcLabel(4, StatCollector.translateToLocal("cloner.order"), guiLeft + 150, guiTop + 112)); - addButton(new GuiNpcButton(14, guiLeft + 215, guiTop + 105, new String[]{"cloner.ascending", "cloner.descending"}, ascending)); + addLabel(new GuiNpcLabel(4, StatCollector.translateToLocal("cloner.order"), guiLeft + 150, guiTop + 112)); + addButton(new GuiNpcButton(14, guiLeft + 215, guiTop + 105, new String[]{"cloner.ascending", "cloner.descending"}, ascending)); - addLabel(new GuiNpcLabel(5, StatCollector.translateToLocal("cloner.type"), guiLeft + 150, guiTop + 135)); - addButton(new GuiNpcButton(15, guiLeft + 215, guiTop + 128, new String[]{"cloner.name", "cloner.date"}, sortType)); + addLabel(new GuiNpcLabel(5, StatCollector.translateToLocal("cloner.type"), guiLeft + 150, guiTop + 135)); + addButton(new GuiNpcButton(15, guiLeft + 215, guiTop + 128, new String[]{"cloner.name", "cloner.date"}, sortType)); - getButton(12).width = 65; - getButton(12).height = 20; + getButton(12).width = 65; + getButton(12).height = 20; - getButton(13).width = 65; - getButton(13).height = 20; + getButton(13).width = 65; + getButton(13).height = 20; - getButton(14).width = 65; - getButton(14).height = 20; + getButton(14).width = 65; + getButton(14).height = 20; - getButton(15).width = 65; - getButton(15).height = 20; + getButton(15).width = 65; + getButton(15).height = 20; - showFilters(); - } - } + showFilters(); + } + } - public int getShowingClones() {return showingClones; } + public int getShowingClones() { + return showingClones; + } - public void showFilters(){ - filterScroll.setList(getTagList()); - } + public void showFilters() { + filterScroll.setList(getTagList()); + } - private void showEntities() { - Map data = EntityList.stringToClassMapping; - ArrayList list = new ArrayList(); - for(Object name : data.keySet()){ - Class c = (Class) data.get(name); - try { - if(EntityLiving.class.isAssignableFrom(c) && c.getConstructor(new Class[] {World.class}) != null && !Modifier.isAbstract(c.getModifiers())) - list.add(name.toString()); - } catch (SecurityException e) { - e.printStackTrace(); - } catch (NoSuchMethodException e) { - } - } - this.list = list; - this.rawList = new ArrayList(this.list); - scroll.setList(getSearchList(), ascending == 0, sortType == 0); - } - private void showClones() { - if(showingClones == 2){ + private void showEntities() { + Map data = EntityList.stringToClassMapping; + ArrayList list = new ArrayList(); + for (Object name : data.keySet()) { + Class c = (Class) data.get(name); + try { + if (EntityLiving.class.isAssignableFrom(c) && c.getConstructor(new Class[]{World.class}) != null && !Modifier.isAbstract(c.getModifiers())) + list.add(name.toString()); + } catch (SecurityException e) { + e.printStackTrace(); + } catch (NoSuchMethodException e) { + } + } + this.list = list; + this.rawList = new ArrayList(this.list); + scroll.setList(getSearchList(), ascending == 0, sortType == 0); + } + + private void showClones() { + if (showingClones == 2) { PacketClient.sendClient(new CloneTagListPacket(activeTab)); PacketClient.sendClient(new CloneListPacket(activeTab)); - return; - } + return; + } - if(sortType == 0){ - this.list = ClientCloneController.Instance.getClones(activeTab); - } - else { - this.list = ClientCloneController.Instance.getClonesDate(activeTab); - } + if (sortType == 0) { + this.list = ClientCloneController.Instance.getClones(activeTab); + } else { + this.list = ClientCloneController.Instance.getClonesDate(activeTab); + } - this.tagMap = ClientTagMapController.Instance.getTagMap(activeTab); - this.rawList = new ArrayList(this.list); - if(this.tagMap != null){ - if(GuiNpcMobSpawner.displayTags == 0 || GuiNpcMobSpawner.displayTags == 1){ - for(int i = 0; i < this.list.size(); i++){ - StringBuilder npcName = new StringBuilder(list.get(i)); - if (this.tagMap.hasClone(list.get(i))) { - for (UUID tagUUID : this.tagMap.getUUIDsList(list.get(i))){ - Tag tag = tags.get(tagUUID); - if(tag != null){ - if(GuiNpcMobSpawner.displayTags == 1 || !tag.getIsHidden()){ - npcName.append(" [" + tag.name + "]"); - } - } - } - } - this.rawList.set(i, npcName.toString()); - } - } - } + this.tagMap = ClientTagMapController.Instance.getTagMap(activeTab); + this.rawList = new ArrayList(this.list); + if (this.tagMap != null) { + if (GuiNpcMobSpawner.displayTags == 0 || GuiNpcMobSpawner.displayTags == 1) { + for (int i = 0; i < this.list.size(); i++) { + StringBuilder npcName = new StringBuilder(list.get(i)); + if (this.tagMap.hasClone(list.get(i))) { + for (UUID tagUUID : this.tagMap.getUUIDsList(list.get(i))) { + Tag tag = tags.get(tagUUID); + if (tag != null) { + if (GuiNpcMobSpawner.displayTags == 1 || !tag.getIsHidden()) { + npcName.append(" [" + tag.name + "]"); + } + } + } + } + this.rawList.set(i, npcName.toString()); + } + } + } - scroll.setList(getSearchList(), ascending == 0, sortType == 0); - } - public void keyTyped(char c, int i) - { - super.keyTyped(c, i); - if(getTextField(1) != null){ - if(search.equals(getTextField(1).getText())) - return; - search = getTextField(1).getText().toLowerCase(); - scroll.setList(getSearchList(), ascending == 0, sortType == 0); - } - if(getTextField(2) != null){ - if(tagSearch.equals(getTextField(2).getText())) - return; - tagSearch = getTextField(2).getText().toLowerCase(); - filterScroll.setList(getTagList()); - } + scroll.setList(getSearchList(), ascending == 0, sortType == 0); + } - } + public void keyTyped(char c, int i) { + super.keyTyped(c, i); + if (getTextField(1) != null) { + if (search.equals(getTextField(1).getText())) + return; + search = getTextField(1).getText().toLowerCase(); + scroll.setList(getSearchList(), ascending == 0, sortType == 0); + } + if (getTextField(2) != null) { + if (tagSearch.equals(getTextField(2).getText())) + return; + tagSearch = getTextField(2).getText().toLowerCase(); + filterScroll.setList(getTagList()); + } - private List getSearchList(){ - if(this.list == null){ - this.list = new ArrayList(); - } - if(this.rawList == null){ - this.rawList = new ArrayList(); - } + } - // No Filters - or - Entities - if(tagFilters.size() == 0 || showingClones == 1){ - // No Search - if(search.isEmpty()) - return new ArrayList(this.list); - // Yes Search - else { - List list = new ArrayList(); - for(int i = 0; i < this.list.size(); i++){ - if(this.rawList.get(i).toLowerCase().contains(search)){ - list.add(this.list.get(i)); - } - } - return list; - } - } + private List getSearchList() { + if (this.list == null) { + this.list = new ArrayList(); + } + if (this.rawList == null) { + this.rawList = new ArrayList(); + } - //////////////////////// - //// WITH FILTERS + // No Filters - or - Entities + if (tagFilters.size() == 0 || showingClones == 1) { + // No Search + if (search.isEmpty()) + return new ArrayList(this.list); + // Yes Search + else { + List list = new ArrayList(); + for (int i = 0; i < this.list.size(); i++) { + if (this.rawList.get(i).toLowerCase().contains(search)) { + list.add(this.list.get(i)); + } + } + return list; + } + } - // No Search - if(search.isEmpty()){ - List list = new ArrayList(); - for(String name : this.list){ - if(tagMap.hasClone(name)){ - if(meetsCondition(name)){ - list.add(name); - } - } - } - return list; - } + //////////////////////// + //// WITH FILTERS - // Yes Search - List list = new ArrayList(); - for(int i = 0; i < this.list.size(); i++){ - if(this.rawList.get(i).toLowerCase().contains(search)){ - String npcName = this.list.get(i); - if(tagMap.hasClone(npcName)){ - if(meetsCondition(npcName)){ - list.add(npcName); - } - } - } + // No Search + if (search.isEmpty()) { + List list = new ArrayList(); + for (String name : this.list) { + if (tagMap.hasClone(name)) { + if (meetsCondition(name)) { + list.add(name); + } + } + } + return list; + } - } - return list; - } + // Yes Search + List list = new ArrayList(); + for (int i = 0; i < this.list.size(); i++) { + if (this.rawList.get(i).toLowerCase().contains(search)) { + String npcName = this.list.get(i); + if (tagMap.hasClone(npcName)) { + if (meetsCondition(npcName)) { + list.add(npcName); + } + } + } - private boolean meetsCondition(String name){ - if(tagMap == null){ - return true; - } - boolean conditionMet = true; - boolean allRequirement = filterCondition == 1 || filterCondition == 3; + } + return list; + } - for(String tagName : tagFilters){ - UUID tagUUID = tagNames.get(tagName); - if(tagUUID != null) { - boolean hasTag = tagMap.hasTag(name, tagUUID); - if (!allRequirement) { - if (!hasTag && filterCondition == 0) { - conditionMet = false; - break; - } else if (hasTag && filterCondition == 2) { - conditionMet = false; - break; - } - } else { - if (!hasTag && filterCondition == 1) { - conditionMet = false; - break; - } else if (hasTag && filterCondition == 3) { - conditionMet = false; - break; - } - } - } - } + private boolean meetsCondition(String name) { + if (tagMap == null) { + return true; + } + boolean conditionMet = true; + boolean allRequirement = filterCondition == 1 || filterCondition == 3; - return conditionMet; - } + for (String tagName : tagFilters) { + UUID tagUUID = tagNames.get(tagName); + if (tagUUID != null) { + boolean hasTag = tagMap.hasTag(name, tagUUID); + if (!allRequirement) { + if (!hasTag && filterCondition == 0) { + conditionMet = false; + break; + } else if (hasTag && filterCondition == 2) { + conditionMet = false; + break; + } + } else { + if (!hasTag && filterCondition == 1) { + conditionMet = false; + break; + } else if (hasTag && filterCondition == 3) { + conditionMet = false; + break; + } + } + } + } - private List getTagList(){ - if(this.tagList == null){ - this.tagList = new ArrayList(); - } - // No Search // No Filters - or - Entities - if(tagSearch.isEmpty()) - return new ArrayList(tagNames.keySet()); - // Yes Search // No Filters - or - Entities + return conditionMet; + } - List list = new ArrayList(); - for(String name : this.tagList){ - if(name.toLowerCase().contains(tagSearch)) - list.add(name); - } - return list; - } + private List getTagList() { + if (this.tagList == null) { + this.tagList = new ArrayList(); + } + // No Search // No Filters - or - Entities + if (tagSearch.isEmpty()) + return new ArrayList(tagNames.keySet()); + // Yes Search // No Filters - or - Entities - private NBTTagCompound getCompound(){ - String sel = scroll.getSelected(); - if(sel == null) - return null; + List list = new ArrayList(); + for (String name : this.tagList) { + if (name.toLowerCase().contains(tagSearch)) + list.add(name); + } + return list; + } - if(showingClones == 0){ - return ClientCloneController.Instance.getCloneData(player, sel, activeTab); - } - else{ - Entity entity = EntityList.createEntityByName(sel, Minecraft.getMinecraft().theWorld); - if(entity == null) - return null; - NBTTagCompound compound = new NBTTagCompound(); - entity.writeToNBTOptional(compound); - return compound; - } - } + private NBTTagCompound getCompound() { + String sel = scroll.getSelected(); + if (sel == null) + return null; - @Override - protected void actionPerformed(GuiButton guibutton){ - int id = guibutton.id; - if(id == 0){ - close(); - } - if(id == 1){ - if(showingClones == 2){ - String sel = scroll.getSelected(); - if(sel == null) - return; + if (showingClones == 0) { + return ClientCloneController.Instance.getCloneData(player, sel, activeTab); + } else { + Entity entity = EntityList.createEntityByName(sel, Minecraft.getMinecraft().theWorld); + if (entity == null) + return null; + NBTTagCompound compound = new NBTTagCompound(); + entity.writeToNBTOptional(compound); + return compound; + } + } + + @Override + protected void actionPerformed(GuiButton guibutton) { + int id = guibutton.id; + if (id == 0) { + close(); + } + if (id == 1) { + if (showingClones == 2) { + String sel = scroll.getSelected(); + if (sel == null) + return; SpawnMobPacket.Server(posX, posY, posZ, sel, activeTab); - close(); - } - else{ - NBTTagCompound compound = getCompound(); - if(compound == null) - return; + close(); + } else { + NBTTagCompound compound = getCompound(); + if (compound == null) + return; SpawnMobPacket.Client(posX, posY, posZ, compound); - close(); - } - } - if(id == 2){ - if(showingClones == 2){ - String sel = scroll.getSelected(); - if(sel == null) - return; + close(); + } + } + if (id == 2) { + if (showingClones == 2) { + String sel = scroll.getSelected(); + if (sel == null) + return; MobSpawnerPacket.Server(posX, posY, posZ, sel, activeTab); - close(); - } - else{ - NBTTagCompound compound = getCompound(); - if(compound == null) - return; + close(); + } else { + NBTTagCompound compound = getCompound(); + if (compound == null) + return; MobSpawnerPacket.Client(posX, posY, posZ, compound); - close(); + close(); - } - } - if(id == 3){ - showingClones = 0; - initGui(); - } - if(id == 4){ - showingClones = 1; - initGui(); - } - if(id == 5){ - showingClones = 2; - initGui(); - } - if(id == 16){ - showingClones = 3; - initGui(); - } - if(id == 17){ - close(); - } - if(id == 6){ - if(scroll.getSelected() != null){ - if(showingClones == 2){ + } + } + if (id == 3) { + showingClones = 0; + initGui(); + } + if (id == 4) { + showingClones = 1; + initGui(); + } + if (id == 5) { + showingClones = 2; + initGui(); + } + if (id == 16) { + showingClones = 3; + initGui(); + } + if (id == 17) { + close(); + } + if (id == 6) { + if (scroll.getSelected() != null) { + if (showingClones == 2) { PacketClient.sendClient(new CloneRemovePacket(activeTab, scroll.getSelected())); - return; - } - ClientCloneController.Instance.removeClone(scroll.getSelected(), activeTab); - scroll.selected = -1; - initGui(); - } - } - if (id == 11) { - tagFilters = new HashSet<>(); - filterScroll.setSelectedList(tagFilters); - initGui(); - } - if (id == 12) { - GuiNpcButton button = (GuiNpcButton) guibutton; - displayTags = (byte) button.getValue(); - } - if (id == 13) { - GuiNpcButton button = (GuiNpcButton) guibutton; - filterCondition = (byte) button.getValue(); - } - if (id == 14) { - GuiNpcButton button = (GuiNpcButton) guibutton; - ascending = (byte) button.getValue(); - } - if (id == 15) { - GuiNpcButton button = (GuiNpcButton) guibutton; - sortType = (byte) button.getValue(); - } - if(id > 20){ - activeTab = id - 20; - initGui(); - } - } + return; + } + ClientCloneController.Instance.removeClone(scroll.getSelected(), activeTab); + scroll.selected = -1; + initGui(); + } + } + if (id == 11) { + tagFilters = new HashSet<>(); + filterScroll.setSelectedList(tagFilters); + initGui(); + } + if (id == 12) { + GuiNpcButton button = (GuiNpcButton) guibutton; + displayTags = (byte) button.getValue(); + } + if (id == 13) { + GuiNpcButton button = (GuiNpcButton) guibutton; + filterCondition = (byte) button.getValue(); + } + if (id == 14) { + GuiNpcButton button = (GuiNpcButton) guibutton; + ascending = (byte) button.getValue(); + } + if (id == 15) { + GuiNpcButton button = (GuiNpcButton) guibutton; + sortType = (byte) button.getValue(); + } + if (id > 20) { + activeTab = id - 20; + initGui(); + } + } - @Override - public void save() { + @Override + public void save() { - } + } - @Override - public void setGuiData(NBTTagCompound compound) { - if (compound.hasKey("CloneTags")) { - this.tagMap = new TagMap(activeTab); - NBTTagCompound cloneTags = compound.getCompoundTag("CloneTags"); - this.tagMap.readNBT(cloneTags); - } - else if (compound.hasKey("AllTags")) { - NBTTagList validTags = compound.getTagList("AllTags", 10); - if(validTags != null){ - HashMap tagsUpdate = new HashMap<>(); - HashMap tagNamesUpdate = new HashMap<>(); - for(int j = 0; j < validTags.tagCount(); j++) - { - NBTTagCompound tagStructure = validTags.getCompoundTagAt(j); - Tag tag = new Tag(); - tag.readNBT(tagStructure); - tagsUpdate.put(tag.uuid, tag); - tagNamesUpdate.put(tag.name, tag.uuid); - } - tags = tagsUpdate; - tagNames = tagNamesUpdate; - this.tagList = new ArrayList(tagNames.keySet()); - filterScroll.setList(getTagList()); - } - } - else { - List list = new ArrayList(); - if(sortType == 1){ - NBTTagList nbtlist = compound.getTagList("ListDate", 8); - for(int i = 0; i < nbtlist.tagCount(); i++){ - list.add(nbtlist.getStringTagAt(i)); - } - } - else { - NBTTagList nbtlist = compound.getTagList("List", 8); - for(int i = 0; i < nbtlist.tagCount(); i++){ - list.add(nbtlist.getStringTagAt(i)); - } - } + @Override + public void setGuiData(NBTTagCompound compound) { + if (compound.hasKey("CloneTags")) { + this.tagMap = new TagMap(activeTab); + NBTTagCompound cloneTags = compound.getCompoundTag("CloneTags"); + this.tagMap.readNBT(cloneTags); + } else if (compound.hasKey("AllTags")) { + NBTTagList validTags = compound.getTagList("AllTags", 10); + if (validTags != null) { + HashMap tagsUpdate = new HashMap<>(); + HashMap tagNamesUpdate = new HashMap<>(); + for (int j = 0; j < validTags.tagCount(); j++) { + NBTTagCompound tagStructure = validTags.getCompoundTagAt(j); + Tag tag = new Tag(); + tag.readNBT(tagStructure); + tagsUpdate.put(tag.uuid, tag); + tagNamesUpdate.put(tag.name, tag.uuid); + } + tags = tagsUpdate; + tagNames = tagNamesUpdate; + this.tagList = new ArrayList(tagNames.keySet()); + filterScroll.setList(getTagList()); + } + } else { + List list = new ArrayList(); + if (sortType == 1) { + NBTTagList nbtlist = compound.getTagList("ListDate", 8); + for (int i = 0; i < nbtlist.tagCount(); i++) { + list.add(nbtlist.getStringTagAt(i)); + } + } else { + NBTTagList nbtlist = compound.getTagList("List", 8); + for (int i = 0; i < nbtlist.tagCount(); i++) { + list.add(nbtlist.getStringTagAt(i)); + } + } - this.list = list; + this.list = list; - this.rawList = new ArrayList(this.list); - if(this.tagMap != null){ - if(GuiNpcMobSpawner.displayTags == 0 || GuiNpcMobSpawner.displayTags == 1){ - for(int i = 0; i < this.list.size(); i++){ - StringBuilder npcName = new StringBuilder(list.get(i)); - if (this.tagMap.hasClone(list.get(i))) { - for (UUID tagUUID : this.tagMap.getUUIDsList(list.get(i))){ - Tag tag = tags.get(tagUUID); - if(tag != null){ - if(GuiNpcMobSpawner.displayTags == 1 || !tag.getIsHidden()){ - npcName.append(" [" + tag.name + "]"); - } - } - } - } - this.rawList.set(i, npcName.toString()); - } - } - } + this.rawList = new ArrayList(this.list); + if (this.tagMap != null) { + if (GuiNpcMobSpawner.displayTags == 0 || GuiNpcMobSpawner.displayTags == 1) { + for (int i = 0; i < this.list.size(); i++) { + StringBuilder npcName = new StringBuilder(list.get(i)); + if (this.tagMap.hasClone(list.get(i))) { + for (UUID tagUUID : this.tagMap.getUUIDsList(list.get(i))) { + Tag tag = tags.get(tagUUID); + if (tag != null) { + if (GuiNpcMobSpawner.displayTags == 1 || !tag.getIsHidden()) { + npcName.append(" [" + tag.name + "]"); + } + } + } + } + this.rawList.set(i, npcName.toString()); + } + } + } - scroll.setList(getSearchList(), ascending == 0, sortType == 0); - } - } + scroll.setList(getSearchList(), ascending == 0, sortType == 0); + } + } } diff --git a/src/main/java/noppes/npcs/client/gui/GuiNpcMobSpawnerAdd.java b/src/main/java/noppes/npcs/client/gui/GuiNpcMobSpawnerAdd.java index 66ae14499..3dc90d15f 100644 --- a/src/main/java/noppes/npcs/client/gui/GuiNpcMobSpawnerAdd.java +++ b/src/main/java/noppes/npcs/client/gui/GuiNpcMobSpawnerAdd.java @@ -27,173 +27,169 @@ public class GuiNpcMobSpawnerAdd extends GuiNPCInterface implements GuiYesNoCall private Entity toClone; private NBTTagCompound compound; - private static boolean serverSide = false; - private static int tab = 1; - public boolean isNPC = false; + private static boolean serverSide = false; + private static int tab = 1; + public boolean isNPC = false; - // Selected Tags to Add + // Selected Tags to Add public static NBTTagList tagsCompound; - public static HashSet addTags; - public static ArrayList allTags = new ArrayList<>(); + public static HashSet addTags; + public static ArrayList allTags = new ArrayList<>(); public static HashSet addTagUUIDs; public static HashMap tagMap = new HashMap<>(); - public GuiNpcMobSpawnerAdd(NBTTagCompound compound){ - this.toClone = EntityList.createEntityFromNBT(compound, Minecraft.getMinecraft().theWorld); - this.compound = compound; + public GuiNpcMobSpawnerAdd(NBTTagCompound compound) { + this.toClone = EntityList.createEntityFromNBT(compound, Minecraft.getMinecraft().theWorld); + this.compound = compound; tagsCompound = new NBTTagList(); - if(toClone instanceof EntityNPCInterface){ - isNPC = true; - tagsCompound = this.compound.getTagList("TagUUIDs",8); - } - setBackground("menubg.png"); - xSize = 256; - ySize = 216; - closeOnEsc = true; + if (toClone instanceof EntityNPCInterface) { + isNPC = true; + tagsCompound = this.compound.getTagList("TagUUIDs", 8); + } + setBackground("menubg.png"); + xSize = 256; + ySize = 216; + closeOnEsc = true; - if(addTags == null){ - addTags = new HashSet<>(); - } - if(addTagUUIDs == null){ + if (addTags == null) { + addTags = new HashSet<>(); + } + if (addTagUUIDs == null) { addTagUUIDs = new HashSet<>(); } - if(isNPC){ + if (isNPC) { PacketClient.sendClient(new CloneAllTagsShortPacket()); - } - } + } + } - @Override - public void initGui(){ - super.initGui(); - String name = toClone.getCommandSenderName(); - addLabel(new GuiNpcLabel(0, "Save as", guiLeft + 4, guiTop + 6)); - addTextField(new GuiNpcTextField(0, this, fontRendererObj, guiLeft + 4, guiTop + 18, 200, 20, name)); + @Override + public void initGui() { + super.initGui(); + String name = toClone.getCommandSenderName(); + addLabel(new GuiNpcLabel(0, "Save as", guiLeft + 4, guiTop + 6)); + addTextField(new GuiNpcTextField(0, this, fontRendererObj, guiLeft + 4, guiTop + 18, 200, 20, name)); - addLabel(new GuiNpcLabel(1, "Tab", guiLeft + 10, guiTop + 50)); - addButton(new GuiButtonBiDirectional(2, guiLeft + 40, guiTop + 45, 60, 20, new String[]{"1","2","3","4","5","6","7","8","9","10","11","12","13","14","15"}, tab - 1)); + addLabel(new GuiNpcLabel(1, "Tab", guiLeft + 10, guiTop + 50)); + addButton(new GuiButtonBiDirectional(2, guiLeft + 40, guiTop + 45, 60, 20, new String[]{"1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15"}, tab - 1)); - addButton(new GuiNpcButton(3, guiLeft + 4, guiTop + 95, new String[]{"Client side", "Server side"}, serverSide?1:0)); - addLabel(new GuiNpcLabel(1, "Tab", guiLeft + 10, guiTop + 50)); + addButton(new GuiNpcButton(3, guiLeft + 4, guiTop + 95, new String[]{"Client side", "Server side"}, serverSide ? 1 : 0)); + addLabel(new GuiNpcLabel(1, "Tab", guiLeft + 10, guiTop + 50)); - addButton(new GuiNpcButton(0, guiLeft + 4, guiTop + 70, 80, 20, "gui.save")); - addButton(new GuiNpcButton(1, guiLeft + 86, guiTop + 70, 80, 20, "gui.cancel")); + addButton(new GuiNpcButton(0, guiLeft + 4, guiTop + 70, 80, 20, "gui.save")); + addButton(new GuiNpcButton(1, guiLeft + 86, guiTop + 70, 80, 20, "gui.cancel")); - if(isNPC){ - addButton(new GuiNpcButton(4, guiLeft + 4, guiTop + 120, 99, 20, "cloner.wandTags")); - addButton(new GuiNpcButton(5, guiLeft + 106, guiTop + 120, 99, 20, "cloner.npcTags")); - if(addTags.size() > 0){ - addLabel(new GuiNpcLabel(6, "cloner.wandtagsapplied", guiLeft + 10, guiTop + 160)); - } - } - } + if (isNPC) { + addButton(new GuiNpcButton(4, guiLeft + 4, guiTop + 120, 99, 20, "cloner.wandTags")); + addButton(new GuiNpcButton(5, guiLeft + 106, guiTop + 120, 99, 20, "cloner.npcTags")); + if (addTags.size() > 0) { + addLabel(new GuiNpcLabel(6, "cloner.wandtagsapplied", guiLeft + 10, guiTop + 160)); + } + } + } - public void buttonEvent(GuiButton guibutton) { - int id = guibutton.id; - if(id == 0){ - String name = getTextField(0).getText(); - if(name.isEmpty()) - return; - int tab = ((GuiNpcButton)guibutton).getValue() + 1; - if(!serverSide){ - if(ClientCloneController.Instance.getCloneData(null, name, tab) != null) - displayGuiScreen(new GuiYesNo(this, "Warning", "You are about to overwrite a clone", 1)); - else - confirmClicked(true, 0); - } - else + public void buttonEvent(GuiButton guibutton) { + int id = guibutton.id; + if (id == 0) { + String name = getTextField(0).getText(); + if (name.isEmpty()) + return; + int tab = ((GuiNpcButton) guibutton).getValue() + 1; + if (!serverSide) { + if (ClientCloneController.Instance.getCloneData(null, name, tab) != null) + displayGuiScreen(new GuiYesNo(this, "Warning", "You are about to overwrite a clone", 1)); + else + confirmClicked(true, 0); + } else PacketClient.sendClient(new ClonePreSavePacket(name, tab)); - } - if(id == 1){ - close(); - } - if(id == 2){ - tab = ((GuiNpcButton)guibutton).getValue() + 1; - } - if(id == 3){ - serverSide = ((GuiNpcButton)guibutton).getValue() == 1; - } - if (id == 4) { - if(isNPC){ - this.setSubGui(new SubGuiClonerQuickTags(this)); - } - } - if (id == 5) { - if(isNPC){ - this.setSubGui(new SubGuiClonerNPCTags((EntityNPCInterface) toClone, this)); - } - } - } - - - @Override - public void confirmClicked(boolean confirm, int id){ - if(confirm){ - String name = getTextField(0).getText(); - NBTTagCompound extraTags = new NBTTagCompound(); - if(isNPC){ - extraTags = setTempTags(); - } - if(!serverSide){ - if(isNPC){ - compound.setTag("TagUUIDs", tagsCompound); - } - ClientCloneController.Instance.addClone(compound, name, tab, extraTags); - } - else { - NBTTagCompound compounder = new NBTTagCompound(); - if(isNPC){ - compounder.setTag("TagUUIDs", tagsCompound); - } - PacketClient.sendClient(new CloneSavePacket(name, tab, extraTags, compounder)); - } - - close(); - } - else - displayGuiScreen(this); + } + if (id == 1) { + close(); + } + if (id == 2) { + tab = ((GuiNpcButton) guibutton).getValue() + 1; + } + if (id == 3) { + serverSide = ((GuiNpcButton) guibutton).getValue() == 1; + } + if (id == 4) { + if (isNPC) { + this.setSubGui(new SubGuiClonerQuickTags(this)); + } + } + if (id == 5) { + if (isNPC) { + this.setSubGui(new SubGuiClonerNPCTags((EntityNPCInterface) toClone, this)); + } + } } - @Override - public void save() {} + @Override + public void confirmClicked(boolean confirm, int id) { + if (confirm) { + String name = getTextField(0).getText(); + NBTTagCompound extraTags = new NBTTagCompound(); + if (isNPC) { + extraTags = setTempTags(); + } + if (!serverSide) { + if (isNPC) { + compound.setTag("TagUUIDs", tagsCompound); + } + ClientCloneController.Instance.addClone(compound, name, tab, extraTags); + } else { + NBTTagCompound compounder = new NBTTagCompound(); + if (isNPC) { + compounder.setTag("TagUUIDs", tagsCompound); + } + PacketClient.sendClient(new CloneSavePacket(name, tab, extraTags, compounder)); + } - @Override - public void setGuiData(NBTTagCompound compound) { - if(compound.hasKey("NameExists")){ - if(compound.getBoolean("NameExists")) - displayGuiScreen(new GuiYesNo(this, "Warning", "You are about to overwrite a clone", 1)); - else - confirmClicked(true, 0); - } - else if (compound.hasKey("ShortTags")) { - NBTTagList validTags = compound.getTagList("ShortTags", 10); - tagMap.clear(); - allTags.clear(); + close(); + } else + displayGuiScreen(this); + } + + + @Override + public void save() { + } + + @Override + public void setGuiData(NBTTagCompound compound) { + if (compound.hasKey("NameExists")) { + if (compound.getBoolean("NameExists")) + displayGuiScreen(new GuiYesNo(this, "Warning", "You are about to overwrite a clone", 1)); + else + confirmClicked(true, 0); + } else if (compound.hasKey("ShortTags")) { + NBTTagList validTags = compound.getTagList("ShortTags", 10); + tagMap.clear(); + allTags.clear(); addTagUUIDs.clear(); - if(validTags != null){ - for(int j = 0; j < validTags.tagCount(); j++) - { - NBTTagCompound tagStructure = validTags.getCompoundTagAt(j); - Tag tag = new Tag(); - tag.readShortNBT(tagStructure); - tagMap.put(tag.name, tag.uuid); + if (validTags != null) { + for (int j = 0; j < validTags.tagCount(); j++) { + NBTTagCompound tagStructure = validTags.getCompoundTagAt(j); + Tag tag = new Tag(); + tag.readShortNBT(tagStructure); + tagMap.put(tag.name, tag.uuid); addTagUUIDs.add(tag.uuid); - } - allTags.addAll(tagMap.keySet()); - allTags.sort(String.CASE_INSENSITIVE_ORDER); - } - initGui(); - } - } + } + allTags.addAll(tagMap.keySet()); + allTags.sort(String.CASE_INSENSITIVE_ORDER); + } + initGui(); + } + } - @Override - public void subGuiClosed(SubGuiInterface subgui) { - initGui(); - } + @Override + public void subGuiClosed(SubGuiInterface subgui) { + initGui(); + } - public NBTTagCompound setTempTags(){ + public NBTTagCompound setTempTags() { NBTTagCompound nbtTagCompound = new NBTTagCompound(); NBTTagList nbtTagList = new NBTTagList(); for (String name : addTags) { @@ -203,7 +199,7 @@ public class GuiNpcMobSpawnerAdd extends GuiNPCInterface implements GuiYesNoCall addTags.remove(name); } } - nbtTagCompound.setTag("TempTagUUIDs", nbtTagList); - return nbtTagCompound; - } + nbtTagCompound.setTag("TempTagUUIDs", nbtTagList); + return nbtTagCompound; + } } diff --git a/src/main/java/noppes/npcs/client/gui/GuiNpcMobSpawnerMounter.java b/src/main/java/noppes/npcs/client/gui/GuiNpcMobSpawnerMounter.java index d1157b1cc..6b7ef382a 100644 --- a/src/main/java/noppes/npcs/client/gui/GuiNpcMobSpawnerMounter.java +++ b/src/main/java/noppes/npcs/client/gui/GuiNpcMobSpawnerMounter.java @@ -20,22 +20,22 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; -public class GuiNpcMobSpawnerMounter extends GuiNPCInterface implements IGuiData{ +public class GuiNpcMobSpawnerMounter extends GuiNPCInterface implements IGuiData { private GuiCustomScroll scroll; - private int posX,posY,posZ; + private int posX, posY, posZ; private List list; private static int showingClones = 0; - private static String search = ""; + private static String search = ""; - private int activeTab = 1; + private int activeTab = 1; - public GuiNpcMobSpawnerMounter(int i, int j, int k) { - super(); + public GuiNpcMobSpawnerMounter(int i, int j, int k) { + super(); xSize = 256; posX = i; @@ -45,26 +45,25 @@ public class GuiNpcMobSpawnerMounter extends GuiNPCInterface implements IGuiData this.closeOnEsc = true; setBackground("menubg.png"); - } - public void initGui() - { + } + + public void initGui() { super.initGui(); guiTop += 10; - if(scroll == null){ - scroll = new GuiCustomScroll(this,0); - scroll.setSize(165, 188); - } - else - scroll.clear(); + if (scroll == null) { + scroll = new GuiCustomScroll(this, 0); + scroll.setSize(165, 188); + } else + scroll.clear(); scroll.guiLeft = guiLeft + 4; scroll.guiTop = guiTop + 26; addScroll(scroll); - addTextField(new GuiNpcTextField(1, this, fontRendererObj, guiLeft + 4, guiTop + 4, 165, 20, search)); + addTextField(new GuiNpcTextField(1, this, fontRendererObj, guiLeft + 4, guiTop + 4, 165, 20, search)); GuiMenuTopButton button; - addTopButton(button = new GuiMenuTopButton(3,guiLeft + 4, guiTop - 17, "spawner.clones")); + addTopButton(button = new GuiMenuTopButton(3, guiLeft + 4, guiTop - 17, "spawner.clones")); button.active = showingClones == 0; addTopButton(button = new GuiMenuTopButton(4, button, "spawner.entities")); button.active = showingClones == 1; @@ -75,137 +74,137 @@ public class GuiNpcMobSpawnerMounter extends GuiNPCInterface implements IGuiData addButton(new GuiNpcButton(2, guiLeft + 170, guiTop + 50, 82, 20, "spawner.mountplayer")); - if(showingClones == 0 || showingClones == 2){ - addSideButton(new GuiMenuSideButton(21,guiLeft - 90, this.guiTop + 2, 90,22, "1")); - addSideButton(new GuiMenuSideButton(22,guiLeft - 90, this.guiTop + 23, 90,22, "2")); - addSideButton(new GuiMenuSideButton(23,guiLeft - 90, this.guiTop + 44, 90,22, "3")); - addSideButton(new GuiMenuSideButton(24,guiLeft - 90, this.guiTop + 65, 90,22, "4")); - addSideButton(new GuiMenuSideButton(25,guiLeft - 90, this.guiTop + 86, 90,22, "5")); - addSideButton(new GuiMenuSideButton(26,guiLeft - 45, this.guiTop + 107, 45,22, "6")); - addSideButton(new GuiMenuSideButton(27,guiLeft - 90, this.guiTop + 107, 45,22, "7")); - addSideButton(new GuiMenuSideButton(28,guiLeft - 45, this.guiTop + 128, 45,22, "8")); - addSideButton(new GuiMenuSideButton(29,guiLeft - 90, this.guiTop + 128, 45,22, "9")); - addSideButton(new GuiMenuSideButton(30,guiLeft - 45, this.guiTop + 149, 45,22, "10")); - addSideButton(new GuiMenuSideButton(31,guiLeft - 90, this.guiTop + 149, 45,22, "11")); - addSideButton(new GuiMenuSideButton(32,guiLeft - 45, this.guiTop + 170, 45,22, "12")); - addSideButton(new GuiMenuSideButton(33,guiLeft - 90, this.guiTop + 170, 45,22, "13")); - addSideButton(new GuiMenuSideButton(34,guiLeft - 45, this.guiTop + 191, 45,22, "14")); - addSideButton(new GuiMenuSideButton(35,guiLeft - 90, this.guiTop + 191, 45,22, "15")); + if (showingClones == 0 || showingClones == 2) { + addSideButton(new GuiMenuSideButton(21, guiLeft - 90, this.guiTop + 2, 90, 22, "1")); + addSideButton(new GuiMenuSideButton(22, guiLeft - 90, this.guiTop + 23, 90, 22, "2")); + addSideButton(new GuiMenuSideButton(23, guiLeft - 90, this.guiTop + 44, 90, 22, "3")); + addSideButton(new GuiMenuSideButton(24, guiLeft - 90, this.guiTop + 65, 90, 22, "4")); + addSideButton(new GuiMenuSideButton(25, guiLeft - 90, this.guiTop + 86, 90, 22, "5")); + addSideButton(new GuiMenuSideButton(26, guiLeft - 45, this.guiTop + 107, 45, 22, "6")); + addSideButton(new GuiMenuSideButton(27, guiLeft - 90, this.guiTop + 107, 45, 22, "7")); + addSideButton(new GuiMenuSideButton(28, guiLeft - 45, this.guiTop + 128, 45, 22, "8")); + addSideButton(new GuiMenuSideButton(29, guiLeft - 90, this.guiTop + 128, 45, 22, "9")); + addSideButton(new GuiMenuSideButton(30, guiLeft - 45, this.guiTop + 149, 45, 22, "10")); + addSideButton(new GuiMenuSideButton(31, guiLeft - 90, this.guiTop + 149, 45, 22, "11")); + addSideButton(new GuiMenuSideButton(32, guiLeft - 45, this.guiTop + 170, 45, 22, "12")); + addSideButton(new GuiMenuSideButton(33, guiLeft - 90, this.guiTop + 170, 45, 22, "13")); + addSideButton(new GuiMenuSideButton(34, guiLeft - 45, this.guiTop + 191, 45, 22, "14")); + addSideButton(new GuiMenuSideButton(35, guiLeft - 90, this.guiTop + 191, 45, 22, "15")); - getSideButton(20 + activeTab).active = true; - showClones(); - } - else - showEntities(); + getSideButton(20 + activeTab).active = true; + showClones(); + } else + showEntities(); } - private void showEntities() { - Map data = EntityList.stringToClassMapping; + + private void showEntities() { + Map data = EntityList.stringToClassMapping; ArrayList list = new ArrayList(); - for(Object name : data.keySet()){ - Class c = (Class) data.get(name); - try { - if(EntityLiving.class.isAssignableFrom(c) && c.getConstructor(new Class[] {World.class}) != null && !Modifier.isAbstract(c.getModifiers())) - list.add(name.toString()); - } catch (SecurityException e) { - e.printStackTrace(); - } catch (NoSuchMethodException e) { - } + for (Object name : data.keySet()) { + Class c = (Class) data.get(name); + try { + if (EntityLiving.class.isAssignableFrom(c) && c.getConstructor(new Class[]{World.class}) != null && !Modifier.isAbstract(c.getModifiers())) + list.add(name.toString()); + } catch (SecurityException e) { + e.printStackTrace(); + } catch (NoSuchMethodException e) { + } } this.list = list; scroll.setList(getSearchList()); - } - private void showClones() { + } - if(showingClones == 2){ + private void showClones() { + + if (showingClones == 2) { PacketClient.sendClient(new CloneListPacket(activeTab)); - return; - } + return; + } ArrayList list = new ArrayList(); this.list = ClientCloneController.Instance.getClones(activeTab); scroll.setList(getSearchList()); - } - public void keyTyped(char c, int i) - { - super.keyTyped(c, i); - - if(search.equals(getTextField(1).getText())) - return; - search = getTextField(1).getText().toLowerCase(); - scroll.setList(getSearchList()); } - private List getSearchList(){ - if(search.isEmpty()) - return new ArrayList(list); - List list = new ArrayList(); - for(String name : this.list){ - if(name.toLowerCase().contains(search)) - list.add(name); - } - return list; + + public void keyTyped(char c, int i) { + super.keyTyped(c, i); + + if (search.equals(getTextField(1).getText())) + return; + search = getTextField(1).getText().toLowerCase(); + scroll.setList(getSearchList()); } - private NBTTagCompound getCompound(){ - String sel = scroll.getSelected(); - if(sel == null) - return null; - if(showingClones == 0){ - return ClientCloneController.Instance.getCloneData(player, sel, activeTab); - } - else{ - Entity entity = EntityList.createEntityByName(sel, Minecraft.getMinecraft().theWorld); - if(entity == null) - return null; - NBTTagCompound compound = new NBTTagCompound(); - entity.writeToNBTOptional(compound); - return compound; - } + private List getSearchList() { + if (search.isEmpty()) + return new ArrayList(list); + List list = new ArrayList(); + for (String name : this.list) { + if (name.toLowerCase().contains(search)) + list.add(name); + } + return list; + } - } + private NBTTagCompound getCompound() { + String sel = scroll.getSelected(); + if (sel == null) + return null; - protected void actionPerformed(GuiButton guibutton) - { - int id = guibutton.id; - if(id == 0){ - close(); - } - if(id == 1){ - NBTTagCompound compound = getCompound(); - if(compound != null){ - compound.setTag("Pos", this.newDoubleNBTList(new double[] {this.posX + 0.5, this.posY + 1, this.posZ + 0.5})); + if (showingClones == 0) { + return ClientCloneController.Instance.getCloneData(player, sel, activeTab); + } else { + Entity entity = EntityList.createEntityByName(sel, Minecraft.getMinecraft().theWorld); + if (entity == null) + return null; + NBTTagCompound compound = new NBTTagCompound(); + entity.writeToNBTOptional(compound); + return compound; + } + + } + + protected void actionPerformed(GuiButton guibutton) { + int id = guibutton.id; + if (id == 0) { + close(); + } + if (id == 1) { + NBTTagCompound compound = getCompound(); + if (compound != null) { + compound.setTag("Pos", this.newDoubleNBTList(new double[]{this.posX + 0.5, this.posY + 1, this.posZ + 0.5})); MountPacket.Spawn(compound); - close(); - } - } - if(id == 2){ + close(); + } + } + if (id == 2) { MountPacket.Player(); - close(); - } - if(id == 3){ - showingClones = 0; - initGui(); - } - if(id == 4){ - showingClones = 1; - initGui(); - } - if(id == 5){ - showingClones = 2; - initGui(); - } - if(id > 20){ - activeTab = id - 20; - initGui(); - } + close(); + } + if (id == 3) { + showingClones = 0; + initGui(); + } + if (id == 4) { + showingClones = 1; + initGui(); + } + if (id == 5) { + showingClones = 2; + initGui(); + } + if (id > 20) { + activeTab = id - 20; + initGui(); + } } - protected NBTTagList newDoubleNBTList(double ... par1ArrayOfDouble) - { + + protected NBTTagList newDoubleNBTList(double... par1ArrayOfDouble) { NBTTagList nbttaglist = new NBTTagList(); double[] adouble = par1ArrayOfDouble; int i = par1ArrayOfDouble.length; - for (int j = 0; j < i; ++j) - { + for (int j = 0; j < i; ++j) { double d1 = adouble[j]; nbttaglist.appendTag(new NBTTagDouble(d1)); } @@ -213,19 +212,20 @@ public class GuiNpcMobSpawnerMounter extends GuiNPCInterface implements IGuiData return nbttaglist; } - @Override - public void save() { + @Override + public void save() { - } - @Override - public void setGuiData(NBTTagCompound compound) { - NBTTagList nbtlist = compound.getTagList("List", 8); - List list = new ArrayList(); - for(int i = 0; i < nbtlist.tagCount(); i++){ - list.add(nbtlist.getStringTagAt(i)); - } - this.list = list; + } + + @Override + public void setGuiData(NBTTagCompound compound) { + NBTTagList nbtlist = compound.getTagList("List", 8); + List list = new ArrayList(); + for (int i = 0; i < nbtlist.tagCount(); i++) { + list.add(nbtlist.getStringTagAt(i)); + } + this.list = list; scroll.setList(getSearchList()); - } + } } diff --git a/src/main/java/noppes/npcs/client/gui/GuiNpcMobSpawnerSelector.java b/src/main/java/noppes/npcs/client/gui/GuiNpcMobSpawnerSelector.java index cc9cff0c2..c0b988e23 100644 --- a/src/main/java/noppes/npcs/client/gui/GuiNpcMobSpawnerSelector.java +++ b/src/main/java/noppes/npcs/client/gui/GuiNpcMobSpawnerSelector.java @@ -12,127 +12,127 @@ import noppes.npcs.client.gui.util.*; import java.util.ArrayList; import java.util.List; -public class GuiNpcMobSpawnerSelector extends SubGuiInterface implements IGuiData{ +public class GuiNpcMobSpawnerSelector extends SubGuiInterface implements IGuiData { private GuiCustomScroll scroll; private List list; - private static String search = ""; - public int activeTab = 1; - public boolean isServer = false; + private static String search = ""; + public int activeTab = 1; + public boolean isServer = false; - public GuiNpcMobSpawnerSelector() { - super(); + public GuiNpcMobSpawnerSelector() { + super(); xSize = 256; this.closeOnEsc = true; setBackground("menubg.png"); - } + } - public void initGui(){ + public void initGui() { super.initGui(); - if(scroll == null){ - scroll = new GuiCustomScroll(this,0); - scroll.setSize(165, 188); - } - else - scroll.clear(); + if (scroll == null) { + scroll = new GuiCustomScroll(this, 0); + scroll.setSize(165, 188); + } else + scroll.clear(); scroll.guiLeft = guiLeft + 4; scroll.guiTop = guiTop + 26; addScroll(scroll); - addTextField(new GuiNpcTextField(1, this, fontRendererObj, guiLeft + 4, guiTop + 4, 165, 20, search)); + addTextField(new GuiNpcTextField(1, this, fontRendererObj, guiLeft + 4, guiTop + 4, 165, 20, search)); - addButton(new GuiNpcButton(0, guiLeft + 171, guiTop + 80, 80, 20, "gui.done")); - addButton(new GuiNpcButton(1, guiLeft + 171, guiTop + 103, 80, 20, "gui.cancel")); + addButton(new GuiNpcButton(0, guiLeft + 171, guiTop + 80, 80, 20, "gui.done")); + addButton(new GuiNpcButton(1, guiLeft + 171, guiTop + 103, 80, 20, "gui.cancel")); - addSideButton(new GuiMenuSideButton(21,guiLeft - 90, this.guiTop + 2, 90,22, "1")); - addSideButton(new GuiMenuSideButton(22,guiLeft - 90, this.guiTop + 23, 90,22, "2")); - addSideButton(new GuiMenuSideButton(23,guiLeft - 90, this.guiTop + 44, 90,22, "3")); - addSideButton(new GuiMenuSideButton(24,guiLeft - 90, this.guiTop + 65, 90,22, "4")); - addSideButton(new GuiMenuSideButton(25,guiLeft - 90, this.guiTop + 86, 90,22, "5")); - addSideButton(new GuiMenuSideButton(26,guiLeft - 45, this.guiTop + 107, 45,22, "6")); - addSideButton(new GuiMenuSideButton(27,guiLeft - 90, this.guiTop + 107, 45,22, "7")); - addSideButton(new GuiMenuSideButton(28,guiLeft - 45, this.guiTop + 128, 45,22, "8")); - addSideButton(new GuiMenuSideButton(29,guiLeft - 90, this.guiTop + 128, 45,22, "9")); - addSideButton(new GuiMenuSideButton(30,guiLeft - 45, this.guiTop + 149, 45,22, "10")); - addSideButton(new GuiMenuSideButton(31,guiLeft - 90, this.guiTop + 149, 45,22, "11")); - addSideButton(new GuiMenuSideButton(32,guiLeft - 45, this.guiTop + 170, 45,22, "12")); - addSideButton(new GuiMenuSideButton(33,guiLeft - 90, this.guiTop + 170, 45,22, "13")); - addSideButton(new GuiMenuSideButton(34,guiLeft - 45, this.guiTop + 191, 45,22, "14")); - addSideButton(new GuiMenuSideButton(35,guiLeft - 90, this.guiTop + 191, 45,22, "15")); + addSideButton(new GuiMenuSideButton(21, guiLeft - 90, this.guiTop + 2, 90, 22, "1")); + addSideButton(new GuiMenuSideButton(22, guiLeft - 90, this.guiTop + 23, 90, 22, "2")); + addSideButton(new GuiMenuSideButton(23, guiLeft - 90, this.guiTop + 44, 90, 22, "3")); + addSideButton(new GuiMenuSideButton(24, guiLeft - 90, this.guiTop + 65, 90, 22, "4")); + addSideButton(new GuiMenuSideButton(25, guiLeft - 90, this.guiTop + 86, 90, 22, "5")); + addSideButton(new GuiMenuSideButton(26, guiLeft - 45, this.guiTop + 107, 45, 22, "6")); + addSideButton(new GuiMenuSideButton(27, guiLeft - 90, this.guiTop + 107, 45, 22, "7")); + addSideButton(new GuiMenuSideButton(28, guiLeft - 45, this.guiTop + 128, 45, 22, "8")); + addSideButton(new GuiMenuSideButton(29, guiLeft - 90, this.guiTop + 128, 45, 22, "9")); + addSideButton(new GuiMenuSideButton(30, guiLeft - 45, this.guiTop + 149, 45, 22, "10")); + addSideButton(new GuiMenuSideButton(31, guiLeft - 90, this.guiTop + 149, 45, 22, "11")); + addSideButton(new GuiMenuSideButton(32, guiLeft - 45, this.guiTop + 170, 45, 22, "12")); + addSideButton(new GuiMenuSideButton(33, guiLeft - 90, this.guiTop + 170, 45, 22, "13")); + addSideButton(new GuiMenuSideButton(34, guiLeft - 45, this.guiTop + 191, 45, 22, "14")); + addSideButton(new GuiMenuSideButton(35, guiLeft - 90, this.guiTop + 191, 45, 22, "15")); - getSideButton(20 + activeTab).active = true; - showClones(); + getSideButton(20 + activeTab).active = true; + showClones(); } - public String getSelected(){ - return scroll.getSelected(); + public String getSelected() { + return scroll.getSelected(); } - private void showClones() { - if(isServer){ + private void showClones() { + + if (isServer) { PacketClient.sendClient(new CloneListPacket(activeTab)); - return; - } + return; + } ArrayList list = new ArrayList(); this.list = new ArrayList(ClientCloneController.Instance.getClones(activeTab)); scroll.setList(getSearchList()); - } - public void keyTyped(char c, int i) - { - super.keyTyped(c, i); - - if(search.equals(getTextField(1).getText())) - return; - search = getTextField(1).getText().toLowerCase(); - scroll.setList(getSearchList()); } - private List getSearchList(){ - if(search.isEmpty()) - return new ArrayList(list); - List list = new ArrayList(); - for(String name : this.list){ - if(name.toLowerCase().contains(search)) - list.add(name); - } - return list; - } - public NBTTagCompound getCompound(){ - String sel = scroll.getSelected(); - if(sel == null) - return null; - NBTTagCompound compound = ClientCloneController.Instance.getCloneData(player, sel, activeTab); - compound.setString("ClonedName", sel); - return compound; - } + public void keyTyped(char c, int i) { + super.keyTyped(c, i); - public void buttonEvent(GuiButton guibutton) - { - int id = guibutton.id; - if(id == 0){ - close(); - } - if(id == 1){ - scroll.clear(); - close(); - } - if(id > 20){ - activeTab = id - 20; - initGui(); - } + if (search.equals(getTextField(1).getText())) + return; + search = getTextField(1).getText().toLowerCase(); + scroll.setList(getSearchList()); } - protected NBTTagList newDoubleNBTList(double ... par1ArrayOfDouble) - { + + private List getSearchList() { + if (search.isEmpty()) + return new ArrayList(list); + List list = new ArrayList(); + for (String name : this.list) { + if (name.toLowerCase().contains(search)) + list.add(name); + } + return list; + } + + public NBTTagCompound getCompound() { + String sel = scroll.getSelected(); + if (sel == null) + return null; + + NBTTagCompound compound = ClientCloneController.Instance.getCloneData(player, sel, activeTab); + compound.setString("ClonedName", sel); + return compound; + } + + public void buttonEvent(GuiButton guibutton) { + int id = guibutton.id; + if (id == 0) { + close(); + } + if (id == 1) { + scroll.clear(); + close(); + } + if (id > 20) { + activeTab = id - 20; + initGui(); + } + } + + protected NBTTagList newDoubleNBTList(double... par1ArrayOfDouble) { NBTTagList nbttaglist = new NBTTagList(); double[] adouble = par1ArrayOfDouble; int i = par1ArrayOfDouble.length; - for (int j = 0; j < i; ++j) - { + for (int j = 0; j < i; ++j) { double d1 = adouble[j]; nbttaglist.appendTag(new NBTTagDouble(d1)); } @@ -140,22 +140,22 @@ public class GuiNpcMobSpawnerSelector extends SubGuiInterface implements IGuiDat return nbttaglist; } - @Override - public void save() { + @Override + public void save() { - } + } - @Override - public void setGuiData(NBTTagCompound compound) { - NBTTagList nbtlist = compound.getTagList("List", 8); - List list = new ArrayList(); - for(int i = 0; i < nbtlist.tagCount(); i++){ - list.add(nbtlist.getStringTagAt(i)); - } - this.list = list; + @Override + public void setGuiData(NBTTagCompound compound) { + NBTTagList nbtlist = compound.getTagList("List", 8); + List list = new ArrayList(); + for (int i = 0; i < nbtlist.tagCount(); i++) { + list.add(nbtlist.getStringTagAt(i)); + } + this.list = list; scroll.setList(getSearchList()); - } + } } diff --git a/src/main/java/noppes/npcs/client/gui/GuiNpcPather.java b/src/main/java/noppes/npcs/client/gui/GuiNpcPather.java index 7bb61e1c3..6f81da73b 100644 --- a/src/main/java/noppes/npcs/client/gui/GuiNpcPather.java +++ b/src/main/java/noppes/npcs/client/gui/GuiNpcPather.java @@ -17,111 +17,109 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; -public class GuiNpcPather extends GuiNPCInterface implements IGuiData{ +public class GuiNpcPather extends GuiNPCInterface implements IGuiData { private GuiCustomScroll scroll; private HashMap data = new HashMap(); private DataAI ai; - public GuiNpcPather(EntityNPCInterface npc) { - super(); - drawDefaultBackground = false; + public GuiNpcPather(EntityNPCInterface npc) { + super(); + drawDefaultBackground = false; xSize = 176; title = "Npc Pather"; setBackground("smallbg.png"); ai = npc.ais; PacketClient.sendClient(new MovingPathGetPacket()); - } - @Override - public void initGui() - { + } + + @Override + public void initGui() { super.initGui(); - scroll = new GuiCustomScroll(this,0); + scroll = new GuiCustomScroll(this, 0); scroll.setSize(160, 164); List list = new ArrayList(); - for(int[] arr: ai.getMovingPath()){ - list.add("x:" + arr[0] + " y:" + arr[1] + " z:" + arr[2]); + for (int[] arr : ai.getMovingPath()) { + list.add("x:" + arr[0] + " y:" + arr[1] + " z:" + arr[2]); } scroll.setUnsortedList(list); scroll.guiLeft = guiLeft + 7; scroll.guiTop = guiTop + 12; addScroll(scroll); - this.addButton(new GuiNpcButton(0, guiLeft + 6, guiTop + 178,52,20, "gui.down")); - this.addButton(new GuiNpcButton(1, guiLeft + 62, guiTop + 178,52,20, "gui.up")); - this.addButton(new GuiNpcButton(2, guiLeft + 118, guiTop + 178,52,20, "selectWorld.deleteButton")); + this.addButton(new GuiNpcButton(0, guiLeft + 6, guiTop + 178, 52, 20, "gui.down")); + this.addButton(new GuiNpcButton(1, guiLeft + 62, guiTop + 178, 52, 20, "gui.up")); + this.addButton(new GuiNpcButton(2, guiLeft + 118, guiTop + 178, 52, 20, "selectWorld.deleteButton")); } - protected void actionPerformed(GuiButton guibutton) - { - if(scroll.selected < 0) - return; + protected void actionPerformed(GuiButton guibutton) { + if (scroll.selected < 0) + return; - int id = guibutton.id; - if(id == 0){ - List list = ai.getMovingPath(); - int selected = scroll.selected; - if(list.size() <= selected + 1) - return; - int[] a = list.get(selected); - int[] b = list.get(selected + 1); - list.set(selected, b); - list.set(selected + 1, a); - ai.setMovingPath(list); - initGui(); - scroll.selected = selected + 1; - } - if(id == 1){ - if(scroll.selected - 1 < 0) - return; - List list = ai.getMovingPath(); - int selected = scroll.selected; - int[] a = list.get(selected); - int[] b = list.get(selected - 1); - list.set(selected, b); - list.set(selected - 1, a); - ai.setMovingPath(list); - initGui(); - scroll.selected = selected - 1; - } - if(id == 2){ - List list = ai.getMovingPath(); - if(list.size() <= 1) - return; - list.remove(scroll.selected); - ai.setMovingPath(list); - initGui(); - } + int id = guibutton.id; + if (id == 0) { + List list = ai.getMovingPath(); + int selected = scroll.selected; + if (list.size() <= selected + 1) + return; + int[] a = list.get(selected); + int[] b = list.get(selected + 1); + list.set(selected, b); + list.set(selected + 1, a); + ai.setMovingPath(list); + initGui(); + scroll.selected = selected + 1; + } + if (id == 1) { + if (scroll.selected - 1 < 0) + return; + List list = ai.getMovingPath(); + int selected = scroll.selected; + int[] a = list.get(selected); + int[] b = list.get(selected - 1); + list.set(selected, b); + list.set(selected - 1, a); + ai.setMovingPath(list); + initGui(); + scroll.selected = selected - 1; + } + if (id == 2) { + List list = ai.getMovingPath(); + if (list.size() <= 1) + return; + list.remove(scroll.selected); + ai.setMovingPath(list); + initGui(); + } } - protected void drawGuiContainerBackgroundLayer(float f, int i, int j) - { + + protected void drawGuiContainerBackgroundLayer(float f, int i, int j) { } + @Override - public void mouseClicked(int i, int j, int k) - { - super.mouseClicked(i, j, k); - scroll.mouseClicked(i, j, k); + public void mouseClicked(int i, int j, int k) { + super.mouseClicked(i, j, k); + scroll.mouseClicked(i, j, k); } + @Override - public void keyTyped(char c, int i) - { - if (i == 1 || isInventoryKey(i)) - { + public void keyTyped(char c, int i) { + if (i == 1 || isInventoryKey(i)) { close(); } } - @Override - public void save() { - NBTTagCompound compound = new NBTTagCompound(); - compound.setTag("MovingPathNew", NBTTags.nbtIntegerArraySet(ai.getMovingPath())); + @Override + public void save() { + NBTTagCompound compound = new NBTTagCompound(); + compound.setTag("MovingPathNew", NBTTags.nbtIntegerArraySet(ai.getMovingPath())); PacketClient.sendClient(new MovingPathSavePacket(compound)); - } + } - @Override - public void setGuiData(NBTTagCompound compound) { - ai.readToNBT(compound); - initGui(); - } + @Override + public void setGuiData(NBTTagCompound compound) { + ai.readToNBT(compound); + initGui(); + } } diff --git a/src/main/java/noppes/npcs/client/gui/GuiNpcRedstoneBlock.java b/src/main/java/noppes/npcs/client/gui/GuiNpcRedstoneBlock.java index 9c81a1286..1f4abf0c7 100644 --- a/src/main/java/noppes/npcs/client/gui/GuiNpcRedstoneBlock.java +++ b/src/main/java/noppes/npcs/client/gui/GuiNpcRedstoneBlock.java @@ -12,110 +12,109 @@ import noppes.npcs.client.gui.util.GuiNpcLabel; import noppes.npcs.client.gui.util.GuiNpcTextField; -public class GuiNpcRedstoneBlock extends GuiNPCInterface{ +public class GuiNpcRedstoneBlock extends GuiNPCInterface { - private TileRedstoneBlock tile; + private TileRedstoneBlock tile; public GuiNpcRedstoneBlock(int x, int y, int z) { - super(); - tile = (TileRedstoneBlock) player.worldObj.getTileEntity(x, y, z); - } - - @Override - public void initGui(){ - super.initGui(); - - this.addButton(new GuiNpcButton(4, guiLeft + 40, guiTop + 20, 120, 20, "availability.options")); - - addLabel(new GuiNpcLabel(11,"gui.detailed", guiLeft+ 40, guiTop + 47, 0xffffff)); - this.addButton(new GuiNpcButton(1, guiLeft + 110, guiTop + 42, 50, 20, new String[]{"gui.no", "gui.yes"},tile.isDetailed?1:0)); - - if(tile.isDetailed){ - addLabel(new GuiNpcLabel(0,StatCollector.translateToLocal("bard.ondistance") + " X:", guiLeft+ 1, guiTop + 76, 0xffffff)); - addTextField(new GuiNpcTextField(0, this, fontRendererObj, guiLeft+ 80, guiTop + 71,30,20, tile.onRangeX + "")); - getTextField(0).integersOnly = true; - getTextField(0).setMinMaxDefault(0, 50, 6); - addLabel(new GuiNpcLabel(1,"Y:", guiLeft+ 113, guiTop + 76, 0xffffff)); - addTextField(new GuiNpcTextField(1, this, fontRendererObj, guiLeft+ 122, guiTop + 71,30,20, tile.onRangeY + "")); - getTextField(1).integersOnly = true; - getTextField(1).setMinMaxDefault(0, 50, 6); - addLabel(new GuiNpcLabel(2,"Z:", guiLeft+ 155, guiTop + 76, 0xffffff)); - addTextField(new GuiNpcTextField(2, this, fontRendererObj, guiLeft+ 164, guiTop + 71,30,20, tile.onRangeZ + "")); - getTextField(2).integersOnly = true; - getTextField(2).setMinMaxDefault(0, 50, 6); - - addLabel(new GuiNpcLabel(3,StatCollector.translateToLocal("bard.offdistance") + " X:", guiLeft - 3, guiTop + 99, 0xffffff)); - addTextField(new GuiNpcTextField(3, this, fontRendererObj, guiLeft+ 80, guiTop + 94,30,20, tile.offRangeX + "")); - getTextField(3).integersOnly = true; - getTextField(3).setMinMaxDefault(0, 50, 10); - addLabel(new GuiNpcLabel(4,"Y:", guiLeft+ 113, guiTop + 99, 0xffffff)); - addTextField(new GuiNpcTextField(4, this, fontRendererObj, guiLeft+ 122, guiTop + 94,30,20, tile.offRangeY + "")); - getTextField(4).integersOnly = true; - getTextField(4).setMinMaxDefault(0, 50, 10); - addLabel(new GuiNpcLabel(5,"Z:", guiLeft+ 155, guiTop + 99, 0xffffff)); - addTextField(new GuiNpcTextField(5, this, fontRendererObj, guiLeft+ 164, guiTop + 94,30,20, tile.offRangeZ + "")); - getTextField(5).integersOnly = true; - getTextField(5).setMinMaxDefault(0, 50, 10); - } - else{ - addLabel(new GuiNpcLabel(0,"bard.ondistance", guiLeft+ 1, guiTop + 76, 0xffffff)); - addTextField(new GuiNpcTextField(0, this, fontRendererObj, guiLeft+ 80, guiTop + 71,30,20, tile.onRange + "")); - getTextField(0).integersOnly = true; - getTextField(0).setMinMaxDefault(0, 50, 6); - - addLabel(new GuiNpcLabel(3,"bard.offdistance", guiLeft - 3, guiTop + 99, 0xffffff)); - addTextField(new GuiNpcTextField(3, this, fontRendererObj, guiLeft+ 80, guiTop + 94,30,20, tile.offRange + "")); - getTextField(3).integersOnly = true; - getTextField(3).setMinMaxDefault(0, 50, 10); - } - addButton(new GuiNpcButton(0, guiLeft + 40, guiTop + 190,120,20, "Done")); + super(); + tile = (TileRedstoneBlock) player.worldObj.getTileEntity(x, y, z); } @Override - protected void actionPerformed(GuiButton guibutton) { - int id = guibutton.id; - if(id == 0) - close(); - if(id == 1){ - tile.isDetailed = ((GuiNpcButton)guibutton).getValue() == 1; - initGui(); - } - if (id == 4) { - save(); - setSubGui(new SubGuiNpcAvailability(tile.availability)); - } - } - @Override - public void save() { - if(tile == null) - return; - if(tile.isDetailed){ - tile.onRangeX = getTextField(0).getInteger(); - tile.onRangeY = getTextField(1).getInteger(); - tile.onRangeZ = getTextField(2).getInteger(); + public void initGui() { + super.initGui(); - tile.offRangeX = getTextField(3).getInteger(); - tile.offRangeY = getTextField(4).getInteger(); - tile.offRangeZ = getTextField(5).getInteger(); + this.addButton(new GuiNpcButton(4, guiLeft + 40, guiTop + 20, 120, 20, "availability.options")); - if(tile.onRangeX > tile.offRangeX) - tile.offRangeX = tile.onRangeX; - if(tile.onRangeY > tile.offRangeY) - tile.offRangeY = tile.onRangeY; - if(tile.onRangeZ > tile.offRangeZ) - tile.offRangeZ = tile.onRangeZ; - } - else{ - tile.onRange = getTextField(0).getInteger(); - tile.offRange = getTextField(3).getInteger(); - if(tile.onRange > tile.offRange) - tile.offRange = tile.onRange; - } - tile.isActivated = false; + addLabel(new GuiNpcLabel(11, "gui.detailed", guiLeft + 40, guiTop + 47, 0xffffff)); + this.addButton(new GuiNpcButton(1, guiLeft + 110, guiTop + 42, 50, 20, new String[]{"gui.no", "gui.yes"}, tile.isDetailed ? 1 : 0)); - NBTTagCompound compound = new NBTTagCompound(); - tile.writeToNBT(compound); + if (tile.isDetailed) { + addLabel(new GuiNpcLabel(0, StatCollector.translateToLocal("bard.ondistance") + " X:", guiLeft + 1, guiTop + 76, 0xffffff)); + addTextField(new GuiNpcTextField(0, this, fontRendererObj, guiLeft + 80, guiTop + 71, 30, 20, tile.onRangeX + "")); + getTextField(0).integersOnly = true; + getTextField(0).setMinMaxDefault(0, 50, 6); + addLabel(new GuiNpcLabel(1, "Y:", guiLeft + 113, guiTop + 76, 0xffffff)); + addTextField(new GuiNpcTextField(1, this, fontRendererObj, guiLeft + 122, guiTop + 71, 30, 20, tile.onRangeY + "")); + getTextField(1).integersOnly = true; + getTextField(1).setMinMaxDefault(0, 50, 6); + addLabel(new GuiNpcLabel(2, "Z:", guiLeft + 155, guiTop + 76, 0xffffff)); + addTextField(new GuiNpcTextField(2, this, fontRendererObj, guiLeft + 164, guiTop + 71, 30, 20, tile.onRangeZ + "")); + getTextField(2).integersOnly = true; + getTextField(2).setMinMaxDefault(0, 50, 6); + + addLabel(new GuiNpcLabel(3, StatCollector.translateToLocal("bard.offdistance") + " X:", guiLeft - 3, guiTop + 99, 0xffffff)); + addTextField(new GuiNpcTextField(3, this, fontRendererObj, guiLeft + 80, guiTop + 94, 30, 20, tile.offRangeX + "")); + getTextField(3).integersOnly = true; + getTextField(3).setMinMaxDefault(0, 50, 10); + addLabel(new GuiNpcLabel(4, "Y:", guiLeft + 113, guiTop + 99, 0xffffff)); + addTextField(new GuiNpcTextField(4, this, fontRendererObj, guiLeft + 122, guiTop + 94, 30, 20, tile.offRangeY + "")); + getTextField(4).integersOnly = true; + getTextField(4).setMinMaxDefault(0, 50, 10); + addLabel(new GuiNpcLabel(5, "Z:", guiLeft + 155, guiTop + 99, 0xffffff)); + addTextField(new GuiNpcTextField(5, this, fontRendererObj, guiLeft + 164, guiTop + 94, 30, 20, tile.offRangeZ + "")); + getTextField(5).integersOnly = true; + getTextField(5).setMinMaxDefault(0, 50, 10); + } else { + addLabel(new GuiNpcLabel(0, "bard.ondistance", guiLeft + 1, guiTop + 76, 0xffffff)); + addTextField(new GuiNpcTextField(0, this, fontRendererObj, guiLeft + 80, guiTop + 71, 30, 20, tile.onRange + "")); + getTextField(0).integersOnly = true; + getTextField(0).setMinMaxDefault(0, 50, 6); + + addLabel(new GuiNpcLabel(3, "bard.offdistance", guiLeft - 3, guiTop + 99, 0xffffff)); + addTextField(new GuiNpcTextField(3, this, fontRendererObj, guiLeft + 80, guiTop + 94, 30, 20, tile.offRange + "")); + getTextField(3).integersOnly = true; + getTextField(3).setMinMaxDefault(0, 50, 10); + } + addButton(new GuiNpcButton(0, guiLeft + 40, guiTop + 190, 120, 20, "Done")); + } + + @Override + protected void actionPerformed(GuiButton guibutton) { + int id = guibutton.id; + if (id == 0) + close(); + if (id == 1) { + tile.isDetailed = ((GuiNpcButton) guibutton).getValue() == 1; + initGui(); + } + if (id == 4) { + save(); + setSubGui(new SubGuiNpcAvailability(tile.availability)); + } + } + + @Override + public void save() { + if (tile == null) + return; + if (tile.isDetailed) { + tile.onRangeX = getTextField(0).getInteger(); + tile.onRangeY = getTextField(1).getInteger(); + tile.onRangeZ = getTextField(2).getInteger(); + + tile.offRangeX = getTextField(3).getInteger(); + tile.offRangeY = getTextField(4).getInteger(); + tile.offRangeZ = getTextField(5).getInteger(); + + if (tile.onRangeX > tile.offRangeX) + tile.offRangeX = tile.onRangeX; + if (tile.onRangeY > tile.offRangeY) + tile.offRangeY = tile.onRangeY; + if (tile.onRangeZ > tile.offRangeZ) + tile.offRangeZ = tile.onRangeZ; + } else { + tile.onRange = getTextField(0).getInteger(); + tile.offRange = getTextField(3).getInteger(); + if (tile.onRange > tile.offRange) + tile.offRange = tile.onRange; + } + tile.isActivated = false; + + NBTTagCompound compound = new NBTTagCompound(); + tile.writeToNBT(compound); PacketClient.sendClient(new TileEntitySavePacket(compound)); - } + } } diff --git a/src/main/java/noppes/npcs/client/gui/GuiNpcRemoteEditor.java b/src/main/java/noppes/npcs/client/gui/GuiNpcRemoteEditor.java index 5eb74dde9..2e92d8cce 100644 --- a/src/main/java/noppes/npcs/client/gui/GuiNpcRemoteEditor.java +++ b/src/main/java/noppes/npcs/client/gui/GuiNpcRemoteEditor.java @@ -17,25 +17,25 @@ import java.util.HashMap; import java.util.List; import java.util.Vector; -public class GuiNpcRemoteEditor extends GuiNPCInterface implements IScrollData, GuiYesNoCallback{ +public class GuiNpcRemoteEditor extends GuiNPCInterface implements IScrollData, GuiYesNoCallback { private GuiCustomScroll scroll; private HashMap data = new HashMap(); private String search = ""; - public GuiNpcRemoteEditor() { - super(); + public GuiNpcRemoteEditor() { + super(); xSize = 256; setBackground("menubg.png"); PacketClient.sendClient(new RemoteNpcsGetPacket()); PacketClient.sendClient(new RemoteFreezeGetPacket()); - } - public void initGui() - { + } + + public void initGui() { super.initGui(); - if(scroll == null){ - scroll = new GuiCustomScroll(this,0, 0); - scroll.setSize(165, 188); + if (scroll == null) { + scroll = new GuiCustomScroll(this, 0, 0); + scroll.setSize(165, 188); } scroll.guiLeft = guiLeft + 4; scroll.guiTop = guiTop + 4; @@ -48,118 +48,117 @@ public class GuiNpcRemoteEditor extends GuiNPCInterface implements IScrollData, this.addLabel(new GuiNpcLabel(0, title, guiLeft + x, guiTop - 8)); - this.addButton(new GuiNpcButton(0, guiLeft + 170, guiTop + 6,82,20, "selectServer.edit")); - this.addButton(new GuiNpcButton(1, guiLeft + 170, guiTop + 28,82,20, "selectWorld.deleteButton")); - this.addButton(new GuiNpcButton(2, guiLeft + 170, guiTop + 50,82,20, "remote.reset")); - this.addButton(new GuiNpcButton(3, guiLeft + 170, guiTop + 132,82,20, "remote.freeze")); - this.addButton(new GuiNpcButton(4, guiLeft + 170, guiTop + 72,82,20, "remote.tp")); - this.addButton(new GuiNpcButton(5, guiLeft + 170, guiTop + 110,82,20, "remote.resetall")); - this.addButton(new GuiNpcButton(6, guiLeft + 170, guiTop + 165,82,20, "menu.global")); + this.addButton(new GuiNpcButton(0, guiLeft + 170, guiTop + 6, 82, 20, "selectServer.edit")); + this.addButton(new GuiNpcButton(1, guiLeft + 170, guiTop + 28, 82, 20, "selectWorld.deleteButton")); + this.addButton(new GuiNpcButton(2, guiLeft + 170, guiTop + 50, 82, 20, "remote.reset")); + this.addButton(new GuiNpcButton(3, guiLeft + 170, guiTop + 132, 82, 20, "remote.freeze")); + this.addButton(new GuiNpcButton(4, guiLeft + 170, guiTop + 72, 82, 20, "remote.tp")); + this.addButton(new GuiNpcButton(5, guiLeft + 170, guiTop + 110, 82, 20, "remote.resetall")); + this.addButton(new GuiNpcButton(6, guiLeft + 170, guiTop + 165, 82, 20, "menu.global")); } @Override - public void confirmClicked(boolean flag, int i){ - if(flag){ + public void confirmClicked(boolean flag, int i) { + if (flag) { PacketClient.sendClient(new RemoteDeletePacket(data.get(scroll.getSelected()))); - } - NoppesUtil.openGUI(player, this); + } + NoppesUtil.openGUI(player, this); } - protected void actionPerformed(GuiButton guibutton) - { - int id = guibutton.id; - if(id == 3){ + + protected void actionPerformed(GuiButton guibutton) { + int id = guibutton.id; + if (id == 3) { PacketClient.sendClient(new RemoteFreezePacket()); - } - if(id == 5){ - for(int ids : data.values()){ + } + if (id == 5) { + for (int ids : data.values()) { PacketClient.sendClient(new RemoteResetPacket(ids)); - Entity entity = player.worldObj.getEntityByID(ids); - if(entity != null && entity instanceof EntityNPCInterface) - ((EntityNPCInterface)entity).reset(); - } - } - if(id == 6){ - NoppesUtil.setLastNpc(null); + Entity entity = player.worldObj.getEntityByID(ids); + if (entity != null && entity instanceof EntityNPCInterface) + ((EntityNPCInterface) entity).reset(); + } + } + if (id == 6) { + NoppesUtil.setLastNpc(null); PacketClient.sendClient(new RemoteGlobalMenuPacket()); - } + } - if(!data.containsKey(scroll.getSelected())) - return; + if (!data.containsKey(scroll.getSelected())) + return; - if(id == 0){ + if (id == 0) { PacketClient.sendClient(new RemoteMainMenuPacket(data.get(scroll.getSelected()))); - } - if(id == 1){ + } + if (id == 1) { GuiYesNo guiyesno = new GuiYesNo(this, "Confirm", StatCollector.translateToLocal("gui.delete"), 0); displayGuiScreen(guiyesno); - } - if(id == 2){ + } + if (id == 2) { int selected = data.get(scroll.getSelected()); PacketClient.sendClient(new RemoteResetPacket(selected)); - Entity entity = player.worldObj.getEntityByID(selected); - if(entity != null && entity instanceof EntityNPCInterface) - ((EntityNPCInterface)entity).reset(); - } - if(id == 4){ + Entity entity = player.worldObj.getEntityByID(selected); + if (entity != null && entity instanceof EntityNPCInterface) + ((EntityNPCInterface) entity).reset(); + } + if (id == 4) { PacketClient.sendClient(new RemoteTpToNpcPacket(data.get(scroll.getSelected()))); - close(); - } + close(); + } } @Override - public void mouseClicked(int i, int j, int k) - { - super.mouseClicked(i, j, k); - scroll.mouseClicked(i, j, k); + public void mouseClicked(int i, int j, int k) { + super.mouseClicked(i, j, k); + scroll.mouseClicked(i, j, k); } + @Override - public void keyTyped(char c, int i) - { + public void keyTyped(char c, int i) { super.keyTyped(c, i); - if(getTextField(66) != null){ - if(getTextField(66).isFocused()){ - if (i == 1) - { + if (getTextField(66) != null) { + if (getTextField(66).isFocused()) { + if (i == 1) { close(); return; } - if(search.equals(getTextField(66).getText())) + if (search.equals(getTextField(66).getText())) return; search = getTextField(66).getText().toLowerCase(); scroll.resetScroll(); scroll.setList(getNPCSearch()); } } - if (i == 1) - { + if (i == 1) { close(); } } - private List getNPCSearch(){ - if(search.isEmpty()){ + private List getNPCSearch() { + if (search.isEmpty()) { return new ArrayList(this.data.keySet()); } List list = new ArrayList(); - for(String name : this.data.keySet()){ - if(name.toLowerCase().contains(search)) + for (String name : this.data.keySet()) { + if (name.toLowerCase().contains(search)) list.add(name); } return list; } - @Override - public void save() {} + @Override + public void save() { + } - @Override - public void setData(Vector list, HashMap data, EnumScrollData type) { + @Override + public void setData(Vector list, HashMap data, EnumScrollData type) { this.data = data; scroll.resetScroll(); scroll.setList(getNPCSearch()); - } - @Override - public void setSelected(String selected) { - getButton(3).setDisplayText(selected); - } + } + + @Override + public void setSelected(String selected) { + getButton(3).setDisplayText(selected); + } } diff --git a/src/main/java/noppes/npcs/client/gui/GuiNpcSelectionInterface.java b/src/main/java/noppes/npcs/client/gui/GuiNpcSelectionInterface.java index 1604ce225..aeb2346be 100644 --- a/src/main/java/noppes/npcs/client/gui/GuiNpcSelectionInterface.java +++ b/src/main/java/noppes/npcs/client/gui/GuiNpcSelectionInterface.java @@ -12,108 +12,106 @@ import java.util.Collections; import java.util.HashSet; import java.util.Vector; -public abstract class GuiNpcSelectionInterface extends GuiNPCInterface{ - public GuiNPCStringSlot slot; - public GuiScreen parent; - - private String up = "..<" + StatCollector.translateToLocal("gui.up") + ">.."; +public abstract class GuiNpcSelectionInterface extends GuiNPCInterface { + public GuiNPCStringSlot slot; + public GuiScreen parent; - private String root = ""; - public AssetsBrowser assets; - private HashSet dataFolder = new HashSet(); - protected HashSet dataTextures = new HashSet(); - - public GuiNpcSelectionInterface(EntityNPCInterface npc, GuiScreen parent, String sound){ - super(npc); - root = AssetsBrowser.getRoot(sound); - assets = new AssetsBrowser(root, getExtension()); - drawDefaultBackground = false; - title = ""; - this.parent = parent; + private String up = "..<" + StatCollector.translateToLocal("gui.up") + ">.."; + + private String root = ""; + public AssetsBrowser assets; + private HashSet dataFolder = new HashSet(); + protected HashSet dataTextures = new HashSet(); + + public GuiNpcSelectionInterface(EntityNPCInterface npc, GuiScreen parent, String sound) { + super(npc); + root = AssetsBrowser.getRoot(sound); + assets = new AssetsBrowser(root, getExtension()); + drawDefaultBackground = false; + title = ""; + this.parent = parent; } @Override - public void initGui(){ + public void initGui() { super.initGui(); dataFolder.clear(); String ss = "Current Folder: /assets" + root; - addLabel(new GuiNpcLabel(0,ss, width / 2 - (this.fontRendererObj.getStringWidth(ss)/2), 20, 0xffffff)); + addLabel(new GuiNpcLabel(0, ss, width / 2 - (this.fontRendererObj.getStringWidth(ss) / 2), 20, 0xffffff)); Vector list = new Vector(); - if(!assets.isRoot) - list.add(up); - for(String folder : assets.folders){ - list.add("/" + folder); - dataFolder.add("/" + folder); + if (!assets.isRoot) + list.add(up); + for (String folder : assets.folders) { + list.add("/" + folder); + dataFolder.add("/" + folder); } - for(String texture : assets.files){ - list.add(texture); - dataTextures.add(texture); + for (String texture : assets.files) { + list.add(texture); + dataTextures.add(texture); } - Collections.sort(list,String.CASE_INSENSITIVE_ORDER); - slot = new GuiNPCStringSlot(list,this,false,18); + Collections.sort(list, String.CASE_INSENSITIVE_ORDER); + slot = new GuiNPCStringSlot(list, this, false, 18); slot.registerScrollButtons(4, 5); - this.addButton(new GuiNpcButton(2, width / 2 - 100, height - 44,98, 20, "gui.back")); - this.addButton(new GuiNpcButton(3, width / 2 + 2, height - 44,98, 20, "gui.up")); - getButton(3).enabled = !assets.isRoot; + this.addButton(new GuiNpcButton(2, width / 2 - 100, height - 44, 98, 20, "gui.back")); + this.addButton(new GuiNpcButton(3, width / 2 + 2, height - 44, 98, 20, "gui.up")); + getButton(3).enabled = !assets.isRoot; } @Override - public void drawScreen(int i, int j, float f) - { - slot.drawScreen(i, j, f); + public void drawScreen(int i, int j, float f) { + slot.drawScreen(i, j, f); super.drawScreen(i, j, f); } - @Override - public void elementClicked(){ - if(slot.selected != null && this.dataTextures.contains(slot.selected)){ - if(parent instanceof GuiNPCInterface){ - ((GuiNPCInterface)parent).elementClicked(); - } - else if(parent instanceof GuiNPCInterface2){ - ((GuiNPCInterface2)parent).elementClicked(); - } - } - } - @Override - public void doubleClicked(){ - if(slot.selected.equals(up)){ - root = root.substring(0,root.lastIndexOf("/")); - assets = new AssetsBrowser(root, getExtension()); - initGui(); - } - else if(dataFolder.contains(slot.selected)){ - root += slot.selected; - assets = new AssetsBrowser(root, getExtension()); - initGui(); - } - else { - close(); - NoppesUtil.openGUI(player, parent); - } - } @Override - protected void actionPerformed(GuiButton guibutton){ - int id = guibutton.id; - if(id == 2){ - close(); - NoppesUtil.openGUI(player, parent); - } - if(id == 3){ - root = root.substring(0,root.lastIndexOf("/")); - assets = new AssetsBrowser(root, getExtension()); - initGui(); + public void elementClicked() { + if (slot.selected != null && this.dataTextures.contains(slot.selected)) { + if (parent instanceof GuiNPCInterface) { + ((GuiNPCInterface) parent).elementClicked(); + } else if (parent instanceof GuiNPCInterface2) { + ((GuiNPCInterface2) parent).elementClicked(); + } } } @Override - public void save() { - } - - public String getSelected(){ - return assets.getAsset(slot.selected); + public void doubleClicked() { + if (slot.selected.equals(up)) { + root = root.substring(0, root.lastIndexOf("/")); + assets = new AssetsBrowser(root, getExtension()); + initGui(); + } else if (dataFolder.contains(slot.selected)) { + root += slot.selected; + assets = new AssetsBrowser(root, getExtension()); + initGui(); + } else { + close(); + NoppesUtil.openGUI(player, parent); + } } - + + @Override + protected void actionPerformed(GuiButton guibutton) { + int id = guibutton.id; + if (id == 2) { + close(); + NoppesUtil.openGUI(player, parent); + } + if (id == 3) { + root = root.substring(0, root.lastIndexOf("/")); + assets = new AssetsBrowser(root, getExtension()); + initGui(); + } + } + + @Override + public void save() { + } + + public String getSelected() { + return assets.getAsset(slot.selected); + } + public abstract String[] getExtension(); } diff --git a/src/main/java/noppes/npcs/client/gui/GuiNpcTextureCloaks.java b/src/main/java/noppes/npcs/client/gui/GuiNpcTextureCloaks.java index c6039137b..442138a98 100644 --- a/src/main/java/noppes/npcs/client/gui/GuiNpcTextureCloaks.java +++ b/src/main/java/noppes/npcs/client/gui/GuiNpcTextureCloaks.java @@ -7,31 +7,27 @@ import net.minecraft.client.renderer.entity.RenderManager; import noppes.npcs.entity.EntityNPCInterface; import org.lwjgl.opengl.GL11; -public class GuiNpcTextureCloaks extends GuiNpcSelectionInterface -{ - public GuiNpcTextureCloaks(EntityNPCInterface npc,GuiScreen parent) - { - super(npc, parent, npc.display.cloakTexture.isEmpty()?"customnpcs:textures/cloak/":npc.display.cloakTexture); - title = "Select Cloak"; +public class GuiNpcTextureCloaks extends GuiNpcSelectionInterface { + public GuiNpcTextureCloaks(EntityNPCInterface npc, GuiScreen parent) { + super(npc, parent, npc.display.cloakTexture.isEmpty() ? "customnpcs:textures/cloak/" : npc.display.cloakTexture); + title = "Select Cloak"; } - public void initGui() - { + public void initGui() { super.initGui(); int index = npc.display.cloakTexture.lastIndexOf("/"); - if(index > 0){ - String asset = npc.display.cloakTexture.substring(index + 1); - if(npc.display.cloakTexture.equals(assets.getAsset(asset))) - slot.selected = asset; + if (index > 0) { + String asset = npc.display.cloakTexture.substring(index + 1); + if (npc.display.cloakTexture.equals(assets.getAsset(asset))) + slot.selected = asset; } } - public void drawScreen(int i, int j, float f) - { + public void drawScreen(int i, int j, float f) { npc.isDrawn = true; - int l = (width/2)-180; - int i1 = (height/2) - 90; + int l = (width / 2) - 180; + int i1 = (height / 2) - 90; GL11.glEnable(32826 /*GL_RESCALE_NORMAL_EXT*/); GL11.glEnable(2903 /*GL_COLOR_MATERIAL*/); GL11.glPushMatrix(); @@ -43,17 +39,17 @@ public class GuiNpcTextureCloaks extends GuiNpcSelectionInterface float f3 = npc.rotationYaw; float f4 = npc.rotationPitch; float f7 = npc.rotationYawHead; - float f5 = (float)(l + 33) - i; - float f6 = (float)((i1 + 131) - 50) - j; + float f5 = (float) (l + 33) - i; + float f6 = (float) ((i1 + 131) - 50) - j; GL11.glRotatef(135F, 0.0F, 1.0F, 0.0F); RenderHelper.enableStandardItemLighting(); GL11.glRotatef(-135F, 0.0F, 1.0F, 0.0F); - GL11.glRotatef(-(float)Math.atan(f6 / 40F) * 20F, 1.0F, 0.0F, 0.0F); - npc.renderYawOffset = (float)Math.atan(f5 / 40F) * 20F + 180; - npc.rotationYaw = (float)Math.atan(f5 / 40F) * 40f + 180; - npc.rotationPitch = -(float)Math.atan(f6 / 40F) * 20F; + GL11.glRotatef(-(float) Math.atan(f6 / 40F) * 20F, 1.0F, 0.0F, 0.0F); + npc.renderYawOffset = (float) Math.atan(f5 / 40F) * 20F + 180; + npc.rotationYaw = (float) Math.atan(f5 / 40F) * 40f + 180; + npc.rotationPitch = -(float) Math.atan(f6 / 40F) * 20F; npc.rotationYawHead = npc.rotationYaw; - npc.cloakUpdate(); + npc.cloakUpdate(); GL11.glTranslatef(0.0F, npc.yOffset, 0.0F); RenderManager.instance.playerViewY = 180F; RenderManager.instance.renderEntityWithPosYaw(npc, 0.0D, 0.0D, 0.0D, 0.0F, 1.0F); @@ -72,20 +68,21 @@ public class GuiNpcTextureCloaks extends GuiNpcSelectionInterface super.drawScreen(i, j, f); } + @Override - public void elementClicked(){ - if(dataTextures.contains(slot.selected) && slot.selected != null){ - npc.display.cloakTexture = assets.getAsset(slot.selected); - } + public void elementClicked() { + if (dataTextures.contains(slot.selected) && slot.selected != null) { + npc.display.cloakTexture = assets.getAsset(slot.selected); + } } - public void save() { - } + public void save() { + } - @Override - public String[] getExtension() { - return new String[]{"png"}; - } + @Override + public String[] getExtension() { + return new String[]{"png"}; + } } diff --git a/src/main/java/noppes/npcs/client/gui/GuiNpcTextureOverlays.java b/src/main/java/noppes/npcs/client/gui/GuiNpcTextureOverlays.java index 842fcdc11..77456f68d 100644 --- a/src/main/java/noppes/npcs/client/gui/GuiNpcTextureOverlays.java +++ b/src/main/java/noppes/npcs/client/gui/GuiNpcTextureOverlays.java @@ -8,30 +8,29 @@ import noppes.npcs.controllers.data.SkinOverlay; import noppes.npcs.entity.EntityNPCInterface; import org.lwjgl.opengl.GL11; -public class GuiNpcTextureOverlays extends GuiNpcSelectionInterface{ - public GuiNpcTextureOverlays(EntityNPCInterface npc,GuiScreen parent){ +public class GuiNpcTextureOverlays extends GuiNpcSelectionInterface { + public GuiNpcTextureOverlays(EntityNPCInterface npc, GuiScreen parent) { super(npc, parent, npc.display.skinOverlayData.overlayList.containsKey(0) ? !npc.display.skinOverlayData.overlayList.get(0).getTexture().isEmpty() ? npc.display.skinOverlayData.overlayList.get(0).getTexture() : "customnpcs:textures/overlays/" : "customnpcs:textures/overlays/"); title = "Select Overlay"; - this.parent = parent; + this.parent = parent; } - public void initGui(){ - super.initGui(); + public void initGui() { + super.initGui(); String str = npc.display.skinOverlayData.overlayList.containsKey(0) ? npc.display.skinOverlayData.overlayList.get(0).getTexture() : ""; int index = str.lastIndexOf("/"); - if(index > 0){ - String asset = str.substring(index + 1); - if(str.equals(assets.getAsset(asset))) - slot.selected = asset; + if (index > 0) { + String asset = str.substring(index + 1); + if (str.equals(assets.getAsset(asset))) + slot.selected = asset; } } - public void drawScreen(int i, int j, float f) - { + public void drawScreen(int i, int j, float f) { npc.isDrawn = true; - int l = (width/2)-180; - int i1 = (height/2) - 90; + int l = (width / 2) - 180; + int i1 = (height / 2) - 90; GL11.glEnable(32826 /*GL_RESCALE_NORMAL_EXT*/); GL11.glEnable(2903 /*GL_COLOR_MATERIAL*/); GL11.glPushMatrix(); @@ -43,15 +42,15 @@ public class GuiNpcTextureOverlays extends GuiNpcSelectionInterface{ float f3 = npc.rotationYaw; float f4 = npc.rotationPitch; float f7 = npc.rotationYawHead; - float f5 = (float)(l + 33) - i; - float f6 = (float)((i1 + 131) - 50) - j; + float f5 = (float) (l + 33) - i; + float f6 = (float) ((i1 + 131) - 50) - j; GL11.glRotatef(135F, 0.0F, 1.0F, 0.0F); RenderHelper.enableStandardItemLighting(); GL11.glRotatef(-135F, 0.0F, 1.0F, 0.0F); - GL11.glRotatef(-(float)Math.atan(f6 / 40F) * 20F, 1.0F, 0.0F, 0.0F); - npc.renderYawOffset = (float)Math.atan(f5 / 40F) * 20F; - npc.rotationYaw = (float)Math.atan(f5 / 40F) * 40F; - npc.rotationPitch = -(float)Math.atan(f6 / 40F) * 20F; + GL11.glRotatef(-(float) Math.atan(f6 / 40F) * 20F, 1.0F, 0.0F, 0.0F); + npc.renderYawOffset = (float) Math.atan(f5 / 40F) * 20F; + npc.rotationYaw = (float) Math.atan(f5 / 40F) * 40F; + npc.rotationPitch = -(float) Math.atan(f6 / 40F) * 20F; npc.rotationYawHead = npc.rotationYaw; //npc.updateCloak(); GL11.glTranslatef(0.0F, npc.yOffset, 0.0F); @@ -74,22 +73,22 @@ public class GuiNpcTextureOverlays extends GuiNpcSelectionInterface{ } @Override - public void elementClicked(){ - if(dataTextures.contains(slot.selected) && slot.selected != null){ - //npc.display.glowTexture = assets.getAsset(slot.selected); - //npc.textureGlowLocation = null; + public void elementClicked() { + if (dataTextures.contains(slot.selected) && slot.selected != null) { + //npc.display.glowTexture = assets.getAsset(slot.selected); + //npc.textureGlowLocation = null; - npc.display.skinOverlayData.overlayList.put(0,new SkinOverlay(assets.getAsset(slot.selected))); - } + npc.display.skinOverlayData.overlayList.put(0, new SkinOverlay(assets.getAsset(slot.selected))); + } } - public void save() { - } + public void save() { + } - @Override - public String[] getExtension() { - return new String[]{"png"}; - } + @Override + public String[] getExtension() { + return new String[]{"png"}; + } } diff --git a/src/main/java/noppes/npcs/client/gui/GuiNpcWaypoint.java b/src/main/java/noppes/npcs/client/gui/GuiNpcWaypoint.java index c0afa6aaf..f73f6de6b 100644 --- a/src/main/java/noppes/npcs/client/gui/GuiNpcWaypoint.java +++ b/src/main/java/noppes/npcs/client/gui/GuiNpcWaypoint.java @@ -11,43 +11,45 @@ import noppes.npcs.client.gui.util.GuiNpcLabel; import noppes.npcs.client.gui.util.GuiNpcTextField; -public class GuiNpcWaypoint extends GuiNPCInterface{ +public class GuiNpcWaypoint extends GuiNPCInterface { - private TileWaypoint tile; + private TileWaypoint tile; public GuiNpcWaypoint(int x, int y, int z) { - super(); - tile = (TileWaypoint) player.worldObj.getTileEntity(x, y, z); - xSize = 265; - } - public void initGui() - { - super.initGui(); - - - addLabel(new GuiNpcLabel(0,"gui.name", guiLeft+ 1, guiTop + 76, 0xffffff)); - addTextField(new GuiNpcTextField(0, this, fontRendererObj, guiLeft+ 60, guiTop + 71,200,20, tile.name)); - - addLabel(new GuiNpcLabel(1,"gui.range", guiLeft+ 1, guiTop + 97, 0xffffff)); - addTextField(new GuiNpcTextField(1, this, fontRendererObj, guiLeft+ 60, guiTop + 92,200,20, tile.range + "")); - getTextField(1).integersOnly = true; - getTextField(1).setMinMaxDefault(2, 60, 10); - - addButton(new GuiNpcButton(0, guiLeft + 40, guiTop + 190,120,20, "Done")); + super(); + tile = (TileWaypoint) player.worldObj.getTileEntity(x, y, z); + xSize = 265; } - protected void actionPerformed(GuiButton guibutton) { - int id = guibutton.id; - if(id == 0) - close(); - } - @Override - public void save() { - tile.name = getTextField(0).getText(); - tile.range = getTextField(1).getInteger(); - NBTTagCompound compound = new NBTTagCompound(); - tile.writeToNBT(compound); + public void initGui() { + super.initGui(); + + + addLabel(new GuiNpcLabel(0, "gui.name", guiLeft + 1, guiTop + 76, 0xffffff)); + addTextField(new GuiNpcTextField(0, this, fontRendererObj, guiLeft + 60, guiTop + 71, 200, 20, tile.name)); + + addLabel(new GuiNpcLabel(1, "gui.range", guiLeft + 1, guiTop + 97, 0xffffff)); + addTextField(new GuiNpcTextField(1, this, fontRendererObj, guiLeft + 60, guiTop + 92, 200, 20, tile.range + "")); + getTextField(1).integersOnly = true; + getTextField(1).setMinMaxDefault(2, 60, 10); + + addButton(new GuiNpcButton(0, guiLeft + 40, guiTop + 190, 120, 20, "Done")); + } + + protected void actionPerformed(GuiButton guibutton) { + int id = guibutton.id; + if (id == 0) + close(); + } + + @Override + public void save() { + tile.name = getTextField(0).getText(); + tile.range = getTextField(1).getInteger(); + + NBTTagCompound compound = new NBTTagCompound(); + tile.writeToNBT(compound); PacketClient.sendClient(new TileEntitySavePacket(compound)); - } + } } diff --git a/src/main/java/noppes/npcs/client/gui/GuiScript.java b/src/main/java/noppes/npcs/client/gui/GuiScript.java index d5025d87b..761354dd3 100644 --- a/src/main/java/noppes/npcs/client/gui/GuiScript.java +++ b/src/main/java/noppes/npcs/client/gui/GuiScript.java @@ -21,154 +21,152 @@ import noppes.npcs.entity.EntityNPCInterface; import java.util.*; public class GuiScript extends GuiNPCInterface implements IGuiData, GuiYesNoCallback, ICustomScrollListener, IJTextAreaListener, ITextChangeListener { - public boolean showScript = false; - private int activeTab = 0; - public DataScript script; - public Map> languages = new HashMap>(); + public boolean showScript = false; + private int activeTab = 0; + public DataScript script; + public Map> languages = new HashMap>(); - private static int activeConsole = 0; + private static int activeConsole = 0; - public GuiScript(EntityNPCInterface npc) { - super(npc); - script = npc.script; - drawDefaultBackground = true; - closeOnEsc = true; - xSize = 420; + public GuiScript(EntityNPCInterface npc) { + super(npc); + script = npc.script; + drawDefaultBackground = true; + closeOnEsc = true; + xSize = 420; - setBackground("menubg.png"); + setBackground("menubg.png"); NPCScriptPacket.Get(); - } + } - public void initGui() { - super.initGui(); - guiTop += 10; - GuiMenuTopButton top; - addTopButton(top = new GuiMenuTopButton(13, guiLeft + 4, guiTop - 17, "script.scripts")); - addTopButton(new GuiMenuTopButton(16, guiLeft + (xSize - 102), guiTop - 17, "eventscript.eventScripts")); - addTopButton(new GuiMenuTopButton(17, guiLeft + (xSize - 22), guiTop - 17, "X")); - top.active = showScript; - addTopButton(top = new GuiMenuTopButton(14, top, "gui.settings")); - top.active = !showScript; - addTopButton(new GuiMenuTopButton(15, top, "gui.website")); + public void initGui() { + super.initGui(); + guiTop += 10; + GuiMenuTopButton top; + addTopButton(top = new GuiMenuTopButton(13, guiLeft + 4, guiTop - 17, "script.scripts")); + addTopButton(new GuiMenuTopButton(16, guiLeft + (xSize - 102), guiTop - 17, "eventscript.eventScripts")); + addTopButton(new GuiMenuTopButton(17, guiLeft + (xSize - 22), guiTop - 17, "X")); + top.active = showScript; + addTopButton(top = new GuiMenuTopButton(14, top, "gui.settings")); + top.active = !showScript; + addTopButton(new GuiMenuTopButton(15, top, "gui.website")); - List list = new ArrayList(); - list.add("script.init"); - list.add("script.update"); - list.add("script.interact"); - list.add("dialog.dialog"); - list.add("script.damaged"); - list.add("script.killed"); - list.add("script.attack"); - list.add("script.target"); - list.add("script.collide"); - list.add("script.kills"); - list.add("script.dialog_closed"); - list.add("script.timer"); - list.add("script.targetLost"); - list.add("script.projectileTick"); - list.add("script.projectileImpact"); + List list = new ArrayList(); + list.add("script.init"); + list.add("script.update"); + list.add("script.interact"); + list.add("dialog.dialog"); + list.add("script.damaged"); + list.add("script.killed"); + list.add("script.attack"); + list.add("script.target"); + list.add("script.collide"); + list.add("script.kills"); + list.add("script.dialog_closed"); + list.add("script.timer"); + list.add("script.targetLost"); + list.add("script.projectileTick"); + list.add("script.projectileImpact"); - if(showScript){ - addLabel(new GuiNpcLabel(0, "script.hooks", guiLeft + 4, guiTop + 5)); - GuiCustomScroll hooks = new GuiCustomScroll(this, 1); - hooks.setSize(68, 198); - hooks.guiLeft = guiLeft + 4; - hooks.guiTop = guiTop + 14; - hooks.setUnsortedList(list); - hooks.selected = activeTab; - addScroll(hooks); + if (showScript) { + addLabel(new GuiNpcLabel(0, "script.hooks", guiLeft + 4, guiTop + 5)); + GuiCustomScroll hooks = new GuiCustomScroll(this, 1); + hooks.setSize(68, 198); + hooks.guiLeft = guiLeft + 4; + hooks.guiTop = guiTop + 14; + hooks.setUnsortedList(list); + hooks.selected = activeTab; + addScroll(hooks); - ScriptContainer container = script.getNPCScript(activeTab); + ScriptContainer container = script.getNPCScript(activeTab); - GuiScriptTextArea ta = new GuiScriptTextArea(this,2, guiLeft + 74, guiTop + 4, 239, 208, container == null?"":container.script); - ta.enableCodeHighlighting(); - ta.setListener(this); - this.addTextField(ta); + GuiScriptTextArea ta = new GuiScriptTextArea(this, 2, guiLeft + 74, guiTop + 4, 239, 208, container == null ? "" : container.script); + ta.enableCodeHighlighting(); + ta.setListener(this); + this.addTextField(ta); - addButton(new GuiNpcButton(102, guiLeft + 315, guiTop + 4, 50, 20, "gui.clear")); - addButton(new GuiNpcButton(101, guiLeft + 366, guiTop + 4, 50, 20, "gui.paste")); - addButton(new GuiNpcButton(100, guiLeft + 315, guiTop + 25, 50, 20, "gui.copy")); + addButton(new GuiNpcButton(102, guiLeft + 315, guiTop + 4, 50, 20, "gui.clear")); + addButton(new GuiNpcButton(101, guiLeft + 366, guiTop + 4, 50, 20, "gui.paste")); + addButton(new GuiNpcButton(100, guiLeft + 315, guiTop + 25, 50, 20, "gui.copy")); - addButton(new GuiNpcButton(107, guiLeft + 315, guiTop + 70, 80, 20, "script.loadscript")); + addButton(new GuiNpcButton(107, guiLeft + 315, guiTop + 70, 80, 20, "script.loadscript")); - GuiCustomScroll scroll = new GuiCustomScroll(this, 0).setUnselectable(); - scroll.setSize(100, 120); - scroll.guiLeft = guiLeft + 315; - scroll.guiTop = guiTop + 92; - if(container != null) - scroll.setList(container.scripts); - addScroll(scroll); - } - else{ - addLabel(new GuiNpcLabel(0, "script.console", guiLeft + 4, guiTop + 16)); - getTopButton(14).active = true; - addTextField(new GuiNpcTextArea(2, this, guiLeft + 4, guiTop + 26, 226, 186, getConsoleText())); - getTextField(2).canEdit = false; - addButton(new GuiNpcButton(100, guiLeft + 232, guiTop + 170, 56, 20, "gui.copy")); - addButton(new GuiNpcButton(102, guiLeft + 232, guiTop + 192, 56, 20, "gui.clear")); + GuiCustomScroll scroll = new GuiCustomScroll(this, 0).setUnselectable(); + scroll.setSize(100, 120); + scroll.guiLeft = guiLeft + 315; + scroll.guiTop = guiTop + 92; + if (container != null) + scroll.setList(container.scripts); + addScroll(scroll); + } else { + addLabel(new GuiNpcLabel(0, "script.console", guiLeft + 4, guiTop + 16)); + getTopButton(14).active = true; + addTextField(new GuiNpcTextArea(2, this, guiLeft + 4, guiTop + 26, 226, 186, getConsoleText())); + getTextField(2).canEdit = false; + addButton(new GuiNpcButton(100, guiLeft + 232, guiTop + 170, 56, 20, "gui.copy")); + addButton(new GuiNpcButton(102, guiLeft + 232, guiTop + 192, 56, 20, "gui.clear")); - List l = new ArrayList(); - l.add("All"); - l.addAll(list); - addButton(new GuiNpcButton(105, guiLeft + 60, guiTop + 4, 80, 20, l.toArray(new String[l.size()]), activeConsole)); + List l = new ArrayList(); + l.add("All"); + l.addAll(list); + addButton(new GuiNpcButton(105, guiLeft + 60, guiTop + 4, 80, 20, l.toArray(new String[l.size()]), activeConsole)); - addLabel(new GuiNpcLabel(1, "script.language", guiLeft + 232, guiTop + 30)); - addButton(new GuiNpcButton(103, guiLeft + 294, guiTop + 25, 80, 20, languages.keySet().toArray(new String[languages.keySet().size()]), getScriptIndex())); - getButton(103).enabled = languages.size() > 0; + addLabel(new GuiNpcLabel(1, "script.language", guiLeft + 232, guiTop + 30)); + addButton(new GuiNpcButton(103, guiLeft + 294, guiTop + 25, 80, 20, languages.keySet().toArray(new String[languages.keySet().size()]), getScriptIndex())); + getButton(103).enabled = languages.size() > 0; - addLabel(new GuiNpcLabel(2, "gui.enabled", guiLeft + 232, guiTop + 53)); - addButton(new GuiNpcButton(104, guiLeft + 294, guiTop + 48, 50, 20, new String[]{"gui.no","gui.yes"}, script.enabled?1:0)); + addLabel(new GuiNpcLabel(2, "gui.enabled", guiLeft + 232, guiTop + 53)); + addButton(new GuiNpcButton(104, guiLeft + 294, guiTop + 48, 50, 20, new String[]{"gui.no", "gui.yes"}, script.enabled ? 1 : 0)); - if(MinecraftServer.getServer() != null) - addButton(new GuiNpcButton(106, guiLeft + 232, guiTop + 71, 150, 20, "script.openfolder")); - } - } + if (MinecraftServer.getServer() != null) + addButton(new GuiNpcButton(106, guiLeft + 232, guiTop + 71, 150, 20, "script.openfolder")); + } + } - private int getScriptIndex() { - int i = 0; - for(String language : languages.keySet()){ - if(language.equalsIgnoreCase(script.scriptLanguage)) - return i; - i++; - } - return 0; - } + private int getScriptIndex() { + int i = 0; + for (String language : languages.keySet()) { + if (language.equalsIgnoreCase(script.scriptLanguage)) + return i; + i++; + } + return 0; + } - private String getConsoleText() { - Map map = this.script.getOldConsoleText(); - StringBuilder builder = new StringBuilder(); - Iterator var3 = map.entrySet().iterator(); + private String getConsoleText() { + Map map = this.script.getOldConsoleText(); + StringBuilder builder = new StringBuilder(); + Iterator var3 = map.entrySet().iterator(); - while(var3.hasNext()) { - Map.Entry entry = (Map.Entry)var3.next(); - builder.insert(0, new Date((Long)entry.getKey()) + (String)entry.getValue() + "\n"); - } + while (var3.hasNext()) { + Map.Entry entry = (Map.Entry) var3.next(); + builder.insert(0, new Date((Long) entry.getKey()) + (String) entry.getValue() + "\n"); + } - return builder.toString(); - } + return builder.toString(); + } @Override public void confirmClicked(boolean result, int id) { NoppesUtil.openGUI(player, this); - if(!result) + if (!result) return; - if(id == 0) { + if (id == 0) { openLink("https://kamkeel.github.io/CustomNPC-Plus/"); } - if(id == 101) { + if (id == 101) { getTextField(2).setText(NoppesStringUtils.getClipboardContents()); } - if(id == 102) { + if (id == 102) { getTextField(2).setText(""); - if(!showScript){ - if(activeConsole == 0){ - for(ScriptContainer container : script.getNPCScripts()) + if (!showScript) { + if (activeConsole == 0) { + for (ScriptContainer container : script.getNPCScripts()) container.console.clear(); - } - else{ + } else { ScriptContainer container = script.getNPCScript(activeConsole - 1); - if(container != null) + if (container != null) container.console.clear(); } } @@ -178,118 +176,118 @@ public class GuiScript extends GuiNPCInterface implements IGuiData, GuiYesNoCall displayGuiScreen(this); } - @Override - protected void actionPerformed(GuiButton guibutton) { - if(guibutton.id == 13){ - showScript = true; - initGui(); - } - if(guibutton.id == 14){ - setScript(); - showScript = false; - initGui(); - } - if(guibutton.id == 15){ - GuiConfirmOpenLink guiyesno = new GuiConfirmOpenLink(this, "https://kamkeel.github.io/CustomNPC-Plus/", 0, true); - mc.displayGuiScreen(guiyesno); - } - if(guibutton.id == 16){ - close(); - mc.displayGuiScreen(new GuiNPCEventScripts(npc)); - } - if(guibutton.id == 17){ - close(); - } - if (guibutton.id == 100) { - NoppesStringUtils.setClipboardContents(getTextField(2).getText()); - } - if (guibutton.id == 101) { + @Override + protected void actionPerformed(GuiButton guibutton) { + if (guibutton.id == 13) { + showScript = true; + initGui(); + } + if (guibutton.id == 14) { + setScript(); + showScript = false; + initGui(); + } + if (guibutton.id == 15) { + GuiConfirmOpenLink guiyesno = new GuiConfirmOpenLink(this, "https://kamkeel.github.io/CustomNPC-Plus/", 0, true); + mc.displayGuiScreen(guiyesno); + } + if (guibutton.id == 16) { + close(); + mc.displayGuiScreen(new GuiNPCEventScripts(npc)); + } + if (guibutton.id == 17) { + close(); + } + if (guibutton.id == 100) { + NoppesStringUtils.setClipboardContents(getTextField(2).getText()); + } + if (guibutton.id == 101) { GuiYesNo guiyesno = new GuiYesNo(this, StatCollector.translateToLocal("gui.paste"), StatCollector.translateToLocal("gui.sure"), 101); displayGuiScreen(guiyesno); - } - if (guibutton.id == 102) { + } + if (guibutton.id == 102) { GuiYesNo guiyesno = new GuiYesNo(this, StatCollector.translateToLocal("gui.clear"), StatCollector.translateToLocal("gui.sure"), 102); displayGuiScreen(guiyesno); - } - if (guibutton.id == 103) { - script.scriptLanguage = ((GuiNpcButton)guibutton).displayString; - } - if (guibutton.id == 104) { - script.enabled = ((GuiNpcButton)guibutton).getValue() == 1; - } - if (guibutton.id == 105) { - activeConsole = ((GuiNpcButton)guibutton).getValue(); - initGui(); - } - if (guibutton.id == 106) { - NoppesUtil.openFolder(ScriptController.Instance.dir); - } - if (guibutton.id == 107) { - ScriptContainer container = script.getNPCScript(activeTab); - if(container == null) - script.setNPCScript(activeTab, container = new ScriptContainer(this.script)); - setSubGui(new GuiScriptList(languages.get(script.scriptLanguage), container)); - } - } + } + if (guibutton.id == 103) { + script.scriptLanguage = ((GuiNpcButton) guibutton).displayString; + } + if (guibutton.id == 104) { + script.enabled = ((GuiNpcButton) guibutton).getValue() == 1; + } + if (guibutton.id == 105) { + activeConsole = ((GuiNpcButton) guibutton).getValue(); + initGui(); + } + if (guibutton.id == 106) { + NoppesUtil.openFolder(ScriptController.Instance.dir); + } + if (guibutton.id == 107) { + ScriptContainer container = script.getNPCScript(activeTab); + if (container == null) + script.setNPCScript(activeTab, container = new ScriptContainer(this.script)); + setSubGui(new GuiScriptList(languages.get(script.scriptLanguage), container)); + } + } - private void setScript(){ - if(showScript){ - ScriptContainer container = script.getNPCScript(activeTab); - if(container == null) - script.setNPCScript(activeTab, container = new ScriptContainer(this.script)); - String text = getTextField(2).getText(); - text = text.replace("\r\n", "\n"); - text = text.replace("\r", "\n"); - container.script = text; - } - } + private void setScript() { + if (showScript) { + ScriptContainer container = script.getNPCScript(activeTab); + if (container == null) + script.setNPCScript(activeTab, container = new ScriptContainer(this.script)); + String text = getTextField(2).getText(); + text = text.replace("\r\n", "\n"); + text = text.replace("\r", "\n"); + container.script = text; + } + } - @Override - public void setGuiData(NBTTagCompound compound) { - script.readFromNBT(compound); - NBTTagList data = compound.getTagList("Languages", 10); - Map> languages = new HashMap>(); - for(int i = 0; i < data.tagCount(); i++){ - NBTTagCompound comp = data.getCompoundTagAt(i); - List scripts = new ArrayList(); - NBTTagList list = comp.getTagList("Scripts", 8); - for(int j = 0; j < list.tagCount(); j++){ - scripts.add(list.getStringTagAt(j)); - } - languages.put(comp.getString("Language"), scripts); - } - this.languages = languages; - initGui(); - } + @Override + public void setGuiData(NBTTagCompound compound) { + script.readFromNBT(compound); + NBTTagList data = compound.getTagList("Languages", 10); + Map> languages = new HashMap>(); + for (int i = 0; i < data.tagCount(); i++) { + NBTTagCompound comp = data.getCompoundTagAt(i); + List scripts = new ArrayList(); + NBTTagList list = comp.getTagList("Scripts", 8); + for (int j = 0; j < list.tagCount(); j++) { + scripts.add(list.getStringTagAt(j)); + } + languages.put(comp.getString("Language"), scripts); + } + this.languages = languages; + initGui(); + } - @Override - public void save() { - setScript(); + @Override + public void save() { + setScript(); NPCScriptPacket.Save(script.writeToNBT(new NBTTagCompound())); - } + } - @Override - public void customScrollClicked(int i, int j, int k, GuiCustomScroll scroll) { - if(scroll.id == 1){ - setScript(); - activeTab = scroll.selected; - initGui(); - } - } + @Override + public void customScrollClicked(int i, int j, int k, GuiCustomScroll scroll) { + if (scroll.id == 1) { + setScript(); + activeTab = scroll.selected; + initGui(); + } + } - public void textUpdate(String text) { - ScriptContainer container = script.getNPCScript(activeTab); - if(container != null) - container.script = text; - } + public void textUpdate(String text) { + ScriptContainer container = script.getNPCScript(activeTab); + if (container != null) + container.script = text; + } - @Override - public void saveText(String text) { - ScriptContainer container = script.getNPCScript(activeTab); - if(container != null) - container.script = text; - initGui(); - } + @Override + public void saveText(String text) { + ScriptContainer container = script.getNPCScript(activeTab); + if (container != null) + container.script = text; + initGui(); + } } diff --git a/src/main/java/noppes/npcs/client/gui/GuiScriptList.java b/src/main/java/noppes/npcs/client/gui/GuiScriptList.java index c14c48139..0d03d13cd 100644 --- a/src/main/java/noppes/npcs/client/gui/GuiScriptList.java +++ b/src/main/java/noppes/npcs/client/gui/GuiScriptList.java @@ -10,36 +10,37 @@ import noppes.npcs.controllers.ScriptContainer; import java.util.ArrayList; import java.util.List; -public class GuiScriptList extends SubGuiInterface{ - private GuiCustomScroll scroll1; - private GuiCustomScroll scroll2; - private ScriptContainer container; - private List scripts; +public class GuiScriptList extends SubGuiInterface { + private GuiCustomScroll scroll1; + private GuiCustomScroll scroll2; + private ScriptContainer container; + private List scripts; - public GuiScriptList(List scripts, ScriptContainer container){ - this.container = container; - setBackground("menubg.png"); - xSize = 346; - ySize = 216; - if(scripts == null) - scripts = new ArrayList(); - this.scripts = scripts; - } - @Override - public void initGui(){ - super.initGui(); - if(scroll1 == null){ - scroll1 = new GuiCustomScroll(this,0); - scroll1.setSize(140, 180); + public GuiScriptList(List scripts, ScriptContainer container) { + this.container = container; + setBackground("menubg.png"); + xSize = 346; + ySize = 216; + if (scripts == null) + scripts = new ArrayList(); + this.scripts = scripts; + } + + @Override + public void initGui() { + super.initGui(); + if (scroll1 == null) { + scroll1 = new GuiCustomScroll(this, 0); + scroll1.setSize(140, 180); } scroll1.guiLeft = guiLeft + 4; scroll1.guiTop = guiTop + 14; this.addScroll(scroll1); addLabel(new GuiNpcLabel(1, "script.availableScripts", guiLeft + 4, guiTop + 4)); - if(scroll2 == null){ - scroll2 = new GuiCustomScroll(this,1); - scroll2.setSize(140, 180); + if (scroll2 == null) { + scroll2 = new GuiCustomScroll(this, 1); + scroll2.setSize(140, 180); } scroll2.guiLeft = guiLeft + 200; scroll2.guiTop = guiTop + 14; @@ -50,54 +51,55 @@ public class GuiScriptList extends SubGuiInterface{ scroll1.setList(temp); scroll2.setList(container.scripts); - addButton(new GuiNpcButton(1, guiLeft + 145, guiTop + 40, 55, 20, ">")); - addButton(new GuiNpcButton(2, guiLeft + 145, guiTop + 62, 55, 20, "<")); + addButton(new GuiNpcButton(1, guiLeft + 145, guiTop + 40, 55, 20, ">")); + addButton(new GuiNpcButton(2, guiLeft + 145, guiTop + 62, 55, 20, "<")); - addButton(new GuiNpcButton(3, guiLeft + 145, guiTop + 90, 55, 20, ">>")); - addButton(new GuiNpcButton(4, guiLeft + 145, guiTop + 112, 55, 20, "<<")); + addButton(new GuiNpcButton(3, guiLeft + 145, guiTop + 90, 55, 20, ">>")); + addButton(new GuiNpcButton(4, guiLeft + 145, guiTop + 112, 55, 20, "<<")); - addButton(new GuiNpcButton(66, guiLeft + 260, guiTop + 194, 60, 20, "gui.done")); - } + addButton(new GuiNpcButton(66, guiLeft + 260, guiTop + 194, 60, 20, "gui.done")); + } - protected void actionPerformed(GuiButton guibutton){ - GuiNpcButton button = (GuiNpcButton) guibutton; - if(button.id == 1){ - if(scroll1.hasSelected()){ - container.scripts.add(scroll1.getSelected()); - scroll1.selected = -1; - scroll2.selected = -1; - initGui(); - } - } - if(button.id == 2){ - if(scroll2.hasSelected()){ - container.scripts.remove(scroll2.getSelected()); - scroll2.selected = -1; - initGui(); - } - } - if(button.id == 3){ - container.scripts.clear(); - for(String script : scripts){ - container.scripts.add(script); - } - scroll1.selected = -1; - scroll2.selected = -1; - initGui(); - } - if(button.id == 4){ - container.scripts.clear(); - scroll1.selected = -1; - scroll2.selected = -1; - initGui(); - } - if(button.id == 66){ - close(); + protected void actionPerformed(GuiButton guibutton) { + GuiNpcButton button = (GuiNpcButton) guibutton; + if (button.id == 1) { + if (scroll1.hasSelected()) { + container.scripts.add(scroll1.getSelected()); + scroll1.selected = -1; + scroll2.selected = -1; + initGui(); + } + } + if (button.id == 2) { + if (scroll2.hasSelected()) { + container.scripts.remove(scroll2.getSelected()); + scroll2.selected = -1; + initGui(); + } + } + if (button.id == 3) { + container.scripts.clear(); + for (String script : scripts) { + container.scripts.add(script); + } + scroll1.selected = -1; + scroll2.selected = -1; + initGui(); + } + if (button.id == 4) { + container.scripts.clear(); + scroll1.selected = -1; + scroll2.selected = -1; + initGui(); + } + if (button.id == 66) { + close(); } } - @Override - public void save() { - } + @Override + public void save() { + + } } diff --git a/src/main/java/noppes/npcs/client/gui/SubGuiAnimationFrame.java b/src/main/java/noppes/npcs/client/gui/SubGuiAnimationFrame.java index 5f02d1254..f6b3e2b49 100644 --- a/src/main/java/noppes/npcs/client/gui/SubGuiAnimationFrame.java +++ b/src/main/java/noppes/npcs/client/gui/SubGuiAnimationFrame.java @@ -43,7 +43,7 @@ public class SubGuiAnimationFrame extends SubGuiInterface implements ITextfieldL return; } - int value = ((GuiNpcButton)guibutton).getValue(); + int value = ((GuiNpcButton) guibutton).getValue(); if (guibutton.id == 10) { editingFrame.setCustomized(!editingFrame.isCustomized()); } else if (guibutton.id == 12) { diff --git a/src/main/java/noppes/npcs/client/gui/SubGuiAnimationOptions.java b/src/main/java/noppes/npcs/client/gui/SubGuiAnimationOptions.java index 4c1a7a736..27921388b 100644 --- a/src/main/java/noppes/npcs/client/gui/SubGuiAnimationOptions.java +++ b/src/main/java/noppes/npcs/client/gui/SubGuiAnimationOptions.java @@ -34,7 +34,7 @@ public class SubGuiAnimationOptions extends SubGuiInterface { @Override protected void actionPerformed(GuiButton guibutton) { super.actionPerformed(guibutton); - int value = ((GuiNpcButton)guibutton).getValue(); + int value = ((GuiNpcButton) guibutton).getValue(); if (guibutton.id == 11) { animation.whileStanding = value == 0; diff --git a/src/main/java/noppes/npcs/client/gui/SubGuiClonerNPCTags.java b/src/main/java/noppes/npcs/client/gui/SubGuiClonerNPCTags.java index 05c38b5b8..5fbaf3bec 100644 --- a/src/main/java/noppes/npcs/client/gui/SubGuiClonerNPCTags.java +++ b/src/main/java/noppes/npcs/client/gui/SubGuiClonerNPCTags.java @@ -18,7 +18,7 @@ import java.util.HashMap; import java.util.List; import java.util.Vector; -public class SubGuiClonerNPCTags extends SubGuiInterface implements IGuiData,IScrollData { +public class SubGuiClonerNPCTags extends SubGuiInterface implements IGuiData, IScrollData { private GuiCustomScroll scrollTags; private GuiCustomScroll npcTags; private final ArrayList allTags = new ArrayList<>(); @@ -27,8 +27,7 @@ public class SubGuiClonerNPCTags extends SubGuiInterface implements IGuiData,ISc private final EntityNPCInterface npc; private GuiNpcMobSpawnerAdd mobSpawnerAdd; - public SubGuiClonerNPCTags(EntityNPCInterface npc, GuiNpcMobSpawnerAdd guiNpcMobSpawnerAdd) - { + public SubGuiClonerNPCTags(EntityNPCInterface npc, GuiNpcMobSpawnerAdd guiNpcMobSpawnerAdd) { this.parent = guiNpcMobSpawnerAdd; this.mobSpawnerAdd = guiNpcMobSpawnerAdd; PacketClient.sendClient(new TagsGetPacket()); @@ -40,15 +39,14 @@ public class SubGuiClonerNPCTags extends SubGuiInterface implements IGuiData,ISc closeOnEsc = true; } - public void initGui() - { + public void initGui() { super.initGui(); addLabel(new GuiNpcLabel(5, npc.display.name + " " + StatCollector.translateToLocal("tags.tags"), guiLeft + 10, guiTop + 8)); addLabel(new GuiNpcLabel(1, StatCollector.translateToLocal("tags.allTags"), guiLeft + 10, guiTop + 22)); - if(scrollTags == null){ - scrollTags = new GuiCustomScroll(this,0); + if (scrollTags == null) { + scrollTags = new GuiCustomScroll(this, 0); scrollTags.setSize(110, 145); } scrollTags.guiLeft = guiLeft + 10; @@ -57,8 +55,8 @@ public class SubGuiClonerNPCTags extends SubGuiInterface implements IGuiData,ISc addTextField(new GuiNpcTextField(4, this, fontRendererObj, guiLeft + 10, guiTop + 24 + 160, 110, 20, search)); addLabel(new GuiNpcLabel(2, StatCollector.translateToLocal("tags.selectedTags"), guiLeft + 185, guiTop + 22)); - if(npcTags == null){ - npcTags = new GuiCustomScroll(this,1); + if (npcTags == null) { + npcTags = new GuiCustomScroll(this, 1); npcTags.setSize(110, 170); } npcTags.guiLeft = guiLeft + 185; @@ -98,14 +96,13 @@ public class SubGuiClonerNPCTags extends SubGuiInterface implements IGuiData,ISc } @Override - public void close(){ + public void close() { super.close(); save(); } @Override - public void setData(Vector list, HashMap data, EnumScrollData type) - { + public void setData(Vector list, HashMap data, EnumScrollData type) { allTags.addAll(data.keySet()); allTags.sort(String.CASE_INSENSITIVE_ORDER); scrollTags.setList(allTags); @@ -114,17 +111,16 @@ public class SubGuiClonerNPCTags extends SubGuiInterface implements IGuiData,ISc @Override public void setGuiData(NBTTagCompound compound) { - NBTTagList tagList = compound.getTagList("TagNames",8); + NBTTagList tagList = compound.getTagList("TagNames", 8); tagNames.clear(); for (int i = 0; i < tagList.tagCount(); i++) { tagNames.add(tagList.getStringTagAt(i)); } } - public void mouseClicked(int i, int j, int k) - { + public void mouseClicked(int i, int j, int k) { super.mouseClicked(i, j, k); - if(k == 0 && scrollTags != null) + if (k == 0 && scrollTags != null) scrollTags.mouseClicked(i, j, k); } @@ -140,33 +136,32 @@ public class SubGuiClonerNPCTags extends SubGuiInterface implements IGuiData,ISc NBTTagList UUIDTagList = new NBTTagList(); for (String string : this.tagNames) { tagList.appendTag(new NBTTagString(string)); - if(GuiNpcMobSpawnerAdd.tagMap.containsKey(string)) + if (GuiNpcMobSpawnerAdd.tagMap.containsKey(string)) UUIDTagList.appendTag(new NBTTagString(GuiNpcMobSpawnerAdd.tagMap.get(string).toString())); } GuiNpcMobSpawnerAdd.tagsCompound = UUIDTagList; - tagCompound.setTag("TagNames",tagList); + tagCompound.setTag("TagNames", tagList); PacketClient.sendClient(new TagSetPacket(tagCompound)); } - public void keyTyped(char c, int i) - { + public void keyTyped(char c, int i) { super.keyTyped(c, i); - if(getTextField(4) != null){ - if(search.equals(getTextField(4).getText())) + if (getTextField(4) != null) { + if (search.equals(getTextField(4).getText())) return; search = getTextField(4).getText().toLowerCase(); scrollTags.setList(getSearchList()); } } - private List getSearchList(){ - if(search.isEmpty()){ + private List getSearchList() { + if (search.isEmpty()) { return new ArrayList(allTags); } List list = new ArrayList(); - for(String name : this.allTags){ - if(name.toLowerCase().contains(search)) + for (String name : this.allTags) { + if (name.toLowerCase().contains(search)) list.add(name); } return list; diff --git a/src/main/java/noppes/npcs/client/gui/SubGuiClonerQuickTags.java b/src/main/java/noppes/npcs/client/gui/SubGuiClonerQuickTags.java index 514547d88..996259b25 100644 --- a/src/main/java/noppes/npcs/client/gui/SubGuiClonerQuickTags.java +++ b/src/main/java/noppes/npcs/client/gui/SubGuiClonerQuickTags.java @@ -7,116 +7,114 @@ import noppes.npcs.constants.EnumScrollData; import java.util.*; -public class SubGuiClonerQuickTags extends SubGuiInterface implements IScrollData -{ - public GuiNpcMobSpawnerAdd parent; - public GuiCustomScroll quickScroll = new GuiCustomScroll(this,0); - public GuiCustomScroll selectedScroll = new GuiCustomScroll(this,5); - private static String quickSearch = ""; +public class SubGuiClonerQuickTags extends SubGuiInterface implements IScrollData { + public GuiNpcMobSpawnerAdd parent; + public GuiCustomScroll quickScroll = new GuiCustomScroll(this, 0); + public GuiCustomScroll selectedScroll = new GuiCustomScroll(this, 5); + private static String quickSearch = ""; - public SubGuiClonerQuickTags(GuiNpcMobSpawnerAdd par){ - this.parent = par; - setBackground("menubg.png"); - xSize = 305; - ySize = 220; - closeOnEsc = true; + public SubGuiClonerQuickTags(GuiNpcMobSpawnerAdd par) { + this.parent = par; + setBackground("menubg.png"); + xSize = 305; + ySize = 220; + closeOnEsc = true; } - public void initGui(){ + public void initGui() { super.initGui(); - quickScroll.clear(); - quickScroll.setSize(140, 166); - quickScroll.guiLeft = guiLeft + 4; - quickScroll.guiTop = guiTop + 19; - quickScroll.multipleSelection = true; - quickScroll.setSelectedList(GuiNpcMobSpawnerAdd.addTags); + quickScroll.clear(); + quickScroll.setSize(140, 166); + quickScroll.guiLeft = guiLeft + 4; + quickScroll.guiTop = guiTop + 19; + quickScroll.multipleSelection = true; + quickScroll.setSelectedList(GuiNpcMobSpawnerAdd.addTags); this.addScroll(quickScroll); - addLabel(new GuiNpcLabel(1, StatCollector.translateToLocal("cloner.wandTags"), guiLeft + 7, guiTop + 7)); - addScroll(quickScroll); - addTextField(new GuiNpcTextField(2, this, fontRendererObj, guiLeft + 4, guiTop + 190, 140, 20, quickSearch)); + addLabel(new GuiNpcLabel(1, StatCollector.translateToLocal("cloner.wandTags"), guiLeft + 7, guiTop + 7)); + addScroll(quickScroll); + addTextField(new GuiNpcTextField(2, this, fontRendererObj, guiLeft + 4, guiTop + 190, 140, 20, quickSearch)); - addButton(new GuiNpcButton(10, guiLeft + 150, guiTop + 20, 120, 20, "gui.selectAll")); - addButton(new GuiNpcButton(11, guiLeft + 150, guiTop + 43, 120, 20, "gui.deselectAll")); + addButton(new GuiNpcButton(10, guiLeft + 150, guiTop + 20, 120, 20, "gui.selectAll")); + addButton(new GuiNpcButton(11, guiLeft + 150, guiTop + 43, 120, 20, "gui.deselectAll")); - selectedScroll.clear(); - selectedScroll.setSize(145, 103); - selectedScroll.guiLeft = guiLeft + 150; - selectedScroll.guiTop = guiTop + 82; - selectedScroll.setUnselectable(); - this.addScroll(selectedScroll); + selectedScroll.clear(); + selectedScroll.setSize(145, 103); + selectedScroll.guiLeft = guiLeft + 150; + selectedScroll.guiTop = guiTop + 82; + selectedScroll.setUnselectable(); + this.addScroll(selectedScroll); - addLabel(new GuiNpcLabel(3, StatCollector.translateToLocal("tags.selectedTags"), guiLeft + 153, guiTop + 68)); - addScroll(selectedScroll); + addLabel(new GuiNpcLabel(3, StatCollector.translateToLocal("tags.selectedTags"), guiLeft + 153, guiTop + 68)); + addScroll(selectedScroll); - addButton(new GuiNpcButton(66, guiLeft + 240, guiTop + 190, 60, 20, "gui.done")); + addButton(new GuiNpcButton(66, guiLeft + 240, guiTop + 190, 60, 20, "gui.done")); - setSelected(); - refreshSelected(); + setSelected(); + refreshSelected(); } - protected void actionPerformed(GuiButton guibutton){ - if (guibutton.id == 10) { - GuiNpcMobSpawnerAdd.addTags = new HashSet<>(parent.allTags); - quickScroll.setSelectedList(GuiNpcMobSpawnerAdd.addTags); - refreshSelected(); - } - if (guibutton.id == 11) { - GuiNpcMobSpawnerAdd.addTags = new HashSet<>(); - quickScroll.setSelectedList(GuiNpcMobSpawnerAdd.addTags); - refreshSelected(); - } - if (guibutton.id == 66) { - close(); - } - } - @Override - public void mouseClicked(int i, int j, int k) - { - super.mouseClicked(i, j, k); - refreshSelected(); - } + protected void actionPerformed(GuiButton guibutton) { + if (guibutton.id == 10) { + GuiNpcMobSpawnerAdd.addTags = new HashSet<>(parent.allTags); + quickScroll.setSelectedList(GuiNpcMobSpawnerAdd.addTags); + refreshSelected(); + } + if (guibutton.id == 11) { + GuiNpcMobSpawnerAdd.addTags = new HashSet<>(); + quickScroll.setSelectedList(GuiNpcMobSpawnerAdd.addTags); + refreshSelected(); + } + if (guibutton.id == 66) { + close(); + } + } - public void setSelected(){ - quickScroll.setList(getQuickTags()); - } + @Override + public void mouseClicked(int i, int j, int k) { + super.mouseClicked(i, j, k); + refreshSelected(); + } - public void refreshSelected(){ - List sortedList = new ArrayList<>(new TreeSet<>(GuiNpcMobSpawnerAdd.addTags)); - selectedScroll.setList(sortedList); - } + public void setSelected() { + quickScroll.setList(getQuickTags()); + } - @Override - public void keyTyped(char c, int i) - { - super.keyTyped(c, i); - if(getTextField(2) != null){ - if(quickSearch.equals(getTextField(2).getText())) - return; - quickSearch = getTextField(2).getText().toLowerCase(); - quickScroll.setList(getQuickTags()); - } - } + public void refreshSelected() { + List sortedList = new ArrayList<>(new TreeSet<>(GuiNpcMobSpawnerAdd.addTags)); + selectedScroll.setList(sortedList); + } - private List getQuickTags(){ - if(quickSearch.isEmpty()){ - return new ArrayList(parent.allTags); - } - List list = new ArrayList(); - for(String name : this.parent.allTags){ - if(name.toLowerCase().contains(quickSearch)) - list.add(name); - } - return list; - } + @Override + public void keyTyped(char c, int i) { + super.keyTyped(c, i); + if (getTextField(2) != null) { + if (quickSearch.equals(getTextField(2).getText())) + return; + quickSearch = getTextField(2).getText().toLowerCase(); + quickScroll.setList(getQuickTags()); + } + } - @Override - public void setData(Vector list, HashMap data, EnumScrollData type) { + private List getQuickTags() { + if (quickSearch.isEmpty()) { + return new ArrayList(parent.allTags); + } + List list = new ArrayList(); + for (String name : this.parent.allTags) { + if (name.toLowerCase().contains(quickSearch)) + list.add(name); + } + return list; + } - } + @Override + public void setData(Vector list, HashMap data, EnumScrollData type) { - @Override - public void setSelected(String selected) { + } - } + @Override + public void setSelected(String selected) { + + } } diff --git a/src/main/java/noppes/npcs/client/gui/SubGuiColorSelector.java b/src/main/java/noppes/npcs/client/gui/SubGuiColorSelector.java index 48aec618c..947825f5a 100644 --- a/src/main/java/noppes/npcs/client/gui/SubGuiColorSelector.java +++ b/src/main/java/noppes/npcs/client/gui/SubGuiColorSelector.java @@ -14,117 +14,114 @@ import java.awt.image.BufferedImage; import java.io.IOException; import java.io.InputStream; -public class SubGuiColorSelector extends SubGuiInterface implements ITextfieldListener{ +public class SubGuiColorSelector extends SubGuiInterface implements ITextfieldListener { - private final static ResourceLocation resource = new ResourceLocation("customnpcs:textures/gui/color.png"); - - private int colorX, colorY; - - private GuiNpcTextField textfield; - - public int color; + private final static ResourceLocation resource = new ResourceLocation("customnpcs:textures/gui/color.png"); - public SubGuiColorSelector(int color){ - xSize = 176; - ySize = 222; - this.color = color; - setBackground("smallbg.png"); - } + private int colorX, colorY; + + private GuiNpcTextField textfield; + + public int color; + + public SubGuiColorSelector(int color) { + xSize = 176; + ySize = 222; + this.color = color; + setBackground("smallbg.png"); + } @Override public void initGui() { - super.initGui(); - colorX = guiLeft + 30; - colorY = guiTop + 50; - - this.addTextField(textfield = new GuiNpcTextField(0, this, guiLeft + 53, guiTop + 20, 70, 20, getColor())); - textfield.setTextColor(color); + super.initGui(); + colorX = guiLeft + 30; + colorY = guiTop + 50; - addButton(new GuiNpcButton(66, guiLeft + 112, guiTop + 198, 60, 20, "gui.done")); + this.addTextField(textfield = new GuiNpcTextField(0, this, guiLeft + 53, guiTop + 20, 70, 20, getColor())); + textfield.setTextColor(color); + + addButton(new GuiNpcButton(66, guiLeft + 112, guiTop + 198, 60, 20, "gui.done")); } - - public String getColor(){ - String str = Integer.toHexString(color); - while(str.length() < 6) - str = "0" + str; - return str; - } - - @Override - public void keyTyped(char c, int i){ - String prev = textfield.getText(); - super.keyTyped(c, i); - String newText = textfield.getText(); - if(newText.equals(prev)) - return; - try{ - color = Integer.parseInt(textfield.getText(),16); - textfield.setTextColor(color); - } - catch(NumberFormatException e){ - textfield.setText(prev); - } + + public String getColor() { + String str = Integer.toHexString(color); + while (str.length() < 6) + str = "0" + str; + return str; } @Override - protected void actionPerformed(GuiButton btn) { - super.actionPerformed(btn); - if(btn.id == 66){ - close(); + public void keyTyped(char c, int i) { + String prev = textfield.getText(); + super.keyTyped(c, i); + String newText = textfield.getText(); + if (newText.equals(prev)) + return; + try { + color = Integer.parseInt(textfield.getText(), 16); + textfield.setTextColor(color); + } catch (NumberFormatException e) { + textfield.setText(prev); } } @Override - public void close(){ + protected void actionPerformed(GuiButton btn) { + super.actionPerformed(btn); + if (btn.id == 66) { + close(); + } + } + + @Override + public void close() { super.close(); } @Override - public void drawScreen(int par1, int par2, float par3){ - super.drawScreen(par1, par2, par3); + public void drawScreen(int par1, int par2, float par3) { + super.drawScreen(par1, par2, par3); mc.getTextureManager().bindTexture(resource); - + GL11.glColor4f(1, 1, 1, 1); this.drawTexturedModalRect(colorX, colorY, 0, 0, 120, 120); } - - @Override - public void mouseClicked(int i, int j, int k){ - super.mouseClicked(i, j, k); - if( i < colorX || i > colorX + 117 || j < colorY || j > colorY + 117) - return; - InputStream stream = null; - try { - IResource iresource = this.mc.getResourceManager().getResource(resource); + + @Override + public void mouseClicked(int i, int j, int k) { + super.mouseClicked(i, j, k); + if (i < colorX || i > colorX + 117 || j < colorY || j > colorY + 117) + return; + InputStream stream = null; + try { + IResource iresource = this.mc.getResourceManager().getResource(resource); BufferedImage bufferedimage = ImageIO.read(stream = iresource.getInputStream()); - color = bufferedimage.getRGB((i - guiLeft - 30) * 4, (j - guiTop - 50) * 4) & 16777215; - textfield.setTextColor(color); - textfield.setText(getColor()); - - } catch (IOException e) { - } - finally{ - if(stream != null){ - try { - stream.close(); - } catch (IOException e) { - - } - } - } + color = bufferedimage.getRGB((i - guiLeft - 30) * 4, (j - guiTop - 50) * 4) & 16777215; + textfield.setTextColor(color); + textfield.setText(getColor()); + + } catch (IOException e) { + } finally { + if (stream != null) { + try { + stream.close(); + } catch (IOException e) { + + } + } + } } - @Override - public void unFocused(GuiNpcTextField textfield) { - int color = 0; - try{ - color = Integer.parseInt(textfield.getText(),16); - } - catch(NumberFormatException e){ - color = 0; - } - this.color = color; - textfield.setTextColor(color); - } + @Override + public void unFocused(GuiNpcTextField textfield) { + int color = 0; + try { + color = Integer.parseInt(textfield.getText(), 16); + } catch (NumberFormatException e) { + color = 0; + } + this.color = color; + textfield.setTextColor(color); + } } diff --git a/src/main/java/noppes/npcs/client/gui/SubGuiCustomHitbox.java b/src/main/java/noppes/npcs/client/gui/SubGuiCustomHitbox.java index d3687f223..09fc84fe1 100644 --- a/src/main/java/noppes/npcs/client/gui/SubGuiCustomHitbox.java +++ b/src/main/java/noppes/npcs/client/gui/SubGuiCustomHitbox.java @@ -4,10 +4,10 @@ import net.minecraft.client.gui.GuiButton; import noppes.npcs.client.gui.util.*; import noppes.npcs.controllers.data.HitboxData; -public class SubGuiCustomHitbox extends SubGuiInterface implements ITextfieldListener -{ +public class SubGuiCustomHitbox extends SubGuiInterface implements ITextfieldListener { private final HitboxData hitboxData; - public SubGuiCustomHitbox(HitboxData hitboxData){ + + public SubGuiCustomHitbox(HitboxData hitboxData) { this.hitboxData = hitboxData; setBackground("menubg.png"); xSize = 256; @@ -16,43 +16,43 @@ public class SubGuiCustomHitbox extends SubGuiInterface implements ITextfieldLis } @Override - public void initGui(){ + public void initGui() { super.initGui(); - addLabel(new GuiNpcLabel(0,"hitbox.hitbox", guiLeft + 5, guiTop + 35)); - addButton(new GuiNpcButtonYesNo(0,guiLeft + 122, guiTop + 30, 56, 20 ,hitboxData.isHitboxEnabled())); - if(hitboxData.isHitboxEnabled()){ - addLabel(new GuiNpcLabel(3,"hitbox.width", guiLeft + 5, guiTop + 57)); - addTextField(new GuiNpcTextField(2,this, fontRendererObj, guiLeft + 122, guiTop + 53, 50, 18, hitboxData.getWidthScale() + "")); + addLabel(new GuiNpcLabel(0, "hitbox.hitbox", guiLeft + 5, guiTop + 35)); + addButton(new GuiNpcButtonYesNo(0, guiLeft + 122, guiTop + 30, 56, 20, hitboxData.isHitboxEnabled())); + if (hitboxData.isHitboxEnabled()) { + addLabel(new GuiNpcLabel(3, "hitbox.width", guiLeft + 5, guiTop + 57)); + addTextField(new GuiNpcTextField(2, this, fontRendererObj, guiLeft + 122, guiTop + 53, 50, 18, hitboxData.getWidthScale() + "")); getTextField(2).floatsOnly = true; getTextField(2).setMinMaxDefaultFloat(0, Float.MAX_VALUE, 1); - addLabel(new GuiNpcLabel(4,"hitbox.height", guiLeft + 5, guiTop + 79)); - addTextField(new GuiNpcTextField(3,this, fontRendererObj, guiLeft + 122, guiTop + 75, 50, 18, hitboxData.getHeightScale() + "")); + addLabel(new GuiNpcLabel(4, "hitbox.height", guiLeft + 5, guiTop + 79)); + addTextField(new GuiNpcTextField(3, this, fontRendererObj, guiLeft + 122, guiTop + 75, 50, 18, hitboxData.getHeightScale() + "")); getTextField(3).floatsOnly = true; getTextField(3).setMinMaxDefaultFloat(0, Float.MAX_VALUE, 1); } - addButton(new GuiNpcButton(66, guiLeft + 82, guiTop + 190,98, 20, "gui.done")); + addButton(new GuiNpcButton(66, guiLeft + 82, guiTop + 190, 98, 20, "gui.done")); } @Override - protected void actionPerformed(GuiButton guibutton){ + protected void actionPerformed(GuiButton guibutton) { int id = guibutton.id; GuiNpcButton button = (GuiNpcButton) guibutton; - if(button.id == 0){ - hitboxData.setHitboxEnabled(((GuiNpcButtonYesNo)button).getBoolean()); + if (button.id == 0) { + hitboxData.setHitboxEnabled(((GuiNpcButtonYesNo) button).getBoolean()); initGui(); } - if(id == 66){ + if (id == 66) { close(); } } @Override public void unFocused(GuiNpcTextField textfield) { - if(textfield.id == 2){ + if (textfield.id == 2) { hitboxData.setWidthScale(textfield.getFloat()); } - if(textfield.id == 3){ + if (textfield.id == 3) { hitboxData.setHeightScale(textfield.getFloat()); } } diff --git a/src/main/java/noppes/npcs/client/gui/SubGuiEditText.java b/src/main/java/noppes/npcs/client/gui/SubGuiEditText.java index 2d44df4a1..5fe7ffe71 100644 --- a/src/main/java/noppes/npcs/client/gui/SubGuiEditText.java +++ b/src/main/java/noppes/npcs/client/gui/SubGuiEditText.java @@ -5,36 +5,37 @@ import noppes.npcs.client.gui.util.GuiNpcButton; import noppes.npcs.client.gui.util.GuiNpcTextField; import noppes.npcs.client.gui.util.SubGuiInterface; -public class SubGuiEditText extends SubGuiInterface{ - public String text; - public boolean cancelled = true; - public SubGuiEditText(String text){ - this.text = text; - setBackground("extrasmallbg.png"); - closeOnEsc = true; - xSize = 176; - ySize = 71; - } - - @Override - public void initGui(){ - super.initGui(); - addTextField(new GuiNpcTextField(0, parent, guiLeft + 4, guiTop + 14, 168, 20, text)); - - this.addButton(new GuiNpcButton(0, guiLeft + 4, guiTop + 44, 80, 20, "gui.done")); - this.addButton(new GuiNpcButton(1, guiLeft + 90, guiTop + 44, 80, 20, "gui.cancel")); - } - - @Override - public void buttonEvent(GuiButton button){ - if(button.id == 0){ - cancelled = false; - text = getTextField(0).getText(); - } - close(); - } - - @Override - public void save() { - } +public class SubGuiEditText extends SubGuiInterface { + public String text; + public boolean cancelled = true; + + public SubGuiEditText(String text) { + this.text = text; + setBackground("extrasmallbg.png"); + closeOnEsc = true; + xSize = 176; + ySize = 71; + } + + @Override + public void initGui() { + super.initGui(); + addTextField(new GuiNpcTextField(0, parent, guiLeft + 4, guiTop + 14, 168, 20, text)); + + this.addButton(new GuiNpcButton(0, guiLeft + 4, guiTop + 44, 80, 20, "gui.done")); + this.addButton(new GuiNpcButton(1, guiLeft + 90, guiTop + 44, 80, 20, "gui.cancel")); + } + + @Override + public void buttonEvent(GuiButton button) { + if (button.id == 0) { + cancelled = false; + text = getTextField(0).getText(); + } + close(); + } + + @Override + public void save() { + } } diff --git a/src/main/java/noppes/npcs/client/gui/SubGuiEffectGeneral.java b/src/main/java/noppes/npcs/client/gui/SubGuiEffectGeneral.java index ea9152189..e30784af0 100644 --- a/src/main/java/noppes/npcs/client/gui/SubGuiEffectGeneral.java +++ b/src/main/java/noppes/npcs/client/gui/SubGuiEffectGeneral.java @@ -71,7 +71,7 @@ public class SubGuiEffectGeneral extends SubGuiInterface implements ITextfieldLi y += 23; addTextField(setIntegerOnly( - new GuiNpcTextField(3, this, x + 70, y, 83, 20, ""+effect.everyXTick), + new GuiNpcTextField(3, this, x + 70, y, 83, 20, "" + effect.everyXTick), 10, 1200, effect.everyXTick @@ -81,20 +81,20 @@ public class SubGuiEffectGeneral extends SubGuiInterface implements ITextfieldLi addLabel(new GuiNpcLabel(3, "effect.editor.runsEveryX", x, y + 5)); int oldX = x; - int xEnd = guiLeft+xSize-10; + int xEnd = guiLeft + xSize - 10; x = getTextField(3).xPosition + getTextField(3).width; - addButton(new GuiNpcButtonYesNo(10, (x+xEnd - 83) / 2, y + 23, 83, 20, effect.lossOnDeath)); + addButton(new GuiNpcButtonYesNo(10, (x + xEnd - 83) / 2, y + 23, 83, 20, effect.lossOnDeath)); GuiNpcLabel label = new GuiNpcLabel(10, "effect.editor.lossOnDeath", x, y + 5); - label.x = (x+xEnd - fontRendererObj.getStringWidth(label.label))/2; + label.x = (x + xEnd - fontRendererObj.getStringWidth(label.label)) / 2; addLabel(label); x = oldX; y += 23; addTextField(setIntegerOnly( - new GuiNpcTextField(4, this, x + 70, y, 83, 20, ""+effect.length), + new GuiNpcTextField(4, this, x + 70, y, 83, 20, "" + effect.length), -100, 86400, - effect.length + effect.length )); addLabel(new GuiNpcLabel(4, "effect.editor.defaultLength", x, y + 5)); @@ -141,20 +141,20 @@ public class SubGuiEffectGeneral extends SubGuiInterface implements ITextfieldLi x = 116; scrollWindow.addLabel(new GuiNpcLabel(5, "display.texture", x, y, 0xFFFFFF)); y += 12; - scrollWindow.addTextField(new GuiNpcTextField(5, this, x, y, scrollWindow.clipWidth-x-10, 20, effect.icon)); + scrollWindow.addTextField(new GuiNpcTextField(5, this, x, y, scrollWindow.clipWidth - x - 10, 20, effect.icon)); scrollWindow.getTextField(5).setMaxStringLength(100); y += 25; scrollWindow.addLabel(new GuiNpcLabel(6, "effect.editor.xPos", x, y + 6, 0xFFFFFF)); scrollWindow.addTextField(setIntegerOnly( - new GuiNpcTextField(6, this, x + 43, y, 60, 20, ""+effect.iconX), + new GuiNpcTextField(6, this, x + 43, y, 60, 20, "" + effect.iconX), 0, 10240, effect.iconX )); scrollWindow.addTextField(setIntegerOnly( - new GuiNpcTextField(7, this, scrollWindow.clipWidth - 60 - 10, y, 60, 20, ""+effect.iconY), + new GuiNpcTextField(7, this, scrollWindow.clipWidth - 60 - 10, y, 60, 20, "" + effect.iconY), 0, 10240, effect.iconY @@ -164,13 +164,13 @@ public class SubGuiEffectGeneral extends SubGuiInterface implements ITextfieldLi scrollWindow.addLabel(new GuiNpcLabel(8, "effect.editor.width", x, y + 6, 0xFFFFFF)); scrollWindow.addTextField(setIntegerOnly( - new GuiNpcTextField(8, this, x + 43, y, 60, 20, ""+effect.width), + new GuiNpcTextField(8, this, x + 43, y, 60, 20, "" + effect.width), 0, 10240, effect.width )); scrollWindow.addTextField(setIntegerOnly( - new GuiNpcTextField(9, this, scrollWindow.clipWidth - 60 - 10, y, 60, 20, ""+effect.height), + new GuiNpcTextField(9, this, scrollWindow.clipWidth - 60 - 10, y, 60, 20, "" + effect.height), 0, 10240, effect.height @@ -220,13 +220,13 @@ public class SubGuiEffectGeneral extends SubGuiInterface implements ITextfieldLi break; case 3: effect.setEveryXTick(guiNpcTextField.getInteger()); - guiNpcTextField.setText(effect.everyXTick+""); + guiNpcTextField.setText(effect.everyXTick + ""); break; case 4: int length = guiNpcTextField.getInteger(); if (length < 0) length = -100; - guiNpcTextField.setText(length+""); + guiNpcTextField.setText(length + ""); effect.length = length; break; case 5: diff --git a/src/main/java/noppes/npcs/client/gui/SubGuiMagic.java b/src/main/java/noppes/npcs/client/gui/SubGuiMagic.java index 8b6c32d9a..c60f851a4 100644 --- a/src/main/java/noppes/npcs/client/gui/SubGuiMagic.java +++ b/src/main/java/noppes/npcs/client/gui/SubGuiMagic.java @@ -3,10 +3,7 @@ package noppes.npcs.client.gui; import kamkeel.npcs.network.PacketClient; import kamkeel.npcs.network.packets.request.magic.MagicSavePacket; import net.minecraft.client.gui.GuiButton; -import net.minecraft.client.gui.GuiTextField; import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.StatCollector; -import noppes.npcs.client.gui.SubGuiColorSelector; import noppes.npcs.client.gui.global.GuiNpcManageMagic; import noppes.npcs.client.gui.util.*; import noppes.npcs.constants.EnumTextureType; @@ -46,12 +43,12 @@ public class SubGuiMagic extends SubGuiInterface implements ITextfieldListener, public void initGui() { super.initGui(); - int y = guiTop + 6; + int y = guiTop + 6; - addLabel(new GuiNpcLabel(1,"gui.name", guiLeft + 4, y + 5)); + addLabel(new GuiNpcLabel(1, "gui.name", guiLeft + 4, y + 5)); addTextField(new GuiNpcTextField(1, this, this.fontRendererObj, guiLeft + 80, y, 200, 20, magic.name)); - addLabel(new GuiNpcLabel(-10,"ID", guiLeft + 200 + 80 + 5, y + 2)); + addLabel(new GuiNpcLabel(-10, "ID", guiLeft + 200 + 80 + 5, y + 2)); addLabel(new GuiNpcLabel(-11, magic.id + "", guiLeft + 200 + 80 + 5, y + 12)); y += 25; @@ -61,7 +58,7 @@ public class SubGuiMagic extends SubGuiInterface implements ITextfieldListener, addTextField(new GuiNpcTextField(2, this, fontRendererObj, guiLeft + 80, y, 200, 20, magic.displayName)); String color = Integer.toHexString(magic.color); - while(color.length() < 6) + while (color.length() < 6) color = 0 + color; addButton(new GuiNpcButton(12, guiLeft + 80 + 5 + 200, y, 65, 20, color)); getButton(12).setTextColor(magic.color); @@ -74,8 +71,8 @@ public class SubGuiMagic extends SubGuiInterface implements ITextfieldListener, // Interactions - if(allMagic == null){ - allMagic = new GuiCustomScroll(this,0); + if (allMagic == null) { + allMagic = new GuiCustomScroll(this, 0); allMagic.setSize(150, 107); } allMagic.guiLeft = guiLeft + 5; @@ -84,8 +81,8 @@ public class SubGuiMagic extends SubGuiInterface implements ITextfieldListener, addTextField(new GuiNpcTextField(34, this, fontRendererObj, guiLeft + 5, guiTop + 30 + 160, 150, 20, search)); allMagic.setList(getSearchList()); - if(interactionsScroll == null){ - interactionsScroll = new GuiCustomScroll(this,1); + if (interactionsScroll == null) { + interactionsScroll = new GuiCustomScroll(this, 1); interactionsScroll.setSize(150, 107); } interactionsScroll.guiLeft = guiLeft + 200; @@ -97,7 +94,7 @@ public class SubGuiMagic extends SubGuiInterface implements ITextfieldListener, interactionField = new GuiNpcTextField(90, this, fontRendererObj, guiLeft + 245, guiTop + 30 + 160, 45, 20, ""); interactionField.setFloatsOnly(); addTextField(interactionField); - if(selectedInteraction != null){ + if (selectedInteraction != null) { interactionField.setText(interactionValues.get(selectedInteraction) + ""); } else { interactionField.enabled = false; @@ -115,11 +112,11 @@ public class SubGuiMagic extends SubGuiInterface implements ITextfieldListener, @Override public void actionPerformed(GuiButton button) { - if(button.id == 99){ + if (button.id == 99) { close(); } - if(button.id == 13){ - magic.type = EnumTextureType.values()[((GuiNpcButton)button).getValue()]; + if (button.id == 13) { + magic.type = EnumTextureType.values()[((GuiNpcButton) button).getValue()]; } if (button.id == 12) { setSubGui(new SubGuiColorSelector(magic.color)); @@ -141,8 +138,8 @@ public class SubGuiMagic extends SubGuiInterface implements ITextfieldListener, } if (button.id == 62) { // Add All - for(String name : this.parent.magicData.keySet()){ - if(!interactionNames.containsKey(name)){ + for (String name : this.parent.magicData.keySet()) { + if (!interactionNames.containsKey(name)) { interactionNames.put(name, this.parent.magicData.get(name)); interactionValues.put(name, 0.0f); } @@ -163,27 +160,26 @@ public class SubGuiMagic extends SubGuiInterface implements ITextfieldListener, @Override public void unFocused(GuiNpcTextField guiNpcTextField) { - if(guiNpcTextField.id == 1) { - if(magic.id < 0) + if (guiNpcTextField.id == 1) { + if (magic.id < 0) guiNpcTextField.setText(""); - else{ + else { String name = guiNpcTextField.getText(); - if(name.isEmpty() || ((GuiNpcManageMagic)this.parent).magicData.containsKey(name)){ + if (name.isEmpty() || ((GuiNpcManageMagic) this.parent).magicData.containsKey(name)) { guiNpcTextField.setText(magic.name); - } - else if(magic.id >= 0){ + } else if (magic.id >= 0) { String old = magic.name; - ((GuiNpcManageMagic)this.parent).magicData.remove(old); + ((GuiNpcManageMagic) this.parent).magicData.remove(old); magic.name = name; - ((GuiNpcManageMagic)this.parent).magicData.put(magic.name, magic.id); - ((GuiNpcManageMagic)this.parent).rightScroll.replace(old, magic.name); + ((GuiNpcManageMagic) this.parent).magicData.put(magic.name, magic.id); + ((GuiNpcManageMagic) this.parent).rightScroll.replace(old, magic.name); } } } - if(guiNpcTextField.id == 2){ + if (guiNpcTextField.id == 2) { magic.displayName = guiNpcTextField.getText(); } - if(guiNpcTextField.id == 3){ + if (guiNpcTextField.id == 3) { magic.iconTexture = guiNpcTextField.getText(); } if (guiNpcTextField.id == 90 && selectedInteraction != null) { @@ -191,18 +187,16 @@ public class SubGuiMagic extends SubGuiInterface implements ITextfieldListener, } } - public void mouseClicked(int i, int j, int k) - { + public void mouseClicked(int i, int j, int k) { super.mouseClicked(i, j, k); - if(k == 0 && allMagic != null) + if (k == 0 && allMagic != null) allMagic.mouseClicked(i, j, k); } - public void keyTyped(char c, int i) - { + public void keyTyped(char c, int i) { super.keyTyped(c, i); - if(getTextField(34) != null && getTextField(34).isFocused()){ - if(search.equals(getTextField(34).getText())) + if (getTextField(34) != null && getTextField(34).isFocused()) { + if (search.equals(getTextField(34).getText())) return; search = getTextField(34).getText().toLowerCase(); allMagic.setList(getSearchList()); @@ -210,26 +204,26 @@ public class SubGuiMagic extends SubGuiInterface implements ITextfieldListener, } } - private List getSearchList(){ + private List getSearchList() { List original = new ArrayList<>(this.parent.magicData.keySet()); - if(search.isEmpty()){ + if (search.isEmpty()) { return original; } List filtered = new ArrayList<>(); - for(String name : original){ - if(name.toLowerCase().contains(search)){ + for (String name : original) { + if (name.toLowerCase().contains(search)) { filtered.add(name); } } return filtered; } - public void processInteractions(){ + public void processInteractions() { interactionNames.clear(); interactionValues.clear(); - for(int id : magic.interactions.keySet()){ - for(String name : this.parent.magicData.keySet()){ - if(this.parent.magicData.get(name) == id){ + for (int id : magic.interactions.keySet()) { + for (String name : this.parent.magicData.keySet()) { + if (this.parent.magicData.get(name) == id) { interactionNames.put(name, id); interactionValues.put(name, magic.interactions.get(id)); } @@ -237,22 +231,22 @@ public class SubGuiMagic extends SubGuiInterface implements ITextfieldListener, } } - public void setInteractions(){ + public void setInteractions() { magic.interactions.clear(); - for(String name : interactionNames.keySet()){ + for (String name : interactionNames.keySet()) { magic.interactions.put(interactionNames.get(name), interactionValues.get(name)); } } @Override public void subGuiClosed(SubGuiInterface subgui) { - if(subgui instanceof SubGuiColorSelector){ + if (subgui instanceof SubGuiColorSelector) { magic.color = ((SubGuiColorSelector) subgui).color; initGui(); } } - public void close(){ + public void close() { setInteractions(); NBTTagCompound compound = new NBTTagCompound(); magic.writeNBT(compound); @@ -262,7 +256,7 @@ public class SubGuiMagic extends SubGuiInterface implements ITextfieldListener, @Override public void customScrollClicked(int i, int j, int k, GuiCustomScroll guiCustomScroll) { - if(guiCustomScroll.id == 1){ + if (guiCustomScroll.id == 1) { GuiNpcTextField.unfocus(); selectedInteraction = interactionsScroll.getSelected(); interactionField.enabled = true; @@ -271,5 +265,6 @@ public class SubGuiMagic extends SubGuiInterface implements ITextfieldListener, } @Override - public void customScrollDoubleClicked(String selection, GuiCustomScroll scroll) {} + public void customScrollDoubleClicked(String selection, GuiCustomScroll scroll) { + } } diff --git a/src/main/java/noppes/npcs/client/gui/SubGuiMagicCycle.java b/src/main/java/noppes/npcs/client/gui/SubGuiMagicCycle.java index 2fbeeeeb5..d9180db8d 100644 --- a/src/main/java/noppes/npcs/client/gui/SubGuiMagicCycle.java +++ b/src/main/java/noppes/npcs/client/gui/SubGuiMagicCycle.java @@ -4,11 +4,9 @@ import kamkeel.npcs.network.PacketClient; import kamkeel.npcs.network.packets.request.magic.MagicCycleSavePacket; import net.minecraft.client.gui.GuiButton; import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.StatCollector; import noppes.npcs.client.gui.global.GuiNpcManageMagic; import noppes.npcs.client.gui.util.*; import noppes.npcs.constants.EnumDiagramLayout; -import noppes.npcs.controllers.data.Magic; import noppes.npcs.controllers.data.MagicAssociation; import noppes.npcs.controllers.data.MagicCycle; @@ -62,7 +60,7 @@ public class SubGuiMagicCycle extends SubGuiInterface implements ITextfieldListe addLabel(new GuiNpcLabel(1, "gui.name", guiLeft + 4, y + 5)); addTextField(new GuiNpcTextField(1, this, fontRendererObj, guiLeft + 80, y, 200, 20, cycle.name)); - addLabel(new GuiNpcLabel(-10,"ID", guiLeft + 200 + 80 + 5, y + 2)); + addLabel(new GuiNpcLabel(-10, "ID", guiLeft + 200 + 80 + 5, y + 2)); addLabel(new GuiNpcLabel(-11, cycle.id + "", guiLeft + 200 + 80 + 5, y + 12)); // Layout button – cycles through available layouts @@ -96,7 +94,7 @@ public class SubGuiMagicCycle extends SubGuiInterface implements ITextfieldListe // --- Association Management --- // Scroll for available magics to add - if(allMagic == null){ + if (allMagic == null) { allMagic = new GuiCustomScroll(this, 0); allMagic.setSize(150, 100); } @@ -110,7 +108,7 @@ public class SubGuiMagicCycle extends SubGuiInterface implements ITextfieldListe addTextField(new GuiNpcTextField(34, this, fontRendererObj, guiLeft + 5, y + 105, 150, 20, search)); // Scroll for current associations - if(associationScroll == null){ + if (associationScroll == null) { associationScroll = new GuiCustomScroll(this, 1); associationScroll.setSize(150, 125); } @@ -133,12 +131,12 @@ public class SubGuiMagicCycle extends SubGuiInterface implements ITextfieldListe @Override public void actionPerformed(GuiButton button) { // Layout button: update cycle layout. - if(button.id == 13) { - cycle.layout = EnumDiagramLayout.values()[((GuiNpcButton)button).getValue()]; + if (button.id == 13) { + cycle.layout = EnumDiagramLayout.values()[((GuiNpcButton) button).getValue()]; } // Add single association - if(button.id == 60 && allMagic.hasSelected() && !associationMap.containsKey(allMagic.getSelected()) - && parent.magicData.containsKey(allMagic.getSelected())) { + if (button.id == 60 && allMagic.hasSelected() && !associationMap.containsKey(allMagic.getSelected()) + && parent.magicData.containsKey(allMagic.getSelected())) { MagicAssociation assoc = new MagicAssociation(); assoc.magicId = parent.magicData.get(allMagic.getSelected()); assoc.index = 0; @@ -147,7 +145,7 @@ public class SubGuiMagicCycle extends SubGuiInterface implements ITextfieldListe associationScroll.list.add(allMagic.getSelected()); } // Remove single association - if(button.id == 61 && associationScroll.hasSelected()) { + if (button.id == 61 && associationScroll.hasSelected()) { associationMap.remove(associationScroll.getSelected()); associationScroll.list.remove(associationScroll.selected); associationScroll.selected = -1; @@ -157,9 +155,9 @@ public class SubGuiMagicCycle extends SubGuiInterface implements ITextfieldListe priorityField.setText(""); } // Add All available associations - if(button.id == 62) { - for(String name : parent.magicData.keySet()){ - if(!associationMap.containsKey(name)){ + if (button.id == 62) { + for (String name : parent.magicData.keySet()) { + if (!associationMap.containsKey(name)) { MagicAssociation assoc = new MagicAssociation(); assoc.magicId = parent.magicData.get(name); assoc.index = 0; @@ -170,7 +168,7 @@ public class SubGuiMagicCycle extends SubGuiInterface implements ITextfieldListe associationScroll.setList(new ArrayList<>(associationMap.keySet())); } // Remove All associations - if(button.id == 63) { + if (button.id == 63) { associationMap.clear(); associationScroll.setList(new ArrayList<>()); associationScroll.selected = -1; @@ -180,7 +178,7 @@ public class SubGuiMagicCycle extends SubGuiInterface implements ITextfieldListe priorityField.setText(""); } // Done – save changes and close - if(button.id == 99) { + if (button.id == 99) { close(); } } @@ -188,24 +186,26 @@ public class SubGuiMagicCycle extends SubGuiInterface implements ITextfieldListe @Override public void unFocused(GuiNpcTextField textField) { // Update cycle basic data. - if(textField.id == 1) { + if (textField.id == 1) { cycle.name = textField.getText(); } - if(textField.id == 2) { + if (textField.id == 2) { cycle.displayName = textField.getText(); } // Update association ordering values when fields lose focus. - if(textField.id == 91 && selectedAssociation != null) { + if (textField.id == 91 && selectedAssociation != null) { try { int idx = Integer.parseInt(textField.getText()); associationMap.get(selectedAssociation).index = idx; - } catch(NumberFormatException e) { } + } catch (NumberFormatException e) { + } } - if(textField.id == 92 && selectedAssociation != null) { + if (textField.id == 92 && selectedAssociation != null) { try { int prio = Integer.parseInt(textField.getText()); associationMap.get(selectedAssociation).priority = prio; - } catch(NumberFormatException e) { } + } catch (NumberFormatException e) { + } } } @@ -213,8 +213,8 @@ public class SubGuiMagicCycle extends SubGuiInterface implements ITextfieldListe public void keyTyped(char c, int i) { super.keyTyped(c, i); // Available magic search (text field ID 34) - if(getTextField(34) != null && getTextField(34).isFocused()){ - if(search.equals(getTextField(34).getText())) + if (getTextField(34) != null && getTextField(34).isFocused()) { + if (search.equals(getTextField(34).getText())) return; search = getTextField(34).getText().toLowerCase(); allMagic.setList(getAvailableMagicList()); @@ -226,11 +226,11 @@ public class SubGuiMagicCycle extends SubGuiInterface implements ITextfieldListe * Returns a filtered list of available magic names based on parent's magicData and the search string. * Only those not already in the associationMap are shown. */ - private List getAvailableMagicList(){ + private List getAvailableMagicList() { List original = new ArrayList<>(parent.magicData.keySet()); List filtered = new ArrayList<>(); - for(String name : original){ - if(!associationMap.containsKey(name) && name.toLowerCase().contains(search)){ + for (String name : original) { + if (!associationMap.containsKey(name) && name.toLowerCase().contains(search)) { filtered.add(name); } } @@ -240,12 +240,12 @@ public class SubGuiMagicCycle extends SubGuiInterface implements ITextfieldListe /** * Populates associationMap from cycle.associations using parent's magicData. */ - public void processAssociations(){ + public void processAssociations() { associationMap.clear(); // For each association stored in the cycle, find the corresponding magic name. - for(MagicAssociation assoc : cycle.associations.values()){ - for(String name : parent.magicData.keySet()){ - if(parent.magicData.get(name) == assoc.magicId){ + for (MagicAssociation assoc : cycle.associations.values()) { + for (String name : parent.magicData.keySet()) { + if (parent.magicData.get(name) == assoc.magicId) { associationMap.put(name, assoc); break; } @@ -256,9 +256,9 @@ public class SubGuiMagicCycle extends SubGuiInterface implements ITextfieldListe @Override public void customScrollClicked(int id, int index, int clickType, GuiCustomScroll scroll) { // When clicking the association scroll, update the ordering text fields. - if(scroll.id == 1){ + if (scroll.id == 1) { selectedAssociation = scroll.getSelected(); - if(selectedAssociation != null && associationMap.containsKey(selectedAssociation)){ + if (selectedAssociation != null && associationMap.containsKey(selectedAssociation)) { indexField.enabled = true; priorityField.enabled = true; indexField.setText(associationMap.get(selectedAssociation).index + ""); @@ -268,7 +268,8 @@ public class SubGuiMagicCycle extends SubGuiInterface implements ITextfieldListe } @Override - public void customScrollDoubleClicked(String selection, GuiCustomScroll scroll) { } + public void customScrollDoubleClicked(String selection, GuiCustomScroll scroll) { + } @Override public void subGuiClosed(SubGuiInterface subgui) { @@ -279,10 +280,10 @@ public class SubGuiMagicCycle extends SubGuiInterface implements ITextfieldListe * Called when the user clicks "Done". Updates the cycle's associations from associationMap, * writes the NBT data, and sends a MagicCycleSavePacket. */ - public void close(){ + public void close() { // Clear the cycle's associations and update them from our associationMap. cycle.associations.clear(); - for(String name : associationMap.keySet()){ + for (String name : associationMap.keySet()) { cycle.associations.put(associationMap.get(name).magicId, associationMap.get(name)); } NBTTagCompound compound = new NBTTagCompound(); diff --git a/src/main/java/noppes/npcs/client/gui/SubGuiMagicCycleViewer.java b/src/main/java/noppes/npcs/client/gui/SubGuiMagicCycleViewer.java index e86022344..dd0954ac9 100644 --- a/src/main/java/noppes/npcs/client/gui/SubGuiMagicCycleViewer.java +++ b/src/main/java/noppes/npcs/client/gui/SubGuiMagicCycleViewer.java @@ -1,20 +1,9 @@ package noppes.npcs.client.gui; -import kamkeel.npcs.network.PacketClient; -import kamkeel.npcs.network.packets.request.magic.MagicSavePacket; -import net.minecraft.client.gui.GuiButton; -import net.minecraft.nbt.NBTTagCompound; -import noppes.npcs.client.gui.global.GuiNpcManageMagic; -import noppes.npcs.client.gui.util.*; -import noppes.npcs.constants.EnumTextureType; +import noppes.npcs.client.gui.util.SubGuiInterface; import noppes.npcs.controllers.MagicController; -import noppes.npcs.controllers.data.Magic; import noppes.npcs.controllers.data.MagicCycle; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; - public class SubGuiMagicCycleViewer extends SubGuiInterface { private final MagicCycle magicCycle; @@ -37,7 +26,7 @@ public class SubGuiMagicCycleViewer extends SubGuiInterface { public void initGui() { super.initGui(); - if(magicCycle == null) + if (magicCycle == null) return; // Position the map in a designated area (e.g., right panel) diff --git a/src/main/java/noppes/npcs/client/gui/SubGuiMailmanSendSetup.java b/src/main/java/noppes/npcs/client/gui/SubGuiMailmanSendSetup.java index 2f0f5dfeb..849f0edad 100644 --- a/src/main/java/noppes/npcs/client/gui/SubGuiMailmanSendSetup.java +++ b/src/main/java/noppes/npcs/client/gui/SubGuiMailmanSendSetup.java @@ -11,86 +11,87 @@ import noppes.npcs.client.gui.util.*; import noppes.npcs.containers.ContainerMail; import noppes.npcs.controllers.data.PlayerMail; -public class SubGuiMailmanSendSetup extends SubGuiInterface implements ITextfieldListener, GuiSelectionListener{ +public class SubGuiMailmanSendSetup extends SubGuiInterface implements ITextfieldListener, GuiSelectionListener { - private PlayerMail mail; + private PlayerMail mail; - public SubGuiMailmanSendSetup(PlayerMail mail, GuiScreen parent){ - this.parent = parent; + public SubGuiMailmanSendSetup(PlayerMail mail, GuiScreen parent) { + this.parent = parent; xSize = 256; setBackground("menubg.png"); - this.mail = mail; - } + this.mail = mail; + } - @Override - public void initGui(){ - super.initGui(); - addLabel(new GuiNpcLabel(1, "mailbox.subject", guiLeft + 4, guiTop + 19)); - addTextField(new GuiNpcTextField(1, this, fontRendererObj, guiLeft + 60, guiTop + 14, 180, 20, mail.subject)); - addLabel(new GuiNpcLabel(0, "mailbox.sender", guiLeft + 4, guiTop + 41)); - addTextField(new GuiNpcTextField(0, this, fontRendererObj, guiLeft + 60, guiTop + 36, 180, 20, mail.sender)); + @Override + public void initGui() { + super.initGui(); + addLabel(new GuiNpcLabel(1, "mailbox.subject", guiLeft + 4, guiTop + 19)); + addTextField(new GuiNpcTextField(1, this, fontRendererObj, guiLeft + 60, guiTop + 14, 180, 20, mail.subject)); + addLabel(new GuiNpcLabel(0, "mailbox.sender", guiLeft + 4, guiTop + 41)); + addTextField(new GuiNpcTextField(0, this, fontRendererObj, guiLeft + 60, guiTop + 36, 180, 20, mail.sender)); - addButton(new GuiNpcButton(2, guiLeft + 29, guiTop + 100, "mailbox.write")); + addButton(new GuiNpcButton(2, guiLeft + 29, guiTop + 100, "mailbox.write")); - addLabel(new GuiNpcLabel(3, "quest.quest", guiLeft + 13, guiTop + 135)); - String title = mail.questTitle; - if(title.isEmpty()) - title = "gui.select"; - addButton(new GuiNpcButton(3, guiLeft + 70, guiTop + 130, 100, 20, title)); - addButton(new GuiNpcButton(4, guiLeft + 171, guiTop + 130, 20, 20, "X")); + addLabel(new GuiNpcLabel(3, "quest.quest", guiLeft + 13, guiTop + 135)); + String title = mail.questTitle; + if (title.isEmpty()) + title = "gui.select"; + addButton(new GuiNpcButton(3, guiLeft + 70, guiTop + 130, 100, 20, title)); + addButton(new GuiNpcButton(4, guiLeft + 171, guiTop + 130, 20, 20, "X")); - addButton(new GuiNpcButton(0, guiLeft + 26, guiTop + 190, 100, 20, "gui.done")); - addButton(new GuiNpcButton(1, guiLeft + 130, guiTop + 190, 100, 20, "gui.cancel")); + addButton(new GuiNpcButton(0, guiLeft + 26, guiTop + 190, 100, 20, "gui.done")); + addButton(new GuiNpcButton(1, guiLeft + 130, guiTop + 190, 100, 20, "gui.cancel")); - if(player.openContainer instanceof ContainerMail){ - ContainerMail container = (ContainerMail) player.openContainer; - mail.items = container.mail.items; - } - } + if (player.openContainer instanceof ContainerMail) { + ContainerMail container = (ContainerMail) player.openContainer; + mail.items = container.mail.items; + } + } - public void buttonEvent(GuiButton guibutton) { - int id = guibutton.id; - if(id == 0){ - close(); - } - if(id == 1){ - mail.questId = -1; - mail.questTitle = ""; - mail.message = new NBTTagCompound(); - close(); - } - if(id == 2){ - GuiMailmanWrite.parent = getParent(); - GuiMailmanWrite.mail = mail; + public void buttonEvent(GuiButton guibutton) { + int id = guibutton.id; + if (id == 0) { + close(); + } + if (id == 1) { + mail.questId = -1; + mail.questTitle = ""; + mail.message = new NBTTagCompound(); + close(); + } + if (id == 2) { + GuiMailmanWrite.parent = getParent(); + GuiMailmanWrite.mail = mail; PacketClient.sendClient(new MailOpenSetupPacket(mail.writeNBT())); - } - if(id == 3){ + } + if (id == 3) { setSubGui(new GuiQuestSelection(mail.questId)); - } - if(id == 4){ - mail.questId = -1; - mail.questTitle = ""; - initGui(); - } - } + } + if (id == 4) { + mail.questId = -1; + mail.questTitle = ""; + initGui(); + } + } - @Override - public void selected(int ob, String name) { + @Override + public void selected(int ob, String name) { mail.questId = ob; mail.questTitle = name; - initGui(); - } - @Override - public void save() { + initGui(); + } - } + @Override + public void save() { - @Override - public void unFocused(GuiNpcTextField textField) { - if(textField.id == 0) - mail.sender = textField.getText(); - if(textField.id == 1) - mail.subject = textField.getText(); - } + } + + @Override + public void unFocused(GuiNpcTextField textField) { + if (textField.id == 0) + mail.sender = textField.getText(); + if (textField.id == 1) + mail.subject = textField.getText(); + } } diff --git a/src/main/java/noppes/npcs/client/gui/SubGuiNpcAvailability.java b/src/main/java/noppes/npcs/client/gui/SubGuiNpcAvailability.java index 2d59d80a8..2d3cf7edf 100644 --- a/src/main/java/noppes/npcs/client/gui/SubGuiNpcAvailability.java +++ b/src/main/java/noppes/npcs/client/gui/SubGuiNpcAvailability.java @@ -10,149 +10,146 @@ import noppes.npcs.constants.EnumDayTime; import noppes.npcs.controllers.data.Availability; import noppes.npcs.controllers.data.Faction; -public class SubGuiNpcAvailability extends SubGuiInterface implements ITextfieldListener, GuiSelectionListener, IGuiData -{ - private Availability availabitily; - private int slot = 0; +public class SubGuiNpcAvailability extends SubGuiInterface implements ITextfieldListener, GuiSelectionListener, IGuiData { + private Availability availabitily; + private int slot = 0; - public SubGuiNpcAvailability(Availability availabitily) - { - this.availabitily = availabitily; - setBackground("menubg.png"); - xSize = 256; - ySize = 216; - closeOnEsc = true; + public SubGuiNpcAvailability(Availability availabitily) { + this.availabitily = availabitily; + setBackground("menubg.png"); + xSize = 256; + ySize = 216; + closeOnEsc = true; } - public void initGui() - { + public void initGui() { super.initGui(); - addLabel(new GuiNpcLabel(1,"availability.available", guiLeft, guiTop + 4)); + addLabel(new GuiNpcLabel(1, "availability.available", guiLeft, guiTop + 4)); getLabel(1).center(xSize); this.addButton(new GuiNpcButton(0, guiLeft + 34, guiTop + 12, 180, 20, "availability.selectdialog")); this.addButton(new GuiNpcButton(1, guiLeft + 34, guiTop + 35, 180, 20, "availability.selectquest")); - this.addButton(new GuiNpcButton(20, guiLeft + 4, guiTop + 104, 50, 20, new String[]{"availability.always","availability.is","availability.isnot"},availabitily.factionAvailable.ordinal())); - this.addButton(new GuiNpcButton(22, guiLeft + 56, guiTop + 104, 60, 20, new String[]{"faction.friendly","faction.neutral","faction.unfriendly"},availabitily.factionStance.ordinal())); - this.addButton(new GuiNpcButton(21, guiLeft + 118, guiTop + 104, 110, 20, "availability.selectfaction")); - getButton(21).setEnabled(availabitily.factionAvailable != EnumAvailabilityFactionType.Always); - getButton(22).setEnabled(availabitily.factionAvailable != EnumAvailabilityFactionType.Always); - this.addButton(new GuiNpcButton(23, guiLeft + 230, guiTop + 104,20, 20, "X")); + this.addButton(new GuiNpcButton(20, guiLeft + 4, guiTop + 104, 50, 20, new String[]{"availability.always", "availability.is", "availability.isnot"}, availabitily.factionAvailable.ordinal())); + this.addButton(new GuiNpcButton(22, guiLeft + 56, guiTop + 104, 60, 20, new String[]{"faction.friendly", "faction.neutral", "faction.unfriendly"}, availabitily.factionStance.ordinal())); + this.addButton(new GuiNpcButton(21, guiLeft + 118, guiTop + 104, 110, 20, "availability.selectfaction")); + getButton(21).setEnabled(availabitily.factionAvailable != EnumAvailabilityFactionType.Always); + getButton(22).setEnabled(availabitily.factionAvailable != EnumAvailabilityFactionType.Always); + this.addButton(new GuiNpcButton(23, guiLeft + 230, guiTop + 104, 20, 20, "X")); - this.addButton(new GuiNpcButton(24, guiLeft + 4, guiTop + 126, 50, 20, new String[]{"availability.always","availability.is","availability.isnot"},availabitily.faction2Available.ordinal())); - this.addButton(new GuiNpcButton(27, guiLeft + 56, guiTop + 126, 60, 20, new String[]{"faction.friendly","faction.neutral","faction.unfriendly"},availabitily.faction2Stance.ordinal())); - this.addButton(new GuiNpcButton(25, guiLeft + 118, guiTop + 126, 110, 20, "availability.selectfaction")); - getButton(25).setEnabled(availabitily.faction2Available != EnumAvailabilityFactionType.Always); - getButton(27).setEnabled(availabitily.faction2Available != EnumAvailabilityFactionType.Always); - this.addButton(new GuiNpcButton(26, guiLeft + 230, guiTop + 126,20, 20, "X")); + this.addButton(new GuiNpcButton(24, guiLeft + 4, guiTop + 126, 50, 20, new String[]{"availability.always", "availability.is", "availability.isnot"}, availabitily.faction2Available.ordinal())); + this.addButton(new GuiNpcButton(27, guiLeft + 56, guiTop + 126, 60, 20, new String[]{"faction.friendly", "faction.neutral", "faction.unfriendly"}, availabitily.faction2Stance.ordinal())); + this.addButton(new GuiNpcButton(25, guiLeft + 118, guiTop + 126, 110, 20, "availability.selectfaction")); + getButton(25).setEnabled(availabitily.faction2Available != EnumAvailabilityFactionType.Always); + getButton(27).setEnabled(availabitily.faction2Available != EnumAvailabilityFactionType.Always); + this.addButton(new GuiNpcButton(26, guiLeft + 230, guiTop + 126, 20, 20, "X")); - addLabel(new GuiNpcLabel(50,"availability.daytime", guiLeft + 4 , guiTop + 153)); - this.addButton(new GuiNpcButton(50, guiLeft + 50, guiTop + 148,150, 20, new String[]{"availability.wholeday","availability.night","availability.day"},availabitily.daytime.ordinal())); + addLabel(new GuiNpcLabel(50, "availability.daytime", guiLeft + 4, guiTop + 153)); + this.addButton(new GuiNpcButton(50, guiLeft + 50, guiTop + 148, 150, 20, new String[]{"availability.wholeday", "availability.night", "availability.day"}, availabitily.daytime.ordinal())); - addLabel(new GuiNpcLabel(51,"availability.minlevel", guiLeft + 4 , guiTop + 175)); - this.addTextField(new GuiNpcTextField(51, this, fontRendererObj, guiLeft + 50, guiTop + 170,90, 20, availabitily.minPlayerLevel + "")); - this.getTextField(51).integersOnly = true; - this.getTextField(51).setMinMaxDefault(0, Integer.MAX_VALUE, 0); + addLabel(new GuiNpcLabel(51, "availability.minlevel", guiLeft + 4, guiTop + 175)); + this.addTextField(new GuiNpcTextField(51, this, fontRendererObj, guiLeft + 50, guiTop + 170, 90, 20, availabitily.minPlayerLevel + "")); + this.getTextField(51).integersOnly = true; + this.getTextField(51).setMinMaxDefault(0, Integer.MAX_VALUE, 0); - this.addButton(new GuiNpcButton(66, guiLeft + 82, guiTop + 192,98, 20, "gui.done")); + this.addButton(new GuiNpcButton(66, guiLeft + 82, guiTop + 192, 98, 20, "gui.done")); - updateGuiButtons(); + updateGuiButtons(); } private void updateGuiButtons() { - if(availabitily.factionId >= 0){ + if (availabitily.factionId >= 0) { FactionGetPacket.getFaction(availabitily.factionId); - } - if(availabitily.faction2Id >= 0){ + } + if (availabitily.faction2Id >= 0) { FactionGetPacket.getFaction(availabitily.faction2Id); - } - } - - @Override - protected void actionPerformed(GuiButton guibutton){ - GuiNpcButton button = (GuiNpcButton) guibutton; - - if(button.id == 0){ - setSubGui(new SubGuiNpcAvailabilityDialog(availabitily)); - } - if(button.id == 1){ - setSubGui(new SubGuiNpcAvailabilityQuest(availabitily)); - } - - if(button.id == 20){ - availabitily.setFactionAvailability(button.getValue()); - if(availabitily.factionAvailable == EnumAvailabilityFactionType.Always) - availabitily.factionId = -1; - initGui(); - } - if(button.id == 24){ - availabitily.setFaction2Availability(button.getValue()); - if(availabitily.faction2Available == EnumAvailabilityFactionType.Always) - availabitily.faction2Id = -1; - initGui(); - } - if(button.id == 21){ - slot = 1; - GuiNPCFactionSelection gui = new GuiNPCFactionSelection(npc, getParent(), availabitily.factionId); - gui.listener = this; - NoppesUtil.openGUI(player, gui); - } - if(button.id == 25){ - slot = 2; - GuiNPCFactionSelection gui = new GuiNPCFactionSelection(npc, getParent(), availabitily.faction2Id); - gui.listener = this; - NoppesUtil.openGUI(player, gui); - } - if(button.id == 22){ - availabitily.setFactionAvailabilityStance(button.getValue()); - } - - if(button.id == 27){ - availabitily.setFaction2AvailabilityStance(button.getValue()); - } - if(button.id == 23){ - availabitily.factionId = -1; - getButton(21).setDisplayText("availability.selectfaction"); - } - if(button.id == 26){ - availabitily.faction2Id = -1; - getButton(25).setDisplayText("availability.selectfaction"); - } - if(button.id == 50){ - availabitily.daytime = EnumDayTime.values()[button.getValue()]; - } - if(button.id == 66){ - close(); } } - @Override - public void selected(int id, String name) { - if(slot == 1) - availabitily.factionId = id; - if(slot == 2) - availabitily.faction2Id = id; - } + @Override + protected void actionPerformed(GuiButton guibutton) { + GuiNpcButton button = (GuiNpcButton) guibutton; - @Override - public void setGuiData(NBTTagCompound compound) { - if(compound.hasKey("Slot")){ - Faction faction = new Faction(); - faction.readNBT(compound); - if(availabitily.factionId == faction.id) - getButton(21).setDisplayText(faction.name); - if(availabitily.faction2Id == faction.id) - getButton(25).setDisplayText(faction.name); - } - } + if (button.id == 0) { + setSubGui(new SubGuiNpcAvailabilityDialog(availabitily)); + } + if (button.id == 1) { + setSubGui(new SubGuiNpcAvailabilityQuest(availabitily)); + } - @Override - public void unFocused(GuiNpcTextField textfield) { - if(textfield.id == 51) - availabitily.minPlayerLevel = textfield.getInteger(); - } + if (button.id == 20) { + availabitily.setFactionAvailability(button.getValue()); + if (availabitily.factionAvailable == EnumAvailabilityFactionType.Always) + availabitily.factionId = -1; + initGui(); + } + if (button.id == 24) { + availabitily.setFaction2Availability(button.getValue()); + if (availabitily.faction2Available == EnumAvailabilityFactionType.Always) + availabitily.faction2Id = -1; + initGui(); + } + if (button.id == 21) { + slot = 1; + GuiNPCFactionSelection gui = new GuiNPCFactionSelection(npc, getParent(), availabitily.factionId); + gui.listener = this; + NoppesUtil.openGUI(player, gui); + } + if (button.id == 25) { + slot = 2; + GuiNPCFactionSelection gui = new GuiNPCFactionSelection(npc, getParent(), availabitily.faction2Id); + gui.listener = this; + NoppesUtil.openGUI(player, gui); + } + if (button.id == 22) { + availabitily.setFactionAvailabilityStance(button.getValue()); + } + + if (button.id == 27) { + availabitily.setFaction2AvailabilityStance(button.getValue()); + } + if (button.id == 23) { + availabitily.factionId = -1; + getButton(21).setDisplayText("availability.selectfaction"); + } + if (button.id == 26) { + availabitily.faction2Id = -1; + getButton(25).setDisplayText("availability.selectfaction"); + } + if (button.id == 50) { + availabitily.daytime = EnumDayTime.values()[button.getValue()]; + } + if (button.id == 66) { + close(); + } + } + + @Override + public void selected(int id, String name) { + if (slot == 1) + availabitily.factionId = id; + if (slot == 2) + availabitily.faction2Id = id; + } + + @Override + public void setGuiData(NBTTagCompound compound) { + if (compound.hasKey("Slot")) { + Faction faction = new Faction(); + faction.readNBT(compound); + if (availabitily.factionId == faction.id) + getButton(21).setDisplayText(faction.name); + if (availabitily.faction2Id == faction.id) + getButton(25).setDisplayText(faction.name); + } + } + + @Override + public void unFocused(GuiNpcTextField textfield) { + if (textfield.id == 51) + availabitily.minPlayerLevel = textfield.getInteger(); + } } diff --git a/src/main/java/noppes/npcs/client/gui/SubGuiNpcAvailabilityDialog.java b/src/main/java/noppes/npcs/client/gui/SubGuiNpcAvailabilityDialog.java index c55f040c5..cee94a3f5 100644 --- a/src/main/java/noppes/npcs/client/gui/SubGuiNpcAvailabilityDialog.java +++ b/src/main/java/noppes/npcs/client/gui/SubGuiNpcAvailabilityDialog.java @@ -9,164 +9,164 @@ import noppes.npcs.constants.EnumAvailabilityDialog; import noppes.npcs.controllers.data.Availability; import noppes.npcs.controllers.data.Dialog; -public class SubGuiNpcAvailabilityDialog extends SubGuiInterface implements GuiSelectionListener, IGuiData{ - private Availability availabitily; - private int slot = 0; +public class SubGuiNpcAvailabilityDialog extends SubGuiInterface implements GuiSelectionListener, IGuiData { + private Availability availabitily; + private int slot = 0; - public SubGuiNpcAvailabilityDialog(Availability availabitily){ - this.availabitily = availabitily; - setBackground("menubg.png"); - xSize = 256; - ySize = 216; - closeOnEsc = true; + public SubGuiNpcAvailabilityDialog(Availability availabitily) { + this.availabitily = availabitily; + setBackground("menubg.png"); + xSize = 256; + ySize = 216; + closeOnEsc = true; } @Override - public void initGui(){ + public void initGui() { super.initGui(); - addLabel(new GuiNpcLabel(1,"availability.available", guiLeft, guiTop + 4)); + addLabel(new GuiNpcLabel(1, "availability.available", guiLeft, guiTop + 4)); getLabel(1).center(xSize); int y = guiTop + 12; - this.addButton(new GuiNpcButton(0, guiLeft + 4, y, 50, 20, new String[]{"availability.always","availability.after","availability.before"},availabitily.dialogAvailable.ordinal())); - this.addButton(new GuiNpcButton(10, guiLeft + 56, y, 172, 20, "availability.selectdialog")); - getButton(10).setEnabled(availabitily.dialogAvailable != EnumAvailabilityDialog.Always); - this.addButton(new GuiNpcButton(20, guiLeft + 230, y,20, 20, "X")); + this.addButton(new GuiNpcButton(0, guiLeft + 4, y, 50, 20, new String[]{"availability.always", "availability.after", "availability.before"}, availabitily.dialogAvailable.ordinal())); + this.addButton(new GuiNpcButton(10, guiLeft + 56, y, 172, 20, "availability.selectdialog")); + getButton(10).setEnabled(availabitily.dialogAvailable != EnumAvailabilityDialog.Always); + this.addButton(new GuiNpcButton(20, guiLeft + 230, y, 20, 20, "X")); - y += 23; - this.addButton(new GuiNpcButton(1, guiLeft + 4, y, 50, 20, new String[]{"availability.always","availability.after","availability.before"},availabitily.dialog2Available.ordinal())); - this.addButton(new GuiNpcButton(11, guiLeft + 56, y, 172, 20, "availability.selectdialog")); - getButton(11).setEnabled(availabitily.dialog2Available != EnumAvailabilityDialog.Always); - this.addButton(new GuiNpcButton(21, guiLeft + 230, y,20, 20, "X")); + y += 23; + this.addButton(new GuiNpcButton(1, guiLeft + 4, y, 50, 20, new String[]{"availability.always", "availability.after", "availability.before"}, availabitily.dialog2Available.ordinal())); + this.addButton(new GuiNpcButton(11, guiLeft + 56, y, 172, 20, "availability.selectdialog")); + getButton(11).setEnabled(availabitily.dialog2Available != EnumAvailabilityDialog.Always); + this.addButton(new GuiNpcButton(21, guiLeft + 230, y, 20, 20, "X")); - y += 23; - this.addButton(new GuiNpcButton(2, guiLeft + 4, y, 50, 20, new String[]{"availability.always","availability.after","availability.before"},availabitily.dialog3Available.ordinal())); - this.addButton(new GuiNpcButton(12, guiLeft + 56, y, 172, 20, "availability.selectdialog")); - getButton(12).setEnabled(availabitily.dialog3Available != EnumAvailabilityDialog.Always); - this.addButton(new GuiNpcButton(22, guiLeft + 230, y,20, 20, "X")); + y += 23; + this.addButton(new GuiNpcButton(2, guiLeft + 4, y, 50, 20, new String[]{"availability.always", "availability.after", "availability.before"}, availabitily.dialog3Available.ordinal())); + this.addButton(new GuiNpcButton(12, guiLeft + 56, y, 172, 20, "availability.selectdialog")); + getButton(12).setEnabled(availabitily.dialog3Available != EnumAvailabilityDialog.Always); + this.addButton(new GuiNpcButton(22, guiLeft + 230, y, 20, 20, "X")); - y += 23; - this.addButton(new GuiNpcButton(3, guiLeft + 4, y, 50, 20, new String[]{"availability.always","availability.after","availability.before"},availabitily.dialog4Available.ordinal())); - this.addButton(new GuiNpcButton(13, guiLeft + 56, y, 172, 20, "availability.selectdialog")); - getButton(13).setEnabled(availabitily.dialog4Available != EnumAvailabilityDialog.Always); - this.addButton(new GuiNpcButton(23, guiLeft + 230, y,20, 20, "X")); + y += 23; + this.addButton(new GuiNpcButton(3, guiLeft + 4, y, 50, 20, new String[]{"availability.always", "availability.after", "availability.before"}, availabitily.dialog4Available.ordinal())); + this.addButton(new GuiNpcButton(13, guiLeft + 56, y, 172, 20, "availability.selectdialog")); + getButton(13).setEnabled(availabitily.dialog4Available != EnumAvailabilityDialog.Always); + this.addButton(new GuiNpcButton(23, guiLeft + 230, y, 20, 20, "X")); - this.addButton(new GuiNpcButton(66, guiLeft + 82, guiTop + 192,98, 20, "gui.done")); + this.addButton(new GuiNpcButton(66, guiLeft + 82, guiTop + 192, 98, 20, "gui.done")); - updateGuiButtons(); + updateGuiButtons(); } private void updateGuiButtons() { - getButton(10).setDisplayText("availability.selectdialog"); - getButton(11).setDisplayText("availability.selectdialog"); - getButton(12).setDisplayText("availability.selectdialog"); - getButton(13).setDisplayText("availability.selectdialog"); + getButton(10).setDisplayText("availability.selectdialog"); + getButton(11).setDisplayText("availability.selectdialog"); + getButton(12).setDisplayText("availability.selectdialog"); + getButton(13).setDisplayText("availability.selectdialog"); - if(availabitily.dialogId >= 0){ + if (availabitily.dialogId >= 0) { DialogGetPacket.getDialog(availabitily.dialogId); - } - if(availabitily.dialog2Id >= 0){ + } + if (availabitily.dialog2Id >= 0) { DialogGetPacket.getDialog(availabitily.dialog2Id); - } - if(availabitily.dialog3Id >= 0){ + } + if (availabitily.dialog3Id >= 0) { DialogGetPacket.getDialog(availabitily.dialog3Id); - } - if(availabitily.dialog4Id >= 0){ + } + if (availabitily.dialog4Id >= 0) { DialogGetPacket.getDialog(availabitily.dialog4Id); - } - } - - @Override - protected void actionPerformed(GuiButton guibutton){ - GuiNpcButton button = (GuiNpcButton) guibutton; - - if(button.id == 0){ - availabitily.dialogAvailable = EnumAvailabilityDialog.values()[button.getValue()]; - if(availabitily.dialogAvailable == EnumAvailabilityDialog.Always) - availabitily.dialogId = -1; - initGui(); - } - if(button.id == 1){ - availabitily.dialog2Available = EnumAvailabilityDialog.values()[button.getValue()]; - if(availabitily.dialog2Available == EnumAvailabilityDialog.Always) - availabitily.dialog2Id = -1; - initGui(); - } - if(button.id == 2){ - availabitily.dialog3Available = EnumAvailabilityDialog.values()[button.getValue()]; - if(availabitily.dialog3Available == EnumAvailabilityDialog.Always) - availabitily.dialog3Id = -1; - initGui(); - } - if(button.id == 3){ - availabitily.dialog4Available = EnumAvailabilityDialog.values()[button.getValue()]; - if(availabitily.dialog4Available == EnumAvailabilityDialog.Always) - availabitily.dialog4Id = -1; - initGui(); - } - if(button.id == 10){ - slot = 1; - setSubGui(new GuiDialogSelection(availabitily.questId)); - } - if(button.id == 11){ - slot = 2; - setSubGui(new GuiDialogSelection(availabitily.quest2Id)); - } - if(button.id == 12){ - slot = 3; - setSubGui(new GuiDialogSelection(availabitily.quest3Id)); - } - if(button.id == 13){ - slot = 4; - setSubGui(new GuiDialogSelection(availabitily.quest4Id)); - } - if(button.id == 20){ - availabitily.dialogId = -1; - getButton(10).setDisplayText("availability.selectdialog"); - } - if(button.id == 21){ - availabitily.dialog2Id = -1; - getButton(11).setDisplayText("availability.selectdialog"); - } - if(button.id == 22){ - availabitily.dialog3Id = -1; - getButton(12).setDisplayText("availability.selectdialog"); - } - if(button.id == 23){ - availabitily.dialog4Id = -1; - getButton(13).setDisplayText("availability.selectdialog"); - } - if(button.id == 66){ - close(); } } - @Override - public void selected(int id, String name) { - if(slot == 1) - availabitily.dialogId = id; - if(slot == 2) - availabitily.dialog2Id = id; - if(slot == 3) - availabitily.dialog3Id = id; - if(slot == 4) - availabitily.dialog4Id = id; + @Override + protected void actionPerformed(GuiButton guibutton) { + GuiNpcButton button = (GuiNpcButton) guibutton; + + if (button.id == 0) { + availabitily.dialogAvailable = EnumAvailabilityDialog.values()[button.getValue()]; + if (availabitily.dialogAvailable == EnumAvailabilityDialog.Always) + availabitily.dialogId = -1; + initGui(); + } + if (button.id == 1) { + availabitily.dialog2Available = EnumAvailabilityDialog.values()[button.getValue()]; + if (availabitily.dialog2Available == EnumAvailabilityDialog.Always) + availabitily.dialog2Id = -1; + initGui(); + } + if (button.id == 2) { + availabitily.dialog3Available = EnumAvailabilityDialog.values()[button.getValue()]; + if (availabitily.dialog3Available == EnumAvailabilityDialog.Always) + availabitily.dialog3Id = -1; + initGui(); + } + if (button.id == 3) { + availabitily.dialog4Available = EnumAvailabilityDialog.values()[button.getValue()]; + if (availabitily.dialog4Available == EnumAvailabilityDialog.Always) + availabitily.dialog4Id = -1; + initGui(); + } + if (button.id == 10) { + slot = 1; + setSubGui(new GuiDialogSelection(availabitily.questId)); + } + if (button.id == 11) { + slot = 2; + setSubGui(new GuiDialogSelection(availabitily.quest2Id)); + } + if (button.id == 12) { + slot = 3; + setSubGui(new GuiDialogSelection(availabitily.quest3Id)); + } + if (button.id == 13) { + slot = 4; + setSubGui(new GuiDialogSelection(availabitily.quest4Id)); + } + if (button.id == 20) { + availabitily.dialogId = -1; + getButton(10).setDisplayText("availability.selectdialog"); + } + if (button.id == 21) { + availabitily.dialog2Id = -1; + getButton(11).setDisplayText("availability.selectdialog"); + } + if (button.id == 22) { + availabitily.dialog3Id = -1; + getButton(12).setDisplayText("availability.selectdialog"); + } + if (button.id == 23) { + availabitily.dialog4Id = -1; + getButton(13).setDisplayText("availability.selectdialog"); + } + if (button.id == 66) { + close(); + } + } + + @Override + public void selected(int id, String name) { + if (slot == 1) + availabitily.dialogId = id; + if (slot == 2) + availabitily.dialog2Id = id; + if (slot == 3) + availabitily.dialog3Id = id; + if (slot == 4) + availabitily.dialog4Id = id; updateGuiButtons(); } - @Override - public void setGuiData(NBTTagCompound compound) { - Dialog dialog = new Dialog(); - dialog.readNBT(compound); - if(availabitily.dialogId == dialog.id) - getButton(10).setDisplayText(dialog.title); - if(availabitily.dialog2Id == dialog.id) - getButton(11).setDisplayText(dialog.title); - if(availabitily.dialog3Id == dialog.id) - getButton(12).setDisplayText(dialog.title); - if(availabitily.dialog4Id == dialog.id) - getButton(13).setDisplayText(dialog.title); - } + @Override + public void setGuiData(NBTTagCompound compound) { + Dialog dialog = new Dialog(); + dialog.readNBT(compound); + if (availabitily.dialogId == dialog.id) + getButton(10).setDisplayText(dialog.title); + if (availabitily.dialog2Id == dialog.id) + getButton(11).setDisplayText(dialog.title); + if (availabitily.dialog3Id == dialog.id) + getButton(12).setDisplayText(dialog.title); + if (availabitily.dialog4Id == dialog.id) + getButton(13).setDisplayText(dialog.title); + } } diff --git a/src/main/java/noppes/npcs/client/gui/SubGuiNpcAvailabilityQuest.java b/src/main/java/noppes/npcs/client/gui/SubGuiNpcAvailabilityQuest.java index 5d333ba3a..f4098c445 100644 --- a/src/main/java/noppes/npcs/client/gui/SubGuiNpcAvailabilityQuest.java +++ b/src/main/java/noppes/npcs/client/gui/SubGuiNpcAvailabilityQuest.java @@ -10,167 +10,167 @@ import noppes.npcs.controllers.data.Availability; import noppes.npcs.controllers.data.Quest; public class SubGuiNpcAvailabilityQuest extends SubGuiInterface implements GuiSelectionListener, IGuiData { - private Availability availabitily; - private int slot = 0; + private Availability availabitily; + private int slot = 0; - public SubGuiNpcAvailabilityQuest(Availability availabitily){ - this.availabitily = availabitily; - setBackground("menubg.png"); - xSize = 316; - ySize = 216; - closeOnEsc = true; - } + public SubGuiNpcAvailabilityQuest(Availability availabitily) { + this.availabitily = availabitily; + setBackground("menubg.png"); + xSize = 316; + ySize = 216; + closeOnEsc = true; + } @Override - public void initGui(){ + public void initGui() { super.initGui(); - addLabel(new GuiNpcLabel(1,"availability.available", guiLeft, guiTop + 4)); + addLabel(new GuiNpcLabel(1, "availability.available", guiLeft, guiTop + 4)); getLabel(1).center(xSize); int y = guiTop + 12; - this.addButton(new GuiNpcButton(0, guiLeft + 4, y, 90, 20, new String[]{"availability.always","availability.after","availability.before","availability.whenactive", "availability.whennotactive", "availability.acceptable", "availability.notacceptable"},availabitily.questAvailable.ordinal())); - this.addButton(new GuiNpcButton(10, guiLeft + 96, y, 192, 20, "availability.selectquest")); - getButton(10).setEnabled(availabitily.questAvailable != EnumAvailabilityQuest.Always); - this.addButton(new GuiNpcButton(20, guiLeft + 290, y, 20, 20, "X")); + this.addButton(new GuiNpcButton(0, guiLeft + 4, y, 90, 20, new String[]{"availability.always", "availability.after", "availability.before", "availability.whenactive", "availability.whennotactive", "availability.acceptable", "availability.notacceptable"}, availabitily.questAvailable.ordinal())); + this.addButton(new GuiNpcButton(10, guiLeft + 96, y, 192, 20, "availability.selectquest")); + getButton(10).setEnabled(availabitily.questAvailable != EnumAvailabilityQuest.Always); + this.addButton(new GuiNpcButton(20, guiLeft + 290, y, 20, 20, "X")); - y += 23; - this.addButton(new GuiNpcButton(1, guiLeft + 4, y, 90, 20, new String[]{"availability.always","availability.after","availability.before","availability.whenactive", "availability.whennotactive", "availability.acceptable", "availability.notacceptable"},availabitily.quest2Available.ordinal())); - this.addButton(new GuiNpcButton(11, guiLeft + 96, y, 192, 20, "availability.selectquest")); - getButton(11).setEnabled(availabitily.quest2Available != EnumAvailabilityQuest.Always); - this.addButton(new GuiNpcButton(21, guiLeft + 290, y, 20, 20, "X")); + y += 23; + this.addButton(new GuiNpcButton(1, guiLeft + 4, y, 90, 20, new String[]{"availability.always", "availability.after", "availability.before", "availability.whenactive", "availability.whennotactive", "availability.acceptable", "availability.notacceptable"}, availabitily.quest2Available.ordinal())); + this.addButton(new GuiNpcButton(11, guiLeft + 96, y, 192, 20, "availability.selectquest")); + getButton(11).setEnabled(availabitily.quest2Available != EnumAvailabilityQuest.Always); + this.addButton(new GuiNpcButton(21, guiLeft + 290, y, 20, 20, "X")); - y += 23; - this.addButton(new GuiNpcButton(2, guiLeft + 4, y, 90, 20, new String[]{"availability.always","availability.after","availability.before","availability.whenactive", "availability.whennotactive", "availability.acceptable", "availability.notacceptable"},availabitily.quest3Available.ordinal())); - this.addButton(new GuiNpcButton(12, guiLeft + 96, y, 192, 20, "availability.selectquest")); - getButton(12).setEnabled(availabitily.quest3Available != EnumAvailabilityQuest.Always); - this.addButton(new GuiNpcButton(22, guiLeft + 290, y, 20, 20, "X")); + y += 23; + this.addButton(new GuiNpcButton(2, guiLeft + 4, y, 90, 20, new String[]{"availability.always", "availability.after", "availability.before", "availability.whenactive", "availability.whennotactive", "availability.acceptable", "availability.notacceptable"}, availabitily.quest3Available.ordinal())); + this.addButton(new GuiNpcButton(12, guiLeft + 96, y, 192, 20, "availability.selectquest")); + getButton(12).setEnabled(availabitily.quest3Available != EnumAvailabilityQuest.Always); + this.addButton(new GuiNpcButton(22, guiLeft + 290, y, 20, 20, "X")); - y += 23; - this.addButton(new GuiNpcButton(3, guiLeft + 4, y, 90, 20, new String[]{"availability.always","availability.after","availability.before","availability.whenactive", "availability.whennotactive", "availability.acceptable", "availability.notacceptable"},availabitily.quest4Available.ordinal())); - this.addButton(new GuiNpcButton(13, guiLeft + 96, y, 192, 20, "availability.selectquest")); - getButton(13).setEnabled(availabitily.quest4Available != EnumAvailabilityQuest.Always); - this.addButton(new GuiNpcButton(23, guiLeft + 290, y, 20, 20, "X")); + y += 23; + this.addButton(new GuiNpcButton(3, guiLeft + 4, y, 90, 20, new String[]{"availability.always", "availability.after", "availability.before", "availability.whenactive", "availability.whennotactive", "availability.acceptable", "availability.notacceptable"}, availabitily.quest4Available.ordinal())); + this.addButton(new GuiNpcButton(13, guiLeft + 96, y, 192, 20, "availability.selectquest")); + getButton(13).setEnabled(availabitily.quest4Available != EnumAvailabilityQuest.Always); + this.addButton(new GuiNpcButton(23, guiLeft + 290, y, 20, 20, "X")); - this.addButton(new GuiNpcButton(66, guiLeft + 82, guiTop + 192,98, 20, "gui.done")); + this.addButton(new GuiNpcButton(66, guiLeft + 82, guiTop + 192, 98, 20, "gui.done")); - updateGuiButtons(); + updateGuiButtons(); } private void updateGuiButtons() { - getButton(10).setDisplayText("availability.selectquest"); - getButton(11).setDisplayText("availability.selectquest"); - getButton(12).setDisplayText("availability.selectquest"); - getButton(13).setDisplayText("availability.selectquest"); + getButton(10).setDisplayText("availability.selectquest"); + getButton(11).setDisplayText("availability.selectquest"); + getButton(12).setDisplayText("availability.selectquest"); + getButton(13).setDisplayText("availability.selectquest"); - if(availabitily.questId >= 0){ + if (availabitily.questId >= 0) { QuestGetPacket.getQuest(availabitily.questId); - } - if(availabitily.quest2Id >= 0){ + } + if (availabitily.quest2Id >= 0) { QuestGetPacket.getQuest(availabitily.quest2Id); - } - if(availabitily.quest3Id >= 0){ + } + if (availabitily.quest3Id >= 0) { QuestGetPacket.getQuest(availabitily.quest3Id); - } - if(availabitily.quest4Id >= 0){ + } + if (availabitily.quest4Id >= 0) { QuestGetPacket.getQuest(availabitily.quest4Id); - } - } - - @Override - protected void actionPerformed(GuiButton guibutton){ - GuiNpcButton button = (GuiNpcButton) guibutton; - - if(button.id == 0){ - availabitily.questAvailable = EnumAvailabilityQuest.values()[button.getValue()]; - if(availabitily.questAvailable == EnumAvailabilityQuest.Always) - availabitily.questId = -1; - initGui(); - } - if(button.id == 1){ - availabitily.quest2Available = EnumAvailabilityQuest.values()[button.getValue()]; - if(availabitily.quest2Available == EnumAvailabilityQuest.Always) - availabitily.quest2Id = -1; - initGui(); - } - if(button.id == 2){ - availabitily.quest3Available = EnumAvailabilityQuest.values()[button.getValue()]; - if(availabitily.quest3Available == EnumAvailabilityQuest.Always) - availabitily.quest3Id = -1; - initGui(); - } - if(button.id == 3){ - availabitily.quest4Available = EnumAvailabilityQuest.values()[button.getValue()]; - if(availabitily.quest4Available == EnumAvailabilityQuest.Always) - availabitily.quest4Id = -1; - initGui(); - } - if(button.id == 10){ - slot = 1; - setSubGui(new GuiQuestSelection(availabitily.questId)); - } - if(button.id == 11){ - slot = 2; - setSubGui(new GuiQuestSelection(availabitily.quest2Id)); - } - if(button.id == 12){ - slot = 3; - setSubGui(new GuiQuestSelection(availabitily.quest3Id)); - } - if(button.id == 13){ - slot = 4; - setSubGui(new GuiQuestSelection(availabitily.quest4Id)); - } - - if(button.id == 20){ - availabitily.questId = -1; - getButton(10).setDisplayText("availability.selectquest"); - } - if(button.id == 21){ - availabitily.quest2Id = -1; - getButton(11).setDisplayText("availability.selectquest"); - } - if(button.id == 22){ - availabitily.quest3Id = -1; - getButton(12).setDisplayText("availability.selectquest"); - } - if(button.id == 23){ - availabitily.quest4Id = -1; - getButton(13).setDisplayText("availability.selectquest"); - } - - if(button.id == 66){ - close(); } } - @Override - public void selected(int id, String name) { - if(slot == 1) - availabitily.questId = id; - if(slot == 2) - availabitily.quest2Id = id; - if(slot == 3) - availabitily.quest3Id = id; - if(slot == 4) - availabitily.quest4Id = id; + @Override + protected void actionPerformed(GuiButton guibutton) { + GuiNpcButton button = (GuiNpcButton) guibutton; + + if (button.id == 0) { + availabitily.questAvailable = EnumAvailabilityQuest.values()[button.getValue()]; + if (availabitily.questAvailable == EnumAvailabilityQuest.Always) + availabitily.questId = -1; + initGui(); + } + if (button.id == 1) { + availabitily.quest2Available = EnumAvailabilityQuest.values()[button.getValue()]; + if (availabitily.quest2Available == EnumAvailabilityQuest.Always) + availabitily.quest2Id = -1; + initGui(); + } + if (button.id == 2) { + availabitily.quest3Available = EnumAvailabilityQuest.values()[button.getValue()]; + if (availabitily.quest3Available == EnumAvailabilityQuest.Always) + availabitily.quest3Id = -1; + initGui(); + } + if (button.id == 3) { + availabitily.quest4Available = EnumAvailabilityQuest.values()[button.getValue()]; + if (availabitily.quest4Available == EnumAvailabilityQuest.Always) + availabitily.quest4Id = -1; + initGui(); + } + if (button.id == 10) { + slot = 1; + setSubGui(new GuiQuestSelection(availabitily.questId)); + } + if (button.id == 11) { + slot = 2; + setSubGui(new GuiQuestSelection(availabitily.quest2Id)); + } + if (button.id == 12) { + slot = 3; + setSubGui(new GuiQuestSelection(availabitily.quest3Id)); + } + if (button.id == 13) { + slot = 4; + setSubGui(new GuiQuestSelection(availabitily.quest4Id)); + } + + if (button.id == 20) { + availabitily.questId = -1; + getButton(10).setDisplayText("availability.selectquest"); + } + if (button.id == 21) { + availabitily.quest2Id = -1; + getButton(11).setDisplayText("availability.selectquest"); + } + if (button.id == 22) { + availabitily.quest3Id = -1; + getButton(12).setDisplayText("availability.selectquest"); + } + if (button.id == 23) { + availabitily.quest4Id = -1; + getButton(13).setDisplayText("availability.selectquest"); + } + + if (button.id == 66) { + close(); + } + } + + @Override + public void selected(int id, String name) { + if (slot == 1) + availabitily.questId = id; + if (slot == 2) + availabitily.quest2Id = id; + if (slot == 3) + availabitily.quest3Id = id; + if (slot == 4) + availabitily.quest4Id = id; updateGuiButtons(); - } + } - @Override - public void setGuiData(NBTTagCompound compound) { - Quest quest = new Quest(); - quest.readNBT(compound); - if(availabitily.questId == quest.id) - getButton(10).setDisplayText(quest.title); - if(availabitily.quest2Id == quest.id) - getButton(11).setDisplayText(quest.title); - if(availabitily.quest3Id == quest.id) - getButton(12).setDisplayText(quest.title); - if(availabitily.quest4Id == quest.id) - getButton(13).setDisplayText(quest.title); + @Override + public void setGuiData(NBTTagCompound compound) { + Quest quest = new Quest(); + quest.readNBT(compound); + if (availabitily.questId == quest.id) + getButton(10).setDisplayText(quest.title); + if (availabitily.quest2Id == quest.id) + getButton(11).setDisplayText(quest.title); + if (availabitily.quest3Id == quest.id) + getButton(12).setDisplayText(quest.title); + if (availabitily.quest4Id == quest.id) + getButton(13).setDisplayText(quest.title); - } + } } diff --git a/src/main/java/noppes/npcs/client/gui/SubGuiNpcBiomes.java b/src/main/java/noppes/npcs/client/gui/SubGuiNpcBiomes.java index 2ab4c1277..76b5d8150 100644 --- a/src/main/java/noppes/npcs/client/gui/SubGuiNpcBiomes.java +++ b/src/main/java/noppes/npcs/client/gui/SubGuiNpcBiomes.java @@ -11,34 +11,33 @@ import noppes.npcs.controllers.data.SpawnData; import java.util.ArrayList; import java.util.List; -public class SubGuiNpcBiomes extends SubGuiInterface -{ - private SpawnData data; - private GuiCustomScroll scroll1; - private GuiCustomScroll scroll2; +public class SubGuiNpcBiomes extends SubGuiInterface { + private SpawnData data; + private GuiCustomScroll scroll1; + private GuiCustomScroll scroll2; - public SubGuiNpcBiomes(SpawnData data){ - this.data = data; - setBackground("menubg.png"); - xSize = 346; - ySize = 216; - closeOnEsc = true; + public SubGuiNpcBiomes(SpawnData data) { + this.data = data; + setBackground("menubg.png"); + xSize = 346; + ySize = 216; + closeOnEsc = true; } - public void initGui(){ + public void initGui() { super.initGui(); - if(scroll1 == null){ - scroll1 = new GuiCustomScroll(this,0); - scroll1.setSize(140, 180); + if (scroll1 == null) { + scroll1 = new GuiCustomScroll(this, 0); + scroll1.setSize(140, 180); } scroll1.guiLeft = guiLeft + 4; scroll1.guiTop = guiTop + 14; this.addScroll(scroll1); addLabel(new GuiNpcLabel(1, "spawning.availableBiomes", guiLeft + 4, guiTop + 4)); - if(scroll2 == null){ - scroll2 = new GuiCustomScroll(this,1); - scroll2.setSize(140, 180); + if (scroll2 == null) { + scroll2 = new GuiCustomScroll(this, 1); + scroll2.setSize(140, 180); } scroll2.guiLeft = guiLeft + 200; scroll2.guiTop = guiTop + 14; @@ -48,58 +47,58 @@ public class SubGuiNpcBiomes extends SubGuiInterface List biomes = new ArrayList(); for (BiomeGenBase base : BiomeGenBase.getBiomeGenArray()) { if (base != null && base.biomeName != null && !data.biomes.contains(base.biomeName)) { - biomes.add(base.biomeName); + biomes.add(base.biomeName); } } scroll1.setList(biomes); scroll2.setList(data.biomes); - addButton(new GuiNpcButton(1, guiLeft + 145, guiTop + 40, 55, 20, ">")); - addButton(new GuiNpcButton(2, guiLeft + 145, guiTop + 62, 55, 20, "<")); + addButton(new GuiNpcButton(1, guiLeft + 145, guiTop + 40, 55, 20, ">")); + addButton(new GuiNpcButton(2, guiLeft + 145, guiTop + 62, 55, 20, "<")); - addButton(new GuiNpcButton(3, guiLeft + 145, guiTop + 90, 55, 20, ">>")); - addButton(new GuiNpcButton(4, guiLeft + 145, guiTop + 112, 55, 20, "<<")); + addButton(new GuiNpcButton(3, guiLeft + 145, guiTop + 90, 55, 20, ">>")); + addButton(new GuiNpcButton(4, guiLeft + 145, guiTop + 112, 55, 20, "<<")); - addButton(new GuiNpcButton(66, guiLeft + 260, guiTop + 194, 60, 20, "gui.done")); + addButton(new GuiNpcButton(66, guiLeft + 260, guiTop + 194, 60, 20, "gui.done")); } - protected void actionPerformed(GuiButton guibutton){ - GuiNpcButton button = (GuiNpcButton) guibutton; - if(button.id == 1){ - if(scroll1.hasSelected()){ - data.biomes.add(scroll1.getSelected()); - scroll1.selected = -1; - scroll1.selected = -1; - initGui(); - } - } - if(button.id == 2){ - if(scroll2.hasSelected()){ - data.biomes.remove(scroll2.getSelected()); - scroll2.selected = -1; - initGui(); - } - } - if(button.id == 3){ - data.biomes.clear(); - for (BiomeGenBase base : BiomeGenBase.getBiomeGenArray()) { - if (base != null) { - data.biomes.add(base.biomeName); - } - } - scroll1.selected = -1; - scroll2.selected = -1; - initGui(); - } - if(button.id == 4){ - data.biomes.clear(); - scroll1.selected = -1; - scroll2.selected = -1; - initGui(); - } - if(button.id == 66){ - close(); + protected void actionPerformed(GuiButton guibutton) { + GuiNpcButton button = (GuiNpcButton) guibutton; + if (button.id == 1) { + if (scroll1.hasSelected()) { + data.biomes.add(scroll1.getSelected()); + scroll1.selected = -1; + scroll1.selected = -1; + initGui(); + } + } + if (button.id == 2) { + if (scroll2.hasSelected()) { + data.biomes.remove(scroll2.getSelected()); + scroll2.selected = -1; + initGui(); + } + } + if (button.id == 3) { + data.biomes.clear(); + for (BiomeGenBase base : BiomeGenBase.getBiomeGenArray()) { + if (base != null) { + data.biomes.add(base.biomeName); + } + } + scroll1.selected = -1; + scroll2.selected = -1; + initGui(); + } + if (button.id == 4) { + data.biomes.clear(); + scroll1.selected = -1; + scroll2.selected = -1; + initGui(); + } + if (button.id == 66) { + close(); } } diff --git a/src/main/java/noppes/npcs/client/gui/SubGuiNpcCommand.java b/src/main/java/noppes/npcs/client/gui/SubGuiNpcCommand.java index 0eaaaf595..9b3c42572 100644 --- a/src/main/java/noppes/npcs/client/gui/SubGuiNpcCommand.java +++ b/src/main/java/noppes/npcs/client/gui/SubGuiNpcCommand.java @@ -3,56 +3,52 @@ package noppes.npcs.client.gui; import net.minecraft.client.gui.GuiButton; import noppes.npcs.client.gui.util.*; -public class SubGuiNpcCommand extends SubGuiInterface implements ITextfieldListener -{ - public String command; +public class SubGuiNpcCommand extends SubGuiInterface implements ITextfieldListener { + public String command; - public SubGuiNpcCommand(String command) - { - this.command = command; - setBackground("menubg.png"); - xSize = 256; - ySize = 216; - closeOnEsc = true; + public SubGuiNpcCommand(String command) { + this.command = command; + setBackground("menubg.png"); + xSize = 256; + ySize = 216; + closeOnEsc = true; } - public void initGui() - { + public void initGui() { super.initGui(); this.addLabel(new GuiNpcLabel(4, "advMode.command", guiLeft + 4, guiTop + 74)); - this.addTextField(new GuiNpcTextField(4, this, this.fontRendererObj, guiLeft + 4, guiTop + 84, 248, 20, command)); - this.getTextField(4).setMaxStringLength(32767); + this.addTextField(new GuiNpcTextField(4, this, this.fontRendererObj, guiLeft + 4, guiTop + 84, 248, 20, command)); + this.getTextField(4).setMaxStringLength(32767); - this.addLabel(new GuiNpcLabel(5, "advMode.nearestPlayer", guiLeft + 4, guiTop + 110)); - this.addLabel(new GuiNpcLabel(6, "advMode.randomPlayer", guiLeft + 4, guiTop + 125)); - this.addLabel(new GuiNpcLabel(7, "advMode.allPlayers", guiLeft + 4, guiTop + 140)); - this.addLabel(new GuiNpcLabel(8, "dialog.commandoptionplayer", guiLeft + 4, guiTop + 155)); + this.addLabel(new GuiNpcLabel(5, "advMode.nearestPlayer", guiLeft + 4, guiTop + 110)); + this.addLabel(new GuiNpcLabel(6, "advMode.randomPlayer", guiLeft + 4, guiTop + 125)); + this.addLabel(new GuiNpcLabel(7, "advMode.allPlayers", guiLeft + 4, guiTop + 140)); + this.addLabel(new GuiNpcLabel(8, "dialog.commandoptionplayer", guiLeft + 4, guiTop + 155)); this.addLabel(new GuiNpcLabel(9, "dialog.commandmultiple", guiLeft + 4, guiTop + 170)); - this.addButton(new GuiNpcButton(66, guiLeft + 82, guiTop + 190,98, 20, "gui.done")); + this.addButton(new GuiNpcButton(66, guiLeft + 82, guiTop + 190, 98, 20, "gui.done")); } - protected void actionPerformed(GuiButton guibutton) - { - int id = guibutton.id; - if(id == 66){ - close(); + protected void actionPerformed(GuiButton guibutton) { + int id = guibutton.id; + if (id == 66) { + close(); } } @Override - public void close(){ - if(getTextField(4) != null){ + public void close() { + if (getTextField(4) != null) { unFocused(getTextField(4)); } super.close(); } - @Override - public void unFocused(GuiNpcTextField textfield) { - if(textfield.id == 4){ - command = textfield.getText(); - } - } + @Override + public void unFocused(GuiNpcTextField textfield) { + if (textfield.id == 4) { + command = textfield.getText(); + } + } } diff --git a/src/main/java/noppes/npcs/client/gui/SubGuiNpcDialog.java b/src/main/java/noppes/npcs/client/gui/SubGuiNpcDialog.java index f1efa4716..cff9e03f0 100644 --- a/src/main/java/noppes/npcs/client/gui/SubGuiNpcDialog.java +++ b/src/main/java/noppes/npcs/client/gui/SubGuiNpcDialog.java @@ -15,191 +15,182 @@ import noppes.npcs.controllers.data.Dialog; import noppes.npcs.controllers.data.PlayerMail; import noppes.npcs.entity.EntityDialogNpc; -public class SubGuiNpcDialog extends SubGuiInterface implements ISubGuiListener, GuiSelectionListener,ITextfieldListener -{ - public int dialogCategoryID; - public Dialog dialog; - private final GuiNPCManageDialogs parent; +public class SubGuiNpcDialog extends SubGuiInterface implements ISubGuiListener, GuiSelectionListener, ITextfieldListener { + public int dialogCategoryID; + public Dialog dialog; + private final GuiNPCManageDialogs parent; - public SubGuiNpcDialog(GuiNPCManageDialogs parent, Dialog dialog, int catId) - { - this.parent = parent; - this.dialog = dialog; - this.dialogCategoryID = catId; - setBackground("menubg.png"); - xSize = 360; - ySize = 216; - } + public SubGuiNpcDialog(GuiNPCManageDialogs parent, Dialog dialog, int catId) { + this.parent = parent; + this.dialog = dialog; + this.dialogCategoryID = catId; + setBackground("menubg.png"); + xSize = 360; + ySize = 216; + } - public void initGui() - { + public void initGui() { super.initGui(); - addLabel(new GuiNpcLabel(1,"gui.title", guiLeft + 4, guiTop + 8)); - addTextField(new GuiNpcTextField(1, this, this.fontRendererObj, guiLeft + 36, guiTop + 3, 200, 20, dialog.title)); + addLabel(new GuiNpcLabel(1, "gui.title", guiLeft + 4, guiTop + 8)); + addTextField(new GuiNpcTextField(1, this, this.fontRendererObj, guiLeft + 36, guiTop + 3, 200, 20, dialog.title)); - addLabel(new GuiNpcLabel(0,"ID", guiLeft + 238, guiTop + 4)); - addLabel(new GuiNpcLabel(2, dialog.id + "", guiLeft + 238, guiTop + 14)); + addLabel(new GuiNpcLabel(0, "ID", guiLeft + 238, guiTop + 4)); + addLabel(new GuiNpcLabel(2, dialog.id + "", guiLeft + 238, guiTop + 14)); - addLabel(new GuiNpcLabel(3, "dialog.dialogtext", guiLeft + 7, guiTop + 33)); - addButton(new GuiNpcButton(3, guiLeft + 120, guiTop + 28, 50, 20, "selectServer.edit")); + addLabel(new GuiNpcLabel(3, "dialog.dialogtext", guiLeft + 7, guiTop + 33)); + addButton(new GuiNpcButton(3, guiLeft + 120, guiTop + 28, 50, 20, "selectServer.edit")); - addLabel(new GuiNpcLabel(6, "dialog.options", guiLeft + 7, guiTop + 57)); - addButton(new GuiNpcButton(6, guiLeft + 120, guiTop + 52, 50, 20, "selectServer.edit")); + addLabel(new GuiNpcLabel(6, "dialog.options", guiLeft + 7, guiTop + 57)); + addButton(new GuiNpcButton(6, guiLeft + 120, guiTop + 52, 50, 20, "selectServer.edit")); - addLabel(new GuiNpcLabel(11, "dialog.visualOption", guiLeft + 7, guiTop + 81)); - addButton(new GuiNpcButton(11, guiLeft + 120, guiTop + 76, 50, 20, "selectServer.edit")); + addLabel(new GuiNpcLabel(11, "dialog.visualOption", guiLeft + 7, guiTop + 81)); + addButton(new GuiNpcButton(11, guiLeft + 120, guiTop + 76, 50, 20, "selectServer.edit")); - addLabel(new GuiNpcLabel(9, "gui.selectSound", guiLeft + 7, guiTop + 105)); - addTextField(new GuiNpcTextField(2, this, fontRendererObj, guiLeft + 90, guiTop + 100, 194, 20, dialog.sound)); - addButton(new GuiNpcButton(9, guiLeft + 293, guiTop + 100, 60, 20, "gui.select")); + addLabel(new GuiNpcLabel(9, "gui.selectSound", guiLeft + 7, guiTop + 105)); + addTextField(new GuiNpcTextField(2, this, fontRendererObj, guiLeft + 90, guiTop + 100, 194, 20, dialog.sound)); + addButton(new GuiNpcButton(9, guiLeft + 293, guiTop + 100, 60, 20, "gui.select")); - addLabel(new GuiNpcLabel(4, "availability.options", guiLeft + 180, guiTop + 33)); - addButton(new GuiNpcButton(4, guiLeft + 303, guiTop + 28, 50, 20, "selectServer.edit")); + addLabel(new GuiNpcLabel(4, "availability.options", guiLeft + 180, guiTop + 33)); + addButton(new GuiNpcButton(4, guiLeft + 303, guiTop + 28, 50, 20, "selectServer.edit")); - addLabel(new GuiNpcLabel(5, "faction.options", guiLeft + 180, guiTop + 57)); - addButton(new GuiNpcButton(5, guiLeft + 303, guiTop + 52, 50, 20, "selectServer.edit")); + addLabel(new GuiNpcLabel(5, "faction.options", guiLeft + 180, guiTop + 57)); + addButton(new GuiNpcButton(5, guiLeft + 303, guiTop + 52, 50, 20, "selectServer.edit")); - addButton(new GuiNpcButton(7, guiLeft + 4, guiTop + 130, 144, 20, "availability.selectquest")); - addButton(new GuiNpcButton(8, guiLeft + 150, guiTop + 130, 20, 20, "X")); + addButton(new GuiNpcButton(7, guiLeft + 4, guiTop + 130, 144, 20, "availability.selectquest")); + addButton(new GuiNpcButton(8, guiLeft + 150, guiTop + 130, 20, 20, "X")); - addButton(new GuiNpcButton(13, guiLeft + 4, guiTop + 154, 144, 20, "mailbox.setup")); - addButton(new GuiNpcButton(14, guiLeft + 150, guiTop + 154, 20, 20, "X")); + addButton(new GuiNpcButton(13, guiLeft + 4, guiTop + 154, 144, 20, "mailbox.setup")); + addButton(new GuiNpcButton(14, guiLeft + 150, guiTop + 154, 20, 20, "X")); - addButton(new GuiNpcButton(10, guiLeft + 303, guiTop + 130, 50, 20, "selectServer.edit")); - addLabel(new GuiNpcLabel(10, "advMode.command", guiLeft + 180, guiTop + 130 + 5)); + addButton(new GuiNpcButton(10, guiLeft + 303, guiTop + 130, 50, 20, "selectServer.edit")); + addLabel(new GuiNpcLabel(10, "advMode.command", guiLeft + 180, guiTop + 130 + 5)); - addButton(new GuiNpcButtonYesNo(15, guiLeft + 303, guiTop + 154, dialog.disableEsc)); - addLabel(new GuiNpcLabel(15, "dialog.disableEsc", guiLeft + 180, guiTop + 154 + 5)); + addButton(new GuiNpcButtonYesNo(15, guiLeft + 303, guiTop + 154, dialog.disableEsc)); + addLabel(new GuiNpcLabel(15, "dialog.disableEsc", guiLeft + 180, guiTop + 154 + 5)); - addButton(new GuiNpcButton(16, guiLeft + 303, guiTop + 192, 50, 20, "gui.done")); + addButton(new GuiNpcButton(16, guiLeft + 303, guiTop + 192, 50, 20, "gui.done")); addButton(new GuiNpcButton(17, guiLeft + 303 - 55, guiTop + 192, 50, 20, "gui.test")); - if(!parent.dialogQuestName.equals("")) - getButton(7).setDisplayText(parent.dialogQuestName); + if (!parent.dialogQuestName.equals("")) + getButton(7).setDisplayText(parent.dialogQuestName); - if(!dialog.mail.subject.isEmpty()) - getButton(13).setDisplayText(dialog.mail.subject); - } + if (!dialog.mail.subject.isEmpty()) + getButton(13).setDisplayText(dialog.mail.subject); + } - public void buttonEvent(GuiButton guibutton) - { - int id = guibutton.id; - if(id == 3 && dialog.id >= 0){ - setSubGui(new SubGuiNpcTextArea(dialog.text)); - } - if(id == 4 && dialog.id >= 0){ - setSubGui(new SubGuiNpcAvailability(dialog.availability)); - } - if(id == 5 && dialog.id >= 0){ - setSubGui(new SubGuiNpcFactionOptions(dialog.factionOptions)); - } - if(id == 6 && dialog.id >= 0){ - setSubGui(new SubGuiNpcDialogOptions(dialog)); - } - if(id == 7 && dialog.id >= 0){ + public void buttonEvent(GuiButton guibutton) { + int id = guibutton.id; + if (id == 3 && dialog.id >= 0) { + setSubGui(new SubGuiNpcTextArea(dialog.text)); + } + if (id == 4 && dialog.id >= 0) { + setSubGui(new SubGuiNpcAvailability(dialog.availability)); + } + if (id == 5 && dialog.id >= 0) { + setSubGui(new SubGuiNpcFactionOptions(dialog.factionOptions)); + } + if (id == 6 && dialog.id >= 0) { + setSubGui(new SubGuiNpcDialogOptions(dialog)); + } + if (id == 7 && dialog.id >= 0) { setSubGui(new GuiQuestSelection(dialog.quest)); - } - if(id == 8 && dialog.id >= 0){ - dialog.quest = -1; - parent.dialogQuestName = ""; - initGui(); - } - if(id == 9 && dialog.id >= 0){ + } + if (id == 8 && dialog.id >= 0) { + dialog.quest = -1; + parent.dialogQuestName = ""; + initGui(); + } + if (id == 9 && dialog.id >= 0) { setSubGui(new GuiSoundSelection((getTextField(2).getText()))); - } - if(id == 10){ - setSubGui(new SubGuiNpcCommand(dialog.command)); - } - if(id == 11){ - setSubGui(new SubGuiNpcDialogVisual(dialog)); - } - if(id == 13){ - setSubGui(new SubGuiMailmanSendSetup(dialog.mail, getParent())); - } - if(id == 14){ - dialog.mail = new PlayerMail(); - initGui(); - } - if(id == 15){ - if(guibutton instanceof GuiNpcButton){ - dialog.disableEsc = ((GuiNpcButton) guibutton).getValue() == 1; - } - } - if(id == 16){ - close(); - } - if(id == 17){ + } + if (id == 10) { + setSubGui(new SubGuiNpcCommand(dialog.command)); + } + if (id == 11) { + setSubGui(new SubGuiNpcDialogVisual(dialog)); + } + if (id == 13) { + setSubGui(new SubGuiMailmanSendSetup(dialog.mail, getParent())); + } + if (id == 14) { + dialog.mail = new PlayerMail(); + initGui(); + } + if (id == 15) { + if (guibutton instanceof GuiNpcButton) { + dialog.disableEsc = ((GuiNpcButton) guibutton).getValue() == 1; + } + } + if (id == 16) { + close(); + } + if (id == 17) { EntityDialogNpc npc = new EntityDialogNpc(player.worldObj); npc.display.name = "TEST"; EntityUtil.Copy(player, npc); GuiDialogInteract gui = new GuiDialogInteract(getParent(), npc, dialog); NoppesUtil.openGUI(player, gui); } - } + } - @Override - public void unFocused(GuiNpcTextField guiNpcTextField) { - if(guiNpcTextField.id == 1) { - if(dialog.id < 0) - guiNpcTextField.setText(""); - else{ - String name = guiNpcTextField.getText(); - if(name.isEmpty() || this.parent.dialogData.containsKey(name)){ - guiNpcTextField.setText(dialog.title); - } - else if(dialog.id >= 0){ - String old = dialog.title; - this.parent.dialogData.remove(old); - dialog.title = name; - this.parent.dialogData.put(dialog.title, dialog.id); - this.parent.dialogScroll.replace(old,dialog.title); - } - } - } - if(guiNpcTextField.id == 2) { - dialog.sound = guiNpcTextField.getText(); - } - } + @Override + public void unFocused(GuiNpcTextField guiNpcTextField) { + if (guiNpcTextField.id == 1) { + if (dialog.id < 0) + guiNpcTextField.setText(""); + else { + String name = guiNpcTextField.getText(); + if (name.isEmpty() || this.parent.dialogData.containsKey(name)) { + guiNpcTextField.setText(dialog.title); + } else if (dialog.id >= 0) { + String old = dialog.title; + this.parent.dialogData.remove(old); + dialog.title = name; + this.parent.dialogData.put(dialog.title, dialog.id); + this.parent.dialogScroll.replace(old, dialog.title); + } + } + } + if (guiNpcTextField.id == 2) { + dialog.sound = guiNpcTextField.getText(); + } + } - @Override - public void subGuiClosed(SubGuiInterface subgui){ - if(subgui instanceof SubGuiNpcTextArea){ - SubGuiNpcTextArea gui = (SubGuiNpcTextArea) subgui; - dialog.text = gui.text; - } - else if(subgui instanceof SubGuiNpcCommand){ - dialog.command = ((SubGuiNpcCommand) subgui).command; - } - else if(subgui instanceof GuiQuestSelection){ + @Override + public void subGuiClosed(SubGuiInterface subgui) { + if (subgui instanceof SubGuiNpcTextArea) { + SubGuiNpcTextArea gui = (SubGuiNpcTextArea) subgui; + dialog.text = gui.text; + } else if (subgui instanceof SubGuiNpcCommand) { + dialog.command = ((SubGuiNpcCommand) subgui).command; + } else if (subgui instanceof GuiQuestSelection) { GuiQuestSelection gqs = (GuiQuestSelection) subgui; - if(gqs.selectedQuest != null) { + if (gqs.selectedQuest != null) { dialog.quest = gqs.selectedQuest.id; initGui(); } - } - else if(subgui instanceof SubGuiMailmanSendSetup){ - initGui(); - } - else if (subgui instanceof GuiSoundSelection){ + } else if (subgui instanceof SubGuiMailmanSendSetup) { + initGui(); + } else if (subgui instanceof GuiSoundSelection) { GuiSoundSelection gss = (GuiSoundSelection) subgui; - if(gss.selectedResource != null) { + if (gss.selectedResource != null) { getTextField(2).setText(gss.selectedResource.toString()); unFocused(getTextField(2)); initGui(); } } - } + } - @Override - public void selected(int ob, String name) { - dialog.quest = ob; - parent.dialogQuestName = name; - initGui(); + @Override + public void selected(int ob, String name) { + dialog.quest = ob; + parent.dialogQuestName = name; + initGui(); PacketClient.sendClient(new DialogSavePacket(this.dialogCategoryID, dialog.writeToNBT(new NBTTagCompound()), false)); - } + } - public void save(){ + public void save() { PacketClient.sendClient(new DialogSavePacket(this.dialogCategoryID, dialog.writeToNBT(new NBTTagCompound()), false)); - } + } } diff --git a/src/main/java/noppes/npcs/client/gui/SubGuiNpcDialogOption.java b/src/main/java/noppes/npcs/client/gui/SubGuiNpcDialogOption.java index b47e71794..6a7accc98 100644 --- a/src/main/java/noppes/npcs/client/gui/SubGuiNpcDialogOption.java +++ b/src/main/java/noppes/npcs/client/gui/SubGuiNpcDialogOption.java @@ -9,20 +9,20 @@ import noppes.npcs.constants.EnumOptionType; import noppes.npcs.controllers.data.Dialog; import noppes.npcs.controllers.data.DialogOption; -public class SubGuiNpcDialogOption extends SubGuiInterface implements IGuiData, ITextfieldListener, GuiSelectionListener, ISubGuiListener{ - private DialogOption option; - public static int LastColor = 0xe0e0e0; +public class SubGuiNpcDialogOption extends SubGuiInterface implements IGuiData, ITextfieldListener, GuiSelectionListener, ISubGuiListener { + private DialogOption option; + public static int LastColor = 0xe0e0e0; - public SubGuiNpcDialogOption(DialogOption option){ - this.option = option; - setBackground("menubg.png"); - xSize = 256; - ySize = 216; - closeOnEsc = true; + public SubGuiNpcDialogOption(DialogOption option) { + this.option = option; + setBackground("menubg.png"); + xSize = 256; + ySize = 216; + closeOnEsc = true; } @Override - public void initGui(){ + public void initGui() { super.initGui(); this.addLabel(new GuiNpcLabel(66, "dialog.editoption", guiLeft, guiTop + 4)); this.getLabel(66).center(xSize); @@ -31,97 +31,96 @@ public class SubGuiNpcDialogOption extends SubGuiInterface implements IGuiData, this.addTextField(new GuiNpcTextField(0, this, this.fontRendererObj, guiLeft + 40, guiTop + 15, 196, 20, option.title)); String color = Integer.toHexString(option.optionColor); - while(color.length() < 6) - color = 0 + color; + while (color.length() < 6) + color = 0 + color; addLabel(new GuiNpcLabel(2, "gui.color", guiLeft + 4, guiTop + 45)); - this.addButton(new GuiNpcButton(2, guiLeft + 62, guiTop + 40, 92, 20, color)); - this.getButton(2).setTextColor(option.optionColor); + this.addButton(new GuiNpcButton(2, guiLeft + 62, guiTop + 40, 92, 20, color)); + this.getButton(2).setTextColor(option.optionColor); this.addLabel(new GuiNpcLabel(1, "dialog.optiontype", guiLeft + 4, guiTop + 67)); - this.addButton(new GuiNpcButton(1, guiLeft + 62, guiTop + 62, 92, 20, new String[]{"gui.close","dialog.dialog","gui.disabled","menu.role","tile.commandBlock.name"},option.optionType.ordinal())); + this.addButton(new GuiNpcButton(1, guiLeft + 62, guiTop + 62, 92, 20, new String[]{"gui.close", "dialog.dialog", "gui.disabled", "menu.role", "tile.commandBlock.name"}, option.optionType.ordinal())); - if(option.optionType == EnumOptionType.DialogOption){ - this.addButton(new GuiNpcButton(3, guiLeft + 4, guiTop + 84, "availability.selectdialog")); - if(option.dialogId >= 0) + if (option.optionType == EnumOptionType.DialogOption) { + this.addButton(new GuiNpcButton(3, guiLeft + 4, guiTop + 84, "availability.selectdialog")); + if (option.dialogId >= 0) DialogGetPacket.getDialog(option.dialogId); - } - if(option.optionType == EnumOptionType.CommandBlock){ - this.addTextField(new GuiNpcTextField(4, this, this.fontRendererObj, guiLeft + 4, guiTop + 84, 248, 20, option.command)); - this.getTextField(4).setMaxStringLength(32767); + } + if (option.optionType == EnumOptionType.CommandBlock) { + this.addTextField(new GuiNpcTextField(4, this, this.fontRendererObj, guiLeft + 4, guiTop + 84, 248, 20, option.command)); + this.getTextField(4).setMaxStringLength(32767); this.addLabel(new GuiNpcLabel(5, "advMode.nearestPlayer", guiLeft + 4, guiTop + 110)); this.addLabel(new GuiNpcLabel(6, "advMode.randomPlayer", guiLeft + 4, guiTop + 125)); this.addLabel(new GuiNpcLabel(7, "advMode.allPlayers", guiLeft + 4, guiTop + 140)); this.addLabel(new GuiNpcLabel(8, "dialog.commandoptionplayer", guiLeft + 4, guiTop + 155)); this.addLabel(new GuiNpcLabel(9, "dialog.commandmultiple", guiLeft + 4, guiTop + 170)); - } + } - this.addButton(new GuiNpcButton(66, guiLeft + 82, guiTop + 190,98, 20, "gui.done")); + this.addButton(new GuiNpcButton(66, guiLeft + 82, guiTop + 190, 98, 20, "gui.done")); } @Override - protected void actionPerformed(GuiButton guibutton){ - GuiNpcButton button = (GuiNpcButton) guibutton; + protected void actionPerformed(GuiButton guibutton) { + GuiNpcButton button = (GuiNpcButton) guibutton; - if(button.id == 1){ - option.optionType = EnumOptionType.values()[button.getValue()]; - initGui(); - } - if(button.id == 2){ - this.setSubGui(new SubGuiColorSelector(option.optionColor)); - } - if(button.id == 3){ + if (button.id == 1) { + option.optionType = EnumOptionType.values()[button.getValue()]; + initGui(); + } + if (button.id == 2) { + this.setSubGui(new SubGuiColorSelector(option.optionColor)); + } + if (button.id == 3) { setSubGui(new GuiDialogSelection(option.dialogId)); - } - if(button.id == 66) - { - close(); + } + if (button.id == 66) { + close(); } } - @Override - public void unFocused(GuiNpcTextField textfield) { - if(textfield.id == 0){ - if(textfield.isEmpty()) - textfield.setText(option.title); - else{ - option.title = textfield.getText(); - } - } - if(textfield.id == 4){ - option.command = textfield.getText(); - } - } - - @Override - public void setGuiData(NBTTagCompound compound) { - if(compound.hasKey("DialogId")){ - Dialog dialog = new Dialog(); - dialog.readNBT(compound); - option.dialogId = dialog.id; - if(this.getButton(3) != null) - getButton(3).setDisplayText(dialog.title); - } - } - - @Override - public void selected(int ob, String name) { - option.dialogId = ob; - } - - @Override - public void subGuiClosed(SubGuiInterface subgui) { - if(subgui instanceof SubGuiColorSelector) { - LastColor = option.optionColor = ((SubGuiColorSelector)subgui).color; + @Override + public void unFocused(GuiNpcTextField textfield) { + if (textfield.id == 0) { + if (textfield.isEmpty()) + textfield.setText(option.title); + else { + option.title = textfield.getText(); + } } - if(subgui instanceof GuiDialogSelection) { - Dialog dialog = ((GuiDialogSelection)subgui).selectedDialog; - if(dialog != null) { + if (textfield.id == 4) { + option.command = textfield.getText(); + } + } + + @Override + public void setGuiData(NBTTagCompound compound) { + if (compound.hasKey("DialogId")) { + Dialog dialog = new Dialog(); + dialog.readNBT(compound); + option.dialogId = dialog.id; + if (this.getButton(3) != null) + getButton(3).setDisplayText(dialog.title); + } + } + + @Override + public void selected(int ob, String name) { + option.dialogId = ob; + } + + @Override + public void subGuiClosed(SubGuiInterface subgui) { + if (subgui instanceof SubGuiColorSelector) { + LastColor = option.optionColor = ((SubGuiColorSelector) subgui).color; + } + if (subgui instanceof GuiDialogSelection) { + Dialog dialog = ((GuiDialogSelection) subgui).selectedDialog; + if (dialog != null) { option.dialogId = dialog.id; } } initGui(); - } + } } diff --git a/src/main/java/noppes/npcs/client/gui/SubGuiNpcDialogOptions.java b/src/main/java/noppes/npcs/client/gui/SubGuiNpcDialogOptions.java index 7e97d55b3..242a2ba22 100644 --- a/src/main/java/noppes/npcs/client/gui/SubGuiNpcDialogOptions.java +++ b/src/main/java/noppes/npcs/client/gui/SubGuiNpcDialogOptions.java @@ -8,55 +8,50 @@ import noppes.npcs.constants.EnumOptionType; import noppes.npcs.controllers.data.Dialog; import noppes.npcs.controllers.data.DialogOption; -public class SubGuiNpcDialogOptions extends SubGuiInterface -{ - private Dialog dialog; - - public SubGuiNpcDialogOptions(Dialog dialog) - { - this.dialog = dialog; - setBackground("menubg.png"); - xSize = 256; - ySize = 216; - closeOnEsc = true; +public class SubGuiNpcDialogOptions extends SubGuiInterface { + private Dialog dialog; + + public SubGuiNpcDialogOptions(Dialog dialog) { + this.dialog = dialog; + setBackground("menubg.png"); + xSize = 256; + ySize = 216; + closeOnEsc = true; } - public void initGui() - { + public void initGui() { super.initGui(); this.addLabel(new GuiNpcLabel(66, "dialog.options", guiLeft, guiTop + 4)); this.getLabel(66).center(xSize); - - for (int i = 0; i < 6; i++) { - String optionString = ""; - DialogOption option = dialog.options.get(i); - if(option != null && option.optionType != EnumOptionType.Disabled) - optionString += option.title; - this.addLabel(new GuiNpcLabel(i + 10, i + 1 + ": ", guiLeft + 4, guiTop + 16 + i * 32)); - this.addLabel(new GuiNpcLabel(i, optionString, guiLeft + 14, guiTop + 12 + i * 32)); - this.addButton(new GuiNpcButton(i, guiLeft + 13, guiTop + 21 + i * 32, 60, 20, "selectServer.edit")); - - } + for (int i = 0; i < 6; i++) { + String optionString = ""; + DialogOption option = dialog.options.get(i); + if (option != null && option.optionType != EnumOptionType.Disabled) + optionString += option.title; + + this.addLabel(new GuiNpcLabel(i + 10, i + 1 + ": ", guiLeft + 4, guiTop + 16 + i * 32)); + this.addLabel(new GuiNpcLabel(i, optionString, guiLeft + 14, guiTop + 12 + i * 32)); + this.addButton(new GuiNpcButton(i, guiLeft + 13, guiTop + 21 + i * 32, 60, 20, "selectServer.edit")); + + } + + this.addButton(new GuiNpcButton(66, guiLeft + 82, guiTop + 194, 98, 20, "gui.done")); - this.addButton(new GuiNpcButton(66, guiLeft + 82, guiTop + 194,98, 20, "gui.done")); - } - protected void actionPerformed(GuiButton guibutton) - { - int id = guibutton.id; - if(id < 6){ - DialogOption option = dialog.options.get(id); - if(option == null){ - dialog.options.put(id, option = new DialogOption()); - option.optionColor = SubGuiNpcDialogOption.LastColor; - } - this.setSubGui(new SubGuiNpcDialogOption(option)); + protected void actionPerformed(GuiButton guibutton) { + int id = guibutton.id; + if (id < 6) { + DialogOption option = dialog.options.get(id); + if (option == null) { + dialog.options.put(id, option = new DialogOption()); + option.optionColor = SubGuiNpcDialogOption.LastColor; + } + this.setSubGui(new SubGuiNpcDialogOption(option)); } - if(id == 66) - { - close(); + if (id == 66) { + close(); } } } diff --git a/src/main/java/noppes/npcs/client/gui/SubGuiNpcDialogVisual.java b/src/main/java/noppes/npcs/client/gui/SubGuiNpcDialogVisual.java index 81da655e8..81892873c 100644 --- a/src/main/java/noppes/npcs/client/gui/SubGuiNpcDialogVisual.java +++ b/src/main/java/noppes/npcs/client/gui/SubGuiNpcDialogVisual.java @@ -32,17 +32,16 @@ public class SubGuiNpcDialogVisual extends SubGuiInterface implements ISubGuiLis closeOnEsc = true; } - public void initGui() - { + public void initGui() { super.initGui(); int y = guiTop - 10; - GuiMenuTopButton close = new GuiMenuTopButton(0,guiLeft + xSize - 22, guiTop - 17, "X"); - GuiMenuTopButton general = new GuiMenuTopButton(1, guiLeft + 4, guiTop - 17, "General"); - GuiMenuTopButton spacing = new GuiMenuTopButton(2, general.xPosition + general.getWidth(), guiTop - 17, "Spacing"); - GuiMenuTopButton images = new GuiMenuTopButton(3, spacing.xPosition + spacing.getWidth(), guiTop - 17, "Images"); - topButtons = new GuiMenuTopButton[]{general,images,spacing,close}; - for(GuiMenuTopButton button : topButtons) { + GuiMenuTopButton close = new GuiMenuTopButton(0, guiLeft + xSize - 22, guiTop - 17, "X"); + GuiMenuTopButton general = new GuiMenuTopButton(1, guiLeft + 4, guiTop - 17, "General"); + GuiMenuTopButton spacing = new GuiMenuTopButton(2, general.xPosition + general.getWidth(), guiTop - 17, "Spacing"); + GuiMenuTopButton images = new GuiMenuTopButton(3, spacing.xPosition + spacing.getWidth(), guiTop - 17, "Images"); + topButtons = new GuiMenuTopButton[]{general, images, spacing, close}; + for (GuiMenuTopButton button : topButtons) { button.active = button.id == activeMenu; addButton(button); } @@ -202,7 +201,7 @@ public class SubGuiNpcDialogVisual extends SubGuiInterface implements ISubGuiLis getTextField(17).setMinMaxDefault(-Integer.MAX_VALUE, Integer.MAX_VALUE, 0); String color = Integer.toHexString(dialogImage.color); - while(color.length() < 6) + while (color.length() < 6) color = 0 + color; addButton(new GuiNpcButton(18, guiLeft + 35, y += 25, 60, 20, color)); addLabel(new GuiNpcLabel(15, "gui.color", guiLeft + 4, y + 5)); @@ -232,10 +231,10 @@ public class SubGuiNpcDialogVisual extends SubGuiInterface implements ISubGuiLis addLabel(new GuiNpcLabel(20, "gui.type", guiLeft + 4, y + 5)); addButton(new GuiNpcButton(24, guiLeft + 160, y, 60, 20, - new String[]{"display.topLeft", "display.topCenter", "display.topRight", - "display.left", "display.center", "display.right", - "display.botLeft", "display.botCenter", "display.botRight"}, - dialogImage.alignment)); + new String[]{"display.topLeft", "display.topCenter", "display.topRight", + "display.left", "display.center", "display.right", + "display.botLeft", "display.botCenter", "display.botRight"}, + dialogImage.alignment)); addLabel(new GuiNpcLabel(21, "display.alignment", guiLeft + 110, y + 5)); getButton(24).setEnabled(dialogImage.imageType == 0); getButton(24).setVisible(dialogImage.imageType == 0); @@ -266,7 +265,7 @@ public class SubGuiNpcDialogVisual extends SubGuiInterface implements ISubGuiLis NoppesUtil.clickSound(); int id = button.id; - if(id == 0){ + if (id == 0) { close(); return; } @@ -277,7 +276,7 @@ public class SubGuiNpcDialogVisual extends SubGuiInterface implements ISubGuiLis } @Override - protected void actionPerformed(GuiButton guibutton){ + protected void actionPerformed(GuiButton guibutton) { GuiNpcButton button = (GuiNpcButton) guibutton; if (guibutton instanceof GuiMenuTopButton) { @@ -385,15 +384,15 @@ public class SubGuiNpcDialogVisual extends SubGuiInterface implements ISubGuiLis } @Override - public void drawScreen(int i, int j, float f){ - super.drawScreen(i,j,f); - for(GuiMenuTopButton button: topButtons) + public void drawScreen(int i, int j, float f) { + super.drawScreen(i, j, f); + for (GuiMenuTopButton button : topButtons) button.drawButton(mc, i, j); } @Override - public void subGuiClosed(SubGuiInterface subgui){ + public void subGuiClosed(SubGuiInterface subgui) { if (activeMenu == 1) { if (lastColorClicked == 0) { dialog.color = ((SubGuiColorSelector) subgui).color; @@ -418,8 +417,8 @@ public class SubGuiNpcDialogVisual extends SubGuiInterface implements ISubGuiLis public void save() { GuiNpcTextField.unfocus(); - if(dialog.id >= 0) - PacketClient.sendClient(new DialogSavePacket(((SubGuiNpcDialog)parent).dialogCategoryID, dialog.writeToNBT(new NBTTagCompound()), false)); + if (dialog.id >= 0) + PacketClient.sendClient(new DialogSavePacket(((SubGuiNpcDialog) parent).dialogCategoryID, dialog.writeToNBT(new NBTTagCompound()), false)); } private DialogImage getSelectedImage() { @@ -545,7 +544,7 @@ public class SubGuiNpcDialogVisual extends SubGuiInterface implements ISubGuiLis @Override public void customScrollClicked(int i, int j, int k, GuiCustomScroll guiCustomScroll) { - if(guiCustomScroll.id == 0 && imageScroll != null) { + if (guiCustomScroll.id == 0 && imageScroll != null) { selected = guiCustomScroll.selected; initGui(); } diff --git a/src/main/java/noppes/npcs/client/gui/SubGuiNpcDimensions.java b/src/main/java/noppes/npcs/client/gui/SubGuiNpcDimensions.java index 2bc34cbbc..03f8301ab 100644 --- a/src/main/java/noppes/npcs/client/gui/SubGuiNpcDimensions.java +++ b/src/main/java/noppes/npcs/client/gui/SubGuiNpcDimensions.java @@ -9,112 +9,111 @@ import noppes.npcs.controllers.data.SpawnData; import java.util.*; -public class SubGuiNpcDimensions extends SubGuiInterface implements IScrollData -{ - private final SpawnData data; - private GuiCustomScroll allDimensions; - private HashMap dimensionMap = new HashMap<>(); - private GuiCustomScroll dataDimensions; +public class SubGuiNpcDimensions extends SubGuiInterface implements IScrollData { + private final SpawnData data; + private GuiCustomScroll allDimensions; + private HashMap dimensionMap = new HashMap<>(); + private GuiCustomScroll dataDimensions; - public SubGuiNpcDimensions(SpawnData data){ - this.data = data; - setBackground("menubg.png"); - xSize = 346; - ySize = 216; - closeOnEsc = true; + public SubGuiNpcDimensions(SpawnData data) { + this.data = data; + setBackground("menubg.png"); + xSize = 346; + ySize = 216; + closeOnEsc = true; PacketClient.sendClient(new DimensionsGetPacket()); } - public void initGui(){ + public void initGui() { super.initGui(); - if(allDimensions == null){ - allDimensions = new GuiCustomScroll(this,0); - allDimensions.setSize(140, 180); + if (allDimensions == null) { + allDimensions = new GuiCustomScroll(this, 0); + allDimensions.setSize(140, 180); } allDimensions.guiLeft = guiLeft + 4; allDimensions.guiTop = guiTop + 14; this.addScroll(allDimensions); addLabel(new GuiNpcLabel(1, "spawning.availableDimensions", guiLeft + 4, guiTop + 4)); - if(dataDimensions == null){ - dataDimensions = new GuiCustomScroll(this,1); - dataDimensions.setSize(140, 180); + if (dataDimensions == null) { + dataDimensions = new GuiCustomScroll(this, 1); + dataDimensions.setSize(140, 180); } dataDimensions.guiLeft = guiLeft + 200; dataDimensions.guiTop = guiTop + 14; this.addScroll(dataDimensions); addLabel(new GuiNpcLabel(2, "spawning.spawningDimensions", guiLeft + 200, guiTop + 4)); - ArrayList dimensions = new ArrayList<>(); - Set> entrySet = this.dimensionMap.entrySet(); - for (Map.Entry entry : entrySet) { - if (this.data.dimensions.contains(entry.getValue())) { - dimensions.add(entry.getKey()); - } - } - dataDimensions.setList(dimensions); + ArrayList dimensions = new ArrayList<>(); + Set> entrySet = this.dimensionMap.entrySet(); + for (Map.Entry entry : entrySet) { + if (this.data.dimensions.contains(entry.getValue())) { + dimensions.add(entry.getKey()); + } + } + dataDimensions.setList(dimensions); - addButton(new GuiNpcButton(1, guiLeft + 145, guiTop + 40, 55, 20, ">")); - addButton(new GuiNpcButton(2, guiLeft + 145, guiTop + 62, 55, 20, "<")); + addButton(new GuiNpcButton(1, guiLeft + 145, guiTop + 40, 55, 20, ">")); + addButton(new GuiNpcButton(2, guiLeft + 145, guiTop + 62, 55, 20, "<")); - addButton(new GuiNpcButton(3, guiLeft + 145, guiTop + 90, 55, 20, ">>")); - addButton(new GuiNpcButton(4, guiLeft + 145, guiTop + 112, 55, 20, "<<")); + addButton(new GuiNpcButton(3, guiLeft + 145, guiTop + 90, 55, 20, ">>")); + addButton(new GuiNpcButton(4, guiLeft + 145, guiTop + 112, 55, 20, "<<")); - addButton(new GuiNpcButton(66, guiLeft + 260, guiTop + 194, 60, 20, "gui.done")); + addButton(new GuiNpcButton(66, guiLeft + 260, guiTop + 194, 60, 20, "gui.done")); } - protected void actionPerformed(GuiButton guibutton){ - GuiNpcButton button = (GuiNpcButton) guibutton; - if(button.id == 1){ - if(allDimensions.hasSelected()){ - data.dimensions.add(dimensionMap.get(allDimensions.getSelected())); - allDimensions.selected = -1; - initGui(); - } - } - if(button.id == 2){ - if(dataDimensions.hasSelected()){ - data.dimensions.remove(dimensionMap.get(dataDimensions.getSelected())); - dataDimensions.selected = -1; - initGui(); - } - } - if(button.id == 3){ - data.dimensions.clear(); - this.data.dimensions.addAll(this.dimensionMap.values()); - allDimensions.selected = -1; - initGui(); - } - if(button.id == 4){ - data.dimensions.clear(); - allDimensions.selected = -1; - initGui(); - } - if(button.id == 66){ - close(); + protected void actionPerformed(GuiButton guibutton) { + GuiNpcButton button = (GuiNpcButton) guibutton; + if (button.id == 1) { + if (allDimensions.hasSelected()) { + data.dimensions.add(dimensionMap.get(allDimensions.getSelected())); + allDimensions.selected = -1; + initGui(); + } + } + if (button.id == 2) { + if (dataDimensions.hasSelected()) { + data.dimensions.remove(dimensionMap.get(dataDimensions.getSelected())); + dataDimensions.selected = -1; + initGui(); + } + } + if (button.id == 3) { + data.dimensions.clear(); + this.data.dimensions.addAll(this.dimensionMap.values()); + allDimensions.selected = -1; + initGui(); + } + if (button.id == 4) { + data.dimensions.clear(); + allDimensions.selected = -1; + initGui(); + } + if (button.id == 66) { + close(); } } - @Override - public void setData(Vector list, HashMap data, EnumScrollData type) { - this.allDimensions.setList(list); - this.dimensionMap = data; + @Override + public void setData(Vector list, HashMap data, EnumScrollData type) { + this.allDimensions.setList(list); + this.dimensionMap = data; - ArrayList dimensions = new ArrayList<>(); - Set> entrySet = this.dimensionMap.entrySet(); - for (Map.Entry entry : entrySet) { - if (this.data.dimensions.contains(entry.getValue())) { - dimensions.add(entry.getKey()); - } - } - dataDimensions.setList(dimensions); + ArrayList dimensions = new ArrayList<>(); + Set> entrySet = this.dimensionMap.entrySet(); + for (Map.Entry entry : entrySet) { + if (this.data.dimensions.contains(entry.getValue())) { + dimensions.add(entry.getKey()); + } + } + dataDimensions.setList(dimensions); - initGui(); - } + initGui(); + } - @Override - public void setSelected(String selected) { + @Override + public void setSelected(String selected) { - } + } } diff --git a/src/main/java/noppes/npcs/client/gui/SubGuiNpcFactionOptions.java b/src/main/java/noppes/npcs/client/gui/SubGuiNpcFactionOptions.java index 95ee03f5f..b2ece2a5d 100644 --- a/src/main/java/noppes/npcs/client/gui/SubGuiNpcFactionOptions.java +++ b/src/main/java/noppes/npcs/client/gui/SubGuiNpcFactionOptions.java @@ -11,68 +11,65 @@ import noppes.npcs.controllers.data.FactionOptions; import java.util.HashMap; import java.util.Vector; -public class SubGuiNpcFactionOptions extends SubGuiInterface implements IScrollData,ICustomScrollListener -{ - private FactionOptions options; - private HashMap data = new HashMap(); - private GuiCustomScroll scrollFactions; +public class SubGuiNpcFactionOptions extends SubGuiInterface implements IScrollData, ICustomScrollListener { + private FactionOptions options; + private HashMap data = new HashMap(); + private GuiCustomScroll scrollFactions; - private int selected = -1; + private int selected = -1; - public SubGuiNpcFactionOptions(FactionOptions options) - { - this.options = options; - setBackground("menubg.png"); - xSize = 256; - ySize = 216; - closeOnEsc = true; + public SubGuiNpcFactionOptions(FactionOptions options) { + this.options = options; + setBackground("menubg.png"); + xSize = 256; + ySize = 216; + closeOnEsc = true; PacketClient.sendClient(new FactionsGetPacket()); } - public void initGui() - { + public void initGui() { super.initGui(); - if(scrollFactions == null){ - scrollFactions = new GuiCustomScroll(this,0); - scrollFactions.setSize(120, 208); + if (scrollFactions == null) { + scrollFactions = new GuiCustomScroll(this, 0); + scrollFactions.setSize(120, 208); } scrollFactions.guiLeft = guiLeft + 130; scrollFactions.guiTop = guiTop + 4; addScroll(scrollFactions); - addLabel(new GuiNpcLabel(0, "1: ", guiLeft + 4, guiTop + 12)); - if(data.containsValue(options.factionId)){ - addLabel(new GuiNpcLabel(1, getFactionName(options.factionId), guiLeft + 12, guiTop + 8)); + addLabel(new GuiNpcLabel(0, "1: ", guiLeft + 4, guiTop + 12)); + if (data.containsValue(options.factionId)) { + addLabel(new GuiNpcLabel(1, getFactionName(options.factionId), guiLeft + 12, guiTop + 8)); String label = ""; - if(options.decreaseFactionPoints) - label += StatCollector.translateToLocal("gui.decrease"); + if (options.decreaseFactionPoints) + label += StatCollector.translateToLocal("gui.decrease"); else - label += StatCollector.translateToLocal("gui.increase"); + label += StatCollector.translateToLocal("gui.increase"); label += " " + options.factionPoints + " " + StatCollector.translateToLocal("faction.points"); - addLabel(new GuiNpcLabel(3, label, guiLeft + 12, guiTop + 16)); + addLabel(new GuiNpcLabel(3, label, guiLeft + 12, guiTop + 16)); addButton(new GuiNpcButton(0, guiLeft + 110, guiTop + 7, 20, 20, "X")); } - addLabel(new GuiNpcLabel(4, "2: ", guiLeft + 4, guiTop + 40)); - if(data.containsValue(options.faction2Id)){ - addLabel(new GuiNpcLabel(5, getFactionName(options.faction2Id), guiLeft + 12, guiTop + 36)); + addLabel(new GuiNpcLabel(4, "2: ", guiLeft + 4, guiTop + 40)); + if (data.containsValue(options.faction2Id)) { + addLabel(new GuiNpcLabel(5, getFactionName(options.faction2Id), guiLeft + 12, guiTop + 36)); String label = ""; - if(options.decreaseFaction2Points) - label += StatCollector.translateToLocal("gui.decrease"); + if (options.decreaseFaction2Points) + label += StatCollector.translateToLocal("gui.decrease"); else - label += StatCollector.translateToLocal("gui.increase"); + label += StatCollector.translateToLocal("gui.increase"); label += " " + options.faction2Points + " " + StatCollector.translateToLocal("faction.points"); - addLabel(new GuiNpcLabel(6, label, guiLeft + 12, guiTop + 44)); + addLabel(new GuiNpcLabel(6, label, guiLeft + 12, guiTop + 44)); addButton(new GuiNpcButton(1, guiLeft + 110, guiTop + 35, 20, 20, "X")); } - if(selected >= 0 && (!data.containsValue(options.faction2Id) || !data.containsValue(options.factionId)) && !options.hasFaction(selected)){ - addButton(new GuiNpcButton(2, guiLeft + 4, guiTop + 60, 90, 20, new String[]{"gui.increase","gui.decrease"},0)); + if (selected >= 0 && (!data.containsValue(options.faction2Id) || !data.containsValue(options.factionId)) && !options.hasFaction(selected)) { + addButton(new GuiNpcButton(2, guiLeft + 4, guiTop + 60, 90, 20, new String[]{"gui.increase", "gui.decrease"}, 0)); addTextField(new GuiNpcTextField(1, this, fontRendererObj, guiLeft + 4, guiTop + 82, 110, 20, "10")); getTextField(1).integersOnly = true; @@ -83,69 +80,64 @@ public class SubGuiNpcFactionOptions extends SubGuiInterface implements IScrollD addButton(new GuiNpcButton(66, guiLeft + 20, guiTop + 192, 90, 20, "gui.done")); } - private String getFactionName(int faction){ - for(String s : data.keySet()) - if(data.get(s) == faction) - return s; - return null; + + private String getFactionName(int faction) { + for (String s : data.keySet()) + if (data.get(s) == faction) + return s; + return null; } - protected void actionPerformed(GuiButton guibutton) - { - int id = guibutton.id; - if(id == 0) - { - options.factionId = -1; - initGui(); + protected void actionPerformed(GuiButton guibutton) { + int id = guibutton.id; + if (id == 0) { + options.factionId = -1; + initGui(); } - if(id == 1) - { - options.faction2Id = -1; - initGui(); + if (id == 1) { + options.faction2Id = -1; + initGui(); } - if(id == 3) - { - if(!data.containsValue(options.factionId)){ - options.factionId = selected; - options.decreaseFactionPoints = getButton(2).getValue() == 1; - options.factionPoints = getTextField(1).getInteger(); - } - else if(!data.containsValue(options.faction2Id)){ - options.faction2Id = selected; - options.decreaseFaction2Points = getButton(2).getValue() == 1; - options.faction2Points = getTextField(1).getInteger(); - } - initGui(); + if (id == 3) { + if (!data.containsValue(options.factionId)) { + options.factionId = selected; + options.decreaseFactionPoints = getButton(2).getValue() == 1; + options.factionPoints = getTextField(1).getInteger(); + } else if (!data.containsValue(options.faction2Id)) { + options.faction2Id = selected; + options.decreaseFaction2Points = getButton(2).getValue() == 1; + options.faction2Points = getTextField(1).getInteger(); + } + initGui(); } - if(id == 66) - { - close(); + if (id == 66) { + close(); } } - @Override - public void customScrollClicked(int i, int j, int k, - GuiCustomScroll guiCustomScroll) { - selected = data.get(guiCustomScroll.getSelected()); - initGui(); - } + @Override + public void customScrollClicked(int i, int j, int k, + GuiCustomScroll guiCustomScroll) { + selected = data.get(guiCustomScroll.getSelected()); + initGui(); + } - @Override - public void setData(Vector list, HashMap data, EnumScrollData type) { - GuiCustomScroll scroll = getScroll(0); - String name = scroll.getSelected(); - this.data = data; - scroll.setList(list); + @Override + public void setData(Vector list, HashMap data, EnumScrollData type) { + GuiCustomScroll scroll = getScroll(0); + String name = scroll.getSelected(); + this.data = data; + scroll.setList(list); - if(name != null) - scroll.setSelected(name); + if (name != null) + scroll.setSelected(name); - initGui(); - } + initGui(); + } - @Override - public void setSelected(String selected) { + @Override + public void setSelected(String selected) { - } + } } diff --git a/src/main/java/noppes/npcs/client/gui/SubGuiNpcFactionPoints.java b/src/main/java/noppes/npcs/client/gui/SubGuiNpcFactionPoints.java index 9a5952e07..074464d74 100644 --- a/src/main/java/noppes/npcs/client/gui/SubGuiNpcFactionPoints.java +++ b/src/main/java/noppes/npcs/client/gui/SubGuiNpcFactionPoints.java @@ -5,62 +5,62 @@ import net.minecraft.util.StatCollector; import noppes.npcs.client.gui.util.*; import noppes.npcs.controllers.data.Faction; -public class SubGuiNpcFactionPoints extends SubGuiInterface implements ITextfieldListener -{ - private Faction faction; - public SubGuiNpcFactionPoints(Faction faction){ - this.faction = faction; - setBackground("menubg.png"); - xSize = 256; - ySize = 216; - closeOnEsc = true; +public class SubGuiNpcFactionPoints extends SubGuiInterface implements ITextfieldListener { + private Faction faction; + + public SubGuiNpcFactionPoints(Faction faction) { + this.faction = faction; + setBackground("menubg.png"); + xSize = 256; + ySize = 216; + closeOnEsc = true; } @Override - public void initGui(){ + public void initGui() { super.initGui(); - - addLabel(new GuiNpcLabel(2,"faction.default", guiLeft + 4, guiTop + 33)); - - this.addTextField(new GuiNpcTextField(2, this, guiLeft + 8 + fontRendererObj.getStringWidth(getLabel(2).label), guiTop + 28, 70, 20, faction.defaultPoints + "")); - getTextField(2).setMaxStringLength(6); - getTextField(2).integersOnly = true; - - String title = StatCollector.translateToLocal("faction.unfriendly") + "<->" + StatCollector.translateToLocal("faction.neutral"); - addLabel(new GuiNpcLabel(3, title, guiLeft + 4, guiTop + 80)); - addTextField(new GuiNpcTextField(3, this, guiLeft + 8 + fontRendererObj.getStringWidth(title), guiTop + 75, 70, 20, faction.neutralPoints + "")); - title = StatCollector.translateToLocal("faction.neutral") + "<->" + StatCollector.translateToLocal("faction.friendly"); - addLabel(new GuiNpcLabel(4, title, guiLeft + 4, guiTop + 105)); - addTextField(new GuiNpcTextField(4, this, guiLeft + 8 + fontRendererObj.getStringWidth(title), guiTop + 100, 70, 20, faction.friendlyPoints + "")); + addLabel(new GuiNpcLabel(2, "faction.default", guiLeft + 4, guiTop + 33)); - getTextField(3).integersOnly = true; - getTextField(4).integersOnly = true; - - if(getTextField(3).xPosition > getTextField(4).xPosition) - getTextField(4).xPosition = getTextField(3).xPosition; - else - getTextField(3).xPosition = getTextField(4).xPosition; - - addButton(new GuiNpcButton(66, guiLeft + 20, guiTop + 192, 90, 20, "gui.done")); + this.addTextField(new GuiNpcTextField(2, this, guiLeft + 8 + fontRendererObj.getStringWidth(getLabel(2).label), guiTop + 28, 70, 20, faction.defaultPoints + "")); + getTextField(2).setMaxStringLength(6); + getTextField(2).integersOnly = true; + + String title = StatCollector.translateToLocal("faction.unfriendly") + "<->" + StatCollector.translateToLocal("faction.neutral"); + addLabel(new GuiNpcLabel(3, title, guiLeft + 4, guiTop + 80)); + addTextField(new GuiNpcTextField(3, this, guiLeft + 8 + fontRendererObj.getStringWidth(title), guiTop + 75, 70, 20, faction.neutralPoints + "")); + + title = StatCollector.translateToLocal("faction.neutral") + "<->" + StatCollector.translateToLocal("faction.friendly"); + addLabel(new GuiNpcLabel(4, title, guiLeft + 4, guiTop + 105)); + addTextField(new GuiNpcTextField(4, this, guiLeft + 8 + fontRendererObj.getStringWidth(title), guiTop + 100, 70, 20, faction.friendlyPoints + "")); + + getTextField(3).integersOnly = true; + getTextField(4).integersOnly = true; + + if (getTextField(3).xPosition > getTextField(4).xPosition) + getTextField(4).xPosition = getTextField(3).xPosition; + else + getTextField(3).xPosition = getTextField(4).xPosition; + + addButton(new GuiNpcButton(66, guiLeft + 20, guiTop + 192, 90, 20, "gui.done")); } @Override - public void unFocused(GuiNpcTextField textfield) { - if(textfield.id == 2) { - faction.defaultPoints = textfield.getInteger(); - }else if(textfield.id == 3) { - faction.neutralPoints = textfield.getInteger(); - }else if(textfield.id == 4) { - faction.friendlyPoints = textfield.getInteger(); - } - } + public void unFocused(GuiNpcTextField textfield) { + if (textfield.id == 2) { + faction.defaultPoints = textfield.getInteger(); + } else if (textfield.id == 3) { + faction.neutralPoints = textfield.getInteger(); + } else if (textfield.id == 4) { + faction.friendlyPoints = textfield.getInteger(); + } + } @Override - protected void actionPerformed(GuiButton guibutton){ - int id = guibutton.id; - if(id == 66){ - close(); + protected void actionPerformed(GuiButton guibutton) { + int id = guibutton.id; + if (id == 66) { + close(); } } diff --git a/src/main/java/noppes/npcs/client/gui/SubGuiNpcMeleeProperties.java b/src/main/java/noppes/npcs/client/gui/SubGuiNpcMeleeProperties.java index 5b55631d6..c9d451c1b 100644 --- a/src/main/java/noppes/npcs/client/gui/SubGuiNpcMeleeProperties.java +++ b/src/main/java/noppes/npcs/client/gui/SubGuiNpcMeleeProperties.java @@ -5,86 +5,77 @@ import noppes.npcs.DataStats; import noppes.npcs.client.gui.util.*; import noppes.npcs.constants.EnumPotionType; -public class SubGuiNpcMeleeProperties extends SubGuiInterface implements ITextfieldListener -{ - private DataStats stats; - private String[] potionNames = new String[]{"gui.none", "tile.fire.name", "potion.poison", "potion.hunger", "potion.weakness", "potion.moveSlowdown", "potion.confusion", "potion.blindness", "potion.wither"}; +public class SubGuiNpcMeleeProperties extends SubGuiInterface implements ITextfieldListener { + private DataStats stats; + private String[] potionNames = new String[]{"gui.none", "tile.fire.name", "potion.poison", "potion.hunger", "potion.weakness", "potion.moveSlowdown", "potion.confusion", "potion.blindness", "potion.wither"}; - public SubGuiNpcMeleeProperties(DataStats stats) - { - this.stats = stats; - setBackground("menubg.png"); - xSize = 256; - ySize = 216; - closeOnEsc = true; + public SubGuiNpcMeleeProperties(DataStats stats) { + this.stats = stats; + setBackground("menubg.png"); + xSize = 256; + ySize = 216; + closeOnEsc = true; } - public void initGui() - { + public void initGui() { super.initGui(); - addLabel(new GuiNpcLabel(1,"stats.meleestrength", guiLeft + 5, guiTop + 15)); - addTextField(new GuiNpcTextField(1,this, fontRendererObj, guiLeft + 85, guiTop + 10, 160, 18, String.format("%.0f", stats.getAttackStrength()) + "")); + addLabel(new GuiNpcLabel(1, "stats.meleestrength", guiLeft + 5, guiTop + 15)); + addTextField(new GuiNpcTextField(1, this, fontRendererObj, guiLeft + 85, guiTop + 10, 160, 18, String.format("%.0f", stats.getAttackStrength()) + "")); getTextField(1).floatsOnly = true; - getTextField(1).setMinMaxDefaultFloat(0,Float.MAX_VALUE,5); - addLabel(new GuiNpcLabel(2,"stats.meleerange", guiLeft + 5, guiTop + 45)); - addTextField(new GuiNpcTextField(2,this, fontRendererObj, guiLeft + 85, guiTop + 40, 40, 18, stats.attackRange+"")); + getTextField(1).setMinMaxDefaultFloat(0, Float.MAX_VALUE, 5); + addLabel(new GuiNpcLabel(2, "stats.meleerange", guiLeft + 5, guiTop + 45)); + addTextField(new GuiNpcTextField(2, this, fontRendererObj, guiLeft + 85, guiTop + 40, 40, 18, stats.attackRange + "")); getTextField(2).integersOnly = true; getTextField(2).setMinMaxDefault(1, Integer.MAX_VALUE, 2); - addLabel(new GuiNpcLabel(3,"stats.meleespeed", guiLeft + 5, guiTop + 75)); - addTextField(new GuiNpcTextField(3,this, fontRendererObj, guiLeft + 85, guiTop + 70, 40, 18, stats.attackSpeed+"")); + addLabel(new GuiNpcLabel(3, "stats.meleespeed", guiLeft + 5, guiTop + 75)); + addTextField(new GuiNpcTextField(3, this, fontRendererObj, guiLeft + 85, guiTop + 70, 40, 18, stats.attackSpeed + "")); getTextField(3).integersOnly = true; getTextField(3).setMinMaxDefault(1, Integer.MAX_VALUE, 20); - addLabel(new GuiNpcLabel(4,"enchantment.knockback", guiLeft + 5, guiTop + 105)); - addTextField(new GuiNpcTextField(4,this, fontRendererObj, guiLeft + 85, guiTop + 100, 40, 18, stats.knockback + "")); - getTextField(4).integersOnly = true; - getTextField(4).setMinMaxDefault(0, Integer.MAX_VALUE, 0); - addLabel(new GuiNpcLabel(5,"stats.meleeeffect", guiLeft + 5, guiTop + 135)); - addButton(new GuiButtonBiDirectional(5,guiLeft + 85, guiTop + 130, 100, 20, potionNames, stats.potionType.ordinal())); - if(stats.potionType != EnumPotionType.None) { - addLabel(new GuiNpcLabel(6,"gui.time", guiLeft + 5, guiTop + 165)); - addTextField(new GuiNpcTextField(6,this, fontRendererObj, guiLeft + 85, guiTop + 160, 40, 18, stats.potionDuration + "")); - getTextField(6).integersOnly = true; - getTextField(6).setMinMaxDefault(1, Integer.MAX_VALUE, 5); - if(stats.potionType != EnumPotionType.Fire) { - addLabel(new GuiNpcLabel(7,"stats.amplify", guiLeft + 5, guiTop + 195)); - addButton(new GuiButtonBiDirectional(7,guiLeft + 85, guiTop + 190, 52, 20, new String[]{"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10"} ,stats.potionAmp)); - } - } - addButton(new GuiNpcButton(66, guiLeft + 190, guiTop + 190, 60, 20, "gui.done")); + addLabel(new GuiNpcLabel(4, "enchantment.knockback", guiLeft + 5, guiTop + 105)); + addTextField(new GuiNpcTextField(4, this, fontRendererObj, guiLeft + 85, guiTop + 100, 40, 18, stats.knockback + "")); + getTextField(4).integersOnly = true; + getTextField(4).setMinMaxDefault(0, Integer.MAX_VALUE, 0); + addLabel(new GuiNpcLabel(5, "stats.meleeeffect", guiLeft + 5, guiTop + 135)); + addButton(new GuiButtonBiDirectional(5, guiLeft + 85, guiTop + 130, 100, 20, potionNames, stats.potionType.ordinal())); + if (stats.potionType != EnumPotionType.None) { + addLabel(new GuiNpcLabel(6, "gui.time", guiLeft + 5, guiTop + 165)); + addTextField(new GuiNpcTextField(6, this, fontRendererObj, guiLeft + 85, guiTop + 160, 40, 18, stats.potionDuration + "")); + getTextField(6).integersOnly = true; + getTextField(6).setMinMaxDefault(1, Integer.MAX_VALUE, 5); + if (stats.potionType != EnumPotionType.Fire) { + addLabel(new GuiNpcLabel(7, "stats.amplify", guiLeft + 5, guiTop + 195)); + addButton(new GuiButtonBiDirectional(7, guiLeft + 85, guiTop + 190, 52, 20, new String[]{"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10"}, stats.potionAmp)); + } + } + addButton(new GuiNpcButton(66, guiLeft + 190, guiTop + 190, 60, 20, "gui.done")); } - public void unFocused(GuiNpcTextField textfield) { - if(textfield.id == 1){ - stats.setAttackStrength(Float.parseFloat(textfield.getText())); - } - else if(textfield.id == 2){ - stats.attackRange = textfield.getInteger(); - } - else if(textfield.id == 3){ - stats.attackSpeed = textfield.getInteger(); - } - else if(textfield.id == 4){ - stats.knockback = textfield.getInteger(); - } - else if(textfield.id == 6){ - stats.potionDuration = textfield.getInteger(); - } - } + public void unFocused(GuiNpcTextField textfield) { + if (textfield.id == 1) { + stats.setAttackStrength(Float.parseFloat(textfield.getText())); + } else if (textfield.id == 2) { + stats.attackRange = textfield.getInteger(); + } else if (textfield.id == 3) { + stats.attackSpeed = textfield.getInteger(); + } else if (textfield.id == 4) { + stats.knockback = textfield.getInteger(); + } else if (textfield.id == 6) { + stats.potionDuration = textfield.getInteger(); + } + } - protected void actionPerformed(GuiButton guibutton) - { - GuiNpcButton button = (GuiNpcButton) guibutton; - if(button.id == 5){ - stats.potionType = EnumPotionType.values()[button.getValue()]; - initGui(); + protected void actionPerformed(GuiButton guibutton) { + GuiNpcButton button = (GuiNpcButton) guibutton; + if (button.id == 5) { + stats.potionType = EnumPotionType.values()[button.getValue()]; + initGui(); } - if(button.id == 7){ - stats.potionAmp = button.getValue(); + if (button.id == 7) { + stats.potionAmp = button.getValue(); } - if(button.id == 66) - { - close(); + if (button.id == 66) { + close(); } } diff --git a/src/main/java/noppes/npcs/client/gui/SubGuiNpcMovement.java b/src/main/java/noppes/npcs/client/gui/SubGuiNpcMovement.java index 23b76d687..39c712771 100644 --- a/src/main/java/noppes/npcs/client/gui/SubGuiNpcMovement.java +++ b/src/main/java/noppes/npcs/client/gui/SubGuiNpcMovement.java @@ -7,200 +7,181 @@ import noppes.npcs.constants.EnumAnimation; import noppes.npcs.constants.EnumMovingType; import noppes.npcs.constants.EnumStandingType; -public class SubGuiNpcMovement extends SubGuiInterface implements ITextfieldListener -{ - private DataAI ai; - - public SubGuiNpcMovement(DataAI ai){ - this.ai = ai; - setBackground("menubg.png"); - xSize = 256; - ySize = 216; - closeOnEsc = true; +public class SubGuiNpcMovement extends SubGuiInterface implements ITextfieldListener { + private DataAI ai; + + public SubGuiNpcMovement(DataAI ai) { + this.ai = ai; + setBackground("menubg.png"); + xSize = 256; + ySize = 216; + closeOnEsc = true; } - public void initGui(){ + public void initGui() { super.initGui(); int y = guiTop + 4; this.addLabel(new GuiNpcLabel(0, "movement.type", guiLeft + 4, y + 5)); - this.addButton(new GuiNpcButton(0, guiLeft + 80, y, 100, 20, EnumMovingType.names(), ai.movingType.ordinal())); + this.addButton(new GuiNpcButton(0, guiLeft + 80, y, 100, 20, EnumMovingType.names(), ai.movingType.ordinal())); - this.addButton(new GuiNpcButton(15, guiLeft + 80, y += 22, 100, 20, new String[]{"movement.ground","movement.flying"}, ai.movementType)); + this.addButton(new GuiNpcButton(15, guiLeft + 80, y += 22, 100, 20, new String[]{"movement.ground", "movement.flying"}, ai.movementType)); - if(ai.movementType == 1){ - this.addLabel(new GuiNpcLabel(18, "fly.speed", guiLeft + 4, y + 140)); - addTextField(new GuiNpcTextField(18,this, guiLeft + 80, y + 135, 40, 20, ai.flySpeed + "")); - getTextField(18).doublesOnly = true; - getTextField(18).setMinMaxDefaultDouble(0.0D,Double.MAX_VALUE,1.0D); + if (ai.movementType == 1) { + this.addLabel(new GuiNpcLabel(18, "fly.speed", guiLeft + 4, y + 140)); + addTextField(new GuiNpcTextField(18, this, guiLeft + 80, y + 135, 40, 20, ai.flySpeed + "")); + getTextField(18).doublesOnly = true; + getTextField(18).setMinMaxDefaultDouble(0.0D, Double.MAX_VALUE, 1.0D); - this.addLabel(new GuiNpcLabel(19, "fly.gravity", guiLeft + 4, y + 160)); - addTextField(new GuiNpcTextField(19,this, guiLeft + 80, y + 155, 40, 20, ai.flyGravity + "")); - getTextField(19).doublesOnly = true; - getTextField(19).setMinMaxDefaultDouble(0.0D,1.0D,0.0D); + this.addLabel(new GuiNpcLabel(19, "fly.gravity", guiLeft + 4, y + 160)); + addTextField(new GuiNpcTextField(19, this, guiLeft + 80, y + 155, 40, 20, ai.flyGravity + "")); + getTextField(19).doublesOnly = true; + getTextField(19).setMinMaxDefaultDouble(0.0D, 1.0D, 0.0D); - this.addLabel(new GuiNpcLabel(20, "Limit Height", guiLeft + 150, y + 116)); - addButton(new GuiNpcButton(20, guiLeft + 210, y + 110, 40, 20, new String[]{"gui.no","gui.yes"}, ai.hasFlyLimit?1:0)); + this.addLabel(new GuiNpcLabel(20, "Limit Height", guiLeft + 150, y + 116)); + addButton(new GuiNpcButton(20, guiLeft + 210, y + 110, 40, 20, new String[]{"gui.no", "gui.yes"}, ai.hasFlyLimit ? 1 : 0)); - if(ai.hasFlyLimit) { - this.addLabel(new GuiNpcLabel(21, "Height", guiLeft + 150, y + 140)); - addTextField(new GuiNpcTextField(21, this, guiLeft + 185, y + 135, 40, 20, ai.flyHeightLimit + "")); - getTextField(21).integersOnly = true; - getTextField(21).setMinMaxDefaultDouble(0.0D, Double.MAX_VALUE, 1.0D); - } - } + if (ai.hasFlyLimit) { + this.addLabel(new GuiNpcLabel(21, "Height", guiLeft + 150, y + 140)); + addTextField(new GuiNpcTextField(21, this, guiLeft + 185, y + 135, 40, 20, ai.flyHeightLimit + "")); + getTextField(21).integersOnly = true; + getTextField(21).setMinMaxDefaultDouble(0.0D, Double.MAX_VALUE, 1.0D); + } + } - if(ai.movingType == EnumMovingType.Wandering){ - addTextField(new GuiNpcTextField(4,this, guiLeft + 100, y += 22, 40, 20, ai.walkingRange + "")); - getTextField(4).integersOnly = true; - getTextField(4).setMinMaxDefault(0, Integer.MAX_VALUE, 5); - addLabel(new GuiNpcLabel(4,"gui.range", guiLeft + 4, y + 5)); - - addButton(new GuiNpcButton(5, guiLeft + 100, y += 22, 50, 20, new String[]{"gui.no","gui.yes"}, ai.npcInteracting?1:0)); - addLabel(new GuiNpcLabel(5,"movement.wanderinteract", guiLeft + 4, y + 5)); - } - else if(ai.movingType == EnumMovingType.Standing){ - addTextField(new GuiNpcTextField(7,this, guiLeft + 99, y += 22, 24, 20, (int)ai.bodyOffsetX + "")); - addLabel(new GuiNpcLabel(17, "spawner.posoffset", guiLeft + 4, y + 5)); - addLabel(new GuiNpcLabel(7,"X:", guiLeft + 115, y + 5)); - getTextField(7).integersOnly = true; - getTextField(7).setMinMaxDefault(0, 10, 5); - addLabel(new GuiNpcLabel(8,"Y:", guiLeft + 125, y + 5)); - addTextField(new GuiNpcTextField(8,this, guiLeft + 135, y, 24, 20, (int)ai.bodyOffsetY + "")); - getTextField(8).integersOnly = true; - getTextField(8).setMinMaxDefault(0, 10, 5); - addLabel(new GuiNpcLabel(9,"Z:", guiLeft + 161, y + 5)); - addTextField(new GuiNpcTextField(9,this, guiLeft + 171, y, 24, 20, (int)ai.bodyOffsetZ + "")); - getTextField(9).integersOnly = true; - getTextField(9).setMinMaxDefault(0, 10, 5); + if (ai.movingType == EnumMovingType.Wandering) { + addTextField(new GuiNpcTextField(4, this, guiLeft + 100, y += 22, 40, 20, ai.walkingRange + "")); + getTextField(4).integersOnly = true; + getTextField(4).setMinMaxDefault(0, Integer.MAX_VALUE, 5); + addLabel(new GuiNpcLabel(4, "gui.range", guiLeft + 4, y + 5)); - this.addButton(new GuiNpcButton(3, guiLeft + 80, y += 22, 100, 20, new String[]{"stats.normal","movement.sitting","movement.lying","movement.sneaking","movement.dancing","movement.aiming", "movement.crawling", "movement.hug"},ai.animationType.ordinal())); - this.addLabel(new GuiNpcLabel(3, "movement.animation", guiLeft + 4, y + 5)); - - if(ai.animationType != EnumAnimation.LYING){ - this.addButton(new GuiNpcButton(4, guiLeft + 80, y += 22, 80, 20, new String[]{"movement.body","movement.manual","movement.stalking","movement.head"},ai.standingType.ordinal())); - this.addLabel(new GuiNpcLabel(1, "movement.rotation", guiLeft + 4, y + 5)); - } - else{ - addTextField(new GuiNpcTextField(5,this, guiLeft + 99, y += 22, 40, 20, ai.orientation + "")); - getTextField(5).integersOnly = true; - getTextField(5).setMinMaxDefault(0, 359, 0); - this.addLabel(new GuiNpcLabel(6, "movement.rotation", guiLeft + 4, y + 5)); - addLabel(new GuiNpcLabel(5,"(0-359)", guiLeft + 142, y + 5)); - } - if(ai.standingType == EnumStandingType.NoRotation || ai.standingType == EnumStandingType.HeadRotation){ - addTextField(new GuiNpcTextField(5,this, guiLeft + 165, y, 40, 20, ai.orientation + "")); - getTextField(5).integersOnly = true; - getTextField(5).setMinMaxDefault(0, 359, 0); - addLabel(new GuiNpcLabel(5,"(0-359)", guiLeft + 207, y + 5)); - } - } - if(ai.movingType != EnumMovingType.Standing){ - this.addButton(new GuiNpcButton(12, guiLeft + 80, y += 22, 100, 20, new String[]{"stats.normal","movement.sneaking","movement.aiming", "movement.dancing", "movement.crawling", "movement.hug"},ai.animationType.getWalkingAnimation())); - this.addLabel(new GuiNpcLabel(12, "movement.animation", guiLeft + 4, y + 5)); - } - - if(ai.movingType == EnumMovingType.MovingPath){ - this.addButton(new GuiNpcButton(8, guiLeft + 80, y += 22, 80, 20, new String[]{"ai.looping","ai.backtracking"}, ai.movingPattern)); - this.addLabel(new GuiNpcLabel(8, "movement.name", guiLeft + 4, y + 5)); - this.addButton(new GuiNpcButton(9, guiLeft + 80, y += 22, 80, 20, new String[]{"gui.no","gui.yes"}, ai.movingPause?1:0)); - this.addLabel(new GuiNpcLabel(9, "movement.pauses", guiLeft + 4, y + 5)); - } - addButton(new GuiNpcButton(13, guiLeft + 100, y += 22, 50, 20, new String[]{"gui.no","gui.yes"}, ai.stopAndInteract?1:0)); - addLabel(new GuiNpcLabel(13,"movement.stopinteract", guiLeft + 4, y + 5)); + addButton(new GuiNpcButton(5, guiLeft + 100, y += 22, 50, 20, new String[]{"gui.no", "gui.yes"}, ai.npcInteracting ? 1 : 0)); + addLabel(new GuiNpcLabel(5, "movement.wanderinteract", guiLeft + 4, y + 5)); + } else if (ai.movingType == EnumMovingType.Standing) { + addTextField(new GuiNpcTextField(7, this, guiLeft + 99, y += 22, 24, 20, (int) ai.bodyOffsetX + "")); + addLabel(new GuiNpcLabel(17, "spawner.posoffset", guiLeft + 4, y + 5)); + addLabel(new GuiNpcLabel(7, "X:", guiLeft + 115, y + 5)); + getTextField(7).integersOnly = true; + getTextField(7).setMinMaxDefault(0, 10, 5); + addLabel(new GuiNpcLabel(8, "Y:", guiLeft + 125, y + 5)); + addTextField(new GuiNpcTextField(8, this, guiLeft + 135, y, 24, 20, (int) ai.bodyOffsetY + "")); + getTextField(8).integersOnly = true; + getTextField(8).setMinMaxDefault(0, 10, 5); + addLabel(new GuiNpcLabel(9, "Z:", guiLeft + 161, y + 5)); + addTextField(new GuiNpcTextField(9, this, guiLeft + 171, y, 24, 20, (int) ai.bodyOffsetZ + "")); + getTextField(9).integersOnly = true; + getTextField(9).setMinMaxDefault(0, 10, 5); - addTextField(new GuiNpcTextField(14,this, guiLeft + 80, y += 22, 50, 18, ai.getWalkingSpeed()+"")); + this.addButton(new GuiNpcButton(3, guiLeft + 80, y += 22, 100, 20, new String[]{"stats.normal", "movement.sitting", "movement.lying", "movement.sneaking", "movement.dancing", "movement.aiming", "movement.crawling", "movement.hug"}, ai.animationType.ordinal())); + this.addLabel(new GuiNpcLabel(3, "movement.animation", guiLeft + 4, y + 5)); + + if (ai.animationType != EnumAnimation.LYING) { + this.addButton(new GuiNpcButton(4, guiLeft + 80, y += 22, 80, 20, new String[]{"movement.body", "movement.manual", "movement.stalking", "movement.head"}, ai.standingType.ordinal())); + this.addLabel(new GuiNpcLabel(1, "movement.rotation", guiLeft + 4, y + 5)); + } else { + addTextField(new GuiNpcTextField(5, this, guiLeft + 99, y += 22, 40, 20, ai.orientation + "")); + getTextField(5).integersOnly = true; + getTextField(5).setMinMaxDefault(0, 359, 0); + this.addLabel(new GuiNpcLabel(6, "movement.rotation", guiLeft + 4, y + 5)); + addLabel(new GuiNpcLabel(5, "(0-359)", guiLeft + 142, y + 5)); + } + if (ai.standingType == EnumStandingType.NoRotation || ai.standingType == EnumStandingType.HeadRotation) { + addTextField(new GuiNpcTextField(5, this, guiLeft + 165, y, 40, 20, ai.orientation + "")); + getTextField(5).integersOnly = true; + getTextField(5).setMinMaxDefault(0, 359, 0); + addLabel(new GuiNpcLabel(5, "(0-359)", guiLeft + 207, y + 5)); + } + } + if (ai.movingType != EnumMovingType.Standing) { + this.addButton(new GuiNpcButton(12, guiLeft + 80, y += 22, 100, 20, new String[]{"stats.normal", "movement.sneaking", "movement.aiming", "movement.dancing", "movement.crawling", "movement.hug"}, ai.animationType.getWalkingAnimation())); + this.addLabel(new GuiNpcLabel(12, "movement.animation", guiLeft + 4, y + 5)); + } + + if (ai.movingType == EnumMovingType.MovingPath) { + this.addButton(new GuiNpcButton(8, guiLeft + 80, y += 22, 80, 20, new String[]{"ai.looping", "ai.backtracking"}, ai.movingPattern)); + this.addLabel(new GuiNpcLabel(8, "movement.name", guiLeft + 4, y + 5)); + this.addButton(new GuiNpcButton(9, guiLeft + 80, y += 22, 80, 20, new String[]{"gui.no", "gui.yes"}, ai.movingPause ? 1 : 0)); + this.addLabel(new GuiNpcLabel(9, "movement.pauses", guiLeft + 4, y + 5)); + } + addButton(new GuiNpcButton(13, guiLeft + 100, y += 22, 50, 20, new String[]{"gui.no", "gui.yes"}, ai.stopAndInteract ? 1 : 0)); + addLabel(new GuiNpcLabel(13, "movement.stopinteract", guiLeft + 4, y + 5)); + + addTextField(new GuiNpcTextField(14, this, guiLeft + 80, y += 22, 50, 18, ai.getWalkingSpeed() + "")); getTextField(14).integersOnly = true; getTextField(14).setMinMaxDefault(0, Integer.MAX_VALUE, 4); - addLabel(new GuiNpcLabel(14,"stats.walkspeed", guiLeft + 5, y + 5)); - - addButton(new GuiNpcButton(66, guiLeft + 190, guiTop + 190, 60, 20, "gui.done")); + addLabel(new GuiNpcLabel(14, "stats.walkspeed", guiLeft + 5, y + 5)); + + addButton(new GuiNpcButton(66, guiLeft + 190, guiTop + 190, 60, 20, "gui.done")); } - protected void actionPerformed(GuiButton guibutton){ - GuiNpcButton button = (GuiNpcButton) guibutton; - if(button.id == 0){ - ai.movingType = EnumMovingType.values()[button.getValue()]; - if(ai.movingType != EnumMovingType.Standing){ - ai.animationType = EnumAnimation.NONE; - ai.standingType = EnumStandingType.RotateBody; - ai.bodyOffsetX = ai.bodyOffsetY = ai.bodyOffsetZ = 5; - } - initGui(); - } - else if(button.id == 3){ - ai.animationType = EnumAnimation.values()[button.getValue()]; - initGui(); - } - else if(button.id == 4){ - ai.standingType = EnumStandingType.values()[button.getValue()]; - initGui(); - } - else if(button.id == 5){ - ai.npcInteracting = button.getValue() == 1; - } - else if (button.id == 8) { - ai.movingPattern = button.getValue(); - } - else if (button.id == 9) { - ai.movingPause = button.getValue() == 1; - } - else if (button.id == 12) { - if(button.getValue() == 0) - ai.animationType = EnumAnimation.NONE; - if(button.getValue() == 1) - ai.animationType = EnumAnimation.SNEAKING; - if(button.getValue() == 2) - ai.animationType = EnumAnimation.AIMING; - if(button.getValue() == 3) - ai.animationType = EnumAnimation.DANCING; - if(button.getValue() == 4) - ai.animationType = EnumAnimation.CRAWLING; - if(button.getValue() == 5) - ai.animationType = EnumAnimation.HUG; - } - else if (button.id == 13) { - ai.stopAndInteract = button.getValue() == 1; - } - else if (button.id == 15) { - ai.movementType = button.getValue(); - initGui(); - } else if (button.id == 20) { - ai.hasFlyLimit = button.getValue() == 1; - initGui(); - } else if (button.id == 66) { - close(); - } + protected void actionPerformed(GuiButton guibutton) { + GuiNpcButton button = (GuiNpcButton) guibutton; + if (button.id == 0) { + ai.movingType = EnumMovingType.values()[button.getValue()]; + if (ai.movingType != EnumMovingType.Standing) { + ai.animationType = EnumAnimation.NONE; + ai.standingType = EnumStandingType.RotateBody; + ai.bodyOffsetX = ai.bodyOffsetY = ai.bodyOffsetZ = 5; + } + initGui(); + } else if (button.id == 3) { + ai.animationType = EnumAnimation.values()[button.getValue()]; + initGui(); + } else if (button.id == 4) { + ai.standingType = EnumStandingType.values()[button.getValue()]; + initGui(); + } else if (button.id == 5) { + ai.npcInteracting = button.getValue() == 1; + } else if (button.id == 8) { + ai.movingPattern = button.getValue(); + } else if (button.id == 9) { + ai.movingPause = button.getValue() == 1; + } else if (button.id == 12) { + if (button.getValue() == 0) + ai.animationType = EnumAnimation.NONE; + if (button.getValue() == 1) + ai.animationType = EnumAnimation.SNEAKING; + if (button.getValue() == 2) + ai.animationType = EnumAnimation.AIMING; + if (button.getValue() == 3) + ai.animationType = EnumAnimation.DANCING; + if (button.getValue() == 4) + ai.animationType = EnumAnimation.CRAWLING; + if (button.getValue() == 5) + ai.animationType = EnumAnimation.HUG; + } else if (button.id == 13) { + ai.stopAndInteract = button.getValue() == 1; + } else if (button.id == 15) { + ai.movementType = button.getValue(); + initGui(); + } else if (button.id == 20) { + ai.hasFlyLimit = button.getValue() == 1; + initGui(); + } else if (button.id == 66) { + close(); + } } - @Override - public void unFocused(GuiNpcTextField textfield) { - if(textfield.id == 7){ - ai.bodyOffsetX = textfield.getInteger(); - } - else if(textfield.id == 8){ - ai.bodyOffsetY = textfield.getInteger(); - } - else if(textfield.id == 9){ - ai.bodyOffsetZ = textfield.getInteger(); - } - else if(textfield.id == 5){ - ai.orientation = textfield.getInteger(); - } - else if(textfield.id == 4){ - ai.walkingRange = textfield.getInteger(); - } - else if(textfield.id == 14){ - ai.setWalkingSpeed(textfield.getInteger()); - } - else if(textfield.id == 18){ - ai.flySpeed = textfield.getDouble(); - } - else if(textfield.id == 19){ - ai.flyGravity = textfield.getDouble(); - } - else if(textfield.id == 21){ - ai.flyHeightLimit = textfield.getInteger(); - } - } + @Override + public void unFocused(GuiNpcTextField textfield) { + if (textfield.id == 7) { + ai.bodyOffsetX = textfield.getInteger(); + } else if (textfield.id == 8) { + ai.bodyOffsetY = textfield.getInteger(); + } else if (textfield.id == 9) { + ai.bodyOffsetZ = textfield.getInteger(); + } else if (textfield.id == 5) { + ai.orientation = textfield.getInteger(); + } else if (textfield.id == 4) { + ai.walkingRange = textfield.getInteger(); + } else if (textfield.id == 14) { + ai.setWalkingSpeed(textfield.getInteger()); + } else if (textfield.id == 18) { + ai.flySpeed = textfield.getDouble(); + } else if (textfield.id == 19) { + ai.flyGravity = textfield.getDouble(); + } else if (textfield.id == 21) { + ai.flyHeightLimit = textfield.getInteger(); + } + } } diff --git a/src/main/java/noppes/npcs/client/gui/SubGuiNpcName.java b/src/main/java/noppes/npcs/client/gui/SubGuiNpcName.java index ff9e0d7e9..a31a4dea4 100644 --- a/src/main/java/noppes/npcs/client/gui/SubGuiNpcName.java +++ b/src/main/java/noppes/npcs/client/gui/SubGuiNpcName.java @@ -6,58 +6,59 @@ import noppes.npcs.client.gui.mainmenu.GuiNpcDisplay; import noppes.npcs.client.gui.util.*; public class SubGuiNpcName extends SubGuiInterface implements ITextfieldListener { - private DataDisplay display; - public SubGuiNpcName(DataDisplay display){ - this.display = display; - setBackground("menubg.png"); - xSize = 256; - ySize = 216; - closeOnEsc = true; + private DataDisplay display; + + public SubGuiNpcName(DataDisplay display) { + this.display = display; + setBackground("menubg.png"); + xSize = 256; + ySize = 216; + closeOnEsc = true; } @Override - public void initGui(){ + public void initGui() { super.initGui(); int y = guiTop + 4; - addButton(new GuiNpcButton(66, guiLeft + xSize - 24, y, 20, 20, "X")); - - addTextField(new GuiNpcTextField(0,this, fontRendererObj, guiLeft + 4, y += 50, 226, 20, display.name)); - this.addButton(new GuiButtonBiDirectional(1, guiLeft + 4, y += 22 , 200, 20, new String[] {"markov.roman.name", "markov.japanese.name", "markov.slavic.name", "markov.welsh.name", "markov.sami.name", "markov.oldNorse.name", "markov.ancientGreek.name", "markov.aztec.name", "markov.classicCNPCs.name", "markov.spanish.name"}, display.getMarkovGeneratorId())); - - this.addButton(new GuiButtonBiDirectional(2, guiLeft + 64, y += 22 , 120, 20, new String[] {"markov.gender.either", "markov.gender.male", "markov.gender.female"}, display.getMarkovGender())); - addLabel(new GuiNpcLabel(2,"markov.gender.name", guiLeft + 5, y + 5)); - - addButton(new GuiNpcButton(3, guiLeft + 4, y += 42, 70, 20, "markov.generate")); + addButton(new GuiNpcButton(66, guiLeft + xSize - 24, y, 20, 20, "X")); + + addTextField(new GuiNpcTextField(0, this, fontRendererObj, guiLeft + 4, y += 50, 226, 20, display.name)); + this.addButton(new GuiButtonBiDirectional(1, guiLeft + 4, y += 22, 200, 20, new String[]{"markov.roman.name", "markov.japanese.name", "markov.slavic.name", "markov.welsh.name", "markov.sami.name", "markov.oldNorse.name", "markov.ancientGreek.name", "markov.aztec.name", "markov.classicCNPCs.name", "markov.spanish.name"}, display.getMarkovGeneratorId())); + + this.addButton(new GuiButtonBiDirectional(2, guiLeft + 64, y += 22, 120, 20, new String[]{"markov.gender.either", "markov.gender.male", "markov.gender.female"}, display.getMarkovGender())); + addLabel(new GuiNpcLabel(2, "markov.gender.name", guiLeft + 5, y + 5)); + + addButton(new GuiNpcButton(3, guiLeft + 4, y += 42, 70, 20, "markov.generate")); } - @Override - public void unFocused(GuiNpcTextField textfield) { - if(textfield.id == 0){ - if(!textfield.isEmpty()) - display.setName(textfield.getText()); - else - textfield.setText(display.getName()); - } - } - - @Override - protected void actionPerformed(GuiButton guibutton){ - GuiNpcButton button = (GuiNpcButton) guibutton; + @Override + public void unFocused(GuiNpcTextField textfield) { + if (textfield.id == 0) { + if (!textfield.isEmpty()) + display.setName(textfield.getText()); + else + textfield.setText(display.getName()); + } + } - if(button.id == 1) { - display.setMarkovGeneratorId(button.getValue()); - } - if(button.id == 2) { - display.setMarkovGender(button.getValue()); - } - if(button.id == 3) { - String name = display.getRandomName(); - display.setName(name); - getTextField(0).setText(name); - ((GuiNpcDisplay)parent).nameText.setText(name); - } - if(button.id == 66){ - close(); + @Override + protected void actionPerformed(GuiButton guibutton) { + GuiNpcButton button = (GuiNpcButton) guibutton; + + if (button.id == 1) { + display.setMarkovGeneratorId(button.getValue()); + } + if (button.id == 2) { + display.setMarkovGender(button.getValue()); + } + if (button.id == 3) { + String name = display.getRandomName(); + display.setName(name); + getTextField(0).setText(name); + ((GuiNpcDisplay) parent).nameText.setText(name); + } + if (button.id == 66) { + close(); } } } diff --git a/src/main/java/noppes/npcs/client/gui/SubGuiNpcPartyOptions.java b/src/main/java/noppes/npcs/client/gui/SubGuiNpcPartyOptions.java index f1d2f2101..3c9fbd653 100644 --- a/src/main/java/noppes/npcs/client/gui/SubGuiNpcPartyOptions.java +++ b/src/main/java/noppes/npcs/client/gui/SubGuiNpcPartyOptions.java @@ -7,21 +7,18 @@ import noppes.npcs.constants.EnumPartyObjectives; import noppes.npcs.constants.EnumPartyRequirements; import noppes.npcs.controllers.data.PartyOptions; -public class SubGuiNpcPartyOptions extends SubGuiInterface implements ITextfieldListener -{ - private final PartyOptions options; +public class SubGuiNpcPartyOptions extends SubGuiInterface implements ITextfieldListener { + private final PartyOptions options; - public SubGuiNpcPartyOptions(PartyOptions options) - { - this.options = options; - setBackground("menubg.png"); - xSize = 256; - ySize = 216; - closeOnEsc = true; + public SubGuiNpcPartyOptions(PartyOptions options) { + this.options = options; + setBackground("menubg.png"); + xSize = 256; + ySize = 216; + closeOnEsc = true; } - public void initGui() - { + public void initGui() { super.initGui(); int y = 0; @@ -88,9 +85,8 @@ public class SubGuiNpcPartyOptions extends SubGuiInterface implements ITextfield addButton(new GuiNpcButton(66, guiLeft + 200, guiTop + 192, 50, 20, "gui.done")); } - protected void actionPerformed(GuiButton guibutton) - { - int id = guibutton.id; + protected void actionPerformed(GuiButton guibutton) { + int id = guibutton.id; switch (id) { case 0: options.allowParty = !options.allowParty; diff --git a/src/main/java/noppes/npcs/client/gui/SubGuiNpcProfileOptions.java b/src/main/java/noppes/npcs/client/gui/SubGuiNpcProfileOptions.java index bc6376bd5..844cfe431 100644 --- a/src/main/java/noppes/npcs/client/gui/SubGuiNpcProfileOptions.java +++ b/src/main/java/noppes/npcs/client/gui/SubGuiNpcProfileOptions.java @@ -1,25 +1,24 @@ package noppes.npcs.client.gui; import net.minecraft.client.gui.GuiButton; -import noppes.npcs.client.gui.util.*; +import noppes.npcs.client.gui.util.GuiNpcButton; +import noppes.npcs.client.gui.util.GuiNpcLabel; +import noppes.npcs.client.gui.util.SubGuiInterface; import noppes.npcs.constants.EnumProfileSync; import noppes.npcs.controllers.data.ProfileOptions; -public class SubGuiNpcProfileOptions extends SubGuiInterface -{ - private final ProfileOptions options; +public class SubGuiNpcProfileOptions extends SubGuiInterface { + private final ProfileOptions options; - public SubGuiNpcProfileOptions(ProfileOptions options) - { - this.options = options; - setBackground("menubg.png"); - xSize = 256; - ySize = 216; - closeOnEsc = true; + public SubGuiNpcProfileOptions(ProfileOptions options) { + this.options = options; + setBackground("menubg.png"); + xSize = 256; + ySize = 216; + closeOnEsc = true; } - public void initGui() - { + public void initGui() { super.initGui(); int y = 0; @@ -43,9 +42,8 @@ public class SubGuiNpcProfileOptions extends SubGuiInterface addButton(new GuiNpcButton(66, guiLeft + 200, guiTop + 192, 50, 20, "gui.done")); } - protected void actionPerformed(GuiButton guibutton) - { - int id = guibutton.id; + protected void actionPerformed(GuiButton guibutton) { + int id = guibutton.id; switch (id) { case 0: options.enableOptions = !options.enableOptions; diff --git a/src/main/java/noppes/npcs/client/gui/SubGuiNpcProjectiles.java b/src/main/java/noppes/npcs/client/gui/SubGuiNpcProjectiles.java index c2bbc6570..3f221e8aa 100644 --- a/src/main/java/noppes/npcs/client/gui/SubGuiNpcProjectiles.java +++ b/src/main/java/noppes/npcs/client/gui/SubGuiNpcProjectiles.java @@ -6,136 +6,128 @@ import noppes.npcs.client.gui.util.*; import noppes.npcs.constants.EnumParticleType; import noppes.npcs.constants.EnumPotionType; -public class SubGuiNpcProjectiles extends SubGuiInterface implements ITextfieldListener -{ - private DataStats stats; - private String[] potionNames = new String[]{"gui.none", "tile.fire.name", "potion.poison", "potion.hunger", "potion.weakness", "potion.moveSlowdown", "potion.confusion", "potion.blindness", "potion.wither"}; - private String[] trailNames = new String[]{"gui.none", "Smoke", "Portal", "Redstone", "Lightning", "LargeSmoke", "Magic", "Enchant"}; - public SubGuiNpcProjectiles(DataStats stats) - { - this.stats = stats; - setBackground("menubg.png"); - xSize = 256; - ySize = 216; - closeOnEsc = true; +public class SubGuiNpcProjectiles extends SubGuiInterface implements ITextfieldListener { + private DataStats stats; + private String[] potionNames = new String[]{"gui.none", "tile.fire.name", "potion.poison", "potion.hunger", "potion.weakness", "potion.moveSlowdown", "potion.confusion", "potion.blindness", "potion.wither"}; + private String[] trailNames = new String[]{"gui.none", "Smoke", "Portal", "Redstone", "Lightning", "LargeSmoke", "Magic", "Enchant"}; + + public SubGuiNpcProjectiles(DataStats stats) { + this.stats = stats; + setBackground("menubg.png"); + xSize = 256; + ySize = 216; + closeOnEsc = true; } - public void initGui() - { + public void initGui() { super.initGui(); - addLabel(new GuiNpcLabel(1,"enchantment.arrowDamage", guiLeft + 5, guiTop + 15)); - addTextField(new GuiNpcTextField(1,this, fontRendererObj, guiLeft + 45, guiTop + 10, 50, 18, String.format("%.0f", stats.pDamage) +"")); + addLabel(new GuiNpcLabel(1, "enchantment.arrowDamage", guiLeft + 5, guiTop + 15)); + addTextField(new GuiNpcTextField(1, this, fontRendererObj, guiLeft + 45, guiTop + 10, 50, 18, String.format("%.0f", stats.pDamage) + "")); getTextField(1).setFloatsOnly(); getTextField(1).setMinMaxDefaultFloat(0, Float.MAX_VALUE, 5); - addLabel(new GuiNpcLabel(2,"enchantment.arrowKnockback", guiLeft + 110, guiTop + 15)); - addTextField(new GuiNpcTextField(2,this, fontRendererObj, guiLeft + 150, guiTop + 10, 50, 18, stats.pImpact+"")); + addLabel(new GuiNpcLabel(2, "enchantment.arrowKnockback", guiLeft + 110, guiTop + 15)); + addTextField(new GuiNpcTextField(2, this, fontRendererObj, guiLeft + 150, guiTop + 10, 50, 18, stats.pImpact + "")); getTextField(2).integersOnly = true; getTextField(2).setMinMaxDefault(0, Integer.MAX_VALUE, 0); - addLabel(new GuiNpcLabel(3,"stats.size", guiLeft + 5, guiTop + 45)); - addTextField(new GuiNpcTextField(3,this, fontRendererObj, guiLeft + 45, guiTop + 40, 50, 18, stats.pSize+"")); + addLabel(new GuiNpcLabel(3, "stats.size", guiLeft + 5, guiTop + 45)); + addTextField(new GuiNpcTextField(3, this, fontRendererObj, guiLeft + 45, guiTop + 40, 50, 18, stats.pSize + "")); getTextField(3).integersOnly = true; getTextField(3).setMinMaxDefault(1, Integer.MAX_VALUE, 10); - addLabel(new GuiNpcLabel(4,"stats.speed", guiLeft + 5, guiTop + 75)); - addTextField(new GuiNpcTextField(4,this, fontRendererObj, guiLeft + 45, guiTop + 70, 50, 18, stats.pSpeed+"")); + addLabel(new GuiNpcLabel(4, "stats.speed", guiLeft + 5, guiTop + 75)); + addTextField(new GuiNpcTextField(4, this, fontRendererObj, guiLeft + 45, guiTop + 70, 50, 18, stats.pSpeed + "")); getTextField(4).integersOnly = true; getTextField(4).setMinMaxDefault(1, Integer.MAX_VALUE, 10); - - addLabel(new GuiNpcLabel(5,"stats.hasgravity", guiLeft + 5, guiTop + 105)); - addButton(new GuiNpcButton(0, guiLeft + 60, guiTop + 100, 60, 20, new String[]{"gui.no", "gui.yes"} ,stats.pPhysics ? 1:0)); - if(!stats.pPhysics) { - addButton(new GuiNpcButton(1, guiLeft + 140, guiTop + 100, 60, 20, new String[]{"gui.constant", "gui.accelerate"} ,stats.pXlr8 ? 1:0)); - } - addLabel(new GuiNpcLabel(6,"stats.explosive", guiLeft + 5, guiTop + 135)); - addButton(new GuiNpcButton(2, guiLeft + 60, guiTop + 130, 60, 20, new String[]{"gui.no", "gui.yes"} ,stats.pExplode ? 1:0)); - if(stats.pExplode) { - addButton(new GuiNpcButton(3, guiLeft + 140, guiTop + 130, 60, 20, new String[]{"gui.none", "gui.small", "gui.medium", "gui.large"} ,stats.pArea)); - } - addLabel(new GuiNpcLabel(7,"stats.rangedeffect", guiLeft + 5, guiTop + 165)); - addButton(new GuiNpcButton(4,guiLeft + 60, guiTop + 160, 60, 20, potionNames, stats.pEffect.ordinal())); - if(stats.pEffect != EnumPotionType.None) { - addTextField(new GuiNpcTextField(5,this, fontRendererObj, guiLeft + 140, guiTop + 160, 60, 18, stats.pDur + "")); - getTextField(5).integersOnly = true; - getTextField(5).setMinMaxDefault(1, Integer.MAX_VALUE, 5); - if(stats.pEffect != EnumPotionType.Fire) { - addButton(new GuiNpcButton(10, guiLeft + 210, guiTop + 160, 40, 20, new String[]{"stats.regular", "stats.amplified"} ,stats.pEffAmp)); - } - } - - addLabel(new GuiNpcLabel(8,"stats.trail", guiLeft + 5, guiTop + 195)); - addButton(new GuiNpcButton(5, guiLeft + 60, guiTop + 190, 60, 20, trailNames, stats.pTrail.ordinal())); - - addButton(new GuiNpcButton(7, guiLeft + 220, guiTop + 10, 30, 20, new String[]{"2D", "3D"} ,stats.pRender3D ? 1:0)); - if (stats.pRender3D) { - addLabel(new GuiNpcLabel(10,"stats.spin", guiLeft + 160, guiTop + 45)); - addButton(new GuiNpcButton(8, guiLeft + 220, guiTop + 40, 30, 20, new String[]{"gui.no", "gui.yes"} ,stats.pSpin ? 1:0)); - addLabel(new GuiNpcLabel(11,"stats.stick", guiLeft + 160, guiTop + 75)); - addButton(new GuiNpcButton(9, guiLeft + 220, guiTop + 70, 30, 20, new String[]{"gui.no", "gui.yes"} ,stats.pStick ? 1:0)); - } - addButton(new GuiNpcButton(6, guiLeft + 140, guiTop + 190, 60, 20, new String[]{"stats.noglow", "stats.glows"} ,stats.pGlows ? 1:0)); - addButton(new GuiNpcButton(66, guiLeft + 210, guiTop + 190, 40, 20, "gui.done")); + + addLabel(new GuiNpcLabel(5, "stats.hasgravity", guiLeft + 5, guiTop + 105)); + addButton(new GuiNpcButton(0, guiLeft + 60, guiTop + 100, 60, 20, new String[]{"gui.no", "gui.yes"}, stats.pPhysics ? 1 : 0)); + if (!stats.pPhysics) { + addButton(new GuiNpcButton(1, guiLeft + 140, guiTop + 100, 60, 20, new String[]{"gui.constant", "gui.accelerate"}, stats.pXlr8 ? 1 : 0)); + } + addLabel(new GuiNpcLabel(6, "stats.explosive", guiLeft + 5, guiTop + 135)); + addButton(new GuiNpcButton(2, guiLeft + 60, guiTop + 130, 60, 20, new String[]{"gui.no", "gui.yes"}, stats.pExplode ? 1 : 0)); + if (stats.pExplode) { + addButton(new GuiNpcButton(3, guiLeft + 140, guiTop + 130, 60, 20, new String[]{"gui.none", "gui.small", "gui.medium", "gui.large"}, stats.pArea)); + } + addLabel(new GuiNpcLabel(7, "stats.rangedeffect", guiLeft + 5, guiTop + 165)); + addButton(new GuiNpcButton(4, guiLeft + 60, guiTop + 160, 60, 20, potionNames, stats.pEffect.ordinal())); + if (stats.pEffect != EnumPotionType.None) { + addTextField(new GuiNpcTextField(5, this, fontRendererObj, guiLeft + 140, guiTop + 160, 60, 18, stats.pDur + "")); + getTextField(5).integersOnly = true; + getTextField(5).setMinMaxDefault(1, Integer.MAX_VALUE, 5); + if (stats.pEffect != EnumPotionType.Fire) { + addButton(new GuiNpcButton(10, guiLeft + 210, guiTop + 160, 40, 20, new String[]{"stats.regular", "stats.amplified"}, stats.pEffAmp)); + } + } + + addLabel(new GuiNpcLabel(8, "stats.trail", guiLeft + 5, guiTop + 195)); + addButton(new GuiNpcButton(5, guiLeft + 60, guiTop + 190, 60, 20, trailNames, stats.pTrail.ordinal())); + + addButton(new GuiNpcButton(7, guiLeft + 220, guiTop + 10, 30, 20, new String[]{"2D", "3D"}, stats.pRender3D ? 1 : 0)); + if (stats.pRender3D) { + addLabel(new GuiNpcLabel(10, "stats.spin", guiLeft + 160, guiTop + 45)); + addButton(new GuiNpcButton(8, guiLeft + 220, guiTop + 40, 30, 20, new String[]{"gui.no", "gui.yes"}, stats.pSpin ? 1 : 0)); + addLabel(new GuiNpcLabel(11, "stats.stick", guiLeft + 160, guiTop + 75)); + addButton(new GuiNpcButton(9, guiLeft + 220, guiTop + 70, 30, 20, new String[]{"gui.no", "gui.yes"}, stats.pStick ? 1 : 0)); + } + addButton(new GuiNpcButton(6, guiLeft + 140, guiTop + 190, 60, 20, new String[]{"stats.noglow", "stats.glows"}, stats.pGlows ? 1 : 0)); + addButton(new GuiNpcButton(66, guiLeft + 210, guiTop + 190, 40, 20, "gui.done")); } - public void unFocused(GuiNpcTextField textfield) { - if(textfield.id == 1){ - stats.pDamage = (float)(Math.floor(Float.parseFloat(textfield.getText()))); - } - else if(textfield.id == 2){ - stats.pImpact = textfield.getInteger(); - } - else if(textfield.id == 3){ - stats.pSize = textfield.getInteger(); - } - else if(textfield.id == 4){ - stats.pSpeed = textfield.getInteger(); - } - else if(textfield.id == 5){ - stats.pDur = textfield.getInteger(); - } - } - - protected void actionPerformed(GuiButton guibutton) - { - GuiNpcButton button = (GuiNpcButton) guibutton; - if(button.id == 0){ - stats.pPhysics = (button.getValue() == 1); - initGui(); + public void unFocused(GuiNpcTextField textfield) { + if (textfield.id == 1) { + stats.pDamage = (float) (Math.floor(Float.parseFloat(textfield.getText()))); + } else if (textfield.id == 2) { + stats.pImpact = textfield.getInteger(); + } else if (textfield.id == 3) { + stats.pSize = textfield.getInteger(); + } else if (textfield.id == 4) { + stats.pSpeed = textfield.getInteger(); + } else if (textfield.id == 5) { + stats.pDur = textfield.getInteger(); } - if(button.id == 1){ - stats.pXlr8 = (button.getValue() == 1); + } + + protected void actionPerformed(GuiButton guibutton) { + GuiNpcButton button = (GuiNpcButton) guibutton; + if (button.id == 0) { + stats.pPhysics = (button.getValue() == 1); + initGui(); } - if(button.id == 2){ - stats.pExplode = (button.getValue() == 1); - initGui(); + if (button.id == 1) { + stats.pXlr8 = (button.getValue() == 1); } - if(button.id == 3){ - stats.pArea = button.getValue(); + if (button.id == 2) { + stats.pExplode = (button.getValue() == 1); + initGui(); } - if(button.id == 4){ - stats.pEffect = EnumPotionType.values()[button.getValue()]; - initGui(); + if (button.id == 3) { + stats.pArea = button.getValue(); } - if(button.id == 5){ - stats.pTrail = EnumParticleType.values()[button.getValue()]; + if (button.id == 4) { + stats.pEffect = EnumPotionType.values()[button.getValue()]; + initGui(); } - if(button.id == 6){ - stats.pGlows = (button.getValue() == 1); + if (button.id == 5) { + stats.pTrail = EnumParticleType.values()[button.getValue()]; } - if(button.id == 7){ - stats.pRender3D = (button.getValue() == 1); - initGui(); + if (button.id == 6) { + stats.pGlows = (button.getValue() == 1); } - if(button.id == 8){ - stats.pSpin = (button.getValue() == 1); + if (button.id == 7) { + stats.pRender3D = (button.getValue() == 1); + initGui(); } - if(button.id == 9){ - stats.pStick = (button.getValue() == 1); + if (button.id == 8) { + stats.pSpin = (button.getValue() == 1); } - if(button.id == 10){ - stats.pEffAmp = button.getValue(); + if (button.id == 9) { + stats.pStick = (button.getValue() == 1); } - if(button.id == 66) - { - close(); + if (button.id == 10) { + stats.pEffAmp = button.getValue(); + } + if (button.id == 66) { + close(); } } } diff --git a/src/main/java/noppes/npcs/client/gui/SubGuiNpcQuest.java b/src/main/java/noppes/npcs/client/gui/SubGuiNpcQuest.java index bd8e559c8..5c56ce292 100644 --- a/src/main/java/noppes/npcs/client/gui/SubGuiNpcQuest.java +++ b/src/main/java/noppes/npcs/client/gui/SubGuiNpcQuest.java @@ -19,231 +19,219 @@ import noppes.npcs.constants.EnumQuestType; import noppes.npcs.controllers.data.PlayerMail; import noppes.npcs.controllers.data.Quest; -public class SubGuiNpcQuest extends SubGuiInterface implements ISubGuiListener, GuiSelectionListener,ITextfieldListener -{ +public class SubGuiNpcQuest extends SubGuiInterface implements ISubGuiListener, GuiSelectionListener, ITextfieldListener { - public int questCategoryID; - public Quest quest; - private final GuiNPCManageQuest parent; - private boolean questlogTA = false; + public int questCategoryID; + public Quest quest; + private final GuiNPCManageQuest parent; + private boolean questlogTA = false; - public SubGuiNpcQuest(GuiNPCManageQuest parent, Quest quest, int catId) - { - this.parent = parent; - this.quest = quest; - this.questCategoryID = catId; - setBackground("menubg.png"); - xSize = 360; - ySize = 216; - } + public SubGuiNpcQuest(GuiNPCManageQuest parent, Quest quest, int catId) { + this.parent = parent; + this.quest = quest; + this.questCategoryID = catId; + setBackground("menubg.png"); + xSize = 360; + ySize = 216; + } - public void initGui() - { + public void initGui() { super.initGui(); - addLabel(new GuiNpcLabel(1,"gui.title", guiLeft + 4, guiTop + 8)); - addTextField(new GuiNpcTextField(1, this, this.fontRendererObj, guiLeft + 36, guiTop + 3, 200, 20, quest.title)); + addLabel(new GuiNpcLabel(1, "gui.title", guiLeft + 4, guiTop + 8)); + addTextField(new GuiNpcTextField(1, this, this.fontRendererObj, guiLeft + 36, guiTop + 3, 200, 20, quest.title)); - addLabel(new GuiNpcLabel(0,"ID", guiLeft + 238, guiTop + 4)); - addLabel(new GuiNpcLabel(2, quest.id + "", guiLeft + 238, guiTop + 14)); + addLabel(new GuiNpcLabel(0, "ID", guiLeft + 238, guiTop + 4)); + addLabel(new GuiNpcLabel(2, quest.id + "", guiLeft + 238, guiTop + 14)); - addLabel(new GuiNpcLabel(3, "quest.completedtext", guiLeft + 7, guiTop + 33)); - addButton(new GuiNpcButton(3, guiLeft + 120, guiTop + 28, 50, 20, "selectServer.edit")); + addLabel(new GuiNpcLabel(3, "quest.completedtext", guiLeft + 7, guiTop + 33)); + addButton(new GuiNpcButton(3, guiLeft + 120, guiTop + 28, 50, 20, "selectServer.edit")); - addLabel(new GuiNpcLabel(4, "quest.questlogtext", guiLeft + 7, guiTop + 57)); - addButton(new GuiNpcButton(4, guiLeft + 120, guiTop + 52, 50, 20, "selectServer.edit")); + addLabel(new GuiNpcLabel(4, "quest.questlogtext", guiLeft + 7, guiTop + 57)); + addButton(new GuiNpcButton(4, guiLeft + 120, guiTop + 52, 50, 20, "selectServer.edit")); - addLabel(new GuiNpcLabel(5, "quest.reward", guiLeft + 7, guiTop + 81)); - addButton(new GuiNpcButton(5, guiLeft + 120, guiTop + 76, 50, 20, "selectServer.edit")); + addLabel(new GuiNpcLabel(5, "quest.reward", guiLeft + 7, guiTop + 81)); + addButton(new GuiNpcButton(5, guiLeft + 120, guiTop + 76, 50, 20, "selectServer.edit")); - addLabel(new GuiNpcLabel(10, "faction.options", guiLeft + 180, guiTop + 33)); - addButton(new GuiNpcButton(10, guiLeft + 303, guiTop + 28, 50, 20, "selectServer.edit")); + addLabel(new GuiNpcLabel(10, "faction.options", guiLeft + 180, guiTop + 33)); + addButton(new GuiNpcButton(10, guiLeft + 303, guiTop + 28, 50, 20, "selectServer.edit")); - addLabel(new GuiNpcLabel(11, "advMode.command", guiLeft + 180, guiTop + 57)); - addButton(new GuiNpcButton(11, guiLeft + 303, guiTop + 52, 50, 20, "selectServer.edit")); + addLabel(new GuiNpcLabel(11, "advMode.command", guiLeft + 180, guiTop + 57)); + addButton(new GuiNpcButton(11, guiLeft + 303, guiTop + 52, 50, 20, "selectServer.edit")); - addLabel(new GuiNpcLabel(6, "gui.type", guiLeft + 180, guiTop + 81)); - addButton(new GuiNpcButton(6, guiLeft + 240, guiTop + 76, 60, 20, new String[]{"quest.item","quest.dialog","quest.kill","quest.location","quest.areakill","quest.manual"},quest.type.ordinal())); - addButton(new GuiNpcButton(7, guiLeft + 303, guiTop + 76,50, 20, "selectServer.edit")); + addLabel(new GuiNpcLabel(6, "gui.type", guiLeft + 180, guiTop + 81)); + addButton(new GuiNpcButton(6, guiLeft + 240, guiTop + 76, 60, 20, new String[]{"quest.item", "quest.dialog", "quest.kill", "quest.location", "quest.areakill", "quest.manual"}, quest.type.ordinal())); + addButton(new GuiNpcButton(7, guiLeft + 303, guiTop + 76, 50, 20, "selectServer.edit")); - addLabel(new GuiNpcLabel(17, "party.options", guiLeft + 180, guiTop + 135)); - addButton(new GuiNpcButton(18, guiLeft + 303, guiTop + 130, 50, 20, "selectServer.edit")); + addLabel(new GuiNpcLabel(17, "party.options", guiLeft + 180, guiTop + 135)); + addButton(new GuiNpcButton(18, guiLeft + 303, guiTop + 130, 50, 20, "selectServer.edit")); addLabel(new GuiNpcLabel(33, "quest.profile", guiLeft + 180, guiTop + 159)); addButton(new GuiNpcButton(33, guiLeft + 303, guiTop + 154, 50, 20, "selectServer.edit")); - this.addButton(new GuiNpcButton(9, guiLeft + 7, guiTop + 102,90, 20, new String[]{"quest.npc","quest.instant"},quest.completion.ordinal())); - if(quest.completerNpc.isEmpty() && npc != null) - quest.completerNpc = npc.display.name; - this.addTextField(new GuiNpcTextField(2,this, this.fontRendererObj, guiLeft + 104, guiTop + 102, 154, 20, quest.completerNpc)); - this.getTextField(2).enabled = quest.completion == EnumQuestCompletion.Npc; + this.addButton(new GuiNpcButton(9, guiLeft + 7, guiTop + 102, 90, 20, new String[]{"quest.npc", "quest.instant"}, quest.completion.ordinal())); + if (quest.completerNpc.isEmpty() && npc != null) + quest.completerNpc = npc.display.name; + this.addTextField(new GuiNpcTextField(2, this, this.fontRendererObj, guiLeft + 104, guiTop + 102, 154, 20, quest.completerNpc)); + this.getTextField(2).enabled = quest.completion == EnumQuestCompletion.Npc; - addButton(new GuiNpcButton(15, guiLeft + 4, guiTop + 130, 144, 20, "quest.next")); - addButton(new GuiNpcButton(12, guiLeft + 150, guiTop + 130, 20, 20, "X")); - if(!parent.nextQuestName.isEmpty()) - getButton(15).setDisplayText(parent.nextQuestName); + addButton(new GuiNpcButton(15, guiLeft + 4, guiTop + 130, 144, 20, "quest.next")); + addButton(new GuiNpcButton(12, guiLeft + 150, guiTop + 130, 20, 20, "X")); + if (!parent.nextQuestName.isEmpty()) + getButton(15).setDisplayText(parent.nextQuestName); - addButton(new GuiNpcButton(13, guiLeft + 4, guiTop + 154, 144, 20, "mailbox.setup")); - addButton(new GuiNpcButton(14, guiLeft + 150, guiTop + 154, 20, 20, "X")); - if(!quest.mail.subject.isEmpty()) - getButton(13).setDisplayText(quest.mail.subject); + addButton(new GuiNpcButton(13, guiLeft + 4, guiTop + 154, 144, 20, "mailbox.setup")); + addButton(new GuiNpcButton(14, guiLeft + 150, guiTop + 154, 20, 20, "X")); + if (!quest.mail.subject.isEmpty()) + getButton(13).setDisplayText(quest.mail.subject); addLabel(new GuiNpcLabel(8, "quest.repeatable", guiLeft + 7, guiTop + 178 + 5)); this.addButton(new GuiNpcButton(8, guiLeft + 100, guiTop + 178, 70, 20, new String[]{"gui.no", "gui.yes", "quest.mcdaily", "quest.mcweekly", "quest.rldaily", "quest.rlweekly", "quest.mccustom", "quest.rlcustom"}, quest.repeat.ordinal())); - if(quest.repeat == EnumQuestRepeat.MCCUSTOM || quest.repeat == EnumQuestRepeat.RLCUSTOM) { + if (quest.repeat == EnumQuestRepeat.MCCUSTOM || quest.repeat == EnumQuestRepeat.RLCUSTOM) { addButton(new GuiNpcButton(19, guiLeft + 175, guiTop + 178, 90, 20, "Set Cooldown")); } - addButton(new GuiNpcButton(16, guiLeft + 303, guiTop + 192, 50, 20, "gui.done")); + addButton(new GuiNpcButton(16, guiLeft + 303, guiTop + 192, 50, 20, "gui.done")); - if(!quest.mail.subject.isEmpty()) - getButton(13).setDisplayText(quest.mail.subject); - } + if (!quest.mail.subject.isEmpty()) + getButton(13).setDisplayText(quest.mail.subject); + } - public void buttonEvent(GuiButton guibutton) - { - GuiNpcButton button = (GuiNpcButton) guibutton; - if(button.id == 3 && quest.id >= 0){ - questlogTA = false; - setSubGui(new SubGuiNpcTextArea(quest.completeText)); - } - if(button.id == 4 && quest.id >= 0){ - questlogTA = true; - setSubGui(new SubGuiNpcTextArea(quest.logText)); - } - if(button.id == 5 && quest.id >= 0){ + public void buttonEvent(GuiButton guibutton) { + GuiNpcButton button = (GuiNpcButton) guibutton; + if (button.id == 3 && quest.id >= 0) { + questlogTA = false; + setSubGui(new SubGuiNpcTextArea(quest.completeText)); + } + if (button.id == 4 && quest.id >= 0) { + questlogTA = true; + setSubGui(new SubGuiNpcTextArea(quest.logText)); + } + if (button.id == 5 && quest.id >= 0) { PacketClient.sendClient(new QuestOpenGuiPacket(EnumGuiType.QuestReward, quest.writeToNBT(new NBTTagCompound()))); - } - if(button.id == 6 && quest.id >= 0){ - quest.setType(EnumQuestType.values()[button.getValue()]); - } - if(button.id == 7) - { - if(quest.type == EnumQuestType.Item) + } + if (button.id == 6 && quest.id >= 0) { + quest.setType(EnumQuestType.values()[button.getValue()]); + } + if (button.id == 7) { + if (quest.type == EnumQuestType.Item) PacketClient.sendClient(new QuestOpenGuiPacket(EnumGuiType.QuestItem, quest.writeToNBT(new NBTTagCompound()))); - if(quest.type == EnumQuestType.Dialog) - setSubGui(new GuiNpcQuestTypeDialog(npc, quest, this)); + if (quest.type == EnumQuestType.Dialog) + setSubGui(new GuiNpcQuestTypeDialog(npc, quest, this)); - if(quest.type == EnumQuestType.Kill) - setSubGui(new GuiNpcQuestTypeKill(npc, quest, this)); + if (quest.type == EnumQuestType.Kill) + setSubGui(new GuiNpcQuestTypeKill(npc, quest, this)); - if(quest.type == EnumQuestType.Location) - setSubGui(new GuiNpcQuestTypeLocation(npc, quest, this)); + if (quest.type == EnumQuestType.Location) + setSubGui(new GuiNpcQuestTypeLocation(npc, quest, this)); - if(quest.type == EnumQuestType.AreaKill) - setSubGui(new GuiNpcQuestTypeKill(npc, quest, this)); + if (quest.type == EnumQuestType.AreaKill) + setSubGui(new GuiNpcQuestTypeKill(npc, quest, this)); - if(quest.type == EnumQuestType.Manual) + if (quest.type == EnumQuestType.Manual) setSubGui(new GuiNpcQuestTypeManual(npc, quest, this)); - } - if(button.id == 8) - { - quest.repeat = EnumQuestRepeat.values()[button.getValue()]; + } + if (button.id == 8) { + quest.repeat = EnumQuestRepeat.values()[button.getValue()]; initGui(); - } - if(button.id == 9) - { - quest.completion = EnumQuestCompletion.values()[button.getValue()]; - this.getTextField(2).enabled = quest.completion == EnumQuestCompletion.Npc; - } - if(button.id == 10) - { - setSubGui(new SubGuiNpcFactionOptions(quest.factionOptions)); - } - if(button.id == 11){ - setSubGui(new SubGuiNpcCommand(quest.command)); - } - if(button.id == 12 && quest.id >= 0){ - quest.nextQuestid = -1; - parent.nextQuestName = ""; - initGui(); - } - if(button.id == 13){ - setSubGui(new SubGuiMailmanSendSetup(quest.mail, getParent())); - } - if(button.id == 14){ - quest.mail = new PlayerMail(); - initGui(); - } - if(button.id == 15 && quest.id >= 0){ + } + if (button.id == 9) { + quest.completion = EnumQuestCompletion.values()[button.getValue()]; + this.getTextField(2).enabled = quest.completion == EnumQuestCompletion.Npc; + } + if (button.id == 10) { + setSubGui(new SubGuiNpcFactionOptions(quest.factionOptions)); + } + if (button.id == 11) { + setSubGui(new SubGuiNpcCommand(quest.command)); + } + if (button.id == 12 && quest.id >= 0) { + quest.nextQuestid = -1; + parent.nextQuestName = ""; + initGui(); + } + if (button.id == 13) { + setSubGui(new SubGuiMailmanSendSetup(quest.mail, getParent())); + } + if (button.id == 14) { + quest.mail = new PlayerMail(); + initGui(); + } + if (button.id == 15 && quest.id >= 0) { setSubGui(new GuiQuestSelection(quest.nextQuestid)); - } - if(button.id == 18) - { - setSubGui(new SubGuiNpcPartyOptions(quest.partyOptions)); - } - if(button.id == 19) { + } + if (button.id == 18) { + setSubGui(new SubGuiNpcPartyOptions(quest.partyOptions)); + } + if (button.id == 19) { boolean isMCCustom = (quest.repeat == EnumQuestRepeat.MCCUSTOM); setSubGui(new SubGuiNpcCooldownPicker(isMCCustom, quest.customCooldown)); } - if(button.id == 33){ + if (button.id == 33) { setSubGui(new SubGuiNpcProfileOptions(quest.profileOptions)); } - if(button.id == 16){ - close(); - } - } + if (button.id == 16) { + close(); + } + } - @Override - public void unFocused(GuiNpcTextField guiNpcTextField) { - if(guiNpcTextField.id == 1) { - if(quest.id < 0) - guiNpcTextField.setText(""); - else{ - String name = guiNpcTextField.getText(); - if(name.isEmpty() || this.parent.questData.containsKey(name)){ - guiNpcTextField.setText(quest.title); - } - else if(quest.id >= 0){ - String old = quest.title; - this.parent.questData.remove(old); - quest.title = name; - this.parent.questData.put(quest.title, quest.id); - this.parent.questScroll.replace(old, quest.title); - } - } - } - if(guiNpcTextField.id == 2){ - quest.completerNpc = guiNpcTextField.getText(); - } - } + @Override + public void unFocused(GuiNpcTextField guiNpcTextField) { + if (guiNpcTextField.id == 1) { + if (quest.id < 0) + guiNpcTextField.setText(""); + else { + String name = guiNpcTextField.getText(); + if (name.isEmpty() || this.parent.questData.containsKey(name)) { + guiNpcTextField.setText(quest.title); + } else if (quest.id >= 0) { + String old = quest.title; + this.parent.questData.remove(old); + quest.title = name; + this.parent.questData.put(quest.title, quest.id); + this.parent.questScroll.replace(old, quest.title); + } + } + } + if (guiNpcTextField.id == 2) { + quest.completerNpc = guiNpcTextField.getText(); + } + } - @Override - public void subGuiClosed(SubGuiInterface subgui){ - if(subgui instanceof SubGuiNpcTextArea){ - SubGuiNpcTextArea gui = (SubGuiNpcTextArea) subgui; - if(questlogTA) - quest.logText = gui.text; - else - quest.completeText = gui.text; - } - else if(subgui instanceof SubGuiNpcCommand){ - SubGuiNpcCommand sub = (SubGuiNpcCommand) subgui; - quest.command = sub.command; + @Override + public void subGuiClosed(SubGuiInterface subgui) { + if (subgui instanceof SubGuiNpcTextArea) { + SubGuiNpcTextArea gui = (SubGuiNpcTextArea) subgui; + if (questlogTA) + quest.logText = gui.text; + else + quest.completeText = gui.text; + } else if (subgui instanceof SubGuiNpcCommand) { + SubGuiNpcCommand sub = (SubGuiNpcCommand) subgui; + quest.command = sub.command; initGui(); - } else if(subgui instanceof SubGuiNpcCooldownPicker){ + } else if (subgui instanceof SubGuiNpcCooldownPicker) { SubGuiNpcCooldownPicker cooldownGui = (SubGuiNpcCooldownPicker) subgui; quest.customCooldown = cooldownGui.cooldownValue; initGui(); + } else { + initGui(); } - else { - initGui(); - } - } + } - @Override - public void selected(int id, String name) { - quest.nextQuestid = id; - quest.nextQuestTitle = name; - parent.nextQuestName = name; - initGui(); + @Override + public void selected(int id, String name) { + quest.nextQuestid = id; + quest.nextQuestTitle = name; + parent.nextQuestName = name; + initGui(); PacketClient.sendClient(new QuestSavePacket(this.questCategoryID, quest.writeToNBT(new NBTTagCompound()), false)); - } + } - public void save(){ + public void save() { PacketClient.sendClient(new QuestSavePacket(this.questCategoryID, quest.writeToNBT(new NBTTagCompound()), false)); - } + } } diff --git a/src/main/java/noppes/npcs/client/gui/SubGuiNpcRangeProperties.java b/src/main/java/noppes/npcs/client/gui/SubGuiNpcRangeProperties.java index 53a6bb044..5d376f9bf 100644 --- a/src/main/java/noppes/npcs/client/gui/SubGuiNpcRangeProperties.java +++ b/src/main/java/noppes/npcs/client/gui/SubGuiNpcRangeProperties.java @@ -5,25 +5,23 @@ import noppes.npcs.DataStats; import noppes.npcs.client.gui.select.GuiSoundSelection; import noppes.npcs.client.gui.util.*; -public class SubGuiNpcRangeProperties extends SubGuiInterface implements ITextfieldListener, ISubGuiListener -{ - private DataStats stats; +public class SubGuiNpcRangeProperties extends SubGuiInterface implements ITextfieldListener, ISubGuiListener { + private DataStats stats; private GuiNpcTextField soundSelected = null; - public SubGuiNpcRangeProperties(DataStats stats) - { - this.stats = stats; - setBackground("menubg.png"); - xSize = 256; - ySize = 216; - closeOnEsc = true; + public SubGuiNpcRangeProperties(DataStats stats) { + this.stats = stats; + setBackground("menubg.png"); + xSize = 256; + ySize = 216; + closeOnEsc = true; } - public void initGui(){ + public void initGui() { super.initGui(); int y = guiTop + 4; - addTextField(new GuiNpcTextField(1,this, fontRendererObj, guiLeft + 80, y, 50, 18, stats.accuracy+"")); - addLabel(new GuiNpcLabel(1,"stats.accuracy", guiLeft + 5, y + 5)); + addTextField(new GuiNpcTextField(1, this, fontRendererObj, guiLeft + 80, y, 50, 18, stats.accuracy + "")); + addLabel(new GuiNpcLabel(1, "stats.accuracy", guiLeft + 5, y + 5)); getTextField(1).integersOnly = true; getTextField(1).setMinMaxDefault(0, 100, 90); @@ -32,18 +30,18 @@ public class SubGuiNpcRangeProperties extends SubGuiInterface implements ITextfi getTextField(8).integersOnly = true; getTextField(8).setMinMaxDefault(1, Integer.MAX_VALUE, 1); - addTextField(new GuiNpcTextField(2,this, fontRendererObj, guiLeft + 80, y += 22, 50, 18, stats.rangedRange+"")); - addLabel(new GuiNpcLabel(2,"stats.rangedrange", guiLeft + 5, y + 5)); + addTextField(new GuiNpcTextField(2, this, fontRendererObj, guiLeft + 80, y += 22, 50, 18, stats.rangedRange + "")); + addLabel(new GuiNpcLabel(2, "stats.rangedrange", guiLeft + 5, y + 5)); getTextField(2).integersOnly = true; getTextField(2).setMinMaxDefault(1, 64, 2); - addTextField(new GuiNpcTextField(3,this, fontRendererObj, guiLeft + 80, y += 22, 50, 18, stats.minDelay+"")); - addLabel(new GuiNpcLabel(3,"stats.mindelay", guiLeft + 5, y + 5)); + addTextField(new GuiNpcTextField(3, this, fontRendererObj, guiLeft + 80, y += 22, 50, 18, stats.minDelay + "")); + addLabel(new GuiNpcLabel(3, "stats.mindelay", guiLeft + 5, y + 5)); getTextField(3).integersOnly = true; getTextField(3).setMinMaxDefault(1, Integer.MAX_VALUE, 20); - addTextField(new GuiNpcTextField(4,this, fontRendererObj, guiLeft + 200, y, 50, 18, stats.maxDelay+"")); - addLabel(new GuiNpcLabel(4,"stats.maxdelay", guiLeft + 135, y + 5)); + addTextField(new GuiNpcTextField(4, this, fontRendererObj, guiLeft + 200, y, 50, 18, stats.maxDelay + "")); + addLabel(new GuiNpcLabel(4, "stats.maxdelay", guiLeft + 135, y + 5)); getTextField(4).integersOnly = true; getTextField(4).setMinMaxDefault(1, Integer.MAX_VALUE, 20); @@ -53,85 +51,70 @@ public class SubGuiNpcRangeProperties extends SubGuiInterface implements ITextfi getTextField(6).integersOnly = true; getTextField(6).setMinMaxDefault(1, Integer.MAX_VALUE, 20); - addTextField(new GuiNpcTextField(5, this, fontRendererObj, guiLeft + 200, y , 50, 18, stats.fireRate + "")); + addTextField(new GuiNpcTextField(5, this, fontRendererObj, guiLeft + 200, y, 50, 18, stats.fireRate + "")); addLabel(new GuiNpcLabel(5, "stats.burstspeed", guiLeft + 135, y + 5)); - getTextField(5).integersOnly = true; - getTextField(5).setMinMaxDefault(0, Integer.MAX_VALUE, 0); + getTextField(5).integersOnly = true; + getTextField(5).setMinMaxDefault(0, Integer.MAX_VALUE, 0); - addTextField(new GuiNpcTextField(7,this, fontRendererObj, guiLeft + 80, y += 22, 100, 20, stats.fireSound)); - addLabel(new GuiNpcLabel(7, "stats.firesound:", guiLeft + 5, y + 5)); - addButton(new GuiNpcButton(7, guiLeft + 187, y, 60, 20, "gui.select")); + addTextField(new GuiNpcTextField(7, this, fontRendererObj, guiLeft + 80, y += 22, 100, 20, stats.fireSound)); + addLabel(new GuiNpcLabel(7, "stats.firesound:", guiLeft + 5, y + 5)); + addButton(new GuiNpcButton(7, guiLeft + 187, y, 60, 20, "gui.select")); - addButton(new GuiNpcButtonYesNo(9, guiLeft + 100, y += 22, stats.aimWhileShooting)); - addLabel(new GuiNpcLabel(9, "stats.aimWhileShooting", guiLeft + 5, y + 5)); + addButton(new GuiNpcButtonYesNo(9, guiLeft + 100, y += 22, stats.aimWhileShooting)); + addLabel(new GuiNpcLabel(9, "stats.aimWhileShooting", guiLeft + 5, y + 5)); - addButton(new GuiNpcButton(66, guiLeft + 190, guiTop + 190, 60, 20, "gui.done")); + addButton(new GuiNpcButton(66, guiLeft + 190, guiTop + 190, 60, 20, "gui.done")); } - public void unFocused(GuiNpcTextField textfield) { - if(textfield.id == 1){ - stats.accuracy = textfield.getInteger(); - } - else if(textfield.id == 2){ - stats.rangedRange = textfield.getInteger(); - } - else if(textfield.id == 3){ - if (textfield.getInteger() > stats.maxDelay) - { - stats.minDelay = stats.maxDelay; - textfield.setText(stats.minDelay + ""); - } - else - { - stats.minDelay = textfield.getInteger(); - } - } - else if(textfield.id == 4){ - if (textfield.getInteger() < stats.minDelay) - { - stats.maxDelay = stats.minDelay; - textfield.setText(stats.maxDelay + ""); - } - else - { - stats.maxDelay = textfield.getInteger(); - } - } - else if(textfield.id == 5){ - stats.fireRate = textfield.getInteger(); - } - else if(textfield.id == 6){ - stats.burstCount = textfield.getInteger(); - } - else if(textfield.id == 7){ - stats.fireSound = textfield.getText(); - } - else if(textfield.id == 8){ - stats.shotCount = textfield.getInteger(); - } - } + public void unFocused(GuiNpcTextField textfield) { + if (textfield.id == 1) { + stats.accuracy = textfield.getInteger(); + } else if (textfield.id == 2) { + stats.rangedRange = textfield.getInteger(); + } else if (textfield.id == 3) { + if (textfield.getInteger() > stats.maxDelay) { + stats.minDelay = stats.maxDelay; + textfield.setText(stats.minDelay + ""); + } else { + stats.minDelay = textfield.getInteger(); + } + } else if (textfield.id == 4) { + if (textfield.getInteger() < stats.minDelay) { + stats.maxDelay = stats.minDelay; + textfield.setText(stats.maxDelay + ""); + } else { + stats.maxDelay = textfield.getInteger(); + } + } else if (textfield.id == 5) { + stats.fireRate = textfield.getInteger(); + } else if (textfield.id == 6) { + stats.burstCount = textfield.getInteger(); + } else if (textfield.id == 7) { + stats.fireSound = textfield.getText(); + } else if (textfield.id == 8) { + stats.shotCount = textfield.getInteger(); + } + } - @Override - protected void actionPerformed(GuiButton guibutton){ - int id = guibutton.id; - if(id == 7){ + @Override + protected void actionPerformed(GuiButton guibutton) { + int id = guibutton.id; + if (id == 7) { soundSelected = getTextField(7); setSubGui(new GuiSoundSelection(soundSelected.getText())); } - if(id == 66) - { - close(); + if (id == 66) { + close(); + } else if (id == 9) { + stats.aimWhileShooting = ((GuiNpcButtonYesNo) guibutton).getBoolean(); } - else if(id == 9){ - stats.aimWhileShooting = ((GuiNpcButtonYesNo)guibutton).getBoolean(); - } } @Override public void subGuiClosed(SubGuiInterface subgui) { GuiSoundSelection gss = (GuiSoundSelection) subgui; - if(gss.selectedResource != null) { + if (gss.selectedResource != null) { soundSelected.setText(gss.selectedResource.toString()); unFocused(soundSelected); initGui(); diff --git a/src/main/java/noppes/npcs/client/gui/SubGuiNpcResistanceProperties.java b/src/main/java/noppes/npcs/client/gui/SubGuiNpcResistanceProperties.java index bbe0e136b..ddcf0239b 100644 --- a/src/main/java/noppes/npcs/client/gui/SubGuiNpcResistanceProperties.java +++ b/src/main/java/noppes/npcs/client/gui/SubGuiNpcResistanceProperties.java @@ -4,90 +4,86 @@ import net.minecraft.client.gui.GuiButton; import noppes.npcs.Resistances; import noppes.npcs.client.gui.util.*; -public class SubGuiNpcResistanceProperties extends SubGuiInterface implements ISliderListener -{ - private Resistances resistances; - public SubGuiNpcResistanceProperties(Resistances resistances) - { - this.resistances = resistances; - setBackground("menubg.png"); - xSize = 256; - ySize = 216; - closeOnEsc = true; +public class SubGuiNpcResistanceProperties extends SubGuiInterface implements ISliderListener { + private Resistances resistances; + + public SubGuiNpcResistanceProperties(Resistances resistances) { + this.resistances = resistances; + setBackground("menubg.png"); + xSize = 256; + ySize = 216; + closeOnEsc = true; } - public void initGui() - { + public void initGui() { super.initGui(); int y = guiTop + 10; - addLabel(new GuiNpcLabel(0,"enchantment.knockback", guiLeft + 4, y + 5)); - addSlider(new GuiNpcSlider(this, 0, guiLeft + 94, y, (int)(resistances.knockback * 100 - 100) + "%", resistances.knockback / 2)); + addLabel(new GuiNpcLabel(0, "enchantment.knockback", guiLeft + 4, y + 5)); + addSlider(new GuiNpcSlider(this, 0, guiLeft + 94, y, (int) (resistances.knockback * 100 - 100) + "%", resistances.knockback / 2)); y += 22; - addLabel(new GuiNpcLabel(1,"item.arrow.name", guiLeft + 4, y + 5)); - addSlider(new GuiNpcSlider(this, 1, guiLeft + 94, y, (int)(resistances.arrow * 100 - 100) + "%", resistances.arrow / 2)); + addLabel(new GuiNpcLabel(1, "item.arrow.name", guiLeft + 4, y + 5)); + addSlider(new GuiNpcSlider(this, 1, guiLeft + 94, y, (int) (resistances.arrow * 100 - 100) + "%", resistances.arrow / 2)); getSlider(1).enabled = !resistances.disableDamage; y += 22; - addLabel(new GuiNpcLabel(2,"stats.melee", guiLeft + 4, y + 5)); - addSlider(new GuiNpcSlider(this, 2, guiLeft + 94, y, (int)(resistances.playermelee * 100 - 100) + "%", resistances.playermelee / 2)); + addLabel(new GuiNpcLabel(2, "stats.melee", guiLeft + 4, y + 5)); + addSlider(new GuiNpcSlider(this, 2, guiLeft + 94, y, (int) (resistances.playermelee * 100 - 100) + "%", resistances.playermelee / 2)); getSlider(2).enabled = !resistances.disableDamage; y += 22; - addLabel(new GuiNpcLabel(3,"stats.explosion", guiLeft + 4, y + 5)); - addSlider(new GuiNpcSlider(this, 3, guiLeft + 94, y, (int)(resistances.explosion * 100 - 100) + "%", resistances.explosion / 2)); + addLabel(new GuiNpcLabel(3, "stats.explosion", guiLeft + 4, y + 5)); + addSlider(new GuiNpcSlider(this, 3, guiLeft + 94, y, (int) (resistances.explosion * 100 - 100) + "%", resistances.explosion / 2)); getSlider(3).enabled = !resistances.disableDamage; y += 22; - addLabel(new GuiNpcLabel(21,"stats.disabledamage", guiLeft + 4, y + 5)); - this.addButton(new GuiNpcButton(21, guiLeft + 94, y, 56, 20, new String[]{"gui.no","gui.yes"}, this.resistances.disableDamage? 1:0)); + addLabel(new GuiNpcLabel(21, "stats.disabledamage", guiLeft + 4, y + 5)); + this.addButton(new GuiNpcButton(21, guiLeft + 94, y, 56, 20, new String[]{"gui.no", "gui.yes"}, this.resistances.disableDamage ? 1 : 0)); - addButton(new GuiNpcButton(66, guiLeft + 190, guiTop + 190, 60, 20, "gui.done")); + addButton(new GuiNpcButton(66, guiLeft + 190, guiTop + 190, 60, 20, "gui.done")); } - protected void actionPerformed(GuiButton guibutton) - { - int id = guibutton.id; - if(id == 21){ - resistances.disableDamage = ((GuiNpcButton)guibutton).getValue() == 1; + protected void actionPerformed(GuiButton guibutton) { + int id = guibutton.id; + if (id == 21) { + resistances.disableDamage = ((GuiNpcButton) guibutton).getValue() == 1; initGui(); } - if(id == 66) - { - close(); + if (id == 66) { + close(); } } - @Override - public void mouseDragged(GuiNpcSlider slider) { - slider.displayString = (int)(slider.sliderValue * 200 - 100) + "%"; - } + @Override + public void mouseDragged(GuiNpcSlider slider) { + slider.displayString = (int) (slider.sliderValue * 200 - 100) + "%"; + } - @Override - public void mousePressed(GuiNpcSlider slider) { + @Override + public void mousePressed(GuiNpcSlider slider) { - } + } - @Override - public void mouseReleased(GuiNpcSlider slider) { - if(slider.id == 0){ - resistances.knockback = slider.sliderValue * 2; - } - if(slider.id == 1){ - resistances.arrow = slider.sliderValue * 2; - } - if(slider.id == 2){ - resistances.playermelee = slider.sliderValue * 2; - } - if(slider.id == 3){ - resistances.explosion = slider.sliderValue * 2; - } + @Override + public void mouseReleased(GuiNpcSlider slider) { + if (slider.id == 0) { + resistances.knockback = slider.sliderValue * 2; + } + if (slider.id == 1) { + resistances.arrow = slider.sliderValue * 2; + } + if (slider.id == 2) { + resistances.playermelee = slider.sliderValue * 2; + } + if (slider.id == 3) { + resistances.explosion = slider.sliderValue * 2; + } - } + } } diff --git a/src/main/java/noppes/npcs/client/gui/SubGuiNpcRespawn.java b/src/main/java/noppes/npcs/client/gui/SubGuiNpcRespawn.java index bde28b39a..ea70f7cf2 100644 --- a/src/main/java/noppes/npcs/client/gui/SubGuiNpcRespawn.java +++ b/src/main/java/noppes/npcs/client/gui/SubGuiNpcRespawn.java @@ -4,68 +4,66 @@ import net.minecraft.client.gui.GuiButton; import noppes.npcs.DataStats; import noppes.npcs.client.gui.util.*; -public class SubGuiNpcRespawn extends SubGuiInterface implements ITextfieldListener -{ - private DataStats stats; - public SubGuiNpcRespawn(DataStats stats){ - this.stats = stats; - setBackground("menubg.png"); - xSize = 256; - ySize = 216; - closeOnEsc = true; +public class SubGuiNpcRespawn extends SubGuiInterface implements ITextfieldListener { + private DataStats stats; + + public SubGuiNpcRespawn(DataStats stats) { + this.stats = stats; + setBackground("menubg.png"); + xSize = 256; + ySize = 216; + closeOnEsc = true; } @Override - public void initGui(){ + public void initGui() { super.initGui(); - addLabel(new GuiNpcLabel(0,"stats.respawn", guiLeft + 5, guiTop + 35)); - addButton(new GuiNpcButton(0,guiLeft + 122, guiTop + 30, 56, 20, new String[]{"gui.yes","gui.day","gui.night","gui.no"} ,stats.spawnCycle)); - if(stats.respawnTime > 0){ - addLabel(new GuiNpcLabel(3,"gui.time", guiLeft + 5, guiTop + 57)); - addTextField(new GuiNpcTextField(2,this, fontRendererObj, guiLeft + 122, guiTop + 53, 50, 18, stats.respawnTime + "")); - getTextField(2).integersOnly = true; - getTextField(2).setMinMaxDefault(1, Integer.MAX_VALUE, 20); - - addLabel(new GuiNpcLabel(4,"stats.deadbody", guiLeft + 4, guiTop + 79)); - addButton(new GuiNpcButton(4,guiLeft + 122, guiTop + 74, 51, 20, new String[]{"gui.no","gui.yes"} ,stats.hideKilledBody?1:0)); - } - + addLabel(new GuiNpcLabel(0, "stats.respawn", guiLeft + 5, guiTop + 35)); + addButton(new GuiNpcButton(0, guiLeft + 122, guiTop + 30, 56, 20, new String[]{"gui.yes", "gui.day", "gui.night", "gui.no"}, stats.spawnCycle)); + if (stats.respawnTime > 0) { + addLabel(new GuiNpcLabel(3, "gui.time", guiLeft + 5, guiTop + 57)); + addTextField(new GuiNpcTextField(2, this, fontRendererObj, guiLeft + 122, guiTop + 53, 50, 18, stats.respawnTime + "")); + getTextField(2).integersOnly = true; + getTextField(2).setMinMaxDefault(1, Integer.MAX_VALUE, 20); - addLabel(new GuiNpcLabel(1,"stats.naturallydespawns", guiLeft + 4, guiTop + 101)); - addButton(new GuiNpcButton(1,guiLeft + 122, guiTop + 96, 51, 20, new String[]{"gui.no","gui.yes"} ,stats.canDespawn?1:0)); + addLabel(new GuiNpcLabel(4, "stats.deadbody", guiLeft + 4, guiTop + 79)); + addButton(new GuiNpcButton(4, guiLeft + 122, guiTop + 74, 51, 20, new String[]{"gui.no", "gui.yes"}, stats.hideKilledBody ? 1 : 0)); + } - addButton(new GuiNpcButton(66, guiLeft + 82, guiTop + 190,98, 20, "gui.done")); + + addLabel(new GuiNpcLabel(1, "stats.naturallydespawns", guiLeft + 4, guiTop + 101)); + addButton(new GuiNpcButton(1, guiLeft + 122, guiTop + 96, 51, 20, new String[]{"gui.no", "gui.yes"}, stats.canDespawn ? 1 : 0)); + + addButton(new GuiNpcButton(66, guiLeft + 82, guiTop + 190, 98, 20, "gui.done")); } @Override - protected void actionPerformed(GuiButton guibutton){ - int id = guibutton.id; - GuiNpcButton button = (GuiNpcButton) guibutton; - if(button.id == 0){ - stats.spawnCycle = button.getValue(); - if(stats.spawnCycle == 3) - stats.respawnTime = 0; - else - stats.respawnTime = 20; - initGui(); - } - else if(button.id == 1){ - stats.canDespawn = button.getValue() == 1; - stats.playerSetCanDespawn = stats.canDespawn; - } - else if(button.id == 4){ - stats.hideKilledBody = button.getValue() == 1; - } - if(id == 66){ - close(); + protected void actionPerformed(GuiButton guibutton) { + int id = guibutton.id; + GuiNpcButton button = (GuiNpcButton) guibutton; + if (button.id == 0) { + stats.spawnCycle = button.getValue(); + if (stats.spawnCycle == 3) + stats.respawnTime = 0; + else + stats.respawnTime = 20; + initGui(); + } else if (button.id == 1) { + stats.canDespawn = button.getValue() == 1; + stats.playerSetCanDespawn = stats.canDespawn; + } else if (button.id == 4) { + stats.hideKilledBody = button.getValue() == 1; + } + if (id == 66) { + close(); } } - @Override - public void unFocused(GuiNpcTextField textfield) { - if(textfield.id == 2){ - stats.respawnTime = textfield.getInteger(); - } - } + @Override + public void unFocused(GuiNpcTextField textfield) { + if (textfield.id == 2) { + stats.respawnTime = textfield.getInteger(); + } + } } diff --git a/src/main/java/noppes/npcs/client/gui/SubGuiNpcTextArea.java b/src/main/java/noppes/npcs/client/gui/SubGuiNpcTextArea.java index 047535c31..24b2066dc 100644 --- a/src/main/java/noppes/npcs/client/gui/SubGuiNpcTextArea.java +++ b/src/main/java/noppes/npcs/client/gui/SubGuiNpcTextArea.java @@ -6,61 +6,61 @@ import noppes.npcs.client.gui.util.GuiNpcButton; import noppes.npcs.client.gui.util.GuiNpcTextArea; import noppes.npcs.client.gui.util.SubGuiInterface; -public class SubGuiNpcTextArea extends SubGuiInterface{ - public String text; - private GuiNpcTextArea textarea; +public class SubGuiNpcTextArea extends SubGuiInterface { + public String text; + private GuiNpcTextArea textarea; - public SubGuiNpcTextArea(String text){ - this.text = text; - setBackground("bgfilled.png"); - xSize = 256; - ySize = 256; - closeOnEsc = true; - } - - @Override - public void initGui(){ - xSize = (int) (width * 0.88); - ySize = (int) (xSize * 0.56); - bgScale = xSize / 440f; - super.initGui(); - if(textarea != null) - this.text = textarea.getText(); - int yoffset = (int) (ySize * 0.02); - this.addTextField(textarea = new GuiNpcTextArea(2, this, guiLeft + yoffset, guiTop + yoffset, xSize - 100 - yoffset * 2, ySize - yoffset * 2, text)); + public SubGuiNpcTextArea(String text) { + this.text = text; + setBackground("bgfilled.png"); + xSize = 256; + ySize = 256; + closeOnEsc = true; + } - - this.buttonList.add(new GuiNpcButton(102, guiLeft + xSize - 90 - yoffset, guiTop + 20, 56, 20, "gui.clear")); - this.buttonList.add(new GuiNpcButton(101, guiLeft + xSize - 90 - yoffset, guiTop + 43, 56, 20, "gui.paste")); - this.buttonList.add(new GuiNpcButton(100, guiLeft + xSize - 90 - yoffset, guiTop + 66, 56, 20, "gui.copy")); - - this.buttonList.add(new GuiNpcButton(0, guiLeft + xSize - 90 - yoffset, guiTop + 160, 56, 20, "gui.close")); - - xSize = 420; - ySize = 256; - } + @Override + public void initGui() { + xSize = (int) (width * 0.88); + ySize = (int) (xSize * 0.56); + bgScale = xSize / 440f; + super.initGui(); + if (textarea != null) + this.text = textarea.getText(); + int yoffset = (int) (ySize * 0.02); + this.addTextField(textarea = new GuiNpcTextArea(2, this, guiLeft + yoffset, guiTop + yoffset, xSize - 100 - yoffset * 2, ySize - yoffset * 2, text)); - @Override - public void close(){ - text = getTextField(2).getText(); - super.close(); - } + this.buttonList.add(new GuiNpcButton(102, guiLeft + xSize - 90 - yoffset, guiTop + 20, 56, 20, "gui.clear")); + this.buttonList.add(new GuiNpcButton(101, guiLeft + xSize - 90 - yoffset, guiTop + 43, 56, 20, "gui.paste")); + this.buttonList.add(new GuiNpcButton(100, guiLeft + xSize - 90 - yoffset, guiTop + 66, 56, 20, "gui.copy")); - @Override - public void buttonEvent(GuiButton guibutton) { - int id = guibutton.id; - if (id == 100) { - NoppesStringUtils.setClipboardContents(getTextField(2).getText()); - } - if (id == 101) { - getTextField(2).setText(NoppesStringUtils.getClipboardContents()); - } - if (id == 102) { - getTextField(2).setText(""); - } - if(id == 0){ - close(); - } - } + this.buttonList.add(new GuiNpcButton(0, guiLeft + xSize - 90 - yoffset, guiTop + 160, 56, 20, "gui.close")); + + xSize = 420; + ySize = 256; + } + + + @Override + public void close() { + text = getTextField(2).getText(); + super.close(); + } + + @Override + public void buttonEvent(GuiButton guibutton) { + int id = guibutton.id; + if (id == 100) { + NoppesStringUtils.setClipboardContents(getTextField(2).getText()); + } + if (id == 101) { + getTextField(2).setText(NoppesStringUtils.getClipboardContents()); + } + if (id == 102) { + getTextField(2).setText(""); + } + if (id == 0) { + close(); + } + } } diff --git a/src/main/java/noppes/npcs/client/gui/SubGuiNpcTint.java b/src/main/java/noppes/npcs/client/gui/SubGuiNpcTint.java index 9130b375b..cb5c24516 100644 --- a/src/main/java/noppes/npcs/client/gui/SubGuiNpcTint.java +++ b/src/main/java/noppes/npcs/client/gui/SubGuiNpcTint.java @@ -22,27 +22,27 @@ public class SubGuiNpcTint extends SubGuiInterface implements ISubGuiListener, I int y = 30; addLabel(new GuiNpcLabel(0, "tint.enable", guiLeft + 5, guiTop + y + 5)); addButton(new GuiNpcButtonYesNo(0, guiLeft + 122, guiTop + y, 56, 20, tintData.isTintEnabled())); - y+=22; + y += 22; if (tintData.isTintEnabled()) { addLabel(new GuiNpcLabel(1, "tint.enablegeneral", guiLeft + 5, guiTop + y + 5)); addButton(new GuiNpcButtonYesNo(1, guiLeft + 122, guiTop + y, 56, 20, tintData.isGeneralTintEnabled())); - y+=22; - if(tintData.isGeneralTintEnabled()) { + y += 22; + if (tintData.isGeneralTintEnabled()) { String color = Integer.toHexString(tintData.getGeneralTint()); while (color.length() < 6) color = 0 + color; addLabel(new GuiNpcLabel(2, "tint.tint", guiLeft + 4, guiTop + y + 5)); addButton(new GuiNpcButton(2, guiLeft + 122, guiTop + y, 60, 20, color)); getButton(2).setTextColor(tintData.getGeneralTint()); - y+=22; - addLabel(new GuiNpcLabel(3,"tint.alpha", guiLeft + 5, guiTop + y + 5)); - addTextField(new GuiNpcTextField(3,this, fontRendererObj, guiLeft + 122, guiTop + y, 60, 20, tintData.getGeneralAlpha() + "")); + y += 22; + addLabel(new GuiNpcLabel(3, "tint.alpha", guiLeft + 5, guiTop + y + 5)); + addTextField(new GuiNpcTextField(3, this, fontRendererObj, guiLeft + 122, guiTop + y, 60, 20, tintData.getGeneralAlpha() + "")); getTextField(3).integersOnly = true; getTextField(3).setMinMaxDefault(1, 100, 40); - y+=22; + y += 22; } addLabel(new GuiNpcLabel(4, "tint.enablehurt", guiLeft + 5, guiTop + y + 5)); addButton(new GuiNpcButtonYesNo(4, guiLeft + 122, guiTop + y, 56, 20, tintData.isHurtTintEnabled())); - y+=22; + y += 22; if (tintData.isHurtTintEnabled()) { String color2 = Integer.toHexString(tintData.getHurtTint()); while (color2.length() < 6) color2 = 0 + color2; @@ -96,7 +96,7 @@ public class SubGuiNpcTint extends SubGuiInterface implements ISubGuiListener, I @Override public void unFocused(GuiNpcTextField textfield) { - if(textfield.id==3){ + if (textfield.id == 3) { tintData.setGeneralAlpha(textfield.getInteger()); } } diff --git a/src/main/java/noppes/npcs/client/gui/SubGuiPlayerData.java b/src/main/java/noppes/npcs/client/gui/SubGuiPlayerData.java index 859a71349..58e352c19 100644 --- a/src/main/java/noppes/npcs/client/gui/SubGuiPlayerData.java +++ b/src/main/java/noppes/npcs/client/gui/SubGuiPlayerData.java @@ -2,8 +2,8 @@ package noppes.npcs.client.gui; import kamkeel.npcs.network.PacketClient; import kamkeel.npcs.network.packets.request.magic.MagicGetAllPacket; -import kamkeel.npcs.network.packets.request.playerdata.PlayerDataGetInfoPacket; import kamkeel.npcs.network.packets.request.playerdata.PlayerDataDeleteInfoPacket; +import kamkeel.npcs.network.packets.request.playerdata.PlayerDataGetInfoPacket; import kamkeel.npcs.network.packets.request.playerdata.PlayerDataSaveInfoPacket; import net.minecraft.client.gui.GuiButton; import net.minecraft.nbt.NBTTagCompound; @@ -212,7 +212,7 @@ public class SubGuiPlayerData extends SubGuiInterface implements IPlayerDataInfo } break; } - if(currentTab != 15) + if (currentTab != 15) addButton(new GuiNpcButton(30, guiLeft + xSize - 60, guiTop + 10 - 7, 50, 20, "gui.remove")); } @@ -459,7 +459,7 @@ public class SubGuiPlayerData extends SubGuiInterface implements IPlayerDataInfo addTextField(splitField); addTextField(damageField); - if(magicSelectedScroll.hasSelected()){ + if (magicSelectedScroll.hasSelected()) { String sel = magicSelectedScroll.getSelected(); int id = availableMagicElements.get(sel); if (magicData.hasMagic(id)) { @@ -997,7 +997,7 @@ public class SubGuiPlayerData extends SubGuiInterface implements IPlayerDataInfo super.actionPerformed(button); } - private void saveMagicCompound(){ + private void saveMagicCompound() { NBTTagCompound magicCompound = new NBTTagCompound(); magicData.writeToNBT(magicCompound); PacketClient.sendClient(new PlayerDataSaveInfoPacket(playerName, EnumPlayerData.Magic, magicCompound)); @@ -1121,7 +1121,8 @@ public class SubGuiPlayerData extends SubGuiInterface implements IPlayerDataInfo } @Override - public void customScrollDoubleClicked(String selection, GuiCustomScroll scroll) {} + public void customScrollDoubleClicked(String selection, GuiCustomScroll scroll) { + } @Override public void unFocused(GuiNpcTextField textField) { @@ -1133,12 +1134,14 @@ public class SubGuiPlayerData extends SubGuiInterface implements IPlayerDataInfo try { float split = Float.parseFloat(textField.getText()); magicData.getMagic(id).split = split; - } catch(NumberFormatException e) { } + } catch (NumberFormatException e) { + } } else if (textField.id == 74) { try { float dmg = Float.parseFloat(textField.getText()); magicData.getMagic(id).damage = dmg; - } catch(NumberFormatException e) { } + } catch (NumberFormatException e) { + } } } saveMagicCompound(); @@ -1154,7 +1157,7 @@ public class SubGuiPlayerData extends SubGuiInterface implements IPlayerDataInfo selected.add(name); } } - if(magicSelectedScroll != null) + if (magicSelectedScroll != null) magicSelectedScroll.setList(selected); } @@ -1170,5 +1173,6 @@ public class SubGuiPlayerData extends SubGuiInterface implements IPlayerDataInfo } @Override - public void setSelected(String selected) {} + public void setSelected(String selected) { + } } diff --git a/src/main/java/noppes/npcs/client/gui/SubGuiSpawningOptions.java b/src/main/java/noppes/npcs/client/gui/SubGuiSpawningOptions.java index 54728ec1a..98d6cb2b2 100644 --- a/src/main/java/noppes/npcs/client/gui/SubGuiSpawningOptions.java +++ b/src/main/java/noppes/npcs/client/gui/SubGuiSpawningOptions.java @@ -7,7 +7,7 @@ import noppes.npcs.controllers.data.SpawnData; public class SubGuiSpawningOptions extends SubGuiInterface implements ITextfieldListener { private SpawnData data; - public SubGuiSpawningOptions(SpawnData data){ + public SubGuiSpawningOptions(SpawnData data) { this.data = data; setBackground("menubg.png"); xSize = 216; diff --git a/src/main/java/noppes/npcs/client/gui/advanced/GuiNPCAdvancedLinkedNpc.java b/src/main/java/noppes/npcs/client/gui/advanced/GuiNPCAdvancedLinkedNpc.java index 360ead177..f954e0129 100644 --- a/src/main/java/noppes/npcs/client/gui/advanced/GuiNPCAdvancedLinkedNpc.java +++ b/src/main/java/noppes/npcs/client/gui/advanced/GuiNPCAdvancedLinkedNpc.java @@ -14,27 +14,27 @@ import java.util.HashMap; import java.util.List; import java.util.Vector; -public class GuiNPCAdvancedLinkedNpc extends GuiNPCInterface2 implements IScrollData, ICustomScrollListener{ - private GuiCustomScroll scroll; - private List data = new ArrayList(); +public class GuiNPCAdvancedLinkedNpc extends GuiNPCInterface2 implements IScrollData, ICustomScrollListener { + private GuiCustomScroll scroll; + private List data = new ArrayList(); - public static GuiScreen Instance; + public static GuiScreen Instance; - public GuiNPCAdvancedLinkedNpc(EntityNPCInterface npc){ - super(npc); - Instance = this; + public GuiNPCAdvancedLinkedNpc(EntityNPCInterface npc) { + super(npc); + Instance = this; LinkedGetAllPacket.GetNPCs(); } @Override - public void initGui(){ + public void initGui() { super.initGui(); - this.addButton(new GuiNpcButton(1,guiLeft + 358, guiTop + 38, 58, 20, "gui.clear")); + this.addButton(new GuiNpcButton(1, guiLeft + 358, guiTop + 38, 58, 20, "gui.clear")); - if(scroll == null){ - scroll = new GuiCustomScroll(this,0); - scroll.setSize(143, 208); + if (scroll == null) { + scroll = new GuiCustomScroll(this, 0); + scroll.setSize(143, 208); } scroll.guiLeft = guiLeft + 137; scroll.guiTop = guiTop + 4; @@ -44,33 +44,33 @@ public class GuiNPCAdvancedLinkedNpc extends GuiNPCInterface2 implements IScroll } @Override - public void buttonEvent(GuiButton button){ - if(button.id == 1){ + public void buttonEvent(GuiButton button) { + if (button.id == 1) { PacketClient.sendClient(new LinkedSetPacket("")); } } - @Override - public void setData(Vector list, HashMap data, EnumScrollData type) { - this.data = new ArrayList(list); - initGui(); - } + @Override + public void setData(Vector list, HashMap data, EnumScrollData type) { + this.data = new ArrayList(list); + initGui(); + } - @Override - public void setSelected(String selected) { - scroll.setSelected(selected); - } + @Override + public void setSelected(String selected) { + scroll.setSelected(selected); + } - @Override - public void save() { + @Override + public void save() { - } + } - @Override - public void customScrollClicked(int i, int j, int k, - GuiCustomScroll guiCustomScroll) { + @Override + public void customScrollClicked(int i, int j, int k, + GuiCustomScroll guiCustomScroll) { PacketClient.sendClient(new LinkedSetPacket(guiCustomScroll.getSelected())); - } + } } diff --git a/src/main/java/noppes/npcs/client/gui/advanced/GuiNPCDialogNpcOptions.java b/src/main/java/noppes/npcs/client/gui/advanced/GuiNPCDialogNpcOptions.java index 4db6170b1..084c11e1a 100644 --- a/src/main/java/noppes/npcs/client/gui/advanced/GuiNPCDialogNpcOptions.java +++ b/src/main/java/noppes/npcs/client/gui/advanced/GuiNPCDialogNpcOptions.java @@ -15,71 +15,73 @@ import noppes.npcs.entity.EntityNPCInterface; import java.util.HashMap; -public class GuiNPCDialogNpcOptions extends GuiNPCInterface2 implements GuiSelectionListener, IGuiData{ - private GuiScreen parent; - private HashMap data = new HashMap(); +public class GuiNPCDialogNpcOptions extends GuiNPCInterface2 implements GuiSelectionListener, IGuiData { + private GuiScreen parent; + private HashMap data = new HashMap(); - public GuiNPCDialogNpcOptions(EntityNPCInterface npc, GuiScreen parent) { - super(npc); - this.parent = parent; - this.drawDefaultBackground = true; + public GuiNPCDialogNpcOptions(EntityNPCInterface npc, GuiScreen parent) { + super(npc); + this.parent = parent; + this.drawDefaultBackground = true; PacketClient.sendClient(new DialogNpcGetPacket()); - } + } - public void initGui() { - super.initGui(); - for (int i = 0; i < 12; i++) { - int offset = i >=6 ?200:0; - this.addButton(new GuiNpcButton(i + 20, guiLeft + 20 + offset, guiTop + 13 + i % 6 * 22, 20, 20, "X")); - this.addLabel(new GuiNpcLabel(i, "" + i, guiLeft + 6 + offset, guiTop + 18 + i % 6 * 22)); + public void initGui() { + super.initGui(); + for (int i = 0; i < 12; i++) { + int offset = i >= 6 ? 200 : 0; + this.addButton(new GuiNpcButton(i + 20, guiLeft + 20 + offset, guiTop + 13 + i % 6 * 22, 20, 20, "X")); + this.addLabel(new GuiNpcLabel(i, "" + i, guiLeft + 6 + offset, guiTop + 18 + i % 6 * 22)); - String title = "dialog.selectoption"; - if(data.containsKey(i)) - title = data.get(i).title; - this.addButton(new GuiNpcButton(i, guiLeft + 44 + offset, guiTop + 13 + i % 6 * 22, 140, 20, title)); + String title = "dialog.selectoption"; + if (data.containsKey(i)) + title = data.get(i).title; + this.addButton(new GuiNpcButton(i, guiLeft + 44 + offset, guiTop + 13 + i % 6 * 22, 140, 20, title)); - } - } + } + } - public void drawScreen(int i, int j, float f) { - super.drawScreen(i, j, f); - } - private int selectedSlot; - protected void actionPerformed(GuiButton guibutton) { - int id = guibutton.id; - if (id >= 0 && id < 20) { - selectedSlot = id; - int dialogID = -1; - if(data.containsKey(id)) - dialogID = data.get(id).dialogId; + public void drawScreen(int i, int j, float f) { + super.drawScreen(i, j, f); + } + + private int selectedSlot; + + protected void actionPerformed(GuiButton guibutton) { + int id = guibutton.id; + if (id >= 0 && id < 20) { + selectedSlot = id; + int dialogID = -1; + if (data.containsKey(id)) + dialogID = data.get(id).dialogId; setSubGui(new GuiDialogSelection(dialogID)); - } - if (id >= 20 && id < 40) { - int slot = id - 20; - data.remove(slot); + } + if (id >= 20 && id < 40) { + int slot = id - 20; + data.remove(slot); PacketClient.sendClient(new DialogNpcRemovePacket(slot)); - initGui(); - } - } + initGui(); + } + } - public void save() { - return; - } + public void save() { + return; + } - @Override - public void selected(int id, String name) { + @Override + public void selected(int id, String name) { PacketClient.sendClient(new DialogNpcSetPacket(selectedSlot, id)); - } + } - @Override - public void setGuiData(NBTTagCompound compound) { - int pos = compound.getInteger("Position"); + @Override + public void setGuiData(NBTTagCompound compound) { + int pos = compound.getInteger("Position"); - DialogOption dialog = new DialogOption(); - dialog.readNBT(compound); + DialogOption dialog = new DialogOption(); + dialog.readNBT(compound); - data.put(pos, dialog); - initGui(); - } + data.put(pos, dialog); + initGui(); + } } diff --git a/src/main/java/noppes/npcs/client/gui/advanced/GuiNPCFactionSetup.java b/src/main/java/noppes/npcs/client/gui/advanced/GuiNPCFactionSetup.java index 4f3da362b..8caecf0c7 100644 --- a/src/main/java/noppes/npcs/client/gui/advanced/GuiNPCFactionSetup.java +++ b/src/main/java/noppes/npcs/client/gui/advanced/GuiNPCFactionSetup.java @@ -14,33 +14,30 @@ import noppes.npcs.entity.EntityNPCInterface; import java.util.HashMap; import java.util.Vector; -public class GuiNPCFactionSetup extends GuiNPCInterface2 implements IScrollData,ICustomScrollListener -{ - private GuiCustomScroll scrollFactions; - private HashMap data = new HashMap(); +public class GuiNPCFactionSetup extends GuiNPCInterface2 implements IScrollData, ICustomScrollListener { + private GuiCustomScroll scrollFactions; + private HashMap data = new HashMap(); - public GuiNPCFactionSetup(EntityNPCInterface npc) - { - super(npc); + public GuiNPCFactionSetup(EntityNPCInterface npc) { + super(npc); PacketClient.sendClient(new FactionsGetPacket()); } - public void initGui() - { + public void initGui() { super.initGui(); this.addLabel(new GuiNpcLabel(0, "faction.attackHostile", guiLeft + 4, guiTop + 25)); - this.addButton(new GuiNpcButton(0, guiLeft + 144, guiTop + 20,40,20, new String[]{"gui.no","gui.yes"}, npc.advanced.attackOtherFactions?1:0)); + this.addButton(new GuiNpcButton(0, guiLeft + 144, guiTop + 20, 40, 20, new String[]{"gui.no", "gui.yes"}, npc.advanced.attackOtherFactions ? 1 : 0)); this.addLabel(new GuiNpcLabel(1, "faction.defend", guiLeft + 4, guiTop + 47)); - this.addButton(new GuiNpcButton(1, guiLeft + 144, guiTop + 42,40,20, new String[]{"gui.no","gui.yes"}, npc.advanced.defendFaction?1:0)); + this.addButton(new GuiNpcButton(1, guiLeft + 144, guiTop + 42, 40, 20, new String[]{"gui.no", "gui.yes"}, npc.advanced.defendFaction ? 1 : 0)); this.addLabel(new GuiNpcLabel(12, "faction.ondeath", guiLeft + 4, guiTop + 69)); addButton(new GuiNpcButton(12, guiLeft + 90, guiTop + 64, 80, 20, "faction.points")); - if(scrollFactions == null){ - scrollFactions = new GuiCustomScroll(this,0,0); - scrollFactions.setSize(180, 200); + if (scrollFactions == null) { + scrollFactions = new GuiCustomScroll(this, 0, 0); + scrollFactions.setSize(180, 200); } scrollFactions.guiLeft = guiLeft + 200; scrollFactions.guiTop = guiTop + 4; @@ -49,54 +46,49 @@ public class GuiNPCFactionSetup extends GuiNPCInterface2 implements IScrollData, @Override public void buttonEvent(GuiButton guibutton) { - { - GuiNpcButton button = (GuiNpcButton) guibutton; - if(button.id == 0) { - npc.advanced.attackOtherFactions = button.getValue() == 1; + GuiNpcButton button = (GuiNpcButton) guibutton; + if (button.id == 0) { + npc.advanced.attackOtherFactions = button.getValue() == 1; + } + if (button.id == 1) { + npc.advanced.defendFaction = button.getValue() == 1; + } + if (button.id == 12) + setSubGui(new SubGuiNpcFactionOptions(npc.advanced.factions)); } - if(button.id == 1) - { - npc.advanced.defendFaction = button.getValue() == 1; - } - if(button.id == 12) - setSubGui(new SubGuiNpcFactionOptions(npc.advanced.factions)); - } } - @Override - public void setData(Vector list, HashMap data, EnumScrollData type) - { - String name = npc.getFaction().name; - this.data = data; - scrollFactions.setList(list); + @Override + public void setData(Vector list, HashMap data, EnumScrollData type) { + String name = npc.getFaction().name; + this.data = data; + scrollFactions.setList(list); - if(name != null) - setSelected(name); - } - - public void mouseClicked(int i, int j, int k) - { - super.mouseClicked(i, j, k); - if(k == 0 && scrollFactions != null) - scrollFactions.mouseClicked(i, j, k); + if (name != null) + setSelected(name); } - @Override - public void setSelected(String selected) { - scrollFactions.setSelected(selected); - } + public void mouseClicked(int i, int j, int k) { + super.mouseClicked(i, j, k); + if (k == 0 && scrollFactions != null) + scrollFactions.mouseClicked(i, j, k); + } - @Override - public void customScrollClicked(int i, int j, int k, GuiCustomScroll guiCustomScroll) { - if(guiCustomScroll.id == 0) - { + @Override + public void setSelected(String selected) { + scrollFactions.setSelected(selected); + } + + @Override + public void customScrollClicked(int i, int j, int k, GuiCustomScroll guiCustomScroll) { + if (guiCustomScroll.id == 0) { PacketClient.sendClient(new FactionSetPacket(data.get(scrollFactions.getSelected()))); - } - } + } + } - public void save() { + public void save() { PacketClient.sendClient(new MainmenuAdvancedSavePacket(npc.advanced.writeToNBT(new NBTTagCompound()))); } } diff --git a/src/main/java/noppes/npcs/client/gui/advanced/GuiNPCLinesMenu.java b/src/main/java/noppes/npcs/client/gui/advanced/GuiNPCLinesMenu.java index 3a1b0a0e7..0c1682eab 100644 --- a/src/main/java/noppes/npcs/client/gui/advanced/GuiNPCLinesMenu.java +++ b/src/main/java/noppes/npcs/client/gui/advanced/GuiNPCLinesMenu.java @@ -15,50 +15,50 @@ import noppes.npcs.entity.EntityNPCInterface; public class GuiNPCLinesMenu extends GuiNPCInterface2 { public GuiNPCLinesMenu(EntityNPCInterface npc) { - super(npc); + super(npc); } - @Override - public void initGui(){ + @Override + public void initGui() { super.initGui(); - this.addButton(new GuiNpcButton(0, guiLeft + 85, guiTop + 20, "World Lines")); - this.addButton(new GuiNpcButton(1, guiLeft + 85, guiTop + 43, "Attack Lines")); - this.addButton(new GuiNpcButton(2, guiLeft + 85, guiTop + 66, "Interact Lines")); - this.addButton(new GuiNpcButton(5, guiLeft + 85, guiTop + 89, "Killed Lines")); - this.addButton(new GuiNpcButton(6, guiLeft + 85, guiTop + 112, "Kill Lines")); + this.addButton(new GuiNpcButton(0, guiLeft + 85, guiTop + 20, "World Lines")); + this.addButton(new GuiNpcButton(1, guiLeft + 85, guiTop + 43, "Attack Lines")); + this.addButton(new GuiNpcButton(2, guiLeft + 85, guiTop + 66, "Interact Lines")); + this.addButton(new GuiNpcButton(5, guiLeft + 85, guiTop + 89, "Killed Lines")); + this.addButton(new GuiNpcButton(6, guiLeft + 85, guiTop + 112, "Kill Lines")); - this.addLabel(new GuiNpcLabel(16, "Random Lines", guiLeft + 85, guiTop + 157)); - this.addButton(new GuiNpcButtonYesNo(16, guiLeft + 175, guiTop + 152, !npc.advanced.orderedLines)); + this.addLabel(new GuiNpcLabel(16, "Random Lines", guiLeft + 85, guiTop + 157)); + this.addButton(new GuiNpcButtonYesNo(16, guiLeft + 175, guiTop + 152, !npc.advanced.orderedLines)); } - @Override - protected void actionPerformed(GuiButton guibutton){ - int id = guibutton.id; - if(id == 0){ - NoppesUtil.openGUI(player, new GuiNPCLinesEdit(npc, npc.advanced.worldLines)); + @Override + protected void actionPerformed(GuiButton guibutton) { + int id = guibutton.id; + if (id == 0) { + NoppesUtil.openGUI(player, new GuiNPCLinesEdit(npc, npc.advanced.worldLines)); } - if(id == 1){ - NoppesUtil.openGUI(player, new GuiNPCLinesEdit(npc, npc.advanced.attackLines)); + if (id == 1) { + NoppesUtil.openGUI(player, new GuiNPCLinesEdit(npc, npc.advanced.attackLines)); } - if(id == 2){ - NoppesUtil.openGUI(player, new GuiNPCLinesEdit(npc, npc.advanced.interactLines)); + if (id == 2) { + NoppesUtil.openGUI(player, new GuiNPCLinesEdit(npc, npc.advanced.interactLines)); } - if(id == 5){ - NoppesUtil.openGUI(player, new GuiNPCLinesEdit(npc, npc.advanced.killedLines)); + if (id == 5) { + NoppesUtil.openGUI(player, new GuiNPCLinesEdit(npc, npc.advanced.killedLines)); } - if(id == 6){ - NoppesUtil.openGUI(player, new GuiNPCLinesEdit(npc, npc.advanced.killLines)); + if (id == 6) { + NoppesUtil.openGUI(player, new GuiNPCLinesEdit(npc, npc.advanced.killLines)); } - if(id == 16){ - npc.advanced.orderedLines = !((GuiNpcButtonYesNo)guibutton).getBoolean(); + if (id == 16) { + npc.advanced.orderedLines = !((GuiNpcButtonYesNo) guibutton).getBoolean(); } } - @Override - public void save() { + @Override + public void save() { PacketClient.sendClient(new MainmenuAdvancedSavePacket(npc.advanced.writeToNBT(new NBTTagCompound()))); - } + } } diff --git a/src/main/java/noppes/npcs/client/gui/advanced/GuiNPCMagic.java b/src/main/java/noppes/npcs/client/gui/advanced/GuiNPCMagic.java index 013674161..5fcd3a825 100644 --- a/src/main/java/noppes/npcs/client/gui/advanced/GuiNPCMagic.java +++ b/src/main/java/noppes/npcs/client/gui/advanced/GuiNPCMagic.java @@ -261,12 +261,14 @@ public class GuiNPCMagic extends GuiNPCInterface2 implements IScrollData, ICusto try { float split = Float.parseFloat(textField.getText()); npcMagicData.getMagic(id).split = split; - } catch (NumberFormatException e) { } + } catch (NumberFormatException e) { + } } else if (textField.id == 74) { try { float bonus = Float.parseFloat(textField.getText()); npcMagicData.getMagic(id).damage = bonus; - } catch (NumberFormatException e) { } + } catch (NumberFormatException e) { + } } save(); } diff --git a/src/main/java/noppes/npcs/client/gui/advanced/GuiNPCMarks.java b/src/main/java/noppes/npcs/client/gui/advanced/GuiNPCMarks.java index 048af68c0..bc22bcde2 100644 --- a/src/main/java/noppes/npcs/client/gui/advanced/GuiNPCMarks.java +++ b/src/main/java/noppes/npcs/client/gui/advanced/GuiNPCMarks.java @@ -11,74 +11,74 @@ import noppes.npcs.controllers.data.MarkData; import noppes.npcs.entity.EntityNPCInterface; public class GuiNPCMarks extends GuiNPCInterface2 implements ISubGuiListener { - private final String[] marks = new String[]{"gui.none", "mark.question", "mark.exclamation", "mark.pointer", "mark.skull", "mark.cross", "mark.star"}; - private MarkData data; - private MarkData.Mark selectedMark; + private final String[] marks = new String[]{"gui.none", "mark.question", "mark.exclamation", "mark.pointer", "mark.skull", "mark.cross", "mark.star"}; + private MarkData data; + private MarkData.Mark selectedMark; - public GuiNPCMarks(EntityNPCInterface npc){ - super(npc); - this.data = MarkData.get(npc); + public GuiNPCMarks(EntityNPCInterface npc) { + super(npc); + this.data = MarkData.get(npc); } @Override - public void initGui(){ + public void initGui() { super.initGui(); int y = guiTop + 14; - for(int i = 0; i < data.marks.size(); i++){ - MarkData.Mark mark = data.marks.get(i); - this.addButton(new GuiButtonBiDirectional(1 + i * 10, guiLeft + 6, y, 120, 20, marks, mark.type)); + for (int i = 0; i < data.marks.size(); i++) { + MarkData.Mark mark = data.marks.get(i); + this.addButton(new GuiButtonBiDirectional(1 + i * 10, guiLeft + 6, y, 120, 20, marks, mark.type)); - String color = Integer.toHexString(mark.color); - while(color.length() < 6) - color = "0" + color; - addButton(new GuiNpcButton(2 + i * 10, guiLeft + 128, y, 60, 20, color)); - getButton(2 + i * 10).setTextColor(mark.color); + String color = Integer.toHexString(mark.color); + while (color.length() < 6) + color = "0" + color; + addButton(new GuiNpcButton(2 + i * 10, guiLeft + 128, y, 60, 20, color)); + getButton(2 + i * 10).setTextColor(mark.color); - this.addButton(new GuiNpcButton(3 + i * 10, guiLeft + 190, y, 120, 20, "availability.options")); - this.addButton(new GuiNpcButton(4 + i * 10, guiLeft + 312, y, 40, 20, "X")); - y += 22; + this.addButton(new GuiNpcButton(3 + i * 10, guiLeft + 190, y, 120, 20, "availability.options")); + this.addButton(new GuiNpcButton(4 + i * 10, guiLeft + 312, y, 40, 20, "X")); + y += 22; } - if(data.marks.size() < 9){ - this.addButton(new GuiNpcButton(101 , guiLeft + 6, y + 2, 60, 20, "gui.add")); + if (data.marks.size() < 9) { + this.addButton(new GuiNpcButton(101, guiLeft + 6, y + 2, 60, 20, "gui.add")); } } @Override - public void buttonEvent(GuiButton button){ - if(button.id < 90){ - selectedMark = data.marks.get(button.id / 10); - if(button.id % 10 == 1){ - selectedMark.type = ((GuiNpcButton)button).getValue(); - } - if(button.id % 10 == 2){ - this.setSubGui(new SubGuiColorSelector(selectedMark.color)); - } - if(button.id % 10 == 3){ - setSubGui(new SubGuiNpcAvailability(selectedMark.availability)); - } - if(button.id % 10 == 4){ - data.marks.remove(selectedMark); - initGui(); - } - } - if(button.id == 101){ - data.addMark(MarkType.NONE); - initGui(); + public void buttonEvent(GuiButton button) { + if (button.id < 90) { + selectedMark = data.marks.get(button.id / 10); + if (button.id % 10 == 1) { + selectedMark.type = ((GuiNpcButton) button).getValue(); + } + if (button.id % 10 == 2) { + this.setSubGui(new SubGuiColorSelector(selectedMark.color)); + } + if (button.id % 10 == 3) { + setSubGui(new SubGuiNpcAvailability(selectedMark.availability)); + } + if (button.id % 10 == 4) { + data.marks.remove(selectedMark); + initGui(); + } + } + if (button.id == 101) { + data.addMark(MarkType.NONE); + initGui(); } } - @Override - public void subGuiClosed(SubGuiInterface subgui) { - if(subgui instanceof SubGuiColorSelector){ - selectedMark.color = ((SubGuiColorSelector)subgui).color; - initGui(); - } - } + @Override + public void subGuiClosed(SubGuiInterface subgui) { + if (subgui instanceof SubGuiColorSelector) { + selectedMark.color = ((SubGuiColorSelector) subgui).color; + initGui(); + } + } - @Override - public void save() { + @Override + public void save() { PacketClient.sendClient(new MainmenuAdvancedMarkDataPacket(data.getNBT())); - } + } } diff --git a/src/main/java/noppes/npcs/client/gui/advanced/GuiNPCNightSetup.java b/src/main/java/noppes/npcs/client/gui/advanced/GuiNPCNightSetup.java index 4ca3755b6..c0999471e 100644 --- a/src/main/java/noppes/npcs/client/gui/advanced/GuiNPCNightSetup.java +++ b/src/main/java/noppes/npcs/client/gui/advanced/GuiNPCNightSetup.java @@ -13,90 +13,87 @@ import noppes.npcs.client.gui.util.IGuiData; import noppes.npcs.controllers.data.DataTransform; import noppes.npcs.entity.EntityNPCInterface; -public class GuiNPCNightSetup extends GuiNPCInterface2 implements IGuiData -{ - private DataTransform data; +public class GuiNPCNightSetup extends GuiNPCInterface2 implements IGuiData { + private DataTransform data; - public GuiNPCNightSetup(EntityNPCInterface npc) - { - super(npc); - data = npc.transform; + public GuiNPCNightSetup(EntityNPCInterface npc) { + super(npc); + data = npc.transform; PacketClient.sendClient(new TransformGetPacket()); } - public void initGui() - { + public void initGui() { super.initGui(); this.addLabel(new GuiNpcLabel(0, "menu.display", guiLeft + 4, guiTop + 25)); - this.addButton(new GuiNpcButton(0, guiLeft + 104, guiTop + 20, 50, 20, new String[]{"gui.no","gui.yes"}, data.hasDisplay?1:0)); + this.addButton(new GuiNpcButton(0, guiLeft + 104, guiTop + 20, 50, 20, new String[]{"gui.no", "gui.yes"}, data.hasDisplay ? 1 : 0)); this.addLabel(new GuiNpcLabel(1, "menu.stats", guiLeft + 4, guiTop + 47)); - this.addButton(new GuiNpcButton(1, guiLeft + 104, guiTop + 42, 50, 20, new String[]{"gui.no","gui.yes"}, data.hasStats?1:0)); + this.addButton(new GuiNpcButton(1, guiLeft + 104, guiTop + 42, 50, 20, new String[]{"gui.no", "gui.yes"}, data.hasStats ? 1 : 0)); this.addLabel(new GuiNpcLabel(2, "menu.ai", guiLeft + 4, guiTop + 69)); - this.addButton(new GuiNpcButton(2, guiLeft + 104, guiTop + 64, 50, 20, new String[]{"gui.no","gui.yes"}, data.hasAi?1:0)); + this.addButton(new GuiNpcButton(2, guiLeft + 104, guiTop + 64, 50, 20, new String[]{"gui.no", "gui.yes"}, data.hasAi ? 1 : 0)); this.addLabel(new GuiNpcLabel(3, "menu.inventory", guiLeft + 4, guiTop + 91)); - this.addButton(new GuiNpcButton(3, guiLeft + 104, guiTop + 86, 50, 20, new String[]{"gui.no","gui.yes"}, data.hasInv?1:0)); + this.addButton(new GuiNpcButton(3, guiLeft + 104, guiTop + 86, 50, 20, new String[]{"gui.no", "gui.yes"}, data.hasInv ? 1 : 0)); this.addLabel(new GuiNpcLabel(4, "menu.advanced", guiLeft + 4, guiTop + 113)); - this.addButton(new GuiNpcButton(4, guiLeft + 104, guiTop + 108, 50, 20, new String[]{"gui.no","gui.yes"}, data.hasAdvanced?1:0)); + this.addButton(new GuiNpcButton(4, guiLeft + 104, guiTop + 108, 50, 20, new String[]{"gui.no", "gui.yes"}, data.hasAdvanced ? 1 : 0)); this.addLabel(new GuiNpcLabel(5, "role.name", guiLeft + 4, guiTop + 135)); - this.addButton(new GuiNpcButton(5, guiLeft + 104, guiTop + 130, 50, 20, new String[]{"gui.no","gui.yes"}, data.hasRole?1:0)); + this.addButton(new GuiNpcButton(5, guiLeft + 104, guiTop + 130, 50, 20, new String[]{"gui.no", "gui.yes"}, data.hasRole ? 1 : 0)); this.addLabel(new GuiNpcLabel(6, "job.name", guiLeft + 4, guiTop + 157)); - this.addButton(new GuiNpcButton(6, guiLeft + 104, guiTop + 152, 50, 20, new String[]{"gui.no","gui.yes"}, data.hasJob?1:0)); + this.addButton(new GuiNpcButton(6, guiLeft + 104, guiTop + 152, 50, 20, new String[]{"gui.no", "gui.yes"}, data.hasJob ? 1 : 0)); this.addLabel(new GuiNpcLabel(10, "advanced.editingmode", guiLeft + 170, guiTop + 9)); - this.addButton(new GuiNpcButton(10, guiLeft + 244, guiTop + 4, 50, 20, new String[]{"gui.no","gui.yes"}, data.editingModus?1:0)); + this.addButton(new GuiNpcButton(10, guiLeft + 244, guiTop + 4, 50, 20, new String[]{"gui.no", "gui.yes"}, data.editingModus ? 1 : 0)); - if(data.editingModus){ - this.addButton(new GuiNpcButton(11, guiLeft + 170, guiTop + 34, "advanced.loadday")); - this.addButton(new GuiNpcButton(12, guiLeft + 170, guiTop + 56, "advanced.loadnight")); + if (data.editingModus) { + this.addButton(new GuiNpcButton(11, guiLeft + 170, guiTop + 34, "advanced.loadday")); + this.addButton(new GuiNpcButton(12, guiLeft + 170, guiTop + 56, "advanced.loadnight")); } } @Override public void buttonEvent(GuiButton guibutton) { - GuiNpcButton button = (GuiNpcButton) guibutton; - if(button.id == 0) - data.hasDisplay = button.getValue() == 1; - if(button.id == 1) - data.hasStats = button.getValue() == 1; - if(button.id == 2) - data.hasAi = button.getValue() == 1; - if(button.id == 3) - data.hasInv = button.getValue() == 1; - if(button.id == 4) - data.hasAdvanced = button.getValue() == 1; - if(button.id == 5) - data.hasRole = button.getValue() == 1; - if(button.id == 6) - data.hasJob = button.getValue() == 1; + GuiNpcButton button = (GuiNpcButton) guibutton; + if (button.id == 0) + data.hasDisplay = button.getValue() == 1; + if (button.id == 1) + data.hasStats = button.getValue() == 1; + if (button.id == 2) + data.hasAi = button.getValue() == 1; + if (button.id == 3) + data.hasInv = button.getValue() == 1; + if (button.id == 4) + data.hasAdvanced = button.getValue() == 1; + if (button.id == 5) + data.hasRole = button.getValue() == 1; + if (button.id == 6) + data.hasJob = button.getValue() == 1; - if(button.id == 10){ - data.editingModus = button.getValue() == 1; - save(); - initGui(); + if (button.id == 10) { + data.editingModus = button.getValue() == 1; + save(); + initGui(); } - if(button.id == 11){ + if (button.id == 11) { PacketClient.sendClient(new TransformLoadPacket(false)); } - if(button.id == 12){ + if (button.id == 12) { PacketClient.sendClient(new TransformLoadPacket(true)); } } - public void save() { + public void save() { PacketClient.sendClient(new TransformSavePacket(data.writeOptions(new NBTTagCompound()))); - } + } - @Override - public void setGuiData(NBTTagCompound compound) { - data.readOptions(compound); - initGui(); - } + @Override + public void setGuiData(NBTTagCompound compound) { + data.readOptions(compound); + initGui(); + } } diff --git a/src/main/java/noppes/npcs/client/gui/advanced/GuiNPCSoundsMenu.java b/src/main/java/noppes/npcs/client/gui/advanced/GuiNPCSoundsMenu.java index 352b9044c..44942ea4c 100644 --- a/src/main/java/noppes/npcs/client/gui/advanced/GuiNPCSoundsMenu.java +++ b/src/main/java/noppes/npcs/client/gui/advanced/GuiNPCSoundsMenu.java @@ -8,76 +8,76 @@ import noppes.npcs.client.gui.select.GuiSoundSelection; import noppes.npcs.client.gui.util.*; import noppes.npcs.entity.EntityNPCInterface; -public class GuiNPCSoundsMenu extends GuiNPCInterface2 implements ITextfieldListener, ISubGuiListener -{ - private GuiNpcTextField selectedField; - public GuiNPCSoundsMenu(EntityNPCInterface npc){ - super(npc); +public class GuiNPCSoundsMenu extends GuiNPCInterface2 implements ITextfieldListener, ISubGuiListener { + private GuiNpcTextField selectedField; + + public GuiNPCSoundsMenu(EntityNPCInterface npc) { + super(npc); } - public void initGui() - { + public void initGui() { super.initGui(); - addLabel(new GuiNpcLabel(0,"advanced.idlesound", guiLeft + 5, guiTop + 20)); - addTextField(new GuiNpcTextField(0,this, fontRendererObj, guiLeft + 80, guiTop + 15, 200, 20, npc.advanced.idleSound)); + addLabel(new GuiNpcLabel(0, "advanced.idlesound", guiLeft + 5, guiTop + 20)); + addTextField(new GuiNpcTextField(0, this, fontRendererObj, guiLeft + 80, guiTop + 15, 200, 20, npc.advanced.idleSound)); addButton(new GuiNpcButton(0, guiLeft + 290, guiTop + 15, 80, 20, "gui.selectSound")); - addLabel(new GuiNpcLabel(2,"advanced.angersound", guiLeft + 5, guiTop + 45)); - addTextField(new GuiNpcTextField(2,this, fontRendererObj, guiLeft + 80, guiTop + 40, 200, 20, npc.advanced.angrySound)); + addLabel(new GuiNpcLabel(2, "advanced.angersound", guiLeft + 5, guiTop + 45)); + addTextField(new GuiNpcTextField(2, this, fontRendererObj, guiLeft + 80, guiTop + 40, 200, 20, npc.advanced.angrySound)); addButton(new GuiNpcButton(2, guiLeft + 290, guiTop + 40, 80, 20, "gui.selectSound")); - addLabel(new GuiNpcLabel(3,"advanced.hurtsound", guiLeft + 5, guiTop + 70)); - addTextField(new GuiNpcTextField(3,this, fontRendererObj, guiLeft + 80, guiTop + 65, 200, 20, npc.advanced.hurtSound)); + addLabel(new GuiNpcLabel(3, "advanced.hurtsound", guiLeft + 5, guiTop + 70)); + addTextField(new GuiNpcTextField(3, this, fontRendererObj, guiLeft + 80, guiTop + 65, 200, 20, npc.advanced.hurtSound)); addButton(new GuiNpcButton(3, guiLeft + 290, guiTop + 65, 80, 20, "gui.selectSound")); - addLabel(new GuiNpcLabel(4,"advanced.deathsound", guiLeft + 5, guiTop + 95)); - addTextField(new GuiNpcTextField(4,this, fontRendererObj, guiLeft + 80, guiTop + 90, 200, 20, npc.advanced.deathSound)); + addLabel(new GuiNpcLabel(4, "advanced.deathsound", guiLeft + 5, guiTop + 95)); + addTextField(new GuiNpcTextField(4, this, fontRendererObj, guiLeft + 80, guiTop + 90, 200, 20, npc.advanced.deathSound)); addButton(new GuiNpcButton(4, guiLeft + 290, guiTop + 90, 80, 20, "gui.selectSound")); - addLabel(new GuiNpcLabel(5,"advanced.stepsound", guiLeft + 5, guiTop + 120)); - addTextField(new GuiNpcTextField(5,this, fontRendererObj, guiLeft + 80, guiTop + 115, 200, 20, npc.advanced.stepSound)); + addLabel(new GuiNpcLabel(5, "advanced.stepsound", guiLeft + 5, guiTop + 120)); + addTextField(new GuiNpcTextField(5, this, fontRendererObj, guiLeft + 80, guiTop + 115, 200, 20, npc.advanced.stepSound)); addButton(new GuiNpcButton(5, guiLeft + 290, guiTop + 115, 80, 20, "gui.selectSound")); - addLabel(new GuiNpcLabel(6,"advanced.haspitch", guiLeft + 5, guiTop + 150)); - addButton(new GuiNpcButton(6, guiLeft + 120, guiTop + 145, 80, 20, new String[]{"gui.no","gui.yes"}, npc.advanced.disablePitch?0:1)); + addLabel(new GuiNpcLabel(6, "advanced.haspitch", guiLeft + 5, guiTop + 150)); + addButton(new GuiNpcButton(6, guiLeft + 120, guiTop + 145, 80, 20, new String[]{"gui.no", "gui.yes"}, npc.advanced.disablePitch ? 0 : 1)); } - public void buttonEvent(GuiButton button){ - if(button.id == 6) - npc.advanced.disablePitch =((GuiNpcButton)button).getValue() == 0; - else{ + + public void buttonEvent(GuiButton button) { + if (button.id == 6) + npc.advanced.disablePitch = ((GuiNpcButton) button).getValue() == 0; + else { selectedField = getTextField(button.id); setSubGui(new GuiSoundSelection(selectedField.getText())); - } + } } - @Override - public void unFocused(GuiNpcTextField textfield) { - if(textfield.id == 0) - npc.advanced.idleSound = textfield.getText(); - if(textfield.id == 2) - npc.advanced.angrySound = textfield.getText(); - if(textfield.id == 3) - npc.advanced.hurtSound = textfield.getText(); - if(textfield.id == 4) - npc.advanced.deathSound = textfield.getText(); - if(textfield.id == 5) - npc.advanced.stepSound = textfield.getText(); - } + @Override + public void unFocused(GuiNpcTextField textfield) { + if (textfield.id == 0) + npc.advanced.idleSound = textfield.getText(); + if (textfield.id == 2) + npc.advanced.angrySound = textfield.getText(); + if (textfield.id == 3) + npc.advanced.hurtSound = textfield.getText(); + if (textfield.id == 4) + npc.advanced.deathSound = textfield.getText(); + if (textfield.id == 5) + npc.advanced.stepSound = textfield.getText(); + } @Override public void subGuiClosed(SubGuiInterface subgui) { GuiSoundSelection gss = (GuiSoundSelection) subgui; - if(gss.selectedResource != null) { + if (gss.selectedResource != null) { selectedField.setText(gss.selectedResource.toString()); unFocused(selectedField); initGui(); } } - @Override - public void save() { + @Override + public void save() { PacketClient.sendClient(new MainmenuAdvancedSavePacket(npc.advanced.writeToNBT(new NBTTagCompound()))); - } + } } diff --git a/src/main/java/noppes/npcs/client/gui/advanced/GuiNPCTagSetup.java b/src/main/java/noppes/npcs/client/gui/advanced/GuiNPCTagSetup.java index 859081c19..f32aeab39 100644 --- a/src/main/java/noppes/npcs/client/gui/advanced/GuiNPCTagSetup.java +++ b/src/main/java/noppes/npcs/client/gui/advanced/GuiNPCTagSetup.java @@ -18,133 +18,128 @@ import java.util.HashMap; import java.util.List; import java.util.Vector; -public class GuiNPCTagSetup extends GuiNPCInterface2 implements IScrollData,ICustomScrollListener,IGuiData -{ - private GuiCustomScroll scrollTags; - private GuiCustomScroll npcTags; - private final ArrayList allTags = new ArrayList<>(); - private ArrayList tagNames = new ArrayList<>(); - private String search = ""; +public class GuiNPCTagSetup extends GuiNPCInterface2 implements IScrollData, ICustomScrollListener, IGuiData { + private GuiCustomScroll scrollTags; + private GuiCustomScroll npcTags; + private final ArrayList allTags = new ArrayList<>(); + private ArrayList tagNames = new ArrayList<>(); + private String search = ""; - public GuiNPCTagSetup(EntityNPCInterface npc) - { - super(npc); + public GuiNPCTagSetup(EntityNPCInterface npc) { + super(npc); PacketClient.sendClient(new TagsGetPacket()); PacketClient.sendClient(new TagsNpcGetPacket()); } - public void initGui() - { + public void initGui() { super.initGui(); - addLabel(new GuiNpcLabel(1, StatCollector.translateToLocal("tags.allTags"), guiLeft + 22, guiTop + 11)); - if(scrollTags == null){ - scrollTags = new GuiCustomScroll(this,0); - scrollTags.setSize(150, 155); + addLabel(new GuiNpcLabel(1, StatCollector.translateToLocal("tags.allTags"), guiLeft + 22, guiTop + 11)); + if (scrollTags == null) { + scrollTags = new GuiCustomScroll(this, 0); + scrollTags.setSize(150, 155); } scrollTags.guiLeft = guiLeft + 20; scrollTags.guiTop = guiTop + 24; this.addScroll(scrollTags); - addTextField(new GuiNpcTextField(4, this, fontRendererObj, guiLeft + 20, guiTop + 24 + 160, 150, 20, search)); + addTextField(new GuiNpcTextField(4, this, fontRendererObj, guiLeft + 20, guiTop + 24 + 160, 150, 20, search)); - addLabel(new GuiNpcLabel(2, StatCollector.translateToLocal("tags.selectedTags"), guiLeft + 252, guiTop + 11)); - if(npcTags == null){ - npcTags = new GuiCustomScroll(this,1); - npcTags.setSize(150, 180); - } - npcTags.guiLeft = guiLeft + 250; - npcTags.guiTop = guiTop + 24; - npcTags.setList(tagNames); - this.addScroll(npcTags); + addLabel(new GuiNpcLabel(2, StatCollector.translateToLocal("tags.selectedTags"), guiLeft + 252, guiTop + 11)); + if (npcTags == null) { + npcTags = new GuiCustomScroll(this, 1); + npcTags.setSize(150, 180); + } + npcTags.guiLeft = guiLeft + 250; + npcTags.guiTop = guiTop + 24; + npcTags.setList(tagNames); + this.addScroll(npcTags); - addButton(new GuiNpcButton(10, guiLeft + 185, guiTop + 90, 55, 20, ">")); - addButton(new GuiNpcButton(11, guiLeft + 185, guiTop + 112, 55, 20, "<")); + addButton(new GuiNpcButton(10, guiLeft + 185, guiTop + 90, 55, 20, ">")); + addButton(new GuiNpcButton(11, guiLeft + 185, guiTop + 112, 55, 20, "<")); - addButton(new GuiNpcButton(12, guiLeft + 185, guiTop + 140, 55, 20, ">>")); - addButton(new GuiNpcButton(13, guiLeft + 185, guiTop + 162, 55, 20, "<<")); + addButton(new GuiNpcButton(12, guiLeft + 185, guiTop + 140, 55, 20, ">>")); + addButton(new GuiNpcButton(13, guiLeft + 185, guiTop + 162, 55, 20, "<<")); } @Override public void buttonEvent(GuiButton guibutton) { - if (guibutton.id == 10 && scrollTags.hasSelected() && !tagNames.contains(scrollTags.getSelected())) { - tagNames.add(scrollTags.getSelected()); - } - if (guibutton.id == 12) { - tagNames.clear(); - tagNames.addAll(allTags); - } - if (guibutton.id == 11 && npcTags.hasSelected()) { - tagNames.remove(npcTags.getSelected()); - } - if (guibutton.id == 13) { - tagNames.clear(); - } - initGui(); + if (guibutton.id == 10 && scrollTags.hasSelected() && !tagNames.contains(scrollTags.getSelected())) { + tagNames.add(scrollTags.getSelected()); + } + if (guibutton.id == 12) { + tagNames.clear(); + tagNames.addAll(allTags); + } + if (guibutton.id == 11 && npcTags.hasSelected()) { + tagNames.remove(npcTags.getSelected()); + } + if (guibutton.id == 13) { + tagNames.clear(); + } + initGui(); } - @Override - public void setData(Vector list, HashMap data, EnumScrollData type) - { - allTags.addAll(data.keySet()); - allTags.sort(String.CASE_INSENSITIVE_ORDER); - scrollTags.setList(allTags); - initGui(); - } - - @Override - public void setGuiData(NBTTagCompound compound) { - NBTTagList tagList = compound.getTagList("TagNames",8); - tagNames.clear(); - for (int i = 0; i < tagList.tagCount(); i++) { - tagNames.add(tagList.getStringTagAt(i)); - } - } - - public void mouseClicked(int i, int j, int k) - { - super.mouseClicked(i, j, k); - if(k == 0 && scrollTags != null) - scrollTags.mouseClicked(i, j, k); + @Override + public void setData(Vector list, HashMap data, EnumScrollData type) { + allTags.addAll(data.keySet()); + allTags.sort(String.CASE_INSENSITIVE_ORDER); + scrollTags.setList(allTags); + initGui(); } - @Override - public void setSelected(String selected) { - scrollTags.setSelected(selected); - } + @Override + public void setGuiData(NBTTagCompound compound) { + NBTTagList tagList = compound.getTagList("TagNames", 8); + tagNames.clear(); + for (int i = 0; i < tagList.tagCount(); i++) { + tagNames.add(tagList.getStringTagAt(i)); + } + } - @Override - public void customScrollClicked(int i, int j, int k, GuiCustomScroll guiCustomScroll) {} + public void mouseClicked(int i, int j, int k) { + super.mouseClicked(i, j, k); + if (k == 0 && scrollTags != null) + scrollTags.mouseClicked(i, j, k); + } - public void save() { - NBTTagCompound tagCompound = new NBTTagCompound(); - NBTTagList tagList = new NBTTagList(); - for (String string : this.tagNames) { - tagList.appendTag(new NBTTagString(string)); - } - tagCompound.setTag("TagNames",tagList); + @Override + public void setSelected(String selected) { + scrollTags.setSelected(selected); + } + + @Override + public void customScrollClicked(int i, int j, int k, GuiCustomScroll guiCustomScroll) { + } + + public void save() { + NBTTagCompound tagCompound = new NBTTagCompound(); + NBTTagList tagList = new NBTTagList(); + for (String string : this.tagNames) { + tagList.appendTag(new NBTTagString(string)); + } + tagCompound.setTag("TagNames", tagList); PacketClient.sendClient(new TagSetPacket(tagCompound)); - } + } - public void keyTyped(char c, int i) - { - super.keyTyped(c, i); - if(getTextField(4) != null){ - if(search.equals(getTextField(4).getText())) - return; - search = getTextField(4).getText().toLowerCase(); - scrollTags.setList(getSearchList()); - } - } + public void keyTyped(char c, int i) { + super.keyTyped(c, i); + if (getTextField(4) != null) { + if (search.equals(getTextField(4).getText())) + return; + search = getTextField(4).getText().toLowerCase(); + scrollTags.setList(getSearchList()); + } + } - private List getSearchList(){ - if(search.isEmpty()){ - return new ArrayList(allTags); - } - List list = new ArrayList(); - for(String name : this.allTags){ - if(name.toLowerCase().contains(search)) - list.add(name); - } - return list; - } + private List getSearchList() { + if (search.isEmpty()) { + return new ArrayList(allTags); + } + List list = new ArrayList(); + for (String name : this.allTags) { + if (name.toLowerCase().contains(search)) + list.add(name); + } + return list; + } } diff --git a/src/main/java/noppes/npcs/client/gui/custom/GuiCustom.java b/src/main/java/noppes/npcs/client/gui/custom/GuiCustom.java index c187118aa..de8304c75 100644 --- a/src/main/java/noppes/npcs/client/gui/custom/GuiCustom.java +++ b/src/main/java/noppes/npcs/client/gui/custom/GuiCustom.java @@ -90,16 +90,16 @@ public class GuiCustom extends GuiScreen implements ICustomScrollListener, IGuiD super.initGui(); this.mc.thePlayer.openContainer = this.inventorySlots; if (this.gui != null) { - guiLeft = (this.width - this.xSize)/2; - guiTop = (this.height - this.ySize)/2; + guiLeft = (this.width - this.xSize) / 2; + guiTop = (this.height - this.ySize) / 2; this.components.clear(); this.clickListeners.clear(); this.keyListeners.clear(); this.dataHolders.clear(); Iterator var1 = this.gui.getComponents().iterator(); - while(var1.hasNext()) { - ICustomGuiComponent c = (ICustomGuiComponent)var1.next(); + while (var1.hasNext()) { + ICustomGuiComponent c = (ICustomGuiComponent) var1.next(); this.addComponent(c); } } @@ -111,15 +111,14 @@ public class GuiCustom extends GuiScreen implements ICustomScrollListener, IGuiD Iterator var1 = this.dataHolders.iterator(); - while(var1.hasNext()) { - IDataHolder component = (IDataHolder)var1.next(); + while (var1.hasNext()) { + IDataHolder component = (IDataHolder) var1.next(); if (component instanceof GuiTextField) { - ((GuiTextField)component).updateCursorCounter(); + ((GuiTextField) component).updateCursorCounter(); } } - if (!this.mc.thePlayer.isEntityAlive() || this.mc.thePlayer.isDead) - { + if (!this.mc.thePlayer.isEntityAlive() || this.mc.thePlayer.isDead) { this.mc.thePlayer.closeScreen(); } } @@ -133,12 +132,12 @@ public class GuiCustom extends GuiScreen implements ICustomScrollListener, IGuiD Iterator var4 = this.components.values().iterator(); - while(var4.hasNext()) { + while (var4.hasNext()) { GL11.glEnable(GL11.GL_BLEND); OpenGlHelper.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0); GL11.glDisable(GL11.GL_ALPHA_TEST); - IGuiComponent component = (IGuiComponent)var4.next(); + IGuiComponent component = (IGuiComponent) var4.next(); component.onRender(this.mc, mouseX, mouseY, Mouse.getDWheel(), partialTicks); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); @@ -153,8 +152,7 @@ public class GuiCustom extends GuiScreen implements ICustomScrollListener, IGuiD drawScreenSuper(mouseX, mouseY, partialTicks); } - public void drawScreenSuper(int mouseX, int mouseY, float partialTicks) - { + public void drawScreenSuper(int mouseX, int mouseY, float partialTicks) { //this.drawDefaultBackground(); int k = this.guiLeft; int l = this.guiTop; @@ -166,23 +164,21 @@ public class GuiCustom extends GuiScreen implements ICustomScrollListener, IGuiD super.drawScreen(mouseX, mouseY, partialTicks); RenderHelper.enableGUIStandardItemLighting(); GL11.glPushMatrix(); - GL11.glTranslatef((float)k, (float)l, 0.0F); + GL11.glTranslatef((float) k, (float) l, 0.0F); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GL11.glEnable(GL12.GL_RESCALE_NORMAL); this.theSlot = null; short short1 = 240; short short2 = 240; - OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float)short1 / 1.0F, (float)short2 / 1.0F); + OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float) short1 / 1.0F, (float) short2 / 1.0F); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); int k1; - for (int i1 = 0; i1 < this.inventorySlots.inventorySlots.size(); ++i1) - { - Slot slot = (Slot)this.inventorySlots.inventorySlots.get(i1); + for (int i1 = 0; i1 < this.inventorySlots.inventorySlots.size(); ++i1) { + Slot slot = (Slot) this.inventorySlots.inventorySlots.get(i1); this.drawSlot(slot); - if (this.isMouseOverSlot(slot, mouseX, mouseY) && slot.func_111238_b()) - { + if (this.isMouseOverSlot(slot, mouseX, mouseY) && slot.func_111238_b()) { this.theSlot = slot; GL11.glDisable(GL11.GL_LIGHTING); GL11.glDisable(GL11.GL_DEPTH_TEST); @@ -204,24 +200,19 @@ public class GuiCustom extends GuiScreen implements ICustomScrollListener, IGuiD InventoryPlayer inventoryplayer = this.mc.thePlayer.inventory; ItemStack itemstack = this.draggedStack == null ? inventoryplayer.getItemStack() : this.draggedStack; - if (itemstack != null) - { + if (itemstack != null) { byte b0 = 8; k1 = this.draggedStack == null ? 8 : 16; String s = null; - if (this.draggedStack != null && this.isRightMouseClick) - { + if (this.draggedStack != null && this.isRightMouseClick) { itemstack = itemstack.copy(); - itemstack.stackSize = MathHelper.ceiling_float_int((float)itemstack.stackSize / 2.0F); - } - else if (this.field_147007_t && this.field_147008_s.size() > 1) - { + itemstack.stackSize = MathHelper.ceiling_float_int((float) itemstack.stackSize / 2.0F); + } else if (this.field_147007_t && this.field_147008_s.size() > 1) { itemstack = itemstack.copy(); itemstack.stackSize = this.field_146996_I; - if (itemstack.stackSize == 0) - { + if (itemstack.stackSize == 0) { s = "" + EnumChatFormatting.YELLOW + "0"; } } @@ -229,27 +220,24 @@ public class GuiCustom extends GuiScreen implements ICustomScrollListener, IGuiD this.drawItemStack(itemstack, mouseX - k - b0, mouseY - l - k1, s); } - if (this.returningStack != null) - { - float f1 = (float)(Minecraft.getSystemTime() - this.returningStackTime) / 100.0F; + if (this.returningStack != null) { + float f1 = (float) (Minecraft.getSystemTime() - this.returningStackTime) / 100.0F; - if (f1 >= 1.0F) - { + if (f1 >= 1.0F) { f1 = 1.0F; this.returningStack = null; } k1 = this.returningStackDestSlot.xDisplayPosition - this.field_147011_y; int j2 = this.returningStackDestSlot.yDisplayPosition - this.field_147010_z; - int l1 = this.field_147011_y + (int)((float)k1 * f1); - int i2 = this.field_147010_z + (int)((float)j2 * f1); - this.drawItemStack(this.returningStack, l1, i2, (String)null); + int l1 = this.field_147011_y + (int) ((float) k1 * f1); + int i2 = this.field_147010_z + (int) ((float) j2 * f1); + this.drawItemStack(this.returningStack, l1, i2, (String) null); } GL11.glPopMatrix(); - if (inventoryplayer.getItemStack() == null && this.theSlot != null && this.theSlot.getHasStack()) - { + if (inventoryplayer.getItemStack() == null && this.theSlot != null && this.theSlot.getHasStack()) { ItemStack itemstack1 = this.theSlot.getStack(); this.renderToolTip(itemstack1, mouseX, mouseY); } @@ -259,8 +247,7 @@ public class GuiCustom extends GuiScreen implements ICustomScrollListener, IGuiD RenderHelper.enableStandardItemLighting(); } - private void drawItemStack(ItemStack p_146982_1_, int p_146982_2_, int p_146982_3_, String p_146982_4_) - { + private void drawItemStack(ItemStack p_146982_1_, int p_146982_2_, int p_146982_3_, String p_146982_4_) { GL11.glTranslatef(0.0F, 0.0F, 32.0F); this.zLevel = 200.0F; itemRender.zLevel = 200.0F; @@ -273,13 +260,11 @@ public class GuiCustom extends GuiScreen implements ICustomScrollListener, IGuiD itemRender.zLevel = 0.0F; } - private boolean isMouseOverSlot(Slot slot, int posX, int posY) - { + private boolean isMouseOverSlot(Slot slot, int posX, int posY) { return this.isPointInRegion(slot.xDisplayPosition, slot.yDisplayPosition, 16, 16, posX, posY); } - protected boolean isPointInRegion(int slotDisplayX, int slotDisplayY, int slotSizeX, int slotSizeY, int posX, int posY) - { + protected boolean isPointInRegion(int slotDisplayX, int slotDisplayY, int slotSizeX, int slotSizeY, int posX, int posY) { int k1 = this.guiLeft; int l1 = this.guiTop; posX -= k1; @@ -287,8 +272,7 @@ public class GuiCustom extends GuiScreen implements ICustomScrollListener, IGuiD return posX >= slotDisplayX - 1 && posX < slotDisplayX + slotSizeX + 1 && posY >= slotDisplayY - 1 && posY < slotDisplayY + slotSizeY + 1; } - private void drawSlot(Slot p_146977_1_) - { + private void drawSlot(Slot p_146977_1_) { int i = p_146977_1_.xDisplayPosition; int j = p_146977_1_.yDisplayPosition; ItemStack itemstack = p_146977_1_.getStack(); @@ -297,38 +281,29 @@ public class GuiCustom extends GuiScreen implements ICustomScrollListener, IGuiD ItemStack itemstack1 = this.mc.thePlayer.inventory.getItemStack(); String s = null; - if (p_146977_1_ == this.clickedSlot && this.draggedStack != null && this.isRightMouseClick && itemstack != null) - { + if (p_146977_1_ == this.clickedSlot && this.draggedStack != null && this.isRightMouseClick && itemstack != null) { itemstack = itemstack.copy(); itemstack.stackSize /= 2; - } - else if (this.field_147007_t && this.field_147008_s.contains(p_146977_1_) && itemstack1 != null) - { - if (this.field_147008_s.size() == 1) - { + } else if (this.field_147007_t && this.field_147008_s.contains(p_146977_1_) && itemstack1 != null) { + if (this.field_147008_s.size() == 1) { return; } - if (Container.func_94527_a(p_146977_1_, itemstack1, true) && this.inventorySlots.canDragIntoSlot(p_146977_1_)) - { + if (Container.func_94527_a(p_146977_1_, itemstack1, true) && this.inventorySlots.canDragIntoSlot(p_146977_1_)) { itemstack = itemstack1.copy(); flag = true; Container.func_94525_a(this.field_147008_s, this.field_146987_F, itemstack, p_146977_1_.getStack() == null ? 0 : p_146977_1_.getStack().stackSize); - if (itemstack.stackSize > itemstack.getMaxStackSize()) - { + if (itemstack.stackSize > itemstack.getMaxStackSize()) { s = EnumChatFormatting.YELLOW + "" + itemstack.getMaxStackSize(); itemstack.stackSize = itemstack.getMaxStackSize(); } - if (itemstack.stackSize > p_146977_1_.getSlotStackLimit()) - { + if (itemstack.stackSize > p_146977_1_.getSlotStackLimit()) { s = EnumChatFormatting.YELLOW + "" + p_146977_1_.getSlotStackLimit(); itemstack.stackSize = p_146977_1_.getSlotStackLimit(); } - } - else - { + } else { this.field_147008_s.remove(p_146977_1_); this.func_146980_g(); } @@ -337,12 +312,10 @@ public class GuiCustom extends GuiScreen implements ICustomScrollListener, IGuiD this.zLevel = 100.0F; itemRender.zLevel = 100.0F; - if (itemstack == null) - { + if (itemstack == null) { IIcon iicon = p_146977_1_.getBackgroundIconIndex(); - if (iicon != null) - { + if (iicon != null) { GL11.glDisable(GL11.GL_LIGHTING); GL11.glEnable(GL11.GL_BLEND); // Forge: Blending needs to be enabled for this. this.mc.getTextureManager().bindTexture(TextureMap.locationItemsTexture); @@ -353,10 +326,8 @@ public class GuiCustom extends GuiScreen implements ICustomScrollListener, IGuiD } } - if (!flag1) - { - if (flag) - { + if (!flag1) { + if (flag) { drawRect(i, j, i + 16, j + 16, -2130706433); } @@ -369,30 +340,25 @@ public class GuiCustom extends GuiScreen implements ICustomScrollListener, IGuiD this.zLevel = 0.0F; } - private void func_146980_g() - { + private void func_146980_g() { ItemStack itemstack = this.mc.thePlayer.inventory.getItemStack(); - if (itemstack != null && this.field_147007_t) - { + if (itemstack != null && this.field_147007_t) { this.field_146996_I = itemstack.stackSize; ItemStack itemstack1; int i; - for (Iterator iterator = this.field_147008_s.iterator(); iterator.hasNext(); this.field_146996_I -= itemstack1.stackSize - i) - { - Slot slot = (Slot)iterator.next(); + for (Iterator iterator = this.field_147008_s.iterator(); iterator.hasNext(); this.field_146996_I -= itemstack1.stackSize - i) { + Slot slot = (Slot) iterator.next(); itemstack1 = itemstack.copy(); i = slot.getStack() == null ? 0 : slot.getStack().stackSize; Container.func_94525_a(this.field_147008_s, this.field_146987_F, itemstack1, i); - if (itemstack1.stackSize > itemstack1.getMaxStackSize()) - { + if (itemstack1.stackSize > itemstack1.getMaxStackSize()) { itemstack1.stackSize = itemstack1.getMaxStackSize(); } - if (itemstack1.stackSize > slot.getSlotStackLimit()) - { + if (itemstack1.stackSize > slot.getSlotStackLimit()) { itemstack1.stackSize = slot.getSlotStackLimit(); } } @@ -408,26 +374,26 @@ public class GuiCustom extends GuiScreen implements ICustomScrollListener, IGuiD } private void addComponent(ICustomGuiComponent component) { - ScriptGuiComponent c = (ScriptGuiComponent)component; - switch(c.getType()) { + ScriptGuiComponent c = (ScriptGuiComponent) component; + switch (c.getType()) { case 0: - CustomGuiButton button = CustomGuiButton.fromComponent((ScriptGuiButton)component); + CustomGuiButton button = CustomGuiButton.fromComponent((ScriptGuiButton) component); button.setParent(this); this.components.put(button.getID(), button); this.addClickListener(button); break; case 1: - CustomGuiLabel lbl = CustomGuiLabel.fromComponent((ScriptGuiLabel)component); + CustomGuiLabel lbl = CustomGuiLabel.fromComponent((ScriptGuiLabel) component); lbl.setParent(this); this.components.put(lbl.getID(), lbl); break; case 2: - CustomGuiTexturedRect rect = CustomGuiTexturedRect.fromComponent((ScriptGuiTexturedRect)component); + CustomGuiTexturedRect rect = CustomGuiTexturedRect.fromComponent((ScriptGuiTexturedRect) component); rect.setParent(this); this.components.put(rect.getID(), rect); break; case 3: - CustomGuiTextField textField = CustomGuiTextField.fromComponent((ScriptGuiTextField)component); + CustomGuiTextField textField = CustomGuiTextField.fromComponent((ScriptGuiTextField) component); textField.setParent(this); this.components.put(textField.getID(), textField); this.addDataHolder(textField); @@ -435,8 +401,8 @@ public class GuiCustom extends GuiScreen implements ICustomScrollListener, IGuiD this.addKeyListener(textField); break; case 4: - CustomGuiScrollComponent scroll = new CustomGuiScrollComponent(this.mc, this, component.getID(), ((ScriptGuiScroll)component).isMultiSelect()); - scroll.fromComponent((ScriptGuiScroll)component); + CustomGuiScrollComponent scroll = new CustomGuiScrollComponent(this.mc, this, component.getID(), ((ScriptGuiScroll) component).isMultiSelect()); + scroll.fromComponent((ScriptGuiScroll) component); scroll.setParent(this); this.components.put(scroll.getID(), scroll); this.addDataHolder(scroll); @@ -444,7 +410,7 @@ public class GuiCustom extends GuiScreen implements ICustomScrollListener, IGuiD break; case 6: CustomGuiLine line = CustomGuiLine.fromComponent((ScriptGuiLine) component); - this.components.put(line.getID(),line); + this.components.put(line.getID(), line); break; } @@ -460,10 +426,11 @@ public class GuiCustom extends GuiScreen implements ICustomScrollListener, IGuiD } public String prevScrollClicked = null; + public void customScrollClicked(int i, int j, int k, GuiCustomScroll scroll) { - PacketClient.sendClient(new CustomScrollClickPacket(this.updateGui().toNBT(), scroll.id, scroll.selected, this.getScrollSelection((CustomGuiScrollComponent)scroll), false)); - if(Integer.toString(scroll.selected).equals(prevScrollClicked)){ - PacketClient.sendClient(new CustomScrollClickPacket(this.updateGui().toNBT(), scroll.id, scroll.selected, this.getScrollSelection((CustomGuiScrollComponent)scroll), true)); + PacketClient.sendClient(new CustomScrollClickPacket(this.updateGui().toNBT(), scroll.id, scroll.selected, this.getScrollSelection((CustomGuiScrollComponent) scroll), false)); + if (Integer.toString(scroll.selected).equals(prevScrollClicked)) { + PacketClient.sendClient(new CustomScrollClickPacket(this.updateGui().toNBT(), scroll.id, scroll.selected, this.getScrollSelection((CustomGuiScrollComponent) scroll), true)); } prevScrollClicked = Integer.toString(scroll.selected); } @@ -473,21 +440,20 @@ public class GuiCustom extends GuiScreen implements ICustomScrollListener, IGuiD PacketClient.sendClient(new CustomGuiClosePacket(this.updateGui().toNBT())); } - if (this.mc.thePlayer != null) - { + if (this.mc.thePlayer != null) { this.inventorySlots.onContainerClosed(this.mc.thePlayer); } } - public void onTextFieldUnfocused(CustomGuiTextField textField){ + public void onTextFieldUnfocused(CustomGuiTextField textField) { PacketClient.sendClient(new CustomGuiUnfocusedPacket(textField.getID(), this.updateGui().toNBT())); } public ScriptGui updateGui() { Iterator var1 = this.dataHolders.iterator(); - while(var1.hasNext()) { - IDataHolder component = (IDataHolder)var1.next(); + while (var1.hasNext()) { + IDataHolder component = (IDataHolder) var1.next(); this.gui.updateComponent(component.toComponent()); } @@ -499,8 +465,8 @@ public class GuiCustom extends GuiScreen implements ICustomScrollListener, IGuiD if (scroll.multiSelect) { Iterator var3 = scroll.getSelectedList().iterator(); - while(var3.hasNext()) { - String s = (String)var3.next(); + while (var3.hasNext()) { + String s = (String) var3.next(); list.appendTag(new NBTTagString(s)); } } else { @@ -513,28 +479,23 @@ public class GuiCustom extends GuiScreen implements ICustomScrollListener, IGuiD } protected void keyTyped(char typedChar, int keyCode) { - if (keyCode == 1 && closeOnEsc) - { + if (keyCode == 1 && closeOnEsc) { this.mc.thePlayer.closeScreen(); } this.checkHotbarKeys(keyCode); - if (this.theSlot != null && this.theSlot.getHasStack()) - { - if (keyCode == this.mc.gameSettings.keyBindPickBlock.getKeyCode()) - { + if (this.theSlot != null && this.theSlot.getHasStack()) { + if (keyCode == this.mc.gameSettings.keyBindPickBlock.getKeyCode()) { this.handleMouseClick(this.theSlot, this.theSlot.slotNumber, 0, 3); - } - else if (keyCode == this.mc.gameSettings.keyBindDrop.getKeyCode()) - { + } else if (keyCode == this.mc.gameSettings.keyBindDrop.getKeyCode()) { this.handleMouseClick(this.theSlot, this.theSlot.slotNumber, isCtrlKeyDown() ? 1 : 0, 4); } } Iterator var3 = this.keyListeners.iterator(); - while(var3.hasNext()) { + while (var3.hasNext()) { CustomGuiTextField listener = (CustomGuiTextField) var3.next(); listener.keyTyped(typedChar, keyCode); } @@ -557,12 +518,10 @@ public class GuiCustom extends GuiScreen implements ICustomScrollListener, IGuiD boolean flag1 = true; int k1 = -1; - for (int i = 0; i < this.inventorySlots.inventorySlots.size(); ++i) - { - Slot invSlot = (Slot)this.inventorySlots.inventorySlots.get(i); + for (int i = 0; i < this.inventorySlots.inventorySlots.size(); ++i) { + Slot invSlot = (Slot) this.inventorySlots.inventorySlots.get(i); - if (invSlot.equals(slot)) - { + if (invSlot.equals(slot)) { flag1 = false; } } @@ -629,8 +588,8 @@ public class GuiCustom extends GuiScreen implements ICustomScrollListener, IGuiD Iterator var4 = this.clickListeners.iterator(); - while(var4.hasNext()) { - IClickListener listener = (IClickListener)var4.next(); + while (var4.hasNext()) { + IClickListener listener = (IClickListener) var4.next(); listener.mouseClicked(this, mouseX, mouseY, mouseButton); } @@ -654,8 +613,8 @@ public class GuiCustom extends GuiScreen implements ICustomScrollListener, IGuiD public void setGuiData(NBTTagCompound compound) { Minecraft mc = Minecraft.getMinecraft(); - ScriptGui gui = (ScriptGui)(new ScriptGui()).fromNBT(compound); - ((ContainerCustomGui)this.inventorySlots).setGui(gui, mc.thePlayer); + ScriptGui gui = (ScriptGui) (new ScriptGui()).fromNBT(compound); + ((ContainerCustomGui) this.inventorySlots).setGui(gui, mc.thePlayer); this.gui = gui; this.xSize = gui.getWidth(); this.ySize = gui.getHeight(); @@ -670,14 +629,10 @@ public class GuiCustom extends GuiScreen implements ICustomScrollListener, IGuiD /** * This function is what controls the hotbar shortcut check when you press a number key when hovering a stack. */ - protected boolean checkHotbarKeys(int p_146983_1_) - { - if (this.mc.thePlayer.inventory.getItemStack() == null && this.theSlot != null) - { - for (int j = 0; j < 9; ++j) - { - if (p_146983_1_ == this.mc.gameSettings.keyBindsHotbar[j].getKeyCode()) - { + protected boolean checkHotbarKeys(int p_146983_1_) { + if (this.mc.thePlayer.inventory.getItemStack() == null && this.theSlot != null) { + for (int j = 0; j < 9; ++j) { + if (p_146983_1_ == this.mc.gameSettings.keyBindsHotbar[j].getKeyCode()) { this.handleMouseClick(this.theSlot, this.theSlot.slotNumber, j, 2); return true; } @@ -687,18 +642,15 @@ public class GuiCustom extends GuiScreen implements ICustomScrollListener, IGuiD return false; } - protected void handleMouseClick(Slot slot, int index, int p_146984_3_, int p_146984_4_) - { - if (slot != null) - { + protected void handleMouseClick(Slot slot, int index, int p_146984_3_, int p_146984_4_) { + if (slot != null) { index = slot.slotNumber; } this.mc.playerController.windowClick(this.inventorySlots.windowId, index, p_146984_3_, p_146984_4_, this.mc.thePlayer); } - protected void mouseMovedOrUp(int p_146286_1_, int p_146286_2_, int p_146286_3_) - { + protected void mouseMovedOrUp(int p_146286_1_, int p_146286_2_, int p_146286_3_) { super.mouseMovedOrUp(p_146286_1_, p_146286_2_, p_146286_3_); //Forge, Call parent to release buttons Slot slot = this.getSlotAtPosition(p_146286_1_, p_146286_2_); int l = this.guiLeft; @@ -706,96 +658,74 @@ public class GuiCustom extends GuiScreen implements ICustomScrollListener, IGuiD boolean flag = p_146286_1_ < l || p_146286_2_ < i1 || p_146286_1_ >= l + this.xSize || p_146286_2_ >= i1 + this.ySize; int j1 = -1; - if (slot != null) - { + if (slot != null) { j1 = slot.slotNumber; } - if (flag) - { + if (flag) { j1 = -999; } Slot slot1; Iterator iterator; - if (this.field_146993_M && slot != null && p_146286_3_ == 0 && this.inventorySlots.func_94530_a((ItemStack)null, slot)) - { - if (isShiftKeyDown()) - { - if (slot != null && slot.inventory != null && this.field_146994_N != null) - { + if (this.field_146993_M && slot != null && p_146286_3_ == 0 && this.inventorySlots.func_94530_a((ItemStack) null, slot)) { + if (isShiftKeyDown()) { + if (slot != null && slot.inventory != null && this.field_146994_N != null) { iterator = this.inventorySlots.inventorySlots.iterator(); - while (iterator.hasNext()) - { - slot1 = (Slot)iterator.next(); + while (iterator.hasNext()) { + slot1 = (Slot) iterator.next(); - if (slot1 != null && slot1.canTakeStack(this.mc.thePlayer) && slot1.getHasStack() && slot1.inventory == slot.inventory && Container.func_94527_a(slot1, this.field_146994_N, true)) - { + if (slot1 != null && slot1.canTakeStack(this.mc.thePlayer) && slot1.getHasStack() && slot1.inventory == slot.inventory && Container.func_94527_a(slot1, this.field_146994_N, true)) { this.handleMouseClick(slot1, slot1.slotNumber, p_146286_3_, 1); } } } - } - else - { + } else { this.handleMouseClick(slot, j1, p_146286_3_, 6); } this.field_146993_M = false; this.field_146997_J = 0L; - } - else - { - if (this.field_147007_t && this.field_146988_G != p_146286_3_) - { + } else { + if (this.field_147007_t && this.field_146988_G != p_146286_3_) { this.field_147007_t = false; this.field_147008_s.clear(); this.field_146995_H = true; return; } - if (this.field_146995_H) - { + if (this.field_146995_H) { this.field_146995_H = false; return; } boolean flag1; - if (this.clickedSlot != null && this.mc.gameSettings.touchscreen) - { - if (p_146286_3_ == 0 || p_146286_3_ == 1) - { - if (this.draggedStack == null && slot != this.clickedSlot) - { + if (this.clickedSlot != null && this.mc.gameSettings.touchscreen) { + if (p_146286_3_ == 0 || p_146286_3_ == 1) { + if (this.draggedStack == null && slot != this.clickedSlot) { this.draggedStack = this.clickedSlot.getStack(); } flag1 = Container.func_94527_a(slot, this.draggedStack, false); - if (j1 != -1 && this.draggedStack != null && flag1) - { + if (j1 != -1 && this.draggedStack != null && flag1) { this.handleMouseClick(this.clickedSlot, this.clickedSlot.slotNumber, p_146286_3_, 0); this.handleMouseClick(slot, j1, 0, 0); - if (this.mc.thePlayer.inventory.getItemStack() != null) - { + if (this.mc.thePlayer.inventory.getItemStack() != null) { this.handleMouseClick(this.clickedSlot, this.clickedSlot.slotNumber, p_146286_3_, 0); this.field_147011_y = p_146286_1_ - l; this.field_147010_z = p_146286_2_ - i1; this.returningStackDestSlot = this.clickedSlot; this.returningStack = this.draggedStack; this.returningStackTime = Minecraft.getSystemTime(); - } - else - { + } else { this.returningStack = null; } - } - else if (this.draggedStack != null) - { + } else if (this.draggedStack != null) { this.field_147011_y = p_146286_1_ - l; this.field_147010_z = p_146286_2_ - i1; this.returningStackDestSlot = this.clickedSlot; @@ -806,32 +736,23 @@ public class GuiCustom extends GuiScreen implements ICustomScrollListener, IGuiD this.draggedStack = null; this.clickedSlot = null; } - } - else if (this.field_147007_t && !this.field_147008_s.isEmpty()) - { - this.handleMouseClick((Slot)null, -999, Container.func_94534_d(0, this.field_146987_F), 5); + } else if (this.field_147007_t && !this.field_147008_s.isEmpty()) { + this.handleMouseClick((Slot) null, -999, Container.func_94534_d(0, this.field_146987_F), 5); iterator = this.field_147008_s.iterator(); - while (iterator.hasNext()) - { - slot1 = (Slot)iterator.next(); + while (iterator.hasNext()) { + slot1 = (Slot) iterator.next(); this.handleMouseClick(slot1, slot1.slotNumber, Container.func_94534_d(1, this.field_146987_F), 5); } - this.handleMouseClick((Slot)null, -999, Container.func_94534_d(2, this.field_146987_F), 5); - } - else if (this.mc.thePlayer.inventory.getItemStack() != null) - { - if (p_146286_3_ == this.mc.gameSettings.keyBindPickBlock.getKeyCode() + 100) - { + this.handleMouseClick((Slot) null, -999, Container.func_94534_d(2, this.field_146987_F), 5); + } else if (this.mc.thePlayer.inventory.getItemStack() != null) { + if (p_146286_3_ == this.mc.gameSettings.keyBindPickBlock.getKeyCode() + 100) { this.handleMouseClick(slot, j1, p_146286_3_, 3); - } - else - { + } else { flag1 = j1 != -999 && (Keyboard.isKeyDown(42) || Keyboard.isKeyDown(54)); - if (flag1) - { + if (flag1) { this.field_146994_N = slot != null && slot.getHasStack() ? slot.getStack() : null; } @@ -840,22 +761,18 @@ public class GuiCustom extends GuiScreen implements ICustomScrollListener, IGuiD } } - if (this.mc.thePlayer.inventory.getItemStack() == null) - { + if (this.mc.thePlayer.inventory.getItemStack() == null) { this.field_146997_J = 0L; } this.field_147007_t = false; } - private Slot getSlotAtPosition(int posX, int posY) - { - for (int k = 0; k < this.inventorySlots.inventorySlots.size(); ++k) - { - Slot slot = (Slot)this.inventorySlots.inventorySlots.get(k); + private Slot getSlotAtPosition(int posX, int posY) { + for (int k = 0; k < this.inventorySlots.inventorySlots.size(); ++k) { + Slot slot = (Slot) this.inventorySlots.inventorySlots.get(k); - if (this.isMouseOverSlot(slot, posX, posY)) - { + if (this.isMouseOverSlot(slot, posX, posY)) { return slot; } } @@ -863,47 +780,34 @@ public class GuiCustom extends GuiScreen implements ICustomScrollListener, IGuiD return null; } - protected void mouseClickMove(int p_146273_1_, int p_146273_2_, int p_146273_3_, long p_146273_4_) - { + protected void mouseClickMove(int p_146273_1_, int p_146273_2_, int p_146273_3_, long p_146273_4_) { Slot slot = this.getSlotAtPosition(p_146273_1_, p_146273_2_); ItemStack itemstack = this.mc.thePlayer.inventory.getItemStack(); - if (this.clickedSlot != null && this.mc.gameSettings.touchscreen) - { - if (p_146273_3_ == 0 || p_146273_3_ == 1) - { - if (this.draggedStack == null) - { - if (slot != this.clickedSlot) - { + if (this.clickedSlot != null && this.mc.gameSettings.touchscreen) { + if (p_146273_3_ == 0 || p_146273_3_ == 1) { + if (this.draggedStack == null) { + if (slot != this.clickedSlot) { this.draggedStack = this.clickedSlot.getStack().copy(); } - } - else if (this.draggedStack.stackSize > 1 && slot != null && Container.func_94527_a(slot, this.draggedStack, false)) - { + } else if (this.draggedStack.stackSize > 1 && slot != null && Container.func_94527_a(slot, this.draggedStack, false)) { long i1 = Minecraft.getSystemTime(); - if (this.field_146985_D == slot) - { - if (i1 - this.field_146986_E > 500L) - { + if (this.field_146985_D == slot) { + if (i1 - this.field_146986_E > 500L) { this.handleMouseClick(this.clickedSlot, this.clickedSlot.slotNumber, 0, 0); this.handleMouseClick(slot, slot.slotNumber, 1, 0); this.handleMouseClick(this.clickedSlot, this.clickedSlot.slotNumber, 0, 0); this.field_146986_E = i1 + 750L; --this.draggedStack.stackSize; } - } - else - { + } else { this.field_146985_D = slot; this.field_146986_E = i1; } } } - } - else if (this.field_147007_t && slot != null && itemstack != null && itemstack.stackSize > this.field_147008_s.size() && Container.func_94527_a(slot, itemstack, true) && slot.isItemValid(itemstack) && this.inventorySlots.canDragIntoSlot(slot)) - { + } else if (this.field_147007_t && slot != null && itemstack != null && itemstack.stackSize > this.field_147008_s.size() && Container.func_94527_a(slot, itemstack, true) && slot.isItemValid(itemstack) && this.inventorySlots.canDragIntoSlot(slot)) { this.field_147008_s.add(slot); this.func_146980_g(); } diff --git a/src/main/java/noppes/npcs/client/gui/custom/components/CustomGuiButton.java b/src/main/java/noppes/npcs/client/gui/custom/components/CustomGuiButton.java index d9832b8ef..f09481498 100644 --- a/src/main/java/noppes/npcs/client/gui/custom/components/CustomGuiButton.java +++ b/src/main/java/noppes/npcs/client/gui/custom/components/CustomGuiButton.java @@ -89,67 +89,67 @@ public class CustomGuiButton extends GuiButton implements IClickListener { FontRenderer fontRenderer = mc.fontRenderer; float red = (color >> 16 & 255) / 255f; - float green = (color >> 8 & 255) / 255f; + float green = (color >> 8 & 255) / 255f; float blue = (color & 255) / 255f; - GL11.glColor4f(red,green,blue,this.alpha); + GL11.glColor4f(red, green, blue, this.alpha); if (this.imageData != null && this.imageData.imageLoaded()) { int totalWidth = this.imageData.getTotalWidth(); int totalHeight = this.imageData.getTotalHeight(); - float u1 = (float)textureX/(float)totalWidth; - float u2 = u1 + (float)width/(float)totalWidth; - float v1 = (float)textureY/(float)totalHeight; - float v2 = v1 + (float)height/(float)totalHeight; + float u1 = (float) textureX / (float) totalWidth; + float u2 = u1 + (float) width / (float) totalWidth; + float v1 = (float) textureY / (float) totalHeight; + float v2 = v1 + (float) height / (float) totalHeight; if (this.enabled) { if (this.field_146123_n) { - v1 = (float)(textureY + 2 * this.height)/(float)totalHeight; + v1 = (float) (textureY + 2 * this.height) / (float) totalHeight; } else { - v1 = (float)(textureY + this.height)/(float)totalHeight; + v1 = (float) (textureY + this.height) / (float) totalHeight; } - v2 = v1 + (float)height/(float)totalHeight; + v2 = v1 + (float) height / (float) totalHeight; } GL11.glPushMatrix(); - GL11.glTranslatef(GuiCustom.guiLeft + this.xPosition - u1 * totalWidth * this.scale, GuiCustom.guiTop + this.yPosition - v1 * totalHeight * this.scale,(float)this.id); - GL11.glScalef(this.scale,this.scale,1.0F); + GL11.glTranslatef(GuiCustom.guiLeft + this.xPosition - u1 * totalWidth * this.scale, GuiCustom.guiTop + this.yPosition - v1 * totalHeight * this.scale, (float) this.id); + GL11.glScalef(this.scale, this.scale, 1.0F); - this.imageData.bindTexture(); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - Tessellator tessellator = Tessellator.instance; - tessellator.startDrawingQuads(); - tessellator.setColorOpaque_F(1, 1, 1); - tessellator.setColorRGBA_F(red, green, blue, alpha); - tessellator.addVertexWithUV(u2 * totalWidth, v2 * totalHeight, 0, u2, v2); - tessellator.addVertexWithUV(u2 * totalWidth, v1 * totalHeight, 0, u2, v1); - tessellator.addVertexWithUV(u1 * totalWidth, v1 * totalHeight, 0, u1, v1); - tessellator.addVertexWithUV(u1 * totalWidth, v2 * totalHeight, 0, u1, v2); - tessellator.draw(); - GL11.glTranslated(0.0D, 0.0D, 0.1D); - this.drawCenteredString(fontRenderer, this.label, this.width / 2, (this.height - 8) / 2, this.color); + this.imageData.bindTexture(); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + Tessellator tessellator = Tessellator.instance; + tessellator.startDrawingQuads(); + tessellator.setColorOpaque_F(1, 1, 1); + tessellator.setColorRGBA_F(red, green, blue, alpha); + tessellator.addVertexWithUV(u2 * totalWidth, v2 * totalHeight, 0, u2, v2); + tessellator.addVertexWithUV(u2 * totalWidth, v1 * totalHeight, 0, u2, v1); + tessellator.addVertexWithUV(u1 * totalWidth, v1 * totalHeight, 0, u1, v1); + tessellator.addVertexWithUV(u1 * totalWidth, v2 * totalHeight, 0, u1, v2); + tessellator.draw(); + GL11.glTranslated(0.0D, 0.0D, 0.1D); + this.drawCenteredString(fontRenderer, this.label, this.width / 2, (this.height - 8) / 2, this.color); GL11.glPopMatrix(); } else { GL11.glPushMatrix(); - GL11.glTranslatef(GuiCustom.guiLeft + this.xPosition, GuiCustom.guiTop + this.yPosition,(float)this.id); - GL11.glScalef(this.scale,this.scale,1.0F); + GL11.glTranslatef(GuiCustom.guiLeft + this.xPosition, GuiCustom.guiTop + this.yPosition, (float) this.id); + GL11.glScalef(this.scale, this.scale, 1.0F); - mc.getTextureManager().bindTexture(buttonTextures); - int i = this.getHoverState(this.field_146123_n); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - this.drawTexturedModalRect(0, 0, 0, 46 + i * 20, this.width / 2, this.height); - this.drawTexturedModalRect(this.width / 2, 0, 200 - this.width / 2, 46 + i * 20, this.width / 2, this.height); - this.mouseDragged(mc, mouseX, mouseY); - int j = 14737632; - if (this.packedFGColour != 0) { - j = this.packedFGColour; - } else if (!this.enabled) { - j = 10526880; - } else if (this.field_146123_n) { - j = 16777120; - } - GL11.glTranslated(0.0D, 0.0D, 0.1D); - this.drawCenteredString(fontRenderer, this.displayString, this.width / 2, (this.height - 8) / 2, j); + mc.getTextureManager().bindTexture(buttonTextures); + int i = this.getHoverState(this.field_146123_n); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + this.drawTexturedModalRect(0, 0, 0, 46 + i * 20, this.width / 2, this.height); + this.drawTexturedModalRect(this.width / 2, 0, 200 - this.width / 2, 46 + i * 20, this.width / 2, this.height); + this.mouseDragged(mc, mouseX, mouseY); + int j = 14737632; + if (this.packedFGColour != 0) { + j = this.packedFGColour; + } else if (!this.enabled) { + j = 10526880; + } else if (this.field_146123_n) { + j = 16777120; + } + GL11.glTranslated(0.0D, 0.0D, 0.1D); + this.drawCenteredString(fontRenderer, this.displayString, this.width / 2, (this.height - 8) / 2, j); GL11.glPopMatrix(); } diff --git a/src/main/java/noppes/npcs/client/gui/custom/components/CustomGuiLabel.java b/src/main/java/noppes/npcs/client/gui/custom/components/CustomGuiLabel.java index 58deee21f..daa1a98e0 100644 --- a/src/main/java/noppes/npcs/client/gui/custom/components/CustomGuiLabel.java +++ b/src/main/java/noppes/npcs/client/gui/custom/components/CustomGuiLabel.java @@ -61,7 +61,7 @@ public class CustomGuiLabel extends Gui implements IGuiComponent { private float posX; private float posY; - public CustomGuiLabel(int id, String fullLabel, int x, int y, int width, int height, boolean shadow){ + public CustomGuiLabel(int id, String fullLabel, int x, int y, int width, int height, boolean shadow) { this.id = id; this.fullLabel = fullLabel; this.x = x; @@ -73,20 +73,17 @@ public class CustomGuiLabel extends Gui implements IGuiComponent { locationFontTexture = new ResourceLocation("textures/font/ascii.png"); readFontTexture(); readGlyphSizes(); - for (int i = 0; i < 32; ++i) - { + for (int i = 0; i < 32; ++i) { int j = (i >> 3 & 1) * 85; int k = (i >> 2 & 1) * 170 + j; int l = (i >> 1 & 1) * 170 + j; int i1 = (i >> 0 & 1) * 170 + j; - if (i == 6) - { + if (i == 6) { k += 85; } - if (Minecraft.getMinecraft().gameSettings.anaglyph) - { + if (Minecraft.getMinecraft().gameSettings.anaglyph) { int j1 = (k * 30 + l * 59 + i1 * 11) / 100; int k1 = (k * 30 + l * 70) / 100; int l1 = (k * 30 + i1 * 70) / 100; @@ -95,8 +92,7 @@ public class CustomGuiLabel extends Gui implements IGuiComponent { i1 = l1; } - if (i >= 16) - { + if (i >= 16) { k /= 4; l /= 4; i1 /= 4; @@ -112,8 +108,8 @@ public class CustomGuiLabel extends Gui implements IGuiComponent { public void onRender(Minecraft mc, int mouseX, int mouseY, int mouseWheel, float partialTicks) { GL11.glPushMatrix(); - GL11.glTranslatef(0.0F,0.0F,(float)this.id); - this.drawLabel(mouseX,mouseY); + GL11.glTranslatef(0.0F, 0.0F, (float) this.id); + this.drawLabel(mouseX, mouseY); GL11.glPopMatrix(); } @@ -153,40 +149,34 @@ public class CustomGuiLabel extends Gui implements IGuiComponent { return component; } - public void drawLabel(int mouseX, int mouseY) - { + public void drawLabel(int mouseX, int mouseY) { GL11.glPushMatrix(); - red = (color >> 16 & 255) / 255f; - green = (color >> 8 & 255) / 255f; - blue = (color & 255) / 255f; + red = (color >> 16 & 255) / 255f; + green = (color >> 8 & 255) / 255f; + blue = (color & 255) / 255f; - GL11.glTranslatef(this.x,this.y,0.0F); - GL11.glRotated(rotation,0.0D,0.0D,1.0D); - GL11.glScalef(this.scale, this.scale, this.scale); - this.drawString(fullLabel, 0, 0, this.color, this.labelShadowEnabled, mouseX, mouseY); + GL11.glTranslatef(this.x, this.y, 0.0F); + GL11.glRotated(rotation, 0.0D, 0.0D, 1.0D); + GL11.glScalef(this.scale, this.scale, this.scale); + this.drawString(fullLabel, 0, 0, this.color, this.labelShadowEnabled, mouseX, mouseY); GL11.glPopMatrix(); } - public int drawString(String p_85187_1_, int p_85187_2_, int p_85187_3_, int p_85187_4_, boolean p_85187_5_, int mouseX, int mouseY) - { + public int drawString(String p_85187_1_, int p_85187_2_, int p_85187_3_, int p_85187_4_, boolean p_85187_5_, int mouseX, int mouseY) { this.resetStyles(); int l; - if (p_85187_5_) - { + if (p_85187_5_) { l = this.renderString(p_85187_1_, p_85187_2_ + 1, p_85187_3_ + 1, p_85187_4_, true, mouseX, mouseY); l = Math.max(l, this.renderString(p_85187_1_, p_85187_2_, p_85187_3_, p_85187_4_, false, mouseX, mouseY)); - } - else - { + } else { l = this.renderString(p_85187_1_, p_85187_2_, p_85187_3_, p_85187_4_, false, mouseX, mouseY); } return l; } - private void resetStyles() - { + private void resetStyles() { this.randomStyle = false; this.boldStyle = false; this.italicStyle = false; @@ -194,16 +184,11 @@ public class CustomGuiLabel extends Gui implements IGuiComponent { this.strikethroughStyle = false; } - private int renderString(String p_78258_1_, int p_78258_2_, int p_78258_3_, int p_78258_4_, boolean p_78258_5_, int mouseX, int mouseY) - { - if (p_78258_1_ == null) - { + private int renderString(String p_78258_1_, int p_78258_2_, int p_78258_3_, int p_78258_4_, boolean p_78258_5_, int mouseX, int mouseY) { + if (p_78258_1_ == null) { return 0; - } - else - { - if (this.bidiFlag) - { + } else { + if (this.bidiFlag) { p_78258_1_ = this.bidiReorder(p_78258_1_); } @@ -219,7 +204,7 @@ public class CustomGuiLabel extends Gui implements IGuiComponent { char c = p_78258_1_.charAt(i); boolean formatSymbol = c == '&' && i < p_78258_1_.length() - 1 - && "0123456789abcdefklmnor".indexOf(p_78258_1_.toLowerCase().charAt(i + 1)) != -1; + && "0123456789abcdefklmnor".indexOf(p_78258_1_.toLowerCase().charAt(i + 1)) != -1; if (formatSymbol) { String format = "" + c + p_78258_1_.toLowerCase().charAt(i + 1); if (!format.equals("&r")) { @@ -242,18 +227,18 @@ public class CustomGuiLabel extends Gui implements IGuiComponent { } } setColor(this.red, this.green, this.blue, this.alpha); - this.posX = (float)p_78258_2_; - this.posY = (float)p_78258_3_ + height * ClientProxy.Font.height() * 0.75F; + this.posX = (float) p_78258_2_; + this.posY = (float) p_78258_3_ + height * ClientProxy.Font.height() * 0.75F; - endX = Math.max(endX,this.posX + ClientProxy.Font.width(s.toString())); + endX = Math.max(endX, this.posX + ClientProxy.Font.width(s.toString())); endY = this.posY + ClientProxy.Font.height() * 0.75F; this.renderStringAtPos(s.toString().trim(), p_78258_5_); height++; - if (i >= p_78258_1_.length()-1 || height * ClientProxy.Font.height() * 0.75F >= this.height) { + if (i >= p_78258_1_.length() - 1 || height * ClientProxy.Font.height() * 0.75F >= this.height) { break; } - p_78258_1_ = p_78258_1_.substring(i+1); + p_78258_1_ = p_78258_1_.substring(i + 1); } float textWidth = this.scale * endX; @@ -264,64 +249,47 @@ public class CustomGuiLabel extends Gui implements IGuiComponent { this.parent.hoverText = this.hoverText; } - return (int)this.posX; + return (int) this.posX; } } - private void renderStringAtPos(String p_78255_1_, boolean p_78255_2_) - { - for (int i = 0; i < p_78255_1_.length(); ++i) - { + private void renderStringAtPos(String p_78255_1_, boolean p_78255_2_) { + for (int i = 0; i < p_78255_1_.length(); ++i) { char c0 = p_78255_1_.charAt(i); int j; int k; - if (c0 == 38 && i + 1 < p_78255_1_.length()) - { + if (c0 == 38 && i + 1 < p_78255_1_.length()) { j = "0123456789abcdefklmnor".indexOf(p_78255_1_.toLowerCase().charAt(i + 1)); - if(j < 16){ + if (j < 16) { this.randomStyle = false; this.boldStyle = false; this.strikethroughStyle = false; this.underlineStyle = false; this.italicStyle = false; - if (j < 0 || j > 15) - { + if (j < 0 || j > 15) { j = 15; } - if (p_78255_2_) - { + if (p_78255_2_) { j += 16; } k = this.colorCode[j]; - setColor((float)(k >> 16) / 255.0F, (float)(k >> 8 & 255) / 255.0F, (float)(k & 255) / 255.0F, this.alpha); - } - else if (j == 16) - { + setColor((float) (k >> 16) / 255.0F, (float) (k >> 8 & 255) / 255.0F, (float) (k & 255) / 255.0F, this.alpha); + } else if (j == 16) { this.randomStyle = true; - } - else if (j == 17) - { + } else if (j == 17) { this.boldStyle = true; - } - else if (j == 18) - { + } else if (j == 18) { this.strikethroughStyle = true; - } - else if (j == 19) - { + } else if (j == 19) { this.underlineStyle = true; - } - else if (j == 20) - { + } else if (j == 20) { this.italicStyle = true; - } - else if (j == 21) - { + } else if (j == 21) { this.randomStyle = false; this.boldStyle = false; this.strikethroughStyle = false; @@ -330,15 +298,11 @@ public class CustomGuiLabel extends Gui implements IGuiComponent { } ++i; - } - else - { + } else { j = "\u00c0\u00c1\u00c2\u00c8\u00ca\u00cb\u00cd\u00d3\u00d4\u00d5\u00da\u00df\u00e3\u00f5\u011f\u0130\u0131\u0152\u0153\u015e\u015f\u0174\u0175\u017e\u0207\u0000\u0000\u0000\u0000\u0000\u0000\u0000 !\"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\u0000\u00c7\u00fc\u00e9\u00e2\u00e4\u00e0\u00e5\u00e7\u00ea\u00eb\u00e8\u00ef\u00ee\u00ec\u00c4\u00c5\u00c9\u00e6\u00c6\u00f4\u00f6\u00f2\u00fb\u00f9\u00ff\u00d6\u00dc\u00f8\u00a3\u00d8\u00d7\u0192\u00e1\u00ed\u00f3\u00fa\u00f1\u00d1\u00aa\u00ba\u00bf\u00ae\u00ac\u00bd\u00bc\u00a1\u00ab\u00bb\u2591\u2592\u2593\u2502\u2524\u2561\u2562\u2556\u2555\u2563\u2551\u2557\u255d\u255c\u255b\u2510\u2514\u2534\u252c\u251c\u2500\u253c\u255e\u255f\u255a\u2554\u2569\u2566\u2560\u2550\u256c\u2567\u2568\u2564\u2565\u2559\u2558\u2552\u2553\u256b\u256a\u2518\u250c\u2588\u2584\u258c\u2590\u2580\u03b1\u03b2\u0393\u03c0\u03a3\u03c3\u03bc\u03c4\u03a6\u0398\u03a9\u03b4\u221e\u2205\u2208\u2229\u2261\u00b1\u2265\u2264\u2320\u2321\u00f7\u2248\u00b0\u2219\u00b7\u221a\u207f\u00b2\u25a0\u0000".indexOf(c0); - if (this.randomStyle && j != -1) - { - do - { + if (this.randomStyle && j != -1) { + do { k = Minecraft.getMinecraft().fontRenderer.fontRandom.nextInt(this.charWidth.length); } while (this.charWidth[j] != this.charWidth[k]); @@ -349,26 +313,22 @@ public class CustomGuiLabel extends Gui implements IGuiComponent { float f1 = this.unicodeFlag ? 0.5F : 1.0F; boolean flag1 = (c0 == 0 || j == -1 || this.unicodeFlag) && p_78255_2_; - if (flag1) - { + if (flag1) { this.posX -= f1; this.posY -= f1; } float f = this.renderCharAtPos(j, c0, this.italicStyle); - if (flag1) - { + if (flag1) { this.posX += f1; this.posY += f1; } - if (this.boldStyle) - { + if (this.boldStyle) { this.posX += f1; - if (flag1) - { + if (flag1) { this.posX -= f1; this.posY -= f1; } @@ -376,8 +336,7 @@ public class CustomGuiLabel extends Gui implements IGuiComponent { this.renderCharAtPos(j, c0, this.italicStyle); this.posX -= f1; - if (flag1) - { + if (flag1) { this.posX += f1; this.posY += f1; } @@ -390,56 +349,51 @@ public class CustomGuiLabel extends Gui implements IGuiComponent { } } - protected void doDraw(float f) - { + protected void doDraw(float f) { { { Tessellator tessellator; - if (this.strikethroughStyle) - { + if (this.strikethroughStyle) { tessellator = Tessellator.instance; GL11.glDisable(GL11.GL_TEXTURE_2D); tessellator.startDrawingQuads(); - tessellator.addVertex((double)this.posX, (double)(this.posY + (float)(Minecraft.getMinecraft().fontRenderer.FONT_HEIGHT / 2)), 0.0D); - tessellator.addVertex((double)(this.posX + f), (double)(this.posY + (float)(Minecraft.getMinecraft().fontRenderer.FONT_HEIGHT / 2)), 0.0D); - tessellator.addVertex((double)(this.posX + f), (double)(this.posY + (float)(Minecraft.getMinecraft().fontRenderer.FONT_HEIGHT / 2) - 1.0F), 0.0D); - tessellator.addVertex((double)this.posX, (double)(this.posY + (float)(Minecraft.getMinecraft().fontRenderer.FONT_HEIGHT / 2) - 1.0F), 0.0D); + tessellator.addVertex((double) this.posX, (double) (this.posY + (float) (Minecraft.getMinecraft().fontRenderer.FONT_HEIGHT / 2)), 0.0D); + tessellator.addVertex((double) (this.posX + f), (double) (this.posY + (float) (Minecraft.getMinecraft().fontRenderer.FONT_HEIGHT / 2)), 0.0D); + tessellator.addVertex((double) (this.posX + f), (double) (this.posY + (float) (Minecraft.getMinecraft().fontRenderer.FONT_HEIGHT / 2) - 1.0F), 0.0D); + tessellator.addVertex((double) this.posX, (double) (this.posY + (float) (Minecraft.getMinecraft().fontRenderer.FONT_HEIGHT / 2) - 1.0F), 0.0D); tessellator.draw(); GL11.glEnable(GL11.GL_TEXTURE_2D); } - if (this.underlineStyle) - { + if (this.underlineStyle) { tessellator = Tessellator.instance; GL11.glDisable(GL11.GL_TEXTURE_2D); tessellator.startDrawingQuads(); int l = this.underlineStyle ? -1 : 0; - tessellator.addVertex((double)(this.posX + (float)l), (double)(this.posY + (float)Minecraft.getMinecraft().fontRenderer.FONT_HEIGHT), 0.0D); - tessellator.addVertex((double)(this.posX + f), (double)(this.posY + (float)Minecraft.getMinecraft().fontRenderer.FONT_HEIGHT), 0.0D); - tessellator.addVertex((double)(this.posX + f), (double)(this.posY + (float)Minecraft.getMinecraft().fontRenderer.FONT_HEIGHT - 1.0F), 0.0D); - tessellator.addVertex((double)(this.posX + (float)l), (double)(this.posY + (float)Minecraft.getMinecraft().fontRenderer.FONT_HEIGHT - 1.0F), 0.0D); + tessellator.addVertex((double) (this.posX + (float) l), (double) (this.posY + (float) Minecraft.getMinecraft().fontRenderer.FONT_HEIGHT), 0.0D); + tessellator.addVertex((double) (this.posX + f), (double) (this.posY + (float) Minecraft.getMinecraft().fontRenderer.FONT_HEIGHT), 0.0D); + tessellator.addVertex((double) (this.posX + f), (double) (this.posY + (float) Minecraft.getMinecraft().fontRenderer.FONT_HEIGHT - 1.0F), 0.0D); + tessellator.addVertex((double) (this.posX + (float) l), (double) (this.posY + (float) Minecraft.getMinecraft().fontRenderer.FONT_HEIGHT - 1.0F), 0.0D); tessellator.draw(); GL11.glEnable(GL11.GL_TEXTURE_2D); } - this.posX += (float)((int)f); + this.posX += (float) ((int) f); } } } - private float renderCharAtPos(int p_78278_1_, char p_78278_2_, boolean p_78278_3_) - { + private float renderCharAtPos(int p_78278_1_, char p_78278_2_, boolean p_78278_3_) { return p_78278_2_ == 32 ? 4.0F : ("\u00c0\u00c1\u00c2\u00c8\u00ca\u00cb\u00cd\u00d3\u00d4\u00d5\u00da\u00df\u00e3\u00f5\u011f\u0130\u0131\u0152\u0153\u015e\u015f\u0174\u0175\u017e\u0207\u0000\u0000\u0000\u0000\u0000\u0000\u0000 !\"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\u0000\u00c7\u00fc\u00e9\u00e2\u00e4\u00e0\u00e5\u00e7\u00ea\u00eb\u00e8\u00ef\u00ee\u00ec\u00c4\u00c5\u00c9\u00e6\u00c6\u00f4\u00f6\u00f2\u00fb\u00f9\u00ff\u00d6\u00dc\u00f8\u00a3\u00d8\u00d7\u0192\u00e1\u00ed\u00f3\u00fa\u00f1\u00d1\u00aa\u00ba\u00bf\u00ae\u00ac\u00bd\u00bc\u00a1\u00ab\u00bb\u2591\u2592\u2593\u2502\u2524\u2561\u2562\u2556\u2555\u2563\u2551\u2557\u255d\u255c\u255b\u2510\u2514\u2534\u252c\u251c\u2500\u253c\u255e\u255f\u255a\u2554\u2569\u2566\u2560\u2550\u256c\u2567\u2568\u2564\u2565\u2559\u2558\u2552\u2553\u256b\u256a\u2518\u250c\u2588\u2584\u258c\u2590\u2580\u03b1\u03b2\u0393\u03c0\u03a3\u03c3\u03bc\u03c4\u03a6\u0398\u03a9\u03b4\u221e\u2205\u2208\u2229\u2261\u00b1\u2265\u2264\u2320\u2321\u00f7\u2248\u00b0\u2219\u00b7\u221a\u207f\u00b2\u25a0\u0000".indexOf(p_78278_2_) != -1 && !this.unicodeFlag ? this.renderDefaultChar(p_78278_1_, p_78278_3_) : this.renderUnicodeChar(p_78278_2_, p_78278_3_)); } - protected float renderDefaultChar(int p_78266_1_, boolean p_78266_2_) - { - float f = (float)(p_78266_1_ % 16 * 8); - float f1 = (float)(p_78266_1_ / 16 * 8); + protected float renderDefaultChar(int p_78266_1_, boolean p_78266_2_) { + float f = (float) (p_78266_1_ % 16 * 8); + float f1 = (float) (p_78266_1_ / 16 * 8); float f2 = p_78266_2_ ? 1.0F : 0.0F; bindTexture(this.locationFontTexture); - float f3 = (float)this.charWidth[p_78266_1_] - 0.01F; + float f3 = (float) this.charWidth[p_78266_1_] - 0.01F; GL11.glBegin(GL11.GL_TRIANGLE_STRIP); GL11.glTexCoord2f(f / 128.0F, f1 / 128.0F); GL11.glVertex3f(this.posX + f2, this.posY, 0.0F); @@ -450,43 +404,36 @@ public class CustomGuiLabel extends Gui implements IGuiComponent { GL11.glTexCoord2f((f + f3 - 1.0F) / 128.0F, (f1 + 7.99F) / 128.0F); GL11.glVertex3f(this.posX + f3 - 1.0F - f2, this.posY + 7.99F, 0.0F); GL11.glEnd(); - return (float)this.charWidth[p_78266_1_]; + return (float) this.charWidth[p_78266_1_]; } - private ResourceLocation getUnicodePageLocation(int p_111271_1_) - { - if (unicodePageLocations[p_111271_1_] == null) - { - unicodePageLocations[p_111271_1_] = new ResourceLocation(String.format("textures/font/unicode_page_%02x.png", new Object[] {Integer.valueOf(p_111271_1_)})); + private ResourceLocation getUnicodePageLocation(int p_111271_1_) { + if (unicodePageLocations[p_111271_1_] == null) { + unicodePageLocations[p_111271_1_] = new ResourceLocation(String.format("textures/font/unicode_page_%02x.png", new Object[]{Integer.valueOf(p_111271_1_)})); } return unicodePageLocations[p_111271_1_]; } - private void loadGlyphTexture(int p_78257_1_) - { + private void loadGlyphTexture(int p_78257_1_) { bindTexture(this.getUnicodePageLocation(p_78257_1_)); } /** * Render a single Unicode character at current (posX,posY) location using one of the /font/glyph_XX.png files... */ - protected float renderUnicodeChar(char p_78277_1_, boolean p_78277_2_) - { - if (this.glyphWidth[p_78277_1_] == 0) - { + protected float renderUnicodeChar(char p_78277_1_, boolean p_78277_2_) { + if (this.glyphWidth[p_78277_1_] == 0) { return 0.0F; - } - else - { + } else { int i = p_78277_1_ / 256; this.loadGlyphTexture(i); int j = this.glyphWidth[p_78277_1_] >>> 4; int k = this.glyphWidth[p_78277_1_] & 15; - float f = (float)j; - float f1 = (float)(k + 1); - float f2 = (float)(p_78277_1_ % 16 * 16) + f; - float f3 = (float)((p_78277_1_ & 255) / 16 * 16); + float f = (float) j; + float f1 = (float) (k + 1); + float f2 = (float) (p_78277_1_ % 16 * 16) + f; + float f3 = (float) ((p_78277_1_ & 255) / 16 * 16); float f4 = f1 - f - 0.02F; float f5 = p_78277_2_ ? 1.0F : 0.0F; GL11.glBegin(GL11.GL_TRIANGLE_STRIP); @@ -503,26 +450,20 @@ public class CustomGuiLabel extends Gui implements IGuiComponent { } } - protected void setColor(float r, float g, float b, float a) - { + protected void setColor(float r, float g, float b, float a) { GL11.glColor4f(r, g, b, a); } - protected void bindTexture(ResourceLocation location) - { + protected void bindTexture(ResourceLocation location) { Minecraft.getMinecraft().renderEngine.bindTexture(location); } - private void readFontTexture() - { + private void readFontTexture() { BufferedImage bufferedimage; - try - { + try { bufferedimage = ImageIO.read(getResourceInputStream(this.locationFontTexture)); - } - catch (IOException ioexception) - { + } catch (IOException ioexception) { throw new RuntimeException(ioexception); } @@ -533,81 +474,65 @@ public class CustomGuiLabel extends Gui implements IGuiComponent { int k = j / 16; int l = i / 16; byte b0 = 1; - float f = 8.0F / (float)l; + float f = 8.0F / (float) l; int i1 = 0; - while (i1 < 256) - { + while (i1 < 256) { int j1 = i1 % 16; int k1 = i1 / 16; - if (i1 == 32) - { + if (i1 == 32) { this.charWidth[i1] = 3 + b0; } int l1 = l - 1; - while (true) - { - if (l1 >= 0) - { + while (true) { + if (l1 >= 0) { int i2 = j1 * l + l1; boolean flag = true; - for (int j2 = 0; j2 < k && flag; ++j2) - { + for (int j2 = 0; j2 < k && flag; ++j2) { int k2 = (k1 * l + j2) * i; - if ((aint[i2 + k2] >> 24 & 255) != 0) - { + if ((aint[i2 + k2] >> 24 & 255) != 0) { flag = false; } } - if (flag) - { + if (flag) { --l1; continue; } } ++l1; - this.charWidth[i1] = (int)(0.5D + (double)((float)l1 * f)) + b0; + this.charWidth[i1] = (int) (0.5D + (double) ((float) l1 * f)) + b0; ++i1; break; } } } - private void readGlyphSizes() - { - try - { + private void readGlyphSizes() { + try { InputStream inputstream = getResourceInputStream(new ResourceLocation("font/glyph_sizes.bin")); inputstream.read(this.glyphWidth); - } - catch (IOException ioexception) - { + } catch (IOException ioexception) { throw new RuntimeException(ioexception); } } - protected InputStream getResourceInputStream(ResourceLocation location) throws IOException - { + protected InputStream getResourceInputStream(ResourceLocation location) throws IOException { return Minecraft.getMinecraft().getResourceManager().getResource(location).getInputStream(); } - private String bidiReorder(String p_147647_1_) - { - try - { + private String bidiReorder(String p_147647_1_) { + try { Bidi bidi = new Bidi((new ArabicShaping(8)).shape(p_147647_1_), 127); bidi.setReorderingMode(0); return bidi.writeReordered(2); - } - catch (ArabicShapingException arabicshapingexception) - { + } catch (ArabicShapingException arabicshapingexception) { return p_147647_1_; } } diff --git a/src/main/java/noppes/npcs/client/gui/custom/components/CustomGuiLine.java b/src/main/java/noppes/npcs/client/gui/custom/components/CustomGuiLine.java index c63bac363..f5ee55fe1 100644 --- a/src/main/java/noppes/npcs/client/gui/custom/components/CustomGuiLine.java +++ b/src/main/java/noppes/npcs/client/gui/custom/components/CustomGuiLine.java @@ -21,7 +21,7 @@ public class CustomGuiLine extends Gui implements IGuiComponent { float rotation; int thickness; - public CustomGuiLine(int id, int x1, int y1, int x2, int y2, int color, int thickness){ + public CustomGuiLine(int id, int x1, int y1, int x2, int y2, int color, int thickness) { this.id = id; this.x1 = x1; this.y1 = y1; @@ -41,25 +41,25 @@ public class CustomGuiLine extends Gui implements IGuiComponent { } public void onRender(Minecraft mc, int mouseX, int mouseY, int mouseWheel, float partialTicks) { - double distance = Math.sqrt(Math.pow(x1-x2,2)+Math.pow(y1-y2,2)); + double distance = Math.sqrt(Math.pow(x1 - x2, 2) + Math.pow(y1 - y2, 2)); mc.getTextureManager().bindTexture(new ResourceLocation("customnpcs:textures/gui/misc.png")); GL11.glPushMatrix(); - float red = (color >> 16 & 255) / 255f; - float green = (color >> 8 & 255) / 255f; - float blue = (color & 255) / 255f; - GL11.glColor4f(red,green,blue,this.alpha); + float red = (color >> 16 & 255) / 255f; + float green = (color >> 8 & 255) / 255f; + float blue = (color & 255) / 255f; + GL11.glColor4f(red, green, blue, this.alpha); - GL11.glTranslatef(GuiCustom.guiLeft+this.x1,GuiCustom.guiTop+this.y1,(float)this.id); - GL11.glRotated(-Math.toDegrees(Math.atan2(x2-x1,y2-y1)),0.0F,0.0F,1.0F); - GL11.glRotated(rotation,0.0D,0.0D,1.0D); - GL11.glScaled(thickness, distance,0.0D); - this.drawTexturedModalRect(0,0,0,0, 1, 1); + GL11.glTranslatef(GuiCustom.guiLeft + this.x1, GuiCustom.guiTop + this.y1, (float) this.id); + GL11.glRotated(-Math.toDegrees(Math.atan2(x2 - x1, y2 - y1)), 0.0F, 0.0F, 1.0F); + GL11.glRotated(rotation, 0.0D, 0.0D, 1.0D); + GL11.glScaled(thickness, distance, 0.0D); + this.drawTexturedModalRect(0, 0, 0, 0, 1, 1); GL11.glPopMatrix(); } public ICustomGuiComponent toComponent() { - ScriptGuiLine line = new ScriptGuiLine(this.id, this.x1,this.y1,this.x2,this.y2,this.color,this.thickness); + ScriptGuiLine line = new ScriptGuiLine(this.id, this.x1, this.y1, this.x2, this.y2, this.color, this.thickness); line.setColor(this.color); line.setAlpha(this.alpha); line.setRotation(this.rotation); diff --git a/src/main/java/noppes/npcs/client/gui/custom/components/CustomGuiScrollComponent.java b/src/main/java/noppes/npcs/client/gui/custom/components/CustomGuiScrollComponent.java index 2d1ba540b..976496b81 100644 --- a/src/main/java/noppes/npcs/client/gui/custom/components/CustomGuiScrollComponent.java +++ b/src/main/java/noppes/npcs/client/gui/custom/components/CustomGuiScrollComponent.java @@ -40,17 +40,17 @@ public class CustomGuiScrollComponent extends GuiCustomScroll implements IDataHo public void onRender(Minecraft mc, int mouseX, int mouseY, int mouseWheel, float partialTicks) { GL11.glPushMatrix(); - float red = (color >> 16 & 255) / 255f; - float green = (color >> 8 & 255) / 255f; - float blue = (color & 255) / 255f; - GL11.glColor4f(red,green,blue,this.alpha); + float red = (color >> 16 & 255) / 255f; + float green = (color >> 8 & 255) / 255f; + float blue = (color & 255) / 255f; + GL11.glColor4f(red, green, blue, this.alpha); - GL11.glTranslatef(0.0F, 0.0F, (float)this.id); - boolean hovered = mouseX >= this.guiLeft && mouseY >= this.guiTop && mouseX < this.guiLeft + this.xSize && mouseY < this.guiTop + this.ySize; - super.drawScreen(mouseX, mouseY, partialTicks, mouseWheel); - if (hovered && this.hoverText != null && this.hoverText.length > 0) { - this.parent.hoverText = this.hoverText; - } + GL11.glTranslatef(0.0F, 0.0F, (float) this.id); + boolean hovered = mouseX >= this.guiLeft && mouseY >= this.guiTop && mouseX < this.guiLeft + this.xSize && mouseY < this.guiTop + this.ySize; + super.drawScreen(mouseX, mouseY, partialTicks, mouseWheel); + if (hovered && this.hoverText != null && this.hoverText.length > 0) { + this.parent.hoverText = this.hoverText; + } GL11.glPopMatrix(); } @@ -80,7 +80,7 @@ public class CustomGuiScrollComponent extends GuiCustomScroll implements IDataHo } public ICustomGuiComponent toComponent() { - ScriptGuiScroll component = new ScriptGuiScroll(this.id, this.guiLeft - GuiCustom.guiLeft, this.guiTop - GuiCustom.guiTop, this.xSize, this.ySize, (String[])this.getList().toArray(new String[0])); + ScriptGuiScroll component = new ScriptGuiScroll(this.id, this.guiLeft - GuiCustom.guiLeft, this.guiTop - GuiCustom.guiTop, this.xSize, this.ySize, (String[]) this.getList().toArray(new String[0])); component.setHoverText(this.hoverText); component.setColor(color); component.setAlpha(alpha); @@ -94,8 +94,8 @@ public class CustomGuiScrollComponent extends GuiCustomScroll implements IDataHo NBTTagList tagList = new NBTTagList(); Iterator var3 = this.getSelectedList().iterator(); - while(var3.hasNext()) { - String s = (String)var3.next(); + while (var3.hasNext()) { + String s = (String) var3.next(); tagList.appendTag(new NBTTagString(s)); } diff --git a/src/main/java/noppes/npcs/client/gui/custom/components/CustomGuiSlot.java b/src/main/java/noppes/npcs/client/gui/custom/components/CustomGuiSlot.java index 8c1fed217..90e2ce8b6 100644 --- a/src/main/java/noppes/npcs/client/gui/custom/components/CustomGuiSlot.java +++ b/src/main/java/noppes/npcs/client/gui/custom/components/CustomGuiSlot.java @@ -25,7 +25,7 @@ public class CustomGuiSlot extends Slot { @Override public void onSlotChanged() { - if(!player.worldObj.isRemote){ + if (!player.worldObj.isRemote) { boolean changed; if (getStack() != null && slot.getStack() != null) { changed = !getStack().equals(slot.getStack().getMCItemStack()); @@ -33,10 +33,10 @@ public class CustomGuiSlot extends Slot { // Handle the case when either getStack() or slot.getStack() is null (indicating an empty slot) changed = getStack() != null || slot.getStack() != null; } - if(changed) { + if (changed) { slot.setStack(NpcAPI.Instance().getIItemStack(getStack())); if (player.openContainer instanceof ContainerCustomGui) { - EventHooks.onCustomGuiSlot((IPlayer) NpcAPI.Instance().getIEntity(player), ((ContainerCustomGui)player.openContainer).customGui, + EventHooks.onCustomGuiSlot((IPlayer) NpcAPI.Instance().getIEntity(player), ((ContainerCustomGui) player.openContainer).customGui, getSlotIndex(), getStack(), slot); } } diff --git a/src/main/java/noppes/npcs/client/gui/custom/components/CustomGuiTextField.java b/src/main/java/noppes/npcs/client/gui/custom/components/CustomGuiTextField.java index b95f46247..6d3a0ac02 100644 --- a/src/main/java/noppes/npcs/client/gui/custom/components/CustomGuiTextField.java +++ b/src/main/java/noppes/npcs/client/gui/custom/components/CustomGuiTextField.java @@ -32,14 +32,14 @@ public class CustomGuiTextField extends GuiTextField implements IKeyListener, ID public void onRender(Minecraft mc, int mouseX, int mouseY, int mouseWheel, float partialTicks) { boolean hovered = mouseX >= this.xPosition && mouseY >= this.yPosition && mouseX < this.xPosition + this.width && mouseY < this.yPosition + this.height; float red = (color >> 16 & 255) / 255f; - float green = (color >> 8 & 255) / 255f; + float green = (color >> 8 & 255) / 255f; float blue = (color & 255) / 255f; - GL11.glColor4f(red,green,blue,this.alpha); + GL11.glColor4f(red, green, blue, this.alpha); GL11.glPushMatrix(); - GL11.glTranslatef(0.0F,0.0F,(float)this.id); + GL11.glTranslatef(0.0F, 0.0F, (float) this.id); this.drawTextBox(); GL11.glPopMatrix(); - GL11.glColor4f(1.0F,1.0F,1.0F,1.0F); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); if (hovered && this.hoverText != null && this.hoverText.length > 0) { this.parent.hoverText = this.hoverText; } @@ -88,7 +88,7 @@ public class CustomGuiTextField extends GuiTextField implements IKeyListener, ID public boolean mouseClicked(GuiCustom gui, int mouseX, int mouseY, int mouseButton) { boolean flag = mouseX >= this.xPosition && mouseX < this.xPosition + this.width && mouseY >= this.yPosition && mouseY < this.yPosition + this.height; - if (this.isFocused() && mouseButton == 0 && !flag){ + if (this.isFocused() && mouseButton == 0 && !flag) { parent.onTextFieldUnfocused(this); } diff --git a/src/main/java/noppes/npcs/client/gui/custom/components/CustomGuiTexturedRect.java b/src/main/java/noppes/npcs/client/gui/custom/components/CustomGuiTexturedRect.java index 463841663..58303db63 100644 --- a/src/main/java/noppes/npcs/client/gui/custom/components/CustomGuiTexturedRect.java +++ b/src/main/java/noppes/npcs/client/gui/custom/components/CustomGuiTexturedRect.java @@ -58,7 +58,7 @@ public class CustomGuiTexturedRect extends Gui implements IGuiComponent { } public void onRender(Minecraft mc, int mouseX, int mouseY, int mouseWheel, float partialTicks) { - boolean hovered = mouseX >= this.x + GuiCustom.guiLeft && mouseY >= this.y + GuiCustom.guiTop && mouseX < this.x + GuiCustom.guiLeft + this.width*scale && mouseY < this.y + GuiCustom.guiTop + this.height*scale; + boolean hovered = mouseX >= this.x + GuiCustom.guiLeft && mouseY >= this.y + GuiCustom.guiTop && mouseX < this.x + GuiCustom.guiLeft + this.width * scale && mouseY < this.y + GuiCustom.guiTop + this.height * scale; if (this.imageData != null && this.imageData.imageLoaded()) { int totalWidth = this.imageData.getTotalWidth(); diff --git a/src/main/java/noppes/npcs/client/gui/customoverlay/OverlayCustom.java b/src/main/java/noppes/npcs/client/gui/customoverlay/OverlayCustom.java index 2926b1c2c..aa36108c7 100644 --- a/src/main/java/noppes/npcs/client/gui/customoverlay/OverlayCustom.java +++ b/src/main/java/noppes/npcs/client/gui/customoverlay/OverlayCustom.java @@ -31,32 +31,32 @@ public class OverlayCustom extends Gui { this.mc = mc; } - public void initOverlay(){ + public void initOverlay() { res = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight); - if(this.overlay != null){ + if (this.overlay != null) { scaledWidth = res.getScaledWidth(); scaledHeight = res.getScaledHeight(); this.components.clear(); Iterator var1 = this.overlay.getComponents().iterator(); - while(var1.hasNext()) { - ICustomOverlayComponent c = (ICustomOverlayComponent)var1.next(); + while (var1.hasNext()) { + ICustomOverlayComponent c = (ICustomOverlayComponent) var1.next(); this.addComponent(c); } } } private void addComponent(ICustomOverlayComponent component) { - ScriptOverlayComponent c = (ScriptOverlayComponent)component; - switch(c.getType()) { + ScriptOverlayComponent c = (ScriptOverlayComponent) component; + switch (c.getType()) { case 0: CustomOverlayTexturedRect rect = CustomOverlayTexturedRect.fromComponent((ScriptOverlayTexturedRect) component); rect.setParent(this); this.components.put(rect.getID(), rect); break; case 1: - CustomOverlayLabel lbl = CustomOverlayLabel.fromComponent((ScriptOverlayLabel)component); + CustomOverlayLabel lbl = CustomOverlayLabel.fromComponent((ScriptOverlayLabel) component); lbl.setParent(this); this.components.put(lbl.getID(), lbl); break; @@ -68,19 +68,19 @@ public class OverlayCustom extends Gui { } } - public void renderGameOverlay(float partialTicks){ + public void renderGameOverlay(float partialTicks) { res = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight); scaledWidth = res.getScaledWidth(); scaledHeight = res.getScaledHeight(); Iterator var4 = this.components.values().iterator(); - while(var4.hasNext()) { + while (var4.hasNext()) { GL11.glEnable(GL11.GL_BLEND); OpenGlHelper.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0); GL11.glDisable(GL11.GL_ALPHA_TEST); - IOverlayComponent component = (IOverlayComponent)var4.next(); + IOverlayComponent component = (IOverlayComponent) var4.next(); component.onRender(this.mc, partialTicks); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); @@ -90,7 +90,7 @@ public class OverlayCustom extends Gui { } public void setOverlayData(NBTTagCompound compound) { - this.overlay = (ScriptOverlay)(new ScriptOverlay()).fromNBT(compound); + this.overlay = (ScriptOverlay) (new ScriptOverlay()).fromNBT(compound); this.initOverlay(); } } diff --git a/src/main/java/noppes/npcs/client/gui/customoverlay/components/CustomOverlayLabel.java b/src/main/java/noppes/npcs/client/gui/customoverlay/components/CustomOverlayLabel.java index a0d135f2e..f5b97457b 100644 --- a/src/main/java/noppes/npcs/client/gui/customoverlay/components/CustomOverlayLabel.java +++ b/src/main/java/noppes/npcs/client/gui/customoverlay/components/CustomOverlayLabel.java @@ -58,7 +58,7 @@ public class CustomOverlayLabel extends Gui implements IOverlayComponent { private float posX; private float posY; - public CustomOverlayLabel(int id, String fullLabel, int x, int y, int width, int height, boolean shadow){ + public CustomOverlayLabel(int id, String fullLabel, int x, int y, int width, int height, boolean shadow) { this.id = id; this.fullLabel = fullLabel; this.x = x; @@ -70,20 +70,17 @@ public class CustomOverlayLabel extends Gui implements IOverlayComponent { locationFontTexture = new ResourceLocation("textures/font/ascii.png"); readFontTexture(); readGlyphSizes(); - for (int i = 0; i < 32; ++i) - { + for (int i = 0; i < 32; ++i) { int j = (i >> 3 & 1) * 85; int k = (i >> 2 & 1) * 170 + j; int l = (i >> 1 & 1) * 170 + j; int i1 = (i >> 0 & 1) * 170 + j; - if (i == 6) - { + if (i == 6) { k += 85; } - if (Minecraft.getMinecraft().gameSettings.anaglyph) - { + if (Minecraft.getMinecraft().gameSettings.anaglyph) { int j1 = (k * 30 + l * 59 + i1 * 11) / 100; int k1 = (k * 30 + l * 70) / 100; int l1 = (k * 30 + i1 * 70) / 100; @@ -92,8 +89,7 @@ public class CustomOverlayLabel extends Gui implements IOverlayComponent { i1 = l1; } - if (i >= 16) - { + if (i >= 16) { k /= 4; l /= 4; i1 /= 4; @@ -143,42 +139,36 @@ public class CustomOverlayLabel extends Gui implements IOverlayComponent { return component; } - public void drawLabel() - { + public void drawLabel() { GL11.glPushMatrix(); - GL11.glTranslatef(this.alignment%3*((float)(OverlayCustom.scaledWidth)/2), (float) (Math.floor((float)(alignment/3))*((float)(OverlayCustom.scaledHeight)/2)),0.0F);//alignment%3 * width/2 Math.floor(alignment/3) * height/2 + GL11.glTranslatef(this.alignment % 3 * ((float) (OverlayCustom.scaledWidth) / 2), (float) (Math.floor((float) (alignment / 3)) * ((float) (OverlayCustom.scaledHeight) / 2)), 0.0F);//alignment%3 * width/2 Math.floor(alignment/3) * height/2 - red = (color >> 16 & 255) / 255f; - green = (color >> 8 & 255) / 255f; - blue = (color & 255) / 255f; + red = (color >> 16 & 255) / 255f; + green = (color >> 8 & 255) / 255f; + blue = (color & 255) / 255f; - GL11.glTranslatef(this.x,this.y, (float) this.id); - GL11.glRotated(rotation,0.0D,0.0D,1.0D); - GL11.glScalef(this.scale, this.scale, this.scale); - this.drawString(fullLabel, 0, 0, this.color, this.labelShadowEnabled); + GL11.glTranslatef(this.x, this.y, (float) this.id); + GL11.glRotated(rotation, 0.0D, 0.0D, 1.0D); + GL11.glScalef(this.scale, this.scale, this.scale); + this.drawString(fullLabel, 0, 0, this.color, this.labelShadowEnabled); GL11.glPopMatrix(); } - public int drawString(String p_85187_1_, int p_85187_2_, int p_85187_3_, int p_85187_4_, boolean p_85187_5_) - { + public int drawString(String p_85187_1_, int p_85187_2_, int p_85187_3_, int p_85187_4_, boolean p_85187_5_) { this.resetStyles(); int l; - if (p_85187_5_) - { + if (p_85187_5_) { l = this.renderString(p_85187_1_, p_85187_2_ + 1, p_85187_3_ + 1, p_85187_4_, true); l = Math.max(l, this.renderString(p_85187_1_, p_85187_2_, p_85187_3_, p_85187_4_, false)); - } - else - { + } else { l = this.renderString(p_85187_1_, p_85187_2_, p_85187_3_, p_85187_4_, false); } return l; } - private void resetStyles() - { + private void resetStyles() { this.randomStyle = false; this.boldStyle = false; this.italicStyle = false; @@ -186,81 +176,59 @@ public class CustomOverlayLabel extends Gui implements IOverlayComponent { this.strikethroughStyle = false; } - private int renderString(String p_78258_1_, int p_78258_2_, int p_78258_3_, int p_78258_4_, boolean p_78258_5_) - { - if (p_78258_1_ == null) - { + private int renderString(String p_78258_1_, int p_78258_2_, int p_78258_3_, int p_78258_4_, boolean p_78258_5_) { + if (p_78258_1_ == null) { return 0; - } - else - { - if (this.bidiFlag) - { + } else { + if (this.bidiFlag) { p_78258_1_ = this.bidiReorder(p_78258_1_); } setColor(this.red, this.green, this.blue, this.alpha); - this.posX = (float)p_78258_2_; - this.posY = (float)p_78258_3_; + this.posX = (float) p_78258_2_; + this.posY = (float) p_78258_3_; this.renderStringAtPos(p_78258_1_, p_78258_5_); - return (int)this.posX; + return (int) this.posX; } } - private void renderStringAtPos(String p_78255_1_, boolean p_78255_2_) - { - for (int i = 0; i < p_78255_1_.length(); ++i) - { + private void renderStringAtPos(String p_78255_1_, boolean p_78255_2_) { + for (int i = 0; i < p_78255_1_.length(); ++i) { char c0 = p_78255_1_.charAt(i); int j; int k; - if (c0 == 38 && i + 1 < p_78255_1_.length()) - { + if (c0 == 38 && i + 1 < p_78255_1_.length()) { j = "0123456789abcdefklmnor".indexOf(p_78255_1_.toLowerCase().charAt(i + 1)); - if(j < 16){ + if (j < 16) { this.randomStyle = false; this.boldStyle = false; this.strikethroughStyle = false; this.underlineStyle = false; this.italicStyle = false; - if (j < 0 || j > 15) - { + if (j < 0 || j > 15) { j = 15; } - if (p_78255_2_) - { + if (p_78255_2_) { j += 16; } k = this.colorCode[j]; - setColor((float)(k >> 16) / 255.0F, (float)(k >> 8 & 255) / 255.0F, (float)(k & 255) / 255.0F, this.alpha); - } - else if (j == 16) - { + setColor((float) (k >> 16) / 255.0F, (float) (k >> 8 & 255) / 255.0F, (float) (k & 255) / 255.0F, this.alpha); + } else if (j == 16) { this.randomStyle = true; - } - else if (j == 17) - { + } else if (j == 17) { this.boldStyle = true; - } - else if (j == 18) - { + } else if (j == 18) { this.strikethroughStyle = true; - } - else if (j == 19) - { + } else if (j == 19) { this.underlineStyle = true; - } - else if (j == 20) - { + } else if (j == 20) { this.italicStyle = true; - } - else if (j == 21) - { + } else if (j == 21) { this.randomStyle = false; this.boldStyle = false; this.strikethroughStyle = false; @@ -269,15 +237,11 @@ public class CustomOverlayLabel extends Gui implements IOverlayComponent { } ++i; - } - else - { + } else { j = "\u00c0\u00c1\u00c2\u00c8\u00ca\u00cb\u00cd\u00d3\u00d4\u00d5\u00da\u00df\u00e3\u00f5\u011f\u0130\u0131\u0152\u0153\u015e\u015f\u0174\u0175\u017e\u0207\u0000\u0000\u0000\u0000\u0000\u0000\u0000 !\"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\u0000\u00c7\u00fc\u00e9\u00e2\u00e4\u00e0\u00e5\u00e7\u00ea\u00eb\u00e8\u00ef\u00ee\u00ec\u00c4\u00c5\u00c9\u00e6\u00c6\u00f4\u00f6\u00f2\u00fb\u00f9\u00ff\u00d6\u00dc\u00f8\u00a3\u00d8\u00d7\u0192\u00e1\u00ed\u00f3\u00fa\u00f1\u00d1\u00aa\u00ba\u00bf\u00ae\u00ac\u00bd\u00bc\u00a1\u00ab\u00bb\u2591\u2592\u2593\u2502\u2524\u2561\u2562\u2556\u2555\u2563\u2551\u2557\u255d\u255c\u255b\u2510\u2514\u2534\u252c\u251c\u2500\u253c\u255e\u255f\u255a\u2554\u2569\u2566\u2560\u2550\u256c\u2567\u2568\u2564\u2565\u2559\u2558\u2552\u2553\u256b\u256a\u2518\u250c\u2588\u2584\u258c\u2590\u2580\u03b1\u03b2\u0393\u03c0\u03a3\u03c3\u03bc\u03c4\u03a6\u0398\u03a9\u03b4\u221e\u2205\u2208\u2229\u2261\u00b1\u2265\u2264\u2320\u2321\u00f7\u2248\u00b0\u2219\u00b7\u221a\u207f\u00b2\u25a0\u0000".indexOf(c0); - if (this.randomStyle && j != -1) - { - do - { + if (this.randomStyle && j != -1) { + do { k = Minecraft.getMinecraft().fontRenderer.fontRandom.nextInt(this.charWidth.length); } while (this.charWidth[j] != this.charWidth[k]); @@ -288,26 +252,22 @@ public class CustomOverlayLabel extends Gui implements IOverlayComponent { float f1 = this.unicodeFlag ? 0.5F : 1.0F; boolean flag1 = (c0 == 0 || j == -1 || this.unicodeFlag) && p_78255_2_; - if (flag1) - { + if (flag1) { this.posX -= f1; this.posY -= f1; } float f = this.renderCharAtPos(j, c0, this.italicStyle); - if (flag1) - { + if (flag1) { this.posX += f1; this.posY += f1; } - if (this.boldStyle) - { + if (this.boldStyle) { this.posX += f1; - if (flag1) - { + if (flag1) { this.posX -= f1; this.posY -= f1; } @@ -315,8 +275,7 @@ public class CustomOverlayLabel extends Gui implements IOverlayComponent { this.renderCharAtPos(j, c0, this.italicStyle); this.posX -= f1; - if (flag1) - { + if (flag1) { this.posX += f1; this.posY += f1; } @@ -329,56 +288,51 @@ public class CustomOverlayLabel extends Gui implements IOverlayComponent { } } - protected void doDraw(float f) - { + protected void doDraw(float f) { { { Tessellator tessellator; - if (this.strikethroughStyle) - { + if (this.strikethroughStyle) { tessellator = Tessellator.instance; GL11.glDisable(GL11.GL_TEXTURE_2D); tessellator.startDrawingQuads(); - tessellator.addVertex((double)this.posX, (double)(this.posY + (float)(Minecraft.getMinecraft().fontRenderer.FONT_HEIGHT / 2)), 0.0D); - tessellator.addVertex((double)(this.posX + f), (double)(this.posY + (float)(Minecraft.getMinecraft().fontRenderer.FONT_HEIGHT / 2)), 0.0D); - tessellator.addVertex((double)(this.posX + f), (double)(this.posY + (float)(Minecraft.getMinecraft().fontRenderer.FONT_HEIGHT / 2) - 1.0F), 0.0D); - tessellator.addVertex((double)this.posX, (double)(this.posY + (float)(Minecraft.getMinecraft().fontRenderer.FONT_HEIGHT / 2) - 1.0F), 0.0D); + tessellator.addVertex((double) this.posX, (double) (this.posY + (float) (Minecraft.getMinecraft().fontRenderer.FONT_HEIGHT / 2)), 0.0D); + tessellator.addVertex((double) (this.posX + f), (double) (this.posY + (float) (Minecraft.getMinecraft().fontRenderer.FONT_HEIGHT / 2)), 0.0D); + tessellator.addVertex((double) (this.posX + f), (double) (this.posY + (float) (Minecraft.getMinecraft().fontRenderer.FONT_HEIGHT / 2) - 1.0F), 0.0D); + tessellator.addVertex((double) this.posX, (double) (this.posY + (float) (Minecraft.getMinecraft().fontRenderer.FONT_HEIGHT / 2) - 1.0F), 0.0D); tessellator.draw(); GL11.glEnable(GL11.GL_TEXTURE_2D); } - if (this.underlineStyle) - { + if (this.underlineStyle) { tessellator = Tessellator.instance; GL11.glDisable(GL11.GL_TEXTURE_2D); tessellator.startDrawingQuads(); int l = this.underlineStyle ? -1 : 0; - tessellator.addVertex((double)(this.posX + (float)l), (double)(this.posY + (float)Minecraft.getMinecraft().fontRenderer.FONT_HEIGHT), 0.0D); - tessellator.addVertex((double)(this.posX + f), (double)(this.posY + (float)Minecraft.getMinecraft().fontRenderer.FONT_HEIGHT), 0.0D); - tessellator.addVertex((double)(this.posX + f), (double)(this.posY + (float)Minecraft.getMinecraft().fontRenderer.FONT_HEIGHT - 1.0F), 0.0D); - tessellator.addVertex((double)(this.posX + (float)l), (double)(this.posY + (float)Minecraft.getMinecraft().fontRenderer.FONT_HEIGHT - 1.0F), 0.0D); + tessellator.addVertex((double) (this.posX + (float) l), (double) (this.posY + (float) Minecraft.getMinecraft().fontRenderer.FONT_HEIGHT), 0.0D); + tessellator.addVertex((double) (this.posX + f), (double) (this.posY + (float) Minecraft.getMinecraft().fontRenderer.FONT_HEIGHT), 0.0D); + tessellator.addVertex((double) (this.posX + f), (double) (this.posY + (float) Minecraft.getMinecraft().fontRenderer.FONT_HEIGHT - 1.0F), 0.0D); + tessellator.addVertex((double) (this.posX + (float) l), (double) (this.posY + (float) Minecraft.getMinecraft().fontRenderer.FONT_HEIGHT - 1.0F), 0.0D); tessellator.draw(); GL11.glEnable(GL11.GL_TEXTURE_2D); } - this.posX += (float)((int)f); + this.posX += (float) ((int) f); } } } - private float renderCharAtPos(int p_78278_1_, char p_78278_2_, boolean p_78278_3_) - { + private float renderCharAtPos(int p_78278_1_, char p_78278_2_, boolean p_78278_3_) { return p_78278_2_ == 32 ? 4.0F : ("\u00c0\u00c1\u00c2\u00c8\u00ca\u00cb\u00cd\u00d3\u00d4\u00d5\u00da\u00df\u00e3\u00f5\u011f\u0130\u0131\u0152\u0153\u015e\u015f\u0174\u0175\u017e\u0207\u0000\u0000\u0000\u0000\u0000\u0000\u0000 !\"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\u0000\u00c7\u00fc\u00e9\u00e2\u00e4\u00e0\u00e5\u00e7\u00ea\u00eb\u00e8\u00ef\u00ee\u00ec\u00c4\u00c5\u00c9\u00e6\u00c6\u00f4\u00f6\u00f2\u00fb\u00f9\u00ff\u00d6\u00dc\u00f8\u00a3\u00d8\u00d7\u0192\u00e1\u00ed\u00f3\u00fa\u00f1\u00d1\u00aa\u00ba\u00bf\u00ae\u00ac\u00bd\u00bc\u00a1\u00ab\u00bb\u2591\u2592\u2593\u2502\u2524\u2561\u2562\u2556\u2555\u2563\u2551\u2557\u255d\u255c\u255b\u2510\u2514\u2534\u252c\u251c\u2500\u253c\u255e\u255f\u255a\u2554\u2569\u2566\u2560\u2550\u256c\u2567\u2568\u2564\u2565\u2559\u2558\u2552\u2553\u256b\u256a\u2518\u250c\u2588\u2584\u258c\u2590\u2580\u03b1\u03b2\u0393\u03c0\u03a3\u03c3\u03bc\u03c4\u03a6\u0398\u03a9\u03b4\u221e\u2205\u2208\u2229\u2261\u00b1\u2265\u2264\u2320\u2321\u00f7\u2248\u00b0\u2219\u00b7\u221a\u207f\u00b2\u25a0\u0000".indexOf(p_78278_2_) != -1 && !this.unicodeFlag ? this.renderDefaultChar(p_78278_1_, p_78278_3_) : this.renderUnicodeChar(p_78278_2_, p_78278_3_)); } - protected float renderDefaultChar(int p_78266_1_, boolean p_78266_2_) - { - float f = (float)(p_78266_1_ % 16 * 8); - float f1 = (float)(p_78266_1_ / 16 * 8); + protected float renderDefaultChar(int p_78266_1_, boolean p_78266_2_) { + float f = (float) (p_78266_1_ % 16 * 8); + float f1 = (float) (p_78266_1_ / 16 * 8); float f2 = p_78266_2_ ? 1.0F : 0.0F; bindTexture(this.locationFontTexture); - float f3 = (float)this.charWidth[p_78266_1_] - 0.01F; + float f3 = (float) this.charWidth[p_78266_1_] - 0.01F; GL11.glBegin(GL11.GL_TRIANGLE_STRIP); GL11.glTexCoord2f(f / 128.0F, f1 / 128.0F); GL11.glVertex3f(this.posX + f2, this.posY, 0.0F); @@ -389,43 +343,36 @@ public class CustomOverlayLabel extends Gui implements IOverlayComponent { GL11.glTexCoord2f((f + f3 - 1.0F) / 128.0F, (f1 + 7.99F) / 128.0F); GL11.glVertex3f(this.posX + f3 - 1.0F - f2, this.posY + 7.99F, 0.0F); GL11.glEnd(); - return (float)this.charWidth[p_78266_1_]; + return (float) this.charWidth[p_78266_1_]; } - private ResourceLocation getUnicodePageLocation(int p_111271_1_) - { - if (unicodePageLocations[p_111271_1_] == null) - { - unicodePageLocations[p_111271_1_] = new ResourceLocation(String.format("textures/font/unicode_page_%02x.png", new Object[] {Integer.valueOf(p_111271_1_)})); + private ResourceLocation getUnicodePageLocation(int p_111271_1_) { + if (unicodePageLocations[p_111271_1_] == null) { + unicodePageLocations[p_111271_1_] = new ResourceLocation(String.format("textures/font/unicode_page_%02x.png", new Object[]{Integer.valueOf(p_111271_1_)})); } return unicodePageLocations[p_111271_1_]; } - private void loadGlyphTexture(int p_78257_1_) - { + private void loadGlyphTexture(int p_78257_1_) { bindTexture(this.getUnicodePageLocation(p_78257_1_)); } /** * Render a single Unicode character at current (posX,posY) location using one of the /font/glyph_XX.png files... */ - protected float renderUnicodeChar(char p_78277_1_, boolean p_78277_2_) - { - if (this.glyphWidth[p_78277_1_] == 0) - { + protected float renderUnicodeChar(char p_78277_1_, boolean p_78277_2_) { + if (this.glyphWidth[p_78277_1_] == 0) { return 0.0F; - } - else - { + } else { int i = p_78277_1_ / 256; this.loadGlyphTexture(i); int j = this.glyphWidth[p_78277_1_] >>> 4; int k = this.glyphWidth[p_78277_1_] & 15; - float f = (float)j; - float f1 = (float)(k + 1); - float f2 = (float)(p_78277_1_ % 16 * 16) + f; - float f3 = (float)((p_78277_1_ & 255) / 16 * 16); + float f = (float) j; + float f1 = (float) (k + 1); + float f2 = (float) (p_78277_1_ % 16 * 16) + f; + float f3 = (float) ((p_78277_1_ & 255) / 16 * 16); float f4 = f1 - f - 0.02F; float f5 = p_78277_2_ ? 1.0F : 0.0F; GL11.glBegin(GL11.GL_TRIANGLE_STRIP); @@ -442,26 +389,20 @@ public class CustomOverlayLabel extends Gui implements IOverlayComponent { } } - protected void setColor(float r, float g, float b, float a) - { + protected void setColor(float r, float g, float b, float a) { GL11.glColor4f(r, g, b, a); } - protected void bindTexture(ResourceLocation location) - { + protected void bindTexture(ResourceLocation location) { Minecraft.getMinecraft().renderEngine.bindTexture(location); } - private void readFontTexture() - { + private void readFontTexture() { BufferedImage bufferedimage; - try - { + try { bufferedimage = ImageIO.read(getResourceInputStream(this.locationFontTexture)); - } - catch (IOException ioexception) - { + } catch (IOException ioexception) { throw new RuntimeException(ioexception); } @@ -472,81 +413,65 @@ public class CustomOverlayLabel extends Gui implements IOverlayComponent { int k = j / 16; int l = i / 16; byte b0 = 1; - float f = 8.0F / (float)l; + float f = 8.0F / (float) l; int i1 = 0; - while (i1 < 256) - { + while (i1 < 256) { int j1 = i1 % 16; int k1 = i1 / 16; - if (i1 == 32) - { + if (i1 == 32) { this.charWidth[i1] = 3 + b0; } int l1 = l - 1; - while (true) - { - if (l1 >= 0) - { + while (true) { + if (l1 >= 0) { int i2 = j1 * l + l1; boolean flag = true; - for (int j2 = 0; j2 < k && flag; ++j2) - { + for (int j2 = 0; j2 < k && flag; ++j2) { int k2 = (k1 * l + j2) * i; - if ((aint[i2 + k2] >> 24 & 255) != 0) - { + if ((aint[i2 + k2] >> 24 & 255) != 0) { flag = false; } } - if (flag) - { + if (flag) { --l1; continue; } } ++l1; - this.charWidth[i1] = (int)(0.5D + (double)((float)l1 * f)) + b0; + this.charWidth[i1] = (int) (0.5D + (double) ((float) l1 * f)) + b0; ++i1; break; } } } - private void readGlyphSizes() - { - try - { + private void readGlyphSizes() { + try { InputStream inputstream = getResourceInputStream(new ResourceLocation("font/glyph_sizes.bin")); inputstream.read(this.glyphWidth); - } - catch (IOException ioexception) - { + } catch (IOException ioexception) { throw new RuntimeException(ioexception); } } - protected InputStream getResourceInputStream(ResourceLocation location) throws IOException - { + protected InputStream getResourceInputStream(ResourceLocation location) throws IOException { return Minecraft.getMinecraft().getResourceManager().getResource(location).getInputStream(); } - private String bidiReorder(String p_147647_1_) - { - try - { + private String bidiReorder(String p_147647_1_) { + try { Bidi bidi = new Bidi((new ArabicShaping(8)).shape(p_147647_1_), 127); bidi.setReorderingMode(0); return bidi.writeReordered(2); - } - catch (ArabicShapingException arabicshapingexception) - { + } catch (ArabicShapingException arabicshapingexception) { return p_147647_1_; } } diff --git a/src/main/java/noppes/npcs/client/gui/customoverlay/components/CustomOverlayLine.java b/src/main/java/noppes/npcs/client/gui/customoverlay/components/CustomOverlayLine.java index 69e917f3b..999a41495 100644 --- a/src/main/java/noppes/npcs/client/gui/customoverlay/components/CustomOverlayLine.java +++ b/src/main/java/noppes/npcs/client/gui/customoverlay/components/CustomOverlayLine.java @@ -24,7 +24,7 @@ public class CustomOverlayLine extends Gui implements IOverlayComponent { float alpha; float rotation; - public CustomOverlayLine(int id, int x1, int y1, int x2, int y2, int color, int thickness){ + public CustomOverlayLine(int id, int x1, int y1, int x2, int y2, int color, int thickness) { this.id = id; this.x1 = x1; this.y1 = y1; @@ -43,44 +43,44 @@ public class CustomOverlayLine extends Gui implements IOverlayComponent { } public void onRender(Minecraft mc, float partialTicks) { - double distance = Math.hypot(x1-x2, y1-y2); + double distance = Math.hypot(x1 - x2, y1 - y2); mc.getTextureManager().bindTexture(new ResourceLocation("customnpcs:textures/gui/misc.png")); GL11.glPushMatrix(); - float red = (color >> 16 & 255) / 255f; - float green = (color >> 8 & 255) / 255f; - float blue = (color & 255) / 255f; + float red = (color >> 16 & 255) / 255f; + float green = (color >> 8 & 255) / 255f; + float blue = (color & 255) / 255f; - GL11.glTranslatef(this.alignment%3*((float)(OverlayCustom.scaledWidth)/2), (float) (Math.floor((float)(alignment/3))*((float)(OverlayCustom.scaledHeight)/2)),0.0F);//alignment%3 * width/2 Math.floor(alignment/3) * height/2 - GL11.glTranslatef(this.x1,this.y1, (float) this.id); + GL11.glTranslatef(this.alignment % 3 * ((float) (OverlayCustom.scaledWidth) / 2), (float) (Math.floor((float) (alignment / 3)) * ((float) (OverlayCustom.scaledHeight) / 2)), 0.0F);//alignment%3 * width/2 Math.floor(alignment/3) * height/2 + GL11.glTranslatef(this.x1, this.y1, (float) this.id); - GL11.glRotated(-Math.toDegrees(Math.atan2(x2-x1,y2-y1)),0.0F,0.0F,1.0F); - GL11.glRotated(rotation,0.0D,0.0D,1.0D); - GL11.glScaled(thickness, distance,0.0D); + GL11.glRotated(-Math.toDegrees(Math.atan2(x2 - x1, y2 - y1)), 0.0F, 0.0F, 1.0F); + GL11.glRotated(rotation, 0.0D, 0.0D, 1.0D); + GL11.glScaled(thickness, distance, 0.0D); - int p_73729_1_ = 0; - int p_73729_2_ = 0; - int p_73729_3_ = 0; - int p_73729_4_ = 0; - int p_73729_5_ = 1; - int p_73729_6_ = 1; + int p_73729_1_ = 0; + int p_73729_2_ = 0; + int p_73729_3_ = 0; + int p_73729_4_ = 0; + int p_73729_5_ = 1; + int p_73729_6_ = 1; - float f = 0.00390625F; - float f1 = 0.00390625F; - Tessellator tessellator = Tessellator.instance; - tessellator.startDrawingQuads(); - tessellator.setColorOpaque_F(1, 1, 1); - tessellator.setColorRGBA_F(red, green, blue, alpha); - tessellator.addVertexWithUV((double)(p_73729_1_ + 0), (double)(p_73729_2_ + p_73729_6_), (double)this.zLevel, (double)((float)(p_73729_3_ + 0) * f), (double)((float)(p_73729_4_ + p_73729_6_) * f1)); - tessellator.addVertexWithUV((double)(p_73729_1_ + p_73729_5_), (double)(p_73729_2_ + p_73729_6_), (double)this.zLevel, (double)((float)(p_73729_3_ + p_73729_5_) * f), (double)((float)(p_73729_4_ + p_73729_6_) * f1)); - tessellator.addVertexWithUV((double)(p_73729_1_ + p_73729_5_), (double)(p_73729_2_ + 0), (double)this.zLevel, (double)((float)(p_73729_3_ + p_73729_5_) * f), (double)((float)(p_73729_4_ + 0) * f1)); - tessellator.addVertexWithUV((double)(p_73729_1_ + 0), (double)(p_73729_2_ + 0), (double)this.zLevel, (double)((float)(p_73729_3_ + 0) * f), (double)((float)(p_73729_4_ + 0) * f1)); - tessellator.draw(); + float f = 0.00390625F; + float f1 = 0.00390625F; + Tessellator tessellator = Tessellator.instance; + tessellator.startDrawingQuads(); + tessellator.setColorOpaque_F(1, 1, 1); + tessellator.setColorRGBA_F(red, green, blue, alpha); + tessellator.addVertexWithUV((double) (p_73729_1_ + 0), (double) (p_73729_2_ + p_73729_6_), (double) this.zLevel, (double) ((float) (p_73729_3_ + 0) * f), (double) ((float) (p_73729_4_ + p_73729_6_) * f1)); + tessellator.addVertexWithUV((double) (p_73729_1_ + p_73729_5_), (double) (p_73729_2_ + p_73729_6_), (double) this.zLevel, (double) ((float) (p_73729_3_ + p_73729_5_) * f), (double) ((float) (p_73729_4_ + p_73729_6_) * f1)); + tessellator.addVertexWithUV((double) (p_73729_1_ + p_73729_5_), (double) (p_73729_2_ + 0), (double) this.zLevel, (double) ((float) (p_73729_3_ + p_73729_5_) * f), (double) ((float) (p_73729_4_ + 0) * f1)); + tessellator.addVertexWithUV((double) (p_73729_1_ + 0), (double) (p_73729_2_ + 0), (double) this.zLevel, (double) ((float) (p_73729_3_ + 0) * f), (double) ((float) (p_73729_4_ + 0) * f1)); + tessellator.draw(); GL11.glPopMatrix(); } public ICustomOverlayComponent toComponent() { - ScriptOverlayLine line = new ScriptOverlayLine(this.id, this.x1,this.y1,this.x2,this.y2,this.color,this.thickness); + ScriptOverlayLine line = new ScriptOverlayLine(this.id, this.x1, this.y1, this.x2, this.y2, this.color, this.thickness); line.setAlignment(alignment); line.setAlpha(alpha); line.setColor(color); diff --git a/src/main/java/noppes/npcs/client/gui/customoverlay/components/CustomOverlayTexturedRect.java b/src/main/java/noppes/npcs/client/gui/customoverlay/components/CustomOverlayTexturedRect.java index 1dd320a13..31461b77f 100644 --- a/src/main/java/noppes/npcs/client/gui/customoverlay/components/CustomOverlayTexturedRect.java +++ b/src/main/java/noppes/npcs/client/gui/customoverlay/components/CustomOverlayTexturedRect.java @@ -58,10 +58,10 @@ public class CustomOverlayTexturedRect extends Gui implements IOverlayComponent this.textureX = textureX; this.textureY = textureY; - if(directory.startsWith("https://")){ + if (directory.startsWith("https://")) { this.isUrl = true; TextureManager texturemanager = Minecraft.getMinecraft().getTextureManager(); - this.imageDownloadAlt = new ImageDownloadAlt(null, directory, new ResourceLocation("customnpcs:textures/gui/invisible.png"), new ImageBufferDownloadAlt(true,false)); + this.imageDownloadAlt = new ImageDownloadAlt(null, directory, new ResourceLocation("customnpcs:textures/gui/invisible.png"), new ImageBufferDownloadAlt(true, false)); texturemanager.loadTexture(this.location, this.imageDownloadAlt); } else { try { @@ -83,36 +83,36 @@ public class CustomOverlayTexturedRect extends Gui implements IOverlayComponent public void onRender(Minecraft mc, float partialTicks) { mc.getTextureManager().bindTexture(this.location); - float u1 = (float)textureX/(float)totalWidth; - float u2 = u1 + (float)width/(float)totalWidth; - float v1 = (float)textureY/(float)totalHeight; - float v2 = v1 + (float)height/(float)totalHeight; + float u1 = (float) textureX / (float) totalWidth; + float u2 = u1 + (float) width / (float) totalWidth; + float v1 = (float) textureY / (float) totalHeight; + float v2 = v1 + (float) height / (float) totalHeight; - if(imageDownloadAlt != null && isUrl && !gotWidthHeight){ + if (imageDownloadAlt != null && isUrl && !gotWidthHeight) { getURLWidthHeight(); } GL11.glPushMatrix(); - float red = (color >> 16 & 255) / 255f; - float green = (color >> 8 & 255) / 255f; - float blue = (color & 255) / 255f; + float red = (color >> 16 & 255) / 255f; + float green = (color >> 8 & 255) / 255f; + float blue = (color & 255) / 255f; - GL11.glTranslatef(this.alignment%3*((float)(OverlayCustom.scaledWidth)/2), (float) (Math.floor((float)(alignment/3))*((float)(OverlayCustom.scaledHeight)/2)),0.0F); - GL11.glTranslatef( this.x - u1 * totalWidth, this.y - v1 * totalHeight,(float)this.id); + GL11.glTranslatef(this.alignment % 3 * ((float) (OverlayCustom.scaledWidth) / 2), (float) (Math.floor((float) (alignment / 3)) * ((float) (OverlayCustom.scaledHeight) / 2)), 0.0F); + GL11.glTranslatef(this.x - u1 * totalWidth, this.y - v1 * totalHeight, (float) this.id); - GL11.glScalef(this.scale, this.scale, this.scale); + GL11.glScalef(this.scale, this.scale, this.scale); - GL11.glRotatef(this.rotation,0.0F,0.0F,1.0F); + GL11.glRotatef(this.rotation, 0.0F, 0.0F, 1.0F); - Tessellator tessellator = Tessellator.instance; - tessellator.startDrawingQuads(); - tessellator.setColorOpaque_F(1, 1, 1); - tessellator.setColorRGBA_F(red, green, blue, alpha); - tessellator.addVertexWithUV( u2 * totalWidth, v2 * totalHeight, 0, u2, v2); - tessellator.addVertexWithUV( u2 * totalWidth, v1 * totalHeight, 0, u2, v1); - tessellator.addVertexWithUV( u1 * totalWidth, v1 * totalHeight, 0, u1, v1); - tessellator.addVertexWithUV( u1 * totalWidth, v2 * totalHeight, 0, u1, v2); - tessellator.draw(); + Tessellator tessellator = Tessellator.instance; + tessellator.startDrawingQuads(); + tessellator.setColorOpaque_F(1, 1, 1); + tessellator.setColorRGBA_F(red, green, blue, alpha); + tessellator.addVertexWithUV(u2 * totalWidth, v2 * totalHeight, 0, u2, v2); + tessellator.addVertexWithUV(u2 * totalWidth, v1 * totalHeight, 0, u2, v1); + tessellator.addVertexWithUV(u1 * totalWidth, v1 * totalHeight, 0, u1, v1); + tessellator.addVertexWithUV(u1 * totalWidth, v2 * totalHeight, 0, u1, v2); + tessellator.draw(); GL11.glPopMatrix(); } @@ -163,8 +163,8 @@ public class CustomOverlayTexturedRect extends Gui implements IOverlayComponent } } - public void getURLWidthHeight(){ - if(imageDownloadAlt.getBufferedImage() != null) { + public void getURLWidthHeight() { + if (imageDownloadAlt.getBufferedImage() != null) { gotWidthHeight = true; this.totalWidth = imageDownloadAlt.getBufferedImage().getWidth(); this.totalHeight = imageDownloadAlt.getBufferedImage().getHeight(); @@ -172,7 +172,7 @@ public class CustomOverlayTexturedRect extends Gui implements IOverlayComponent } } - public void correctWidthHeight(){ + public void correctWidthHeight() { totalWidth = Math.max(totalWidth, 1); totalHeight = Math.max(totalHeight, 1); this.width = width < 0 ? totalWidth : width; diff --git a/src/main/java/noppes/npcs/client/gui/global/GuiNPCEditAnimation.java b/src/main/java/noppes/npcs/client/gui/global/GuiNPCEditAnimation.java index 45a965194..ea7343682 100644 --- a/src/main/java/noppes/npcs/client/gui/global/GuiNPCEditAnimation.java +++ b/src/main/java/noppes/npcs/client/gui/global/GuiNPCEditAnimation.java @@ -76,8 +76,8 @@ public class GuiNPCEditAnimation extends GuiModelInterface implements ITextfield Frame editingFrame = this.editingFrame(); if (editingFrame != null) { if (editingFrame != prevFrame && prevFrame != null) { - HashMap frameParts = prevFrame.frameParts; - for (Map.Entry entry : frameParts.entrySet()) { + HashMap frameParts = prevFrame.frameParts; + for (Map.Entry entry : frameParts.entrySet()) { if (editingFrame.frameParts.containsKey(entry.getKey())) { FramePart part = editingFrame.frameParts.get(entry.getKey()); FramePart prevPart = prevFrame.frameParts.get(entry.getKey()); @@ -109,7 +109,7 @@ public class GuiNPCEditAnimation extends GuiModelInterface implements ITextfield frame.speed = animation.speed; frame.smooth = animation.smooth; } - for (Map.Entry entry : frame.frameParts.entrySet()) { + for (Map.Entry entry : frame.frameParts.entrySet()) { FramePart part = entry.getValue(); part.parent = animation; if (!part.isCustomized()) { @@ -178,7 +178,7 @@ public class GuiNPCEditAnimation extends GuiModelInterface implements ITextfield this.addLabel(new GuiNpcLabel(31, "stats.speed", guiLeft + animationX, guiTop + animationY + 24, 0xFFFFFF)); this.addTextField(new GuiNpcTextField(31, this, guiLeft + animationX + 88, guiTop + animationY + 22, 30, 15, animation.speed + "")); this.getTextField(31).floatsOnly = true; - this.getTextField(31).setMinMaxDefaultFloat(0,Float.MAX_VALUE,1.0F); + this.getTextField(31).setMinMaxDefaultFloat(0, Float.MAX_VALUE, 1.0F); // //smooth - button this.addLabel(new GuiNpcLabel(32, "animation.smoothing", guiLeft + animationX, guiTop + animationY + 46, 0xFFFFFF)); @@ -188,7 +188,7 @@ public class GuiNPCEditAnimation extends GuiModelInterface implements ITextfield this.addLabel(new GuiNpcLabel(33, "animation.loop", guiLeft + animationX, guiTop + animationY + 68, 0xFFFFFF)); this.addButton(new GuiNpcButton(33, guiLeft + animationX + 55, guiTop + animationY + 62, 65, 20, animation.loop == -1 ? "gui.none" : "Frame " + animation.loop)); - this.addButton(new GuiNpcButton(34,guiLeft + animationX, guiTop + animationY + 84, 120, 20, "animation.animationOptions")); + this.addButton(new GuiNpcButton(34, guiLeft + animationX, guiTop + animationY + 84, 120, 20, "animation.animationOptions")); //--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- @@ -206,8 +206,8 @@ public class GuiNPCEditAnimation extends GuiModelInterface implements ITextfield this.getTextField(51).integersOnly = true; this.getTextField(51).setMinMaxDefaultFloat(0, Integer.MAX_VALUE, 10); - this.addButton(new GuiNpcButton(52,guiLeft + frameX, guiTop + frameY + 31 , 80, 20, "animation.frameOptions")); - this.addButton(new GuiNpcButton(53,guiLeft + frameX + getButton(52).width + 5, guiTop + frameY + 31 , 35, 20, "gui.color")); + this.addButton(new GuiNpcButton(52, guiLeft + frameX, guiTop + frameY + 31, 80, 20, "animation.frameOptions")); + this.addButton(new GuiNpcButton(53, guiLeft + frameX + getButton(52).width + 5, guiTop + frameY + 31, 35, 20, "gui.color")); int bodyPartX = 280; int bodyPartY = -5; @@ -221,19 +221,19 @@ public class GuiNPCEditAnimation extends GuiModelInterface implements ITextfield // //Head - this.addButton(new GuiTexturedButton(60, "",guiLeft + bodyPartX, guiTop + bodyPartY,22,23, animTexture,0,0)); + this.addButton(new GuiTexturedButton(60, "", guiLeft + bodyPartX, guiTop + bodyPartY, 22, 23, animTexture, 0, 0)); //Body - this.addButton(new GuiTexturedButton(61, "",guiLeft + bodyPartX, guiTop + bodyPartY + 23,22,23, animTexture,24,0)); + this.addButton(new GuiTexturedButton(61, "", guiLeft + bodyPartX, guiTop + bodyPartY + 23, 22, 23, animTexture, 24, 0)); //Right Arm - this.addButton(new GuiTexturedButton(62, "",guiLeft + bodyPartX - 9, guiTop + bodyPartY + 23,8,23, animTexture,48,0)); + this.addButton(new GuiTexturedButton(62, "", guiLeft + bodyPartX - 9, guiTop + bodyPartY + 23, 8, 23, animTexture, 48, 0)); //Left Arm - this.addButton(new GuiTexturedButton(63, "",guiLeft + bodyPartX + 26, guiTop + bodyPartY + 23,8,23, animTexture,48,0)); + this.addButton(new GuiTexturedButton(63, "", guiLeft + bodyPartX + 26, guiTop + bodyPartY + 23, 8, 23, animTexture, 48, 0)); //Right Leg - this.addButton(new GuiTexturedButton(64, "",guiLeft + bodyPartX + 1, guiTop + bodyPartY + 48,10,23, animTexture,58,0)); + this.addButton(new GuiTexturedButton(64, "", guiLeft + bodyPartX + 1, guiTop + bodyPartY + 48, 10, 23, animTexture, 58, 0)); //Left Leg - this.addButton(new GuiTexturedButton(65, "",guiLeft + bodyPartX + 12, guiTop + bodyPartY + 48,10,23, animTexture,58,0)); + this.addButton(new GuiTexturedButton(65, "", guiLeft + bodyPartX + 12, guiTop + bodyPartY + 48, 10, 23, animTexture, 58, 0)); //Full Body - this.addButton(new GuiTexturedButton(66, "",guiLeft + bodyPartX + 40, guiTop + bodyPartY + 2,17,23, animTexture,70,0)); + this.addButton(new GuiTexturedButton(66, "", guiLeft + bodyPartX + 40, guiTop + bodyPartY + 2, 17, 23, animTexture, 70, 0)); for (int i = 0; i < 7; i++) { if (this.buttons.containsKey(60 + i)) { @@ -253,7 +253,7 @@ public class GuiNPCEditAnimation extends GuiModelInterface implements ITextfield this.addLabel(new GuiNpcLabel(67, editingPart.part.name(), guiLeft + bodyPartX + 65, guiTop + bodyPartY + 20, 0xFFFFFF)); this.addButton(new GuiNpcButton(67, guiLeft + bodyPartX + 45, guiTop + bodyPartY + 35, 60, 20, "gui.remove")); - this.addButton(new GuiNpcButton(68, guiLeft + bodyPartX + 45, guiTop + bodyPartY + 57, 60, 20, new String[] {"model.sliders","model.manual"}, partEditMode)); + this.addButton(new GuiNpcButton(68, guiLeft + bodyPartX + 45, guiTop + bodyPartY + 57, 60, 20, new String[]{"model.sliders", "model.manual"}, partEditMode)); if (partEditMode == 0) { this.addButton(new GuiNpcButton(69, guiLeft + bodyPartX, guiTop + bodyPartY + 80, 60, 20, "model.rotate")); @@ -262,14 +262,14 @@ public class GuiNPCEditAnimation extends GuiModelInterface implements ITextfield this.getButton(69).setEnabled(sliderSelection == 1); this.getButton(70).setEnabled(sliderSelection == 0); - if(sliderSelection == 0){ + if (sliderSelection == 0) { for (int i = 0; i < 3; i++) { this.rotationSliders[i].width = 122; - this.rotationSliders[i].height= 20; + this.rotationSliders[i].height = 20; this.rotationSliders[i].xPosition = guiLeft + bodyPartX; int yOffset = 20; - if(i != 0) + if (i != 0) yOffset += 3; yOffset *= i; this.rotationSliders[i].yPosition = guiTop + bodyPartY + 105 + yOffset; @@ -280,15 +280,14 @@ public class GuiNPCEditAnimation extends GuiModelInterface implements ITextfield this.addLabel(new GuiNpcLabel(90, "X", guiLeft + bodyPartX - 10, guiTop + bodyPartY + 112, 0xFFFFFF)); this.addLabel(new GuiNpcLabel(91, "Y", guiLeft + bodyPartX - 10, guiTop + bodyPartY + 135, 0xFFFFFF)); this.addLabel(new GuiNpcLabel(92, "Z", guiLeft + bodyPartX - 10, guiTop + bodyPartY + 157, 0xFFFFFF)); - } - else { + } else { for (int i = 0; i < 3; i++) { this.pivotSliders[i].width = 122; this.pivotSliders[i].height = 20; this.pivotSliders[i].xPosition = guiLeft + bodyPartX; int yOffset = 20; - if(i != 0) + if (i != 0) yOffset += 3; yOffset *= i; this.pivotSliders[i].yPosition = guiTop + bodyPartY + 105 + yOffset; @@ -393,11 +392,11 @@ public class GuiNPCEditAnimation extends GuiModelInterface implements ITextfield } @Override - protected void actionPerformed(GuiButton guibutton){ + protected void actionPerformed(GuiButton guibutton) { super.actionPerformed(guibutton); Frame editingFrame = this.editingFrame(); FramePart part = this.editingPart(); - int value = guibutton instanceof GuiNpcButton ? ((GuiNpcButton)guibutton).getValue() : 0; + int value = guibutton instanceof GuiNpcButton ? ((GuiNpcButton) guibutton).getValue() : 0; AnimationData data = npc.display.animationData; if (guibutton.id == 11) { @@ -423,7 +422,7 @@ public class GuiNPCEditAnimation extends GuiModelInterface implements ITextfield frameIndex++; overrideFrame = true; } else if (guibutton.id >= 60 && guibutton.id <= 66) {//Animation part buttons - EnumAnimationPart enumPart = EnumAnimationPart.values()[guibutton.id-60]; + EnumAnimationPart enumPart = EnumAnimationPart.values()[guibutton.id - 60]; if (editingFrame != null && !editingFrame.frameParts.containsKey(enumPart)) { FramePart framePart = new FramePart(enumPart); framePart.prevRotations = new float[]{0, 0, 0}; @@ -437,13 +436,13 @@ public class GuiNPCEditAnimation extends GuiModelInterface implements ITextfield partEditMode++; partEditMode %= 2; this.updateSliders(); - } else if (guibutton.id == 69 && editingFrame != null) { + } else if (guibutton.id == 69 && editingFrame != null) { if (partEditMode == 1) { this.updateSliders(); } sliderSelection = 0; - } else if (guibutton.id == 70 && editingFrame != null) { + } else if (guibutton.id == 70 && editingFrame != null) { if (partEditMode == 1) { this.updateSliders(); } @@ -463,7 +462,7 @@ public class GuiNPCEditAnimation extends GuiModelInterface implements ITextfield animation.currentFrameTime = 0; for (Frame frame : animation.frames) { for (FramePart framePart : frame.frameParts.values()) { - framePart.prevRotations = new float[]{0,0,0}; + framePart.prevRotations = new float[]{0, 0, 0}; framePart.prevPivots = new float[]{0, 0, 0}; } } @@ -510,9 +509,8 @@ public class GuiNPCEditAnimation extends GuiModelInterface implements ITextfield } @Override - public void drawScreen(int par1, int par2, float par3) - { - super.drawScreen(par1,par2,par3); + public void drawScreen(int par1, int par2, float par3) { + super.drawScreen(par1, par2, par3); AnimationData data = npc.display.animationData; if (!data.isActive() && this.playingAnimation) { this.playingAnimation = false; @@ -523,7 +521,7 @@ public class GuiNPCEditAnimation extends GuiModelInterface implements ITextfield GuiNpcLabel label = this.getLabel(213); if (label != null) { label.label += "."; - if (label.label.length()%4 == 0) { + if (label.label.length() % 4 == 0) { label.label = ""; } } @@ -542,7 +540,7 @@ public class GuiNPCEditAnimation extends GuiModelInterface implements ITextfield } else { button.color = this.animation.frames.get(sliderFrame).getColorMarker(); if ((sliderFrame == this.animation.currentFrame && this.playingAnimation) || sliderFrame == this.frameIndex) { - if((sliderFrame == this.animation.currentFrame && this.playingAnimation)){ + if ((sliderFrame == this.animation.currentFrame && this.playingAnimation)) { button.color = 0xfcf232; } else { button.color = 0x32a852; @@ -566,7 +564,7 @@ public class GuiNPCEditAnimation extends GuiModelInterface implements ITextfield animation.name = text.replaceAll("[^a-zA-Z0-9_-]", "_"); } else if (textfield.id == 15 && animation != null && animation.frames.size() > 0) { animation.frames.remove(frameIndex); - animation.frames.add(textfield.getInteger(),frame); + animation.frames.add(textfield.getInteger(), frame); frameIndex = textfield.getInteger(); overrideFrame = true; initGui(); @@ -577,10 +575,10 @@ public class GuiNPCEditAnimation extends GuiModelInterface implements ITextfield } else if (textfield.id == 51 && frame != null) { frame.duration = textfield.getInteger(); } else if (textfield.id >= 70 && textfield.id <= 73 && part != null) { - part.rotation[textfield.id-70] = textfield.getFloat(); + part.rotation[textfield.id - 70] = textfield.getFloat(); this.updateSliders(); } else if (textfield.id >= 80 && textfield.id <= 83 && part != null) { - part.pivot[textfield.id-80] = textfield.getFloat(); + part.pivot[textfield.id - 80] = textfield.getFloat(); this.updateSliders(); } } @@ -597,9 +595,9 @@ public class GuiNPCEditAnimation extends GuiModelInterface implements ITextfield } } - public void updateFrameSlider(){ + public void updateFrameSlider() { GuiNpcSlider guiNpcSlider = getSlider(350); - if(guiNpcSlider != null){ + if (guiNpcSlider != null) { int frameScroll = Math.max(0, this.animation.frames.size() - this.visibleFrames); this.frameOffset = Math.round(guiNpcSlider.sliderValue * frameScroll); guiNpcSlider.displayString = this.frameOffset + " to " + Math.min(this.animation.frames.size() - 1, this.frameOffset + this.visibleFrames - 1); @@ -624,7 +622,7 @@ public class GuiNPCEditAnimation extends GuiModelInterface implements ITextfield guiNpcSlider.setString(value + ""); } if (id >= 95 && id < 98) { - int value = (int)(100.0F * (guiNpcSlider.sliderValue - 0.5F)); + int value = (int) (100.0F * (guiNpcSlider.sliderValue - 0.5F)); guiNpcSlider.setString(value + ""); part.pivot[id - 95] = value; } diff --git a/src/main/java/noppes/npcs/client/gui/global/GuiNPCManageAnimations.java b/src/main/java/noppes/npcs/client/gui/global/GuiNPCManageAnimations.java index 81b24e3df..381c12f8a 100644 --- a/src/main/java/noppes/npcs/client/gui/global/GuiNPCManageAnimations.java +++ b/src/main/java/noppes/npcs/client/gui/global/GuiNPCManageAnimations.java @@ -24,18 +24,16 @@ import java.util.HashMap; import java.util.List; import java.util.Vector; -public class GuiNPCManageAnimations extends GuiModelInterface2 implements IScrollData,ICustomScrollListener,ITextfieldListener, IGuiData, ISubGuiListener, GuiYesNoCallback -{ +public class GuiNPCManageAnimations extends GuiModelInterface2 implements IScrollData, ICustomScrollListener, ITextfieldListener, IGuiData, ISubGuiListener, GuiYesNoCallback { private GuiCustomScroll scrollAnimations; - private HashMap data = new HashMap(); + private HashMap data = new HashMap(); private Animation animation = new Animation(); public boolean playingAnimation = false; private long prevTick; private String selected = null; private String search = ""; - public GuiNPCManageAnimations(EntityNPCInterface npc, boolean save) - { + public GuiNPCManageAnimations(EntityNPCInterface npc, boolean save) { super(npc); this.setSave(save); this.xOffset = -148 + 70; @@ -46,15 +44,14 @@ public class GuiNPCManageAnimations extends GuiModelInterface2 implements IScrol data.setEnabled(true); } - public void initGui() - { + public void initGui() { super.initGui(); - this.addButton(new GuiNpcButton(0,guiLeft + 368, guiTop + 8, 45, 20, "gui.add")); - this.addButton(new GuiNpcButton(1,guiLeft + 368, guiTop + 32, 45, 20, "gui.remove")); + this.addButton(new GuiNpcButton(0, guiLeft + 368, guiTop + 8, 45, 20, "gui.add")); + this.addButton(new GuiNpcButton(1, guiLeft + 368, guiTop + 32, 45, 20, "gui.remove")); - if(scrollAnimations == null){ - scrollAnimations = new GuiCustomScroll(this,0, 0); + if (scrollAnimations == null) { + scrollAnimations = new GuiCustomScroll(this, 0, 0); scrollAnimations.setSize(143, 185); } scrollAnimations.guiLeft = guiLeft + 220; @@ -65,7 +62,7 @@ public class GuiNPCManageAnimations extends GuiModelInterface2 implements IScrol if (animation.id == -1) return; - addLabel(new GuiNpcLabel(10,"ID", guiLeft + 368, guiTop + 192)); + addLabel(new GuiNpcLabel(10, "ID", guiLeft + 368, guiTop + 192)); addLabel(new GuiNpcLabel(11, animation.id + "", guiLeft + 368, guiTop + 192 + 10)); AnimationData data = npc.display.animationData; @@ -107,9 +104,8 @@ public class GuiNPCManageAnimations extends GuiModelInterface2 implements IScrol } @Override - public void drawScreen(int par1, int par2, float par3) - { - super.drawScreen(par1,par2,par3); + public void drawScreen(int par1, int par2, float par3) { + super.drawScreen(par1, par2, par3); AnimationData data = npc.display.animationData; if (!data.isActive() && this.playingAnimation) { this.playingAnimation = false; @@ -120,7 +116,7 @@ public class GuiNPCManageAnimations extends GuiModelInterface2 implements IScrol GuiNpcLabel label = this.getLabel(94); if (label != null) { label.label += "."; - if (label.label.length()%4 == 0) { + if (label.label.length() % 4 == 0) { label.label = ""; } } @@ -130,12 +126,11 @@ public class GuiNPCManageAnimations extends GuiModelInterface2 implements IScrol } @Override - public void keyTyped(char c, int i) - { + public void keyTyped(char c, int i) { super.keyTyped(c, i); - if(getTextField(55) != null){ - if(getTextField(55).isFocused()){ - if(search.equals(getTextField(55).getText())) + if (getTextField(55) != null) { + if (getTextField(55).isFocused()) { + if (search.equals(getTextField(55).getText())) return; search = getTextField(55).getText().toLowerCase(); scrollAnimations.resetScroll(); @@ -144,32 +139,32 @@ public class GuiNPCManageAnimations extends GuiModelInterface2 implements IScrol } } - private List getSearchList(){ - if(search.isEmpty()){ + private List getSearchList() { + if (search.isEmpty()) { return new ArrayList(this.data.keySet()); } List list = new ArrayList(); - for(String name : this.data.keySet()){ - if(name.toLowerCase().contains(search)) + for (String name : this.data.keySet()) { + if (name.toLowerCase().contains(search)) list.add(name); } return list; } @Override - protected void actionPerformed(GuiButton guibutton){ + protected void actionPerformed(GuiButton guibutton) { GuiNpcButton button = (GuiNpcButton) guibutton; - if(button.id == 0){ - save(); - String name = "New"; - while(data.containsKey(name)) - name += "_"; - Animation animation = new Animation(-1, name); + if (button.id == 0) { + save(); + String name = "New"; + while (data.containsKey(name)) + name += "_"; + Animation animation = new Animation(-1, name); PacketClient.sendClient(new AnimationSavePacket(animation.writeToNBT())); } - if(button.id == 1){ - if(data.containsKey(scrollAnimations.getSelected())) { + if (button.id == 1) { + if (data.containsKey(scrollAnimations.getSelected())) { GuiYesNo guiyesno = new GuiYesNo(this, scrollAnimations.getSelected(), StatCollector.translateToLocal("gui.delete"), 1); displayGuiScreen(guiyesno); } @@ -182,7 +177,7 @@ public class GuiNPCManageAnimations extends GuiModelInterface2 implements IScrol animation.currentFrameTime = 0; for (Frame frame : animation.frames) { for (FramePart framePart : frame.frameParts.values()) { - framePart.prevRotations = new float[]{0,0,0}; + framePart.prevRotations = new float[]{0, 0, 0}; framePart.prevPivots = new float[]{0, 0, 0}; } } @@ -221,7 +216,7 @@ public class GuiNPCManageAnimations extends GuiModelInterface2 implements IScrol this.data = data; scrollAnimations.setList(getSearchList()); - if(name != null) + if (name != null) scrollAnimations.setSelected(name); } @@ -231,29 +226,28 @@ public class GuiNPCManageAnimations extends GuiModelInterface2 implements IScrol scrollAnimations.setSelected(selected); } - @Override - public void customScrollClicked(int i, int j, int k, GuiCustomScroll guiCustomScroll) { - if(guiCustomScroll.id == 0) - { - selected = scrollAnimations.getSelected(); + @Override + public void customScrollClicked(int i, int j, int k, GuiCustomScroll guiCustomScroll) { + if (guiCustomScroll.id == 0) { + selected = scrollAnimations.getSelected(); PacketClient.sendClient(new AnimationGetPacket(data.get(selected))); - } - } + } + } - public void save() { - if(selected != null && data.containsKey(selected) && animation != null){ + public void save() { + if (selected != null && data.containsKey(selected) && animation != null) { PacketClient.sendClient(new AnimationSavePacket(animation.writeToNBT())); - } - } + } + } @Override public void unFocused(GuiNpcTextField guiNpcTextField) { - if(animation.id == -1) + if (animation.id == -1) return; - if(guiNpcTextField.id == 0) { + if (guiNpcTextField.id == 0) { String name = guiNpcTextField.getText(); - if(!name.isEmpty() && !data.containsKey(name)){ + if (!name.isEmpty() && !data.containsKey(name)) { String old = animation.name; data.remove(animation.name); animation.name = name; @@ -265,15 +259,16 @@ public class GuiNPCManageAnimations extends GuiModelInterface2 implements IScrol } @Override - public void subGuiClosed(SubGuiInterface subgui) {} + public void subGuiClosed(SubGuiInterface subgui) { + } @Override public void confirmClicked(boolean result, int id) { NoppesUtil.openGUI(player, this); - if(!result) + if (!result) return; - if(id == 1) { - if(data.containsKey(scrollAnimations.getSelected())) { + if (id == 1) { + if (data.containsKey(scrollAnimations.getSelected())) { PacketClient.sendClient(new AnimationRemovePacket(data.get(selected))); scrollAnimations.clear(); animation = new Animation(); diff --git a/src/main/java/noppes/npcs/client/gui/global/GuiNPCManageBanks.java b/src/main/java/noppes/npcs/client/gui/global/GuiNPCManageBanks.java index b08e9ccdc..ee3cf3f35 100644 --- a/src/main/java/noppes/npcs/client/gui/global/GuiNPCManageBanks.java +++ b/src/main/java/noppes/npcs/client/gui/global/GuiNPCManageBanks.java @@ -19,233 +19,219 @@ import java.util.HashMap; import java.util.List; import java.util.Vector; -public class GuiNPCManageBanks extends GuiContainerNPCInterface2 implements IScrollData,ICustomScrollListener,ITextfieldListener, IGuiData -{ - private GuiCustomScroll scroll; - private HashMap data = new HashMap(); - private ContainerManageBanks container; - private Bank bank = new Bank(); - private String selected = null; - private String search = ""; +public class GuiNPCManageBanks extends GuiContainerNPCInterface2 implements IScrollData, ICustomScrollListener, ITextfieldListener, IGuiData { + private GuiCustomScroll scroll; + private HashMap data = new HashMap(); + private ContainerManageBanks container; + private Bank bank = new Bank(); + private String selected = null; + private String search = ""; - public GuiNPCManageBanks(EntityNPCInterface npc,ContainerManageBanks container) - { - super(npc,container); - this.container = container; - drawDefaultBackground = false; + public GuiNPCManageBanks(EntityNPCInterface npc, ContainerManageBanks container) { + super(npc, container); + this.container = container; + drawDefaultBackground = false; PacketClient.sendClient(new BanksGetPacket()); - setBackground("npcbanksetup.png"); - ySize = 200; + setBackground("npcbanksetup.png"); + ySize = 200; } - public void initGui() - { + public void initGui() { super.initGui(); - this.addButton(new GuiNpcButton(6,guiLeft + 340, guiTop + 10, 45, 20, "gui.add")); - this.addButton(new GuiNpcButton(7,guiLeft + 340, guiTop + 32, 45, 20, "gui.remove")); - if(scroll == null) - scroll = new GuiCustomScroll(this,0,0); - scroll.setSize(160, 180); - scroll.guiLeft = guiLeft + 174; - scroll.guiTop = guiTop + 8; - addScroll(scroll); + this.addButton(new GuiNpcButton(6, guiLeft + 340, guiTop + 10, 45, 20, "gui.add")); + this.addButton(new GuiNpcButton(7, guiLeft + 340, guiTop + 32, 45, 20, "gui.remove")); + if (scroll == null) + scroll = new GuiCustomScroll(this, 0, 0); + scroll.setSize(160, 180); + scroll.guiLeft = guiLeft + 174; + scroll.guiTop = guiTop + 8; + addScroll(scroll); - for(int i = 0; i < 6; i++){ - int x = guiLeft + 6; - int y = (guiTop + 36) + (i * 22); - addButton(new GuiNpcButton(i, x + 50, y,80, 20, new String[]{"Can Upgrade","Can't Upgrade","Upgraded"},0)); + for (int i = 0; i < 6; i++) { + int x = guiLeft + 6; + int y = (guiTop + 36) + (i * 22); + addButton(new GuiNpcButton(i, x + 50, y, 80, 20, new String[]{"Can Upgrade", "Can't Upgrade", "Upgraded"}, 0)); getButton(i).setEnabled(false); } - addTextField(new GuiNpcTextField(0,this, this.fontRendererObj, guiLeft+8, guiTop + 8, 160, 16, "")); + addTextField(new GuiNpcTextField(0, this, this.fontRendererObj, guiLeft + 8, guiTop + 8, 160, 16, "")); getTextField(0).setMaxStringLength(20); - addTextField(new GuiNpcTextField(1,this, this.fontRendererObj, guiLeft+10, guiTop + 80, 16, 16, "")); + addTextField(new GuiNpcTextField(1, this, this.fontRendererObj, guiLeft + 10, guiTop + 80, 16, 16, "")); getTextField(1).integersOnly = true; getTextField(1).setMaxStringLength(1); - addTextField(new GuiNpcTextField(2,this, this.fontRendererObj, guiLeft+10, guiTop + 110, 16, 16, "")); + addTextField(new GuiNpcTextField(2, this, this.fontRendererObj, guiLeft + 10, guiTop + 110, 16, 16, "")); getTextField(2).integersOnly = true; getTextField(2).setMaxStringLength(1); - addTextField(new GuiNpcTextField(33, this, fontRendererObj, guiLeft + 174, guiTop + 8 + 3 + 180, 160, 20, search)); + addTextField(new GuiNpcTextField(33, this, fontRendererObj, guiLeft + 174, guiTop + 8 + 3 + 180, 160, 20, search)); } - public void drawScreen(int x, int y, float f) - { + public void drawScreen(int x, int y, float f) { super.drawScreen(x, y, f); } - @Override - protected void actionPerformed(GuiButton guibutton) - { - GuiNpcButton button = (GuiNpcButton) guibutton; - if(button.id == 6) - { - save(); - scroll.clear(); - String name = "New"; - while(data.containsKey(name)) - name += "_"; - Bank bank = new Bank(); - bank.name = name; - NBTTagCompound compound = new NBTTagCompound(); - bank.writeEntityToNBT(compound); + @Override + protected void actionPerformed(GuiButton guibutton) { + GuiNpcButton button = (GuiNpcButton) guibutton; + if (button.id == 6) { + save(); + scroll.clear(); + String name = "New"; + while (data.containsKey(name)) + name += "_"; + Bank bank = new Bank(); + bank.name = name; + + NBTTagCompound compound = new NBTTagCompound(); + bank.writeEntityToNBT(compound); PacketClient.sendClient(new BankSavePacket(compound)); - } - else if(button.id == 7) - { - if(data.containsKey(scroll.getSelected())) + } else if (button.id == 7) { + if (data.containsKey(scroll.getSelected())) PacketClient.sendClient(new BankRemovePacket(data.get(selected))); - } - else if(button.id >= 0 && button.id < 6) - { - bank.slotTypes.put(button.id, button.getValue()); + } else if (button.id >= 0 && button.id < 6) { + bank.slotTypes.put(button.id, button.getValue()); } } @Override - protected void drawGuiContainerForegroundLayer(int par1, int par2) - { - fontRendererObj.drawString("Tab Cost", 23, 28, CustomNpcResourceListener.DefaultTextColor); - fontRendererObj.drawString("Upg. Cost", 123, 28, CustomNpcResourceListener.DefaultTextColor); - fontRendererObj.drawString("Start", 6, 70, CustomNpcResourceListener.DefaultTextColor); - fontRendererObj.drawString("Max", 9, 100, CustomNpcResourceListener.DefaultTextColor); + protected void drawGuiContainerForegroundLayer(int par1, int par2) { + fontRendererObj.drawString("Tab Cost", 23, 28, CustomNpcResourceListener.DefaultTextColor); + fontRendererObj.drawString("Upg. Cost", 123, 28, CustomNpcResourceListener.DefaultTextColor); + fontRendererObj.drawString("Start", 6, 70, CustomNpcResourceListener.DefaultTextColor); + fontRendererObj.drawString("Max", 9, 100, CustomNpcResourceListener.DefaultTextColor); } - @Override - public void setGuiData(NBTTagCompound compound) { - Bank bank = new Bank(); - bank.readEntityFromNBT(compound); - this.bank = bank; + @Override + public void setGuiData(NBTTagCompound compound) { + Bank bank = new Bank(); + bank.readEntityFromNBT(compound); + this.bank = bank; - if (bank.id == -1) { - getTextField(0).setText(""); - getTextField(1).setText(""); - getTextField(2).setText(""); + if (bank.id == -1) { + getTextField(0).setText(""); + getTextField(1).setText(""); + getTextField(2).setText(""); - for(int i = 0; i < 6; i++) - { - getButton(i).setDisplay(0); - getButton(i).setEnabled(false); - } - } else { - getTextField(0).setText(bank.name); - getTextField(1).setText(Integer.toString(bank.startSlots)); - getTextField(2).setText(Integer.toString(bank.maxSlots)); + for (int i = 0; i < 6; i++) { + getButton(i).setDisplay(0); + getButton(i).setEnabled(false); + } + } else { + getTextField(0).setText(bank.name); + getTextField(1).setText(Integer.toString(bank.startSlots)); + getTextField(2).setText(Integer.toString(bank.maxSlots)); - for(int i = 0; i < 6; i++) - { - int type = 0; - if(bank.slotTypes.containsKey(i)) - type = bank.slotTypes.get(i); - getButton(i).setDisplay(type); - getButton(i).setEnabled(true); - } - } - setSelected(bank.name); - } + for (int i = 0; i < 6; i++) { + int type = 0; + if (bank.slotTypes.containsKey(i)) + type = bank.slotTypes.get(i); + getButton(i).setDisplay(type); + getButton(i).setEnabled(true); + } + } + setSelected(bank.name); + } - public void keyTyped(char c, int i) - { - super.keyTyped(c, i); - if(getTextField(33) != null){ - if(getTextField(33).isFocused()){ - if(search.equals(getTextField(33).getText())) - return; - search = getTextField(33).getText().toLowerCase(); - scroll.setList(getSearchList()); - } - } - } + public void keyTyped(char c, int i) { + super.keyTyped(c, i); + if (getTextField(33) != null) { + if (getTextField(33).isFocused()) { + if (search.equals(getTextField(33).getText())) + return; + search = getTextField(33).getText().toLowerCase(); + scroll.setList(getSearchList()); + } + } + } - private List getSearchList(){ - if(search.isEmpty()){ - return new ArrayList(this.data.keySet()); - } - List list = new ArrayList(); - for(String name : this.data.keySet()){ - if(name.toLowerCase().contains(search)) - list.add(name); - } - return list; - } + private List getSearchList() { + if (search.isEmpty()) { + return new ArrayList(this.data.keySet()); + } + List list = new ArrayList(); + for (String name : this.data.keySet()) { + if (name.toLowerCase().contains(search)) + list.add(name); + } + return list; + } - @Override - public void setData(Vector list, HashMap data, EnumScrollData type) { - String name = scroll.getSelected(); - this.data = data; - scroll.setList(getSearchList()); + @Override + public void setData(Vector list, HashMap data, EnumScrollData type) { + String name = scroll.getSelected(); + this.data = data; + scroll.setList(getSearchList()); - if(name != null) - scroll.setSelected(name); - } + if (name != null) + scroll.setSelected(name); + } - @Override - public void setSelected(String selected) { - this.selected = selected; - scroll.setSelected(selected); - } + @Override + public void setSelected(String selected) { + this.selected = selected; + scroll.setSelected(selected); + } - @Override - public void customScrollClicked(int i, int j, int k, GuiCustomScroll guiCustomScroll) { - if(guiCustomScroll.id == 0) - { - save(); - selected = scroll.getSelected(); + @Override + public void customScrollClicked(int i, int j, int k, GuiCustomScroll guiCustomScroll) { + if (guiCustomScroll.id == 0) { + save(); + selected = scroll.getSelected(); PacketClient.sendClient(new BankGetPacket(data.get(selected))); - } - } + } + } - @Override - public void save() { - if(selected != null && data.containsKey(selected) && bank != null){ - NBTTagCompound compound = new NBTTagCompound(); - bank.currencyInventory = container.bank.currencyInventory; - bank.upgradeInventory = container.bank.upgradeInventory; - bank.writeEntityToNBT(compound); + @Override + public void save() { + if (selected != null && data.containsKey(selected) && bank != null) { + NBTTagCompound compound = new NBTTagCompound(); + bank.currencyInventory = container.bank.currencyInventory; + bank.upgradeInventory = container.bank.upgradeInventory; + bank.writeEntityToNBT(compound); PacketClient.sendClient(new BankSavePacket(compound)); - } - } + } + } - @Override - public void unFocused(GuiNpcTextField guiNpcTextField) { - if(bank.id != -1) { - if(guiNpcTextField.id == 0) { - String name = guiNpcTextField.getText(); - if(!name.isEmpty() && !data.containsKey(name)){ - String old = bank.name; - data.remove(bank.name); - bank.name = name; - data.put(bank.name, bank.id); - selected = name; - scroll.replace(old,bank.name); - } - } else if(guiNpcTextField.id == 1 || guiNpcTextField.id == 2) { - int num = 1; + @Override + public void unFocused(GuiNpcTextField guiNpcTextField) { + if (bank.id != -1) { + if (guiNpcTextField.id == 0) { + String name = guiNpcTextField.getText(); + if (!name.isEmpty() && !data.containsKey(name)) { + String old = bank.name; + data.remove(bank.name); + bank.name = name; + data.put(bank.name, bank.id); + selected = name; + scroll.replace(old, bank.name); + } + } else if (guiNpcTextField.id == 1 || guiNpcTextField.id == 2) { + int num = 1; - if(!guiNpcTextField.isEmpty()) - num = guiNpcTextField.getInteger(); + if (!guiNpcTextField.isEmpty()) + num = guiNpcTextField.getInteger(); - if(num > 6) - num = 6; + if (num > 6) + num = 6; - if(num < 0) - num = 0; + if (num < 0) + num = 0; - if(guiNpcTextField.id == 1) { - bank.startSlots = num; - } else if(guiNpcTextField.id == 2) { - bank.maxSlots = num; - } + if (guiNpcTextField.id == 1) { + bank.startSlots = num; + } else if (guiNpcTextField.id == 2) { + bank.maxSlots = num; + } - if(bank.startSlots > bank.maxSlots) - bank.maxSlots = bank.startSlots; + if (bank.startSlots > bank.maxSlots) + bank.maxSlots = bank.startSlots; - guiNpcTextField.setText(Integer.toString(num)); - } - } - } + guiNpcTextField.setText(Integer.toString(num)); + } + } + } } diff --git a/src/main/java/noppes/npcs/client/gui/global/GuiNPCManageDialogs.java b/src/main/java/noppes/npcs/client/gui/global/GuiNPCManageDialogs.java index a83197789..f0bbc929a 100644 --- a/src/main/java/noppes/npcs/client/gui/global/GuiNPCManageDialogs.java +++ b/src/main/java/noppes/npcs/client/gui/global/GuiNPCManageDialogs.java @@ -21,23 +21,22 @@ import java.util.HashMap; import java.util.List; import java.util.Vector; -public class GuiNPCManageDialogs extends GuiNPCInterface2 implements IScrollData, ISubGuiListener,ICustomScrollListener, IGuiData, GuiYesNoCallback -{ - private GuiCustomScroll catScroll; - public GuiCustomScroll dialogScroll; +public class GuiNPCManageDialogs extends GuiNPCInterface2 implements IScrollData, ISubGuiListener, ICustomScrollListener, IGuiData, GuiYesNoCallback { + private GuiCustomScroll catScroll; + public GuiCustomScroll dialogScroll; - private String prevCatName = ""; - private String prevDialogName = ""; + private String prevCatName = ""; + private String prevDialogName = ""; - public DialogCategory category = new DialogCategory(); - public Dialog dialog = new Dialog(); - public String dialogQuestName = ""; + public DialogCategory category = new DialogCategory(); + public Dialog dialog = new Dialog(); + public String dialogQuestName = ""; - private HashMap catData = new HashMap(); - public HashMap dialogData = new HashMap(); + private HashMap catData = new HashMap(); + public HashMap dialogData = new HashMap(); - private String catSearch = ""; - private String diagSearch = ""; + private String catSearch = ""; + private String diagSearch = ""; private boolean isResizing = false; private int initialDragX = 0; @@ -49,14 +48,12 @@ public class GuiNPCManageDialogs extends GuiNPCInterface2 implements IScrollData private int dividerLineHeight = 20; private int dividerLineYOffset = 0; - public GuiNPCManageDialogs(EntityNPCInterface npc) - { - super(npc); + public GuiNPCManageDialogs(EntityNPCInterface npc) { + super(npc); PacketClient.sendClient(new DialogCategoriesGetPacket()); } - public void initGui() - { + public void initGui() { super.initGui(); // Define overall horizontal region. @@ -88,33 +85,33 @@ public class GuiNPCManageDialogs extends GuiNPCInterface2 implements IScrollData addTextField(new GuiNpcTextField(55, this, fontRendererObj, regionLeft, guiTop + 4 + 3 + 185, dividerX - regionLeft, 20, catSearch)); addTextField(new GuiNpcTextField(66, this, fontRendererObj, dividerX + dividerWidth, guiTop + 4 + 3 + 185, regionRight - (dividerX + dividerWidth), 20, diagSearch)); - this.addButton(new GuiNpcButton(44,guiLeft + 3, guiTop + 8, 58, 20, "gui.categories")); - getButton(44).setEnabled(false); - this.addButton(new GuiNpcButton(4,guiLeft + 3, guiTop + 38, 58, 20, "gui.add")); - this.addButton(new GuiNpcButton(5,guiLeft + 3, guiTop + 61, 58, 20, "gui.remove")); - this.addButton(new GuiNpcButton(6,guiLeft + 3, guiTop + 94, 58, 20, "gui.edit")); + this.addButton(new GuiNpcButton(44, guiLeft + 3, guiTop + 8, 58, 20, "gui.categories")); + getButton(44).setEnabled(false); + this.addButton(new GuiNpcButton(4, guiLeft + 3, guiTop + 38, 58, 20, "gui.add")); + this.addButton(new GuiNpcButton(5, guiLeft + 3, guiTop + 61, 58, 20, "gui.remove")); + this.addButton(new GuiNpcButton(6, guiLeft + 3, guiTop + 94, 58, 20, "gui.edit")); - this.addButton(new GuiNpcButton(33,guiLeft + 358, guiTop + 8, 58, 20, "dialog.dialogs")); - getButton(33).setEnabled(false); - this.addButton(new GuiNpcButton(0,guiLeft + 358, guiTop + 94, 58, 20, "gui.edit")); - this.addButton(new GuiNpcButton(1,guiLeft + 358, guiTop + 38, 58, 20, "gui.add")); - this.addButton(new GuiNpcButton(2,guiLeft + 358, guiTop + 61, 58, 20, "gui.remove")); - this.addButton(new GuiNpcButton(3,guiLeft + 358, guiTop + 117, 58, 20, "gui.copy")); + this.addButton(new GuiNpcButton(33, guiLeft + 358, guiTop + 8, 58, 20, "dialog.dialogs")); + getButton(33).setEnabled(false); + this.addButton(new GuiNpcButton(0, guiLeft + 358, guiTop + 94, 58, 20, "gui.edit")); + this.addButton(new GuiNpcButton(1, guiLeft + 358, guiTop + 38, 58, 20, "gui.add")); + this.addButton(new GuiNpcButton(2, guiLeft + 358, guiTop + 61, 58, 20, "gui.remove")); + this.addButton(new GuiNpcButton(3, guiLeft + 358, guiTop + 117, 58, 20, "gui.copy")); - if(dialog != null) { - if(dialog.id != -1){ - addLabel(new GuiNpcLabel(0, "ID", guiLeft + 358, guiTop + 4 + 3 + 185)); - addLabel(new GuiNpcLabel(1, dialog.id + "", guiLeft + 358, guiTop + 4 + 3 + 195)); - } - } + if (dialog != null) { + if (dialog.id != -1) { + addLabel(new GuiNpcLabel(0, "ID", guiLeft + 358, guiTop + 4 + 3 + 185)); + addLabel(new GuiNpcLabel(1, dialog.id + "", guiLeft + 358, guiTop + 4 + 3 + 195)); + } + } - updateButtons(); - } + updateButtons(); + } @Override public void drawScreen(int mouseX, int mouseY, float partialTicks) { super.drawScreen(mouseX, mouseY, partialTicks); - if(!hasSubGui()){ + if (!hasSubGui()) { int regionLeft = guiLeft + 64; int dividerX = regionLeft + dividerOffset; // dividerOffset remains your left-scroll width int regionTop = guiTop + 4; @@ -127,7 +124,7 @@ public class GuiNPCManageDialogs extends GuiNPCInterface2 implements IScrollData @Override public void mouseClicked(int mouseX, int mouseY, int mouseButton) { - if(!hasSubGui()){ + if (!hasSubGui()) { int regionLeft = guiLeft + 64; int dividerX = regionLeft + dividerOffset; int regionTop = guiTop + 4; @@ -191,249 +188,241 @@ public class GuiNPCManageDialogs extends GuiNPCInterface2 implements IScrollData super.mouseMovedOrUp(mouseX, mouseY, state); } - @Override - public void keyTyped(char c, int i) - { - super.keyTyped(c, i); - if(getTextField(55) != null){ - if(getTextField(55).isFocused()){ - if(catSearch.equals(getTextField(55).getText())) - return; - catSearch = getTextField(55).getText().toLowerCase(); + @Override + public void keyTyped(char c, int i) { + super.keyTyped(c, i); + if (getTextField(55) != null) { + if (getTextField(55).isFocused()) { + if (catSearch.equals(getTextField(55).getText())) + return; + catSearch = getTextField(55).getText().toLowerCase(); catScroll.resetScroll(); - catScroll.setList(getCatSearch()); - } - } - if(getTextField(66) != null){ - if(getTextField(66).isFocused()){ - if(diagSearch.equals(getTextField(66).getText())) - return; - diagSearch = getTextField(66).getText().toLowerCase(); + catScroll.setList(getCatSearch()); + } + } + if (getTextField(66) != null) { + if (getTextField(66).isFocused()) { + if (diagSearch.equals(getTextField(66).getText())) + return; + diagSearch = getTextField(66).getText().toLowerCase(); dialogScroll.resetScroll(); - dialogScroll.setList(getDiagSearch()); - } - } - } - - public void resetDiagList(){ - if(dialogScroll != null){ - diagSearch = ""; - if(getTextField(66) != null){ - getTextField(66).setText(""); - } - dialogScroll.setList(getDiagSearch()); - } - } - - private List getCatSearch(){ - if(catSearch.isEmpty()){ - return new ArrayList(this.catData.keySet()); - } - List list = new ArrayList(); - for(String name : this.catData.keySet()){ - if(name.toLowerCase().contains(catSearch)) - list.add(name); - } - return list; - } - - private List getDiagSearch(){ - if(category != null){ - if(category.id < 0){ - return new ArrayList(); - } - } - else { - return new ArrayList(); - } - - if(diagSearch.isEmpty()){ - return new ArrayList(this.dialogData.keySet()); - } - List list = new ArrayList(); - for(String name : this.dialogData.keySet()){ - if(name.toLowerCase().contains(diagSearch)) - list.add(name); - } - return list; - } - - public void buttonEvent(GuiButton guibutton) - { - int id = guibutton.id; - // Edit Cat - if(id == 6){ - if(category != null && category.id > -1){ - setSubGui(new SubGuiEditText(category.title)); - } - else { - getCategory(false); - } + dialogScroll.setList(getDiagSearch()); + } } - // Add Cat - if(id == 4){ - String name = "New"; - while(catData.containsKey(name)) - name += "_"; - - if(catScroll != null){ - setPrevCatName(name); - } - DialogCategory category = new DialogCategory(); - category.title = name; - PacketClient.sendClient(new DialogCategorySavePacket(category.writeNBT(new NBTTagCompound()))); - } - // Remove Cat - if(id == 5){ - if(catData.containsKey(catScroll.getSelected())) { - GuiYesNo guiyesno = new GuiYesNo(this, catScroll.getSelected(), StatCollector.translateToLocal("gui.delete"), 5); - displayGuiScreen(guiyesno); - } - } - if(category != null && category.id >= 0){ - // Add Dialog - if(id == 1){ - String name = "New"; - while(dialogData.containsKey(name)) - name += "_"; - - if(dialogScroll != null){ - setPrevDialogName(name); - } - Dialog dialog = new Dialog(); - dialog.title = name; - PacketClient.sendClient(new DialogSavePacket(category.id, dialog.writeToNBT(new NBTTagCompound()), true)); - } - // Remove Dialog - if(id == 2) { - if (dialogData.containsKey(dialogScroll.getSelected())) { - GuiYesNo guiyesno = new GuiYesNo(this, dialogScroll.getSelected(), StatCollector.translateToLocal("gui.delete"), 2); - displayGuiScreen(guiyesno); - } - } - // Edit Dialog - if(id == 0) { - if (dialogData.containsKey(dialogScroll.getSelected()) && dialog != null && dialog.id >= 0) { - setSubGui(new SubGuiNpcDialog(this, dialog, category.id)); - } - } - // Clone Dialog - if(id == 3) { - if (dialogData.containsKey(dialogScroll.getSelected()) && dialog != null && dialog.id >= 0) { - String name = dialog.title; - while(dialogData.containsKey(name)) - name += "_"; - - if(dialogScroll != null){ - setPrevDialogName(name); - } - - Dialog dialog = new Dialog(); - dialog.readNBTPartial(this.dialog.writeToNBT(new NBTTagCompound())); - dialog.title = name; - PacketClient.sendClient(new DialogSavePacket(category.id, dialog.writeToNBT(new NBTTagCompound()), true)); - } - } - } - updateButtons(); } - public void updateButtons(){ - boolean enabled = category != null; - if(enabled){ - if(!(category.id >= 0)){ - enabled = false; - } - } + public void resetDiagList() { + if (dialogScroll != null) { + diagSearch = ""; + if (getTextField(66) != null) { + getTextField(66).setText(""); + } + dialogScroll.setList(getDiagSearch()); + } + } - boolean diagEnabled = dialogData != null; - if(diagEnabled){ - if(dialog == null ||!(dialog.id >= 0)){ - diagEnabled = false; - } - } - getButton(6).setEnabled(enabled); + private List getCatSearch() { + if (catSearch.isEmpty()) { + return new ArrayList(this.catData.keySet()); + } + List list = new ArrayList(); + for (String name : this.catData.keySet()) { + if (name.toLowerCase().contains(catSearch)) + list.add(name); + } + return list; + } - getButton(1).setEnabled(enabled); - getButton(2).setEnabled(enabled); + private List getDiagSearch() { + if (category != null) { + if (category.id < 0) { + return new ArrayList(); + } + } else { + return new ArrayList(); + } - getButton(0).setEnabled(enabled && diagEnabled); - getButton(3).setEnabled(enabled && diagEnabled); - } + if (diagSearch.isEmpty()) { + return new ArrayList(this.dialogData.keySet()); + } + List list = new ArrayList(); + for (String name : this.dialogData.keySet()) { + if (name.toLowerCase().contains(diagSearch)) + list.add(name); + } + return list; + } - @Override - public void setGuiData(NBTTagCompound compound) { - if(compound.hasKey("DialogTitle")){ - dialog.readNBT(compound); - if(compound.hasKey("DialogQuestName")){ - dialogQuestName = compound.getString("DialogQuestName"); - } - else { - dialogQuestName = ""; - } - setPrevDialogName(dialog.title); - } - else { - category.readNBT(compound); - setPrevCatName(category.title); + public void buttonEvent(GuiButton guibutton) { + int id = guibutton.id; + // Edit Cat + if (id == 6) { + if (category != null && category.id > -1) { + setSubGui(new SubGuiEditText(category.title)); + } else { + getCategory(false); + } + } + // Add Cat + if (id == 4) { + String name = "New"; + while (catData.containsKey(name)) + name += "_"; + + if (catScroll != null) { + setPrevCatName(name); + } + DialogCategory category = new DialogCategory(); + category.title = name; + PacketClient.sendClient(new DialogCategorySavePacket(category.writeNBT(new NBTTagCompound()))); + } + // Remove Cat + if (id == 5) { + if (catData.containsKey(catScroll.getSelected())) { + GuiYesNo guiyesno = new GuiYesNo(this, catScroll.getSelected(), StatCollector.translateToLocal("gui.delete"), 5); + displayGuiScreen(guiyesno); + } + } + if (category != null && category.id >= 0) { + // Add Dialog + if (id == 1) { + String name = "New"; + while (dialogData.containsKey(name)) + name += "_"; + + if (dialogScroll != null) { + setPrevDialogName(name); + } + Dialog dialog = new Dialog(); + dialog.title = name; + PacketClient.sendClient(new DialogSavePacket(category.id, dialog.writeToNBT(new NBTTagCompound()), true)); + } + // Remove Dialog + if (id == 2) { + if (dialogData.containsKey(dialogScroll.getSelected())) { + GuiYesNo guiyesno = new GuiYesNo(this, dialogScroll.getSelected(), StatCollector.translateToLocal("gui.delete"), 2); + displayGuiScreen(guiyesno); + } + } + // Edit Dialog + if (id == 0) { + if (dialogData.containsKey(dialogScroll.getSelected()) && dialog != null && dialog.id >= 0) { + setSubGui(new SubGuiNpcDialog(this, dialog, category.id)); + } + } + // Clone Dialog + if (id == 3) { + if (dialogData.containsKey(dialogScroll.getSelected()) && dialog != null && dialog.id >= 0) { + String name = dialog.title; + while (dialogData.containsKey(name)) + name += "_"; + + if (dialogScroll != null) { + setPrevDialogName(name); + } + + Dialog dialog = new Dialog(); + dialog.readNBTPartial(this.dialog.writeToNBT(new NBTTagCompound())); + dialog.title = name; + PacketClient.sendClient(new DialogSavePacket(category.id, dialog.writeToNBT(new NBTTagCompound()), true)); + } + } + } + updateButtons(); + } + + public void updateButtons() { + boolean enabled = category != null; + if (enabled) { + if (!(category.id >= 0)) { + enabled = false; + } + } + + boolean diagEnabled = dialogData != null; + if (diagEnabled) { + if (dialog == null || !(dialog.id >= 0)) { + diagEnabled = false; + } + } + getButton(6).setEnabled(enabled); + + getButton(1).setEnabled(enabled); + getButton(2).setEnabled(enabled); + + getButton(0).setEnabled(enabled && diagEnabled); + getButton(3).setEnabled(enabled && diagEnabled); + } + + @Override + public void setGuiData(NBTTagCompound compound) { + if (compound.hasKey("DialogTitle")) { + dialog.readNBT(compound); + if (compound.hasKey("DialogQuestName")) { + dialogQuestName = compound.getString("DialogQuestName"); + } else { + dialogQuestName = ""; + } + setPrevDialogName(dialog.title); + } else { + category.readNBT(compound); + setPrevCatName(category.title); PacketClient.sendClient(new DialogsGetPacket(category.id, true)); - resetDiagList(); - } - initGui(); - } + resetDiagList(); + } + initGui(); + } - @Override - public void subGuiClosed(SubGuiInterface subgui){ - if(subgui instanceof SubGuiEditText){ - if(!((SubGuiEditText)subgui).cancelled){ - if(category != null && category.id > -1){ - String name = ((SubGuiEditText)subgui).text; - if(name != null && !name.equalsIgnoreCase(category.title)){ - if(!(name.isEmpty() || catData.containsKey(name))){ - String old = category.title; - catData.remove(category.title); - category.title = name; - catData.put(category.title, category.id); - catScroll.replace(old,category.title); - } - saveType(false); - } - } - } - clearCategory(); - } - if(subgui instanceof SubGuiNpcDialog){ - saveType(true); - } - } + @Override + public void subGuiClosed(SubGuiInterface subgui) { + if (subgui instanceof SubGuiEditText) { + if (!((SubGuiEditText) subgui).cancelled) { + if (category != null && category.id > -1) { + String name = ((SubGuiEditText) subgui).text; + if (name != null && !name.equalsIgnoreCase(category.title)) { + if (!(name.isEmpty() || catData.containsKey(name))) { + String old = category.title; + catData.remove(category.title); + category.title = name; + catData.put(category.title, category.id); + catScroll.replace(old, category.title); + } + saveType(false); + } + } + } + clearCategory(); + } + if (subgui instanceof SubGuiNpcDialog) { + saveType(true); + } + } - public void setPrevCatName(String selectedCat){ - prevCatName = selectedCat; - this.catScroll.setSelected(prevCatName); - } + public void setPrevCatName(String selectedCat) { + prevCatName = selectedCat; + this.catScroll.setSelected(prevCatName); + } - public void setPrevDialogName(String selectedCat){ - prevDialogName = selectedCat; - this.dialogScroll.setSelected(prevDialogName); - } + public void setPrevDialogName(String selectedCat) { + prevDialogName = selectedCat; + this.dialogScroll.setSelected(prevDialogName); + } - @Override - public void customScrollClicked(int i, int j, int k, GuiCustomScroll guiCustomScroll) { - if(guiCustomScroll.id == 0) - { - getCategory(false); - } - if(guiCustomScroll.id == 1) - { - getDialog(false); - } - } + @Override + public void customScrollClicked(int i, int j, int k, GuiCustomScroll guiCustomScroll) { + if (guiCustomScroll.id == 0) { + getCategory(false); + } + if (guiCustomScroll.id == 1) { + getDialog(false); + } + } - public void getCategory(boolean override){ - if(catScroll.selected != -1){ - String selected = catScroll.getSelected(); - if(!selected.equals(prevCatName) || override){ - category = new DialogCategory(); + public void getCategory(boolean override) { + if (catScroll.selected != -1) { + String selected = catScroll.getSelected(); + if (!selected.equals(prevCatName) || override) { + category = new DialogCategory(); dialogScroll.selected = -1; dialogScroll.resetScroll(); @@ -442,54 +431,54 @@ public class GuiNPCManageDialogs extends GuiNPCInterface2 implements IScrollData getTextField(66).setText(""); PacketClient.sendClient(new DialogCategoryGetPacket(catData.get(selected))); - setPrevCatName(selected); - } - } - } + setPrevCatName(selected); + } + } + } - public void getDialog(boolean override){ - if(dialogScroll.selected != -1){ - String selected = dialogScroll.getSelected(); - if(!selected.equals(prevDialogName) || override){ - dialog = new Dialog(); + public void getDialog(boolean override) { + if (dialogScroll.selected != -1) { + String selected = dialogScroll.getSelected(); + if (!selected.equals(prevDialogName) || override) { + dialog = new Dialog(); DialogGetPacket.getDialog(dialogData.get(selected)); - setPrevDialogName(selected); - } - } - } + setPrevDialogName(selected); + } + } + } - public void clearCategory(){ - catScroll.setList(getCatSearch()); - catScroll.selected = -1; - prevCatName = ""; - category = new DialogCategory(); - this.dialogData.clear(); - resetDiagList(); - } + public void clearCategory() { + catScroll.setList(getCatSearch()); + catScroll.selected = -1; + prevCatName = ""; + category = new DialogCategory(); + this.dialogData.clear(); + resetDiagList(); + } - public void saveType(boolean saveDiag){ - if(saveDiag){ - if(dialogScroll.selected != -1 && dialog.id >= 0){ - if(catScroll.selected != -1 && category.id >= 0){ + public void saveType(boolean saveDiag) { + if (saveDiag) { + if (dialogScroll.selected != -1 && dialog.id >= 0) { + if (catScroll.selected != -1 && category.id >= 0) { PacketClient.sendClient(new DialogSavePacket(category.id, dialog.writeToNBT(new NBTTagCompound()), true)); - } - } - } - else{ - if(catScroll.selected != -1 && category.id >= 0) + } + } + } else { + if (catScroll.selected != -1 && category.id >= 0) PacketClient.sendClient(new DialogCategorySavePacket(category.writeNBT(new NBTTagCompound()))); - } - } + } + } - public void save() {} + public void save() { + } - @Override - public void setData(Vector list, HashMap data, EnumScrollData type) { - if(type == EnumScrollData.DIALOG_GROUP){ + @Override + public void setData(Vector list, HashMap data, EnumScrollData type) { + if (type == EnumScrollData.DIALOG_GROUP) { String name = dialogScroll.getSelected(); this.dialogData = data; dialogScroll.setList(getDiagSearch()); - if(name != null){ + if (name != null) { dialogScroll.setSelected(name); getDialog(false); } else { @@ -500,7 +489,7 @@ public class GuiNPCManageDialogs extends GuiNPCInterface2 implements IScrollData String name = catScroll.getSelected(); this.catData = data; catScroll.setList(getCatSearch()); - if(name != null){ + if (name != null) { catScroll.setSelected(name); getCategory(false); } else { @@ -508,24 +497,25 @@ public class GuiNPCManageDialogs extends GuiNPCInterface2 implements IScrollData getCategory(true); } } - initGui(); - } + initGui(); + } - @Override - public void setSelected(String selected) {} + @Override + public void setSelected(String selected) { + } @Override public void confirmClicked(boolean result, int id) { NoppesUtil.openGUI(player, this); - if(!result) + if (!result) return; - if(id == 5) { - if(catData.containsKey(catScroll.getSelected())) { + if (id == 5) { + if (catData.containsKey(catScroll.getSelected())) { PacketClient.sendClient(new DialogCategoryRemovePacket(category.id)); clearCategory(); } } - if(id == 2) { + if (id == 2) { if (dialogData.containsKey(dialogScroll.getSelected())) { PacketClient.sendClient(new DialogRemovePacket(dialog.id, true)); dialog = new Dialog(); diff --git a/src/main/java/noppes/npcs/client/gui/global/GuiNPCManageEffects.java b/src/main/java/noppes/npcs/client/gui/global/GuiNPCManageEffects.java index 64819f236..68635ae45 100644 --- a/src/main/java/noppes/npcs/client/gui/global/GuiNPCManageEffects.java +++ b/src/main/java/noppes/npcs/client/gui/global/GuiNPCManageEffects.java @@ -121,7 +121,6 @@ public class GuiNPCManageEffects extends GuiNPCInterface2 implements ICustomScro } - @Override public void drawScreen(int i, int j, float f) { super.drawScreen(i, j, f); @@ -183,7 +182,7 @@ public class GuiNPCManageEffects extends GuiNPCInterface2 implements ICustomScro String translated = StatCollector.translateToLocal("gui.name") + ": " + effect.name; fontRendererObj.drawString(translated, x, y, 0xFFFFFF, false); int transLength = getStringWidthWithoutColor(translated); - fontRendererObj.drawString(" (ID: "+ effect.id+ ")", x + transLength, y, 0xB5B5B5, false); + fontRendererObj.drawString(" (ID: " + effect.id + ")", x + transLength, y, 0xB5B5B5, false); y += 12; fontRendererObj.drawString(StatCollector.translateToLocal("general.menuName") + ": " + effect.menuName, x, y, 0xFFFFFF, false); y += 12; diff --git a/src/main/java/noppes/npcs/client/gui/global/GuiNPCManageFactions.java b/src/main/java/noppes/npcs/client/gui/global/GuiNPCManageFactions.java index 6d1f7f9c5..ced128544 100644 --- a/src/main/java/noppes/npcs/client/gui/global/GuiNPCManageFactions.java +++ b/src/main/java/noppes/npcs/client/gui/global/GuiNPCManageFactions.java @@ -20,29 +20,26 @@ import noppes.npcs.entity.EntityNPCInterface; import java.util.*; -public class GuiNPCManageFactions extends GuiNPCInterface2 implements IScrollData,ICustomScrollListener,ITextfieldListener, IGuiData, ISubGuiListener, GuiYesNoCallback -{ +public class GuiNPCManageFactions extends GuiNPCInterface2 implements IScrollData, ICustomScrollListener, ITextfieldListener, IGuiData, ISubGuiListener, GuiYesNoCallback { private GuiCustomScroll scrollFactions; - private HashMap data = new HashMap(); + private HashMap data = new HashMap(); private Faction faction = new Faction(); private String selected = null; private String search = ""; - public GuiNPCManageFactions(EntityNPCInterface npc) - { + public GuiNPCManageFactions(EntityNPCInterface npc) { super(npc); PacketClient.sendClient(new FactionsGetPacket()); } - public void initGui() - { + public void initGui() { super.initGui(); - this.addButton(new GuiNpcButton(0,guiLeft + 368, guiTop + 8, 45, 20, "gui.add")); - this.addButton(new GuiNpcButton(1,guiLeft + 368, guiTop + 32, 45, 20, "gui.remove")); + this.addButton(new GuiNpcButton(0, guiLeft + 368, guiTop + 8, 45, 20, "gui.add")); + this.addButton(new GuiNpcButton(1, guiLeft + 368, guiTop + 32, 45, 20, "gui.remove")); - if(scrollFactions == null){ - scrollFactions = new GuiCustomScroll(this,0, 0); + if (scrollFactions == null) { + scrollFactions = new GuiCustomScroll(this, 0, 0); scrollFactions.setSize(143, 185); } scrollFactions.guiLeft = guiLeft + 220; @@ -55,49 +52,49 @@ public class GuiNPCManageFactions extends GuiNPCInterface2 implements IScrollDat this.addTextField(new GuiNpcTextField(0, this, guiLeft + 40, guiTop + 4, 136, 20, faction.name)); getTextField(0).setMaxStringLength(20); - addLabel(new GuiNpcLabel(0,"gui.name", guiLeft + 8, guiTop + 9)); + addLabel(new GuiNpcLabel(0, "gui.name", guiLeft + 8, guiTop + 9)); - addLabel(new GuiNpcLabel(10,"ID", guiLeft + 178, guiTop + 4)); + addLabel(new GuiNpcLabel(10, "ID", guiLeft + 178, guiTop + 4)); addLabel(new GuiNpcLabel(11, faction.id + "", guiLeft + 178, guiTop + 14)); String color = Integer.toHexString(faction.color); - while(color.length() < 6) + while (color.length() < 6) color = "0" + color; addButton(new GuiNpcButton(10, guiLeft + 40, guiTop + 26, 60, 20, color)); - addLabel(new GuiNpcLabel(1,"gui.color", guiLeft + 8, guiTop + 31)); + addLabel(new GuiNpcLabel(1, "gui.color", guiLeft + 8, guiTop + 31)); getButton(10).setTextColor(faction.color); - addLabel(new GuiNpcLabel(2,"faction.points", guiLeft + 105, guiTop + 31)); - this.addButton(new GuiNpcButton(2,guiLeft + 156, guiTop + 26, 45, 20, "selectServer.edit")); + addLabel(new GuiNpcLabel(2, "faction.points", guiLeft + 105, guiTop + 31)); + this.addButton(new GuiNpcButton(2, guiLeft + 156, guiTop + 26, 45, 20, "selectServer.edit")); int y = guiTop + 48; - addLabel(new GuiNpcLabel(3,"faction.hidden", guiLeft + 8, y + 5)); - this.addButton(new GuiNpcButton(3,guiLeft + 100, y, 45, 20, new String[]{"gui.no","gui.yes"},faction.hideFaction?1:0)); + addLabel(new GuiNpcLabel(3, "faction.hidden", guiLeft + 8, y + 5)); + this.addButton(new GuiNpcButton(3, guiLeft + 100, y, 45, 20, new String[]{"gui.no", "gui.yes"}, faction.hideFaction ? 1 : 0)); y += 23; - addLabel(new GuiNpcLabel(4,"faction.attacked", guiLeft + 8, y + 5)); - this.addButton(new GuiNpcButton(4,guiLeft + 100, y, 45, 20, new String[]{"gui.no","gui.yes"},faction.getsAttacked?1:0)); + addLabel(new GuiNpcLabel(4, "faction.attacked", guiLeft + 8, y + 5)); + this.addButton(new GuiNpcButton(4, guiLeft + 100, y, 45, 20, new String[]{"gui.no", "gui.yes"}, faction.getsAttacked ? 1 : 0)); y += 23; - addLabel(new GuiNpcLabel(5,"faction.passive", guiLeft + 8, y + 5)); - this.addButton(new GuiNpcButton(5,guiLeft + 100, y, 45, 20, new String[]{"gui.no","gui.yes"},faction.isPassive?1:0)); + addLabel(new GuiNpcLabel(5, "faction.passive", guiLeft + 8, y + 5)); + this.addButton(new GuiNpcButton(5, guiLeft + 100, y, 45, 20, new String[]{"gui.no", "gui.yes"}, faction.isPassive ? 1 : 0)); getButton(5).setHoverText("faction.passive.hover"); - addLabel(new GuiNpcLabel(6,"faction.hostiles", guiLeft + 8, guiTop + 120)); + addLabel(new GuiNpcLabel(6, "faction.hostiles", guiLeft + 8, guiTop + 120)); ArrayList hostileList = new ArrayList(scrollFactions.getList()); hostileList.remove(faction.name); HashSet set = new HashSet(); - for(String s : data.keySet()){ - if(!s.equals(faction.name) && faction.attackFactions.contains(data.get(s))) + for (String s : data.keySet()) { + if (!s.equals(faction.name) && faction.attackFactions.contains(data.get(s))) set.add(s); } - GuiCustomScroll scrollHostileFactions = new GuiCustomScroll(this,1,true); + GuiCustomScroll scrollHostileFactions = new GuiCustomScroll(this, 1, true); scrollHostileFactions.setSize(163, 78); scrollHostileFactions.guiLeft = guiLeft + 4; scrollHostileFactions.guiTop = guiTop + 134; @@ -107,12 +104,12 @@ public class GuiNPCManageFactions extends GuiNPCInterface2 implements IScrollDat } @Override - protected void actionPerformed(GuiButton guibutton){ + protected void actionPerformed(GuiButton guibutton) { GuiNpcButton button = (GuiNpcButton) guibutton; - if(button.id == 0){ + if (button.id == 0) { save(); String name = "New"; - while(data.containsKey(name)) + while (data.containsKey(name)) name += "_"; Faction faction = new Faction(-1, name, 0x00FF00, 1000); @@ -120,25 +117,25 @@ public class GuiNPCManageFactions extends GuiNPCInterface2 implements IScrollDat faction.writeNBT(compound); PacketClient.sendClient(new FactionSavePacket(compound)); } - if(button.id == 1){ - if(data.containsKey(scrollFactions.getSelected())) { + if (button.id == 1) { + if (data.containsKey(scrollFactions.getSelected())) { GuiYesNo guiyesno = new GuiYesNo(this, scrollFactions.getSelected(), StatCollector.translateToLocal("gui.delete"), 1); displayGuiScreen(guiyesno); } } - if(button.id == 2){ + if (button.id == 2) { this.setSubGui(new SubGuiNpcFactionPoints(faction)); } - if(button.id == 3){ + if (button.id == 3) { faction.hideFaction = button.getValue() == 1; } - if(button.id == 4){ + if (button.id == 4) { faction.getsAttacked = button.getValue() == 1; } - if(button.id == 4){ + if (button.id == 4) { faction.isPassive = button.getValue() == 1; } - if(button.id == 10){ + if (button.id == 10) { this.setSubGui(new SubGuiColorSelector(faction.color)); } } @@ -153,12 +150,11 @@ public class GuiNPCManageFactions extends GuiNPCInterface2 implements IScrollDat } @Override - public void keyTyped(char c, int i) - { + public void keyTyped(char c, int i) { super.keyTyped(c, i); - if(getTextField(55) != null){ - if(getTextField(55).isFocused()){ - if(search.equals(getTextField(55).getText())) + if (getTextField(55) != null) { + if (getTextField(55).isFocused()) { + if (search.equals(getTextField(55).getText())) return; search = getTextField(55).getText().toLowerCase(); scrollFactions.resetScroll(); @@ -167,13 +163,13 @@ public class GuiNPCManageFactions extends GuiNPCInterface2 implements IScrollDat } } - private List getSearchList(){ - if(search.isEmpty()){ + private List getSearchList() { + if (search.isEmpty()) { return new ArrayList(this.data.keySet()); } List list = new ArrayList(); - for(String name : this.data.keySet()){ - if(name.toLowerCase().contains(search)) + for (String name : this.data.keySet()) { + if (name.toLowerCase().contains(search)) list.add(name); } return list; @@ -185,7 +181,7 @@ public class GuiNPCManageFactions extends GuiNPCInterface2 implements IScrollDat this.data = data; scrollFactions.setList(getSearchList()); - if(name != null) + if (name != null) scrollFactions.setSelected(name); } @@ -197,17 +193,14 @@ public class GuiNPCManageFactions extends GuiNPCInterface2 implements IScrollDat @Override public void customScrollClicked(int i, int j, int k, GuiCustomScroll guiCustomScroll) { - if(guiCustomScroll.id == 0) - { + if (guiCustomScroll.id == 0) { save(); selected = scrollFactions.getSelected(); FactionGetPacket.getFaction(data.get(selected)); - } - else if(guiCustomScroll.id == 1) - { + } else if (guiCustomScroll.id == 1) { HashSet set = new HashSet(); - for(String s : guiCustomScroll.getSelectedList()){ - if(data.containsKey(s)) + for (String s : guiCustomScroll.getSelectedList()) { + if (data.containsKey(s)) set.add(data.get(s)); } faction.attackFactions = set; @@ -216,7 +209,7 @@ public class GuiNPCManageFactions extends GuiNPCInterface2 implements IScrollDat } public void save() { - if(selected != null && data.containsKey(selected) && faction != null){ + if (selected != null && data.containsKey(selected) && faction != null) { NBTTagCompound compound = new NBTTagCompound(); faction.writeNBT(compound); @@ -226,25 +219,24 @@ public class GuiNPCManageFactions extends GuiNPCInterface2 implements IScrollDat @Override public void unFocused(GuiNpcTextField guiNpcTextField) { - if(faction.id == -1) + if (faction.id == -1) return; - if(guiNpcTextField.id == 0) { + if (guiNpcTextField.id == 0) { String name = guiNpcTextField.getText(); - if(!name.isEmpty() && !data.containsKey(name)){ + if (!name.isEmpty() && !data.containsKey(name)) { String old = faction.name; data.remove(faction.name); faction.name = name; data.put(faction.name, faction.id); selected = name; - scrollFactions.replace(old,faction.name); + scrollFactions.replace(old, faction.name); } - } else if(guiNpcTextField.id == 1) { + } else if (guiNpcTextField.id == 1) { int color = 0; - try{ - color = Integer.parseInt(guiNpcTextField.getText(),16); - } - catch(NumberFormatException e){ + try { + color = Integer.parseInt(guiNpcTextField.getText(), 16); + } catch (NumberFormatException e) { color = 0; } faction.color = color; @@ -255,8 +247,8 @@ public class GuiNPCManageFactions extends GuiNPCInterface2 implements IScrollDat @Override public void subGuiClosed(SubGuiInterface subgui) { - if(subgui instanceof SubGuiColorSelector){ - faction.color = ((SubGuiColorSelector)subgui).color; + if (subgui instanceof SubGuiColorSelector) { + faction.color = ((SubGuiColorSelector) subgui).color; initGui(); } } @@ -264,10 +256,10 @@ public class GuiNPCManageFactions extends GuiNPCInterface2 implements IScrollDat @Override public void confirmClicked(boolean result, int id) { NoppesUtil.openGUI(player, this); - if(!result) + if (!result) return; - if(id == 1) { - if(data.containsKey(scrollFactions.getSelected())) { + if (id == 1) { + if (data.containsKey(scrollFactions.getSelected())) { PacketClient.sendClient(new FactionRemovePacket(data.get(selected))); scrollFactions.clear(); faction = new Faction(); diff --git a/src/main/java/noppes/npcs/client/gui/global/GuiNPCManageLinked.java b/src/main/java/noppes/npcs/client/gui/global/GuiNPCManageLinked.java index 8edfc444a..9fa08ba1b 100644 --- a/src/main/java/noppes/npcs/client/gui/global/GuiNPCManageLinked.java +++ b/src/main/java/noppes/npcs/client/gui/global/GuiNPCManageLinked.java @@ -36,7 +36,7 @@ import java.util.List; import java.util.Vector; public class GuiNPCManageLinked extends GuiNPCInterface2 implements IScrollData, ISubGuiListener, ICustomScrollListener, IGuiData, GuiYesNoCallback { - private static int tab = 0; + private static int tab = 0; private boolean loadedNPC = false; private GuiCustomScroll scroll; @@ -46,80 +46,79 @@ public class GuiNPCManageLinked extends GuiNPCInterface2 implements IScrollData, private LinkedItem linkedItem = null; public String originalName = ""; - private String search = ""; + private String search = ""; private float zoomed = 36, rotation; - public GuiNPCManageLinked(EntityNPCInterface npc){ - super(npc); + public GuiNPCManageLinked(EntityNPCInterface npc) { + super(npc); resetNPC(); - if(tab == 0) + if (tab == 0) LinkedGetAllPacket.GetNPCs(); - else if(tab == 1) + else if (tab == 1) LinkedGetAllPacket.GetItems(); } - public void resetNPC(){ - this.npc = new EntityCustomNpc(Minecraft.getMinecraft().theWorld); + public void resetNPC() { + this.npc = new EntityCustomNpc(Minecraft.getMinecraft().theWorld); this.npc.display.name = "Linked NPC"; this.npc.height = 1.62f; this.npc.width = 0.43f; } @Override - public void initGui(){ + public void initGui() { super.initGui(); int y = guiTop + 8; - this.addButton(new GuiNpcButton(10,guiLeft + 368, y, 45, 20, "gui.npcs")); - this.addButton(new GuiNpcButton(11,guiLeft + 368, y += 22, 45, 20, "gui.items")); + this.addButton(new GuiNpcButton(10, guiLeft + 368, y, 45, 20, "gui.npcs")); + this.addButton(new GuiNpcButton(11, guiLeft + 368, y += 22, 45, 20, "gui.items")); getButton(10).enabled = tab == 1; getButton(11).enabled = tab == 0; - this.addButton(new GuiNpcButton(1,guiLeft + 368, y += 40, 45, 20, "gui.add")); - this.addButton(new GuiNpcButton(2,guiLeft + 368, y += 22, 45, 20, "gui.remove")); + this.addButton(new GuiNpcButton(1, guiLeft + 368, y += 40, 45, 20, "gui.add")); + this.addButton(new GuiNpcButton(2, guiLeft + 368, y += 22, 45, 20, "gui.remove")); - this.addButton(new GuiNpcButton(3,guiLeft + 368, y += 22, 45, 20, "gui.edit")); - this.addButton(new GuiNpcButton(4,guiLeft + 368, y += 22, 45, 20, "gui.copy")); - this.addButton(new GuiNpcButton(5,guiLeft + 368, y += 22, 45, 20, "gui.build")); + this.addButton(new GuiNpcButton(3, guiLeft + 368, y += 22, 45, 20, "gui.edit")); + this.addButton(new GuiNpcButton(4, guiLeft + 368, y += 22, 45, 20, "gui.copy")); + this.addButton(new GuiNpcButton(5, guiLeft + 368, y += 22, 45, 20, "gui.build")); getButton(3).enabled = tab == 1; getButton(4).enabled = tab == 1; getButton(5).enabled = tab == 1; - if(scroll == null){ - scroll = new GuiCustomScroll(this,0,0); - scroll.setSize(143, 185); + if (scroll == null) { + scroll = new GuiCustomScroll(this, 0, 0); + scroll.setSize(143, 185); } scroll.guiLeft = guiLeft + 220; scroll.guiTop = guiTop + 4; scroll.setList(getSearchList()); this.addScroll(scroll); - this.addTextField(new GuiNpcTextField(55, this, fontRendererObj, guiLeft + 220, guiTop + 4 + 3 + 185, 143, 20, search)); + this.addTextField(new GuiNpcTextField(55, this, fontRendererObj, guiLeft + 220, guiTop + 4 + 3 + 185, 143, 20, search)); } - @Override - public void keyTyped(char c, int i) - { - super.keyTyped(c, i); - if(getTextField(55) != null){ - if(getTextField(55).isFocused()){ - if(search.equals(getTextField(55).getText())) - return; - search = getTextField(55).getText().toLowerCase(); - scroll.setList(getSearchList()); + @Override + public void keyTyped(char c, int i) { + super.keyTyped(c, i); + if (getTextField(55) != null) { + if (getTextField(55).isFocused()) { + if (search.equals(getTextField(55).getText())) + return; + search = getTextField(55).getText().toLowerCase(); + scroll.setList(getSearchList()); scroll.resetScroll(); - } - } - } + } + } + } @Override public void drawScreen(int i, int j, float f) { super.drawScreen(i, j, f); - if(hasSubGui()) + if (hasSubGui()) return; - if(tab == 0) { + if (tab == 0) { // (Existing NPC rendering code...) if (isMouseOverRenderer(i, j)) { zoomed += Mouse.getDWheel() * 0.035f; @@ -149,17 +148,18 @@ public class GuiNPCManageLinked extends GuiNPCInterface2 implements IScrollData, GL11.glRotatef(135F, 0.0F, 1.0F, 0.0F); RenderHelper.enableStandardItemLighting(); GL11.glRotatef(-135F, 0.0F, 1.0F, 0.0F); - GL11.glRotatef(-(float)Math.atan(f6 / 800F) * 20F, 1.0F, 0.0F, 0.0F); + GL11.glRotatef(-(float) Math.atan(f6 / 800F) * 20F, 1.0F, 0.0F, 0.0F); entity.prevRenderYawOffset = entity.renderYawOffset = rotation; - entity.prevRotationYaw = entity.rotationYaw = (float)Math.atan(f5 / 80F) * 40F + rotation; - entity.rotationPitch = -(float)Math.atan(f6 / 80F) * 20F; + entity.prevRotationYaw = entity.rotationYaw = (float) Math.atan(f5 / 80F) * 40F + rotation; + entity.rotationPitch = -(float) Math.atan(f6 / 80F) * 20F; entity.prevRotationYawHead = entity.rotationYawHead = entity.rotationYaw; GL11.glTranslatef(0.0F, entity.yOffset, 1F); RenderManager.instance.playerViewY = 180F; GL11.glPushMatrix(); try { RenderManager.instance.renderEntityWithPosYaw(entity, 0.0, 0.0, 0.0, 0.0F, 1.0F); - } catch (Exception ignored) {} + } catch (Exception ignored) { + } GL11.glPopMatrix(); entity.prevRenderYawOffset = entity.renderYawOffset = f2; entity.prevRotationYaw = entity.rotationYaw = f3; @@ -172,17 +172,16 @@ public class GuiNPCManageLinked extends GuiNPCInterface2 implements IScrollData, OpenGlHelper.setActiveTexture(OpenGlHelper.defaultTexUnit); GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT); GL11.glPopMatrix(); - } - else if(tab == 1) { + } else if (tab == 1) { // Render the linked item image in the top-left area - if(linkedItem != null) { + if (linkedItem != null) { int x = guiLeft + 155; int y = guiTop + 30; int iconRenderSize = 64; TextureManager textureManager = mc.getTextureManager(); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); ImageData imageData = ClientCacheHandler.getImageData(linkedItem.display.texture); - if(imageData.imageLoaded()){ + if (imageData.imageLoaded()) { float[] colors = ColorUtil.hexToRGB(this.linkedItem.display.itemColor); GL11.glColor3f(colors[0], colors[1], colors[2]); imageData.bindTexture(); @@ -202,22 +201,22 @@ public class GuiNPCManageLinked extends GuiNPCInterface2 implements IScrollData, } } - private List getSearchList(){ - if(search.isEmpty()){ - return new ArrayList(this.data.keySet()); - } - List list = new ArrayList(); - for(String name : this.data.keySet()){ - if(name.toLowerCase().contains(search)) - list.add(name); - } - return list; - } + private List getSearchList() { + if (search.isEmpty()) { + return new ArrayList(this.data.keySet()); + } + List list = new ArrayList(); + for (String name : this.data.keySet()) { + if (name.toLowerCase().contains(search)) + list.add(name); + } + return list; + } @Override - public void buttonEvent(GuiButton button){ - if(button.id == 1){ - if(tab == 0){ + public void buttonEvent(GuiButton button) { + if (button.id == 1) { + if (tab == 0) { setSubGui(new SubGuiEditText("New")); } else { String name = "New"; @@ -227,8 +226,8 @@ public class GuiNPCManageLinked extends GuiNPCInterface2 implements IScrollData, PacketClient.sendClient(new LinkedItemSavePacket(linkedItem.writeToNBT(false), "")); } } - if(button.id == 2){ - if(tab == 0){ + if (button.id == 2) { + if (tab == 0) { if (data.containsKey(scroll.getSelected())) { GuiYesNo guiyesno = new GuiYesNo(this, scroll.getSelected(), StatCollector.translateToLocal("gui.delete"), 0); displayGuiScreen(guiyesno); @@ -240,25 +239,25 @@ public class GuiNPCManageLinked extends GuiNPCInterface2 implements IScrollData, } } } - if(button.id == 10){ + if (button.id == 10) { tab = 0; resetNPC(); LinkedGetAllPacket.GetNPCs(); scroll.setSelected(""); } - if(button.id == 11){ + if (button.id == 11) { tab = 1; LinkedGetAllPacket.GetItems(); scroll.setSelected(""); } - if(linkedItem == null) + if (linkedItem == null) return; - if(button.id == 3){ + if (button.id == 3) { setSubGui(new SubGuiLinkedItem(this, this.linkedItem)); } - if(button.id == 4){ + if (button.id == 4) { if (data.containsKey(scroll.getSelected()) && linkedItem != null && linkedItem.id >= 0) { String name = linkedItem.name; while (data.containsKey(name)) @@ -269,9 +268,9 @@ public class GuiNPCManageLinked extends GuiNPCInterface2 implements IScrollData, PacketClient.sendClient(new LinkedItemSavePacket(linkedItemClone.writeToNBT(false), "")); } } - if(button.id == 5){ + if (button.id == 5) { // Build Linked Item - if(tab == 1) + if (tab == 1) PacketClient.sendClient(new LinkedItemBuildPacket(this.linkedItem.getId())); } @@ -288,7 +287,7 @@ public class GuiNPCManageLinked extends GuiNPCInterface2 implements IScrollData, initGui(); } } - if(id == 1){ + if (id == 1) { if (data.containsKey(scroll.getSelected())) { PacketClient.sendClient(new LinkedItemRemovePacket(data.get(scroll.getSelected()))); initGui(); @@ -432,12 +431,22 @@ public class GuiNPCManageLinked extends GuiNPCInterface2 implements IScrollData, StatCollector.translateToLocal("use_action.drink") }; int useActionIndex; - switch(linkedItem.itemUseAction) { - case 0: useActionIndex = 0; break; - case 1: useActionIndex = 1; break; - case 3: useActionIndex = 2; break; - case 4: useActionIndex = 3; break; - default: useActionIndex = 0; break; + switch (linkedItem.itemUseAction) { + case 0: + useActionIndex = 0; + break; + case 1: + useActionIndex = 1; + break; + case 3: + useActionIndex = 2; + break; + case 4: + useActionIndex = 3; + break; + default: + useActionIndex = 0; + break; } label = StatCollector.translateToLocal("display.useAction") + ": "; value = useActions[useActionIndex]; @@ -524,14 +533,14 @@ public class GuiNPCManageLinked extends GuiNPCInterface2 implements IScrollData, return width; } - @Override - public void subGuiClosed(SubGuiInterface subgui) { - if(subgui instanceof SubGuiEditText){ - if(!((SubGuiEditText)subgui).cancelled){ - PacketClient.sendClient(new LinkedNPCAddPacket(((SubGuiEditText)subgui).text)); + @Override + public void subGuiClosed(SubGuiInterface subgui) { + if (subgui instanceof SubGuiEditText) { + if (!((SubGuiEditText) subgui).cancelled) { + PacketClient.sendClient(new LinkedNPCAddPacket(((SubGuiEditText) subgui).text)); } } - } + } @Override public void setData(Vector list, HashMap data, EnumScrollData type) { @@ -552,8 +561,9 @@ public class GuiNPCManageLinked extends GuiNPCInterface2 implements IScrollData, originalName = scroll.getSelected(); } - @Override - public void save() {} + @Override + public void save() { + } public boolean isMouseOverRenderer(int x, int y) { return x >= guiLeft + 10 && x <= guiLeft + 10 + 200 && y >= guiTop + 6 && y <= guiTop + 6 + 204; @@ -565,8 +575,8 @@ public class GuiNPCManageLinked extends GuiNPCInterface2 implements IScrollData, loadedNPC = false; selected = scroll.getSelected(); originalName = scroll.getSelected(); - if (selected != null && !selected.isEmpty()){ - if(tab == 0) + if (selected != null && !selected.isEmpty()) { + if (tab == 0) LinkedGetPacket.GetNPC(selected); else LinkedGetPacket.GetItem(data.get(selected)); @@ -575,12 +585,13 @@ public class GuiNPCManageLinked extends GuiNPCInterface2 implements IScrollData, } @Override - public void customScrollDoubleClicked(String selection, GuiCustomScroll scroll) {} + public void customScrollDoubleClicked(String selection, GuiCustomScroll scroll) { + } public void setGuiData(NBTTagCompound compound) { loadedNPC = false; this.linkedItem = null; - if(compound.hasKey("NPCData")){ + if (compound.hasKey("NPCData")) { // Linked NPC this.npc.display.readToNBT(compound.getCompoundTag("NPCData")); this.npc.stats.readToNBT(compound.getCompoundTag("NPCData")); diff --git a/src/main/java/noppes/npcs/client/gui/global/GuiNPCManageQuest.java b/src/main/java/noppes/npcs/client/gui/global/GuiNPCManageQuest.java index e12b5fc1e..36ef363cb 100644 --- a/src/main/java/noppes/npcs/client/gui/global/GuiNPCManageQuest.java +++ b/src/main/java/noppes/npcs/client/gui/global/GuiNPCManageQuest.java @@ -457,11 +457,12 @@ public class GuiNPCManageQuest extends GuiNPCInterface2 implements IScrollData, } } - public void save() {} + public void save() { + } @Override public void setData(Vector list, HashMap data, EnumScrollData type) { - if(type == EnumScrollData.QUEST_GROUP){ + if (type == EnumScrollData.QUEST_GROUP) { String name = questScroll.getSelected(); this.questData = data; questScroll.setList(getQuestSearch()); @@ -488,7 +489,8 @@ public class GuiNPCManageQuest extends GuiNPCInterface2 implements IScrollData, } @Override - public void setSelected(String selected) {} + public void setSelected(String selected) { + } @Override public void confirmClicked(boolean result, int id) { diff --git a/src/main/java/noppes/npcs/client/gui/global/GuiNPCManageTags.java b/src/main/java/noppes/npcs/client/gui/global/GuiNPCManageTags.java index 71a5c54c3..ec84783d2 100644 --- a/src/main/java/noppes/npcs/client/gui/global/GuiNPCManageTags.java +++ b/src/main/java/noppes/npcs/client/gui/global/GuiNPCManageTags.java @@ -18,194 +18,188 @@ import java.util.HashMap; import java.util.List; import java.util.Vector; -public class GuiNPCManageTags extends GuiNPCInterface2 implements IScrollData,ICustomScrollListener,ITextfieldListener, IGuiData, ISubGuiListener -{ - private GuiCustomScroll scrollTags; - private HashMap data = new HashMap(); - private Tag tag = new Tag(); - private String selected = null; - private String search = ""; +public class GuiNPCManageTags extends GuiNPCInterface2 implements IScrollData, ICustomScrollListener, ITextfieldListener, IGuiData, ISubGuiListener { + private GuiCustomScroll scrollTags; + private HashMap data = new HashMap(); + private Tag tag = new Tag(); + private String selected = null; + private String search = ""; - public GuiNPCManageTags(EntityNPCInterface npc) - { - super(npc); + public GuiNPCManageTags(EntityNPCInterface npc) { + super(npc); PacketClient.sendClient(new TagsGetPacket()); } - public void initGui() - { + public void initGui() { super.initGui(); - this.addButton(new GuiNpcButton(0,guiLeft + 368, guiTop + 8, 45, 20, "gui.add")); - this.addButton(new GuiNpcButton(1,guiLeft + 368, guiTop + 32, 45, 20, "gui.remove")); + this.addButton(new GuiNpcButton(0, guiLeft + 368, guiTop + 8, 45, 20, "gui.add")); + this.addButton(new GuiNpcButton(1, guiLeft + 368, guiTop + 32, 45, 20, "gui.remove")); - if(scrollTags == null){ - scrollTags = new GuiCustomScroll(this,0, 0); - scrollTags.setSize(143, 185); - } + if (scrollTags == null) { + scrollTags = new GuiCustomScroll(this, 0, 0); + scrollTags.setSize(143, 185); + } scrollTags.guiLeft = guiLeft + 220; scrollTags.guiTop = guiTop + 4; - addScroll(scrollTags); - addTextField(new GuiNpcTextField(55, this, fontRendererObj, guiLeft + 220, guiTop + 4 + 3 + 185, 143, 20, search)); + addScroll(scrollTags); + addTextField(new GuiNpcTextField(55, this, fontRendererObj, guiLeft + 220, guiTop + 4 + 3 + 185, 143, 20, search)); - if (tag.id == -1) - return; + if (tag.id == -1) + return; - this.addTextField(new GuiNpcTextField(0, this, guiLeft + 40, guiTop + 4, 136, 20, tag.name)); - getTextField(0).setMaxStringLength(20); - addLabel(new GuiNpcLabel(0,"gui.name", guiLeft + 8, guiTop + 9)); + this.addTextField(new GuiNpcTextField(0, this, guiLeft + 40, guiTop + 4, 136, 20, tag.name)); + getTextField(0).setMaxStringLength(20); + addLabel(new GuiNpcLabel(0, "gui.name", guiLeft + 8, guiTop + 9)); - addLabel(new GuiNpcLabel(10,"ID", guiLeft + 178, guiTop + 4)); - addLabel(new GuiNpcLabel(11, tag.id + "", guiLeft + 178, guiTop + 14)); + addLabel(new GuiNpcLabel(10, "ID", guiLeft + 178, guiTop + 4)); + addLabel(new GuiNpcLabel(11, tag.id + "", guiLeft + 178, guiTop + 14)); - String color = Integer.toHexString(tag.color); - while(color.length() < 6) - color = "0" + color; - addButton(new GuiNpcButton(10, guiLeft + 50, guiTop + 30, 60, 20, color)); - addLabel(new GuiNpcLabel(1,"gui.color", guiLeft + 8, guiTop + 35)); - getButton(10).setTextColor(tag.color); + String color = Integer.toHexString(tag.color); + while (color.length() < 6) + color = "0" + color; + addButton(new GuiNpcButton(10, guiLeft + 50, guiTop + 30, 60, 20, color)); + addLabel(new GuiNpcLabel(1, "gui.color", guiLeft + 8, guiTop + 35)); + getButton(10).setTextColor(tag.color); - addLabel(new GuiNpcLabel(3,"faction.hidden", guiLeft + 8, guiTop + 59)); - this.addButton(new GuiNpcButton(3,guiLeft + 50, guiTop + 54, 60, 20, new String[]{"gui.no","gui.yes"},tag.hideTag?1:0)); + addLabel(new GuiNpcLabel(3, "faction.hidden", guiLeft + 8, guiTop + 59)); + this.addButton(new GuiNpcButton(3, guiLeft + 50, guiTop + 54, 60, 20, new String[]{"gui.no", "gui.yes"}, tag.hideTag ? 1 : 0)); } - @Override - public void keyTyped(char c, int i) - { - super.keyTyped(c, i); - if(getTextField(55) != null){ - if(getTextField(55).isFocused()){ - if(search.equals(getTextField(55).getText())) - return; - search = getTextField(55).getText().toLowerCase(); - scrollTags.resetScroll(); - scrollTags.setList(getSearchList()); - } - } - } - - private List getSearchList(){ - if(search.isEmpty()){ - return new ArrayList(this.data.keySet()); - } - List list = new ArrayList(); - for(String name : this.data.keySet()){ - if(name.toLowerCase().contains(search)) - list.add(name); - } - return list; - } - @Override - protected void actionPerformed(GuiButton guibutton){ - GuiNpcButton button = (GuiNpcButton) guibutton; - if(button.id == 0){ - save(); - String name = "New"; - while(data.containsKey(name)) - name += "_"; - Tag tag = new Tag(-1, name, 0x00FF00); - - NBTTagCompound compound = new NBTTagCompound(); - tag.writeNBT(compound); - PacketClient.sendClient(new TagSavePacket(compound)); - } - if(button.id == 1){ - if(data.containsKey(scrollTags.getSelected())) { - PacketClient.sendClient(new TagRemovePacket(data.get(selected))); - scrollTags.clear(); - tag = new Tag(); - initGui(); - } - } - if(button.id == 3){ - tag.hideTag = button.getValue() == 1; - } - if(button.id == 10){ - this.setSubGui(new SubGuiColorSelector(tag.color)); + public void keyTyped(char c, int i) { + super.keyTyped(c, i); + if (getTextField(55) != null) { + if (getTextField(55).isFocused()) { + if (search.equals(getTextField(55).getText())) + return; + search = getTextField(55).getText().toLowerCase(); + scrollTags.resetScroll(); + scrollTags.setList(getSearchList()); + } } } - @Override - public void setGuiData(NBTTagCompound compound) { - this.tag = new Tag(); - tag.readNBT(compound); + private List getSearchList() { + if (search.isEmpty()) { + return new ArrayList(this.data.keySet()); + } + List list = new ArrayList(); + for (String name : this.data.keySet()) { + if (name.toLowerCase().contains(search)) + list.add(name); + } + return list; + } - setSelected(tag.name); - initGui(); - } + @Override + protected void actionPerformed(GuiButton guibutton) { + GuiNpcButton button = (GuiNpcButton) guibutton; + if (button.id == 0) { + save(); + String name = "New"; + while (data.containsKey(name)) + name += "_"; + Tag tag = new Tag(-1, name, 0x00FF00); + + NBTTagCompound compound = new NBTTagCompound(); + tag.writeNBT(compound); + PacketClient.sendClient(new TagSavePacket(compound)); + } + if (button.id == 1) { + if (data.containsKey(scrollTags.getSelected())) { + PacketClient.sendClient(new TagRemovePacket(data.get(selected))); + scrollTags.clear(); + tag = new Tag(); + initGui(); + } + } + if (button.id == 3) { + tag.hideTag = button.getValue() == 1; + } + if (button.id == 10) { + this.setSubGui(new SubGuiColorSelector(tag.color)); + } + } + + @Override + public void setGuiData(NBTTagCompound compound) { + this.tag = new Tag(); + tag.readNBT(compound); + + setSelected(tag.name); + initGui(); + } - @Override - public void setData(Vector list, HashMap data, EnumScrollData type) { - String name = scrollTags.getSelected(); - this.data = data; - scrollTags.setList(getSearchList()); + @Override + public void setData(Vector list, HashMap data, EnumScrollData type) { + String name = scrollTags.getSelected(); + this.data = data; + scrollTags.setList(getSearchList()); - if(name != null) - scrollTags.setSelected(name); - } + if (name != null) + scrollTags.setSelected(name); + } - @Override - public void setSelected(String selected) { - this.selected = selected; - scrollTags.setSelected(selected); - } + @Override + public void setSelected(String selected) { + this.selected = selected; + scrollTags.setSelected(selected); + } - @Override - public void customScrollClicked(int i, int j, int k, GuiCustomScroll guiCustomScroll) { - if(guiCustomScroll.id == 0) - { - save(); - selected = scrollTags.getSelected(); + @Override + public void customScrollClicked(int i, int j, int k, GuiCustomScroll guiCustomScroll) { + if (guiCustomScroll.id == 0) { + save(); + selected = scrollTags.getSelected(); PacketClient.sendClient(new TagGetPacket(data.get(selected))); - } - } + } + } - public void save() { - if(selected != null && data.containsKey(selected) && tag != null){ - NBTTagCompound compound = new NBTTagCompound(); - tag.writeNBT(compound); + public void save() { + if (selected != null && data.containsKey(selected) && tag != null) { + NBTTagCompound compound = new NBTTagCompound(); + tag.writeNBT(compound); PacketClient.sendClient(new TagSavePacket(compound)); - } - } + } + } - @Override - public void unFocused(GuiNpcTextField guiNpcTextField) { - if(tag.id == -1) - return; + @Override + public void unFocused(GuiNpcTextField guiNpcTextField) { + if (tag.id == -1) + return; - if(guiNpcTextField.id == 0) { - String name = guiNpcTextField.getText(); - if(!name.isEmpty() && !data.containsKey(name)){ - String old = tag.name; - data.remove(tag.name); - tag.name = name; - data.put(tag.name, tag.id); - selected = name; - scrollTags.replace(old,tag.name); - } - } else if(guiNpcTextField.id == 1) { - int color = 0; - try{ - color = Integer.parseInt(guiNpcTextField.getText(),16); - } - catch(NumberFormatException e){ - color = 0; - } - tag.color = color; - guiNpcTextField.setTextColor(tag.color); - } + if (guiNpcTextField.id == 0) { + String name = guiNpcTextField.getText(); + if (!name.isEmpty() && !data.containsKey(name)) { + String old = tag.name; + data.remove(tag.name); + tag.name = name; + data.put(tag.name, tag.id); + selected = name; + scrollTags.replace(old, tag.name); + } + } else if (guiNpcTextField.id == 1) { + int color = 0; + try { + color = Integer.parseInt(guiNpcTextField.getText(), 16); + } catch (NumberFormatException e) { + color = 0; + } + tag.color = color; + guiNpcTextField.setTextColor(tag.color); + } - } + } - @Override - public void subGuiClosed(SubGuiInterface subgui) { - if(subgui instanceof SubGuiColorSelector){ - tag.color = ((SubGuiColorSelector)subgui).color; - initGui(); - } - } + @Override + public void subGuiClosed(SubGuiInterface subgui) { + if (subgui instanceof SubGuiColorSelector) { + tag.color = ((SubGuiColorSelector) subgui).color; + initGui(); + } + } } diff --git a/src/main/java/noppes/npcs/client/gui/global/GuiNPCManageTransporters.java b/src/main/java/noppes/npcs/client/gui/global/GuiNPCManageTransporters.java index 57835c9ae..c40c9105a 100644 --- a/src/main/java/noppes/npcs/client/gui/global/GuiNPCManageTransporters.java +++ b/src/main/java/noppes/npcs/client/gui/global/GuiNPCManageTransporters.java @@ -20,121 +20,113 @@ import java.util.HashMap; import java.util.Vector; -public class GuiNPCManageTransporters extends GuiNPCInterface implements IScrollData -{ - private GuiNPCStringSlot slot; - private HashMap data; - private boolean selectCategory = true; - public GuiNPCManageTransporters(EntityNPCInterface npc) - { - super(npc); +public class GuiNPCManageTransporters extends GuiNPCInterface implements IScrollData { + private GuiNPCStringSlot slot; + private HashMap data; + private boolean selectCategory = true; + + public GuiNPCManageTransporters(EntityNPCInterface npc) { + super(npc); PacketClient.sendClient(new TransportCategoriesGetPacket()); - drawDefaultBackground = false; - title = "Transport Categories"; - data = new HashMap(); + drawDefaultBackground = false; + title = "Transport Categories"; + data = new HashMap(); } - public void initGui() - { + public void initGui() { super.initGui(); Vector list = new Vector(); - slot = new GuiNPCStringSlot(list,this,false,18); + slot = new GuiNPCStringSlot(list, this, false, 18); slot.registerScrollButtons(4, 5); - this.addButton(new GuiNpcButton(0,width / 2 - 100, height - 52, 65, 20, "gui.add")); - this.addButton(new GuiNpcButton(1,width / 2 - 33 , height - 52, 65, 20, "selectServer.edit")); - getButton(0).setEnabled(selectCategory); - getButton(1).setEnabled(selectCategory); - this.addButton(new GuiNpcButton(3, width / 2 + 33, height - 52,65, 20, "gui.remove")); - this.addButton(new GuiNpcButton(2, width / 2 -100, height - 31,98, 20, "gui.open")); - getButton(2).setEnabled(selectCategory); - this.addButton(new GuiNpcButton(4, width / 2 + 2, height - 31,98, 20, "gui.back")); + this.addButton(new GuiNpcButton(0, width / 2 - 100, height - 52, 65, 20, "gui.add")); + this.addButton(new GuiNpcButton(1, width / 2 - 33, height - 52, 65, 20, "selectServer.edit")); + getButton(0).setEnabled(selectCategory); + getButton(1).setEnabled(selectCategory); + this.addButton(new GuiNpcButton(3, width / 2 + 33, height - 52, 65, 20, "gui.remove")); + this.addButton(new GuiNpcButton(2, width / 2 - 100, height - 31, 98, 20, "gui.open")); + getButton(2).setEnabled(selectCategory); + this.addButton(new GuiNpcButton(4, width / 2 + 2, height - 31, 98, 20, "gui.back")); } - public void drawScreen(int i, int j, float f) - { - slot.drawScreen(i, j, f); + public void drawScreen(int i, int j, float f) { + slot.drawScreen(i, j, f); super.drawScreen(i, j, f); } - protected void actionPerformed(GuiButton guibutton) - { - int id = guibutton.id; - if(id == 0) - { - if(selectCategory){ - NoppesUtil.openGUI(player, new GuiNPCTransportCategoryEdit(npc, this, "", -1)); - }else{ + protected void actionPerformed(GuiButton guibutton) { + int id = guibutton.id; + if (id == 0) { + if (selectCategory) { + NoppesUtil.openGUI(player, new GuiNPCTransportCategoryEdit(npc, this, "", -1)); + } else { - } + } } - if(id == 1) - { - if(slot.selected == null || slot.selected.isEmpty()) - return; - if(selectCategory){ - NoppesUtil.openGUI(player, new GuiNPCTransportCategoryEdit(npc, this,slot.selected, data.get(slot.selected))); - }else{ + if (id == 1) { + if (slot.selected == null || slot.selected.isEmpty()) + return; + if (selectCategory) { + NoppesUtil.openGUI(player, new GuiNPCTransportCategoryEdit(npc, this, slot.selected, data.get(slot.selected))); + } else { - } + } } - if(id == 4) - { - if(selectCategory){ - close(); - NoppesUtil.openGUI(player, new GuiNPCGlobalMainMenu(npc)); - }else{ - title = "Transport Categories"; - selectCategory = true; + if (id == 4) { + if (selectCategory) { + close(); + NoppesUtil.openGUI(player, new GuiNPCGlobalMainMenu(npc)); + } else { + title = "Transport Categories"; + selectCategory = true; PacketClient.sendClient(new TransportCategoriesGetPacket()); - initGui(); - } + initGui(); + } } - if(id == 3) - { - if(slot.selected == null || slot.selected.isEmpty()) - return; - save(); - if(selectCategory){ + if (id == 3) { + if (slot.selected == null || slot.selected.isEmpty()) + return; + save(); + if (selectCategory) { PacketClient.sendClient(new TransportCategoryRemovePacket(data.get(slot.selected))); - } - else{ + } else { PacketClient.sendClient(new TransportRemovePacket(data.get(slot.selected))); - } - initGui(); + } + initGui(); } - if(id == 2) - { - doubleClicked(); + if (id == 2) { + doubleClicked(); } } - public void doubleClicked() { - if(slot.selected == null || slot.selected.isEmpty()) - return; - if(selectCategory){ - selectCategory = false; - title = "TransportLocations"; + + public void doubleClicked() { + if (slot.selected == null || slot.selected.isEmpty()) + return; + if (selectCategory) { + selectCategory = false; + title = "TransportLocations"; PacketClient.sendClient(new TransportsGetPacket(data.get(slot.selected))); - initGui(); - } + initGui(); + } - } - public void save() { - } + } - @Override - public void setData(Vector list, HashMap data, EnumScrollData type) { - this.data = data; - slot.setList(list); - } + public void save() { + } - @Override - public void setSelected(String selected) { + @Override + public void setData(Vector list, HashMap data, EnumScrollData type) { + this.data = data; + slot.setList(list); + } + + @Override + public void setSelected(String selected) { - } + } } diff --git a/src/main/java/noppes/npcs/client/gui/global/GuiNpcManageMagic.java b/src/main/java/noppes/npcs/client/gui/global/GuiNpcManageMagic.java index 7026acacb..601039db2 100644 --- a/src/main/java/noppes/npcs/client/gui/global/GuiNpcManageMagic.java +++ b/src/main/java/noppes/npcs/client/gui/global/GuiNpcManageMagic.java @@ -1,22 +1,22 @@ package noppes.npcs.client.gui.global; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Vector; - import kamkeel.npcs.network.PacketClient; import kamkeel.npcs.network.packets.request.magic.*; -import noppes.npcs.client.gui.SubGuiMagicCycle; +import net.minecraft.client.gui.GuiButton; +import net.minecraft.nbt.NBTTagCompound; import noppes.npcs.client.gui.SubGuiMagic; +import noppes.npcs.client.gui.SubGuiMagicCycle; import noppes.npcs.client.gui.SubGuiMagicCycleViewer; import noppes.npcs.client.gui.util.*; import noppes.npcs.constants.EnumScrollData; import noppes.npcs.controllers.data.Magic; import noppes.npcs.controllers.data.MagicCycle; import noppes.npcs.entity.EntityNPCInterface; -import net.minecraft.client.gui.GuiButton; -import net.minecraft.nbt.NBTTagCompound; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Vector; import static noppes.npcs.client.gui.player.inventory.GuiCNPCInventory.specialIcons; @@ -201,45 +201,45 @@ public class GuiNpcManageMagic extends GuiNPCInterface2 implements ISubGuiListen } - public void updateButtons(){ + public void updateButtons() { // Magic Buttons GuiButton button = getButton(2); - if(button != null){ + if (button != null) { button.enabled = selectedMagic != null; } - if(viewByCycle){ + if (viewByCycle) { button = getButton(1); - if(button != null){ + if (button != null) { button.enabled = selectedMagic != null; } } button = getButton(5); - if(button != null){ + if (button != null) { button.enabled = selectedCycle != null; } button = getButton(6); - if(button != null){ + if (button != null) { button.enabled = selectedCycle != null; } button = getButton(20); - if(button != null){ + if (button != null) { button.enabled = selectedCycle != null; } - if(getLabel(201) != null){ - if(selectedCycle != null){ + if (getLabel(201) != null) { + if (selectedCycle != null) { getLabel(201).label = selectedCycle.id + ""; } else { getLabel(201).label = ""; } } - if(getLabel(101) != null){ - if(selectedMagic != null){ + if (getLabel(101) != null) { + if (selectedMagic != null) { getLabel(101).label = selectedMagic.id + ""; } else { getLabel(101).label = ""; @@ -248,7 +248,8 @@ public class GuiNpcManageMagic extends GuiNPCInterface2 implements ISubGuiListen } @Override - public void save() {} + public void save() { + } @Override public void mouseClickMove(int mouseX, int mouseY, int clickedMouseButton, long timeSinceLastClick) { @@ -366,10 +367,10 @@ public class GuiNpcManageMagic extends GuiNPCInterface2 implements ISubGuiListen currentMagicList.clear(); } - if(rightScroll != null) + if (rightScroll != null) rightScroll.selected = -1; - if(leftScroll != null) + if (leftScroll != null) leftScroll.selected = -1; initGui(); @@ -456,7 +457,8 @@ public class GuiNpcManageMagic extends GuiNPCInterface2 implements ISubGuiListen } @Override - public void customScrollDoubleClicked(String selection, GuiCustomScroll scroll) {} + public void customScrollDoubleClicked(String selection, GuiCustomScroll scroll) { + } @Override public void subGuiClosed(SubGuiInterface subgui) { @@ -512,7 +514,8 @@ public class GuiNpcManageMagic extends GuiNPCInterface2 implements ISubGuiListen } @Override - public void setSelected(String selected) {} + public void setSelected(String selected) { + } @Override public void setGuiData(NBTTagCompound compound) { diff --git a/src/main/java/noppes/npcs/client/gui/global/GuiNpcManagePlayerData.java b/src/main/java/noppes/npcs/client/gui/global/GuiNpcManagePlayerData.java index 84b2e975b..e66019bbd 100644 --- a/src/main/java/noppes/npcs/client/gui/global/GuiNpcManagePlayerData.java +++ b/src/main/java/noppes/npcs/client/gui/global/GuiNpcManagePlayerData.java @@ -61,14 +61,16 @@ public class GuiNpcManagePlayerData extends GuiNPCInterface2 implements GuiYesNo } @Override - public void mouseClicked(int i, int j, int k) {; + public void mouseClicked(int i, int j, int k) { + ; super.mouseClicked(i, j, k); if (k == 0 && playerScroll != null) playerScroll.mouseClicked(i, j, k); } @Override - public void save() {} + public void save() { + } @Override public void keyTyped(char c, int i) { @@ -147,8 +149,10 @@ public class GuiNpcManagePlayerData extends GuiNPCInterface2 implements GuiYesNo } @Override - public void customScrollDoubleClicked(String selection, GuiCustomScroll scroll) {} + public void customScrollDoubleClicked(String selection, GuiCustomScroll scroll) { + } - public void subGuiClosed(SubGuiInterface subgui) {} + public void subGuiClosed(SubGuiInterface subgui) { + } } diff --git a/src/main/java/noppes/npcs/client/gui/global/GuiNpcManageRecipes.java b/src/main/java/noppes/npcs/client/gui/global/GuiNpcManageRecipes.java index 1189a2208..4fa1dd407 100644 --- a/src/main/java/noppes/npcs/client/gui/global/GuiNpcManageRecipes.java +++ b/src/main/java/noppes/npcs/client/gui/global/GuiNpcManageRecipes.java @@ -26,39 +26,39 @@ import java.util.HashMap; import java.util.List; import java.util.Vector; -public class GuiNpcManageRecipes extends GuiContainerNPCInterface2 implements IScrollData, IGuiData, ICustomScrollListener, ITextfieldListener, ISubGuiListener { +public class GuiNpcManageRecipes extends GuiContainerNPCInterface2 implements IScrollData, IGuiData, ICustomScrollListener, ITextfieldListener, ISubGuiListener { public static int tab = 1; public GuiCustomScroll scroll; - public HashMap data = new HashMap(); - private ContainerManageRecipes container; - private String selected = null; - private ResourceLocation slot; - private String search = ""; + public HashMap data = new HashMap(); + private ContainerManageRecipes container; + private String selected = null; + private ResourceLocation slot; + private String search = ""; - public GuiNpcManageRecipes(EntityNPCInterface npc,ContainerManageRecipes container){ - super(npc,container); - this.container = container; - drawDefaultBackground = false; + public GuiNpcManageRecipes(EntityNPCInterface npc, ContainerManageRecipes container) { + super(npc, container); + this.container = container; + drawDefaultBackground = false; PacketClient.sendClient(new RecipesGetPacket(container.width)); setBackground("inventorymenu.png"); slot = getResource("slot.png"); ySize = 200; - if(container.width == 1){ + if (container.width == 1) { tab = 2; - } else if (container.width == 3){ + } else if (container.width == 3) { tab = 0; } else { tab = 1; } } - @Override - public void initGui(){ + @Override + public void initGui() { super.initGui(); - if(scroll == null) - scroll = new GuiCustomScroll(this,0,0); + if (scroll == null) + scroll = new GuiCustomScroll(this, 0, 0); scroll.setSize(130, 150); scroll.guiLeft = guiLeft + 280; scroll.guiTop = guiTop + 38; @@ -66,13 +66,13 @@ public class GuiNpcManageRecipes extends GuiContainerNPCInterface2 implements IS int y = guiTop + 10; - this.addButton(new GuiButtonBiDirectional(0,guiLeft + 280, y, 130, 20, new String[]{"menu.global", "tile.npcCarpentyBench.name", "tile.anvil.name"}, tab)); + this.addButton(new GuiButtonBiDirectional(0, guiLeft + 280, y, 130, 20, new String[]{"menu.global", "tile.npcCarpentyBench.name", "tile.anvil.name"}, tab)); - y+= 106; + y += 106; - this.addButton(new GuiNpcButton(3,guiLeft + 226, y += 22, 50, 20, "gui.add")); - this.addButton(new GuiNpcButton(4,guiLeft + 226, y += 22, 50, 20, "gui.remove")); - this.addButton(new GuiNpcButton(10,guiLeft + 226, y += 30, 50, 20, "gui.copy")); + this.addButton(new GuiNpcButton(3, guiLeft + 226, y += 22, 50, 20, "gui.add")); + this.addButton(new GuiNpcButton(4, guiLeft + 226, y += 22, 50, 20, "gui.remove")); + this.addButton(new GuiNpcButton(10, guiLeft + 226, y += 30, 50, 20, "gui.copy")); if (container.width != 1) { int buttonPos = guiTop + 72; @@ -125,64 +125,63 @@ public class GuiNpcManageRecipes extends GuiContainerNPCInterface2 implements IS this.addTextField(new GuiNpcTextField(0, this, fontRendererObj, guiLeft + 8, guiTop + 8, 160, 20, container.recipeAnvil.name)); this.getTextField(0).enabled = false; } - this.addTextField(new GuiNpcTextField(55, this, fontRendererObj, guiLeft + 280, guiTop + 8 + 3 + 180, 130, 20, search)); - } + this.addTextField(new GuiNpcTextField(55, this, fontRendererObj, guiLeft + 280, guiTop + 8 + 3 + 180, 130, 20, search)); + } - @Override - protected void actionPerformed(GuiButton guibutton){ - GuiNpcButton button = (GuiNpcButton) guibutton; - if(button.id == 0){ + @Override + protected void actionPerformed(GuiButton guibutton) { + GuiNpcButton button = (GuiNpcButton) guibutton; + if (button.id == 0) { GuiButtonBiDirectional buttonBiDirectional = (GuiButtonBiDirectional) button; tab = buttonBiDirectional.getValue(); - if(tab == 0){ + if (tab == 0) { getTextField(55).setText(""); search = ""; scroll.clear(); save(); - NoppesUtil.requestOpenGUI(EnumGuiType.ManageRecipes,3,0,0); - } else if (tab == 1){ + NoppesUtil.requestOpenGUI(EnumGuiType.ManageRecipes, 3, 0, 0); + } else if (tab == 1) { getTextField(55).setText(""); search = ""; scroll.clear(); save(); - NoppesUtil.requestOpenGUI(EnumGuiType.ManageRecipes,4,0,0); + NoppesUtil.requestOpenGUI(EnumGuiType.ManageRecipes, 4, 0, 0); } else { getTextField(55).setText(""); search = ""; scroll.clear(); save(); - NoppesUtil.requestOpenGUI(EnumGuiType.ManageRecipes,1,0,0); + NoppesUtil.requestOpenGUI(EnumGuiType.ManageRecipes, 1, 0, 0); } } - if(button.id == 3){ - save(); - scroll.clear(); - String name = "New"; - while(data.containsKey(name)) - name += "_"; + if (button.id == 3) { + save(); + scroll.clear(); + String name = "New"; + while (data.containsKey(name)) + name += "_"; - if(container.width == 1){ + if (container.width == 1) { RecipeAnvil recipe = new RecipeAnvil(); recipe.name = name; PacketClient.sendClient(new RecipeSavePacket(recipe.writeNBT())); - } - else { + } else { RecipeCarpentry recipe = new RecipeCarpentry(name); recipe.isGlobal = container.width == 3; PacketClient.sendClient(new RecipeSavePacket(recipe.writeNBT())); } } - if(button.id == 4){ - if(data.containsKey(scroll.getSelected())){ + if (button.id == 4) { + if (data.containsKey(scroll.getSelected())) { PacketClient.sendClient(new RecipeRemovePacket(data.get(scroll.getSelected()), container.width == 1)); - scroll.clear(); - } + scroll.clear(); + } } - if(button.id == 5){ - container.recipe.ignoreDamage = button.getValue() == 1; + if (button.id == 5) { + container.recipe.ignoreDamage = button.getValue() == 1; } - if(button.id == 6){ - container.recipe.ignoreNBT = button.getValue() == 1; + if (button.id == 6) { + container.recipe.ignoreNBT = button.getValue() == 1; } if (button.id == 7) { container.recipeAnvil.ignoreRepairMaterialDamage = button.getValue() == 1; @@ -193,9 +192,9 @@ public class GuiNpcManageRecipes extends GuiContainerNPCInterface2 implements IS if (button.id == 9) { container.recipeAnvil.ignoreRepairItemNBT = button.getValue() == 1; } - if(button.id == 15){ + if (button.id == 15) { save(); - if(container.width == 1){ + if (container.width == 1) { setSubGui(new SubGuiNpcAvailability(container.recipeAnvil.availability)); } else { setSubGui(new SubGuiNpcAvailability(container.recipe.availability)); @@ -203,32 +202,31 @@ public class GuiNpcManageRecipes extends GuiContainerNPCInterface2 implements IS } } - @Override - public void keyTyped(char c, int i) - { - super.keyTyped(c, i); - if(getTextField(55) != null){ - if(getTextField(55).isFocused()){ - if(search.equals(getTextField(55).getText())) - return; - search = getTextField(55).getText().toLowerCase(); + @Override + public void keyTyped(char c, int i) { + super.keyTyped(c, i); + if (getTextField(55) != null) { + if (getTextField(55).isFocused()) { + if (search.equals(getTextField(55).getText())) + return; + search = getTextField(55).getText().toLowerCase(); scroll.resetScroll(); - scroll.setList(getSearchList()); - } - } - } + scroll.setList(getSearchList()); + } + } + } - private List getSearchList(){ - if(search.isEmpty()){ - return new ArrayList(this.data.keySet()); - } - List list = new ArrayList(); - for(String name : this.data.keySet()){ - if(name.toLowerCase().contains(search)) - list.add(name); - } - return list; - } + private List getSearchList() { + if (search.isEmpty()) { + return new ArrayList(this.data.keySet()); + } + List list = new ArrayList(); + for (String name : this.data.keySet()) { + if (name.toLowerCase().contains(search)) + list.add(name); + } + return list; + } @Override public void setGuiData(NBTTagCompound compound) { @@ -245,8 +243,8 @@ public class GuiNpcManageRecipes extends GuiContainerNPCInterface2 implements IS } } - private void fixButtons(){ - if(tab == 2){ + private void fixButtons() { + if (tab == 2) { getTextField(0).setText(container.recipeAnvil.name); getTextField(1).setText(container.recipeAnvil.getRepairPercentage() + ""); getTextField(2).setText(container.recipeAnvil.getXpCost() + ""); @@ -256,9 +254,9 @@ public class GuiNpcManageRecipes extends GuiContainerNPCInterface2 implements IS getTextField(1).enabled = true; getTextField(2).enabled = true; - GuiNpcButtonYesNo btnMatDamage = (GuiNpcButtonYesNo)this.getButton(7); - GuiNpcButtonYesNo btnMatNBT = (GuiNpcButtonYesNo)this.getButton(8); - GuiNpcButtonYesNo btnItemNBT = (GuiNpcButtonYesNo)this.getButton(9); + GuiNpcButtonYesNo btnMatDamage = (GuiNpcButtonYesNo) this.getButton(7); + GuiNpcButtonYesNo btnMatNBT = (GuiNpcButtonYesNo) this.getButton(8); + GuiNpcButtonYesNo btnItemNBT = (GuiNpcButtonYesNo) this.getButton(9); if (btnMatDamage != null) { btnMatDamage.setDisplay(container.recipeAnvil.ignoreRepairMaterialDamage ? 1 : 0); btnMatDamage.setEnabled(true); @@ -273,7 +271,7 @@ public class GuiNpcManageRecipes extends GuiContainerNPCInterface2 implements IS } GuiNpcButton avail = this.getButton(15); - if(avail != null) + if (avail != null) avail.setEnabled(true); } else { getTextField(0).setText(container.recipe.name); @@ -285,41 +283,42 @@ public class GuiNpcManageRecipes extends GuiContainerNPCInterface2 implements IS this.getButton(6).setDisplay(container.recipe.ignoreNBT ? 1 : 0); setSelected(container.recipe.name); - if(!container.recipe.isGlobal){ + if (!container.recipe.isGlobal) { GuiNpcButton avail = this.getButton(15); - if(avail != null) + if (avail != null) avail.setEnabled(true); } } } - @Override - protected void drawGuiContainerBackgroundLayer(float f, int x, int y){ - super.drawGuiContainerBackgroundLayer(f, x, y); + @Override + protected void drawGuiContainerBackgroundLayer(float f, int x, int y) { + super.drawGuiContainerBackgroundLayer(f, x, y); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); mc.renderEngine.bindTexture(slot); - for(int i = 0; i < container.width;i++){ - for(int j = 0; j < container.width;j++){ - drawTexturedModalRect(guiLeft + i*18 + 7, guiTop + j*18 + 34, 0, 0, 18, 18); - } - } + for (int i = 0; i < container.width; i++) { + for (int j = 0; j < container.width; j++) { + drawTexturedModalRect(guiLeft + i * 18 + 7, guiTop + j * 18 + 34, 0, 0, 18, 18); + } + } - if(container.width == 1){ + if (container.width == 1) { drawTexturedModalRect(guiLeft + 101, guiTop + 34, 0, 0, 18, 18); this.fontRendererObj.drawString(StatCollector.translateToLocal("gui.material"), guiLeft + 28, guiTop + 38, CustomNpcResourceListener.DefaultTextColor); } else { drawTexturedModalRect(guiLeft + 86, guiTop + 60, 0, 0, 18, 18); } } - @Override - public void setData(Vector list, HashMap data, EnumScrollData type) { - String name = scroll.getSelected(); - this.data = data; - scroll.setList(getSearchList()); + + @Override + public void setData(Vector list, HashMap data, EnumScrollData type) { + String name = scroll.getSelected(); + this.data = data; + scroll.setList(getSearchList()); this.getTextField(0).enabled = name != null; - if(container.width == 1){ + if (container.width == 1) { this.getButton(7).setEnabled(name != null); this.getButton(8).setEnabled(name != null); this.getButton(9).setEnabled(name != null); @@ -328,79 +327,79 @@ public class GuiNpcManageRecipes extends GuiContainerNPCInterface2 implements IS this.getButton(6).setEnabled(name != null); } - if(name != null) - scroll.setSelected(name); - } + if (name != null) + scroll.setSelected(name); + } - @Override - public void setSelected(String selected) { - this.selected = selected; - scroll.setSelected(selected); - } + @Override + public void setSelected(String selected) { + this.selected = selected; + scroll.setSelected(selected); + } - @Override - public void customScrollClicked(int i, int j, int k, GuiCustomScroll guiCustomScroll) { - save(); - selected = scroll.getSelected(); - if(container.width == 1){ + @Override + public void customScrollClicked(int i, int j, int k, GuiCustomScroll guiCustomScroll) { + save(); + selected = scroll.getSelected(); + if (container.width == 1) { PacketClient.sendClient(new RecipeGetPacket(data.get(selected), true)); } else { PacketClient.sendClient(new RecipeGetPacket(data.get(selected), false)); } - } + } - @Override - public void save() { - GuiNpcTextField.unfocus(); - if(selected != null && data.containsKey(selected)){ - container.saveRecipe(); - if(container.width == 1){ + @Override + public void save() { + GuiNpcTextField.unfocus(); + if (selected != null && data.containsKey(selected)) { + container.saveRecipe(); + if (container.width == 1) { PacketClient.sendClient(new RecipeSavePacket(container.recipeAnvil.writeNBT())); } else { PacketClient.sendClient(new RecipeSavePacket(container.recipe.writeNBT())); } - } - } + } + } - @Override - public void unFocused(GuiNpcTextField guiNpcTextField) { - if(guiNpcTextField.id == 0){ - String name = guiNpcTextField.getText(); - if(!name.isEmpty() && !data.containsKey(name)){ - if(container.width == 1){ + @Override + public void unFocused(GuiNpcTextField guiNpcTextField) { + if (guiNpcTextField.id == 0) { + String name = guiNpcTextField.getText(); + if (!name.isEmpty() && !data.containsKey(name)) { + if (container.width == 1) { String old = container.recipeAnvil.name; data.remove(container.recipeAnvil.name); container.recipeAnvil.name = name; data.put(container.recipeAnvil.name, container.recipeAnvil.id); selected = name; - scroll.replace(old,container.recipeAnvil.name); + scroll.replace(old, container.recipeAnvil.name); } else { String old = container.recipe.name; data.remove(container.recipe.name); container.recipe.name = name; data.put(container.recipe.name, container.recipe.id); selected = name; - scroll.replace(old,container.recipe.name); + scroll.replace(old, container.recipe.name); } - } - } - if(guiNpcTextField.id == 1){ + } + } + if (guiNpcTextField.id == 1) { float percent = guiNpcTextField.getFloat(); - if(container.width == 1){ + if (container.width == 1) { container.recipeAnvil.repairPercentage = percent; } } - if(guiNpcTextField.id == 2){ + if (guiNpcTextField.id == 2) { int xpCost = guiNpcTextField.getInteger(); - if(container.width == 1){ + if (container.width == 1) { container.recipeAnvil.xpCost = xpCost; } } - } + } @Override - public void subGuiClosed(SubGuiInterface subgui){ - if(subgui instanceof SubGuiNpcAvailability) + public void subGuiClosed(SubGuiInterface subgui) { + if (subgui instanceof SubGuiNpcAvailability) fixButtons(); } } diff --git a/src/main/java/noppes/npcs/client/gui/global/GuiNpcNaturalSpawns.java b/src/main/java/noppes/npcs/client/gui/global/GuiNpcNaturalSpawns.java index 5239f5e5b..ca5b7fe9e 100644 --- a/src/main/java/noppes/npcs/client/gui/global/GuiNpcNaturalSpawns.java +++ b/src/main/java/noppes/npcs/client/gui/global/GuiNpcNaturalSpawns.java @@ -19,261 +19,260 @@ import noppes.npcs.entity.EntityNPCInterface; import java.util.*; -public class GuiNpcNaturalSpawns extends GuiNPCInterface2 implements IGuiData, IScrollData, ITextfieldListener, ICustomScrollListener, ISliderListener{ - private GuiCustomScroll scrollNaturalSpawns; - private final GuiCustomScroll spawnEntryScroll = new GuiCustomScroll(this, 20, false); - private HashMap data = new HashMap(); - private String search = ""; +public class GuiNpcNaturalSpawns extends GuiNPCInterface2 implements IGuiData, IScrollData, ITextfieldListener, ICustomScrollListener, ISliderListener { + private GuiCustomScroll scrollNaturalSpawns; + private final GuiCustomScroll spawnEntryScroll = new GuiCustomScroll(this, 20, false); + private HashMap data = new HashMap(); + private String search = ""; - private SpawnData spawn = new SpawnData(); + private SpawnData spawn = new SpawnData(); - public GuiNpcNaturalSpawns(EntityNPCInterface npc) { - super(npc); + public GuiNpcNaturalSpawns(EntityNPCInterface npc) { + super(npc); PacketClient.sendClient(new NaturalSpawnGetAllPacket()); - } - - @Override - public void initGui(){ - super.initGui(); - if(this.scrollNaturalSpawns == null){ - this.scrollNaturalSpawns = new GuiCustomScroll(this,0,0); - this.scrollNaturalSpawns.setSize(143, 185); - } - this.scrollNaturalSpawns.guiLeft = guiLeft + 214; - this.scrollNaturalSpawns.guiTop = guiTop + 4; - this.addScroll(this.scrollNaturalSpawns); - addTextField(new GuiNpcTextField(55, this, fontRendererObj, guiLeft + 214, guiTop + 4 + 3 + 185, 143, 20, search)); - - this.addButton(new GuiNpcButton(1,guiLeft + 358, guiTop + 38, 58, 20, "gui.add")); - this.addButton(new GuiNpcButton(2,guiLeft + 358, guiTop + 61, 58, 20, "gui.remove")); - - if(this.spawn.id >= 0) - showSpawn(); - } - - private void showSpawn() { - addLabel(new GuiNpcLabel(1,"gui.title", guiLeft + 4, guiTop + 8)); - addTextField(new GuiNpcTextField(1, this, this.fontRendererObj, guiLeft + 60, guiTop + 3, 140, 20, this.spawn.name)); - - int y = guiTop + 30; - addLabel(new GuiNpcLabel(3,"spawning.biomes", guiLeft + 4, y)); - addButton(new GuiNpcButton(3, guiLeft + 40, y - 5, 50, 20, "selectServer.edit")); - - addLabel(new GuiNpcLabel(11,StatCollector.translateToLocal("Dimensions"), guiLeft + 95, y)); - addButton(new GuiNpcButton(11, guiLeft + 150, y - 5, 50, 20, "selectServer.edit")); - - addLabel(new GuiNpcLabel(4,"spawning.options", guiLeft + 4, y += 22)); - addButton(new GuiNpcButton(4, guiLeft + 90, y - 5, 50, 20, "selectServer.edit")); - - addSlider(new GuiNpcSlider(this, 5, guiLeft + 4, y += 17, 180, 20, (float)this.spawn.itemWeight / 100)); - - this.spawnEntryScroll.guiLeft = guiLeft + 4; - this.spawnEntryScroll.guiTop = y + 40; - this.spawnEntryScroll.setSize(50, 102); - ArrayList list = new ArrayList<>(); - Set keySet = this.spawn.spawnCompounds.keySet(); - for (int i : keySet) { - list.add(String.valueOf(i)); - } - this.spawnEntryScroll.setList(list); - addScroll(this.spawnEntryScroll); - - addButton(new GuiNpcButton(21, guiLeft + 6, y += 20, 20, 20, "+")); - if (this.spawnEntryScroll.hasSelected()) { - int selected = Integer.parseInt(this.spawnEntryScroll.getSelected()); - addButton(new GuiNpcButton(22, guiLeft + 32, y, 20, 20, "-")); - GuiNpcTextField num = new GuiNpcTextField(25, this, guiLeft + 60, y += 10, 30, 20, String.valueOf(selected)); - num.integersOnly = true; - addTextField(num); - addButton(new GuiNpcButton(26, guiLeft + 92, y, 100, 20, this.getTitle(this.spawn.spawnCompounds.get(selected)))); - } - } - - @Override - public void keyTyped(char c, int i) - { - super.keyTyped(c, i); - if(getTextField(55) != null){ - if(getTextField(55).isFocused()){ - if(search.equals(getTextField(55).getText())) - return; - search = getTextField(55).getText().toLowerCase(); - scrollNaturalSpawns.resetScroll(); - scrollNaturalSpawns.setList(getSearchList()); - } - } - } - - private List getSearchList(){ - if(search.isEmpty()){ - return new ArrayList(this.data.keySet()); - } - List list = new ArrayList(); - for(String name : this.data.keySet()){ - if(name.toLowerCase().contains(search)) - list.add(name); - } - return list; - } - - private String getTitle(NBTTagCompound compound) { - if(compound != null && compound.hasKey("ClonedName")) - return compound.getString("ClonedName"); - return "gui.selectnpc"; - } + } @Override - public void buttonEvent(GuiButton guibutton){ - int id = guibutton.id; - if(id == 1){ - save(); - String name = "New"; - while(data.containsKey(name)) - name += "_"; + public void initGui() { + super.initGui(); + if (this.scrollNaturalSpawns == null) { + this.scrollNaturalSpawns = new GuiCustomScroll(this, 0, 0); + this.scrollNaturalSpawns.setSize(143, 185); + } + this.scrollNaturalSpawns.guiLeft = guiLeft + 214; + this.scrollNaturalSpawns.guiTop = guiTop + 4; + this.addScroll(this.scrollNaturalSpawns); + addTextField(new GuiNpcTextField(55, this, fontRendererObj, guiLeft + 214, guiTop + 4 + 3 + 185, 143, 20, search)); - SpawnData spawn = new SpawnData(); - spawn.name = name; + this.addButton(new GuiNpcButton(1, guiLeft + 358, guiTop + 38, 58, 20, "gui.add")); + this.addButton(new GuiNpcButton(2, guiLeft + 358, guiTop + 61, 58, 20, "gui.remove")); + + if (this.spawn.id >= 0) + showSpawn(); + } + + private void showSpawn() { + addLabel(new GuiNpcLabel(1, "gui.title", guiLeft + 4, guiTop + 8)); + addTextField(new GuiNpcTextField(1, this, this.fontRendererObj, guiLeft + 60, guiTop + 3, 140, 20, this.spawn.name)); + + int y = guiTop + 30; + addLabel(new GuiNpcLabel(3, "spawning.biomes", guiLeft + 4, y)); + addButton(new GuiNpcButton(3, guiLeft + 40, y - 5, 50, 20, "selectServer.edit")); + + addLabel(new GuiNpcLabel(11, StatCollector.translateToLocal("Dimensions"), guiLeft + 95, y)); + addButton(new GuiNpcButton(11, guiLeft + 150, y - 5, 50, 20, "selectServer.edit")); + + addLabel(new GuiNpcLabel(4, "spawning.options", guiLeft + 4, y += 22)); + addButton(new GuiNpcButton(4, guiLeft + 90, y - 5, 50, 20, "selectServer.edit")); + + addSlider(new GuiNpcSlider(this, 5, guiLeft + 4, y += 17, 180, 20, (float) this.spawn.itemWeight / 100)); + + this.spawnEntryScroll.guiLeft = guiLeft + 4; + this.spawnEntryScroll.guiTop = y + 40; + this.spawnEntryScroll.setSize(50, 102); + ArrayList list = new ArrayList<>(); + Set keySet = this.spawn.spawnCompounds.keySet(); + for (int i : keySet) { + list.add(String.valueOf(i)); + } + this.spawnEntryScroll.setList(list); + addScroll(this.spawnEntryScroll); + + addButton(new GuiNpcButton(21, guiLeft + 6, y += 20, 20, 20, "+")); + if (this.spawnEntryScroll.hasSelected()) { + int selected = Integer.parseInt(this.spawnEntryScroll.getSelected()); + addButton(new GuiNpcButton(22, guiLeft + 32, y, 20, 20, "-")); + GuiNpcTextField num = new GuiNpcTextField(25, this, guiLeft + 60, y += 10, 30, 20, String.valueOf(selected)); + num.integersOnly = true; + addTextField(num); + addButton(new GuiNpcButton(26, guiLeft + 92, y, 100, 20, this.getTitle(this.spawn.spawnCompounds.get(selected)))); + } + } + + @Override + public void keyTyped(char c, int i) { + super.keyTyped(c, i); + if (getTextField(55) != null) { + if (getTextField(55).isFocused()) { + if (search.equals(getTextField(55).getText())) + return; + search = getTextField(55).getText().toLowerCase(); + scrollNaturalSpawns.resetScroll(); + scrollNaturalSpawns.setList(getSearchList()); + } + } + } + + private List getSearchList() { + if (search.isEmpty()) { + return new ArrayList(this.data.keySet()); + } + List list = new ArrayList(); + for (String name : this.data.keySet()) { + if (name.toLowerCase().contains(search)) + list.add(name); + } + return list; + } + + private String getTitle(NBTTagCompound compound) { + if (compound != null && compound.hasKey("ClonedName")) + return compound.getString("ClonedName"); + return "gui.selectnpc"; + } + + @Override + public void buttonEvent(GuiButton guibutton) { + int id = guibutton.id; + if (id == 1) { + save(); + String name = "New"; + while (data.containsKey(name)) + name += "_"; + + SpawnData spawn = new SpawnData(); + spawn.name = name; PacketClient.sendClient(new NaturalSpawnSavePacket(spawn.writeNBT(new NBTTagCompound()))); - this.spawnEntryScroll.selected = -1; + this.spawnEntryScroll.selected = -1; } - if(id == 2){ - if(data.containsKey(scrollNaturalSpawns.getSelected())) { + if (id == 2) { + if (data.containsKey(scrollNaturalSpawns.getSelected())) { PacketClient.sendClient(new NaturalSpawnRemovePacket(spawn.id)); - spawn = new SpawnData(); - scrollNaturalSpawns.clear(); - this.spawnEntryScroll.selected = -1; - } + spawn = new SpawnData(); + scrollNaturalSpawns.clear(); + this.spawnEntryScroll.selected = -1; + } } - if(id == 3){ - setSubGui(new SubGuiNpcBiomes(spawn)); + if (id == 3) { + setSubGui(new SubGuiNpcBiomes(spawn)); + } + if (id == 11) { + setSubGui(new SubGuiNpcDimensions(spawn)); + } + if (id == 4) { + setSubGui(new SubGuiSpawningOptions(spawn)); + } + if (id == 21) { + int addId = 0; + if (this.spawnEntryScroll.hasSelected()) { + int selected = Integer.parseInt(spawnEntryScroll.getSelected()); + ArrayList keys = new ArrayList<>(this.spawn.spawnCompounds.keySet()); + int keyIndex = keys.indexOf(selected); + do { + addId = keys.get(keyIndex) + 1; + keyIndex++; + } while (this.spawn.spawnCompounds.containsKey(addId)); + } else if (this.spawn.spawnCompounds.size() > 0) { + addId = (Integer) this.spawn.spawnCompounds.keySet().toArray()[this.spawn.spawnCompounds.size() - 1] + 1; + } + this.spawn.spawnCompounds.put(addId, new NBTTagCompound()); + this.initGui(); + } + if (id == 22) { + if (this.spawnEntryScroll.hasSelected()) { + int selected = Integer.parseInt(spawnEntryScroll.getSelected()); + this.spawn.spawnCompounds.remove(selected); + this.spawnEntryScroll.selected = -1; + this.initGui(); + } } - if(id == 11){ - setSubGui(new SubGuiNpcDimensions(spawn)); - } - if(id == 4){ - setSubGui(new SubGuiSpawningOptions(spawn)); - } - if (id == 21) { - int addId = 0; - if (this.spawnEntryScroll.hasSelected()) { - int selected = Integer.parseInt(spawnEntryScroll.getSelected()); - ArrayList keys = new ArrayList<>(this.spawn.spawnCompounds.keySet()); - int keyIndex = keys.indexOf(selected); - do { - addId = keys.get(keyIndex) + 1; - keyIndex++; - } while (this.spawn.spawnCompounds.containsKey(addId)); - } else if (this.spawn.spawnCompounds.size() > 0) { - addId = (Integer) this.spawn.spawnCompounds.keySet().toArray()[this.spawn.spawnCompounds.size() - 1] + 1; - } - this.spawn.spawnCompounds.put(addId, new NBTTagCompound()); - this.initGui(); - } - if (id == 22) { - if (this.spawnEntryScroll.hasSelected()) { - int selected = Integer.parseInt(spawnEntryScroll.getSelected()); - this.spawn.spawnCompounds.remove(selected); - this.spawnEntryScroll.selected = -1; - this.initGui(); - } - } if (id == 26) { - setSubGui(new GuiNpcMobSpawnerSelector()); + setSubGui(new GuiNpcMobSpawnerSelector()); } } - @Override - public void unFocused(GuiNpcTextField textfield) { - if (textfield.id == 1) { - String name = textfield.getText(); - if (name.isEmpty() || data.containsKey(name)) { - textfield.setText(spawn.name); - } else { - String old = spawn.name; - data.remove(old); - spawn.name = name; - data.put(spawn.name, spawn.id); - scrollNaturalSpawns.replace(old, spawn.name); - } - } - if (textfield.id == 25 && this.spawnEntryScroll.hasSelected()) { - int selected = Integer.parseInt(spawnEntryScroll.getSelected()); - if (spawnEntryScroll.getList().contains(String.valueOf(textfield.getInteger()))) { - textfield.setText(String.valueOf(selected)); - return; - } - NBTTagCompound compound = spawn.spawnCompounds.get(selected); - spawn.spawnCompounds.remove(selected); - spawn.spawnCompounds.put(textfield.getInteger(), compound); - spawnEntryScroll.selected = -1; - initGui(); - } - } + @Override + public void unFocused(GuiNpcTextField textfield) { + if (textfield.id == 1) { + String name = textfield.getText(); + if (name.isEmpty() || data.containsKey(name)) { + textfield.setText(spawn.name); + } else { + String old = spawn.name; + data.remove(old); + spawn.name = name; + data.put(spawn.name, spawn.id); + scrollNaturalSpawns.replace(old, spawn.name); + } + } + if (textfield.id == 25 && this.spawnEntryScroll.hasSelected()) { + int selected = Integer.parseInt(spawnEntryScroll.getSelected()); + if (spawnEntryScroll.getList().contains(String.valueOf(textfield.getInteger()))) { + textfield.setText(String.valueOf(selected)); + return; + } + NBTTagCompound compound = spawn.spawnCompounds.get(selected); + spawn.spawnCompounds.remove(selected); + spawn.spawnCompounds.put(textfield.getInteger(), compound); + spawnEntryScroll.selected = -1; + initGui(); + } + } - @Override - public void setData(Vector list, HashMap data, EnumScrollData type) { - String name = scrollNaturalSpawns.getSelected(); - this.data = data; - scrollNaturalSpawns.setList(getSearchList()); + @Override + public void setData(Vector list, HashMap data, EnumScrollData type) { + String name = scrollNaturalSpawns.getSelected(); + this.data = data; + scrollNaturalSpawns.setList(getSearchList()); - if(name != null) - scrollNaturalSpawns.setSelected(name); - initGui(); - } + if (name != null) + scrollNaturalSpawns.setSelected(name); + initGui(); + } - @Override - public void customScrollClicked(int i, int j, int k, GuiCustomScroll guiCustomScroll) { - if (guiCustomScroll.id == 0){ - save(); - String selected = scrollNaturalSpawns.getSelected(); - spawn = new SpawnData(); + @Override + public void customScrollClicked(int i, int j, int k, GuiCustomScroll guiCustomScroll) { + if (guiCustomScroll.id == 0) { + save(); + String selected = scrollNaturalSpawns.getSelected(); + spawn = new SpawnData(); PacketClient.sendClient(new NaturalSpawnGetPacket(data.get(selected))); - } - if (guiCustomScroll.id == 20) { - initGui(); - } - } + } + if (guiCustomScroll.id == 20) { + initGui(); + } + } - @Override - public void save() { - GuiNpcTextField.unfocus(); - if(spawn.id >= 0) + @Override + public void save() { + GuiNpcTextField.unfocus(); + if (spawn.id >= 0) PacketClient.sendClient(new NaturalSpawnSavePacket(spawn.writeNBT(new NBTTagCompound()))); - } + } - @Override - public void setSelected(String selected) { - } + @Override + public void setSelected(String selected) { + } - public void closeSubGui(SubGuiInterface gui) { - super.closeSubGui(gui); - if(gui instanceof GuiNpcMobSpawnerSelector && this.spawnEntryScroll.hasSelected()){ - GuiNpcMobSpawnerSelector selector = (GuiNpcMobSpawnerSelector) gui; - int selected = Integer.parseInt(this.spawnEntryScroll.getSelected()); - this.spawn.spawnCompounds.put(selected,selector.getCompound()); - initGui(); - } - } + public void closeSubGui(SubGuiInterface gui) { + super.closeSubGui(gui); + if (gui instanceof GuiNpcMobSpawnerSelector && this.spawnEntryScroll.hasSelected()) { + GuiNpcMobSpawnerSelector selector = (GuiNpcMobSpawnerSelector) gui; + int selected = Integer.parseInt(this.spawnEntryScroll.getSelected()); + this.spawn.spawnCompounds.put(selected, selector.getCompound()); + initGui(); + } + } - @Override - public void setGuiData(NBTTagCompound compound) { - spawn.readNBT(compound); - setSelected(spawn.name); - initGui(); - } + @Override + public void setGuiData(NBTTagCompound compound) { + spawn.readNBT(compound); + setSelected(spawn.name); + initGui(); + } - @Override - public void mouseDragged(GuiNpcSlider guiNpcSlider) { - guiNpcSlider.displayString = StatCollector.translateToLocal("spawning.weightedChance") + ": " + (int) (guiNpcSlider.sliderValue * 100); - } + @Override + public void mouseDragged(GuiNpcSlider guiNpcSlider) { + guiNpcSlider.displayString = StatCollector.translateToLocal("spawning.weightedChance") + ": " + (int) (guiNpcSlider.sliderValue * 100); + } - @Override - public void mousePressed(GuiNpcSlider guiNpcSlider) { - } + @Override + public void mousePressed(GuiNpcSlider guiNpcSlider) { + } - @Override - public void mouseReleased(GuiNpcSlider guiNpcSlider) { - spawn.itemWeight = (int) (guiNpcSlider.sliderValue * 100); - } + @Override + public void mouseReleased(GuiNpcSlider guiNpcSlider) { + spawn.itemWeight = (int) (guiNpcSlider.sliderValue * 100); + } } diff --git a/src/main/java/noppes/npcs/client/gui/global/GuiNpcQuestReward.java b/src/main/java/noppes/npcs/client/gui/global/GuiNpcQuestReward.java index 647e3361a..6692f5b98 100644 --- a/src/main/java/noppes/npcs/client/gui/global/GuiNpcQuestReward.java +++ b/src/main/java/noppes/npcs/client/gui/global/GuiNpcQuestReward.java @@ -9,57 +9,58 @@ import noppes.npcs.controllers.data.Quest; import noppes.npcs.entity.EntityNPCInterface; import org.lwjgl.opengl.GL11; -public class GuiNpcQuestReward extends GuiContainerNPCInterface implements ITextfieldListener -{ - private Quest quest; - private ResourceLocation resource; - public GuiNpcQuestReward(EntityNPCInterface npc,ContainerNpcQuestReward container){ - super(npc,container); +public class GuiNpcQuestReward extends GuiContainerNPCInterface implements ITextfieldListener { + private Quest quest; + private ResourceLocation resource; + + public GuiNpcQuestReward(EntityNPCInterface npc, ContainerNpcQuestReward container) { + super(npc, container); this.quest = GuiNPCManageQuest.quest; resource = getResource("questreward.png"); } - public void initGui(){ + + public void initGui() { super.initGui(); - addLabel(new GuiNpcLabel(0,"quest.randomitem", guiLeft + 4, guiTop + 4)); - addButton(new GuiNpcButton(0, guiLeft + 4, guiTop + 14, 60, 20, new String[]{"gui.no", "gui.yes"}, quest.randomReward?1:0)); - - addButton(new GuiNpcButton(5, guiLeft, guiTop+ ySize, 98, 20, "gui.back")); - + addLabel(new GuiNpcLabel(0, "quest.randomitem", guiLeft + 4, guiTop + 4)); + addButton(new GuiNpcButton(0, guiLeft + 4, guiTop + 14, 60, 20, new String[]{"gui.no", "gui.yes"}, quest.randomReward ? 1 : 0)); + + addButton(new GuiNpcButton(5, guiLeft, guiTop + ySize, 98, 20, "gui.back")); + addLabel(new GuiNpcLabel(1, "quest.exp", guiLeft + 4, guiTop + 45)); addTextField(new GuiNpcTextField(0, this, this.fontRendererObj, guiLeft + 4, guiTop + 55, 60, 20, quest.rewardExp + "")); getTextField(0).integersOnly = true; getTextField(0).setMinMaxDefault(0, Integer.MAX_VALUE, 0); } - public void actionPerformed(GuiButton guibutton){ - int id = guibutton.id; - if(id == 5){ - NoppesUtil.openGUI(player,GuiNPCManageQuest.Instance); + public void actionPerformed(GuiButton guibutton) { + int id = guibutton.id; + if (id == 5) { + NoppesUtil.openGUI(player, GuiNPCManageQuest.Instance); } - if(id == 0){ - quest.randomReward = ((GuiNpcButton)guibutton).getValue() == 1; + if (id == 0) { + quest.randomReward = ((GuiNpcButton) guibutton).getValue() == 1; } } - public void onGuiClosed(){ + public void onGuiClosed() { } - - protected void drawGuiContainerBackgroundLayer(float f, int i, int j){ + + protected void drawGuiContainerBackgroundLayer(float f, int i, int j) { GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); mc.renderEngine.bindTexture(resource); int l = (width - xSize) / 2; int i1 = (height - ySize) / 2; drawTexturedModalRect(l, i1, 0, 0, xSize, ySize); - super.drawGuiContainerBackgroundLayer(f, i, j); + super.drawGuiContainerBackgroundLayer(f, i, j); + } + + @Override + public void save() { + + } + + @Override + public void unFocused(GuiNpcTextField textfield) { + quest.rewardExp = textfield.getInteger(); } - - @Override - public void save() { - - } - - @Override - public void unFocused(GuiNpcTextField textfield) { - quest.rewardExp = textfield.getInteger(); - } } diff --git a/src/main/java/noppes/npcs/client/gui/hud/ClientHudManager.java b/src/main/java/noppes/npcs/client/gui/hud/ClientHudManager.java index 4b4a4f750..d77c906e5 100644 --- a/src/main/java/noppes/npcs/client/gui/hud/ClientHudManager.java +++ b/src/main/java/noppes/npcs/client/gui/hud/ClientHudManager.java @@ -6,10 +6,11 @@ public class ClientHudManager { private static ClientHudManager instance; private HashMap hudComponents = new HashMap<>(); - private ClientHudManager() {} + private ClientHudManager() { + } public static ClientHudManager getInstance() { - if(instance == null) + if (instance == null) instance = new ClientHudManager(); return instance; } @@ -27,7 +28,7 @@ public class ClientHudManager { */ public void renderAllHUDs(float partialTicks) { for (HudComponent hud : hudComponents.values()) { - if(hud.enabled) + if (hud.enabled) hud.renderOnScreen(partialTicks); } } diff --git a/src/main/java/noppes/npcs/client/gui/hud/CompassHudComponent.java b/src/main/java/noppes/npcs/client/gui/hud/CompassHudComponent.java index 6e7346922..aa6d9c21a 100644 --- a/src/main/java/noppes/npcs/client/gui/hud/CompassHudComponent.java +++ b/src/main/java/noppes/npcs/client/gui/hud/CompassHudComponent.java @@ -10,6 +10,7 @@ import net.minecraft.util.ResourceLocation; import noppes.npcs.config.ConfigClient; import noppes.npcs.constants.MarkType; import org.lwjgl.opengl.GL11; + import java.util.ArrayList; import java.util.Comparator; import java.util.List; @@ -53,7 +54,7 @@ public class CompassHudComponent extends HudComponent { public void loadData(NBTTagCompound compound) { markTargets.clear(); NBTTagList list = compound.getTagList("MarkTargets", 10); - for(int i = 0; i < list.tagCount(); i++) { + for (int i = 0; i < list.tagCount(); i++) { NBTTagCompound entry = list.getCompoundTagAt(i); markTargets.add(new MarkTargetEntry( entry.getInteger("x"), @@ -91,7 +92,7 @@ public class CompassHudComponent extends HudComponent { ConfigClient.CompassOverlayWidth = overlayWidth; ConfigClient.CompassOverlayWidthProperty.set(ConfigClient.CompassOverlayWidth); - if(ConfigClient.config.hasChanged()) + if (ConfigClient.config.hasChanged()) ConfigClient.config.save(); } @@ -100,8 +101,8 @@ public class CompassHudComponent extends HudComponent { if (!hasData || isEditting) return; ScaledResolution res = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight); - int actualX = (int)(posX / 100F * res.getScaledWidth()); - int actualY = (int)(posY / 100F * res.getScaledHeight()); + int actualX = (int) (posX / 100F * res.getScaledWidth()); + int actualY = (int) (posY / 100F * res.getScaledHeight()); float effectiveScale = getEffectiveScale(res); // Calculate interpolated player position and rotation. @@ -156,14 +157,21 @@ public class CompassHudComponent extends HudComponent { } private ResourceLocation getTextureForMark(int type) { - switch(type) { - case MarkType.EXCLAMATION: return new ResourceLocation("customnpcs", "textures/marks/exclamation.png"); - case MarkType.QUESTION: return new ResourceLocation("customnpcs", "textures/marks/question.png"); - case MarkType.POINTER: return new ResourceLocation("customnpcs", "textures/marks/pointer.png"); - case MarkType.CROSS: return new ResourceLocation("customnpcs", "textures/marks/cross.png"); - case MarkType.SKULL: return new ResourceLocation("customnpcs", "textures/marks/skull.png"); - case MarkType.STAR: return new ResourceLocation("customnpcs", "textures/marks/star.png"); - default: return null; + switch (type) { + case MarkType.EXCLAMATION: + return new ResourceLocation("customnpcs", "textures/marks/exclamation.png"); + case MarkType.QUESTION: + return new ResourceLocation("customnpcs", "textures/marks/question.png"); + case MarkType.POINTER: + return new ResourceLocation("customnpcs", "textures/marks/pointer.png"); + case MarkType.CROSS: + return new ResourceLocation("customnpcs", "textures/marks/cross.png"); + case MarkType.SKULL: + return new ResourceLocation("customnpcs", "textures/marks/skull.png"); + case MarkType.STAR: + return new ResourceLocation("customnpcs", "textures/marks/star.png"); + default: + return null; } } @@ -212,20 +220,20 @@ public class CompassHudComponent extends HudComponent { } private int calculateIconSize(float distance) { - if(distance <= SCALE_DISTANCE_MIN) return MAX_ICON_SIZE; - if(distance >= SCALE_DISTANCE_MAX) return BASE_ICON_SIZE; + if (distance <= SCALE_DISTANCE_MIN) return MAX_ICON_SIZE; + if (distance >= SCALE_DISTANCE_MAX) return BASE_ICON_SIZE; float t = (distance - SCALE_DISTANCE_MIN) / (SCALE_DISTANCE_MAX - SCALE_DISTANCE_MIN); - return (int)(MAX_ICON_SIZE - (MAX_ICON_SIZE - BASE_ICON_SIZE) * t); + return (int) (MAX_ICON_SIZE - (MAX_ICON_SIZE - BASE_ICON_SIZE) * t); } @Override public void renderEditing() { isEditting = true; ScaledResolution res = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight); - int actualX = (int)(posX / 100F * res.getScaledWidth()); - int actualY = (int)(posY / 100F * res.getScaledHeight()); + int actualX = (int) (posX / 100F * res.getScaledWidth()); + int actualY = (int) (posY / 100F * res.getScaledHeight()); float effectiveScale = getEffectiveScale(res); GL11.glPushMatrix(); @@ -253,12 +261,12 @@ public class CompassHudComponent extends HudComponent { private void renderDemoIcon(float position, int type, int color) { float pulse = (System.currentTimeMillis() % 1000) / 1000f; - int size = (int)(BASE_ICON_SIZE + (MAX_ICON_SIZE - BASE_ICON_SIZE) * pulse); + int size = (int) (BASE_ICON_SIZE + (MAX_ICON_SIZE - BASE_ICON_SIZE) * pulse); ResourceLocation texture = getTextureForMark(type); - if(texture != null) { + if (texture != null) { GL11.glPushMatrix(); - GL11.glTranslatef(position - size/2, (BAR_HEIGHT - size)/2, 0); + GL11.glTranslatef(position - size / 2, (BAR_HEIGHT - size) / 2, 0); renderTextureIcon(0, 0, size, texture, color); GL11.glPopMatrix(); } diff --git a/src/main/java/noppes/npcs/client/gui/hud/GuiHudEditor.java b/src/main/java/noppes/npcs/client/gui/hud/GuiHudEditor.java index f6e8e91e7..86d719d2e 100644 --- a/src/main/java/noppes/npcs/client/gui/hud/GuiHudEditor.java +++ b/src/main/java/noppes/npcs/client/gui/hud/GuiHudEditor.java @@ -1,16 +1,12 @@ package noppes.npcs.client.gui.hud; -import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.gui.ScaledResolution; import org.lwjgl.input.Mouse; -import org.lwjgl.opengl.GL11; -import java.util.Collections; -import java.util.Comparator; -import java.util.List; import java.util.ArrayList; +import java.util.List; public class GuiHudEditor extends GuiScreen { private GuiScreen parent; @@ -50,8 +46,8 @@ public class GuiHudEditor extends GuiScreen { /** * Updates the custom buttons shown on screen. * Removes all buttons except the global Save (id 0) and then adds: - * - The selected component's custom buttons plus its Reset Position button, - * - Followed by the cycle buttons at the very bottom. + * - The selected component's custom buttons plus its Reset Position button, + * - Followed by the cycle buttons at the very bottom. * Custom buttons are arranged in two columns. */ private void updateCustomButtons() { @@ -149,13 +145,13 @@ public class GuiHudEditor extends GuiScreen { continue; ScaledResolution res = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight); float effectiveScale = hud.getEffectiveScale(res); - int actualX = (int)(hud.posX / 100F * res.getScaledWidth()); - int actualY = (int)(hud.posY / 100F * res.getScaledHeight()); + int actualX = (int) (hud.posX / 100F * res.getScaledWidth()); + int actualY = (int) (hud.posY / 100F * res.getScaledHeight()); int margin = 5; int barWidth = 6; // same as WIDTH_BAR_SIZE - int barX = actualX + (int)(hud.overlayWidth * effectiveScale) + margin; - int barY = actualY + (int)(((hud.overlayHeight - 20) / 2.0F) * effectiveScale); - int barHeight = (int)(20 * effectiveScale); + int barX = actualX + (int) (hud.overlayWidth * effectiveScale) + margin; + int barY = actualY + (int) (((hud.overlayHeight - 20) / 2.0F) * effectiveScale); + int barHeight = (int) (20 * effectiveScale); if (mouseX >= barX && mouseX <= barX + barWidth && mouseY >= barY && mouseY <= barY + barHeight) { resizingWidth = true; @@ -171,10 +167,10 @@ public class GuiHudEditor extends GuiScreen { for (HudComponent hud : ClientHudManager.getInstance().getHudComponents().values()) { ScaledResolution res = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight); float effectiveScale = hud.getEffectiveScale(res); - int actualX = (int)(hud.posX / 100F * res.getScaledWidth()); - int actualY = (int)(hud.posY / 100F * res.getScaledHeight()); - int absWidth = (int)(hud.overlayWidth * effectiveScale); - int absHeight = (int)(hud.overlayHeight * effectiveScale); + int actualX = (int) (hud.posX / 100F * res.getScaledWidth()); + int actualY = (int) (hud.posY / 100F * res.getScaledHeight()); + int absWidth = (int) (hud.overlayWidth * effectiveScale); + int absHeight = (int) (hud.overlayHeight * effectiveScale); if (mouseX >= actualX && mouseX <= actualX + absWidth && mouseY >= actualY && mouseY <= actualY + absHeight) { if (mouseX >= actualX + absWidth - HANDLE_SIZE && mouseY >= actualY + absHeight - HANDLE_SIZE) { @@ -218,12 +214,12 @@ public class GuiHudEditor extends GuiScreen { int newY = scaledHeight - (Mouse.getY() * scaledHeight / mc.displayHeight) - dragOffsetY; if (newX < 0) newX = 0; if (newY < 0) newY = 0; - if (newX + (int)(selectedComponent.overlayWidth * effectiveScale) > scaledWidth) - newX = scaledWidth - (int)(selectedComponent.overlayWidth * effectiveScale); - if (newY + (int)(selectedComponent.overlayHeight * effectiveScale) > scaledHeight) - newY = scaledHeight - (int)(selectedComponent.overlayHeight * effectiveScale); - selectedComponent.posX = (int)(100F * newX / scaledWidth); - selectedComponent.posY = (int)(100F * newY / scaledHeight); + if (newX + (int) (selectedComponent.overlayWidth * effectiveScale) > scaledWidth) + newX = scaledWidth - (int) (selectedComponent.overlayWidth * effectiveScale); + if (newY + (int) (selectedComponent.overlayHeight * effectiveScale) > scaledHeight) + newY = scaledHeight - (int) (selectedComponent.overlayHeight * effectiveScale); + selectedComponent.posX = (int) (100F * newX / scaledWidth); + selectedComponent.posY = (int) (100F * newY / scaledHeight); } if (resizing) { int currentMouseX = Mouse.getX() * width / mc.displayWidth; @@ -256,16 +252,16 @@ public class GuiHudEditor extends GuiScreen { if (selectedComponent instanceof CompassHudComponent) { int margin = 5; int widthBar = 6; // as used in CompassHudComponent. - compWidth = (int)((selectedComponent.overlayWidth + margin + widthBar) * effectiveScale); - compHeight = (int)(selectedComponent.overlayHeight * effectiveScale); + compWidth = (int) ((selectedComponent.overlayWidth + margin + widthBar) * effectiveScale); + compHeight = (int) (selectedComponent.overlayHeight * effectiveScale); } else { - compWidth = (int)(selectedComponent.overlayWidth * effectiveScale); - compHeight = (int)(selectedComponent.overlayHeight * effectiveScale); + compWidth = (int) (selectedComponent.overlayWidth * effectiveScale); + compHeight = (int) (selectedComponent.overlayHeight * effectiveScale); } int centerX = (res.getScaledWidth() - compWidth) / 2; int centerY = (res.getScaledHeight() - compHeight) / 2; - selectedComponent.posX = (int)(100F * centerX / res.getScaledWidth()); - selectedComponent.posY = (int)(100F * centerY / res.getScaledHeight()); + selectedComponent.posX = (int) (100F * centerX / res.getScaledWidth()); + selectedComponent.posY = (int) (100F * centerY / res.getScaledHeight()); updateCustomButtons(); } } else if (button.id == CYCLE_LEFT_ID) { diff --git a/src/main/java/noppes/npcs/client/gui/hud/HudComponent.java b/src/main/java/noppes/npcs/client/gui/hud/HudComponent.java index 48bfece66..53a7a2170 100644 --- a/src/main/java/noppes/npcs/client/gui/hud/HudComponent.java +++ b/src/main/java/noppes/npcs/client/gui/hud/HudComponent.java @@ -3,6 +3,7 @@ package noppes.npcs.client.gui.hud; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.ScaledResolution; import net.minecraft.nbt.NBTTagCompound; + import java.util.List; public abstract class HudComponent { @@ -54,7 +55,7 @@ public abstract class HudComponent { * The default implementation toggles the enabled state if button id is 999. */ public void onEditorButtonPressed(GuiButton button) { - if(button.id == 999){ + if (button.id == 999) { enabled = !enabled; button.displayString = enabled ? "Enabled" : "Disabled"; } diff --git a/src/main/java/noppes/npcs/client/gui/hud/QuestTrackingComponent.java b/src/main/java/noppes/npcs/client/gui/hud/QuestTrackingComponent.java index f172b1ac7..0d5e360d6 100644 --- a/src/main/java/noppes/npcs/client/gui/hud/QuestTrackingComponent.java +++ b/src/main/java/noppes/npcs/client/gui/hud/QuestTrackingComponent.java @@ -1,14 +1,15 @@ package noppes.npcs.client.gui.hud; import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.gui.GuiButton; +import net.minecraft.client.gui.ScaledResolution; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; -import net.minecraft.client.gui.FontRenderer; -import net.minecraft.client.gui.ScaledResolution; -import net.minecraft.client.gui.GuiButton; import noppes.npcs.config.ConfigClient; -import org.lwjgl.opengl.GL11; import noppes.npcs.controllers.data.Quest; +import org.lwjgl.opengl.GL11; + import java.util.ArrayList; import java.util.List; @@ -49,23 +50,23 @@ public class QuestTrackingComponent extends HudComponent { String category = compound.getString("CategoryName"); ArrayList objectives = new ArrayList<>(); - NBTTagList nbtTagList = compound.getTagList("ObjectiveList",8); + NBTTagList nbtTagList = compound.getTagList("ObjectiveList", 8); for (int i = 0; i < nbtTagList.tagCount(); i++) { String objective = nbtTagList.getStringTagAt(i); String[] split = objective.split(":"); - split = split[split.length-1].split("/"); + split = split[split.length - 1].split("/"); boolean completed = false; try { - if(split.length < 2) + if (split.length < 2) throw new NumberFormatException("catch"); int killed = Integer.parseInt(split[0].trim()); int total = Integer.parseInt(split[1].trim()); - if (killed/total == 1) { + if (killed / total == 1) { completed = true; } } catch (NumberFormatException e) { @@ -134,8 +135,8 @@ public class QuestTrackingComponent extends HudComponent { return; ScaledResolution res = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight); - int actualX = (int)(posX / 100F * res.getScaledWidth()); - int actualY = (int)(posY / 100F * res.getScaledHeight()); + int actualX = (int) (posX / 100F * res.getScaledWidth()); + int actualY = (int) (posY / 100F * res.getScaledHeight()); float effectiveScale = getEffectiveScale(res); GL11.glPushMatrix(); @@ -168,8 +169,8 @@ public class QuestTrackingComponent extends HudComponent { public void renderEditing() { isEditting = true; ScaledResolution res = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight); - int actualX = (int)(posX / 100F * res.getScaledWidth()); - int actualY = (int)(posY / 100F * res.getScaledHeight()); + int actualX = (int) (posX / 100F * res.getScaledWidth()); + int actualY = (int) (posY / 100F * res.getScaledHeight()); float effectiveScale = getEffectiveScale(res); GL11.glPushMatrix(); @@ -182,16 +183,16 @@ public class QuestTrackingComponent extends HudComponent { drawRect(overlayWidth - 10, overlayHeight - 10, overlayWidth, overlayHeight, 0xFFCCCCCC); int currentY = 5; - currentY = renderDemoTextBlock(new String[] { "Dummy Quest Title" }, currentY, textAlign, 0xFFFFFF); + currentY = renderDemoTextBlock(new String[]{"Dummy Quest Title"}, currentY, textAlign, 0xFFFFFF); drawDecorativeLine(currentY - 1); currentY += 8; - currentY = renderDemoTextBlock(new String[] { "Dummy Category" }, currentY, textAlign, 0xCCCCCC); + currentY = renderDemoTextBlock(new String[]{"Dummy Category"}, currentY, textAlign, 0xCCCCCC); drawDecorativeLine(currentY - 1); currentY += 8; - currentY = renderDemoTextBlock(new String[] { "Objective: Kill 10 mobs", "Objective: Collect 5 items" }, currentY, textAlign, 0xAAAAAA); + currentY = renderDemoTextBlock(new String[]{"Objective: Kill 10 mobs", "Objective: Collect 5 items"}, currentY, textAlign, 0xAAAAAA); drawDecorativeLine(currentY - 1); currentY += 8; - renderDemoTextBlock(new String[] { "Turn in with NPC" }, currentY, textAlign, 0xAAAAAA); + renderDemoTextBlock(new String[]{"Turn in with NPC"}, currentY, textAlign, 0xAAAAAA); GL11.glPopMatrix(); } @@ -213,12 +214,12 @@ public class QuestTrackingComponent extends HudComponent { } else if (button.id == 3) { // Reset to center. ScaledResolution res = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight); float effectiveScale = getEffectiveScale(res); - int compWidth = (int)(overlayWidth * effectiveScale); - int compHeight = (int)(overlayHeight * effectiveScale); + int compWidth = (int) (overlayWidth * effectiveScale); + int compHeight = (int) (overlayHeight * effectiveScale); int centerX = (res.getScaledWidth() - compWidth) / 2; int centerY = (res.getScaledHeight() - compHeight) / 2; - posX = (int)(100F * centerX / res.getScaledWidth()); - posY = (int)(100F * centerY / res.getScaledHeight()); + posX = (int) (100F * centerX / res.getScaledWidth()); + posY = (int) (100F * centerY / res.getScaledHeight()); } else { super.onEditorButtonPressed(button); } @@ -226,10 +227,14 @@ public class QuestTrackingComponent extends HudComponent { private String getAlignText() { switch (textAlign) { - case 0: return "Align: Left"; - case 1: return "Align: Center"; - case 2: return "Align: Right"; - default: return "Align: Unknown"; + case 0: + return "Align: Left"; + case 1: + return "Align: Center"; + case 2: + return "Align: Right"; + default: + return "Align: Unknown"; } } diff --git a/src/main/java/noppes/npcs/client/gui/item/GuiNpcPaintbrush.java b/src/main/java/noppes/npcs/client/gui/item/GuiNpcPaintbrush.java index 0e038251c..b58e16205 100644 --- a/src/main/java/noppes/npcs/client/gui/item/GuiNpcPaintbrush.java +++ b/src/main/java/noppes/npcs/client/gui/item/GuiNpcPaintbrush.java @@ -30,7 +30,7 @@ public class GuiNpcPaintbrush extends GuiNPCInterface { setBackground("menubg.png"); ItemStack brush = this.player.getHeldItem(); - if(brush == null) + if (brush == null) return; color = ItemNpcTool.getColor(brush.getTagCompound()); @@ -86,7 +86,7 @@ public class GuiNpcPaintbrush extends GuiNPCInterface { } @Override - public void close(){ + public void close() { PacketClient.sendClient(new ColorBrushPacket(this.color)); super.close(); } diff --git a/src/main/java/noppes/npcs/client/gui/item/SubGuiLinkedItem.java b/src/main/java/noppes/npcs/client/gui/item/SubGuiLinkedItem.java index 5d7f8c816..3b8735776 100644 --- a/src/main/java/noppes/npcs/client/gui/item/SubGuiLinkedItem.java +++ b/src/main/java/noppes/npcs/client/gui/item/SubGuiLinkedItem.java @@ -3,7 +3,6 @@ package noppes.npcs.client.gui.item; import kamkeel.npcs.network.PacketClient; import kamkeel.npcs.network.packets.request.linked.LinkedItemSavePacket; import kamkeel.npcs.util.ColorUtil; -import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiYesNo; import net.minecraft.client.gui.GuiYesNoCallback; @@ -124,12 +123,22 @@ public class SubGuiLinkedItem extends SubGuiInterface implements ITextfieldListe addLabel(new GuiNpcLabel(5, "display.useAction", x, y + 5, CustomNpcResourceListener.DefaultTextColor)); String[] useActions = {"use_action.none", "use_action.block", "use_action.eat", "use_action.drink"}; int useActionIndex = 0; - switch(linkedItem.itemUseAction) { - case 0: useActionIndex = 0; break; - case 1: useActionIndex = 1; break; - case 3: useActionIndex = 2; break; - case 4: useActionIndex = 3; break; - default: useActionIndex = 0; break; + switch (linkedItem.itemUseAction) { + case 0: + useActionIndex = 0; + break; + case 1: + useActionIndex = 1; + break; + case 3: + useActionIndex = 2; + break; + case 4: + useActionIndex = 3; + break; + default: + useActionIndex = 0; + break; } GuiButtonBiDirectional useActionButton = new GuiButtonBiDirectional(6, x + 120, y, 100, 20, useActions, useActionIndex); addButton(useActionButton); @@ -164,7 +173,7 @@ public class SubGuiLinkedItem extends SubGuiInterface implements ITextfieldListe // Item Color: label and two buttons scrollWindow.addLabel(new GuiNpcLabel(20, "gui.color", x, localY + 5, 0xFFFFFF)); String colorHex = Integer.toHexString(linkedItem.display.itemColor); - while(colorHex.length() < 6) + while (colorHex.length() < 6) colorHex = "0" + colorHex; GuiNpcButton colorPickerButton = new GuiNpcButton(24, x + 80, localY, 80, 20, colorHex); colorPickerButton.packedFGColour = linkedItem.display.itemColor; @@ -301,9 +310,9 @@ public class SubGuiLinkedItem extends SubGuiInterface implements ITextfieldListe // Clear color: set to 0xFFFFFF. linkedItem.display.itemColor = 0xFFFFFF; GuiScrollWindow scrollWindow = getScrollableGui(0); - if(scrollWindow != null){ + if (scrollWindow != null) { GuiNpcButton npcButton = scrollWindow.getButton(24); - if(npcButton != null){ + if (npcButton != null) { npcButton.displayString = "ffffff"; npcButton.packedFGColour = 0xFFFFFF; } @@ -311,22 +320,42 @@ public class SubGuiLinkedItem extends SubGuiInterface implements ITextfieldListe } else if (id == 6) { // Item Use Action button. int index = ((GuiButtonBiDirectional) guibutton).getValue(); - switch(index) { - case 0: linkedItem.itemUseAction = 0; break; - case 1: linkedItem.itemUseAction = 1; break; - case 2: linkedItem.itemUseAction = 3; break; - case 3: linkedItem.itemUseAction = 4; break; + switch (index) { + case 0: + linkedItem.itemUseAction = 0; + break; + case 1: + linkedItem.itemUseAction = 1; + break; + case 2: + linkedItem.itemUseAction = 3; + break; + case 3: + linkedItem.itemUseAction = 4; + break; } } else if (id == 8) { // Armor Type button. int index = ((GuiButtonBiDirectional) guibutton).getValue(); - switch(index) { - case 0: linkedItem.armorType = -2; break; - case 1: linkedItem.armorType = -1; break; - case 2: linkedItem.armorType = 0; break; - case 3: linkedItem.armorType = 1; break; - case 4: linkedItem.armorType = 2; break; - case 5: linkedItem.armorType = 3; break; + switch (index) { + case 0: + linkedItem.armorType = -2; + break; + case 1: + linkedItem.armorType = -1; + break; + case 2: + linkedItem.armorType = 0; + break; + case 3: + linkedItem.armorType = 1; + break; + case 4: + linkedItem.armorType = 2; + break; + case 5: + linkedItem.armorType = 3; + break; } } else if (id == 27 && guibutton instanceof GuiNpcButtonYesNo) { // IsTool toggle @@ -444,10 +473,10 @@ public class SubGuiLinkedItem extends SubGuiInterface implements ITextfieldListe @Override public void subGuiClosed(SubGuiInterface subgui) { - if(subgui instanceof SubGuiColorSelector){ - if(colorPicked == 1) + if (subgui instanceof SubGuiColorSelector) { + if (colorPicked == 1) linkedItem.display.itemColor = ((SubGuiColorSelector) subgui).color; - if(colorPicked == 2) + if (colorPicked == 2) linkedItem.display.durabilityColor = ((SubGuiColorSelector) subgui).color; initGui(); diff --git a/src/main/java/noppes/npcs/client/gui/mainmenu/GuiNPCGlobalMainMenu.java b/src/main/java/noppes/npcs/client/gui/mainmenu/GuiNPCGlobalMainMenu.java index 1a5f413bb..5290c0a4b 100644 --- a/src/main/java/noppes/npcs/client/gui/mainmenu/GuiNPCGlobalMainMenu.java +++ b/src/main/java/noppes/npcs/client/gui/mainmenu/GuiNPCGlobalMainMenu.java @@ -101,14 +101,14 @@ public class GuiNPCGlobalMainMenu extends GuiNPCInterface2 { /** * Compute the optimal layout by iterating over candidate row counts from 1 to total. * For each candidate: - * - Let c = ceil(total / r) - * - candidateHoriz = (availWidth - (c+1)*padding) / c - * - candidateVert = (availHeight - (r+1)*padding) / r - * - candidate = min(candidateHoriz, candidateVert) - * - usedWidth = candidate * c + (c+1)*padding - * - usedHeight = candidate * r + (r+1)*padding - * - ratio = (usedWidth * usedHeight) / (availWidth * availHeight) - * + * - Let c = ceil(total / r) + * - candidateHoriz = (availWidth - (c+1)*padding) / c + * - candidateVert = (availHeight - (r+1)*padding) / r + * - candidate = min(candidateHoriz, candidateVert) + * - usedWidth = candidate * c + (c+1)*padding + * - usedHeight = candidate * r + (r+1)*padding + * - ratio = (usedWidth * usedHeight) / (availWidth * availHeight) + *

* We choose the candidate (r, candidate) that maximizes this ratio. * * @param total Total number of buttons. @@ -130,7 +130,7 @@ public class GuiNPCGlobalMainMenu extends GuiNPCInterface2 { continue; int usedWidth = candidate * cols + (cols + 1) * padding; int usedHeight = candidate * r + (r + 1) * padding; - double ratio = (double)(usedWidth * usedHeight) / (availWidth * availHeight); + double ratio = (double) (usedWidth * usedHeight) / (availWidth * availHeight); if (ratio > bestRatio || (Math.abs(ratio - bestRatio) < 0.0001 && candidate > bestCandidate)) { bestRatio = ratio; bestCandidate = candidate; diff --git a/src/main/java/noppes/npcs/client/gui/mainmenu/GuiNPCInv.java b/src/main/java/noppes/npcs/client/gui/mainmenu/GuiNPCInv.java index 2d18c8769..6c3669814 100644 --- a/src/main/java/noppes/npcs/client/gui/mainmenu/GuiNPCInv.java +++ b/src/main/java/noppes/npcs/client/gui/mainmenu/GuiNPCInv.java @@ -17,16 +17,14 @@ import org.lwjgl.opengl.GL11; import java.util.HashMap; -public class GuiNPCInv extends GuiContainerNPCInterface2 implements IGuiData, ITextfieldListener -{ - private HashMap chances = new HashMap(); - private ContainerNPCInv container; - private ResourceLocation slot; +public class GuiNPCInv extends GuiContainerNPCInterface2 implements IGuiData, ITextfieldListener { + private HashMap chances = new HashMap(); + private ContainerNPCInv container; + private ResourceLocation slot; private int inventoryTab = 0; - public GuiNPCInv(EntityNPCInterface npc,ContainerNPCInv container) - { - super(npc,container,3); + public GuiNPCInv(EntityNPCInterface npc, ContainerNPCInv container) { + super(npc, container, 3); this.setBackground("npcinv.png"); this.container = container; ySize = 200; @@ -34,15 +32,14 @@ public class GuiNPCInv extends GuiContainerNPCInterface2 implements IGuiData, IT PacketClient.sendClient(new MainmenuInvGetPacket()); } - public void initGui() - { + public void initGui() { super.initGui(); - addLabel(new GuiNpcLabel(0,"inv.minExp", guiLeft + 118, guiTop + 18)); - addTextField(new GuiNpcTextField(0,this, fontRendererObj, guiLeft + 108, guiTop + 29, 60, 20, npc.inventory.minExp + "")); + addLabel(new GuiNpcLabel(0, "inv.minExp", guiLeft + 118, guiTop + 18)); + addTextField(new GuiNpcTextField(0, this, fontRendererObj, guiLeft + 108, guiTop + 29, 60, 20, npc.inventory.minExp + "")); getTextField(0).integersOnly = true; - addLabel(new GuiNpcLabel(1,"inv.maxExp", guiLeft + 118, guiTop + 52)); - addTextField(new GuiNpcTextField(1,this, fontRendererObj, guiLeft + 108, guiTop + 63, 60, 20, npc.inventory.maxExp + "")); + addLabel(new GuiNpcLabel(1, "inv.maxExp", guiLeft + 118, guiTop + 52)); + addTextField(new GuiNpcTextField(1, this, fontRendererObj, guiLeft + 108, guiTop + 63, 60, 20, npc.inventory.maxExp + "")); getTextField(1).integersOnly = true; getTextField(0).setMinMaxDefault(0, getTextField(1).getInteger(), 0); @@ -50,37 +47,37 @@ public class GuiNPCInv extends GuiContainerNPCInterface2 implements IGuiData, IT addButton(new GuiNpcButton(10, guiLeft + 88, guiTop + 88, 80, 20, new String[]{"stats.normal", "inv.auto"}, npc.inventory.lootMode)); - addLabel(new GuiNpcLabel(2,"inv.npcInventory", guiLeft + 191, guiTop + 5)); - addLabel(new GuiNpcLabel(3,"inv.inventory", guiLeft + 8, guiTop + 101)); + addLabel(new GuiNpcLabel(2, "inv.npcInventory", guiLeft + 191, guiTop + 5)); + addLabel(new GuiNpcLabel(3, "inv.inventory", guiLeft + 8, guiTop + 101)); - addLabel(new GuiNpcLabel(4,"Tab", guiLeft + 381, guiTop + 5)); + addLabel(new GuiNpcLabel(4, "Tab", guiLeft + 381, guiTop + 5)); addButton(new GuiNpcButton(11, guiLeft + 375, guiTop + 13, 30, 20, "1")); addButton(new GuiNpcButton(12, guiLeft + 375, guiTop + 34, 30, 20, "2")); getButton(11 + this.inventoryTab).setEnabled(false); getButton(12 - this.inventoryTab).setEnabled(true); - for(int c = 0; c < 4; c++) { + for (int c = 0; c < 4; c++) { for (int r = 0; r < 9; r++) { double chance = 100; - if (npc.inventory.dropchance.containsKey(r + c*9)) { - chance = npc.inventory.dropchance.get(r + c*9); + if (npc.inventory.dropchance.containsKey(r + c * 9)) { + chance = npc.inventory.dropchance.get(r + c * 9); } if (chance <= 0 || chance > 100) chance = 100; - chances.put(r + c*9, chance); + chances.put(r + c * 9, chance); - if(Math.floor((float)c/2) != this.inventoryTab) { - container.getSlot(r + c*9 + 7).xDisplayPosition = 10000; - container.getSlot(r + c*9 + 7).yDisplayPosition = 10000; + if (Math.floor((float) c / 2) != this.inventoryTab) { + container.getSlot(r + c * 9 + 7).xDisplayPosition = 10000; + container.getSlot(r + c * 9 + 7).yDisplayPosition = 10000; continue; } else { - container.getSlot(r + c*9 + 7).xDisplayPosition = 191 + (c-this.inventoryTab*2) * 90; - container.getSlot(r + c*9 + 7).yDisplayPosition = 16 + r * 21; + container.getSlot(r + c * 9 + 7).xDisplayPosition = 191 + (c - this.inventoryTab * 2) * 90; + container.getSlot(r + c * 9 + 7).yDisplayPosition = 16 + r * 21; } - GuiNpcTextField textField = new GuiNpcTextField(2 + r + c*9, this, fontRendererObj, guiLeft + 210 + (c-this.inventoryTab*2)*90, guiTop + 14 + r * 21, 60, 18, chance + ""); - addLabel(new GuiNpcLabel(c*9 + r + 5,"%", guiLeft + 272 + (c-this.inventoryTab*2)*90, guiTop + 16 + r * 21)); + GuiNpcTextField textField = new GuiNpcTextField(2 + r + c * 9, this, fontRendererObj, guiLeft + 210 + (c - this.inventoryTab * 2) * 90, guiTop + 14 + r * 21, 60, 18, chance + ""); + addLabel(new GuiNpcLabel(c * 9 + r + 5, "%", guiLeft + 272 + (c - this.inventoryTab * 2) * 90, guiTop + 16 + r * 21)); textField.doublesOnly = true; textField.setMinMaxDefaultDouble(0, 100, 100); addTextField(textField); @@ -88,52 +85,50 @@ public class GuiNPCInv extends GuiContainerNPCInterface2 implements IGuiData, IT } } - private void drawSlot(int x, int y) - { + private void drawSlot(int x, int y) { GL11.glDisable(GL11.GL_LIGHTING); GL11.glEnable(GL11.GL_BLEND); // Forge: Blending needs to be enabled for this. this.mc.getTextureManager().bindTexture(slot); - this.drawTexturedModalRect(x, y, 0,0,18, 18); + this.drawTexturedModalRect(x, y, 0, 0, 18, 18); GL11.glDisable(GL11.GL_BLEND); // Forge: And clean that up GL11.glEnable(GL11.GL_LIGHTING); } @Override - protected void actionPerformed(GuiButton guibutton) { - if(guibutton.id == 10){ - npc.inventory.lootMode = ((GuiNpcButton)guibutton).getValue(); - } - if(guibutton.id == 11 || guibutton.id == 12){ - this.inventoryTab = Integer.parseInt(guibutton.displayString)-1; + protected void actionPerformed(GuiButton guibutton) { + if (guibutton.id == 10) { + npc.inventory.lootMode = ((GuiNpcButton) guibutton).getValue(); + } + if (guibutton.id == 11 || guibutton.id == 12) { + this.inventoryTab = Integer.parseInt(guibutton.displayString) - 1; initGui(); } } - protected void drawGuiContainerBackgroundLayer(float f, int i, int j) - { - super.drawGuiContainerBackgroundLayer(f, i, j); + protected void drawGuiContainerBackgroundLayer(float f, int i, int j) { + super.drawGuiContainerBackgroundLayer(f, i, j); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); mc.renderEngine.bindTexture(slot); - for(int id = 4; id <= 6;id++){ - Slot slot = container.getSlot(id); - if(slot.getHasStack()) - drawTexturedModalRect(guiLeft + slot.xDisplayPosition - 1, guiTop + slot.yDisplayPosition -1, 0, 0, 18, 18); - } + for (int id = 4; id <= 6; id++) { + Slot slot = container.getSlot(id); + if (slot.getHasStack()) + drawTexturedModalRect(guiLeft + slot.xDisplayPosition - 1, guiTop + slot.yDisplayPosition - 1, 0, 0, 18, 18); + } - for(int c = 0; c < 2; c++) { + for (int c = 0; c < 2; c++) { for (int r = 0; r < 9; r++) { - this.drawSlot(guiLeft + 190 + c*90, guiTop + 15 + r * 21); + this.drawSlot(guiLeft + 190 + c * 90, guiTop + 15 + r * 21); } } } - public void drawScreen(int i, int j, float f) - { + + public void drawScreen(int i, int j, float f) { npc.isDrawn = true; - int showname = npc.display.showName; - npc.display.showName = 1; - int l = guiLeft + 20; //(width/2)-180; - int i1 = (height/2) - 145; + int showname = npc.display.showName; + npc.display.showName = 1; + int l = guiLeft + 20; //(width/2)-180; + int i1 = (height / 2) - 145; GL11.glEnable(32826 /*GL_RESCALE_NORMAL_EXT*/); GL11.glEnable(2903 /*GL_COLOR_MATERIAL*/); GL11.glPushMatrix(); @@ -145,15 +140,15 @@ public class GuiNPCInv extends GuiContainerNPCInterface2 implements IGuiData, IT float f3 = npc.rotationYaw; float f4 = npc.rotationPitch; float f7 = npc.rotationYawHead; - float f5 = (float)(l + 33) - i; - float f6 = (float)((i1 + 131) - 50) - j; + float f5 = (float) (l + 33) - i; + float f6 = (float) ((i1 + 131) - 50) - j; GL11.glRotatef(135F, 0.0F, 1.0F, 0.0F); RenderHelper.enableStandardItemLighting(); GL11.glRotatef(-135F, 0.0F, 1.0F, 0.0F); - GL11.glRotatef(-(float)Math.atan(f6 / 40F) * 20F, 1.0F, 0.0F, 0.0F); - npc.renderYawOffset = (float)Math.atan(f5 / 40F) * 20F; - npc.rotationYaw = (float)Math.atan(f5 / 40F) * 40F; - npc.rotationPitch = -(float)Math.atan(f6 / 40F) * 20F; + GL11.glRotatef(-(float) Math.atan(f6 / 40F) * 20F, 1.0F, 0.0F, 0.0F); + npc.renderYawOffset = (float) Math.atan(f5 / 40F) * 20F; + npc.rotationYaw = (float) Math.atan(f5 / 40F) * 40F; + npc.rotationPitch = -(float) Math.atan(f6 / 40F) * 20F; npc.rotationYawHead = npc.rotationYaw; //npc.updateCloak(); GL11.glTranslatef(0.0F, npc.yOffset, 0.0F); @@ -169,29 +164,29 @@ public class GuiNPCInv extends GuiContainerNPCInterface2 implements IGuiData, IT OpenGlHelper.setActiveTexture(OpenGlHelper.lightmapTexUnit); GL11.glDisable(GL11.GL_TEXTURE_2D); OpenGlHelper.setActiveTexture(OpenGlHelper.defaultTexUnit); - npc.display.showName = showname; + npc.display.showName = showname; npc.isDrawn = false; super.drawScreen(i, j, f); } - @Override - public void save() { + @Override + public void save() { npc.inventory.dropchance = chances; - npc.inventory.minExp = getTextField(0).getInteger(); - npc.inventory.maxExp = getTextField(1).getInteger(); + npc.inventory.minExp = getTextField(0).getInteger(); + npc.inventory.maxExp = getTextField(1).getInteger(); PacketClient.sendClient(new MainmenuInvSavePacket(npc.inventory.writeEntityToNBT(new NBTTagCompound()))); } - @Override - public void setGuiData(NBTTagCompound compound) { - npc.inventory.readEntityFromNBT(compound); - initGui(); - } + @Override + public void setGuiData(NBTTagCompound compound) { + npc.inventory.readEntityFromNBT(compound); + initGui(); + } @Override public void unFocused(GuiNpcTextField textfield) { - if(textfield.id >= 2){ - chances.put(textfield.id-2, Double.parseDouble(textfield.getText())); + if (textfield.id >= 2) { + chances.put(textfield.id - 2, Double.parseDouble(textfield.getText())); } getTextField(0).setMinMaxDefault(0, getTextField(1).getInteger(), 0); getTextField(1).setMinMaxDefault(getTextField(0).getInteger(), Short.MAX_VALUE, 0); diff --git a/src/main/java/noppes/npcs/client/gui/mainmenu/GuiNpcAI.java b/src/main/java/noppes/npcs/client/gui/mainmenu/GuiNpcAI.java index 683898be0..895866a55 100644 --- a/src/main/java/noppes/npcs/client/gui/mainmenu/GuiNpcAI.java +++ b/src/main/java/noppes/npcs/client/gui/mainmenu/GuiNpcAI.java @@ -12,158 +12,147 @@ import noppes.npcs.constants.EnumCombatPolicy; import noppes.npcs.constants.EnumNavType; import noppes.npcs.entity.EntityNPCInterface; -public class GuiNpcAI extends GuiNPCInterface2 implements ITextfieldListener, IGuiData{ - private DataAI ai; - public GuiNpcAI(EntityNPCInterface npc) { - super(npc,6); - ai = npc.ais; - PacketClient.sendClient(new MainmenuAIGetPacket()); - } +public class GuiNpcAI extends GuiNPCInterface2 implements ITextfieldListener, IGuiData { + private DataAI ai; - public void initGui() - { + public GuiNpcAI(EntityNPCInterface npc) { + super(npc, 6); + ai = npc.ais; + PacketClient.sendClient(new MainmenuAIGetPacket()); + } + + public void initGui() { super.initGui(); - addLabel(new GuiNpcLabel(0,"ai.enemyresponse", guiLeft + 5, guiTop + 17)); - addButton(new GuiNpcButton(0,guiLeft + 86, guiTop + 10, 60, 20, new String[]{"gui.retaliate","gui.panic","gui.retreat","gui.nothing"} ,npc.ais.onAttack)); - addLabel(new GuiNpcLabel(1,"ai.door", guiLeft + 5, guiTop + 40)); - addButton(new GuiNpcButton(1,guiLeft + 86, guiTop + 35, 60, 20, new String[]{"gui.break","gui.open","gui.disabled"} ,npc.ais.doorInteract)); - addLabel(new GuiNpcLabel(12,"ai.swim", guiLeft + 5, guiTop + 65)); - addButton(new GuiNpcButton(7,guiLeft + 86, guiTop + 60, 60, 20, new String[]{"gui.no", "gui.yes"} ,npc.ais.canSwim ? 1:0)); - addLabel(new GuiNpcLabel(13,"ai.shelter", guiLeft + 5, guiTop + 90)); - addButton(new GuiNpcButton(9,guiLeft + 86, guiTop + 85, 60, 20, new String[]{"gui.darkness","gui.sunlight","gui.disabled"} ,npc.ais.findShelter)); - addLabel(new GuiNpcLabel(14,"ai.clearlos", guiLeft + 5, guiTop + 115)); - addButton(new GuiNpcButton(10,guiLeft + 86, guiTop + 110, 60, 20, new String[]{"gui.no", "gui.yes"} ,npc.ais.directLOS ? 1:0)); - addLabel(new GuiNpcLabel(18,"ai.sprint", guiLeft + 5, guiTop + 140)); - addButton(new GuiNpcButton(16,guiLeft + 86, guiTop + 135, 60, 20, new String[]{"gui.no", "gui.yes"} ,npc.ais.canSprint ? 1:0)); + addLabel(new GuiNpcLabel(0, "ai.enemyresponse", guiLeft + 5, guiTop + 17)); + addButton(new GuiNpcButton(0, guiLeft + 86, guiTop + 10, 60, 20, new String[]{"gui.retaliate", "gui.panic", "gui.retreat", "gui.nothing"}, npc.ais.onAttack)); + addLabel(new GuiNpcLabel(1, "ai.door", guiLeft + 5, guiTop + 40)); + addButton(new GuiNpcButton(1, guiLeft + 86, guiTop + 35, 60, 20, new String[]{"gui.break", "gui.open", "gui.disabled"}, npc.ais.doorInteract)); + addLabel(new GuiNpcLabel(12, "ai.swim", guiLeft + 5, guiTop + 65)); + addButton(new GuiNpcButton(7, guiLeft + 86, guiTop + 60, 60, 20, new String[]{"gui.no", "gui.yes"}, npc.ais.canSwim ? 1 : 0)); + addLabel(new GuiNpcLabel(13, "ai.shelter", guiLeft + 5, guiTop + 90)); + addButton(new GuiNpcButton(9, guiLeft + 86, guiTop + 85, 60, 20, new String[]{"gui.darkness", "gui.sunlight", "gui.disabled"}, npc.ais.findShelter)); + addLabel(new GuiNpcLabel(14, "ai.clearlos", guiLeft + 5, guiTop + 115)); + addButton(new GuiNpcButton(10, guiLeft + 86, guiTop + 110, 60, 20, new String[]{"gui.no", "gui.yes"}, npc.ais.directLOS ? 1 : 0)); + addLabel(new GuiNpcLabel(18, "ai.sprint", guiLeft + 5, guiTop + 140)); + addButton(new GuiNpcButton(16, guiLeft + 86, guiTop + 135, 60, 20, new String[]{"gui.no", "gui.yes"}, npc.ais.canSprint ? 1 : 0)); - addLabel(new GuiNpcLabel(10,"ai.avoidwater", guiLeft + 150, guiTop + 17)); - addButton(new GuiNpcButton(5, guiLeft + 230, guiTop + 10, 60, 20, new String[]{"gui.no","gui.yes"} ,npc.ais.avoidsWater ? 1:0)); - addLabel(new GuiNpcLabel(11,"ai.return", guiLeft + 150, guiTop + 40)); - addButton(new GuiNpcButton(6, guiLeft + 230, guiTop + 35, 60, 20, new String[]{"gui.no","gui.yes"} ,npc.ais.returnToStart ? 1:0)); - addLabel(new GuiNpcLabel(17,"ai.leapattarget", guiLeft + 150, guiTop + 65)); - addButton(new GuiNpcButton(15,guiLeft + 230, guiTop + 60, 60, 20, new String[]{"gui.no", "ai.jump", "ai.pounce"} ,npc.ais.leapType)); - addLabel(new GuiNpcLabel(15, "ai.indirect", guiLeft + 150, guiTop + 90)); - addButton(new GuiNpcButton(13, guiLeft + 230, guiTop + 85, 60, 20, new String[]{"gui.no", "gui.whendistant", "gui.whenhidden"}, ai.canFireIndirect)); - addLabel(new GuiNpcLabel(16, "ai.rangemelee", guiLeft + 150, guiTop + 115)); - addButton(new GuiNpcButton(14, guiLeft + 230, guiTop + 110, 60, 20, new String[]{npc.inventory.getProjectile() == null?"gui.no":"gui.always", "gui.untilclose","gui.whenavailable"} ,ai.useRangeMelee)); - if (ai.useRangeMelee >= 1){ - addLabel(new GuiNpcLabel(20,"gui.minrange", guiLeft + 300, guiTop + 115)); - addTextField(new GuiNpcTextField(6,this, fontRendererObj, guiLeft + 380, guiTop + 110, 30, 20, ai.distanceToMelee + "")); - getTextField(6).integersOnly = true; - getTextField(6).setMinMaxDefault(1, npc.stats.aggroRange, 5); - } - addLabel(new GuiNpcLabel(19,"ai.tacticalvariant", guiLeft + 150, guiTop + 140)); - addButton(new GuiNpcButton(17 ,guiLeft + 230, guiTop + 135, 60, 20, EnumNavType.names(), ai.tacticalVariant.ordinal())); - if (ai.tacticalVariant != EnumNavType.Default && ai.tacticalVariant != EnumNavType.None) - { - String label = ""; - switch(ai.tacticalVariant) - { - case Surround : label = "gui.orbitdistance" ; break; - case HitNRun : label = "gui.fightifthisclose" ; break; - case Ambush : label = "gui.ambushdistance"; break; - case Stalk : label = "gui.ambushdistance"; break; - default : label = "gui.engagedistance"; - } - addLabel(new GuiNpcLabel(21, label, guiLeft + 300, guiTop + 140)); - addTextField(new GuiNpcTextField(3,this, fontRendererObj, guiLeft + 380, guiTop + 135, 30, 20, ai.tacticalRadius + "")); - getTextField(3).integersOnly = true; - getTextField(3).setMinMaxDefault(1, npc.stats.aggroRange, 5); - } - addLabel(new GuiNpcLabel(25,"ai.combatpolicy", guiLeft + 150, guiTop + 165)); - addButton(new GuiNpcButton(25 ,guiLeft + 230, guiTop + 160, 60, 20, EnumCombatPolicy.names(), ai.combatPolicy.ordinal())); - if (ai.combatPolicy == EnumCombatPolicy.Stubborn) - { - String label = ""; + addLabel(new GuiNpcLabel(10, "ai.avoidwater", guiLeft + 150, guiTop + 17)); + addButton(new GuiNpcButton(5, guiLeft + 230, guiTop + 10, 60, 20, new String[]{"gui.no", "gui.yes"}, npc.ais.avoidsWater ? 1 : 0)); + addLabel(new GuiNpcLabel(11, "ai.return", guiLeft + 150, guiTop + 40)); + addButton(new GuiNpcButton(6, guiLeft + 230, guiTop + 35, 60, 20, new String[]{"gui.no", "gui.yes"}, npc.ais.returnToStart ? 1 : 0)); + addLabel(new GuiNpcLabel(17, "ai.leapattarget", guiLeft + 150, guiTop + 65)); + addButton(new GuiNpcButton(15, guiLeft + 230, guiTop + 60, 60, 20, new String[]{"gui.no", "ai.jump", "ai.pounce"}, npc.ais.leapType)); + addLabel(new GuiNpcLabel(15, "ai.indirect", guiLeft + 150, guiTop + 90)); + addButton(new GuiNpcButton(13, guiLeft + 230, guiTop + 85, 60, 20, new String[]{"gui.no", "gui.whendistant", "gui.whenhidden"}, ai.canFireIndirect)); + addLabel(new GuiNpcLabel(16, "ai.rangemelee", guiLeft + 150, guiTop + 115)); + addButton(new GuiNpcButton(14, guiLeft + 230, guiTop + 110, 60, 20, new String[]{npc.inventory.getProjectile() == null ? "gui.no" : "gui.always", "gui.untilclose", "gui.whenavailable"}, ai.useRangeMelee)); + if (ai.useRangeMelee >= 1) { + addLabel(new GuiNpcLabel(20, "gui.minrange", guiLeft + 300, guiTop + 115)); + addTextField(new GuiNpcTextField(6, this, fontRendererObj, guiLeft + 380, guiTop + 110, 30, 20, ai.distanceToMelee + "")); + getTextField(6).integersOnly = true; + getTextField(6).setMinMaxDefault(1, npc.stats.aggroRange, 5); + } + addLabel(new GuiNpcLabel(19, "ai.tacticalvariant", guiLeft + 150, guiTop + 140)); + addButton(new GuiNpcButton(17, guiLeft + 230, guiTop + 135, 60, 20, EnumNavType.names(), ai.tacticalVariant.ordinal())); + if (ai.tacticalVariant != EnumNavType.Default && ai.tacticalVariant != EnumNavType.None) { + String label = ""; + switch (ai.tacticalVariant) { + case Surround: + label = "gui.orbitdistance"; + break; + case HitNRun: + label = "gui.fightifthisclose"; + break; + case Ambush: + label = "gui.ambushdistance"; + break; + case Stalk: + label = "gui.ambushdistance"; + break; + default: + label = "gui.engagedistance"; + } + addLabel(new GuiNpcLabel(21, label, guiLeft + 300, guiTop + 140)); + addTextField(new GuiNpcTextField(3, this, fontRendererObj, guiLeft + 380, guiTop + 135, 30, 20, ai.tacticalRadius + "")); + getTextField(3).integersOnly = true; + getTextField(3).setMinMaxDefault(1, npc.stats.aggroRange, 5); + } + addLabel(new GuiNpcLabel(25, "ai.combatpolicy", guiLeft + 150, guiTop + 165)); + addButton(new GuiNpcButton(25, guiLeft + 230, guiTop + 160, 60, 20, EnumCombatPolicy.names(), ai.combatPolicy.ordinal())); + if (ai.combatPolicy == EnumCombatPolicy.Stubborn) { + String label = ""; label = "gui.combatchance"; addLabel(new GuiNpcLabel(21, label, guiLeft + 300, guiTop + 165)); - addTextField(new GuiNpcTextField(4,this, fontRendererObj, guiLeft + 380, guiTop + 160, 30, 20, ai.tacticalChance + "")); - getTextField(4).integersOnly = true; - getTextField(4).setMinMaxDefault(1, 100, 5); - } - else if (ai.combatPolicy == EnumCombatPolicy.Tactical) - { - addButton(new GuiNpcButton(40, guiLeft + 295, guiTop + 160, 60, 20, new String[]{"stats.normal","stats.reverse"}, npc.ais.tacticalChance > 50 ? 1:0)); + addTextField(new GuiNpcTextField(4, this, fontRendererObj, guiLeft + 380, guiTop + 160, 30, 20, ai.tacticalChance + "")); + getTextField(4).integersOnly = true; + getTextField(4).setMinMaxDefault(1, 100, 5); + } else if (ai.combatPolicy == EnumCombatPolicy.Tactical) { + addButton(new GuiNpcButton(40, guiLeft + 295, guiTop + 160, 60, 20, new String[]{"stats.normal", "stats.reverse"}, npc.ais.tacticalChance > 50 ? 1 : 0)); } - getButton(17).setEnabled(this.ai.onAttack == 0); - getButton(15).setEnabled(this.ai.onAttack == 0); - getButton(25).setEnabled(this.ai.onAttack == 0); - getButton(13).setEnabled(this.npc.inventory.getProjectile() != null); - getButton(14).setEnabled(this.npc.inventory.getProjectile() != null); - getButton(10).setEnabled(ai.tacticalVariant != EnumNavType.Stalk && ai.tacticalVariant != EnumNavType.None); + getButton(17).setEnabled(this.ai.onAttack == 0); + getButton(15).setEnabled(this.ai.onAttack == 0); + getButton(25).setEnabled(this.ai.onAttack == 0); + getButton(13).setEnabled(this.npc.inventory.getProjectile() != null); + getButton(14).setEnabled(this.npc.inventory.getProjectile() != null); + getButton(10).setEnabled(ai.tacticalVariant != EnumNavType.Stalk && ai.tacticalVariant != EnumNavType.None); - addLabel(new GuiNpcLabel(2,"ai.movement", guiLeft + 4, guiTop + 165)); - addButton(new GuiNpcButton(2, guiLeft + 86, guiTop + 160, 60, 20, "selectServer.edit")); - } - - @Override - public void unFocused(GuiNpcTextField textfield){ - if(textfield.id == 3){ - ai.tacticalRadius = textfield.getInteger(); - } - if(textfield.id == 4){ - ai.tacticalChance = textfield.getInteger(); - } - if(textfield.id == 6){ - ai.distanceToMelee = textfield.getInteger(); - } - } + addLabel(new GuiNpcLabel(2, "ai.movement", guiLeft + 4, guiTop + 165)); + addButton(new GuiNpcButton(2, guiLeft + 86, guiTop + 160, 60, 20, "selectServer.edit")); + } @Override - protected void actionPerformed(GuiButton guibutton) - { - GuiNpcButton button = (GuiNpcButton) guibutton; - if(button.id == 0){ - ai.onAttack = button.getValue(); - initGui(); - } - else if(button.id == 1){ - ai.doorInteract = button.getValue(); - } - else if(button.id == 2){ - setSubGui(new SubGuiNpcMovement(ai)); - } - else if (button.id == 5) { - npc.setAvoidWater(button.getValue() == 1); - } - else if (button.id == 6) { - ai.returnToStart = (button.getValue() == 1); - } - else if (button.id == 7) { - ai.canSwim = (button.getValue() == 1); - } - else if(button.id == 9){ - ai.findShelter = button.getValue(); - } - else if (button.id == 10) { - ai.directLOS = (button.getValue() == 1); - } - else if (button.id == 13) { - ai.canFireIndirect = button.getValue(); - } - else if (button.id == 14) { - ai.useRangeMelee = button.getValue(); - initGui(); - } - else if (button.id == 15) { - ai.leapType = (byte) button.getValue(); - } - else if (button.id == 16) { - ai.canSprint = (button.getValue() == 1); - } - else if (button.id == 17) { - ai.tacticalVariant = EnumNavType.values()[button.getValue()]; - ai.directLOS = EnumNavType.values()[button.getValue()] != EnumNavType.Stalk && this.ai.directLOS; - initGui(); - } - else if (button.id == 25) { - ai.combatPolicy = EnumCombatPolicy.values()[button.getValue()]; + public void unFocused(GuiNpcTextField textfield) { + if (textfield.id == 3) { + ai.tacticalRadius = textfield.getInteger(); + } + if (textfield.id == 4) { + ai.tacticalChance = textfield.getInteger(); + } + if (textfield.id == 6) { + ai.distanceToMelee = textfield.getInteger(); + } + } + + @Override + protected void actionPerformed(GuiButton guibutton) { + GuiNpcButton button = (GuiNpcButton) guibutton; + if (button.id == 0) { + ai.onAttack = button.getValue(); initGui(); - } - else if (button.id == 40) { + } else if (button.id == 1) { + ai.doorInteract = button.getValue(); + } else if (button.id == 2) { + setSubGui(new SubGuiNpcMovement(ai)); + } else if (button.id == 5) { + npc.setAvoidWater(button.getValue() == 1); + } else if (button.id == 6) { + ai.returnToStart = (button.getValue() == 1); + } else if (button.id == 7) { + ai.canSwim = (button.getValue() == 1); + } else if (button.id == 9) { + ai.findShelter = button.getValue(); + } else if (button.id == 10) { + ai.directLOS = (button.getValue() == 1); + } else if (button.id == 13) { + ai.canFireIndirect = button.getValue(); + } else if (button.id == 14) { + ai.useRangeMelee = button.getValue(); + initGui(); + } else if (button.id == 15) { + ai.leapType = (byte) button.getValue(); + } else if (button.id == 16) { + ai.canSprint = (button.getValue() == 1); + } else if (button.id == 17) { + ai.tacticalVariant = EnumNavType.values()[button.getValue()]; + ai.directLOS = EnumNavType.values()[button.getValue()] != EnumNavType.Stalk && this.ai.directLOS; + initGui(); + } else if (button.id == 25) { + ai.combatPolicy = EnumCombatPolicy.values()[button.getValue()]; + initGui(); + } else if (button.id == 40) { int val = button.getValue(); - if(val == 0){ + if (val == 0) { ai.tacticalChance = 0; } else { ai.tacticalChance = 100; @@ -172,15 +161,15 @@ public class GuiNpcAI extends GuiNPCInterface2 implements ITextfieldListener, IG } } - @Override - public void save() { + @Override + public void save() { PacketClient.sendClient(new MainmenuAISavePacket(ai.writeToNBT(new NBTTagCompound()))); - } + } - @Override - public void setGuiData(NBTTagCompound compound) { - ai.readToNBT(compound); - initGui(); - } + @Override + public void setGuiData(NBTTagCompound compound) { + ai.readToNBT(compound); + initGui(); + } } diff --git a/src/main/java/noppes/npcs/client/gui/mainmenu/GuiNpcAdvanced.java b/src/main/java/noppes/npcs/client/gui/mainmenu/GuiNpcAdvanced.java index dce75f5ea..89439bc0c 100644 --- a/src/main/java/noppes/npcs/client/gui/mainmenu/GuiNpcAdvanced.java +++ b/src/main/java/noppes/npcs/client/gui/mainmenu/GuiNpcAdvanced.java @@ -19,36 +19,35 @@ import noppes.npcs.constants.EnumJobType; import noppes.npcs.constants.EnumRoleType; import noppes.npcs.entity.EntityNPCInterface; -public class GuiNpcAdvanced extends GuiNPCInterface2 implements IGuiData -{ - private boolean hasChanges = false; - public GuiNpcAdvanced(EntityNPCInterface npc) - { - super(npc, 4); +public class GuiNpcAdvanced extends GuiNPCInterface2 implements IGuiData { + private boolean hasChanges = false; + + public GuiNpcAdvanced(EntityNPCInterface npc) { + super(npc, 4); PacketClient.sendClient(new MainmenuAdvancedGetPacket()); } @Override - public void initGui(){ - super.initGui(); - int y = guiTop + 10; - this.addButton(new GuiNpcButton(3, guiLeft + 85 + 160, y, 52, 20, "selectServer.edit")); - this.addButton(new GuiNpcButton(8, guiLeft + 85, y,155,20, new String[]{"role.none","role.trader","role.follower","role.bank","role.transporter", "role.mailman", NoppesStringUtils.translate("role.companion", "(WIP)")},npc.advanced.role.ordinal())); - getButton(3).setEnabled(npc.advanced.role != EnumRoleType.None && npc.advanced.role != EnumRoleType.Postman); + public void initGui() { + super.initGui(); + int y = guiTop + 10; + this.addButton(new GuiNpcButton(3, guiLeft + 85 + 160, y, 52, 20, "selectServer.edit")); + this.addButton(new GuiNpcButton(8, guiLeft + 85, y, 155, 20, new String[]{"role.none", "role.trader", "role.follower", "role.bank", "role.transporter", "role.mailman", NoppesStringUtils.translate("role.companion", "(WIP)")}, npc.advanced.role.ordinal())); + getButton(3).setEnabled(npc.advanced.role != EnumRoleType.None && npc.advanced.role != EnumRoleType.Postman); - this.addButton(new GuiNpcButton(4, guiLeft + 85 + 160, y += 22, 52, 20, "selectServer.edit")); - this.addButton(new GuiNpcButton(5, guiLeft + 85, y,155,20, new String[]{"job.none","job.bard","job.healer","job.guard","job.itemgiver","role.follower", "job.spawner", "job.conversation", "job.chunkloader"},npc.advanced.job.ordinal())); + this.addButton(new GuiNpcButton(4, guiLeft + 85 + 160, y += 22, 52, 20, "selectServer.edit")); + this.addButton(new GuiNpcButton(5, guiLeft + 85, y, 155, 20, new String[]{"job.none", "job.bard", "job.healer", "job.guard", "job.itemgiver", "role.follower", "job.spawner", "job.conversation", "job.chunkloader"}, npc.advanced.job.ordinal())); - getButton(4).setEnabled(npc.advanced.job != EnumJobType.None && npc.advanced.job != EnumJobType.ChunkLoader); + getButton(4).setEnabled(npc.advanced.job != EnumJobType.None && npc.advanced.job != EnumJobType.ChunkLoader); - this.addButton(new GuiNpcButton(7, guiLeft + 15, y += 22, 190, 20, "advanced.lines")); - this.addButton(new GuiNpcButton(9, guiLeft + 208, y, 190, 20, "menu.factions")); + this.addButton(new GuiNpcButton(7, guiLeft + 15, y += 22, 190, 20, "advanced.lines")); + this.addButton(new GuiNpcButton(9, guiLeft + 208, y, 190, 20, "menu.factions")); this.addButton(new GuiNpcButton(10, guiLeft + 15, y += 22, 190, 20, "dialog.dialogs")); - this.addButton(new GuiNpcButton(11, guiLeft + 208, y, 190, 20, "advanced.sounds")); + this.addButton(new GuiNpcButton(11, guiLeft + 208, y, 190, 20, "advanced.sounds")); this.addButton(new GuiNpcButton(12, guiLeft + 15, y += 22, 190, 20, "advanced.night")); - this.addButton(new GuiNpcButton(13, guiLeft + 208, y, 190, 20, "global.linked")); + this.addButton(new GuiNpcButton(13, guiLeft + 208, y, 190, 20, "global.linked")); this.addButton(new GuiNpcButton(14, guiLeft + 15, y += 22, 190, 20, "menu.tags")); this.addButton(new GuiNpcButton(15, guiLeft + 208, y, 190, 20, "advanced.marks")); @@ -57,115 +56,113 @@ public class GuiNpcAdvanced extends GuiNPCInterface2 implements IGuiData } @Override - protected void actionPerformed(GuiButton guibutton) { - GuiNpcButton button = (GuiNpcButton) guibutton; - if (button.id == 3) { - save(); + protected void actionPerformed(GuiButton guibutton) { + GuiNpcButton button = (GuiNpcButton) guibutton; + if (button.id == 3) { + save(); PacketClient.sendClient(new RoleGetPacket()); - } - if(button.id == 8){ - hasChanges = true; - npc.advanced.setRole(button.getValue()); - - getButton(3).setEnabled(npc.advanced.role != EnumRoleType.None && npc.advanced.role != EnumRoleType.Postman); } - if(button.id == 4){ - save(); + if (button.id == 8) { + hasChanges = true; + npc.advanced.setRole(button.getValue()); + + getButton(3).setEnabled(npc.advanced.role != EnumRoleType.None && npc.advanced.role != EnumRoleType.Postman); + } + if (button.id == 4) { + save(); PacketClient.sendClient(new JobGetPacket()); } - if(button.id == 5){ - hasChanges = true; - npc.advanced.setJob(button.getValue()); + if (button.id == 5) { + hasChanges = true; + npc.advanced.setJob(button.getValue()); - getButton(4).setEnabled(npc.advanced.job != EnumJobType.None && npc.advanced.job != EnumJobType.ChunkLoader); + getButton(4).setEnabled(npc.advanced.job != EnumJobType.None && npc.advanced.job != EnumJobType.ChunkLoader); } - if(button.id == 9){ - save(); - NoppesUtil.openGUI(player, new GuiNPCFactionSetup(npc)); + if (button.id == 9) { + save(); + NoppesUtil.openGUI(player, new GuiNPCFactionSetup(npc)); } - if(button.id == 10){ - save(); - NoppesUtil.openGUI(player, new GuiNPCDialogNpcOptions(npc,this)); + if (button.id == 10) { + save(); + NoppesUtil.openGUI(player, new GuiNPCDialogNpcOptions(npc, this)); } - if(button.id == 11){ - save(); - NoppesUtil.openGUI(player, new GuiNPCSoundsMenu(npc)); + if (button.id == 11) { + save(); + NoppesUtil.openGUI(player, new GuiNPCSoundsMenu(npc)); } - if (button.id == 7) { - save(); - NoppesUtil.openGUI(player, new GuiNPCLinesMenu(npc)); - } - if(button.id == 12){ - save(); - NoppesUtil.openGUI(player, new GuiNPCNightSetup(npc)); + if (button.id == 7) { + save(); + NoppesUtil.openGUI(player, new GuiNPCLinesMenu(npc)); } - if(button.id == 13){ - save(); - NoppesUtil.openGUI(player, new GuiNPCAdvancedLinkedNpc(npc)); + if (button.id == 12) { + save(); + NoppesUtil.openGUI(player, new GuiNPCNightSetup(npc)); } - if(button.id == 14){ - save(); - NoppesUtil.openGUI(player, new GuiNPCTagSetup(npc)); - } - if(button.id == 15){ + if (button.id == 13) { + save(); + NoppesUtil.openGUI(player, new GuiNPCAdvancedLinkedNpc(npc)); + } + if (button.id == 14) { + save(); + NoppesUtil.openGUI(player, new GuiNPCTagSetup(npc)); + } + if (button.id == 15) { save(); NoppesUtil.openGUI(player, new GuiNPCMarks(npc)); } - if(button.id == 16){ + if (button.id == 16) { save(); NoppesUtil.openGUI(player, new GuiNPCMagic(npc)); } - } + } - @Override - public void setGuiData(NBTTagCompound compound) { - if(compound.hasKey("RoleData")){ - if(npc.roleInterface != null) - npc.roleInterface.readFromNBT(compound); + @Override + public void setGuiData(NBTTagCompound compound) { + if (compound.hasKey("RoleData")) { + if (npc.roleInterface != null) + npc.roleInterface.readFromNBT(compound); - if(npc.advanced.role == EnumRoleType.Trader) - NoppesUtil.requestOpenGUI(EnumGuiType.SetupTrader); - else if(npc.advanced.role == EnumRoleType.Follower) - NoppesUtil.requestOpenGUI(EnumGuiType.SetupFollower); - else if(npc.advanced.role == EnumRoleType.Bank) - NoppesUtil.requestOpenGUI(EnumGuiType.SetupBank); - else if(npc.advanced.role == EnumRoleType.Transporter) - displayGuiScreen(new GuiNpcTransporter(npc)); - else if(npc.advanced.role == EnumRoleType.Companion) - displayGuiScreen(new GuiNpcCompanion(npc)); - } - else if(compound.hasKey("JobData")){ - if(npc.jobInterface != null) - npc.jobInterface.readFromNBT(compound); + if (npc.advanced.role == EnumRoleType.Trader) + NoppesUtil.requestOpenGUI(EnumGuiType.SetupTrader); + else if (npc.advanced.role == EnumRoleType.Follower) + NoppesUtil.requestOpenGUI(EnumGuiType.SetupFollower); + else if (npc.advanced.role == EnumRoleType.Bank) + NoppesUtil.requestOpenGUI(EnumGuiType.SetupBank); + else if (npc.advanced.role == EnumRoleType.Transporter) + displayGuiScreen(new GuiNpcTransporter(npc)); + else if (npc.advanced.role == EnumRoleType.Companion) + displayGuiScreen(new GuiNpcCompanion(npc)); + } else if (compound.hasKey("JobData")) { + if (npc.jobInterface != null) + npc.jobInterface.readFromNBT(compound); - if(npc.advanced.job == EnumJobType.Bard) - NoppesUtil.openGUI(player, new GuiNpcBard(npc)); - else if(npc.advanced.job == EnumJobType.Healer) - NoppesUtil.openGUI(player, new GuiNpcHealer(npc)); - else if(npc.advanced.job == EnumJobType.Guard) - NoppesUtil.openGUI(player, new GuiNpcGuard(npc)); - else if(npc.advanced.job == EnumJobType.ItemGiver) - NoppesUtil.requestOpenGUI(EnumGuiType.SetupItemGiver); - else if(npc.advanced.job == EnumJobType.Follower) - NoppesUtil.openGUI(player, new GuiNpcFollowerJob(npc)); - else if(npc.advanced.job == EnumJobType.Spawner) - NoppesUtil.openGUI(player, new GuiNpcSpawner(npc)); - else if(npc.advanced.job == EnumJobType.Conversation) - NoppesUtil.openGUI(player, new GuiNpcConversation(npc)); - } - else{ - npc.advanced.readToNBT(compound); - initGui(); - } - } + if (npc.advanced.job == EnumJobType.Bard) + NoppesUtil.openGUI(player, new GuiNpcBard(npc)); + else if (npc.advanced.job == EnumJobType.Healer) + NoppesUtil.openGUI(player, new GuiNpcHealer(npc)); + else if (npc.advanced.job == EnumJobType.Guard) + NoppesUtil.openGUI(player, new GuiNpcGuard(npc)); + else if (npc.advanced.job == EnumJobType.ItemGiver) + NoppesUtil.requestOpenGUI(EnumGuiType.SetupItemGiver); + else if (npc.advanced.job == EnumJobType.Follower) + NoppesUtil.openGUI(player, new GuiNpcFollowerJob(npc)); + else if (npc.advanced.job == EnumJobType.Spawner) + NoppesUtil.openGUI(player, new GuiNpcSpawner(npc)); + else if (npc.advanced.job == EnumJobType.Conversation) + NoppesUtil.openGUI(player, new GuiNpcConversation(npc)); + } else { + npc.advanced.readToNBT(compound); + initGui(); + } + } - @Override - public void save() { - if(hasChanges){ + @Override + public void save() { + if (hasChanges) { PacketClient.sendClient(new MainmenuAdvancedSavePacket(npc.advanced.writeToNBT(new NBTTagCompound()))); - hasChanges = false; - } - } + hasChanges = false; + } + } } diff --git a/src/main/java/noppes/npcs/client/gui/mainmenu/GuiNpcDisplay.java b/src/main/java/noppes/npcs/client/gui/mainmenu/GuiNpcDisplay.java index 41394770c..d3bf1c11b 100644 --- a/src/main/java/noppes/npcs/client/gui/mainmenu/GuiNpcDisplay.java +++ b/src/main/java/noppes/npcs/client/gui/mainmenu/GuiNpcDisplay.java @@ -19,117 +19,110 @@ import noppes.npcs.controllers.data.SkinOverlay; import noppes.npcs.entity.EntityCustomNpc; import noppes.npcs.entity.EntityNPCInterface; -public class GuiNpcDisplay extends GuiNPCInterface2 implements ITextfieldListener, IGuiData{ +public class GuiNpcDisplay extends GuiNPCInterface2 implements ITextfieldListener, IGuiData { private DataDisplay display; public GuiNpcTextField nameText; public GuiNpcDisplay(EntityNPCInterface npc) { - super(npc,1); + super(npc, 1); display = npc.display; PacketClient.sendClient(new MainmenuDisplayGetPacket()); } - public void initGui(){ + public void initGui() { super.initGui(); int y = guiTop + 4; - addLabel(new GuiNpcLabel(0,"gui.name", guiLeft + 5, y + 5)); - nameText = new GuiNpcTextField(0,this, fontRendererObj, guiLeft + 50, y, 206, 20, display.name); + addLabel(new GuiNpcLabel(0, "gui.name", guiLeft + 5, y + 5)); + nameText = new GuiNpcTextField(0, this, fontRendererObj, guiLeft + 50, y, 206, 20, display.name); addTextField(nameText); - this.addButton(new GuiNpcButton(0, guiLeft + 253+52, y , 110, 20, new String[]{"display.show","display.hide","display.showAttacking"} ,display.showName)); + this.addButton(new GuiNpcButton(0, guiLeft + 253 + 52, y, 110, 20, new String[]{"display.show", "display.hide", "display.showAttacking"}, display.showName)); - this.addButton(new GuiNpcButton(14, guiLeft + 259, y , 20, 20, Character.toString('\u21bb'))); + this.addButton(new GuiNpcButton(14, guiLeft + 259, y, 20, 20, Character.toString('\u21bb'))); getButton(14).setIconTexture(new ResourceLocation("customnpcs", "textures/gui/slot.png")); - this.addButton(new GuiNpcButton(15, guiLeft + 259 + 22, y , 20, 20, Character.toString('\u22EE'))); + this.addButton(new GuiNpcButton(15, guiLeft + 259 + 22, y, 20, 20, Character.toString('\u22EE'))); - y+=23; - addLabel(new GuiNpcLabel(11,"gui.title", guiLeft + 5, y + 5)); - addTextField(new GuiNpcTextField(11,this, fontRendererObj, guiLeft + 50, y, 206, 20, display.title)); - y+=23; - addLabel(new GuiNpcLabel(1,"display.model", guiLeft + 5, y + 5)); - this.addButton(new GuiNpcButton(1, guiLeft + 50, y,110,20, "selectServer.edit")); - addLabel(new GuiNpcLabel(2,"display.size", guiLeft + 175, y + 5)); - addTextField(new GuiNpcTextField(2,this, fontRendererObj, guiLeft + 203, y, 40, 20, display.modelSize + "")); + y += 23; + addLabel(new GuiNpcLabel(11, "gui.title", guiLeft + 5, y + 5)); + addTextField(new GuiNpcTextField(11, this, fontRendererObj, guiLeft + 50, y, 206, 20, display.title)); + y += 23; + addLabel(new GuiNpcLabel(1, "display.model", guiLeft + 5, y + 5)); + this.addButton(new GuiNpcButton(1, guiLeft + 50, y, 110, 20, "selectServer.edit")); + addLabel(new GuiNpcLabel(2, "display.size", guiLeft + 175, y + 5)); + addTextField(new GuiNpcTextField(2, this, fontRendererObj, guiLeft + 203, y, 40, 20, display.modelSize + "")); getTextField(2).integersOnly = true; getTextField(2).setMinMaxDefault(1, ConfigMain.NpcSizeLimit, 5); - y+=23; - addLabel(new GuiNpcLabel(4,"display.texture", guiLeft + 5, y + 5)); - addTextField(new GuiNpcTextField(3,this, fontRendererObj, guiLeft + 80, y, 200, 20, display.skinType == 0?display.texture:display.url)); + y += 23; + addLabel(new GuiNpcLabel(4, "display.texture", guiLeft + 5, y + 5)); + addTextField(new GuiNpcTextField(3, this, fontRendererObj, guiLeft + 80, y, 200, 20, display.skinType == 0 ? display.texture : display.url)); this.addButton(new GuiNpcButton(3, guiLeft + 325, y, 38, 20, "gui.select")); - this.addButton(new GuiNpcButton(2, guiLeft + 283, y, 40, 20, new String[]{"display.texture","display.player", "display.url", "display.urlSix"},display.skinType)); + this.addButton(new GuiNpcButton(2, guiLeft + 283, y, 40, 20, new String[]{"display.texture", "display.player", "display.url", "display.urlSix"}, display.skinType)); getButton(3).setEnabled(display.skinType == 0); - if(display.skinType == 1 && display.playerProfile != null) + if (display.skinType == 1 && display.playerProfile != null) getTextField(3).setText(display.playerProfile.getName()); - y+=23; - addLabel(new GuiNpcLabel(8,"display.cape", guiLeft + 5, y + 5)); - addTextField(new GuiNpcTextField(8,this, fontRendererObj, guiLeft + 80, y, 200, 20, display.cloakTexture)); + y += 23; + addLabel(new GuiNpcLabel(8, "display.cape", guiLeft + 5, y + 5)); + addTextField(new GuiNpcTextField(8, this, fontRendererObj, guiLeft + 80, y, 200, 20, display.cloakTexture)); this.addButton(new GuiNpcButton(8, guiLeft + 283, y, 80, 20, "display.selectTexture")); - y+=23; - addLabel(new GuiNpcLabel(9,"display.overlay", guiLeft + 5, y + 5)); + y += 23; + addLabel(new GuiNpcLabel(9, "display.overlay", guiLeft + 5, y + 5)); - addTextField(new GuiNpcTextField(9,this, fontRendererObj, guiLeft + 80, y, 200, 20, npc.display.skinOverlayData.overlayList.containsKey(0) ? npc.display.skinOverlayData.overlayList.get(0).getTexture() : "")); + addTextField(new GuiNpcTextField(9, this, fontRendererObj, guiLeft + 80, y, 200, 20, npc.display.skinOverlayData.overlayList.containsKey(0) ? npc.display.skinOverlayData.overlayList.get(0).getTexture() : "")); this.addButton(new GuiNpcButton(9, guiLeft + 283, y, 80, 20, "display.selectTexture")); - this.addButton(new GuiNpcButton(11, guiLeft + 365, y, 50, 20, new String[]{"display.glow","display.solid"}, !npc.display.skinOverlayData.overlayList.containsKey(0) ? 1 : npc.display.skinOverlayData.overlayList.get(0).getGlow() ? 0 : 1)); + this.addButton(new GuiNpcButton(11, guiLeft + 365, y, 50, 20, new String[]{"display.glow", "display.solid"}, !npc.display.skinOverlayData.overlayList.containsKey(0) ? 1 : npc.display.skinOverlayData.overlayList.get(0).getGlow() ? 0 : 1)); if (!npc.display.skinOverlayData.overlayList.containsKey(0)) { this.getButton(11).setVisible(false); this.getButton(11).setEnabled(false); } - y+=23; - addLabel(new GuiNpcLabel(5,"display.livingAnimation", guiLeft + 5, y + 5)); - this.addButton(new GuiNpcButton(5, guiLeft + 120, y, 50, 20, new String[]{"gui.yes","gui.no"}, display.disableLivingAnimation?1:0)); - this.addButton(new GuiNpcButton(13, guiLeft + 185, y , 100, 20, "display.tintsettings")); - this.addButton(new GuiNpcButton(12,guiLeft + 300, y, 100, 20, "display.hitboxsettings")); + y += 23; + addLabel(new GuiNpcLabel(5, "display.livingAnimation", guiLeft + 5, y + 5)); + this.addButton(new GuiNpcButton(5, guiLeft + 120, y, 50, 20, new String[]{"gui.yes", "gui.no"}, display.disableLivingAnimation ? 1 : 0)); + this.addButton(new GuiNpcButton(13, guiLeft + 185, y, 100, 20, "display.tintsettings")); + this.addButton(new GuiNpcButton(12, guiLeft + 300, y, 100, 20, "display.hitboxsettings")); - y+=23; - addLabel(new GuiNpcLabel(7,"display.visible", guiLeft + 5, y + 5)); - this.addButton(new GuiNpcButton(7, guiLeft + 120, y, 50, 20, new String[]{"gui.yes","gui.no","gui.partly"}, display.visible)); + y += 23; + addLabel(new GuiNpcLabel(7, "display.visible", guiLeft + 5, y + 5)); + this.addButton(new GuiNpcButton(7, guiLeft + 120, y, 50, 20, new String[]{"gui.yes", "gui.no", "gui.partly"}, display.visible)); - y+=23; - addLabel(new GuiNpcLabel(10,"display.bossbar", guiLeft + 5, y + 5)); - this.addButton(new GuiNpcButton(10, guiLeft + 60, y, 110, 20, new String[]{"display.hide","display.show","display.showAttacking"}, display.showBossBar)); + y += 23; + addLabel(new GuiNpcLabel(10, "display.bossbar", guiLeft + 5, y + 5)); + this.addButton(new GuiNpcButton(10, guiLeft + 60, y, 110, 20, new String[]{"display.hide", "display.show", "display.showAttacking"}, display.showBossBar)); GeckoAddonClient.Instance.geckoNpcDisplayInitGui(this); } @Override - public void unFocused(GuiNpcTextField textfield){ - if(textfield.id == 0){ - if(!textfield.isEmpty()) + public void unFocused(GuiNpcTextField textfield) { + if (textfield.id == 0) { + if (!textfield.isEmpty()) display.name = textfield.getText(); else textfield.setText(display.name); - } - else if(textfield.id == 2){ + } else if (textfield.id == 2) { display.modelSize = textfield.getInteger(); - } - else if(textfield.id == 3){ + } else if (textfield.id == 3) { // SKIN CHANGE - if(display.skinType == 2 || display.skinType == 3){ + if (display.skinType == 2 || display.skinType == 3) { display.url = textfield.getText(); - } - else if(display.skinType == 1){ - if(!textfield.isEmpty()){ + } else if (display.skinType == 1) { + if (!textfield.isEmpty()) { display.playerProfile = new GameProfile(null, textfield.getText()); - } - else + } else display.playerProfile = null; - } - else + } else display.texture = textfield.getText(); - } - else if(textfield.id == 8){ + } else if (textfield.id == 8) { display.cloakTexture = textfield.getText(); - } - else if(textfield.id == 9){ + } else if (textfield.id == 9) { if (!textfield.getText().isEmpty()) { boolean isGlow = true; - if(npc.display.skinOverlayData.has(0)) + if (npc.display.skinOverlayData.has(0)) isGlow = npc.display.skinOverlayData.overlayList.get(0).getGlow(); SkinOverlay skinOverlay = new SkinOverlay(textfield.getText()); @@ -140,62 +133,51 @@ public class GuiNpcDisplay extends GuiNPCInterface2 implements ITextfieldListene npc.display.skinOverlayData.overlayList.remove(0); } initGui(); - } - else if(textfield.id == 11){ + } else if (textfield.id == 11) { display.title = textfield.getText(); } } - protected void actionPerformed(GuiButton guibutton){ + + protected void actionPerformed(GuiButton guibutton) { GuiNpcButton button = (GuiNpcButton) guibutton; - if(button.id == 0){ + if (button.id == 0) { display.showName = button.getValue(); } - if(button.id == 1){ + if (button.id == 1) { NoppesUtil.openGUI(player, new GuiCreationScreen(this, (EntityCustomNpc) npc)); } - if(button.id == 2){ + if (button.id == 2) { display.skinType = (byte) button.getValue(); - if (display.skinType != 3){ + if (display.skinType != 3) { display.url = ""; } display.playerProfile = null; initGui(); - } - else if(button.id == 3){ + } else if (button.id == 3) { setSubGui(new GuiTextureSelection(npc, npc.display.getSkinTexture())); - } - else if(button.id == 5){ + } else if (button.id == 5) { display.disableLivingAnimation = button.getValue() == 1; - } - else if(button.id == 7){ + } else if (button.id == 7) { display.visible = button.getValue(); - } - else if(button.id == 8){ + } else if (button.id == 8) { NoppesUtil.openGUI(player, new GuiNpcTextureCloaks(npc, this)); - } - else if(button.id == 9){ + } else if (button.id == 9) { NoppesUtil.openGUI(player, new GuiNpcTextureOverlays(npc, this)); - } - else if(button.id == 10){ - display.showBossBar = (byte)button.getValue(); - } - else if(button.id == 11){ + } else if (button.id == 10) { + display.showBossBar = (byte) button.getValue(); + } else if (button.id == 11) { npc.display.skinOverlayData.overlayList.get(0).setGlow(button.getValue() == 0); npc.display.skinOverlayData.overlayList.get(0).setBlend(button.getValue() == 0); initGui(); - } - else if (button.id == 12){ + } else if (button.id == 12) { setSubGui(new SubGuiCustomHitbox(display.hitboxData)); - } - else if (button.id == 13){ + } else if (button.id == 13) { setSubGui(new SubGuiNpcTint(display.tintData)); - } - else if(button.id == 14){ + } else if (button.id == 14) { String name = display.getRandomName(); display.setName(name); getTextField(0).setText(name); - } - else if(button.id == 15){ + } else if (button.id == 15) { setSubGui(new SubGuiNpcName(display)); } @@ -211,7 +193,7 @@ public class GuiNpcDisplay extends GuiNPCInterface2 implements ITextfieldListene @Override public void save() { - if(display.skinType == 1) + if (display.skinType == 1) display.loadProfile(); npc.textureLocation = null; diff --git a/src/main/java/noppes/npcs/client/gui/mainmenu/GuiNpcStats.java b/src/main/java/noppes/npcs/client/gui/mainmenu/GuiNpcStats.java index 7dc198388..b460d9702 100644 --- a/src/main/java/noppes/npcs/client/gui/mainmenu/GuiNpcStats.java +++ b/src/main/java/noppes/npcs/client/gui/mainmenu/GuiNpcStats.java @@ -12,152 +12,137 @@ import noppes.npcs.client.gui.*; import noppes.npcs.client.gui.util.*; import noppes.npcs.entity.EntityNPCInterface; -public class GuiNpcStats extends GuiNPCInterface2 implements ITextfieldListener, IGuiData{ - private DataStats stats; - public GuiNpcStats(EntityNPCInterface npc) { - super(npc,2); - stats = npc.stats; +public class GuiNpcStats extends GuiNPCInterface2 implements ITextfieldListener, IGuiData { + private DataStats stats; + + public GuiNpcStats(EntityNPCInterface npc) { + super(npc, 2); + stats = npc.stats; PacketClient.sendClient(new MainmenuStatsGetPacket()); - } + } - @Override - public void initGui(){ + @Override + public void initGui() { super.initGui(); int y = guiTop + 10; - addLabel(new GuiNpcLabel(0,"stats.health", guiLeft + 5, y + 5)); - addTextField(new GuiNpcTextField(0,this, guiLeft + 82, y, 185, 18, String.format("%.0f", stats.maxHealth) + "")); + addLabel(new GuiNpcLabel(0, "stats.health", guiLeft + 5, y + 5)); + addTextField(new GuiNpcTextField(0, this, guiLeft + 82, y, 185, 18, String.format("%.0f", stats.maxHealth) + "")); getTextField(0).doublesOnly = true; - getTextField(0).setMinMaxDefaultDouble(0, Double.MAX_VALUE,20); + getTextField(0).setMinMaxDefaultDouble(0, Double.MAX_VALUE, 20); - addLabel(new GuiNpcLabel(1,"stats.aggro", guiLeft + 275, y + 5)); - addTextField(new GuiNpcTextField(1, this, fontRendererObj, guiLeft + 355, y, 56, 18, stats.aggroRange+"")); + addLabel(new GuiNpcLabel(1, "stats.aggro", guiLeft + 275, y + 5)); + addTextField(new GuiNpcTextField(1, this, fontRendererObj, guiLeft + 355, y, 56, 18, stats.aggroRange + "")); getTextField(1).integersOnly = true; getTextField(1).setMinMaxDefault(1, 96, 2); // Doesn't work past 32 technically (MC Limitations) - addButton(new GuiNpcButton(0,guiLeft + 82, y+=22, 56, 20, "selectServer.edit")); - addLabel(new GuiNpcLabel(2,"stats.respawn", guiLeft + 5, y + 5)); + addButton(new GuiNpcButton(0, guiLeft + 82, y += 22, 56, 20, "selectServer.edit")); + addLabel(new GuiNpcLabel(2, "stats.respawn", guiLeft + 5, y + 5)); - this.addButton(new GuiNpcButton(2, guiLeft + 82, y+=22, 56, 20, "selectServer.edit")); - addLabel(new GuiNpcLabel(5,"stats.meleeproperties", guiLeft + 5, y + 5)); + this.addButton(new GuiNpcButton(2, guiLeft + 82, y += 22, 56, 20, "selectServer.edit")); + addLabel(new GuiNpcLabel(5, "stats.meleeproperties", guiLeft + 5, y + 5)); - this.addButton(new GuiNpcButton(3, guiLeft + 82, y+=22, 56, 20, "selectServer.edit")); - addLabel(new GuiNpcLabel(6,"stats.rangedproperties", guiLeft + 5, y + 5)); - this.addButton(new GuiNpcButton(9, guiLeft + 217, y, 56, 20, "selectServer.edit")); - addLabel(new GuiNpcLabel(7,"stats.projectileproperties", guiLeft + 140, y + 5)); - addTextField(new GuiNpcTextField(14, this, guiLeft + 355, y, 56, 20, String.format("%.0f", stats.healthRegen) + "").setFloatsOnly()); - addLabel(new GuiNpcLabel(14,"stats.regenhealth", guiLeft + 275, y + 5)); + this.addButton(new GuiNpcButton(3, guiLeft + 82, y += 22, 56, 20, "selectServer.edit")); + addLabel(new GuiNpcLabel(6, "stats.rangedproperties", guiLeft + 5, y + 5)); + this.addButton(new GuiNpcButton(9, guiLeft + 217, y, 56, 20, "selectServer.edit")); + addLabel(new GuiNpcLabel(7, "stats.projectileproperties", guiLeft + 140, y + 5)); + addTextField(new GuiNpcTextField(14, this, guiLeft + 355, y, 56, 20, String.format("%.0f", stats.healthRegen) + "").setFloatsOnly()); + addLabel(new GuiNpcLabel(14, "stats.regenhealth", guiLeft + 275, y + 5)); - this.addButton(new GuiNpcButton(15, guiLeft + 82, y+=34, 56, 20, "selectServer.edit")); - addLabel(new GuiNpcLabel(15,"potion.resistance", guiLeft + 5, y + 5)); - this.addButton(new GuiNpcButton(21, guiLeft + 217, y, 56, 20, new String[]{"gui.no","gui.yes"}, this.stats.resistances.disableDamage? 1:0)); - addLabel(new GuiNpcLabel(21,"stats.disabledamage", guiLeft + 140, y + 5)); - addTextField(new GuiNpcTextField(16, this, guiLeft + 355, y, 56, 20, String.format("%.0f", stats.combatRegen) + "").setFloatsOnly()); - addLabel(new GuiNpcLabel(16,"stats.combatregen", guiLeft + 275, y + 5)); + this.addButton(new GuiNpcButton(15, guiLeft + 82, y += 34, 56, 20, "selectServer.edit")); + addLabel(new GuiNpcLabel(15, "potion.resistance", guiLeft + 5, y + 5)); + this.addButton(new GuiNpcButton(21, guiLeft + 217, y, 56, 20, new String[]{"gui.no", "gui.yes"}, this.stats.resistances.disableDamage ? 1 : 0)); + addLabel(new GuiNpcLabel(21, "stats.disabledamage", guiLeft + 140, y + 5)); + addTextField(new GuiNpcTextField(16, this, guiLeft + 355, y, 56, 20, String.format("%.0f", stats.combatRegen) + "").setFloatsOnly()); + addLabel(new GuiNpcLabel(16, "stats.combatregen", guiLeft + 275, y + 5)); - addButton(new GuiNpcButton(4,guiLeft + 82, y+=34, 56, 20, new String[]{"gui.no","gui.yes"} ,npc.isImmuneToFire()? 1:0)); - addLabel(new GuiNpcLabel(10,"stats.fireimmune", guiLeft + 5, y + 5)); - addButton(new GuiNpcButton(5,guiLeft + 217, y, 56, 20, new String[]{"stats.never","stats.inWater","stats.inAir"} , stats.drowningType)); - addLabel(new GuiNpcLabel(11,"stats.candrown", guiLeft + 140, y + 5)); - addButton(new GuiNpcButton(23, guiLeft + 358, y, 56, 20, new String[]{"display.all","gui.none","NPCs","Players","Both"}, stats.collidesWith)); - addLabel(new GuiNpcLabel(23,"stats.collides", guiLeft + 275, y + 5)); + addButton(new GuiNpcButton(4, guiLeft + 82, y += 34, 56, 20, new String[]{"gui.no", "gui.yes"}, npc.isImmuneToFire() ? 1 : 0)); + addLabel(new GuiNpcLabel(10, "stats.fireimmune", guiLeft + 5, y + 5)); + addButton(new GuiNpcButton(5, guiLeft + 217, y, 56, 20, new String[]{"stats.never", "stats.inWater", "stats.inAir"}, stats.drowningType)); + addLabel(new GuiNpcLabel(11, "stats.candrown", guiLeft + 140, y + 5)); + addButton(new GuiNpcButton(23, guiLeft + 358, y, 56, 20, new String[]{"display.all", "gui.none", "NPCs", "Players", "Both"}, stats.collidesWith)); + addLabel(new GuiNpcLabel(23, "stats.collides", guiLeft + 275, y + 5)); - addButton(new GuiNpcButton(6,guiLeft + 82, y+=22, 56, 20, new String[]{"gui.no","gui.yes"} ,stats.burnInSun? 1:0)); - addLabel(new GuiNpcLabel(12,"stats.burninsun", guiLeft + 5, y + 5)); - addButton(new GuiNpcButton(7,guiLeft + 217, y, 56, 20, new String[]{"gui.no","gui.yes"} ,stats.noFallDamage? 1:0)); - addLabel(new GuiNpcLabel(13,"stats.nofalldamage", guiLeft + 140, y + 5)); - addLabel(new GuiNpcLabel(22,"ai.cobwebAffected", guiLeft + 275, y + 5)); - addButton(new GuiNpcButton(22 ,guiLeft + 358, y, 56, 20, new String[]{"gui.no", "gui.yes"}, npc.stats.ignoreCobweb ? 0:1)); + addButton(new GuiNpcButton(6, guiLeft + 82, y += 22, 56, 20, new String[]{"gui.no", "gui.yes"}, stats.burnInSun ? 1 : 0)); + addLabel(new GuiNpcLabel(12, "stats.burninsun", guiLeft + 5, y + 5)); + addButton(new GuiNpcButton(7, guiLeft + 217, y, 56, 20, new String[]{"gui.no", "gui.yes"}, stats.noFallDamage ? 1 : 0)); + addLabel(new GuiNpcLabel(13, "stats.nofalldamage", guiLeft + 140, y + 5)); + addLabel(new GuiNpcLabel(22, "ai.cobwebAffected", guiLeft + 275, y + 5)); + addButton(new GuiNpcButton(22, guiLeft + 358, y, 56, 20, new String[]{"gui.no", "gui.yes"}, npc.stats.ignoreCobweb ? 0 : 1)); - addButton(new GuiNpcButtonYesNo(17, guiLeft + 82, y+=22, 56, 20, stats.potionImmune)); - addLabel(new GuiNpcLabel(17,"stats.potionImmune", guiLeft + 5, y + 5)); - addButton(new GuiNpcButtonYesNo(18, guiLeft + 217, y, 56, 20, stats.attackInvisible)); - addLabel(new GuiNpcLabel(18,"stats.attackInvisible", guiLeft + 140, y + 5)); - addLabel(new GuiNpcLabel(34,"stats.creaturetype", guiLeft + 275, y + 5)); - addButton(new GuiNpcButton(8,guiLeft + 358, y, 56, 20, new String[]{"stats.normal","stats.undead","stats.arthropod"} ,stats.creatureType.ordinal())); + addButton(new GuiNpcButtonYesNo(17, guiLeft + 82, y += 22, 56, 20, stats.potionImmune)); + addLabel(new GuiNpcLabel(17, "stats.potionImmune", guiLeft + 5, y + 5)); + addButton(new GuiNpcButtonYesNo(18, guiLeft + 217, y, 56, 20, stats.attackInvisible)); + addLabel(new GuiNpcLabel(18, "stats.attackInvisible", guiLeft + 140, y + 5)); + addLabel(new GuiNpcLabel(34, "stats.creaturetype", guiLeft + 275, y + 5)); + addButton(new GuiNpcButton(8, guiLeft + 358, y, 56, 20, new String[]{"stats.normal", "stats.undead", "stats.arthropod"}, stats.creatureType.ordinal())); DBCClient.Instance.showDBCStatButtons(this, npc); - } - - @Override - public void unFocused(GuiNpcTextField textfield){ - if(textfield.id == 0){ - stats.maxHealth = Math.floor(Double.parseDouble(textfield.getText())); - npc.heal((float)(stats.maxHealth)); - } - else if(textfield.id == 1){ - stats.aggroRange = textfield.getInteger(); - } - else if(textfield.id == 14){ - stats.healthRegen = (float)(Math.floor(Float.parseFloat(textfield.getText()))); - } - else if(textfield.id == 16){ - stats.combatRegen = (float)(Math.floor(Float.parseFloat(textfield.getText()))); - } - } + } @Override - protected void actionPerformed(GuiButton guibutton){ - GuiNpcButton button = (GuiNpcButton) guibutton; - if (button.id == 0){ - setSubGui(new SubGuiNpcRespawn(this.stats)); - } - else if (button.id == 2){ - setSubGui(new SubGuiNpcMeleeProperties(this.stats)); - } - else if (button.id == 3){ - setSubGui(new SubGuiNpcRangeProperties(this.stats)); - } - else if(button.id == 4){ - npc.setImmuneToFire(button.getValue() == 1); - } - else if(button.id == 5){ - npc.stats.drowningType = button.getValue(); - } - else if(button.id == 6){ - stats.burnInSun = button.getValue() == 1; - } - else if(button.id == 7){ - stats.noFallDamage = button.getValue() == 1; - } - else if (button.id == 8) { - stats.creatureType = EnumCreatureAttribute.values()[button.getValue()]; - } - else if (button.id == 9) { - setSubGui(new SubGuiNpcProjectiles(this.stats)); - } - else if (button.id == 15) { - setSubGui(new SubGuiNpcResistanceProperties(this.stats.resistances)); - } - else if (button.id == 17) { - stats.potionImmune = ((GuiNpcButtonYesNo)guibutton).getBoolean(); - } - else if (button.id == 18) { - stats.potionImmune = ((GuiNpcButtonYesNo)guibutton).getBoolean(); - } - else if(button.id == 21){ + public void unFocused(GuiNpcTextField textfield) { + if (textfield.id == 0) { + stats.maxHealth = Math.floor(Double.parseDouble(textfield.getText())); + npc.heal((float) (stats.maxHealth)); + } else if (textfield.id == 1) { + stats.aggroRange = textfield.getInteger(); + } else if (textfield.id == 14) { + stats.healthRegen = (float) (Math.floor(Float.parseFloat(textfield.getText()))); + } else if (textfield.id == 16) { + stats.combatRegen = (float) (Math.floor(Float.parseFloat(textfield.getText()))); + } + } + + @Override + protected void actionPerformed(GuiButton guibutton) { + GuiNpcButton button = (GuiNpcButton) guibutton; + if (button.id == 0) { + setSubGui(new SubGuiNpcRespawn(this.stats)); + } else if (button.id == 2) { + setSubGui(new SubGuiNpcMeleeProperties(this.stats)); + } else if (button.id == 3) { + setSubGui(new SubGuiNpcRangeProperties(this.stats)); + } else if (button.id == 4) { + npc.setImmuneToFire(button.getValue() == 1); + } else if (button.id == 5) { + npc.stats.drowningType = button.getValue(); + } else if (button.id == 6) { + stats.burnInSun = button.getValue() == 1; + } else if (button.id == 7) { + stats.noFallDamage = button.getValue() == 1; + } else if (button.id == 8) { + stats.creatureType = EnumCreatureAttribute.values()[button.getValue()]; + } else if (button.id == 9) { + setSubGui(new SubGuiNpcProjectiles(this.stats)); + } else if (button.id == 15) { + setSubGui(new SubGuiNpcResistanceProperties(this.stats.resistances)); + } else if (button.id == 17) { + stats.potionImmune = ((GuiNpcButtonYesNo) guibutton).getBoolean(); + } else if (button.id == 18) { + stats.potionImmune = ((GuiNpcButtonYesNo) guibutton).getBoolean(); + } else if (button.id == 21) { // Magic Button - stats.resistances.disableDamage = ((GuiNpcButton)guibutton).getValue() == 1; - } - else if (button.id == 22) { - stats.ignoreCobweb = (button.getValue() == 0); - } - else if(button.id == 23){ + stats.resistances.disableDamage = ((GuiNpcButton) guibutton).getValue() == 1; + } else if (button.id == 22) { + stats.ignoreCobweb = (button.getValue() == 0); + } else if (button.id == 23) { stats.collidesWith = button.getValue(); } // Button 300 - if(guibutton instanceof GuiNpcButton) + if (guibutton instanceof GuiNpcButton) DBCClient.Instance.showDBCStatActionPerformed(this, (GuiNpcButton) guibutton); } - @Override - public void save() { - PacketClient.sendClient(new MainmenuStatsSavePacket(stats.writeToNBT(new NBTTagCompound()))); - } - @Override - public void setGuiData(NBTTagCompound compound) { - stats.readToNBT(compound); - initGui(); - } + @Override + public void save() { + PacketClient.sendClient(new MainmenuStatsSavePacket(stats.writeToNBT(new NBTTagCompound()))); + } + + @Override + public void setGuiData(NBTTagCompound compound) { + stats.readToNBT(compound); + initGui(); + } } diff --git a/src/main/java/noppes/npcs/client/gui/model/GuiCreationScreen.java b/src/main/java/noppes/npcs/client/gui/model/GuiCreationScreen.java index 0fbf1e35f..722d9ff86 100644 --- a/src/main/java/noppes/npcs/client/gui/model/GuiCreationScreen.java +++ b/src/main/java/noppes/npcs/client/gui/model/GuiCreationScreen.java @@ -24,371 +24,359 @@ import java.lang.reflect.Method; import java.lang.reflect.Modifier; import java.util.*; -public class GuiCreationScreen extends GuiModelInterface implements ICustomScrollListener{ +public class GuiCreationScreen extends GuiModelInterface implements ICustomScrollListener { - public HashMap> data = new HashMap>(); - private List list; - private final String[] ignoredTags = {"CanBreakDoors", "Bred", "PlayerCreated", "Tame", "HasReproduced"}; + public HashMap> data = new HashMap>(); + private List list; + private final String[] ignoredTags = {"CanBreakDoors", "Bred", "PlayerCreated", "Tame", "HasReproduced"}; - private GuiNpcButton prev,next; + private GuiNpcButton prev, next; - private GuiScreen parent; + private GuiScreen parent; - private HashMap mapped = new HashMap(); + private HashMap mapped = new HashMap(); - public GuiCreationScreen(GuiScreen parent, EntityCustomNpc npc){ - super(npc); - this.parent = parent; - Map mapping = EntityList.stringToClassMapping; - for(Object name : mapping.keySet()){ - Class c = (Class) mapping.get(name); - try { - if(!EntityCustomNpc.class.isAssignableFrom(c) && EntityLiving.class.isAssignableFrom(c) && c.getConstructor(World.class) != null && !Modifier.isAbstract(c.getModifiers())){ - if(RenderManager.instance.getEntityClassRenderObject(c) instanceof RendererLivingEntity){ - if(EntityNpcSlime.class.isAssignableFrom(c)){ - data.put("CustomNPC Slime",c.asSubclass(EntityLivingBase.class)); - } - else if(EntityNpcDragon.class.isAssignableFrom(c)){ - data.put("CustomNPC Dragon",c.asSubclass(EntityLivingBase.class)); - } - else if(EntityNpcPony.class.isAssignableFrom(c)){ - data.put("CustomNPC Pony",c.asSubclass(EntityLivingBase.class)); - } - else if(EntityNPCGolem.class.isAssignableFrom(c)){ - data.put("CustomNPC Golem",c.asSubclass(EntityLivingBase.class)); - } - else if(EntityNpcCrystal.class.isAssignableFrom(c)){ - data.put("CustomNPC Crystal",c.asSubclass(EntityLivingBase.class)); - } - else { - String className = name.toString(); - if(className.equals("npcgecko.CustomModelEntity")){ - data.put("CustomNPC GeoModel",c.asSubclass(EntityLivingBase.class)); - } - else { - data.put(name.toString(),c.asSubclass(EntityLivingBase.class)); - } + public GuiCreationScreen(GuiScreen parent, EntityCustomNpc npc) { + super(npc); + this.parent = parent; + Map mapping = EntityList.stringToClassMapping; + for (Object name : mapping.keySet()) { + Class c = (Class) mapping.get(name); + try { + if (!EntityCustomNpc.class.isAssignableFrom(c) && EntityLiving.class.isAssignableFrom(c) && c.getConstructor(World.class) != null && !Modifier.isAbstract(c.getModifiers())) { + if (RenderManager.instance.getEntityClassRenderObject(c) instanceof RendererLivingEntity) { + if (EntityNpcSlime.class.isAssignableFrom(c)) { + data.put("CustomNPC Slime", c.asSubclass(EntityLivingBase.class)); + } else if (EntityNpcDragon.class.isAssignableFrom(c)) { + data.put("CustomNPC Dragon", c.asSubclass(EntityLivingBase.class)); + } else if (EntityNpcPony.class.isAssignableFrom(c)) { + data.put("CustomNPC Pony", c.asSubclass(EntityLivingBase.class)); + } else if (EntityNPCGolem.class.isAssignableFrom(c)) { + data.put("CustomNPC Golem", c.asSubclass(EntityLivingBase.class)); + } else if (EntityNpcCrystal.class.isAssignableFrom(c)) { + data.put("CustomNPC Crystal", c.asSubclass(EntityLivingBase.class)); + } else { + String className = name.toString(); + if (className.equals("npcgecko.CustomModelEntity")) { + data.put("CustomNPC GeoModel", c.asSubclass(EntityLivingBase.class)); + } else { + data.put(name.toString(), c.asSubclass(EntityLivingBase.class)); + } - } - } - } - } catch (SecurityException e) { - e.printStackTrace(); - } catch (NoSuchMethodException e) { - } - } - list = new ArrayList(data.keySet()); - Collections.sort(list,String.CASE_INSENSITIVE_ORDER); - } + } + } + } + } catch (SecurityException e) { + e.printStackTrace(); + } catch (NoSuchMethodException e) { + } + } + list = new ArrayList(data.keySet()); + Collections.sort(list, String.CASE_INSENSITIVE_ORDER); + } - @Override - public void initGui() { - EntityLivingBase entity = (EntityLivingBase) playerdata.getEntity(npc); - xOffset = entity == null?0:50; - super.initGui(); + @Override + public void initGui() { + EntityLivingBase entity = (EntityLivingBase) playerdata.getEntity(npc); + xOffset = entity == null ? 0 : 50; + super.initGui(); - String title = "CustomNPC"; - if(entity != null) - title = (String) EntityList.classToStringMapping.get(playerdata.getEntityClass()); - this.addButton(new GuiNpcButton(1, guiLeft + 140, guiTop, 100, 20, title)); + String title = "CustomNPC"; + if (entity != null) + title = (String) EntityList.classToStringMapping.get(playerdata.getEntityClass()); + this.addButton(new GuiNpcButton(1, guiLeft + 140, guiTop, 100, 20, title)); - this.addButton(prev = new GuiNpcButton(0, guiLeft + 118, guiTop, 20, 20, "<")); - this.addButton(next = new GuiNpcButton(2, guiLeft + 242, guiTop, 20, 20, ">")); - prev.enabled = getCurrentEntityIndex() >= 0; - next.enabled = getCurrentEntityIndex() < list.size() - 1; + this.addButton(prev = new GuiNpcButton(0, guiLeft + 118, guiTop, 20, 20, "<")); + this.addButton(next = new GuiNpcButton(2, guiLeft + 242, guiTop, 20, 20, ">")); + prev.enabled = getCurrentEntityIndex() >= 0; + next.enabled = getCurrentEntityIndex() < list.size() - 1; - if(entity == null){ - showPlayerButtons(); - } - else if(PixelmonHelper.isPixelmon(entity)){ - showPixelmonMenu(entity); - } - else{ - showEntityButtons(entity); - } - } + if (entity == null) { + showPlayerButtons(); + } else if (PixelmonHelper.isPixelmon(entity)) { + showPixelmonMenu(entity); + } else { + showEntityButtons(entity); + } + } - private void showPlayerButtons() { - int y = guiTop ; + private void showPlayerButtons() { + int y = guiTop; - addButton(new GuiNpcButton(9, guiLeft + 4, y += 22, 96, 20, "model.rotate")); + addButton(new GuiNpcButton(9, guiLeft + 4, y += 22, 96, 20, "model.rotate")); - addButton(new GuiNpcButton(8, guiLeft + 4, y += 22, 96, 20, "model.scale")); + addButton(new GuiNpcButton(8, guiLeft + 4, y += 22, 96, 20, "model.scale")); - addButton(new GuiNpcButton(4, guiLeft + 50, y += 22, 50, 20, "selectServer.edit")); - addLabel(new GuiNpcLabel(1, "Head", guiLeft, y + 5, 0xFFFFFF)); + addButton(new GuiNpcButton(4, guiLeft + 50, y += 22, 50, 20, "selectServer.edit")); + addLabel(new GuiNpcLabel(1, "Head", guiLeft, y + 5, 0xFFFFFF)); - addButton(new GuiNpcButton(5, guiLeft + 50, y += 22, 50, 20, "selectServer.edit")); - addLabel(new GuiNpcLabel(2, "Body", guiLeft, y + 5, 0xFFFFFF)); + addButton(new GuiNpcButton(5, guiLeft + 50, y += 22, 50, 20, "selectServer.edit")); + addLabel(new GuiNpcLabel(2, "Body", guiLeft, y + 5, 0xFFFFFF)); - addButton(new GuiNpcButton(6, guiLeft + 50, y += 22, 50, 20, "selectServer.edit")); - addLabel(new GuiNpcLabel(3, "Arms", guiLeft, y + 5, 0xFFFFFF)); + addButton(new GuiNpcButton(6, guiLeft + 50, y += 22, 50, 20, "selectServer.edit")); + addLabel(new GuiNpcLabel(3, "Arms", guiLeft, y + 5, 0xFFFFFF)); - addButton(new GuiNpcButton(7, guiLeft + 50, y += 22, 50, 20, "selectServer.edit")); - addLabel(new GuiNpcLabel(4, "Legs", guiLeft, y + 5, 0xFFFFFF)); + addButton(new GuiNpcButton(7, guiLeft + 50, y += 22, 50, 20, "selectServer.edit")); + addLabel(new GuiNpcLabel(4, "Legs", guiLeft, y + 5, 0xFFFFFF)); - addButton(new GuiNpcButton(250, guiLeft + 50, y += 22, 50, 20, new String[]{"Default","Steve64","Alex"}, this.npc.display.modelType)); - addLabel(new GuiNpcLabel(250, "Model", guiLeft, y + 5, 0xFFFFFF)); + addButton(new GuiNpcButton(250, guiLeft + 50, y += 22, 50, 20, new String[]{"Default", "Steve64", "Alex"}, this.npc.display.modelType)); + addLabel(new GuiNpcLabel(250, "Model", guiLeft, y + 5, 0xFFFFFF)); - addButton(new GuiNpcButton(44, guiLeft + 310, guiTop + 14, 80, 20, "Save Model")); - addButton(new GuiNpcButton(45, guiLeft + 310, guiTop + 36, 80, 20, "Load Model")); - } + addButton(new GuiNpcButton(44, guiLeft + 310, guiTop + 14, 80, 20, "Save Model")); + addButton(new GuiNpcButton(45, guiLeft + 310, guiTop + 36, 80, 20, "Load Model")); + } - private void showPixelmonMenu(EntityLivingBase entity) { - GuiCustomScroll scroll = new GuiCustomScroll(this, 0); - scroll.setSize(120, 200); - scroll.guiLeft = guiLeft; - scroll.guiTop = guiTop + 20; - addScroll(scroll); + private void showPixelmonMenu(EntityLivingBase entity) { + GuiCustomScroll scroll = new GuiCustomScroll(this, 0); + scroll.setSize(120, 200); + scroll.guiLeft = guiLeft; + scroll.guiTop = guiTop + 20; + addScroll(scroll); - scroll.setList(PixelmonHelper.getPixelmonList()); - scroll.setSelected(PixelmonHelper.getName(entity)); + scroll.setList(PixelmonHelper.getPixelmonList()); + scroll.setSelected(PixelmonHelper.getName(entity)); - Minecraft.getMinecraft().thePlayer.sendChatMessage(PixelmonHelper.getName(entity)); - } + Minecraft.getMinecraft().thePlayer.sendChatMessage(PixelmonHelper.getName(entity)); + } - private void showEntityButtons(EntityLivingBase entity) { - mapped.clear(); - if(entity instanceof EntityNPCInterface) - return; - int y = guiTop + 20; + private void showEntityButtons(EntityLivingBase entity) { + mapped.clear(); + if (entity instanceof EntityNPCInterface) + return; + int y = guiTop + 20; - NBTTagCompound compound = getExtras(entity); - Set keys = compound.func_150296_c(); - int i = 0; - for(String name : keys){ - if(isIgnored(name)) - continue; - NBTBase base = compound.getTag(name); - if(name.equals("Age")){ - i++; - addLabel(new GuiNpcLabel(0, "Child", guiLeft, y + 5 + i * 22, 0xFFFFFF)); - addButton(new GuiNpcButton(30, guiLeft + 80, y + i * 22, 50, 20, new String[]{"gui.no","gui.yes"},entity.isChild()?1:0)); - } - else if(base.getId() == 1){ - byte b = ((NBTTagByte)base).func_150290_f(); - if(b != 0 && b != 1) - continue; - if(playerdata.extra.hasKey(name)) - b = playerdata.extra.getByte(name); - i++; - addLabel(new GuiNpcLabel(100 + i, name, guiLeft, y + 5 + i * 22, 0xFFFFFF)); - addButton(new GuiNpcButton(100 + i, guiLeft + 80, y + i * 22, 50, 20, new String[]{"gui.no","gui.yes"}, b)); + NBTTagCompound compound = getExtras(entity); + Set keys = compound.func_150296_c(); + int i = 0; + for (String name : keys) { + if (isIgnored(name)) + continue; + NBTBase base = compound.getTag(name); + if (name.equals("Age")) { + i++; + addLabel(new GuiNpcLabel(0, "Child", guiLeft, y + 5 + i * 22, 0xFFFFFF)); + addButton(new GuiNpcButton(30, guiLeft + 80, y + i * 22, 50, 20, new String[]{"gui.no", "gui.yes"}, entity.isChild() ? 1 : 0)); + } else if (base.getId() == 1) { + byte b = ((NBTTagByte) base).func_150290_f(); + if (b != 0 && b != 1) + continue; + if (playerdata.extra.hasKey(name)) + b = playerdata.extra.getByte(name); + i++; + addLabel(new GuiNpcLabel(100 + i, name, guiLeft, y + 5 + i * 22, 0xFFFFFF)); + addButton(new GuiNpcButton(100 + i, guiLeft + 80, y + i * 22, 50, 20, new String[]{"gui.no", "gui.yes"}, b)); - mapped.put(i, name); - } - } - if(EntityList.getEntityString(entity).equals("doggystyle.Dog")){ - int breed = 0; - try { - Method method = entity.getClass().getMethod("getBreedID"); - breed = (Integer) method.invoke(entity); - } catch (Exception e) { + mapped.put(i, name); + } + } + if (EntityList.getEntityString(entity).equals("doggystyle.Dog")) { + int breed = 0; + try { + Method method = entity.getClass().getMethod("getBreedID"); + breed = (Integer) method.invoke(entity); + } catch (Exception e) { - } - i++; - addLabel(new GuiNpcLabel(201, "Breed", guiLeft, y + 5 + i * 22, 0xFFFFFF)); - addButton(new GuiNpcButton(201, guiLeft + 80, y + i * 22, 50, 20, new String[]{"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16"}, breed)); - } + } + i++; + addLabel(new GuiNpcLabel(201, "Breed", guiLeft, y + 5 + i * 22, 0xFFFFFF)); + addButton(new GuiNpcButton(201, guiLeft + 80, y + i * 22, 50, 20, new String[]{"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16"}, breed)); + } - GeckoAddonClient.Instance.showGeckoButtons(this, entity); - } - private boolean isIgnored(String tag){ - for(String s : ignoredTags) - if(s.equals(tag)) - return true; - return false; - } + GeckoAddonClient.Instance.showGeckoButtons(this, entity); + } - private NBTTagCompound getExtras(EntityLivingBase entity) { - NBTTagCompound fake = new NBTTagCompound(); - new EntityFakeLiving(entity.worldObj).writeEntityToNBT(fake); + private boolean isIgnored(String tag) { + for (String s : ignoredTags) + if (s.equals(tag)) + return true; + return false; + } - NBTTagCompound compound = new NBTTagCompound(); - try{ - entity.writeEntityToNBT(compound); - } - catch(Exception e){ + private NBTTagCompound getExtras(EntityLivingBase entity) { + NBTTagCompound fake = new NBTTagCompound(); + new EntityFakeLiving(entity.worldObj).writeEntityToNBT(fake); - } - Set keys = fake.func_150296_c(); - for(String name : keys) - compound.removeTag(name); + NBTTagCompound compound = new NBTTagCompound(); + try { + entity.writeEntityToNBT(compound); + } catch (Exception e) { - return compound; - } + } + Set keys = fake.func_150296_c(); + for (String name : keys) + compound.removeTag(name); - private int getCurrentEntityIndex(){ - return list.indexOf(EntityList.classToStringMapping.get(playerdata.getEntityClass())); - } + return compound; + } - @Override - protected void actionPerformed(GuiButton btn) { - super.actionPerformed(btn); - GuiNpcButton button = (GuiNpcButton) btn; - if(button.id == 0){ - int index = getCurrentEntityIndex(); - if(!prev.enabled) - return; - index--; - try{ - if(index < 0){ - playerdata.setEntityClass(null); - npc.display.texture = "customnpcs:textures/entity/humanmale/Steve.png"; - } - else{ - playerdata.setEntityClass(data.get(list.get(index))); + private int getCurrentEntityIndex() { + return list.indexOf(EntityList.classToStringMapping.get(playerdata.getEntityClass())); + } - EntityLivingBase entity = playerdata.getEntity(npc); - if(entity != null){ - RendererLivingEntity render = (RendererLivingEntity) RenderManager.instance.getEntityRenderObject(entity); - npc.display.texture = NPCRendererHelper.getTexture(render,entity); - } - } - //npc.display.glowTexture = ""; - npc.display.skinOverlayData.overlayList.remove(0); - npc.textureLocation = null; - npc.updateHitbox(); - } - catch(Exception ex){ - npc.display.texture = "customnpcs:textures/entity/humanmale/Steve.png"; - } - initGui(); - } - if(button.id == 2){ - int index = getCurrentEntityIndex(); - if(!next.enabled) - return; - index++; - playerdata.setEntityClass(data.get(list.get(index))); + @Override + protected void actionPerformed(GuiButton btn) { + super.actionPerformed(btn); + GuiNpcButton button = (GuiNpcButton) btn; + if (button.id == 0) { + int index = getCurrentEntityIndex(); + if (!prev.enabled) + return; + index--; + try { + if (index < 0) { + playerdata.setEntityClass(null); + npc.display.texture = "customnpcs:textures/entity/humanmale/Steve.png"; + } else { + playerdata.setEntityClass(data.get(list.get(index))); - updateTexture(); + EntityLivingBase entity = playerdata.getEntity(npc); + if (entity != null) { + RendererLivingEntity render = (RendererLivingEntity) RenderManager.instance.getEntityRenderObject(entity); + npc.display.texture = NPCRendererHelper.getTexture(render, entity); + } + } + //npc.display.glowTexture = ""; + npc.display.skinOverlayData.overlayList.remove(0); + npc.textureLocation = null; + npc.updateHitbox(); + } catch (Exception ex) { + npc.display.texture = "customnpcs:textures/entity/humanmale/Steve.png"; + } + initGui(); + } + if (button.id == 2) { + int index = getCurrentEntityIndex(); + if (!next.enabled) + return; + index++; + playerdata.setEntityClass(data.get(list.get(index))); - initGui(); - } + updateTexture(); - if(button.id == 1){ - this.mc.displayGuiScreen(new GuiEntitySelection(this, playerdata, npc)); - } + initGui(); + } - if(button.id == 4){ - this.mc.displayGuiScreen(new GuiModelHead(this, npc)); - } - if(button.id == 5){ - this.mc.displayGuiScreen(new GuiModelBody(this, npc)); - } - if(button.id == 6){ - this.mc.displayGuiScreen(new GuiModelArms(this, npc)); - } - if(button.id == 7){ - this.mc.displayGuiScreen(new GuiModelLegs(this, npc)); - } + if (button.id == 1) { + this.mc.displayGuiScreen(new GuiEntitySelection(this, playerdata, npc)); + } - // New Button for Changing Models - // URL Swapper - if(button.id == 250){ - if(npc.display.modelType == 0){ - if (npc.display.skinType == 2){ - npc.display.skinType = 3; - } - npc.display.modelType = 1; - } - else if(npc.display.modelType == 1){ - npc.display.modelType = 2; - } - else { - if (npc.display.skinType == 3){ - npc.display.skinType = 2; - } - npc.display.modelType = 0; - } - npc.textureLocation = null; - } + if (button.id == 4) { + this.mc.displayGuiScreen(new GuiModelHead(this, npc)); + } + if (button.id == 5) { + this.mc.displayGuiScreen(new GuiModelBody(this, npc)); + } + if (button.id == 6) { + this.mc.displayGuiScreen(new GuiModelArms(this, npc)); + } + if (button.id == 7) { + this.mc.displayGuiScreen(new GuiModelLegs(this, npc)); + } - if(button.id == 8){ - this.mc.displayGuiScreen(new GuiModelScale(this, playerdata, npc)); - } - if(button.id == 9){ - this.mc.displayGuiScreen(new GuiModelRotate(this, playerdata, npc)); - } - if(button.id == 30){ - playerdata.extra.setInteger("Age",button.getValue() == 1?-24000:0); - playerdata.clearEntity(); - } + // New Button for Changing Models + // URL Swapper + if (button.id == 250) { + if (npc.display.modelType == 0) { + if (npc.display.skinType == 2) { + npc.display.skinType = 3; + } + npc.display.modelType = 1; + } else if (npc.display.modelType == 1) { + npc.display.modelType = 2; + } else { + if (npc.display.skinType == 3) { + npc.display.skinType = 2; + } + npc.display.modelType = 0; + } + npc.textureLocation = null; + } - if(button.id == 44){ - this.mc.displayGuiScreen(new GuiPresetSave(this, playerdata)); - } + if (button.id == 8) { + this.mc.displayGuiScreen(new GuiModelScale(this, playerdata, npc)); + } + if (button.id == 9) { + this.mc.displayGuiScreen(new GuiModelRotate(this, playerdata, npc)); + } + if (button.id == 30) { + playerdata.extra.setInteger("Age", button.getValue() == 1 ? -24000 : 0); + playerdata.clearEntity(); + } - if(button.id == 45){ - this.mc.displayGuiScreen(new GuiPresetSelection(this, playerdata)); - } - if(button.id >= 100 && button.id < 200){ - String name = mapped.get(button.id - 100); - if(name != null){ - playerdata.extra.setBoolean(name, button.getValue() == 1); - playerdata.clearEntity(); - } - } - if(button.id == 201){ - try { - EntityLivingBase entity = playerdata.getEntity(npc); - Method method = entity.getClass().getMethod("setBreedID", int.class); - method.invoke(entity, ((GuiNpcButton)button).getValue()); - NBTTagCompound comp = new NBTTagCompound(); - entity.writeEntityToNBT(comp); - playerdata.extra.setString("EntityData21", comp.getString("EntityData21")); - playerdata.clearEntity(); - updateTexture(); - } catch (Exception ignored) {} - } + if (button.id == 44) { + this.mc.displayGuiScreen(new GuiPresetSave(this, playerdata)); + } - GeckoAddonClient.Instance.geckoGuiCreationScreenActionPerformed(this, button); - } + if (button.id == 45) { + this.mc.displayGuiScreen(new GuiPresetSelection(this, playerdata)); + } + if (button.id >= 100 && button.id < 200) { + String name = mapped.get(button.id - 100); + if (name != null) { + playerdata.extra.setBoolean(name, button.getValue() == 1); + playerdata.clearEntity(); + } + } + if (button.id == 201) { + try { + EntityLivingBase entity = playerdata.getEntity(npc); + Method method = entity.getClass().getMethod("setBreedID", int.class); + method.invoke(entity, ((GuiNpcButton) button).getValue()); + NBTTagCompound comp = new NBTTagCompound(); + entity.writeEntityToNBT(comp); + playerdata.extra.setString("EntityData21", comp.getString("EntityData21")); + playerdata.clearEntity(); + updateTexture(); + } catch (Exception ignored) { + } + } - private void updateTexture(){ - try{ - EntityLivingBase entity = playerdata.getEntity(npc); - if (entity != null && entity.equals(npc.modelData.entity)) { - return; - } + GeckoAddonClient.Instance.geckoGuiCreationScreenActionPerformed(this, button); + } - if (entity instanceof EntityNpcDragon) { - npc.display.texture = "customnpcs:textures/entity/dragon/BlackDragon.png"; - } else if (entity instanceof EntityNpcSlime) { - npc.display.texture = "customnpcs:textures/entity/slime/Slime.png"; - } else if (entity instanceof EntityNPCGolem) { - npc.display.texture = "customnpcs:textures/entity/golem/Iron Golem.png"; - } else if (entity instanceof EntityNpcPony) { - npc.display.texture = "customnpcs:textures/entity/ponies/MineLP Derpy Hooves.png"; - } else if (entity instanceof EntityNpcCrystal) { - npc.display.texture = "customnpcs:textures/entity/crystal/EnderCrystal.png"; - } else if (entity != null) { - RendererLivingEntity render = (RendererLivingEntity) RenderManager.instance.getEntityRenderObject(entity); - npc.display.texture = NPCRendererHelper.getTexture(render,entity); - } else { - npc.display.texture = "customnpcs:textures/entity/humanmale/Steve.png"; - } + private void updateTexture() { + try { + EntityLivingBase entity = playerdata.getEntity(npc); + if (entity != null && entity.equals(npc.modelData.entity)) { + return; + } - npc.display.skinOverlayData.overlayList.remove(0); - npc.textureLocation = null; - npc.updateHitbox(); - } catch(Exception ex) { - npc.display.texture = "customnpcs:textures/entity/humanmale/Steve.png"; - } - } + if (entity instanceof EntityNpcDragon) { + npc.display.texture = "customnpcs:textures/entity/dragon/BlackDragon.png"; + } else if (entity instanceof EntityNpcSlime) { + npc.display.texture = "customnpcs:textures/entity/slime/Slime.png"; + } else if (entity instanceof EntityNPCGolem) { + npc.display.texture = "customnpcs:textures/entity/golem/Iron Golem.png"; + } else if (entity instanceof EntityNpcPony) { + npc.display.texture = "customnpcs:textures/entity/ponies/MineLP Derpy Hooves.png"; + } else if (entity instanceof EntityNpcCrystal) { + npc.display.texture = "customnpcs:textures/entity/crystal/EnderCrystal.png"; + } else if (entity != null) { + RendererLivingEntity render = (RendererLivingEntity) RenderManager.instance.getEntityRenderObject(entity); + npc.display.texture = NPCRendererHelper.getTexture(render, entity); + } else { + npc.display.texture = "customnpcs:textures/entity/humanmale/Steve.png"; + } - @Override - public void close(){ + npc.display.skinOverlayData.overlayList.remove(0); + npc.textureLocation = null; + npc.updateHitbox(); + } catch (Exception ex) { + npc.display.texture = "customnpcs:textures/entity/humanmale/Steve.png"; + } + } + + @Override + public void close() { PacketClient.sendClient(new ModelDataSavePacket(playerdata.writeToNBT())); - displayGuiScreen(parent); - } + displayGuiScreen(parent); + } - @Override - public void customScrollClicked(int i, int j, int k, GuiCustomScroll scroll) { - playerdata.clearEntity(); - playerdata.extra.setString("Name", scroll.getSelected()); + @Override + public void customScrollClicked(int i, int j, int k, GuiCustomScroll scroll) { + playerdata.clearEntity(); + playerdata.extra.setString("Name", scroll.getSelected()); - updateTexture(); - } + updateTexture(); + } } diff --git a/src/main/java/noppes/npcs/client/gui/model/GuiEntitySelection.java b/src/main/java/noppes/npcs/client/gui/model/GuiEntitySelection.java index 5ed455569..1689893d3 100644 --- a/src/main/java/noppes/npcs/client/gui/model/GuiEntitySelection.java +++ b/src/main/java/noppes/npcs/client/gui/model/GuiEntitySelection.java @@ -19,61 +19,56 @@ import org.lwjgl.opengl.GL11; import java.util.Collections; import java.util.Vector; -public class GuiEntitySelection extends GuiNPCInterface -{ - private GuiNPCStringSlot slot; - private GuiCreationScreen parent; - private Class prevModel; - private ModelData playerdata; - private EntityCustomNpc npc; +public class GuiEntitySelection extends GuiNPCInterface { + private GuiNPCStringSlot slot; + private GuiCreationScreen parent; + private Class prevModel; + private ModelData playerdata; + private EntityCustomNpc npc; - public GuiEntitySelection(GuiCreationScreen parent, ModelData playerdata, EntityCustomNpc npc) - { - this.parent = parent; - this.playerdata = playerdata; - this.npc = npc; - drawDefaultBackground = false; - prevModel = playerdata.getEntityClass(); + public GuiEntitySelection(GuiCreationScreen parent, ModelData playerdata, EntityCustomNpc npc) { + this.parent = parent; + this.playerdata = playerdata; + this.npc = npc; + drawDefaultBackground = false; + prevModel = playerdata.getEntityClass(); } @Override - public void initGui() - { + public void initGui() { super.initGui(); Vector list = new Vector(parent.data.keySet()); list.add("CustomNPC"); - Collections.sort(list,String.CASE_INSENSITIVE_ORDER); - slot = new GuiNPCStringSlot(list,this,false,18); - if(playerdata.getEntityClass() != null){ + Collections.sort(list, String.CASE_INSENSITIVE_ORDER); + slot = new GuiNPCStringSlot(list, this, false, 18); + if (playerdata.getEntityClass() != null) { slot.selected = (String) EntityList.classToStringMapping.get(playerdata.getEntityClass()); - } - else{ - slot.selected = "CustomNPC"; + } else { + slot.selected = "CustomNPC"; } slot.registerScrollButtons(4, 5); - this.buttonList.add(new GuiNpcButton(2, width / 2 - 100, height - 44,98, 20, "gui.back")); + this.buttonList.add(new GuiNpcButton(2, width / 2 - 100, height - 44, 98, 20, "gui.back")); } @Override - public void drawScreen(int i, int j, float f) - { - EntityLivingBase entity = playerdata.getEntity(npc); - if(entity == null) - entity = this.npc; - else - EntityUtil.Copy(npc, entity); + public void drawScreen(int i, int j, float f) { + EntityLivingBase entity = playerdata.getEntity(npc); + if (entity == null) + entity = this.npc; + else + EntityUtil.Copy(npc, entity); - int l = (width/2)-180; - int i1 = (height/2) - 90; + int l = (width / 2) - 180; + int i1 = (height / 2) - 90; GL11.glEnable(32826 /*GL_RESCALE_NORMAL_EXT*/); GL11.glEnable(2903 /*GL_COLOR_MATERIAL*/); GL11.glPushMatrix(); GL11.glTranslatef(l + 33, i1 + 131, 50F); float scale = 1; - if(entity.height > 2.4) - scale = 2 / entity.height; + if (entity.height > 2.4) + scale = 2 / entity.height; GL11.glScalef(-50 * scale, 50 * scale, 50 * scale); GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); @@ -81,23 +76,22 @@ public class GuiEntitySelection extends GuiNPCInterface float f3 = entity.rotationYaw; float f4 = entity.rotationPitch; float f7 = entity.rotationYawHead; - float f5 = (float)(l + 33) - i; - float f6 = (float)((i1 + 131) - 50) - j; + float f5 = (float) (l + 33) - i; + float f6 = (float) ((i1 + 131) - 50) - j; GL11.glRotatef(135F, 0.0F, 1.0F, 0.0F); RenderHelper.enableStandardItemLighting(); GL11.glRotatef(-135F, 0.0F, 1.0F, 0.0F); - GL11.glRotatef(-(float)Math.atan(f6 / 40F) * 20F, 1.0F, 0.0F, 0.0F); - entity.renderYawOffset = (float)Math.atan(f5 / 40F) * 20F; - entity.rotationYaw = (float)Math.atan(f5 / 40F) * 40F; - entity.rotationPitch = -(float)Math.atan(f6 / 40F) * 20F; + GL11.glRotatef(-(float) Math.atan(f6 / 40F) * 20F, 1.0F, 0.0F, 0.0F); + entity.renderYawOffset = (float) Math.atan(f5 / 40F) * 20F; + entity.rotationYaw = (float) Math.atan(f5 / 40F) * 40F; + entity.rotationPitch = -(float) Math.atan(f6 / 40F) * 20F; entity.rotationYawHead = entity.rotationYaw; GL11.glTranslatef(0.0F, entity.yOffset, 0.0F); - RenderManager.instance.playerViewY = 180F; - try{ + RenderManager.instance.playerViewY = 180F; + try { RenderManager.instance.renderEntityWithPosYaw(entity, 0.0D, 0.0D, 0.0D, 0.0F, 1.0F); - } - catch(Exception e){ - playerdata.setEntityClass(null); + } catch (Exception e) { + playerdata.setEntityClass(null); } entity.renderYawOffset = f2; entity.rotationYaw = f3; @@ -110,18 +104,19 @@ public class GuiEntitySelection extends GuiNPCInterface OpenGlHelper.setActiveTexture(OpenGlHelper.lightmapTexUnit); GL11.glDisable(GL11.GL_TEXTURE_2D); OpenGlHelper.setActiveTexture(OpenGlHelper.defaultTexUnit); - slot.drawScreen(i, j, f); - super.drawScreen(i, j, f); + slot.drawScreen(i, j, f); + super.drawScreen(i, j, f); } - public void elementClicked(){ + + public void elementClicked() { if (playerdata.getEntityClass() != null && playerdata.getEntityClass().equals(parent.data.get(slot.selected))) { return; } - try{ - playerdata.setEntityClass(parent.data.get(slot.selected)); - EntityLivingBase entity = playerdata.getEntity(npc); - if(entity != null){ + try { + playerdata.setEntityClass(parent.data.get(slot.selected)); + EntityLivingBase entity = playerdata.getEntity(npc); + if (entity != null) { npc.display.modelType = 0; if (entity instanceof EntityNpcCrystal) { npc.display.texture = "customnpcs:textures/entity/crystal/EnderCrystal.png"; @@ -137,44 +132,42 @@ public class GuiEntitySelection extends GuiNPCInterface RendererLivingEntity render = (RendererLivingEntity) RenderManager.instance.getEntityRenderObject(entity); npc.display.texture = NPCRendererHelper.getTexture(render, entity); } - } - else{ - npc.display.texture = "customnpcs:textures/entity/humanmale/Steve.png"; - } - //npc.display.glowTexture = ""; + } else { + npc.display.texture = "customnpcs:textures/entity/humanmale/Steve.png"; + } + //npc.display.glowTexture = ""; npc.display.skinOverlayData.overlayList.remove(0); - npc.textureLocation = null; - npc.updateHitbox(); - } catch(Exception ex) { - npc.display.texture = "customnpcs:textures/entity/humanmale/Steve.png"; - } + npc.textureLocation = null; + npc.updateHitbox(); + } catch (Exception ex) { + npc.display.texture = "customnpcs:textures/entity/humanmale/Steve.png"; + } } - public void doubleClicked(){ + + public void doubleClicked() { close(); } - public void keyTyped(char par1, int par2) - { - if (par2 == 1) - { + public void keyTyped(char par1, int par2) { + if (par2 == 1) { close(); } } + public void close() { - this.mc.displayGuiScreen(parent); - } - - - protected void actionPerformed(GuiButton guibutton) - { - close(); + this.mc.displayGuiScreen(parent); } - @Override - public void save() { + + protected void actionPerformed(GuiButton guibutton) { + close(); + } + + @Override + public void save() { - } + } } diff --git a/src/main/java/noppes/npcs/client/gui/model/GuiModelArms.java b/src/main/java/noppes/npcs/client/gui/model/GuiModelArms.java index 0eaca358b..7c9d27487 100644 --- a/src/main/java/noppes/npcs/client/gui/model/GuiModelArms.java +++ b/src/main/java/noppes/npcs/client/gui/model/GuiModelArms.java @@ -8,74 +8,75 @@ import noppes.npcs.client.gui.util.GuiNpcLabel; import noppes.npcs.entity.EntityCustomNpc; import noppes.npcs.entity.data.ModelPartData; -public class GuiModelArms extends GuiModelInterface{ +public class GuiModelArms extends GuiModelInterface { - private final String[] arrArm = new String[]{"gui.no","Both","Right","Left"}; - private final String[] arrArmwear = new String[]{"gui.no","Both","Left","Right"}; - private final String[] arrSolidArmwear = new String[]{"gui.no","Both","Left","Right"}; - private final String[] arrClaws = new String[]{"gui.no","Both","Left","Right"}; + private final String[] arrArm = new String[]{"gui.no", "Both", "Right", "Left"}; + private final String[] arrArmwear = new String[]{"gui.no", "Both", "Left", "Right"}; + private final String[] arrSolidArmwear = new String[]{"gui.no", "Both", "Left", "Right"}; + private final String[] arrClaws = new String[]{"gui.no", "Both", "Left", "Right"}; - private GuiScreen parent; - public GuiModelArms(GuiScreen parent, EntityCustomNpc npc){ - super(npc); - this.parent = parent; - this.xOffset = 60; - } + private GuiScreen parent; + + public GuiModelArms(GuiScreen parent, EntityCustomNpc npc) { + super(npc); + this.parent = parent; + this.xOffset = 60; + } @Override public void initGui() { - super.initGui(); - int y = guiTop + 20; + super.initGui(); + int y = guiTop + 20; - addButton(new GuiNpcButton(30, guiLeft + 50, y += 22, 70, 20, arrArm, playerdata.hideArms)); - addLabel(new GuiNpcLabel(30, "Hide", guiLeft, y + 5, 0xFFFFFF)); + addButton(new GuiNpcButton(30, guiLeft + 50, y += 22, 70, 20, arrArm, playerdata.hideArms)); + addLabel(new GuiNpcLabel(30, "Hide", guiLeft, y + 5, 0xFFFFFF)); - if (npc.display.modelType == 1 || npc.display.modelType == 2) { - addButton(new GuiNpcButton(8, guiLeft + 50, y += 22, 70, 20, arrArmwear, playerdata.armwear)); - addLabel(new GuiNpcLabel(8, "Armwear", guiLeft, y + 5, 0xFFFFFF)); + if (npc.display.modelType == 1 || npc.display.modelType == 2) { + addButton(new GuiNpcButton(8, guiLeft + 50, y += 22, 70, 20, arrArmwear, playerdata.armwear)); + addLabel(new GuiNpcLabel(8, "Armwear", guiLeft, y + 5, 0xFFFFFF)); - addButton(new GuiNpcButton(9, guiLeft + 50, y += 22, 70, 20, arrSolidArmwear, playerdata.solidArmwear)); - addLabel(new GuiNpcLabel(9, "Solid", guiLeft, y + 5, 0xFFFFFF)); - } + addButton(new GuiNpcButton(9, guiLeft + 50, y += 22, 70, 20, arrSolidArmwear, playerdata.solidArmwear)); + addLabel(new GuiNpcLabel(9, "Solid", guiLeft, y + 5, 0xFFFFFF)); + } - ModelPartData claws = playerdata.getPartData("claws"); - addButton(new GuiNpcButton(0, guiLeft + 50, y += 22, 70, 20, arrClaws, claws == null?0:claws.type + 1)); - addLabel(new GuiNpcLabel(0, "Claws", guiLeft, y + 5, 0xFFFFFF)); - if(claws != null) - addButton(new GuiNpcButton(10, guiLeft + 122, y, 40, 20, claws.getColor())); + ModelPartData claws = playerdata.getPartData("claws"); + addButton(new GuiNpcButton(0, guiLeft + 50, y += 22, 70, 20, arrClaws, claws == null ? 0 : claws.type + 1)); + addLabel(new GuiNpcLabel(0, "Claws", guiLeft, y + 5, 0xFFFFFF)); + if (claws != null) + addButton(new GuiNpcButton(10, guiLeft + 122, y, 40, 20, claws.getColor())); } @Override protected void actionPerformed(GuiButton btn) { - super.actionPerformed(btn); - GuiNpcButton button = (GuiNpcButton) btn; + super.actionPerformed(btn); + GuiNpcButton button = (GuiNpcButton) btn; - if(button.id == 8){ - playerdata.armwear = (byte) button.getValue(); - } - if(button.id == 9){ - playerdata.solidArmwear = (byte) button.getValue(); - } - if(button.id == 30){ - playerdata.hideArms = (byte) button.getValue(); - } - if(button.id == 0){ - if(button.getValue() == 0) - playerdata.removePart("claws"); - else{ - ModelPartData data = playerdata.getOrCreatePart("claws"); - data.type = (byte) (button.getValue() - 1); - } - initGui(); - } - if(button.id == 10){ - this.mc.displayGuiScreen(new GuiModelColor(this, playerdata.getPartData("claws"), npc)); - } + if (button.id == 8) { + playerdata.armwear = (byte) button.getValue(); + } + if (button.id == 9) { + playerdata.solidArmwear = (byte) button.getValue(); + } + if (button.id == 30) { + playerdata.hideArms = (byte) button.getValue(); + } + if (button.id == 0) { + if (button.getValue() == 0) + playerdata.removePart("claws"); + else { + ModelPartData data = playerdata.getOrCreatePart("claws"); + data.type = (byte) (button.getValue() - 1); + } + initGui(); + } + if (button.id == 10) { + this.mc.displayGuiScreen(new GuiModelColor(this, playerdata.getPartData("claws"), npc)); + } } @Override - public void close(){ + public void close() { this.mc.displayGuiScreen(parent); } } diff --git a/src/main/java/noppes/npcs/client/gui/model/GuiModelBody.java b/src/main/java/noppes/npcs/client/gui/model/GuiModelBody.java index 73ed212f5..6ba3adc2f 100644 --- a/src/main/java/noppes/npcs/client/gui/model/GuiModelBody.java +++ b/src/main/java/noppes/npcs/client/gui/model/GuiModelBody.java @@ -8,247 +8,247 @@ import noppes.npcs.client.gui.util.GuiNpcLabel; import noppes.npcs.entity.EntityCustomNpc; import noppes.npcs.entity.data.ModelPartData; -public class GuiModelBody extends GuiModelInterface{ +public class GuiModelBody extends GuiModelInterface { - private GuiScreen parent; - private final String[] arrBody = new String[]{"gui.no","gui.yes"}; - private final String[] arrBodywear = new String[]{"gui.no","gui.yes","Solid"}; - private final String[] arrWing = new String[]{"gui.no","Player","Type1","Type2","Type3","Type4","Type5","Type6","Type7","Type8","Type9", - "Type10","Type11","Type12","Type13","Type14","Type15"}; - private final String[] arrBreasts = new String[]{"gui.no","Type1","Type2","Type3"}; - private final String[] arrParticles = new String[]{"gui.no","Player","Type1", "Type2", "Rainbow", "Type3", "Type4", "Type5", "Type6", "Type7"}; - private final String[] arrfins = new String[]{"gui.no","Player","Type1","Type2","Type3","Type4","Type5","Type6"}; - private final String[] arrskirt = new String[]{"gui.no","Player","Type1"}; + private GuiScreen parent; + private final String[] arrBody = new String[]{"gui.no", "gui.yes"}; + private final String[] arrBodywear = new String[]{"gui.no", "gui.yes", "Solid"}; + private final String[] arrWing = new String[]{"gui.no", "Player", "Type1", "Type2", "Type3", "Type4", "Type5", "Type6", "Type7", "Type8", "Type9", + "Type10", "Type11", "Type12", "Type13", "Type14", "Type15"}; + private final String[] arrBreasts = new String[]{"gui.no", "Type1", "Type2", "Type3"}; + private final String[] arrParticles = new String[]{"gui.no", "Player", "Type1", "Type2", "Rainbow", "Type3", "Type4", "Type5", "Type6", "Type7"}; + private final String[] arrfins = new String[]{"gui.no", "Player", "Type1", "Type2", "Type3", "Type4", "Type5", "Type6"}; + private final String[] arrskirt = new String[]{"gui.no", "Player", "Type1"}; - public GuiModelBody(GuiScreen parent, EntityCustomNpc npc){ - super(npc); - this.parent = parent; - this.xOffset = 60; - } + public GuiModelBody(GuiScreen parent, EntityCustomNpc npc) { + super(npc); + this.parent = parent; + this.xOffset = 60; + } @Override public void initGui() { - super.initGui(); + super.initGui(); - int y = guiTop + 20; + int y = guiTop + 20; - addButton(new GuiNpcButton(30, guiLeft + 50, y += 22, 70, 20, arrBody, playerdata.hideBody)); - addLabel(new GuiNpcLabel(30, "Hide", guiLeft, y + 5, 0xFFFFFF)); + addButton(new GuiNpcButton(30, guiLeft + 50, y += 22, 70, 20, arrBody, playerdata.hideBody)); + addLabel(new GuiNpcLabel(30, "Hide", guiLeft, y + 5, 0xFFFFFF)); - if (npc.display.modelType == 1 || npc.display.modelType == 2) { - addButton(new GuiNpcButton(8, guiLeft + 50, y += 22, 70, 20, arrBodywear, playerdata.bodywear)); - addLabel(new GuiNpcLabel(8, "Bodywear", guiLeft, y + 5, 0xFFFFFF)); - } + if (npc.display.modelType == 1 || npc.display.modelType == 2) { + addButton(new GuiNpcButton(8, guiLeft + 50, y += 22, 70, 20, arrBodywear, playerdata.bodywear)); + addLabel(new GuiNpcLabel(8, "Bodywear", guiLeft, y + 5, 0xFFFFFF)); + } - addButton(new GuiNpcButton(1, guiLeft + 50, y += 22, 70, 20, arrBreasts, playerdata.breasts)); - addLabel(new GuiNpcLabel(1, "Breasts", guiLeft, y + 5, 0xFFFFFF)); + addButton(new GuiNpcButton(1, guiLeft + 50, y += 22, 70, 20, arrBreasts, playerdata.breasts)); + addLabel(new GuiNpcLabel(1, "Breasts", guiLeft, y + 5, 0xFFFFFF)); - ModelPartData wing = playerdata.getPartData("wings"); - addButton(new GuiNpcButton(0, guiLeft + 50, y += 22, 70, 20, arrWing, wing == null?0:wing.type + 1)); - addLabel(new GuiNpcLabel(0, "Wings", guiLeft, y + 5, 0xFFFFFF)); - if(wing != null) - addButton(new GuiNpcButton(11, guiLeft + 122, y, 40, 20, wing.getColor())); + ModelPartData wing = playerdata.getPartData("wings"); + addButton(new GuiNpcButton(0, guiLeft + 50, y += 22, 70, 20, arrWing, wing == null ? 0 : wing.type + 1)); + addLabel(new GuiNpcLabel(0, "Wings", guiLeft, y + 5, 0xFFFFFF)); + if (wing != null) + addButton(new GuiNpcButton(11, guiLeft + 122, y, 40, 20, wing.getColor())); - ModelPartData particles = playerdata.getPartData("particles"); - addButton(new GuiNpcButton(2, guiLeft + 50, y += 22, 70, 20, arrParticles, getParticleIndex(particles))); - addLabel(new GuiNpcLabel(2, "Particles", guiLeft, y + 5, 0xFFFFFF)); - if(particles != null && particles.type != 1) - addButton(new GuiNpcButton(12, guiLeft + 122, y, 40, 20, particles.getColor())); + ModelPartData particles = playerdata.getPartData("particles"); + addButton(new GuiNpcButton(2, guiLeft + 50, y += 22, 70, 20, arrParticles, getParticleIndex(particles))); + addLabel(new GuiNpcLabel(2, "Particles", guiLeft, y + 5, 0xFFFFFF)); + if (particles != null && particles.type != 1) + addButton(new GuiNpcButton(12, guiLeft + 122, y, 40, 20, particles.getColor())); - ModelPartData fin = playerdata.getPartData("fin"); - addButton(new GuiNpcButton(3, guiLeft + 50, y += 22, 70, 20, arrfins, getFinIndex(fin))); - addLabel(new GuiNpcLabel(3, "Fin", guiLeft, y + 5, 0xFFFFFF)); - if(fin != null) - addButton(new GuiNpcButton(13, guiLeft + 122, y, 40, 20, fin.getColor())); + ModelPartData fin = playerdata.getPartData("fin"); + addButton(new GuiNpcButton(3, guiLeft + 50, y += 22, 70, 20, arrfins, getFinIndex(fin))); + addLabel(new GuiNpcLabel(3, "Fin", guiLeft, y + 5, 0xFFFFFF)); + if (fin != null) + addButton(new GuiNpcButton(13, guiLeft + 122, y, 40, 20, fin.getColor())); - ModelPartData skirt = playerdata.getPartData("skirt"); - addButton(new GuiNpcButton(4, guiLeft + 50, y += 22, 70, 20, arrskirt, getSkirtindex(skirt))); - addLabel(new GuiNpcLabel(4, "Skirt", guiLeft, y + 5, 0xFFFFFF)); - if(skirt != null) - addButton(new GuiNpcButton(14, guiLeft + 122, y, 40, 20, skirt.getColor())); + ModelPartData skirt = playerdata.getPartData("skirt"); + addButton(new GuiNpcButton(4, guiLeft + 50, y += 22, 70, 20, arrskirt, getSkirtindex(skirt))); + addLabel(new GuiNpcLabel(4, "Skirt", guiLeft, y + 5, 0xFFFFFF)); + if (skirt != null) + addButton(new GuiNpcButton(14, guiLeft + 122, y, 40, 20, skirt.getColor())); } private int getFinIndex(ModelPartData fin) { - if(fin == null) + if (fin == null) return 0; - if(fin.type == 0){ - if(fin.playerTexture) - return 1; - if(fin.texture.contains("1")) + if (fin.type == 0) { + if (fin.playerTexture) + return 1; + if (fin.texture.contains("1")) return 2; - if(fin.texture.contains("2")) + if (fin.texture.contains("2")) return 3; - if(fin.texture.contains("3")) + if (fin.texture.contains("3")) return 4; - if(fin.texture.contains("4")) + if (fin.texture.contains("4")) return 5; - if(fin.texture.contains("5")) + if (fin.texture.contains("5")) return 6; - if(fin.texture.contains("6")) + if (fin.texture.contains("6")) return 7; } return 0; - } + } - private int getSkirtindex(ModelPartData skirt) { - if(skirt == null) - return 0; - if(skirt.type == 0){ - if(skirt.playerTexture) - return 1; - if(skirt.texture.contains("1")) - return 2; - if(skirt.texture.contains("2")) - return 3; - if(skirt.texture.contains("3")) - return 4; - if(skirt.texture.contains("4")) - return 5; - if(skirt.texture.contains("5")) - return 6; - if(skirt.texture.contains("6")) - return 7; - } - return 0; - } + private int getSkirtindex(ModelPartData skirt) { + if (skirt == null) + return 0; + if (skirt.type == 0) { + if (skirt.playerTexture) + return 1; + if (skirt.texture.contains("1")) + return 2; + if (skirt.texture.contains("2")) + return 3; + if (skirt.texture.contains("3")) + return 4; + if (skirt.texture.contains("4")) + return 5; + if (skirt.texture.contains("5")) + return 6; + if (skirt.texture.contains("6")) + return 7; + } + return 0; + } - private int getParticleIndex(ModelPartData particles) { - if(particles == null) - return 0; - if(particles.type == 0){ - if(particles.playerTexture) - return 1; - if(particles.texture.contains("1")) - return 2; - if(particles.texture.contains("2")) - return 3; - if(particles.texture.contains("3")) - return 5; - if(particles.texture.contains("4")) - return 6; - if(particles.texture.contains("5")) - return 7; - if(particles.texture.contains("6")) - return 8; - if(particles.texture.contains("7")) - return 9; - } - if(particles.type == 1){ - return 4; - } + private int getParticleIndex(ModelPartData particles) { + if (particles == null) + return 0; + if (particles.type == 0) { + if (particles.playerTexture) + return 1; + if (particles.texture.contains("1")) + return 2; + if (particles.texture.contains("2")) + return 3; + if (particles.texture.contains("3")) + return 5; + if (particles.texture.contains("4")) + return 6; + if (particles.texture.contains("5")) + return 7; + if (particles.texture.contains("6")) + return 8; + if (particles.texture.contains("7")) + return 9; + } + if (particles.type == 1) { + return 4; + } - return 0; - } + return 0; + } - @Override + @Override protected void actionPerformed(GuiButton btn) { - super.actionPerformed(btn); - GuiNpcButton button = (GuiNpcButton) btn; + super.actionPerformed(btn); + GuiNpcButton button = (GuiNpcButton) btn; - if(button.id == 0){ - if(button.getValue() == 0) - playerdata.removePart("wings"); - else{ - ModelPartData data = playerdata.getOrCreatePart("wings"); - if(button.getValue() > 1) - data.setTexture("wings/wing" + (button.getValue() - 1), button.getValue() - 1); - } - initGui(); - } - if(button.id == 1){ - playerdata.breasts = (byte) button.getValue(); - } - if(button.id == 2){ - int value = button.getValue(); - if(value == 0) - playerdata.removePart("particles"); - else{ - ModelPartData particles = playerdata.getOrCreatePart("particles"); - if(value == 1) - particles.setTexture("", 0); - if(value == 2) - particles.setTexture("particle/type1", 0); - if(value == 3) - particles.setTexture("particle/type2", 0); - if(value == 4) - particles.setTexture("", 1); - if(value == 5) - particles.setTexture("particle/type3", 0); - if(value == 6) - particles.setTexture("particle/type4", 0); - if(value == 7) - particles.setTexture("particle/type5", 0); - if(value == 8) - particles.setTexture("particle/type6", 0); - if(value == 9) - particles.setTexture("particle/type7", 0); - } - initGui(); - } - if(button.id == 3){ - int value = button.getValue(); - if(value == 0) - playerdata.removePart("fin"); - else{ - ModelPartData particles = playerdata.getOrCreatePart("fin"); - if(value == 1) - particles.setTexture("", 0); - if(value == 2) - particles.setTexture("fin/fin1", 0); - if(value == 3) - particles.setTexture("fin/fin2", 0); - if(value == 4) - particles.setTexture("fin/fin3", 0); - if(value == 5) - particles.setTexture("fin/fin4", 0); - if(value == 6) - particles.setTexture("fin/fin5", 0); - if(value == 7) + if (button.id == 0) { + if (button.getValue() == 0) + playerdata.removePart("wings"); + else { + ModelPartData data = playerdata.getOrCreatePart("wings"); + if (button.getValue() > 1) + data.setTexture("wings/wing" + (button.getValue() - 1), button.getValue() - 1); + } + initGui(); + } + if (button.id == 1) { + playerdata.breasts = (byte) button.getValue(); + } + if (button.id == 2) { + int value = button.getValue(); + if (value == 0) + playerdata.removePart("particles"); + else { + ModelPartData particles = playerdata.getOrCreatePart("particles"); + if (value == 1) + particles.setTexture("", 0); + if (value == 2) + particles.setTexture("particle/type1", 0); + if (value == 3) + particles.setTexture("particle/type2", 0); + if (value == 4) + particles.setTexture("", 1); + if (value == 5) + particles.setTexture("particle/type3", 0); + if (value == 6) + particles.setTexture("particle/type4", 0); + if (value == 7) + particles.setTexture("particle/type5", 0); + if (value == 8) + particles.setTexture("particle/type6", 0); + if (value == 9) + particles.setTexture("particle/type7", 0); + } + initGui(); + } + if (button.id == 3) { + int value = button.getValue(); + if (value == 0) + playerdata.removePart("fin"); + else { + ModelPartData particles = playerdata.getOrCreatePart("fin"); + if (value == 1) + particles.setTexture("", 0); + if (value == 2) + particles.setTexture("fin/fin1", 0); + if (value == 3) + particles.setTexture("fin/fin2", 0); + if (value == 4) + particles.setTexture("fin/fin3", 0); + if (value == 5) + particles.setTexture("fin/fin4", 0); + if (value == 6) + particles.setTexture("fin/fin5", 0); + if (value == 7) particles.setTexture("fin/fin6", 0); - } - initGui(); - } + } + initGui(); + } - if(button.id == 4){ - int value = button.getValue(); - if(value == 0) - playerdata.removePart("skirt"); - else{ - ModelPartData skirt = playerdata.getOrCreatePart("skirt"); - if(value == 1) - skirt.setTexture("", 0); - if(value == 2) - skirt.setTexture("skirt/skirt1", 0); - } - initGui(); - } + if (button.id == 4) { + int value = button.getValue(); + if (value == 0) + playerdata.removePart("skirt"); + else { + ModelPartData skirt = playerdata.getOrCreatePart("skirt"); + if (value == 1) + skirt.setTexture("", 0); + if (value == 2) + skirt.setTexture("skirt/skirt1", 0); + } + initGui(); + } - if(button.id == 8){ - playerdata.bodywear = (byte) button.getValue(); - } + if (button.id == 8) { + playerdata.bodywear = (byte) button.getValue(); + } - if(button.id == 30){ - playerdata.hideBody = (byte) button.getValue(); - } + if (button.id == 30) { + playerdata.hideBody = (byte) button.getValue(); + } - if(button.id == 11){ - this.mc.displayGuiScreen(new GuiModelColor(this, playerdata.getPartData("wings"), npc)); - } - if(button.id == 12){ - this.mc.displayGuiScreen(new GuiModelColor(this, playerdata.getPartData("particles"), npc)); - } - if(button.id == 13){ - this.mc.displayGuiScreen(new GuiModelColor(this, playerdata.getPartData("fin"), npc)); - } - if(button.id == 14){ + if (button.id == 11) { + this.mc.displayGuiScreen(new GuiModelColor(this, playerdata.getPartData("wings"), npc)); + } + if (button.id == 12) { + this.mc.displayGuiScreen(new GuiModelColor(this, playerdata.getPartData("particles"), npc)); + } + if (button.id == 13) { + this.mc.displayGuiScreen(new GuiModelColor(this, playerdata.getPartData("fin"), npc)); + } + if (button.id == 14) { this.mc.displayGuiScreen(new GuiModelColor(this, playerdata.getPartData("skirt"), npc)); } } @Override - public void close(){ + public void close() { this.mc.displayGuiScreen(parent); } } diff --git a/src/main/java/noppes/npcs/client/gui/model/GuiModelColor.java b/src/main/java/noppes/npcs/client/gui/model/GuiModelColor.java index 9ea3054df..70d532aaf 100644 --- a/src/main/java/noppes/npcs/client/gui/model/GuiModelColor.java +++ b/src/main/java/noppes/npcs/client/gui/model/GuiModelColor.java @@ -16,109 +16,106 @@ import java.awt.image.BufferedImage; import java.io.IOException; import java.io.InputStream; -public class GuiModelColor extends GuiModelInterface implements ITextfieldListener{ +public class GuiModelColor extends GuiModelInterface implements ITextfieldListener { - private GuiScreen parent; - private final static ResourceLocation color = new ResourceLocation("customnpcs:textures/gui/color.png"); + private GuiScreen parent; + private final static ResourceLocation color = new ResourceLocation("customnpcs:textures/gui/color.png"); - private int colorX, colorY; + private int colorX, colorY; - private GuiNpcTextField textfield; + private GuiNpcTextField textfield; - private ModelPartData data; - public GuiModelColor(GuiScreen parent, ModelPartData data, EntityCustomNpc npc){ - super(npc); - this.parent = parent; - this.data = data; - this.xOffset = 60; - ySize = 230; - } + private ModelPartData data; - @Override - public void initGui() { - super.initGui(); - colorX = guiLeft + 4; - colorY = guiTop + 50; - this.addTextField(textfield = new GuiNpcTextField(0, this, guiLeft + 25, guiTop + 20, 70, 20, data.getColor())); - textfield.setTextColor(data.color); + public GuiModelColor(GuiScreen parent, ModelPartData data, EntityCustomNpc npc) { + super(npc); + this.parent = parent; + this.data = data; + this.xOffset = 60; + ySize = 230; } @Override - public void keyTyped(char c, int i){ - String prev = textfield.getText(); - super.keyTyped(c, i); - String newText = textfield.getText(); - if(newText.equals(prev)) - return; - try{ - int color = Integer.parseInt(textfield.getText(),16); - data.color = color; - textfield.setTextColor(color); - } - catch(NumberFormatException e){ - textfield.setText(prev); - } + public void initGui() { + super.initGui(); + colorX = guiLeft + 4; + colorY = guiTop + 50; + this.addTextField(textfield = new GuiNpcTextField(0, this, guiLeft + 25, guiTop + 20, 70, 20, data.getColor())); + textfield.setTextColor(data.color); + } + + @Override + public void keyTyped(char c, int i) { + String prev = textfield.getText(); + super.keyTyped(c, i); + String newText = textfield.getText(); + if (newText.equals(prev)) + return; + try { + int color = Integer.parseInt(textfield.getText(), 16); + data.color = color; + textfield.setTextColor(color); + } catch (NumberFormatException e) { + textfield.setText(prev); + } } @Override protected void actionPerformed(GuiButton btn) { - super.actionPerformed(btn); + super.actionPerformed(btn); } @Override - public void close(){ + public void close() { this.mc.displayGuiScreen(parent); } @Override - public void drawScreen(int par1, int par2, float par3){ - super.drawScreen(par1, par2, par3); + public void drawScreen(int par1, int par2, float par3) { + super.drawScreen(par1, par2, par3); mc.getTextureManager().bindTexture(color); GL11.glColor4f(1, 1, 1, 1); this.drawTexturedModalRect(colorX, colorY, 0, 0, 120, 120); } - @Override - public void mouseClicked(int i, int j, int k) - { - super.mouseClicked(i, j, k); - if(i < colorX || i > colorX + 120 || j < colorY || j > colorY + 120) - return; - InputStream stream = null; - try { - IResource resource = this.mc.getResourceManager().getResource(color); + @Override + public void mouseClicked(int i, int j, int k) { + super.mouseClicked(i, j, k); + if (i < colorX || i > colorX + 120 || j < colorY || j > colorY + 120) + return; + InputStream stream = null; + try { + IResource resource = this.mc.getResourceManager().getResource(color); BufferedImage bufferedimage = ImageIO.read(stream = resource.getInputStream()); - int color = bufferedimage.getRGB((i - guiLeft - 4) * 4, (j - guiTop - 50) * 4) & 16777215; - if(color != 0){ - data.color = color; - textfield.setTextColor(color); - textfield.setText(data.getColor()); + int color = bufferedimage.getRGB((i - guiLeft - 4) * 4, (j - guiTop - 50) * 4) & 16777215; + if (color != 0) { + data.color = color; + textfield.setTextColor(color); + textfield.setText(data.getColor()); } - } catch (IOException e) { - } - finally{ - if(stream != null){ - try { - stream.close(); - } catch (IOException e) { + } catch (IOException e) { + } finally { + if (stream != null) { + try { + stream.close(); + } catch (IOException e) { - } - } - } + } + } + } } - @Override - public void unFocused(GuiNpcTextField textfield) { - int color = 0; - try{ - color = Integer.parseInt(textfield.getText(),16); - } - catch(NumberFormatException e){ - color = 0; - } - data.color = color; - textfield.setTextColor(color); - } + @Override + public void unFocused(GuiNpcTextField textfield) { + int color = 0; + try { + color = Integer.parseInt(textfield.getText(), 16); + } catch (NumberFormatException e) { + color = 0; + } + data.color = color; + textfield.setTextColor(color); + } } diff --git a/src/main/java/noppes/npcs/client/gui/model/GuiModelHead.java b/src/main/java/noppes/npcs/client/gui/model/GuiModelHead.java index b6aa01568..98052c3c5 100644 --- a/src/main/java/noppes/npcs/client/gui/model/GuiModelHead.java +++ b/src/main/java/noppes/npcs/client/gui/model/GuiModelHead.java @@ -8,230 +8,230 @@ import noppes.npcs.client.gui.util.GuiNpcLabel; import noppes.npcs.entity.EntityCustomNpc; import noppes.npcs.entity.data.ModelPartData; -public class GuiModelHead extends GuiModelInterface{ +public class GuiModelHead extends GuiModelInterface { - private GuiScreen parent; + private GuiScreen parent; - private final String[] arrHead = new String[]{"gui.no","gui.yes"}; - private final String[] arrHeadwear = new String[]{"gui.no","gui.yes","Solid"}; - private final String[] arrHair = new String[]{"gui.no","Player","Long","Thin","Stylish","Ponytail"}; - private final String[] arrBeard = new String[]{"gui.no","Player","Standard","Viking","Long","Short"}; - private final String[] arrMohawk = new String[]{"gui.no","Type1","Type2","Type3"}; - private final String[] arrSnout = new String[]{"gui.no","Player Small","Player Medium", "Player Large", "Player Bunny", - "Small1", "Medium1", "Large1", "Bunny1", "Beak1"}; - private final String[] arrEars = new String[]{"gui.no","Player","Player Bunny","Bunny","Type1"}; - private final String[] arrHorns = new String[]{"gui.no", "Player Bull", "Player Antlers", "Player AntennasB", "Player AntennasF", "Bull", "Antlers", "AntennasB", "AntennasF" }; + private final String[] arrHead = new String[]{"gui.no", "gui.yes"}; + private final String[] arrHeadwear = new String[]{"gui.no", "gui.yes", "Solid"}; + private final String[] arrHair = new String[]{"gui.no", "Player", "Long", "Thin", "Stylish", "Ponytail"}; + private final String[] arrBeard = new String[]{"gui.no", "Player", "Standard", "Viking", "Long", "Short"}; + private final String[] arrMohawk = new String[]{"gui.no", "Type1", "Type2", "Type3"}; + private final String[] arrSnout = new String[]{"gui.no", "Player Small", "Player Medium", "Player Large", "Player Bunny", + "Small1", "Medium1", "Large1", "Bunny1", "Beak1"}; + private final String[] arrEars = new String[]{"gui.no", "Player", "Player Bunny", "Bunny", "Type1"}; + private final String[] arrHorns = new String[]{"gui.no", "Player Bull", "Player Antlers", "Player AntennasB", "Player AntennasF", "Bull", "Antlers", "AntennasB", "AntennasF"}; - public GuiModelHead(GuiScreen parent, EntityCustomNpc npc){ - super(npc); - this.parent = parent; - this.xOffset = 60; - } + public GuiModelHead(GuiScreen parent, EntityCustomNpc npc) { + super(npc); + this.parent = parent; + this.xOffset = 60; + } @Override public void initGui() { - super.initGui(); + super.initGui(); - int y = guiTop + 20; + int y = guiTop + 20; - addButton(new GuiNpcButton(30, guiLeft + 50, y += 22, 70, 20, arrHead, playerdata.hideHead)); - addLabel(new GuiNpcLabel(30, "Hide", guiLeft, y + 5, 0xFFFFFF)); + addButton(new GuiNpcButton(30, guiLeft + 50, y += 22, 70, 20, arrHead, playerdata.hideHead)); + addLabel(new GuiNpcLabel(30, "Hide", guiLeft, y + 5, 0xFFFFFF)); - addButton(new GuiNpcButton(0, guiLeft + 50, y += 22, 70, 20, arrHeadwear, playerdata.headwear)); - addLabel(new GuiNpcLabel(0, "Headwear", guiLeft, y + 5, 0xFFFFFF)); + addButton(new GuiNpcButton(0, guiLeft + 50, y += 22, 70, 20, arrHeadwear, playerdata.headwear)); + addLabel(new GuiNpcLabel(0, "Headwear", guiLeft, y + 5, 0xFFFFFF)); - ModelPartData hair = playerdata.getPartData("hair"); - addButton(new GuiNpcButton(1, guiLeft + 50, y += 22, 70, 20, arrHair, hair == null ? 0 : hair.type + 1)); - addLabel(new GuiNpcLabel(1, "Hair", guiLeft, y + 5, 0xFFFFFF)); - if (hair != null) - addButton(new GuiNpcButton(11, guiLeft + 122, y, 40, 20, hair.getColor())); + ModelPartData hair = playerdata.getPartData("hair"); + addButton(new GuiNpcButton(1, guiLeft + 50, y += 22, 70, 20, arrHair, hair == null ? 0 : hair.type + 1)); + addLabel(new GuiNpcLabel(1, "Hair", guiLeft, y + 5, 0xFFFFFF)); + if (hair != null) + addButton(new GuiNpcButton(11, guiLeft + 122, y, 40, 20, hair.getColor())); - ModelPartData mohawk = playerdata.getPartData("mohawk"); - addButton(new GuiNpcButton(2, guiLeft + 50, y += 22, 70, 20, arrMohawk, mohawk == null ? 0 : mohawk.type)); - addLabel(new GuiNpcLabel(2, "Mohawk", guiLeft, y + 5, 0xFFFFFF)); - if (mohawk != null) - addButton(new GuiNpcButton(12, guiLeft + 122, y, 40, 20, mohawk.getColor())); + ModelPartData mohawk = playerdata.getPartData("mohawk"); + addButton(new GuiNpcButton(2, guiLeft + 50, y += 22, 70, 20, arrMohawk, mohawk == null ? 0 : mohawk.type)); + addLabel(new GuiNpcLabel(2, "Mohawk", guiLeft, y + 5, 0xFFFFFF)); + if (mohawk != null) + addButton(new GuiNpcButton(12, guiLeft + 122, y, 40, 20, mohawk.getColor())); - ModelPartData beard = playerdata.getPartData("beard"); - addButton(new GuiNpcButton(3, guiLeft + 50, y += 22, 70, 20, arrBeard, beard == null ? 0 : beard.type + 1)); - addLabel(new GuiNpcLabel(3, "Beard", guiLeft, y + 5, 0xFFFFFF)); - if (beard != null) - addButton(new GuiNpcButton(13, guiLeft + 122, y, 40, 20, beard.getColor())); + ModelPartData beard = playerdata.getPartData("beard"); + addButton(new GuiNpcButton(3, guiLeft + 50, y += 22, 70, 20, arrBeard, beard == null ? 0 : beard.type + 1)); + addLabel(new GuiNpcLabel(3, "Beard", guiLeft, y + 5, 0xFFFFFF)); + if (beard != null) + addButton(new GuiNpcButton(13, guiLeft + 122, y, 40, 20, beard.getColor())); - ModelPartData snout = playerdata.getPartData("snout"); - addButton(new GuiNpcButton(4, guiLeft + 50, y += 22, 70, 20, arrSnout, snout == null ? 0 : snout.type + (snout.playerTexture ? 1 : 5))); - addLabel(new GuiNpcLabel(4, "Snout", guiLeft, y + 5, 0xFFFFFF)); - if (snout != null) - addButton(new GuiNpcButton(14, guiLeft + 122, y, 40, 20, snout.getColor())); + ModelPartData snout = playerdata.getPartData("snout"); + addButton(new GuiNpcButton(4, guiLeft + 50, y += 22, 70, 20, arrSnout, snout == null ? 0 : snout.type + (snout.playerTexture ? 1 : 5))); + addLabel(new GuiNpcLabel(4, "Snout", guiLeft, y + 5, 0xFFFFFF)); + if (snout != null) + addButton(new GuiNpcButton(14, guiLeft + 122, y, 40, 20, snout.getColor())); - ModelPartData ears = playerdata.getPartData("ears"); - addButton(new GuiNpcButton(5, guiLeft + 50, y += 22, 70, 20, arrEars, getEars(ears))); - addLabel(new GuiNpcLabel(5, "Ears", guiLeft, y + 5, 0xFFFFFF)); - if (ears != null) - addButton(new GuiNpcButton(15, guiLeft + 122, y, 40, 20, ears.getColor())); + ModelPartData ears = playerdata.getPartData("ears"); + addButton(new GuiNpcButton(5, guiLeft + 50, y += 22, 70, 20, arrEars, getEars(ears))); + addLabel(new GuiNpcLabel(5, "Ears", guiLeft, y + 5, 0xFFFFFF)); + if (ears != null) + addButton(new GuiNpcButton(15, guiLeft + 122, y, 40, 20, ears.getColor())); - ModelPartData horns = playerdata.getPartData("horns"); - y += 22;addButton(new GuiNpcButton(6, guiLeft + 50, y, 70, 20, arrHorns, getHorns(horns))); - addLabel(new GuiNpcLabel(6, "Horns", guiLeft, y + 5, 16777215)); - if (horns != null) { - addButton(new GuiNpcButton(16, guiLeft + 122, y, 40, 20, horns.getColor())); - } + ModelPartData horns = playerdata.getPartData("horns"); + y += 22; + addButton(new GuiNpcButton(6, guiLeft + 50, y, 70, 20, arrHorns, getHorns(horns))); + addLabel(new GuiNpcLabel(6, "Horns", guiLeft, y + 5, 16777215)); + if (horns != null) { + addButton(new GuiNpcButton(16, guiLeft + 122, y, 40, 20, horns.getColor())); + } } private int getEars(ModelPartData data) { - if(data == null) - return 0; - if(data.playerTexture && data.type == 0) - return 1; - if(data.playerTexture && data.type == 1) - return 2; - if(data.type == 0) - return 4; - if(data.type == 1) - return 3; + if (data == null) + return 0; + if (data.playerTexture && data.type == 0) + return 1; + if (data.playerTexture && data.type == 1) + return 2; + if (data.type == 0) + return 4; + if (data.type == 1) + return 3; - return 0; - } + return 0; + } - private int getHorns(ModelPartData data) { - if (data == null) - return 0; - if (data.playerTexture) { - return data.type + 1; - } - return data.type + 5; - } + private int getHorns(ModelPartData data) { + if (data == null) + return 0; + if (data.playerTexture) { + return data.type + 1; + } + return data.type + 5; + } - @Override + @Override protected void actionPerformed(GuiButton btn) { - super.actionPerformed(btn); - GuiNpcButton button = (GuiNpcButton) btn; + super.actionPerformed(btn); + GuiNpcButton button = (GuiNpcButton) btn; - if(button.id == 0){ - playerdata.headwear = (byte) button.getValue(); - } + if (button.id == 0) { + playerdata.headwear = (byte) button.getValue(); + } - if(button.id == 30){ - playerdata.hideHead = (byte) button.getValue(); - } + if (button.id == 30) { + playerdata.hideHead = (byte) button.getValue(); + } - if(button.id == 1){ - if(button.getValue() == 0) - playerdata.removePart("hair"); - else{ - ModelPartData data = playerdata.getOrCreatePart("hair"); - if(button.getValue() > 1) - data.setTexture("hair/hair" + (button.getValue() - 1), button.getValue() - 1); - } - initGui(); - } + if (button.id == 1) { + if (button.getValue() == 0) + playerdata.removePart("hair"); + else { + ModelPartData data = playerdata.getOrCreatePart("hair"); + if (button.getValue() > 1) + data.setTexture("hair/hair" + (button.getValue() - 1), button.getValue() - 1); + } + initGui(); + } - if(button.id == 2){ - if(button.getValue() == 0) - playerdata.removePart("mohawk"); - else{ - ModelPartData data = playerdata.getOrCreatePart("mohawk"); - if(button.getValue() > 0) - data.setTexture("hair/mohawk" + button.getValue(),button.getValue()); - } - initGui(); - } + if (button.id == 2) { + if (button.getValue() == 0) + playerdata.removePart("mohawk"); + else { + ModelPartData data = playerdata.getOrCreatePart("mohawk"); + if (button.getValue() > 0) + data.setTexture("hair/mohawk" + button.getValue(), button.getValue()); + } + initGui(); + } - if(button.id == 3){ - if(button.getValue() == 0) - playerdata.removePart("beard"); - else{ - ModelPartData data = playerdata.getOrCreatePart("beard"); - if(button.getValue() > 1) - data.setTexture("beard/beard" + (button.getValue() - 1),button.getValue() - 1); - } - initGui(); - } + if (button.id == 3) { + if (button.getValue() == 0) + playerdata.removePart("beard"); + else { + ModelPartData data = playerdata.getOrCreatePart("beard"); + if (button.getValue() > 1) + data.setTexture("beard/beard" + (button.getValue() - 1), button.getValue() - 1); + } + initGui(); + } - if(button.id == 4){ - if(button.getValue() == 0) + if (button.id == 4) { + if (button.getValue() == 0) playerdata.removePart("snout"); - else if(button.getValue() < 5){ + else if (button.getValue() < 5) { ModelPartData data = playerdata.getOrCreatePart("snout"); data.type = (byte) (button.getValue() - 1); - } - else{ + } else { ModelPartData data = playerdata.getOrCreatePart("snout"); byte type = 0; - if(button.displayString.startsWith("Medium")) + if (button.displayString.startsWith("Medium")) type = 1; - if(button.displayString.startsWith("Large")) + if (button.displayString.startsWith("Large")) type = 2; - if(button.displayString.startsWith("Bunny")) + if (button.displayString.startsWith("Bunny")) type = 3; - if(button.displayString.startsWith("Beak")) + if (button.displayString.startsWith("Beak")) type = 4; data.setTexture("snout/" + button.displayString.toLowerCase(), type); } initGui(); } - if(button.id == 5){ - int value = button.getValue(); - if(value == 0) - playerdata.removePart("ears"); - else{ - ModelPartData data = playerdata.getOrCreatePart("ears"); - if(value == 1) - data.setTexture("", 0); - if(value == 2) - data.setTexture("", 1); - if(value == 3) - data.setTexture("ears/bunny1", 1); - if(value == 4) - data.setTexture("ears/type1", 0); - } - initGui(); - } - - if(button.id == 6){ + if (button.id == 5) { int value = button.getValue(); - if(value == 0) + if (value == 0) + playerdata.removePart("ears"); + else { + ModelPartData data = playerdata.getOrCreatePart("ears"); + if (value == 1) + data.setTexture("", 0); + if (value == 2) + data.setTexture("", 1); + if (value == 3) + data.setTexture("ears/bunny1", 1); + if (value == 4) + data.setTexture("ears/type1", 0); + } + initGui(); + } + + if (button.id == 6) { + int value = button.getValue(); + if (value == 0) playerdata.removePart("horns"); - else{ + else { ModelPartData data = playerdata.getOrCreatePart("horns"); - if(value <= 4) + if (value <= 4) data.setTexture("", value - 1); - if(value == 5) + if (value == 5) data.setTexture("horns/bull", 0); - if(value == 6) + if (value == 6) data.setTexture("horns/antlers", 1); - if(value == 7) + if (value == 7) data.setTexture("horns/antennas", 2); - if(value == 8) + if (value == 8) data.setTexture("horns/antennas", 3); } initGui(); } - if(button.id == 11){ - this.mc.displayGuiScreen(new GuiModelColor(this, playerdata.getPartData("hair"), npc)); - } - if(button.id == 12){ - this.mc.displayGuiScreen(new GuiModelColor(this, playerdata.getPartData("mohawk"), npc)); - } - if(button.id == 13){ - this.mc.displayGuiScreen(new GuiModelColor(this, playerdata.getPartData("beard"), npc)); - } - if(button.id == 14){ - this.mc.displayGuiScreen(new GuiModelColor(this, playerdata.getPartData("snout"), npc)); - } - if(button.id == 15){ - this.mc.displayGuiScreen(new GuiModelColor(this, playerdata.getPartData("ears"), npc)); - } - if(button.id == 16){ + if (button.id == 11) { + this.mc.displayGuiScreen(new GuiModelColor(this, playerdata.getPartData("hair"), npc)); + } + if (button.id == 12) { + this.mc.displayGuiScreen(new GuiModelColor(this, playerdata.getPartData("mohawk"), npc)); + } + if (button.id == 13) { + this.mc.displayGuiScreen(new GuiModelColor(this, playerdata.getPartData("beard"), npc)); + } + if (button.id == 14) { + this.mc.displayGuiScreen(new GuiModelColor(this, playerdata.getPartData("snout"), npc)); + } + if (button.id == 15) { + this.mc.displayGuiScreen(new GuiModelColor(this, playerdata.getPartData("ears"), npc)); + } + if (button.id == 16) { this.mc.displayGuiScreen(new GuiModelColor(this, playerdata.getPartData("horns"), npc)); } } @Override - public void close(){ + public void close() { this.mc.displayGuiScreen(parent); } } diff --git a/src/main/java/noppes/npcs/client/gui/model/GuiModelLegs.java b/src/main/java/noppes/npcs/client/gui/model/GuiModelLegs.java index 960b23480..66c4fa0f9 100644 --- a/src/main/java/noppes/npcs/client/gui/model/GuiModelLegs.java +++ b/src/main/java/noppes/npcs/client/gui/model/GuiModelLegs.java @@ -9,47 +9,48 @@ import noppes.npcs.client.gui.util.GuiNpcLabel; import noppes.npcs.entity.EntityCustomNpc; import noppes.npcs.entity.data.ModelPartData; -public class GuiModelLegs extends GuiModelInterface{ +public class GuiModelLegs extends GuiModelInterface { - private GuiScreen parent; - private final String[] arrLeg = new String[]{"gui.no","Both","Right","Left"}; - private final String[] arrLegwear = new String[]{"gui.no","Both","Left","Right"}; - private final String[] arrSolidLegwear = new String[]{"gui.no","Both","Left","Right"}; - private final String[] arrLegs = new String[]{"gui.no","Player","Player Naga","Spider","Horse","Naga", "Mermaid", "Mermaid 2", "Digitigrade"}; - private final String[] arrTail = new String[]{"gui.no","Player", "Player Dragon","Cat","Wolf","Horse","Dragon", "Squirrel", "Fin", "Rodent", "Feather", "Fox", "Monkey"}; - public GuiModelLegs(GuiScreen parent, EntityCustomNpc npc){ - super(npc); - this.parent = parent; - this.xOffset = 60; - } + private GuiScreen parent; + private final String[] arrLeg = new String[]{"gui.no", "Both", "Right", "Left"}; + private final String[] arrLegwear = new String[]{"gui.no", "Both", "Left", "Right"}; + private final String[] arrSolidLegwear = new String[]{"gui.no", "Both", "Left", "Right"}; + private final String[] arrLegs = new String[]{"gui.no", "Player", "Player Naga", "Spider", "Horse", "Naga", "Mermaid", "Mermaid 2", "Digitigrade"}; + private final String[] arrTail = new String[]{"gui.no", "Player", "Player Dragon", "Cat", "Wolf", "Horse", "Dragon", "Squirrel", "Fin", "Rodent", "Feather", "Fox", "Monkey"}; + + public GuiModelLegs(GuiScreen parent, EntityCustomNpc npc) { + super(npc); + this.parent = parent; + this.xOffset = 60; + } @Override public void initGui() { - super.initGui(); - int y = guiTop + 20; + super.initGui(); + int y = guiTop + 20; - addButton(new GuiNpcButton(30, guiLeft + 50, y += 22, 70, 20, arrLeg, playerdata.hideLegs)); - addLabel(new GuiNpcLabel(30, "Hide", guiLeft, y + 5, 0xFFFFFF)); + addButton(new GuiNpcButton(30, guiLeft + 50, y += 22, 70, 20, arrLeg, playerdata.hideLegs)); + addLabel(new GuiNpcLabel(30, "Hide", guiLeft, y + 5, 0xFFFFFF)); - if (npc.display.modelType == 1 || npc.display.modelType == 2) { - addButton(new GuiNpcButton(8, guiLeft + 50, y += 22, 70, 20, arrLegwear, playerdata.legwear)); - addLabel(new GuiNpcLabel(8, "Legwear", guiLeft, y + 5, 0xFFFFFF)); + if (npc.display.modelType == 1 || npc.display.modelType == 2) { + addButton(new GuiNpcButton(8, guiLeft + 50, y += 22, 70, 20, arrLegwear, playerdata.legwear)); + addLabel(new GuiNpcLabel(8, "Legwear", guiLeft, y + 5, 0xFFFFFF)); - addButton(new GuiNpcButton(9, guiLeft + 50, y += 22, 70, 20, arrSolidLegwear, playerdata.solidLegwear)); - addLabel(new GuiNpcLabel(9, "Solid", guiLeft, y + 5, 0xFFFFFF)); - } + addButton(new GuiNpcButton(9, guiLeft + 50, y += 22, 70, 20, arrSolidLegwear, playerdata.solidLegwear)); + addLabel(new GuiNpcLabel(9, "Solid", guiLeft, y + 5, 0xFFFFFF)); + } - addButton(new GuiNpcButton(1, guiLeft + 50, y += 22, 70, 20, arrLegs, getLegIndex(playerdata.legParts))); - addLabel(new GuiNpcLabel(1, "Legs", guiLeft, y + 5, 0xFFFFFF)); - if(playerdata.legParts.type > 0) - addButton(new GuiNpcButton(11, guiLeft + 122, y, 40, 20, playerdata.legParts.getColor())); + addButton(new GuiNpcButton(1, guiLeft + 50, y += 22, 70, 20, arrLegs, getLegIndex(playerdata.legParts))); + addLabel(new GuiNpcLabel(1, "Legs", guiLeft, y + 5, 0xFFFFFF)); + if (playerdata.legParts.type > 0) + addButton(new GuiNpcButton(11, guiLeft + 122, y, 40, 20, playerdata.legParts.getColor())); - ModelPartData tail = playerdata.getPartData("tail"); - addButton(new GuiNpcButton(2, guiLeft + 50, y += 22, 70, 20, arrTail, getTailIndex(tail))); - addLabel(new GuiNpcLabel(2, "Tail", guiLeft, y + 5, 0xFFFFFF)); - if(tail != null) - addButton(new GuiNpcButton(12, guiLeft + 122, y, 40, 20, tail.getColor())); - if(tail != null && tail.type == 8){ + ModelPartData tail = playerdata.getPartData("tail"); + addButton(new GuiNpcButton(2, guiLeft + 50, y += 22, 70, 20, arrTail, getTailIndex(tail))); + addLabel(new GuiNpcLabel(2, "Tail", guiLeft, y + 5, 0xFFFFFF)); + if (tail != null) + addButton(new GuiNpcButton(12, guiLeft + 122, y, 40, 20, tail.getColor())); + if (tail != null && tail.type == 8) { y += 22; this.addLabel(new GuiNpcLabel(22, "Pattern", guiLeft, y + 5, 0xFFFFFF)); this.addButton(new GuiButtonBiDirectional(22, guiLeft + 50, y, 100, 20, new String[]{"Normal", "Wrapped", "Large"}, tail.pattern)); @@ -57,41 +58,41 @@ public class GuiModelLegs extends GuiModelInterface{ } private int getLegIndex(ModelPartData data) { - if(!data.playerTexture && data.type == 1) - return 5; - if(data.type == 4) - return 6; - if(data.type == 5) - return 8; - return data.type + 1; - } + if (!data.playerTexture && data.type == 1) + return 5; + if (data.type == 4) + return 6; + if (data.type == 5) + return 8; + return data.type + 1; + } - private int getTailIndex(ModelPartData data){ - if(data == null) - return 0; - if(data.playerTexture && data.type == 0) - return 1; - if(data.type == 0 && data.texture.contains("tail1")) - return 3; - if(data.type == 0 && data.texture.contains("tail2")) - return 4; - if(data.playerTexture && data.type == 1) - return 2; - if(data.type == 1) - return 6; - if(data.type == 2) - return 5; - if(data.type == 3) - return 7; - if(data.type == 4) - return 8; - if(data.type == 5) - return 9; - if(data.type == 6) - return 10; - if(data.type == 7) + private int getTailIndex(ModelPartData data) { + if (data == null) + return 0; + if (data.playerTexture && data.type == 0) + return 1; + if (data.type == 0 && data.texture.contains("tail1")) + return 3; + if (data.type == 0 && data.texture.contains("tail2")) + return 4; + if (data.playerTexture && data.type == 1) + return 2; + if (data.type == 1) + return 6; + if (data.type == 2) + return 5; + if (data.type == 3) + return 7; + if (data.type == 4) + return 8; + if (data.type == 5) + return 9; + if (data.type == 6) + return 10; + if (data.type == 7) return 11; - if(data.type == 8) + if (data.type == 8) return 12; return 0; @@ -102,96 +103,96 @@ public class GuiModelLegs extends GuiModelInterface{ super.actionPerformed(btn); GuiNpcButton button = (GuiNpcButton) btn; - if(button.id == 8){ + if (button.id == 8) { playerdata.legwear = (byte) button.getValue(); } - if(button.id == 9){ + if (button.id == 9) { playerdata.solidLegwear = (byte) button.getValue(); } - if(button.id == 30){ + if (button.id == 30) { playerdata.hideLegs = (byte) button.getValue(); } - if(button.id == 1){ + if (button.id == 1) { ModelPartData data = playerdata.legParts; int value = button.getValue() - 1; - if(value < 1) + if (value < 1) data.color = 0xFFFFFF; - if(value < 2){ + if (value < 2) { data.setTexture("", value); } - if(value == 2) + if (value == 2) data.setTexture("legs/spider1", 2); - if(value == 3) + if (value == 3) data.setTexture("legs/horse1", 3); - if(value == 4) - if (npc.display.modelType == 1 || npc.display.modelType == 2){ + if (value == 4) + if (npc.display.modelType == 1 || npc.display.modelType == 2) { data.setTexture("legs/naga2", 1); - } - else{ + } else { data.setTexture("legs/naga1", 1); } - if(value == 5) + if (value == 5) data.setTexture("legs/mermaid1", 4); - if(value == 6) + if (value == 6) data.setTexture("legs/mermaid1", 6); - if(value == 7) + if (value == 7) data.setTexture("", 5); initGui(); } - if(button.id == 2){ + if (button.id == 2) { int value = button.getValue(); - if(value == 0) + if (value == 0) playerdata.removePart("tail"); - else{ + else { ModelPartData data = playerdata.getOrCreatePart("tail"); - if(value == 1){} - data.setTexture("", 0); - if(value == 2) + if (value == 1) { + } + data.setTexture("", 0); + if (value == 2) data.setTexture("", 1); - if(value == 3) + if (value == 3) data.setTexture("tail/tail1", 0); - if(value == 4) + if (value == 4) data.setTexture("tail/tail2", 0); - if(value == 5) + if (value == 5) data.setTexture("tail/horse1", 2); - if(value == 6) + if (value == 6) data.setTexture("tail/dragon1", 1); - if(value == 7) + if (value == 7) data.setTexture("tail/squirrel1", 3); - if(value == 8) + if (value == 8) data.setTexture("tail/fin1", 4); - if(value == 9) + if (value == 9) data.setTexture("tail/rodent1", 5); - if(value == 10) + if (value == 10) data.setTexture("tail/feather1", 6); - if(value == 11) + if (value == 11) data.setTexture("tail/fox1", 7); - if(value == 12) + if (value == 12) data.setTexture("tail/monkey1", 8); data.pattern = 0; } initGui(); } - if(button.id == 22){ + if (button.id == 22) { int value = button.getValue(); ModelPartData data = playerdata.getOrCreatePart("tail"); data.pattern = (byte) value; } - if(button.id == 11){ + if (button.id == 11) { this.mc.displayGuiScreen(new GuiModelColor(this, playerdata.legParts, npc)); } - if(button.id == 12){ + if (button.id == 12) { this.mc.displayGuiScreen(new GuiModelColor(this, playerdata.getPartData("tail"), npc)); } } @Override - public void close(){ + public void close() { this.mc.displayGuiScreen(parent); } } diff --git a/src/main/java/noppes/npcs/client/gui/model/GuiModelRotate.java b/src/main/java/noppes/npcs/client/gui/model/GuiModelRotate.java index 72f0e3b44..743de0945 100644 --- a/src/main/java/noppes/npcs/client/gui/model/GuiModelRotate.java +++ b/src/main/java/noppes/npcs/client/gui/model/GuiModelRotate.java @@ -7,205 +7,196 @@ import noppes.npcs.entity.EntityCustomNpc; import noppes.npcs.entity.data.ModelData; import noppes.npcs.entity.data.ModelRotatePart; -public class GuiModelRotate extends GuiModelInterface implements ISliderListener{ +public class GuiModelRotate extends GuiModelInterface implements ISliderListener { - private GuiScreen parent; - private int type = 6; - private ModelRotatePart part; + private GuiScreen parent; + private int type = 6; + private ModelRotatePart part; - private GuiNpcSlider rotateX; - private GuiNpcSlider rotateY; - private GuiNpcSlider rotateZ; + private GuiNpcSlider rotateX; + private GuiNpcSlider rotateY; + private GuiNpcSlider rotateZ; - public GuiModelRotate(GuiScreen parent, ModelData data, EntityCustomNpc npc){ - super(npc); - this.parent = parent; - this.xOffset = 100; - ySize = 230; - } + public GuiModelRotate(GuiScreen parent, ModelData data, EntityCustomNpc npc) { + super(npc); + this.parent = parent; + this.xOffset = 100; + ySize = 230; + } @Override public void initGui() { - super.initGui(); + super.initGui(); - int y = guiTop; - addLabel(new GuiNpcLabel(27, "movement.rotation", guiLeft + 55, y + 5, 0xFFFFFF)); - addButton(new GuiNpcButton(14, guiLeft + 110, y , 60, 20, new String[]{"gui.enabled","gui.disabled"}, playerdata.enableRotation?0:1)); - y += 24; - if(playerdata.enableRotation){ - addLabel(new GuiNpcLabel(26, "gui.settings", guiLeft + 55, y + 5, 0xFFFFFF)); - if(type == 6){ - addButton(new GuiNpcButton(30, guiLeft + 120, y += 14, 60, 20, new String[]{"gui.yes", "gui.no"}, playerdata.rotation.whileStanding?0:1)); - addLabel(new GuiNpcLabel(30, "puppet.standing", guiLeft + 30, y + 5, 0xFFFFFF)); - addButton(new GuiNpcButton(31, guiLeft + 120, y += 22, 60, 20, new String[]{"gui.yes", "gui.no"}, playerdata.rotation.whileMoving?0:1)); - addLabel(new GuiNpcLabel(31, "puppet.walking", guiLeft + 30, y + 5, 0xFFFFFF)); - addButton(new GuiNpcButton(32, guiLeft + 120, y += 22, 60, 20, new String[]{"gui.yes", "gui.no"}, playerdata.rotation.whileAttacking?0:1)); - addLabel(new GuiNpcLabel(32, "puppet.attacking", guiLeft + 30, y + 5, 0xFFFFFF)); - y += 24; - } - else{ - addButton(new GuiNpcButton(6, guiLeft + 110, y , 60, 20, "selectServer.edit")); - y += 24; - } + int y = guiTop; + addLabel(new GuiNpcLabel(27, "movement.rotation", guiLeft + 55, y + 5, 0xFFFFFF)); + addButton(new GuiNpcButton(14, guiLeft + 110, y, 60, 20, new String[]{"gui.enabled", "gui.disabled"}, playerdata.enableRotation ? 0 : 1)); + y += 24; + if (playerdata.enableRotation) { + addLabel(new GuiNpcLabel(26, "gui.settings", guiLeft + 55, y + 5, 0xFFFFFF)); + if (type == 6) { + addButton(new GuiNpcButton(30, guiLeft + 120, y += 14, 60, 20, new String[]{"gui.yes", "gui.no"}, playerdata.rotation.whileStanding ? 0 : 1)); + addLabel(new GuiNpcLabel(30, "puppet.standing", guiLeft + 30, y + 5, 0xFFFFFF)); + addButton(new GuiNpcButton(31, guiLeft + 120, y += 22, 60, 20, new String[]{"gui.yes", "gui.no"}, playerdata.rotation.whileMoving ? 0 : 1)); + addLabel(new GuiNpcLabel(31, "puppet.walking", guiLeft + 30, y + 5, 0xFFFFFF)); + addButton(new GuiNpcButton(32, guiLeft + 120, y += 22, 60, 20, new String[]{"gui.yes", "gui.no"}, playerdata.rotation.whileAttacking ? 0 : 1)); + addLabel(new GuiNpcLabel(32, "puppet.attacking", guiLeft + 30, y + 5, 0xFFFFFF)); + y += 24; + } else { + addButton(new GuiNpcButton(6, guiLeft + 110, y, 60, 20, "selectServer.edit")); + y += 24; + } - addLabel(new GuiNpcLabel(20, "model.head", guiLeft + 55, y + 5, 0xFFFFFF)); - if(type == 0){ - drawSlider(y, playerdata.rotation.head); - y += 90; - } - else{ - addButton(new GuiNpcButton(0, guiLeft + 110, y , 60, 20, "selectServer.edit")); - y += 24; - } + addLabel(new GuiNpcLabel(20, "model.head", guiLeft + 55, y + 5, 0xFFFFFF)); + if (type == 0) { + drawSlider(y, playerdata.rotation.head); + y += 90; + } else { + addButton(new GuiNpcButton(0, guiLeft + 110, y, 60, 20, "selectServer.edit")); + y += 24; + } - addLabel(new GuiNpcLabel(21, "model.body", guiLeft + 55, y + 5, 0xFFFFFF)); - if(type == 1){ - drawSlider(y, playerdata.rotation.body); - y += 90; - } - else{ - addButton(new GuiNpcButton(1, guiLeft + 110, y , 60, 20, "selectServer.edit")); - y += 24; - } + addLabel(new GuiNpcLabel(21, "model.body", guiLeft + 55, y + 5, 0xFFFFFF)); + if (type == 1) { + drawSlider(y, playerdata.rotation.body); + y += 90; + } else { + addButton(new GuiNpcButton(1, guiLeft + 110, y, 60, 20, "selectServer.edit")); + y += 24; + } - addLabel(new GuiNpcLabel(22, "model.larm", guiLeft + 55, y + 5, 0xFFFFFF)); - if(type == 2){ - drawSlider(y, playerdata.rotation.larm); - y += 90; - } - else{ - addButton(new GuiNpcButton(2, guiLeft + 110, y , 60, 20, "selectServer.edit")); - y += 24; - } + addLabel(new GuiNpcLabel(22, "model.larm", guiLeft + 55, y + 5, 0xFFFFFF)); + if (type == 2) { + drawSlider(y, playerdata.rotation.larm); + y += 90; + } else { + addButton(new GuiNpcButton(2, guiLeft + 110, y, 60, 20, "selectServer.edit")); + y += 24; + } - addLabel(new GuiNpcLabel(23, "model.rarm", guiLeft + 55, y + 5, 0xFFFFFF)); - if(type == 3){ - drawSlider(y, playerdata.rotation.rarm); - y += 90; - } - else{ - addButton(new GuiNpcButton(3, guiLeft + 110, y , 60, 20, "selectServer.edit")); - y += 24; - } + addLabel(new GuiNpcLabel(23, "model.rarm", guiLeft + 55, y + 5, 0xFFFFFF)); + if (type == 3) { + drawSlider(y, playerdata.rotation.rarm); + y += 90; + } else { + addButton(new GuiNpcButton(3, guiLeft + 110, y, 60, 20, "selectServer.edit")); + y += 24; + } - addLabel(new GuiNpcLabel(24, "model.lleg", guiLeft + 55, y + 5, 0xFFFFFF)); - if(type == 4){ - drawSlider(y, playerdata.rotation.lleg); - y += 90; - } - else{ - addButton(new GuiNpcButton(4, guiLeft + 110, y , 60, 20, "selectServer.edit")); - y += 24; - } + addLabel(new GuiNpcLabel(24, "model.lleg", guiLeft + 55, y + 5, 0xFFFFFF)); + if (type == 4) { + drawSlider(y, playerdata.rotation.lleg); + y += 90; + } else { + addButton(new GuiNpcButton(4, guiLeft + 110, y, 60, 20, "selectServer.edit")); + y += 24; + } - addLabel(new GuiNpcLabel(25, "model.rleg", guiLeft + 55, y + 5, 0xFFFFFF)); - if(type == 5){ - drawSlider(y, playerdata.rotation.rleg); - y += 90; - } - else{ - addButton(new GuiNpcButton(5, guiLeft + 110, y , 60, 20, "selectServer.edit")); - y += 24; - } - } + addLabel(new GuiNpcLabel(25, "model.rleg", guiLeft + 55, y + 5, 0xFFFFFF)); + if (type == 5) { + drawSlider(y, playerdata.rotation.rleg); + y += 90; + } else { + addButton(new GuiNpcButton(5, guiLeft + 110, y, 60, 20, "selectServer.edit")); + y += 24; + } + } } - private void drawSlider(int y, ModelRotatePart config){ - part = config; - addButton(new GuiNpcButton(29, guiLeft + 100, y , 80, 20, new String[]{"gui.enabled","gui.disabled"}, config.disabled ?1:0)); - y += 22; - addLabel(new GuiNpcLabel(10, "X", guiLeft, y + 5, 0xFFFFFF)); - rotateX = new GuiNpcSlider(this, 10, guiLeft + 50, y, config.rotationX + 0.5f); - addSlider(rotateX); - addButton(new GuiNpcButton(170, guiLeft + 8, y, 40, 20, "Reset")); - y += 22; - addLabel(new GuiNpcLabel(11, "Y", guiLeft, y + 5, 0xFFFFFF)); - rotateY = new GuiNpcSlider(this, 11, guiLeft + 50, y, config.rotationY + 0.5f); - addSlider(rotateY); - addButton(new GuiNpcButton(171, guiLeft + 8, y, 40, 20, "Reset")); - y += 22; - addLabel(new GuiNpcLabel(12, "Z", guiLeft, y + 5, 0xFFFFFF)); - rotateZ = new GuiNpcSlider(this, 12, guiLeft + 50, y, config.rotationZ + 0.5f); - addSlider(rotateZ); - addButton(new GuiNpcButton(172, guiLeft + 8, y, 40, 20, "Reset")); - } + private void drawSlider(int y, ModelRotatePart config) { + part = config; + addButton(new GuiNpcButton(29, guiLeft + 100, y, 80, 20, new String[]{"gui.enabled", "gui.disabled"}, config.disabled ? 1 : 0)); + y += 22; + addLabel(new GuiNpcLabel(10, "X", guiLeft, y + 5, 0xFFFFFF)); + rotateX = new GuiNpcSlider(this, 10, guiLeft + 50, y, config.rotationX + 0.5f); + addSlider(rotateX); + addButton(new GuiNpcButton(170, guiLeft + 8, y, 40, 20, "Reset")); + y += 22; + addLabel(new GuiNpcLabel(11, "Y", guiLeft, y + 5, 0xFFFFFF)); + rotateY = new GuiNpcSlider(this, 11, guiLeft + 50, y, config.rotationY + 0.5f); + addSlider(rotateY); + addButton(new GuiNpcButton(171, guiLeft + 8, y, 40, 20, "Reset")); + y += 22; + addLabel(new GuiNpcLabel(12, "Z", guiLeft, y + 5, 0xFFFFFF)); + rotateZ = new GuiNpcSlider(this, 12, guiLeft + 50, y, config.rotationZ + 0.5f); + addSlider(rotateZ); + addButton(new GuiNpcButton(172, guiLeft + 8, y, 40, 20, "Reset")); + } @Override protected void actionPerformed(GuiButton btn) { - super.actionPerformed(btn); - if(btn.id < 7){ - type = btn.id; - initGui(); - } - if(!(btn instanceof GuiNpcButton)) - return; + super.actionPerformed(btn); + if (btn.id < 7) { + type = btn.id; + initGui(); + } + if (!(btn instanceof GuiNpcButton)) + return; - GuiNpcButton button = (GuiNpcButton) btn; - if(btn.id == 14){ - playerdata.enableRotation = button.getValue() == 0; - initGui(); - } - if(btn.id == 29){ - part.disabled = button.getValue() == 1; - } - if(btn.id == 30){ - playerdata.rotation.whileStanding = button.getValue() == 0; - } - if(btn.id == 31){ - playerdata.rotation.whileMoving = button.getValue() == 0; - } - if(btn.id == 32){ - playerdata.rotation.whileAttacking = button.getValue() == 0; - } - if(btn.id == 170 || btn.id == 171 || btn.id == 172){ - if(btn.id == 170){ - part.rotationX = 0.0f; - rotateX.sliderValue = 0.5f; - int percent = (int) ((rotateX.sliderValue) * 360); - rotateX.setString(percent + "%"); - } - else if(btn.id == 171){ - part.rotationY = 0.0f; - rotateY.sliderValue = 0.5f; - int percent = (int) ((rotateY.sliderValue) * 360); - rotateY.setString(percent + "%"); - } - else{ - part.rotationZ = 0.0f; - rotateZ.sliderValue = 0.5f; - int percent = (int) ((rotateZ.sliderValue) * 360); - rotateZ.setString(percent + "%"); - } - npc.updateHitbox(); - } + GuiNpcButton button = (GuiNpcButton) btn; + if (btn.id == 14) { + playerdata.enableRotation = button.getValue() == 0; + initGui(); + } + if (btn.id == 29) { + part.disabled = button.getValue() == 1; + } + if (btn.id == 30) { + playerdata.rotation.whileStanding = button.getValue() == 0; + } + if (btn.id == 31) { + playerdata.rotation.whileMoving = button.getValue() == 0; + } + if (btn.id == 32) { + playerdata.rotation.whileAttacking = button.getValue() == 0; + } + if (btn.id == 170 || btn.id == 171 || btn.id == 172) { + if (btn.id == 170) { + part.rotationX = 0.0f; + rotateX.sliderValue = 0.5f; + int percent = (int) ((rotateX.sliderValue) * 360); + rotateX.setString(percent + "%"); + } else if (btn.id == 171) { + part.rotationY = 0.0f; + rotateY.sliderValue = 0.5f; + int percent = (int) ((rotateY.sliderValue) * 360); + rotateY.setString(percent + "%"); + } else { + part.rotationZ = 0.0f; + rotateZ.sliderValue = 0.5f; + int percent = (int) ((rotateZ.sliderValue) * 360); + rotateZ.setString(percent + "%"); + } + npc.updateHitbox(); + } } @Override - public void close(){ + public void close() { this.mc.displayGuiScreen(parent); } - @Override - public void mouseDragged(GuiNpcSlider slider) { - int percent = (int) ((slider.sliderValue) * 360); - slider.setString(percent + "%"); + @Override + public void mouseDragged(GuiNpcSlider slider) { + int percent = (int) ((slider.sliderValue) * 360); + slider.setString(percent + "%"); - if(slider.id == 10) - part.rotationX = slider.sliderValue - 0.5f; - if(slider.id == 11) - part.rotationY = slider.sliderValue - 0.5f; - if(slider.id == 12) - part.rotationZ = slider.sliderValue - 0.5f; - npc.updateHitbox(); - } + if (slider.id == 10) + part.rotationX = slider.sliderValue - 0.5f; + if (slider.id == 11) + part.rotationY = slider.sliderValue - 0.5f; + if (slider.id == 12) + part.rotationZ = slider.sliderValue - 0.5f; + npc.updateHitbox(); + } - @Override - public void mousePressed(GuiNpcSlider slider) { + @Override + public void mousePressed(GuiNpcSlider slider) { - } + } - @Override - public void mouseReleased(GuiNpcSlider slider) { - } + @Override + public void mouseReleased(GuiNpcSlider slider) { + } } diff --git a/src/main/java/noppes/npcs/client/gui/model/GuiModelScale.java b/src/main/java/noppes/npcs/client/gui/model/GuiModelScale.java index 661b0b6ab..e00af5683 100644 --- a/src/main/java/noppes/npcs/client/gui/model/GuiModelScale.java +++ b/src/main/java/noppes/npcs/client/gui/model/GuiModelScale.java @@ -7,166 +7,159 @@ import noppes.npcs.entity.EntityCustomNpc; import noppes.npcs.entity.data.ModelData; import noppes.npcs.entity.data.ModelScalePart; -public class GuiModelScale extends GuiModelInterface implements ISliderListener{ +public class GuiModelScale extends GuiModelInterface implements ISliderListener { - private GuiScreen parent; - private int type = 0; - private int offset = 10; + private GuiScreen parent; + private int type = 0; + private int offset = 10; - private GuiNpcSlider scaleWidth; - private GuiNpcSlider scaleHeight; - private GuiNpcSlider scaleDepth; + private GuiNpcSlider scaleWidth; + private GuiNpcSlider scaleHeight; + private GuiNpcSlider scaleDepth; - public GuiModelScale(GuiScreen parent, ModelData data, EntityCustomNpc npc){ - super(npc); - this.parent = parent; - this.xOffset = 100; - ySize = 230; - } + public GuiModelScale(GuiScreen parent, ModelData data, EntityCustomNpc npc) { + super(npc); + this.parent = parent; + this.xOffset = 100; + ySize = 230; + } @Override public void initGui() { - super.initGui(); + super.initGui(); - int y = guiTop + 2; + int y = guiTop + 2; - addLabel(new GuiNpcLabel(20, "Head", guiLeft + 55, y + 5, 0xFFFFFF)); - if(type == 0){ - drawSlider(y, playerdata.modelScale.head); - y += 88; - } - else{ - addButton(new GuiNpcButton(0, guiLeft + 110, y , 60, 20, "Edit")); - y += 24; - } + addLabel(new GuiNpcLabel(20, "Head", guiLeft + 55, y + 5, 0xFFFFFF)); + if (type == 0) { + drawSlider(y, playerdata.modelScale.head); + y += 88; + } else { + addButton(new GuiNpcButton(0, guiLeft + 110, y, 60, 20, "Edit")); + y += 24; + } - addLabel(new GuiNpcLabel(21, "Body", guiLeft + 55, y + 5, 0xFFFFFF)); - if(type == 1){ - drawSlider(y, playerdata.modelScale.body); - y += 88; - } - else{ - addButton(new GuiNpcButton(1, guiLeft + 110, y , 60, 20, "Edit")); - y += 24; - } + addLabel(new GuiNpcLabel(21, "Body", guiLeft + 55, y + 5, 0xFFFFFF)); + if (type == 1) { + drawSlider(y, playerdata.modelScale.body); + y += 88; + } else { + addButton(new GuiNpcButton(1, guiLeft + 110, y, 60, 20, "Edit")); + y += 24; + } - addLabel(new GuiNpcLabel(22, "Arms", guiLeft + 55, y + 5, 0xFFFFFF)); - if(type == 2){ - drawSlider(y, playerdata.modelScale.arms); - y += 88; - } - else { - addButton(new GuiNpcButton(2, guiLeft + 110, y , 60, 20, "Edit")); - y += 24; - } + addLabel(new GuiNpcLabel(22, "Arms", guiLeft + 55, y + 5, 0xFFFFFF)); + if (type == 2) { + drawSlider(y, playerdata.modelScale.arms); + y += 88; + } else { + addButton(new GuiNpcButton(2, guiLeft + 110, y, 60, 20, "Edit")); + y += 24; + } - addLabel(new GuiNpcLabel(23, "Legs", guiLeft + 55, y + 5, 0xFFFFFF)); - if(type == 3){ - drawSlider(y, playerdata.modelScale.legs); - y += 88; - } - else{ - addButton(new GuiNpcButton(3, guiLeft + 110, y , 60, 20, "Edit")); - y += 24; - } + addLabel(new GuiNpcLabel(23, "Legs", guiLeft + 55, y + 5, 0xFFFFFF)); + if (type == 3) { + drawSlider(y, playerdata.modelScale.legs); + y += 88; + } else { + addButton(new GuiNpcButton(3, guiLeft + 110, y, 60, 20, "Edit")); + y += 24; + } } - private void drawSlider(int y, ModelScalePart config){ - y += 20; - addLabel(new GuiNpcLabel(10, "Width", guiLeft - 25 + offset, y + 5, 0xFFFFFF)); - scaleWidth = new GuiNpcSlider(this, 10, guiLeft + 50 + offset, y, config.scaleX - 0.5f); - addSlider(scaleWidth); - addButton(new GuiNpcButton(170, guiLeft + 8 + offset, y, 40, 20, "Reset")); - y += 22; - addLabel(new GuiNpcLabel(11, "Height", guiLeft - 25 + offset, y + 5, 0xFFFFFF)); - scaleHeight = new GuiNpcSlider(this, 11, guiLeft + 50 + offset, y, config.scaleY - 0.5f); - addSlider(scaleHeight); - addButton(new GuiNpcButton(171, guiLeft + 8 + offset, y, 40, 20, "Reset")); - y += 22; - addLabel(new GuiNpcLabel(12, "Depth", guiLeft - 25 + offset, y + 5, 0xFFFFFF)); - scaleDepth = new GuiNpcSlider(this, 12, guiLeft + 50 + offset, y, config.scaleZ - 0.5f); - addSlider(scaleDepth); - addButton(new GuiNpcButton(172, guiLeft + 8 + offset, y, 40, 20, "Reset")); + private void drawSlider(int y, ModelScalePart config) { + y += 20; + addLabel(new GuiNpcLabel(10, "Width", guiLeft - 25 + offset, y + 5, 0xFFFFFF)); + scaleWidth = new GuiNpcSlider(this, 10, guiLeft + 50 + offset, y, config.scaleX - 0.5f); + addSlider(scaleWidth); + addButton(new GuiNpcButton(170, guiLeft + 8 + offset, y, 40, 20, "Reset")); + y += 22; + addLabel(new GuiNpcLabel(11, "Height", guiLeft - 25 + offset, y + 5, 0xFFFFFF)); + scaleHeight = new GuiNpcSlider(this, 11, guiLeft + 50 + offset, y, config.scaleY - 0.5f); + addSlider(scaleHeight); + addButton(new GuiNpcButton(171, guiLeft + 8 + offset, y, 40, 20, "Reset")); + y += 22; + addLabel(new GuiNpcLabel(12, "Depth", guiLeft - 25 + offset, y + 5, 0xFFFFFF)); + scaleDepth = new GuiNpcSlider(this, 12, guiLeft + 50 + offset, y, config.scaleZ - 0.5f); + addSlider(scaleDepth); + addButton(new GuiNpcButton(172, guiLeft + 8 + offset, y, 40, 20, "Reset")); } @Override protected void actionPerformed(GuiButton btn) { - super.actionPerformed(btn); + super.actionPerformed(btn); - if(btn.id < 4){ - type = btn.id; - initGui(); - } - else{ - // Resetting Type - ModelScalePart config = playerdata.modelScale.head; - if(type == 1) - config = playerdata.modelScale.body; - else if(type == 2) - config = playerdata.modelScale.arms; - else if(type == 3) - config = playerdata.modelScale.legs; + if (btn.id < 4) { + type = btn.id; + initGui(); + } else { + // Resetting Type + ModelScalePart config = playerdata.modelScale.head; + if (type == 1) + config = playerdata.modelScale.body; + else if (type == 2) + config = playerdata.modelScale.arms; + else if (type == 3) + config = playerdata.modelScale.legs; - if(btn.id == 170){ - config.scaleX = 1.0f; - scaleWidth.sliderValue = 0.5f; - int percent = (int) (50 + scaleWidth.sliderValue * 100); - scaleWidth.setString(percent + "%"); - npc.updateHitbox(); - } - else if(btn.id == 171){ - config.scaleY = 1.0f; - scaleHeight.sliderValue = 0.5f; - int percent = (int) (50 + scaleHeight.sliderValue * 100); - scaleHeight.setString(percent + "%"); - npc.updateHitbox(); - } - else if(btn.id == 172){ - config.scaleZ = 1.0f; - scaleDepth.sliderValue = 0.5f; - int percent = (int) (50 + scaleDepth.sliderValue * 100); - scaleDepth.setString(percent + "%"); - npc.updateHitbox(); - } - } + if (btn.id == 170) { + config.scaleX = 1.0f; + scaleWidth.sliderValue = 0.5f; + int percent = (int) (50 + scaleWidth.sliderValue * 100); + scaleWidth.setString(percent + "%"); + npc.updateHitbox(); + } else if (btn.id == 171) { + config.scaleY = 1.0f; + scaleHeight.sliderValue = 0.5f; + int percent = (int) (50 + scaleHeight.sliderValue * 100); + scaleHeight.setString(percent + "%"); + npc.updateHitbox(); + } else if (btn.id == 172) { + config.scaleZ = 1.0f; + scaleDepth.sliderValue = 0.5f; + int percent = (int) (50 + scaleDepth.sliderValue * 100); + scaleDepth.setString(percent + "%"); + npc.updateHitbox(); + } + } } @Override - public void close(){ + public void close() { this.mc.displayGuiScreen(parent); } - @Override - public void mouseDragged(GuiNpcSlider slider) { - int percent = (int) (50 + slider.sliderValue * 100); - slider.setString(percent + "%"); - ModelScalePart config = playerdata.modelScale.head; - if(type == 1) - config = playerdata.modelScale.body; - else if(type == 2) - config = playerdata.modelScale.arms; - else if(type == 3) - config = playerdata.modelScale.legs; + @Override + public void mouseDragged(GuiNpcSlider slider) { + int percent = (int) (50 + slider.sliderValue * 100); + slider.setString(percent + "%"); + ModelScalePart config = playerdata.modelScale.head; + if (type == 1) + config = playerdata.modelScale.body; + else if (type == 2) + config = playerdata.modelScale.arms; + else if (type == 3) + config = playerdata.modelScale.legs; - if(slider.id == 10) - config.scaleX = slider.sliderValue + 0.5f; - if(slider.id == 11) - config.scaleY = slider.sliderValue + 0.5f; - if(slider.id == 12) - config.scaleZ = slider.sliderValue + 0.5f; - npc.updateHitbox(); - } + if (slider.id == 10) + config.scaleX = slider.sliderValue + 0.5f; + if (slider.id == 11) + config.scaleY = slider.sliderValue + 0.5f; + if (slider.id == 12) + config.scaleZ = slider.sliderValue + 0.5f; + npc.updateHitbox(); + } - @Override - public void mousePressed(GuiNpcSlider slider) { - allowRotate = false; - } + @Override + public void mousePressed(GuiNpcSlider slider) { + allowRotate = false; + } - @Override - public void mouseReleased(GuiNpcSlider slider) { + @Override + public void mouseReleased(GuiNpcSlider slider) { allowRotate = true; - } + } } diff --git a/src/main/java/noppes/npcs/client/gui/model/GuiPresetSave.java b/src/main/java/noppes/npcs/client/gui/model/GuiPresetSave.java index 99a396853..ccc1c4485 100644 --- a/src/main/java/noppes/npcs/client/gui/model/GuiPresetSave.java +++ b/src/main/java/noppes/npcs/client/gui/model/GuiPresetSave.java @@ -9,41 +9,44 @@ import noppes.npcs.client.gui.util.GuiNpcButton; import noppes.npcs.client.gui.util.GuiNpcTextField; import noppes.npcs.entity.data.ModelData; -public class GuiPresetSave extends GuiNPCInterface{ - private ModelData data; - private GuiScreen parent; +public class GuiPresetSave extends GuiNPCInterface { + private ModelData data; + private GuiScreen parent; + + public GuiPresetSave(GuiScreen parent, ModelData data) { + this.data = data; + this.parent = parent; + xSize = 200; + this.drawDefaultBackground = true; + } + + @Override + public void initGui() { + super.initGui(); + this.addTextField(new GuiNpcTextField(0, this, guiLeft, guiTop + 70, 200, 20, "")); + this.addButton(new GuiNpcButton(0, guiLeft, guiTop + 100, 98, 20, "Save")); + this.addButton(new GuiNpcButton(1, guiLeft + 100, guiTop + 100, 98, 20, "Cancel")); + } - public GuiPresetSave(GuiScreen parent, ModelData data){ - this.data = data; - this.parent = parent; - xSize = 200; - this.drawDefaultBackground = true; - } - @Override - public void initGui(){ - super.initGui(); - this.addTextField(new GuiNpcTextField(0, this, guiLeft, guiTop + 70,200, 20, "")); - this.addButton(new GuiNpcButton(0,guiLeft, guiTop + 100,98, 20, "Save")); - this.addButton(new GuiNpcButton(1,guiLeft + 100, guiTop + 100, 98, 20, "Cancel")); - } @Override protected void actionPerformed(GuiButton btn) { - super.actionPerformed(btn); - GuiNpcButton button = (GuiNpcButton) btn; - if(button.id == 0){ - String name = this.getTextField(0).getText().trim(); - if(name.isEmpty()) - return; - Preset preset = new Preset(); - preset.name = name; - preset.data = data.copy(); - PresetController.instance.addPreset(preset); - } - mc.displayGuiScreen(parent); + super.actionPerformed(btn); + GuiNpcButton button = (GuiNpcButton) btn; + if (button.id == 0) { + String name = this.getTextField(0).getText().trim(); + if (name.isEmpty()) + return; + Preset preset = new Preset(); + preset.name = name; + preset.data = data.copy(); + PresetController.instance.addPreset(preset); + } + mc.displayGuiScreen(parent); } - @Override - public void save() { + + @Override + public void save() { - } + } } diff --git a/src/main/java/noppes/npcs/client/gui/model/GuiPresetSelection.java b/src/main/java/noppes/npcs/client/gui/model/GuiPresetSelection.java index f8a2e5ad4..06c21a732 100644 --- a/src/main/java/noppes/npcs/client/gui/model/GuiPresetSelection.java +++ b/src/main/java/noppes/npcs/client/gui/model/GuiPresetSelection.java @@ -21,53 +21,49 @@ import org.lwjgl.opengl.GL11; import java.util.Collections; import java.util.Vector; -public class GuiPresetSelection extends GuiNPCInterface -{ - private GuiNPCStringSlot slot; - private GuiCreationScreen parent; - private NBTTagCompound prevData; - private ModelData playerdata; - private EntityCustomNpc npc; +public class GuiPresetSelection extends GuiNPCInterface { + private GuiNPCStringSlot slot; + private GuiCreationScreen parent; + private NBTTagCompound prevData; + private ModelData playerdata; + private EntityCustomNpc npc; - public GuiPresetSelection(GuiCreationScreen parent, ModelData playerdata) - { - this.parent = parent; - this.playerdata = playerdata; - prevData = playerdata.writeToNBT(); - drawDefaultBackground = false; - npc = new EntityCustomNpc(Minecraft.getMinecraft().theWorld); - npc.modelData = playerdata.copy(); + public GuiPresetSelection(GuiCreationScreen parent, ModelData playerdata) { + this.parent = parent; + this.playerdata = playerdata; + prevData = playerdata.writeToNBT(); + drawDefaultBackground = false; + npc = new EntityCustomNpc(Minecraft.getMinecraft().theWorld); + npc.modelData = playerdata.copy(); - PresetController.instance.load(); + PresetController.instance.load(); } - public void initGui() - { + public void initGui() { super.initGui(); Vector list = new Vector(); - for(Preset preset : PresetController.instance.presets.values()) - list.add(preset.name); + for (Preset preset : PresetController.instance.presets.values()) + list.add(preset.name); - Collections.sort(list,String.CASE_INSENSITIVE_ORDER); - slot = new GuiNPCStringSlot(list,this,false,18); + Collections.sort(list, String.CASE_INSENSITIVE_ORDER); + slot = new GuiNPCStringSlot(list, this, false, 18); slot.registerScrollButtons(4, 5); - this.buttonList.add(new GuiNpcButton(2, width / 2 - 100, height - 44,98, 20, "Back")); - this.buttonList.add(new GuiNpcButton(3, width / 2 + 2, height - 44,98, 20, "Load")); - this.buttonList.add(new GuiNpcButton(4, width / 2 - 49, height - 22,98, 20, "Remove")); + this.buttonList.add(new GuiNpcButton(2, width / 2 - 100, height - 44, 98, 20, "Back")); + this.buttonList.add(new GuiNpcButton(3, width / 2 + 2, height - 44, 98, 20, "Load")); + this.buttonList.add(new GuiNpcButton(4, width / 2 - 49, height - 22, 98, 20, "Remove")); } - public void drawScreen(int i, int j, float f) - { - EntityLivingBase entity = npc.modelData.getEntity(npc); - if(entity == null) - entity = this.npc; - else - EntityUtil.Copy(npc, entity); + public void drawScreen(int i, int j, float f) { + EntityLivingBase entity = npc.modelData.getEntity(npc); + if (entity == null) + entity = this.npc; + else + EntityUtil.Copy(npc, entity); - int l = (width/2)-180; - int i1 = (height/2) - 90; + int l = (width / 2) - 180; + int i1 = (height / 2) - 90; GL11.glEnable(32826 /*GL_RESCALE_NORMAL_EXT*/); GL11.glEnable(2903 /*GL_COLOR_MATERIAL*/); GL11.glPushMatrix(); @@ -78,15 +74,15 @@ public class GuiPresetSelection extends GuiNPCInterface float f3 = entity.rotationYaw; float f4 = entity.rotationPitch; float f7 = entity.rotationYawHead; - float f5 = (float)(l + 33) - i; - float f6 = (float)((i1 + 131) - 50) - j; + float f5 = (float) (l + 33) - i; + float f6 = (float) ((i1 + 131) - 50) - j; GL11.glRotatef(135F, 0.0F, 1.0F, 0.0F); RenderHelper.enableStandardItemLighting(); GL11.glRotatef(-135F, 0.0F, 1.0F, 0.0F); - GL11.glRotatef(-(float)Math.atan(f6 / 40F) * 20F, 1.0F, 0.0F, 0.0F); - entity.renderYawOffset = (float)Math.atan(f5 / 40F) * 20F; - entity.rotationYaw = (float)Math.atan(f5 / 40F) * 40F; - entity.rotationPitch = -(float)Math.atan(f6 / 40F) * 20F; + GL11.glRotatef(-(float) Math.atan(f6 / 40F) * 20F, 1.0F, 0.0F, 0.0F); + entity.renderYawOffset = (float) Math.atan(f5 / 40F) * 20F; + entity.rotationYaw = (float) Math.atan(f5 / 40F) * 40F; + entity.rotationPitch = -(float) Math.atan(f6 / 40F) * 20F; entity.rotationYawHead = entity.rotationYaw; GL11.glTranslatef(0.0F, entity.yOffset, 0.0F); RenderManager.instance.playerViewY = 180F; @@ -102,62 +98,62 @@ public class GuiPresetSelection extends GuiNPCInterface OpenGlHelper.setActiveTexture(OpenGlHelper.lightmapTexUnit); GL11.glDisable(GL11.GL_TEXTURE_2D); OpenGlHelper.setActiveTexture(OpenGlHelper.defaultTexUnit); - slot.drawScreen(i, j, f); + slot.drawScreen(i, j, f); super.drawScreen(i, j, f); } - public void elementClicked(){ - Preset preset = PresetController.instance.getPreset(slot.selected); - npc.modelData.readFromNBT(preset.data.writeToNBT()); + + public void elementClicked() { + Preset preset = PresetController.instance.getPreset(slot.selected); + npc.modelData.readFromNBT(preset.data.writeToNBT()); } - public void doubleClicked(){ - playerdata.readFromNBT(npc.modelData.writeToNBT()); + + public void doubleClicked() { + playerdata.readFromNBT(npc.modelData.writeToNBT()); close(); } @Override - public void keyTyped(char par1, int par2) - { - if (par2 == 1) - { + public void keyTyped(char par1, int par2) { + if (par2 == 1) { close(); } } - public void close() { - mc.displayGuiScreen(parent); - } - public FontRenderer getFontRenderer() { - return this.fontRendererObj; - } - - @Override - protected void actionPerformed(GuiButton button) - { - GuiNpcButton guibutton = (GuiNpcButton) button; - if(guibutton.id == 2){ - close(); - } - if(guibutton.id == 3){ - playerdata.readFromNBT(npc.modelData.writeToNBT()); - close(); - } - if(guibutton.id == 4){ - PresetController.instance.removePreset(slot.selected); - Vector list = new Vector(); - for(Preset preset : PresetController.instance.presets.values()) - list.add(preset.name); - - Collections.sort(list,String.CASE_INSENSITIVE_ORDER); - slot.setList(list); - slot.selected = ""; - } + public void close() { + mc.displayGuiScreen(parent); } - @Override - public void save() { + public FontRenderer getFontRenderer() { + return this.fontRendererObj; + } + + @Override + protected void actionPerformed(GuiButton button) { + GuiNpcButton guibutton = (GuiNpcButton) button; + if (guibutton.id == 2) { + close(); + } + if (guibutton.id == 3) { + playerdata.readFromNBT(npc.modelData.writeToNBT()); + close(); + } + if (guibutton.id == 4) { + PresetController.instance.removePreset(slot.selected); + Vector list = new Vector(); + for (Preset preset : PresetController.instance.presets.values()) + list.add(preset.name); + + Collections.sort(list, String.CASE_INSENSITIVE_ORDER); + slot.setList(list); + slot.selected = ""; + } + } + + @Override + public void save() { - } + } } diff --git a/src/main/java/noppes/npcs/client/gui/player/GuiAnvilRecipes.java b/src/main/java/noppes/npcs/client/gui/player/GuiAnvilRecipes.java index c1c78865a..11034b06c 100644 --- a/src/main/java/noppes/npcs/client/gui/player/GuiAnvilRecipes.java +++ b/src/main/java/noppes/npcs/client/gui/player/GuiAnvilRecipes.java @@ -67,7 +67,7 @@ public class GuiAnvilRecipes extends GuiNPCInterface { @Override public void keyTyped(char c, int i) { super.keyTyped(c, i); - if(search.equals(getTextField(3).getText())) + if (search.equals(getTextField(3).getText())) return; search = getTextField(3).getText().toLowerCase(); recipes = getSearchList(); @@ -76,19 +76,19 @@ public class GuiAnvilRecipes extends GuiNPCInterface { } private List getSearchList() { - if(search.isEmpty()) { + if (search.isEmpty()) { return new ArrayList(RecipeController.Instance.anvilRecipes.values()); } List list = new ArrayList(); - for(RecipeAnvil recipe : RecipeController.Instance.anvilRecipes.values()) { + for (RecipeAnvil recipe : RecipeController.Instance.anvilRecipes.values()) { ItemStack repairItem = recipe.itemToRepair; - if(repairItem == null) + if (repairItem == null) continue; - if(repairItem.getDisplayName() == null) + if (repairItem.getDisplayName() == null) continue; - if(repairItem.getDisplayName().trim().isEmpty()) + if (repairItem.getDisplayName().trim().isEmpty()) continue; - if(repairItem.getDisplayName().toLowerCase().contains(search)) + if (repairItem.getDisplayName().toLowerCase().contains(search)) list.add(recipe); } return list; @@ -96,15 +96,15 @@ public class GuiAnvilRecipes extends GuiNPCInterface { @Override protected void actionPerformed(GuiButton button) { - if(!button.enabled) + if (!button.enabled) return; - if(button == btnRight) { - if(page > 0) + if (button == btnRight) { + if (page > 0) page--; } - if(button == btnLeft) { + if (button == btnLeft) { int maxPages = MathHelper.ceiling_float_int(recipes.size() / 8.0F); - if(page < maxPages - 1) + if (page < maxPages - 1) page++; } updateButton(); @@ -113,6 +113,7 @@ public class GuiAnvilRecipes extends GuiNPCInterface { private static class ItemOverlayData { public final int x, y; public final ItemStack item; + public ItemOverlayData(int x, int y, ItemStack item) { this.x = x; this.y = y; @@ -161,7 +162,7 @@ public class GuiAnvilRecipes extends GuiNPCInterface { for (int i = startIndex; i < endIndex; i++) { RecipeAnvil recipe = recipes.get(i); - if(!recipe.isValid()) + if (!recipe.isValid()) continue; int localIndex = i - startIndex; // 0 to 7 @@ -190,8 +191,8 @@ public class GuiAnvilRecipes extends GuiNPCInterface { } drawItem(halfItem, slotX + 1, slotY + 1, mouseX, mouseY); // Instead of drawing overlay immediately, add to list. - if (func_146978_c((slotX+1) - guiLeft, (slotY+1) - guiTop, 16, 16, mouseX, mouseY)) { - itemOverlays.add(new ItemOverlayData(slotX+1, slotY+1, halfItem)); + if (func_146978_c((slotX + 1) - guiLeft, (slotY + 1) - guiTop, 16, 16, mouseX, mouseY)) { + itemOverlays.add(new ItemOverlayData(slotX + 1, slotY + 1, halfItem)); } } @@ -199,8 +200,8 @@ public class GuiAnvilRecipes extends GuiNPCInterface { ItemStack material = recipe.repairMaterial; if (material != null) { drawItem(material, slotX + 23, slotY + 1, mouseX, mouseY); - if (func_146978_c((slotX+23) - guiLeft, (slotY+1) - guiTop, 16, 16, mouseX, mouseY)) { - itemOverlays.add(new ItemOverlayData(slotX+23, slotY+1, material)); + if (func_146978_c((slotX + 23) - guiLeft, (slotY + 1) - guiTop, 16, 16, mouseX, mouseY)) { + itemOverlays.add(new ItemOverlayData(slotX + 23, slotY + 1, material)); } } @@ -230,12 +231,12 @@ public class GuiAnvilRecipes extends GuiNPCInterface { textOverlays.add(new TextOverlayData(percentTextX, percentTextY, percentWidth, fontRendererObj.FONT_HEIGHT, String.valueOf(recipe.getRepairPercentage()))); } - if(!recipe.availability.isDefault()){ - if(!recipe.availability.isAvailable(this.player)){ + if (!recipe.availability.isDefault()) { + if (!recipe.availability.isAvailable(this.player)) { String helpChar = "?"; float scale = 1F; // Adjust for a very small size - int questionWidth = (int)(fontRendererObj.getStringWidth(helpChar) * scale); - int questionHeight = (int)(fontRendererObj.FONT_HEIGHT * scale); + int questionWidth = (int) (fontRendererObj.getStringWidth(helpChar) * scale); + int questionHeight = (int) (fontRendererObj.FONT_HEIGHT * scale); // Center the "?" under the percentage text. int questionX = percentCenterX - (questionWidth / 2) - 1 - row; int questionY = percentTextY + fontRendererObj.FONT_HEIGHT; // You can tweak the vertical offset if needed @@ -255,8 +256,8 @@ public class GuiAnvilRecipes extends GuiNPCInterface { // Draw a very small "?" under the percentage text. String helpChar = "!"; float scale = 1F; // Adjust for a very small size - int questionWidth = (int)(fontRendererObj.getStringWidth(helpChar) * scale); - int questionHeight = (int)(fontRendererObj.FONT_HEIGHT * scale); + int questionWidth = (int) (fontRendererObj.getStringWidth(helpChar) * scale); + int questionHeight = (int) (fontRendererObj.FONT_HEIGHT * scale); // Center the "?" under the percentage text. int questionX = percentCenterX - (questionWidth / 2) - 1 - row; int questionY = percentTextY + fontRendererObj.FONT_HEIGHT; // You can tweak the vertical offset if needed @@ -280,7 +281,7 @@ public class GuiAnvilRecipes extends GuiNPCInterface { int digitCount = xpCostStr.length(); float xpScale = 1.0F - 0.1F * (digitCount - 1); int rawTextWidth = fontRendererObj.getStringWidth(xpCostStr); - int scaledTextWidth = (int)(rawTextWidth * xpScale); + int scaledTextWidth = (int) (rawTextWidth * xpScale); int xpCenterX = (col == 0) ? (guiLeft + 76) : (guiLeft + 76 + colSpacing); int xpTextX = xpCenterX - (scaledTextWidth / 2) + col; int xpTextY = slotY - 4 + row; @@ -305,6 +306,7 @@ public class GuiAnvilRecipes extends GuiNPCInterface { this.drawHoveringText(tod.textLines, mouseX, mouseY, this.fontRendererObj); } } + protected boolean func_146978_c(int p_146978_1_, int p_146978_2_, int p_146978_3_, int p_146978_4_, int p_146978_5_, int p_146978_6_) { int k1 = this.guiLeft; int l1 = this.guiTop; @@ -318,8 +320,8 @@ public class GuiAnvilRecipes extends GuiNPCInterface { return String.valueOf(xp); } double xpK = xp / 1000.0; - if (xpK == (int)xpK) { - return ((int)xpK) + "K"; + if (xpK == (int) xpK) { + return ((int) xpK) + "K"; } else { return String.format("%.1fK", xpK); } @@ -339,5 +341,6 @@ public class GuiAnvilRecipes extends GuiNPCInterface { } @Override - public void save() {} + public void save() { + } } diff --git a/src/main/java/noppes/npcs/client/gui/player/GuiBigSign.java b/src/main/java/noppes/npcs/client/gui/player/GuiBigSign.java index fb4554bed..5e30f3e22 100644 --- a/src/main/java/noppes/npcs/client/gui/player/GuiBigSign.java +++ b/src/main/java/noppes/npcs/client/gui/player/GuiBigSign.java @@ -5,17 +5,18 @@ import kamkeel.npcs.network.packets.player.SaveSignPacket; import noppes.npcs.blocks.tiles.TileBigSign; import noppes.npcs.client.gui.SubGuiNpcTextArea; -public class GuiBigSign extends SubGuiNpcTextArea{ - public TileBigSign tile; - public GuiBigSign(int x, int y, int z) { - super(""); - tile = (TileBigSign) player.worldObj.getTileEntity(x, y, z); - text = tile.getText(); - } +public class GuiBigSign extends SubGuiNpcTextArea { + public TileBigSign tile; - @Override - public void close(){ - super.close(); - PacketClient.sendClient(new SaveSignPacket(tile.xCoord, tile.yCoord, tile.zCoord, text)); - } + public GuiBigSign(int x, int y, int z) { + super(""); + tile = (TileBigSign) player.worldObj.getTileEntity(x, y, z); + text = tile.getText(); + } + + @Override + public void close() { + super.close(); + PacketClient.sendClient(new SaveSignPacket(tile.xCoord, tile.yCoord, tile.zCoord, text)); + } } diff --git a/src/main/java/noppes/npcs/client/gui/player/GuiBook.java b/src/main/java/noppes/npcs/client/gui/player/GuiBook.java index 730427a24..e7fa742c1 100644 --- a/src/main/java/noppes/npcs/client/gui/player/GuiBook.java +++ b/src/main/java/noppes/npcs/client/gui/player/GuiBook.java @@ -23,8 +23,7 @@ import org.lwjgl.input.Keyboard; import org.lwjgl.opengl.GL11; @SideOnly(Side.CLIENT) -public class GuiBook extends GuiScreen -{ +public class GuiBook extends GuiScreen { private static final Logger logger = LogManager.getLogger(); private static final ResourceLocation bookGuiTextures = new ResourceLocation("textures/gui/book.png"); /** @@ -60,33 +59,29 @@ public class GuiBook extends GuiScreen private int x, y, z; - public GuiBook(EntityPlayer par1EntityPlayer, ItemStack item, int x, int y, int z){ - this.x = x; - this.y = y; - this.z = z; + public GuiBook(EntityPlayer par1EntityPlayer, ItemStack item, int x, int y, int z) { + this.x = x; + this.y = y; + this.z = z; this.editingPlayer = par1EntityPlayer; this.bookObj = item; this.bookIsUnsigned = item.getItem() == Items.writable_book; - if (item.hasTagCompound()) - { + if (item.hasTagCompound()) { NBTTagCompound nbttagcompound = item.getTagCompound(); this.bookPages = nbttagcompound.getTagList("pages", 8); - if (this.bookPages != null) - { - this.bookPages = (NBTTagList)this.bookPages.copy(); + if (this.bookPages != null) { + this.bookPages = (NBTTagList) this.bookPages.copy(); this.bookTotalPages = this.bookPages.tagCount(); - if (this.bookTotalPages < 1) - { + if (this.bookTotalPages < 1) { this.bookTotalPages = 1; } } } - if (this.bookPages == null && bookIsUnsigned) - { + if (this.bookPages == null && bookIsUnsigned) { this.bookPages = new NBTTagList(); this.bookPages.appendTag(new NBTTagString("")); this.bookTotalPages = 1; @@ -96,29 +91,29 @@ public class GuiBook extends GuiScreen /** * Called from the main game loop to update the screen. */ - public void updateScreen(){ + public void updateScreen() { super.updateScreen(); ++this.updateCount; } + @Override - public boolean doesGuiPauseGame(){ + public boolean doesGuiPauseGame() { return false; } /** * Adds the buttons (and other controls) to the screen in question. */ - public void initGui(){ + public void initGui() { this.buttonList.clear(); Keyboard.enableRepeatEvents(true); - if (this.bookIsUnsigned){ + if (this.bookIsUnsigned) { this.buttonList.add(this.buttonSign = new GuiButton(3, this.width / 2 - 100, 4 + this.bookImageHeight, 98, 20, I18n.format("book.signButton", new Object[0]))); this.buttonList.add(this.buttonDone = new GuiButton(0, this.width / 2 + 2, 4 + this.bookImageHeight, 98, 20, I18n.format("gui.done", new Object[0]))); this.buttonList.add(this.buttonFinalize = new GuiButton(5, this.width / 2 - 100, 4 + this.bookImageHeight, 98, 20, I18n.format("book.finalizeButton", new Object[0]))); this.buttonList.add(this.buttonCancel = new GuiButton(4, this.width / 2 + 2, 4 + this.bookImageHeight, 98, 20, I18n.format("gui.cancel", new Object[0]))); - } - else{ + } else { this.buttonList.add(this.buttonDone = new GuiButton(0, this.width / 2 - 100, 4 + this.bookImageHeight, 200, 20, I18n.format("gui.done", new Object[0]))); } @@ -132,17 +127,16 @@ public class GuiBook extends GuiScreen /** * Called when the screen is unloaded. Used to disable keyboard repeat events */ - public void onGuiClosed(){ + public void onGuiClosed() { Keyboard.enableRepeatEvents(false); } - private void updateButtons(){ + private void updateButtons() { this.buttonNextPage.visible = !this.field_146480_s && (this.currPage < this.bookTotalPages - 1 || this.bookIsUnsigned); this.buttonPreviousPage.visible = !this.field_146480_s && this.currPage > 0; this.buttonDone.visible = !this.bookIsUnsigned || !this.field_146480_s; - if (this.bookIsUnsigned) - { + if (this.bookIsUnsigned) { this.buttonSign.visible = !this.field_146480_s; this.buttonCancel.visible = this.field_146480_s; this.buttonFinalize.visible = this.field_146480_s; @@ -150,11 +144,11 @@ public class GuiBook extends GuiScreen } } - private void sendBookToServer(boolean sign){ - if (this.bookIsUnsigned && this.field_146481_r){ - if (this.bookPages != null){ + private void sendBookToServer(boolean sign) { + if (this.bookIsUnsigned && this.field_146481_r) { + if (this.bookPages != null) { - while (this.bookPages.tagCount() > 1){ + while (this.bookPages.tagCount() > 1) { String s = this.bookPages.getStringTagAt(this.bookPages.tagCount() - 1); if (s.length() != 0) @@ -163,16 +157,14 @@ public class GuiBook extends GuiScreen this.bookPages.removeTag(this.bookPages.tagCount() - 1); } - if (this.bookObj.hasTagCompound()){ + if (this.bookObj.hasTagCompound()) { NBTTagCompound nbttagcompound = this.bookObj.getTagCompound(); nbttagcompound.setTag("pages", this.bookPages); - } - else{ + } else { this.bookObj.setTagInfo("pages", this.bookPages); } - if (sign) - { + if (sign) { this.bookObj.setTagInfo("author", new NBTTagString(this.editingPlayer.getCommandSenderName())); this.bookObj.setTagInfo("title", new NBTTagString(this.bookTitle.trim())); this.bookObj.func_150996_a(Items.written_book); @@ -184,48 +176,31 @@ public class GuiBook extends GuiScreen } } - protected void actionPerformed(GuiButton p_146284_1_){ - if (p_146284_1_.enabled) - { - if (p_146284_1_.id == 0) - { - this.mc.displayGuiScreen((GuiScreen)null); + protected void actionPerformed(GuiButton p_146284_1_) { + if (p_146284_1_.enabled) { + if (p_146284_1_.id == 0) { + this.mc.displayGuiScreen((GuiScreen) null); this.sendBookToServer(false); - } - else if (p_146284_1_.id == 3 && this.bookIsUnsigned) - { + } else if (p_146284_1_.id == 3 && this.bookIsUnsigned) { this.field_146480_s = true; - } - else if (p_146284_1_.id == 1) - { - if (this.currPage < this.bookTotalPages - 1) - { + } else if (p_146284_1_.id == 1) { + if (this.currPage < this.bookTotalPages - 1) { ++this.currPage; - } - else if (this.bookIsUnsigned) - { + } else if (this.bookIsUnsigned) { this.addNewPage(); - if (this.currPage < this.bookTotalPages - 1) - { + if (this.currPage < this.bookTotalPages - 1) { ++this.currPage; } } - } - else if (p_146284_1_.id == 2) - { - if (this.currPage > 0) - { + } else if (p_146284_1_.id == 2) { + if (this.currPage > 0) { --this.currPage; } - } - else if (p_146284_1_.id == 5 && this.field_146480_s) - { + } else if (p_146284_1_.id == 5 && this.field_146480_s) { this.sendBookToServer(true); - this.mc.displayGuiScreen((GuiScreen)null); - } - else if (p_146284_1_.id == 4 && this.field_146480_s) - { + this.mc.displayGuiScreen((GuiScreen) null); + } else if (p_146284_1_.id == 4 && this.field_146480_s) { this.field_146480_s = false; } @@ -233,9 +208,8 @@ public class GuiBook extends GuiScreen } } - private void addNewPage(){ - if (this.bookPages != null && this.bookPages.tagCount() < 50) - { + private void addNewPage() { + if (this.bookPages != null && this.bookPages.tagCount() < 50) { this.bookPages.appendTag(new NBTTagString("")); ++this.bookTotalPages; this.field_146481_r = true; @@ -245,17 +219,13 @@ public class GuiBook extends GuiScreen /** * Fired when a key is typed. This is the equivalent of KeyListener.keyTyped(KeyEvent e). */ - protected void keyTyped(char par1, int par2){ + protected void keyTyped(char par1, int par2) { super.keyTyped(par1, par2); - if (this.bookIsUnsigned) - { - if (this.field_146480_s) - { + if (this.bookIsUnsigned) { + if (this.field_146480_s) { this.func_146460_c(par1, par2); - } - else - { + } else { this.keyTypedInBook(par1, par2); } } @@ -264,20 +234,17 @@ public class GuiBook extends GuiScreen /** * Processes keystrokes when editing the text of a book */ - private void keyTypedInBook(char p_146463_1_, int p_146463_2_){ - switch (p_146463_1_) - { + private void keyTypedInBook(char p_146463_1_, int p_146463_2_) { + switch (p_146463_1_) { case 22: this.func_146459_b(GuiScreen.getClipboardString()); return; default: - switch (p_146463_2_) - { + switch (p_146463_2_) { case 14: String s = this.func_146456_p(); - if (s.length() > 0) - { + if (s.length() > 0) { this.func_146457_a(s.substring(0, s.length() - 1)); } @@ -287,20 +254,17 @@ public class GuiBook extends GuiScreen this.func_146459_b("\n"); return; default: - if (ChatAllowedCharacters.isAllowedCharacter(p_146463_1_)) - { + if (ChatAllowedCharacters.isAllowedCharacter(p_146463_1_)) { this.func_146459_b(Character.toString(p_146463_1_)); } } } } - private void func_146460_c(char p_146460_1_, int p_146460_2_){ - switch (p_146460_2_) - { + private void func_146460_c(char p_146460_1_, int p_146460_2_) { + switch (p_146460_2_) { case 14: - if (!this.bookTitle.isEmpty()) - { + if (!this.bookTitle.isEmpty()) { this.bookTitle = this.bookTitle.substring(0, this.bookTitle.length() - 1); this.updateButtons(); } @@ -308,16 +272,14 @@ public class GuiBook extends GuiScreen return; case 28: case 156: - if (!this.bookTitle.isEmpty()) - { + if (!this.bookTitle.isEmpty()) { this.sendBookToServer(true); - this.mc.displayGuiScreen((GuiScreen)null); + this.mc.displayGuiScreen((GuiScreen) null); } return; default: - if (this.bookTitle.length() < 16 && ChatAllowedCharacters.isAllowedCharacter(p_146460_1_)) - { + if (this.bookTitle.length() < 16 && ChatAllowedCharacters.isAllowedCharacter(p_146460_1_)) { this.bookTitle = this.bookTitle + Character.toString(p_146460_1_); this.updateButtons(); this.field_146481_r = true; @@ -325,25 +287,23 @@ public class GuiBook extends GuiScreen } } - private String func_146456_p(){ + private String func_146456_p() { return this.bookPages != null && this.currPage >= 0 && this.currPage < this.bookPages.tagCount() ? this.bookPages.getStringTagAt(this.currPage) : ""; } - private void func_146457_a(String p_146457_1_){ - if (this.bookPages != null && this.currPage >= 0 && this.currPage < this.bookPages.tagCount()) - { + private void func_146457_a(String p_146457_1_) { + if (this.bookPages != null && this.currPage >= 0 && this.currPage < this.bookPages.tagCount()) { this.bookPages.func_150304_a(this.currPage, new NBTTagString(p_146457_1_)); this.field_146481_r = true; } } - private void func_146459_b(String p_146459_1_){ + private void func_146459_b(String p_146459_1_) { String s1 = this.func_146456_p(); String s2 = s1 + p_146459_1_; int i = this.fontRendererObj.splitStringWidth(s2 + "" + EnumChatFormatting.BLACK + "_", 118); - if (i <= 118 && s2.length() < 256) - { + if (i <= 118 && s2.length() < 256) { this.func_146457_a(s2); } } @@ -351,7 +311,7 @@ public class GuiBook extends GuiScreen /** * Draws the screen and all the components in it. */ - public void drawScreen(int par1, int par2, float par3){ + public void drawScreen(int par1, int par2, float par3) { GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); this.mc.getTextureManager().bindTexture(bookGuiTextures); int k = (this.width - this.bookImageWidth) / 2; @@ -361,18 +321,13 @@ public class GuiBook extends GuiScreen String s1; int l; - if (this.field_146480_s) - { + if (this.field_146480_s) { s = this.bookTitle; - if (this.bookIsUnsigned) - { - if (this.updateCount / 6 % 2 == 0) - { + if (this.bookIsUnsigned) { + if (this.updateCount / 6 % 2 == 0) { s = s + "" + EnumChatFormatting.BLACK + "_"; - } - else - { + } else { s = s + "" + EnumChatFormatting.GRAY + "_"; } } @@ -382,34 +337,25 @@ public class GuiBook extends GuiScreen this.fontRendererObj.drawString(s1, k + 36 + (116 - l) / 2, b0 + 16 + 16, 0); int i1 = this.fontRendererObj.getStringWidth(s); this.fontRendererObj.drawString(s, k + 36 + (116 - i1) / 2, b0 + 48, 0); - String s2 = I18n.format("book.byAuthor", new Object[] {this.editingPlayer.getCommandSenderName()}); + String s2 = I18n.format("book.byAuthor", new Object[]{this.editingPlayer.getCommandSenderName()}); int j1 = this.fontRendererObj.getStringWidth(s2); this.fontRendererObj.drawString(EnumChatFormatting.DARK_GRAY + s2, k + 36 + (116 - j1) / 2, b0 + 48 + 10, 0); String s3 = I18n.format("book.finalizeWarning", new Object[0]); this.fontRendererObj.drawSplitString(s3, k + 36, b0 + 80, 116, 0); - } - else - { - s = I18n.format("book.pageIndicator", new Object[] {Integer.valueOf(this.currPage + 1), Integer.valueOf(this.bookTotalPages)}); + } else { + s = I18n.format("book.pageIndicator", new Object[]{Integer.valueOf(this.currPage + 1), Integer.valueOf(this.bookTotalPages)}); s1 = ""; - if (this.bookPages != null && this.currPage >= 0 && this.currPage < this.bookPages.tagCount()) - { + if (this.bookPages != null && this.currPage >= 0 && this.currPage < this.bookPages.tagCount()) { s1 = this.bookPages.getStringTagAt(this.currPage); } - if (this.bookIsUnsigned) - { - if (this.fontRendererObj.getBidiFlag()) - { + if (this.bookIsUnsigned) { + if (this.fontRendererObj.getBidiFlag()) { s1 = s1 + "_"; - } - else if (this.updateCount / 6 % 2 == 0) - { + } else if (this.updateCount / 6 % 2 == 0) { s1 = s1 + "" + EnumChatFormatting.BLACK + "_"; - } - else - { + } else { s1 = s1 + "" + EnumChatFormatting.GRAY + "_"; } } @@ -423,41 +369,35 @@ public class GuiBook extends GuiScreen } @SideOnly(Side.CLIENT) - static class NextPageButton extends GuiButton - { - private final boolean field_146151_o; + static class NextPageButton extends GuiButton { + private final boolean field_146151_o; - public NextPageButton(int par1, int par2, int par3, boolean par4) - { - super(par1, par2, par3, 23, 13, ""); - this.field_146151_o = par4; - } + public NextPageButton(int par1, int par2, int par3, boolean par4) { + super(par1, par2, par3, 23, 13, ""); + this.field_146151_o = par4; + } - /** - * Draws this button to the screen. - */ - public void drawButton(Minecraft p_146112_1_, int p_146112_2_, int p_146112_3_) - { - if (this.visible) - { - boolean flag = p_146112_2_ >= this.xPosition && p_146112_3_ >= this.yPosition && p_146112_2_ < this.xPosition + this.width && p_146112_3_ < this.yPosition + this.height; - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - p_146112_1_.getTextureManager().bindTexture(GuiBook.bookGuiTextures); - int k = 0; - int l = 192; + /** + * Draws this button to the screen. + */ + public void drawButton(Minecraft p_146112_1_, int p_146112_2_, int p_146112_3_) { + if (this.visible) { + boolean flag = p_146112_2_ >= this.xPosition && p_146112_3_ >= this.yPosition && p_146112_2_ < this.xPosition + this.width && p_146112_3_ < this.yPosition + this.height; + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + p_146112_1_.getTextureManager().bindTexture(GuiBook.bookGuiTextures); + int k = 0; + int l = 192; - if (flag) - { - k += 23; - } - - if (!this.field_146151_o) - { - l += 13; - } - - this.drawTexturedModalRect(this.xPosition, this.yPosition, k, l, 23, 13); + if (flag) { + k += 23; } + + if (!this.field_146151_o) { + l += 13; + } + + this.drawTexturedModalRect(this.xPosition, this.yPosition, k, l, 23, 13); } } + } } diff --git a/src/main/java/noppes/npcs/client/gui/player/GuiCrate.java b/src/main/java/noppes/npcs/client/gui/player/GuiCrate.java index 6ab456672..4cd8ebbbf 100644 --- a/src/main/java/noppes/npcs/client/gui/player/GuiCrate.java +++ b/src/main/java/noppes/npcs/client/gui/player/GuiCrate.java @@ -11,8 +11,7 @@ import noppes.npcs.containers.ContainerCrate; import org.lwjgl.opengl.GL11; @SideOnly(Side.CLIENT) -public class GuiCrate extends GuiContainer -{ +public class GuiCrate extends GuiContainer { private static final ResourceLocation field_147017_u = new ResourceLocation("textures/gui/container/generic_54.png"); private IInventory upperChestInventory; private IInventory lowerChestInventory; @@ -21,8 +20,7 @@ public class GuiCrate extends GuiContainer */ private int inventoryRows; - public GuiCrate(ContainerCrate container) - { + public GuiCrate(ContainerCrate container) { super(container); this.upperChestInventory = container.upperChestInventory; this.lowerChestInventory = container.lowerChestInventory; @@ -36,14 +34,12 @@ public class GuiCrate extends GuiContainer /** * Draw the foreground layer for the GuiContainer (everything in front of the items) */ - protected void drawGuiContainerForegroundLayer(int p_146979_1_, int p_146979_2_) - { + protected void drawGuiContainerForegroundLayer(int p_146979_1_, int p_146979_2_) { this.fontRendererObj.drawString(this.lowerChestInventory.hasCustomInventoryName() ? this.lowerChestInventory.getInventoryName() : I18n.format(this.lowerChestInventory.getInventoryName(), new Object[0]), 8, 6, CustomNpcResourceListener.DefaultTextColor); this.fontRendererObj.drawString(this.upperChestInventory.hasCustomInventoryName() ? this.upperChestInventory.getInventoryName() : I18n.format(this.upperChestInventory.getInventoryName(), new Object[0]), 8, this.ySize - 96 + 2, CustomNpcResourceListener.DefaultTextColor); } - protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_) - { + protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_) { GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); this.mc.getTextureManager().bindTexture(field_147017_u); int k = (this.width - this.xSize) / 2; @@ -51,4 +47,4 @@ public class GuiCrate extends GuiContainer this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.inventoryRows * 18 + 17); this.drawTexturedModalRect(k, l + this.inventoryRows * 18 + 17, 0, 126, this.xSize, 96); } -} \ No newline at end of file +} diff --git a/src/main/java/noppes/npcs/client/gui/player/GuiDialogImage.java b/src/main/java/noppes/npcs/client/gui/player/GuiDialogImage.java index d8d3266d8..3ac2aef17 100644 --- a/src/main/java/noppes/npcs/client/gui/player/GuiDialogImage.java +++ b/src/main/java/noppes/npcs/client/gui/player/GuiDialogImage.java @@ -64,10 +64,10 @@ public class GuiDialogImage extends Gui { this.imageType = dialogImage.imageType; this.alignment = dialogImage.alignment; - if(texture.startsWith("https://")){ + if (texture.startsWith("https://")) { this.isUrl = true; TextureManager texturemanager = Minecraft.getMinecraft().getTextureManager(); - this.imageDownloadAlt = new ImageDownloadAlt(null, texture, new ResourceLocation("customnpcs:textures/gui/invisible.png"), new ImageBufferDownloadAlt(true,false)); + this.imageDownloadAlt = new ImageDownloadAlt(null, texture, new ResourceLocation("customnpcs:textures/gui/invisible.png"), new ImageBufferDownloadAlt(true, false)); texturemanager.loadTexture(this.location, this.imageDownloadAlt); } else { try { @@ -89,34 +89,36 @@ public class GuiDialogImage extends Gui { public void onRender(Minecraft mc) { try { mc.getTextureManager().bindTexture(this.location); - } catch (Exception ignored) { return; } + } catch (Exception ignored) { + return; + } - float u1 = (float)textureX/(float)totalWidth; - float u2 = u1 + (float)width/(float)totalWidth; - float v1 = (float)textureY/(float)totalHeight; - float v2 = v1 + (float)height/(float)totalHeight; + float u1 = (float) textureX / (float) totalWidth; + float u2 = u1 + (float) width / (float) totalWidth; + float v1 = (float) textureY / (float) totalHeight; + float v2 = v1 + (float) height / (float) totalHeight; - if(imageDownloadAlt != null && isUrl && !gotWidthHeight){ + if (imageDownloadAlt != null && isUrl && !gotWidthHeight) { getURLWidthHeight(); } GL11.glPushMatrix(); float red = (color >> 16 & 255) / 255f; - float green = (color >> 8 & 255) / 255f; + float green = (color >> 8 & 255) / 255f; float blue = (color & 255) / 255f; - GL11.glColor4f(red,green,blue,this.alpha); + GL11.glColor4f(red, green, blue, this.alpha); - GL11.glRotatef(this.rotation,0.0F,0.0F,1.0F); + GL11.glRotatef(this.rotation, 0.0F, 0.0F, 1.0F); GL11.glScalef(this.scale, this.scale, this.scale); Tessellator tessellator = Tessellator.instance; tessellator.startDrawingQuads(); tessellator.setColorOpaque_F(1, 1, 1); tessellator.setColorRGBA_F(red, green, blue, alpha); - tessellator.addVertexWithUV( u2 * totalWidth, v2 * totalHeight, 0, u2, v2); - tessellator.addVertexWithUV( u2 * totalWidth, v1 * totalHeight, 0, u2, v1); - tessellator.addVertexWithUV( u1 * totalWidth, v1 * totalHeight, 0, u1, v1); - tessellator.addVertexWithUV( u1 * totalWidth, v2 * totalHeight, 0, u1, v2); + tessellator.addVertexWithUV(u2 * totalWidth, v2 * totalHeight, 0, u2, v2); + tessellator.addVertexWithUV(u2 * totalWidth, v1 * totalHeight, 0, u2, v1); + tessellator.addVertexWithUV(u1 * totalWidth, v1 * totalHeight, 0, u1, v1); + tessellator.addVertexWithUV(u1 * totalWidth, v2 * totalHeight, 0, u1, v2); tessellator.draw(); GL11.glPopMatrix(); } @@ -141,8 +143,8 @@ public class GuiDialogImage extends Gui { } } - public void getURLWidthHeight(){ - if(imageDownloadAlt.getBufferedImage() != null) { + public void getURLWidthHeight() { + if (imageDownloadAlt.getBufferedImage() != null) { gotWidthHeight = true; this.totalWidth = imageDownloadAlt.getBufferedImage().getWidth(); this.totalHeight = imageDownloadAlt.getBufferedImage().getHeight(); @@ -150,7 +152,7 @@ public class GuiDialogImage extends Gui { } } - public void correctWidthHeight(){ + public void correctWidthHeight() { totalWidth = Math.max(totalWidth, 1); totalHeight = Math.max(totalHeight, 1); this.width = width < 0 ? totalWidth : width; diff --git a/src/main/java/noppes/npcs/client/gui/player/GuiDialogInteract.java b/src/main/java/noppes/npcs/client/gui/player/GuiDialogInteract.java index 43c998667..1287000e1 100644 --- a/src/main/java/noppes/npcs/client/gui/player/GuiDialogInteract.java +++ b/src/main/java/noppes/npcs/client/gui/player/GuiDialogInteract.java @@ -37,669 +37,673 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; -public class GuiDialogInteract extends GuiNPCInterface implements IGuiClose -{ +public class GuiDialogInteract extends GuiNPCInterface implements IGuiClose { private GuiScreen parent; - private Dialog dialog; + private Dialog dialog; private int selected = 0; private List lineBlocks = new ArrayList(); private List options = new ArrayList(); private int totalRows = 0; - private ScaledResolution scaledResolution; + private ScaledResolution scaledResolution; - private String gradualText = ""; - private int currentBlock = 0; - private int currentLine = 0; - private int gradualTextTime = 0; - private int optionStart = 0; + private String gradualText = ""; + private int currentBlock = 0; + private int currentLine = 0; + private int gradualTextTime = 0; + private int optionStart = 0; - private int instantBlockPos = 0; - private int instantLinePos = 0; - private int prevPausePos = -1; + private int instantBlockPos = 0; + private int instantLinePos = 0; + private int prevPausePos = -1; - private int scrollY; - private ResourceLocation wheel; - private ResourceLocation[] wheelparts; - private ResourceLocation indicator; + private int scrollY; + private ResourceLocation wheel; + private ResourceLocation[] wheelparts; + private ResourceLocation indicator; - private boolean isGrabbed = false; - private int textSoundTime = 0; - private int textPauseTime = 0; + private boolean isGrabbed = false; + private int textSoundTime = 0; + private int textPauseTime = 0; - private HashMap dialogImages = new HashMap<>(); + private HashMap dialogImages = new HashMap<>(); - public GuiDialogInteract(EntityNPCInterface npc, Dialog dialog){ - super(npc); - this.dialog = dialog; + public GuiDialogInteract(EntityNPCInterface npc, Dialog dialog) { + super(npc); + this.dialog = dialog; - appendDialog(dialog); - ySize = 238; + appendDialog(dialog); + ySize = 238; - wheel = this.getResource("wheel.png"); - indicator = this.getResource("indicator.png"); - wheelparts = new ResourceLocation[]{getResource("wheel1.png"),getResource("wheel2.png"),getResource("wheel3.png"), - getResource("wheel4.png"),getResource("wheel5.png"),getResource("wheel6.png")}; + wheel = this.getResource("wheel.png"); + indicator = this.getResource("indicator.png"); + wheelparts = new ResourceLocation[]{getResource("wheel1.png"), getResource("wheel2.png"), getResource("wheel3.png"), + getResource("wheel4.png"), getResource("wheel5.png"), getResource("wheel6.png")}; } - public GuiDialogInteract(GuiScreen parent, EntityNPCInterface npc, Dialog dialog){ + public GuiDialogInteract(GuiScreen parent, EntityNPCInterface npc, Dialog dialog) { this(npc, dialog); this.parent = parent; } - public void initGui(){ - super.initGui(); - isGrabbed = false; - grabMouse(dialog.showWheel); - guiTop = (height - ySize); - calculateRowHeight(); - this.scaledResolution = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight); - this.drawDefaultBackground = dialog.darkenScreen; - setOptionOffset(); + public void initGui() { + super.initGui(); + isGrabbed = false; + grabMouse(dialog.showWheel); + guiTop = (height - ySize); + calculateRowHeight(); + this.scaledResolution = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight); + this.drawDefaultBackground = dialog.darkenScreen; + setOptionOffset(); } - public void setOptionOffset() { - optionStart = scaledResolution.getScaledHeight() - (options.size()) * (ClientProxy.Font.height() + dialog.optionSpaceY) - 20; - } - - public void grabMouse(boolean grab){ - if(grab && !isGrabbed){ - Minecraft.getMinecraft().mouseHelper.grabMouseCursor(); - isGrabbed = true; - } - else if(!grab && isGrabbed){ - Minecraft.getMinecraft().mouseHelper.ungrabMouseCursor(); - isGrabbed = false; - } + public void setOptionOffset() { + optionStart = scaledResolution.getScaledHeight() - (options.size()) * (ClientProxy.Font.height() + dialog.optionSpaceY) - 20; } - public void drawScreen(int i, int j, float f){ + public void grabMouse(boolean grab) { + if (grab && !isGrabbed) { + Minecraft.getMinecraft().mouseHelper.grabMouseCursor(); + isGrabbed = true; + } else if (!grab && isGrabbed) { + Minecraft.getMinecraft().mouseHelper.ungrabMouseCursor(); + isGrabbed = false; + } + } + + public void drawScreen(int i, int j, float f) { GL11.glColor4f(1, 1, 1, 1); - if(!dialog.hideNPC){ + if (!dialog.hideNPC) { npc.isDrawn = true; - float l = (guiLeft - 70); - float i1 = (guiTop + ySize); - GL11.glEnable(GL11.GL_COLOR_MATERIAL); - GL11.glPushMatrix(); - GL11.glTranslatef(l + dialog.npcOffsetX, i1 + dialog.npcOffsetY, 50F); - float zoomed = npc.height; - if(npc.width * 2 > zoomed) - zoomed = npc.width * 2; - zoomed = 2 / zoomed * 40; - GL11.glScalef(-zoomed, zoomed, zoomed); - GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); - float f2 = npc.renderYawOffset; - float f3 = npc.rotationYaw; - float f4 = npc.rotationPitch; - float f7 = npc.rotationYawHead; - float f5 = (float)(l) - i; - float f6 = (float)(i1 - 50) - j; - int rotation = npc.ais.orientation; - npc.ais.orientation = 0; - GL11.glRotatef(135F, 0.0F, 1.0F, 0.0F); - RenderHelper.enableStandardItemLighting(); - GL11.glRotatef(-135F, 0.0F, 1.0F, 0.0F); - GL11.glRotatef(-(float)Math.atan(f6 / 80F) * 20F, 1.0F, 0.0F, 0.0F); - npc.renderYawOffset = 0; - npc.rotationYaw = (float)Math.atan(f5 / 80F) * 40F; - npc.rotationPitch = -(float)Math.atan(f6 / 80F) * 20F; - npc.prevRotationYawHead = npc.rotationYawHead = npc.rotationYaw; - GL11.glTranslatef(0.0F, npc.yOffset, 0.0F); - RenderManager.instance.playerViewY = 180F; + float l = (guiLeft - 70); + float i1 = (guiTop + ySize); + GL11.glEnable(GL11.GL_COLOR_MATERIAL); + GL11.glPushMatrix(); + GL11.glTranslatef(l + dialog.npcOffsetX, i1 + dialog.npcOffsetY, 50F); + float zoomed = npc.height; + if (npc.width * 2 > zoomed) + zoomed = npc.width * 2; + zoomed = 2 / zoomed * 40; + GL11.glScalef(-zoomed, zoomed, zoomed); + GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); + float f2 = npc.renderYawOffset; + float f3 = npc.rotationYaw; + float f4 = npc.rotationPitch; + float f7 = npc.rotationYawHead; + float f5 = (float) (l) - i; + float f6 = (float) (i1 - 50) - j; + int rotation = npc.ais.orientation; + npc.ais.orientation = 0; + GL11.glRotatef(135F, 0.0F, 1.0F, 0.0F); + RenderHelper.enableStandardItemLighting(); + GL11.glRotatef(-135F, 0.0F, 1.0F, 0.0F); + GL11.glRotatef(-(float) Math.atan(f6 / 80F) * 20F, 1.0F, 0.0F, 0.0F); + npc.renderYawOffset = 0; + npc.rotationYaw = (float) Math.atan(f5 / 80F) * 40F; + npc.rotationPitch = -(float) Math.atan(f6 / 80F) * 20F; + npc.prevRotationYawHead = npc.rotationYawHead = npc.rotationYaw; + GL11.glTranslatef(0.0F, npc.yOffset, 0.0F); + RenderManager.instance.playerViewY = 180F; - try{ - GL11.glScalef(dialog.npcScale,dialog.npcScale,dialog.npcScale); - RenderManager.instance.renderEntityWithPosYaw(npc, 0.0D, 0.0D, 0.0D, 0.0F, 1.0F); - } catch(Exception ignored){} + try { + GL11.glScalef(dialog.npcScale, dialog.npcScale, dialog.npcScale); + RenderManager.instance.renderEntityWithPosYaw(npc, 0.0D, 0.0D, 0.0D, 0.0F, 1.0F); + } catch (Exception ignored) { + } - npc.ais.orientation = rotation; - npc.renderYawOffset = f2; - npc.rotationYaw = f3; - npc.rotationPitch = f4; - npc.prevRotationYawHead = npc.rotationYawHead = f7; + npc.ais.orientation = rotation; + npc.renderYawOffset = f2; + npc.rotationYaw = f3; + npc.rotationPitch = f4; + npc.prevRotationYawHead = npc.rotationYawHead = f7; npc.isDrawn = false; - GL11.glPopMatrix(); - RenderHelper.disableStandardItemLighting(); - GL11.glDisable(GL12.GL_RESCALE_NORMAL); - OpenGlHelper.setActiveTexture(OpenGlHelper.lightmapTexUnit); - GL11.glDisable(GL11.GL_TEXTURE_2D); - OpenGlHelper.setActiveTexture(OpenGlHelper.defaultTexUnit); + GL11.glPopMatrix(); + RenderHelper.disableStandardItemLighting(); + GL11.glDisable(GL12.GL_RESCALE_NORMAL); + OpenGlHelper.setActiveTexture(OpenGlHelper.lightmapTexUnit); + GL11.glDisable(GL11.GL_TEXTURE_2D); + OpenGlHelper.setActiveTexture(OpenGlHelper.defaultTexUnit); } super.drawScreen(i, j, f); - setOptionOffset(); + setOptionOffset(); GL11.glEnable(GL11.GL_BLEND); OpenGlHelper.glBlendFunc(770, 771, 1, 0); GL11.glEnable(GL11.GL_ALPHA_TEST); GL11.glPushMatrix(); - GL11.glTranslatef(0.0F, 0.5f, 100.065F); - for (IDialogImage dialogImage : dialog.dialogImages.values()) { - if (dialogImage.getImageType() != 0) - continue; + GL11.glTranslatef(0.0F, 0.5f, 100.065F); + for (IDialogImage dialogImage : dialog.dialogImages.values()) { + if (dialogImage.getImageType() != 0) + continue; - GuiDialogImage image; - if (dialogImages.containsKey(dialogImage.getId())) { - image = dialogImages.get(dialogImage.getId()); - } else { - image = new GuiDialogImage((DialogImage) dialogImage); - dialogImages.put(dialogImage.getId(),image); - } + GuiDialogImage image; + if (dialogImages.containsKey(dialogImage.getId())) { + image = dialogImages.get(dialogImage.getId()); + } else { + image = new GuiDialogImage((DialogImage) dialogImage); + dialogImages.put(dialogImage.getId(), image); + } - GL11.glEnable(GL11.GL_BLEND); - OpenGlHelper.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0); - GL11.glDisable(GL11.GL_ALPHA_TEST); - GL11.glTranslatef(image.x,image.y,0.0f); - GL11.glTranslatef(image.alignment%3*((float)(scaledResolution.getScaledWidth())/2), (float) (Math.floor((float)(image.alignment/3))*((float)(scaledResolution.getScaledHeight())/2)),0.0F); - image.onRender(mc); + GL11.glEnable(GL11.GL_BLEND); + OpenGlHelper.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0); + GL11.glDisable(GL11.GL_ALPHA_TEST); + GL11.glTranslatef(image.x, image.y, 0.0f); + GL11.glTranslatef(image.alignment % 3 * ((float) (scaledResolution.getScaledWidth()) / 2), (float) (Math.floor((float) (image.alignment / 3)) * ((float) (scaledResolution.getScaledHeight()) / 2)), 0.0F); + image.onRender(mc); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - GL11.glDisable(GL11.GL_LIGHTING); - GL11.glEnable(GL11.GL_ALPHA_TEST); - } + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glEnable(GL11.GL_ALPHA_TEST); + } - GL11.glPushMatrix(); - for (IDialogImage dialogImage : dialog.dialogImages.values()) { - if (dialogImage.getImageType() != 1) - continue; + GL11.glPushMatrix(); + for (IDialogImage dialogImage : dialog.dialogImages.values()) { + if (dialogImage.getImageType() != 1) + continue; - GuiDialogImage image; - if (dialogImages.containsKey(dialogImage.getId())) { - image = dialogImages.get(dialogImage.getId()); - } else { - image = new GuiDialogImage((DialogImage) dialogImage); - dialogImages.put(dialogImage.getId(),image); - } + GuiDialogImage image; + if (dialogImages.containsKey(dialogImage.getId())) { + image = dialogImages.get(dialogImage.getId()); + } else { + image = new GuiDialogImage((DialogImage) dialogImage); + dialogImages.put(dialogImage.getId(), image); + } - GL11.glEnable(GL11.GL_BLEND); - OpenGlHelper.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0); - GL11.glDisable(GL11.GL_ALPHA_TEST); - GL11.glTranslatef(image.x,image.y,0.0f); - GL11.glTranslatef(guiLeft + dialog.textOffsetX, optionStart + dialog.textOffsetY - image.height * image.scale, 0.0F); - image.onRender(mc); + GL11.glEnable(GL11.GL_BLEND); + OpenGlHelper.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0); + GL11.glDisable(GL11.GL_ALPHA_TEST); + GL11.glTranslatef(image.x, image.y, 0.0f); + GL11.glTranslatef(guiLeft + dialog.textOffsetX, optionStart + dialog.textOffsetY - image.height * image.scale, 0.0F); + image.onRender(mc); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - GL11.glDisable(GL11.GL_LIGHTING); - GL11.glEnable(GL11.GL_ALPHA_TEST); - } - GL11.glPopMatrix(); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glEnable(GL11.GL_ALPHA_TEST); + } + GL11.glPopMatrix(); - if (!dialog.renderGradual) { - int count = 0; - blockLoop: - for (int b = 0; b < lineBlocks.size(); b++) { - TextBlockClient block = lineBlocks.get(b); + if (!dialog.renderGradual) { + int count = 0; + blockLoop: + for (int b = 0; b < lineBlocks.size(); b++) { + TextBlockClient block = lineBlocks.get(b); - int size = ClientProxy.Font.width(block.getName() + " "); - drawDialogString(block.getName() + " ", -4 - size, count, false, block); + int size = ClientProxy.Font.width(block.getName() + " "); + drawDialogString(block.getName() + " ", -4 - size, count, false, block); - for (int l = 0; l < block.lines.size(); l++) { - IChatComponent line = block.lines.get(l); - String drawText = line.getFormattedText(); + for (int l = 0; l < block.lines.size(); l++) { + IChatComponent line = block.lines.get(l); + String drawText = line.getFormattedText(); - if (b >= instantBlockPos && l >= instantLinePos) { - if (drawText.matches("(.*)(\\{(\\d+)})(.*)")) { - if (textPauseTime > 0) { - drawText = drawText.substring(0, prevPausePos); - drawDialogString(drawText, 0, count, true, block); - textPauseTime--; - break blockLoop; - } + if (b >= instantBlockPos && l >= instantLinePos) { + if (drawText.matches("(.*)(\\{(\\d+)})(.*)")) { + if (textPauseTime > 0) { + drawText = drawText.substring(0, prevPausePos); + drawDialogString(drawText, 0, count, true, block); + textPauseTime--; + break blockLoop; + } - String strInt = ""; - for (int c = 0; c < drawText.length(); c++) { - if (drawText.substring(c).matches("^(\\{(\\d+)})(.*)") && c > prevPausePos) { - prevPausePos = c; - strInt += drawText.charAt(++c); - } else if (c > prevPausePos && !strInt.isEmpty()) { - if (drawText.charAt(c) == '}') - break; + String strInt = ""; + for (int c = 0; c < drawText.length(); c++) { + if (drawText.substring(c).matches("^(\\{(\\d+)})(.*)") && c > prevPausePos) { + prevPausePos = c; + strInt += drawText.charAt(++c); + } else if (c > prevPausePos && !strInt.isEmpty()) { + if (drawText.charAt(c) == '}') + break; - strInt += drawText.charAt(c); - } - } + strInt += drawText.charAt(c); + } + } - if (!strInt.isEmpty()) { - drawText = drawText.substring(0, prevPausePos); + if (!strInt.isEmpty()) { + drawText = drawText.substring(0, prevPausePos); - drawDialogString(drawText, 0, count, true, block); + drawDialogString(drawText, 0, count, true, block); - instantBlockPos = b; - instantLinePos = l; - textPauseTime = Integer.parseInt(strInt); - break blockLoop; - } - } else { - prevPausePos = -1; - } - } + instantBlockPos = b; + instantLinePos = l; + textPauseTime = Integer.parseInt(strInt); + break blockLoop; + } + } else { + prevPausePos = -1; + } + } - drawDialogString(drawText, 0, count, true, block); - count++; - } - count++; - } - } else { - int count = 0; - for (int pastBlock = 0; pastBlock < currentBlock; pastBlock++) { - TextBlockClient block = lineBlocks.get(pastBlock); - int size = ClientProxy.Font.width(block.getName() + " "); - drawDialogString(block.getName() + " ", -4 - size, count, false, block); + drawDialogString(drawText, 0, count, true, block); + count++; + } + count++; + } + } else { + int count = 0; + for (int pastBlock = 0; pastBlock < currentBlock; pastBlock++) { + TextBlockClient block = lineBlocks.get(pastBlock); + int size = ClientProxy.Font.width(block.getName() + " "); + drawDialogString(block.getName() + " ", -4 - size, count, false, block); - for (IChatComponent line : block.lines) { - drawDialogString(line.getFormattedText(), 0, count, true, block); - count++; - } - count++; - } + for (IChatComponent line : block.lines) { + drawDialogString(line.getFormattedText(), 0, count, true, block); + count++; + } + count++; + } - if (currentBlock < lineBlocks.size()) { - TextBlockClient block = lineBlocks.get(currentBlock); - int size = ClientProxy.Font.width(block.getName() + " "); - drawDialogString(block.getName() + " ", -4 - size, count, false, block); + if (currentBlock < lineBlocks.size()) { + TextBlockClient block = lineBlocks.get(currentBlock); + int size = ClientProxy.Font.width(block.getName() + " "); + drawDialogString(block.getName() + " ", -4 - size, count, false, block); - for (int pastLine = 0; pastLine < currentLine; pastLine++) { - IChatComponent line = block.lines.get(pastLine); - drawDialogString(line.getFormattedText(), 0, count, true, block); - count++; - } + for (int pastLine = 0; pastLine < currentLine; pastLine++) { + IChatComponent line = block.lines.get(pastLine); + drawDialogString(line.getFormattedText(), 0, count, true, block); + count++; + } - if (currentLine < block.lines.size()) { - IChatComponent line = block.lines.get(currentLine); - try { - if (textPauseTime > 0) { - textPauseTime--; - } else if (ConfigClient.DialogSpeed > 10 || gradualTextTime%(11 - ConfigClient.DialogSpeed) == 0) { - int addChar = ConfigClient.DialogSpeed > 10 ? ConfigClient.DialogSpeed - 9 : 1; - String addText = line.getFormattedText().substring(gradualText.length(), gradualText.length() + addChar); + if (currentLine < block.lines.size()) { + IChatComponent line = block.lines.get(currentLine); + try { + if (textPauseTime > 0) { + textPauseTime--; + } else if (ConfigClient.DialogSpeed > 10 || gradualTextTime % (11 - ConfigClient.DialogSpeed) == 0) { + int addChar = ConfigClient.DialogSpeed > 10 ? ConfigClient.DialogSpeed - 9 : 1; + String addText = line.getFormattedText().substring(gradualText.length(), gradualText.length() + addChar); - if (addText.matches("^(\\{(\\d+)})(.*)")) { - StringBuilder numStr = new StringBuilder(); - int numLength; - for (numLength = 1; numLength < addText.length(); numLength++) { - if (addText.charAt(numLength) == '}') - break; + if (addText.matches("^(\\{(\\d+)})(.*)")) { + StringBuilder numStr = new StringBuilder(); + int numLength; + for (numLength = 1; numLength < addText.length(); numLength++) { + if (addText.charAt(numLength) == '}') + break; - numStr.append(addText.charAt(numLength)); - } - textPauseTime = Integer.parseInt(numStr.toString()); - addText = line.getFormattedText().substring(gradualText.length(), gradualText.length() + numLength + 1); - } else if (addText.matches("(.+)\\{(\\d+)(.*)")) { - StringBuilder str = new StringBuilder(); - for (char c : addText.toCharArray()) { - if (c == '{') - break; - str.append(c); - } + numStr.append(addText.charAt(numLength)); + } + textPauseTime = Integer.parseInt(numStr.toString()); + addText = line.getFormattedText().substring(gradualText.length(), gradualText.length() + numLength + 1); + } else if (addText.matches("(.+)\\{(\\d+)(.*)")) { + StringBuilder str = new StringBuilder(); + for (char c : addText.toCharArray()) { + if (c == '{') + break; + str.append(c); + } - addText = str.toString(); - } else if (addText.matches("(\\{(\\d+))$") || addText.equals("{")) { - do { - if (addText.length() == gradualText.length() + addText.length() + 1) - break; + addText = str.toString(); + } else if (addText.matches("(\\{(\\d+))$") || addText.equals("{")) { + do { + if (addText.length() == gradualText.length() + addText.length() + 1) + break; - addText += line.getFormattedText().substring(gradualText.length() + addText.length(), gradualText.length() + addText.length() + 1); - } while (addText.matches("(.*)(\\{(\\d+))$")); + addText += line.getFormattedText().substring(gradualText.length() + addText.length(), gradualText.length() + addText.length() + 1); + } while (addText.matches("(.*)(\\{(\\d+))$")); - textPauseTime = Integer.parseInt(addText.replace("{","").replace("}","")); - } + textPauseTime = Integer.parseInt(addText.replace("{", "").replace("}", "")); + } - gradualText += addText; - if(ConfigClient.DialogSound){ + gradualText += addText; + if (ConfigClient.DialogSound) { if (textSoundTime % 5 == 0) { Minecraft.getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation(dialog.textSound), dialog.textPitch)); } textSoundTime++; } - } - } catch (IndexOutOfBoundsException exception) { - gradualText = line.getFormattedText(); - } + } + } catch (IndexOutOfBoundsException exception) { + gradualText = line.getFormattedText(); + } - drawDialogString(gradualText, 0, count, true, block); + drawDialogString(gradualText, 0, count, true, block); - if (gradualText.length() == line.getFormattedText().length()) { - gradualText = ""; - currentLine++; - if (currentLine >= lineBlocks.get(currentBlock).lines.size()) { - currentBlock++; - } - } + if (gradualText.length() == line.getFormattedText().length()) { + gradualText = ""; + currentLine++; + if (currentLine >= lineBlocks.get(currentBlock).lines.size()) { + currentBlock++; + } + } - gradualTextTime++; - } - } - } - GL11.glPopMatrix(); + gradualTextTime++; + } + } + } + GL11.glPopMatrix(); - GL11.glPushMatrix(); - if (!options.isEmpty()) { - if (!dialog.showWheel) { - GL11.glTranslatef(dialog.optionOffsetX, dialog.optionOffsetY, 0); - drawLinedOptions(j); - } else { - drawWheel(); - } - } + GL11.glPushMatrix(); + if (!options.isEmpty()) { + if (!dialog.showWheel) { + GL11.glTranslatef(dialog.optionOffsetX, dialog.optionOffsetY, 0); + drawLinedOptions(j); + } else { + drawWheel(); + } + } GL11.glPopMatrix(); } private int selectedX = 0; private int selectedY = 0; - private void drawWheel(){ - int yoffset = optionStart + dialog.optionOffsetY; + + private void drawWheel() { + int yoffset = optionStart + dialog.optionOffsetY; GL11.glColor4f(1, 1, 1, 1); mc.renderEngine.bindTexture(wheel); - drawTexturedModalRect((width/2) - 31 + dialog.optionOffsetX, yoffset, 0, 0, 63, 40); + drawTexturedModalRect((width / 2) - 31 + dialog.optionOffsetX, yoffset, 0, 0, 63, 40); selectedX += Mouse.getDX(); selectedY += Mouse.getDY(); int limit = 80; - if(selectedX > limit) - selectedX = limit; - if(selectedX < -limit) - selectedX = -limit; + if (selectedX > limit) + selectedX = limit; + if (selectedX < -limit) + selectedX = -limit; - if(selectedY > limit) - selectedY = limit; - if(selectedY < -limit) - selectedY = -limit; + if (selectedY > limit) + selectedY = limit; + if (selectedY < -limit) + selectedY = -limit; selected = 1; - if(selectedY < -20) - selected++; - if(selectedY > 54) - selected--; + if (selectedY < -20) + selected++; + if (selectedY > 54) + selected--; - if(selectedX < 0) - selected += 3; + if (selectedX < 0) + selected += 3; mc.renderEngine.bindTexture(wheelparts[selected]); - drawTexturedModalRect((width/2) - 31 + dialog.optionOffsetX,yoffset, 0, 0, 85, 55); - for(int slot:dialog.options.keySet()){ - DialogOption option = dialog.options.get(slot); - if(option == null || option.optionType == EnumOptionType.Disabled) - continue; + drawTexturedModalRect((width / 2) - 31 + dialog.optionOffsetX, yoffset, 0, 0, 85, 55); + for (int slot : dialog.options.keySet()) { + DialogOption option = dialog.options.get(slot); + if (option == null || option.optionType == EnumOptionType.Disabled) + continue; int color = option.optionColor; - if(slot == (selected)) - color = 0x838FD8; - //drawString(fontRenderer, option.title, width/2 -50 ,yoffset+ 162 + slot * 13 , color); - if(slot == 0) - drawString(fontRendererObj, option.title, width/2 + 13 + dialog.optionOffsetX,yoffset - 6 , color); - if(slot == 1) - drawString(fontRendererObj, option.title, width/2 + 33 + dialog.optionOffsetX,yoffset + 12 , color); - if(slot == 2) - drawString(fontRendererObj, option.title, width/2 + 27 + dialog.optionOffsetX,yoffset + 32 , color); - if(slot == 3) - drawString(fontRendererObj, option.title, width/2 - 13 + dialog.optionOffsetX - ClientProxy.Font.width(option.title),yoffset - 6 , color); - if(slot == 4) - drawString(fontRendererObj, option.title, width/2 - 33 + dialog.optionOffsetX - ClientProxy.Font.width(option.title),yoffset + 12 , color); - if(slot == 5) - drawString(fontRendererObj, option.title, width/2 - 27 + dialog.optionOffsetX - ClientProxy.Font.width(option.title),yoffset + 32 , color); + if (slot == (selected)) + color = 0x838FD8; + //drawString(fontRenderer, option.title, width/2 -50 ,yoffset+ 162 + slot * 13 , color); + if (slot == 0) + drawString(fontRendererObj, option.title, width / 2 + 13 + dialog.optionOffsetX, yoffset - 6, color); + if (slot == 1) + drawString(fontRendererObj, option.title, width / 2 + 33 + dialog.optionOffsetX, yoffset + 12, color); + if (slot == 2) + drawString(fontRendererObj, option.title, width / 2 + 27 + dialog.optionOffsetX, yoffset + 32, color); + if (slot == 3) + drawString(fontRendererObj, option.title, width / 2 - 13 + dialog.optionOffsetX - ClientProxy.Font.width(option.title), yoffset - 6, color); + if (slot == 4) + drawString(fontRendererObj, option.title, width / 2 - 33 + dialog.optionOffsetX - ClientProxy.Font.width(option.title), yoffset + 12, color); + if (slot == 5) + drawString(fontRendererObj, option.title, width / 2 - 27 + dialog.optionOffsetX - ClientProxy.Font.width(option.title), yoffset + 32, color); } mc.renderEngine.bindTexture(indicator); - drawTexturedModalRect(width/2 + selectedX/4 - 2 + dialog.optionOffsetX,yoffset + 16 - selectedY/6, 0, 0, 8, 8); + drawTexturedModalRect(width / 2 + selectedX / 4 - 2 + dialog.optionOffsetX, yoffset + 16 - selectedY / 6, 0, 0, 8, 8); } - private void drawLinedOptions(int j){ - int offset = optionStart; - if(j >= offset){ - int selected = (j - offset - ClientProxy.Font.height() - dialog.optionOffsetY) / (ClientProxy.Font.height() + dialog.optionSpaceY); - if(selected < options.size()) - this.selected = selected; + private void drawLinedOptions(int j) { + int offset = optionStart; + + if (j >= offset) { + int selected = (j - offset - ClientProxy.Font.height() - dialog.optionOffsetY) / (ClientProxy.Font.height() + dialog.optionSpaceY); + if (selected < options.size()) + this.selected = selected; } - if(selected >= options.size()) - selected = options.size() - 1; - if(selected < 0) - selected = 0; + if (selected >= options.size()) + selected = options.size() - 1; + if (selected < 0) + selected = 0; - if (dialog.showOptionLine) { - drawHorizontalLine(guiLeft - 60, guiLeft + xSize + 120, offset, 0xFFFFFFFF); - } + if (dialog.showOptionLine) { + drawHorizontalLine(guiLeft - 60, guiLeft + xSize + 120, offset, 0xFFFFFFFF); + } - for(int k = 0; k < options.size(); k++){ - GL11.glPushMatrix(); - int id = options.get(k); - DialogOption option = dialog.options.get(id); - int y = offset + (k + 1) * ClientProxy.Font.height(); - offset += dialog.optionSpaceY; + for (int k = 0; k < options.size(); k++) { + GL11.glPushMatrix(); + int id = options.get(k); + DialogOption option = dialog.options.get(id); + int y = offset + (k + 1) * ClientProxy.Font.height(); + offset += dialog.optionSpaceY; - if(selected == k){ - drawString(fontRendererObj, ">", guiLeft - 60, y, 0xe0e0e0); - } + if (selected == k) { + drawString(fontRendererObj, ">", guiLeft - 60, y, 0xe0e0e0); + } - GL11.glPushMatrix(); - for (IDialogImage dialogImage : dialog.dialogImages.values()) { - if (dialogImage.getImageType() != 2) - continue; + GL11.glPushMatrix(); + for (IDialogImage dialogImage : dialog.dialogImages.values()) { + if (dialogImage.getImageType() != 2) + continue; - GuiDialogImage image; - if (dialogImages.containsKey(dialogImage.getId())) { - image = dialogImages.get(dialogImage.getId()); - } else { - image = new GuiDialogImage((DialogImage) dialogImage); - dialogImages.put(dialogImage.getId(),image); - } + GuiDialogImage image; + if (dialogImages.containsKey(dialogImage.getId())) { + image = dialogImages.get(dialogImage.getId()); + } else { + image = new GuiDialogImage((DialogImage) dialogImage); + dialogImages.put(dialogImage.getId(), image); + } - GL11.glEnable(GL11.GL_BLEND); - OpenGlHelper.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0); - GL11.glDisable(GL11.GL_ALPHA_TEST); + GL11.glEnable(GL11.GL_BLEND); + OpenGlHelper.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0); + GL11.glDisable(GL11.GL_ALPHA_TEST); - GL11.glTranslatef(guiLeft - 30 + dialog.optionSpaceX * k, y, 0.0F); - image.color = selected == k ? image.selectedColor : image.color; - GL11.glTranslatef(image.x,image.y,0.0f); - image.onRender(mc); + GL11.glTranslatef(guiLeft - 30 + dialog.optionSpaceX * k, y, 0.0F); + image.color = selected == k ? image.selectedColor : image.color; + GL11.glTranslatef(image.x, image.y, 0.0f); + image.onRender(mc); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - GL11.glDisable(GL11.GL_LIGHTING); - GL11.glEnable(GL11.GL_ALPHA_TEST); - } - GL11.glPopMatrix(); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glEnable(GL11.GL_ALPHA_TEST); + } + GL11.glPopMatrix(); - drawString(fontRendererObj, NoppesStringUtils.formatText(option.title, player, npc), guiLeft - 30 + dialog.optionSpaceX * k, y, option.optionColor); - GL11.glPopMatrix(); - } + drawString(fontRendererObj, NoppesStringUtils.formatText(option.title, player, npc), guiLeft - 30 + dialog.optionSpaceX * k, y, option.optionColor); + GL11.glPopMatrix(); + } } - private void drawDialogString(String text, int left, int count, boolean mainDialogText, TextBlockClient block){ - int lineOffset = dialog.renderGradual ? (currentBlock < lineBlocks.size() ? lineBlocks.get(currentBlock).lines.size() : lineBlocks.get(lineBlocks.size()-1).lines.size()) - currentLine : 0; + private void drawDialogString(String text, int left, int count, boolean mainDialogText, TextBlockClient block) { + int lineOffset = dialog.renderGradual ? (currentBlock < lineBlocks.size() ? lineBlocks.get(currentBlock).lines.size() : lineBlocks.get(lineBlocks.size() - 1).lines.size()) - currentLine : 0; - int height = count - totalRows + lineOffset; - int screenPos = optionStart; - int y = (height * ClientProxy.Font.height()) + screenPos + scrollY; - if (dialog.alignment == 1) { + int height = count - totalRows + lineOffset; + int screenPos = optionStart; + int y = (height * ClientProxy.Font.height()) + screenPos + scrollY; + if (dialog.alignment == 1) { int i = totalRows - lineBlocks.get(lineBlocks.size() - 1).lines.size() - 1; - height = count - totalRows + lineOffset - i + 1; - screenPos = ClientProxy.Font.height() * (totalRows - lineOffset); + height = count - totalRows + lineOffset - i + 1; + screenPos = ClientProxy.Font.height() * (totalRows - lineOffset); y = (height * ClientProxy.Font.height()) + screenPos + scrollY; - } + } - if (block.titlePos == 0 || mainDialogText) { - if (dialog.alignment == 1) { - if (y > optionStart - ClientProxy.Font.height()/2f) { - return; - } - } else { - if (y < screenPos - dialog.textHeight || y > screenPos - ClientProxy.Font.height()) { - return; - } - } - } + if (block.titlePos == 0 || mainDialogText) { + if (dialog.alignment == 1) { + if (y > optionStart - ClientProxy.Font.height() / 2f) { + return; + } + } else { + if (y < screenPos - dialog.textHeight || y > screenPos - ClientProxy.Font.height()) { + return; + } + } + } - int offsetX, offsetY, color; - if (mainDialogText) { - offsetX = dialog.textOffsetX; - offsetY = dialog.textOffsetY; - color = block.color; - } else { - offsetX = dialog.titleOffsetX; - offsetY = dialog.titleOffsetY; - color = block.titleColor; + int offsetX, offsetY, color; + if (mainDialogText) { + offsetX = dialog.textOffsetX; + offsetY = dialog.textOffsetY; + color = block.color; + } else { + offsetX = dialog.titleOffsetX; + offsetY = dialog.titleOffsetY; + color = block.titleColor; - if (block.titlePos == 1 && block.equals(lineBlocks.get(currentBlock < lineBlocks.size() ? currentBlock : currentBlock - 1))) { - y = screenPos - ClientProxy.Font.height() - 5; - } - } + if (block.titlePos == 1 && block.equals(lineBlocks.get(currentBlock < lineBlocks.size() ? currentBlock : currentBlock - 1))) { + y = screenPos - ClientProxy.Font.height() - 5; + } + } - text = text.replaceAll("\\{(\\d+)}",""); - if (!mainDialogText && block.titlePos == 2 && block.equals(lineBlocks.get(currentBlock < lineBlocks.size() ? currentBlock : currentBlock - 1))) { - drawString(fontRendererObj, text, offsetX, offsetY, color); - } else { - drawString(fontRendererObj, text, guiLeft + left + offsetX, y + offsetY, color); - } - } + text = text.replaceAll("\\{(\\d+)}", ""); + if (!mainDialogText && block.titlePos == 2 && block.equals(lineBlocks.get(currentBlock < lineBlocks.size() ? currentBlock : currentBlock - 1))) { + drawString(fontRendererObj, text, offsetX, offsetY, color); + } else { + drawString(fontRendererObj, text, guiLeft + left + offsetX, y + offsetY, color); + } + } - public void drawString(FontRenderer fontRendererIn, String text, int x, int y, int color){ - ClientProxy.Font.drawString(text, x, y, color); + public void drawString(FontRenderer fontRendererIn, String text, int x, int y, int color) { + ClientProxy.Font.drawString(text, x, y, color); } @Override - public void keyTyped(char c, int i){ - if(i == mc.gameSettings.keyBindForward.getKeyCode() || i == Keyboard.KEY_UP){ - if (dialog.showWheel) { - selected--; - } else { - selected++; - } - } - if(i == mc.gameSettings.keyBindBack.getKeyCode() || i == Keyboard.KEY_DOWN){ - if (dialog.showWheel) { - selected++; - } else { - selected--; - } - } + public void keyTyped(char c, int i) { + if (i == mc.gameSettings.keyBindForward.getKeyCode() || i == Keyboard.KEY_UP) { + if (dialog.showWheel) { + selected--; + } else { + selected++; + } + } + if (i == mc.gameSettings.keyBindBack.getKeyCode() || i == Keyboard.KEY_DOWN) { + if (dialog.showWheel) { + selected++; + } else { + selected--; + } + } - if (dialog.alignment == 1 && totalRows * ClientProxy.Font.height() > dialog.textHeight) { - if ((i == mc.gameSettings.keyBindBack.getKeyCode() || i == 201) && scrollY < totalRows * ClientProxy.Font.height()) {//Page up - scrollY += ClientProxy.Font.height() * 2; - } + if (dialog.alignment == 1 && totalRows * ClientProxy.Font.height() > dialog.textHeight) { + if ((i == mc.gameSettings.keyBindBack.getKeyCode() || i == 201) && scrollY < totalRows * ClientProxy.Font.height()) {//Page up + scrollY += ClientProxy.Font.height() * 2; + } - int latestBlockSize = lineBlocks.get(lineBlocks.size() - 1).lines.size(); - if ((i == mc.gameSettings.keyBindBack.getKeyCode() || i == 209) && scrollY > -(latestBlockSize - 2) * ClientProxy.Font.height()) {//Page down - scrollY -= ClientProxy.Font.height() * 2; - } - } else { - if ((i == mc.gameSettings.keyBindBack.getKeyCode() || i == 201) && scrollY < (totalRows - 2) * ClientProxy.Font.height()) {//Page up - scrollY += ClientProxy.Font.height() * 2; - } - if ((i == mc.gameSettings.keyBindBack.getKeyCode() || i == 209) && scrollY > 0) {//Page down - scrollY -= ClientProxy.Font.height() * 2; - } - } + int latestBlockSize = lineBlocks.get(lineBlocks.size() - 1).lines.size(); + if ((i == mc.gameSettings.keyBindBack.getKeyCode() || i == 209) && scrollY > -(latestBlockSize - 2) * ClientProxy.Font.height()) {//Page down + scrollY -= ClientProxy.Font.height() * 2; + } + } else { + if ((i == mc.gameSettings.keyBindBack.getKeyCode() || i == 201) && scrollY < (totalRows - 2) * ClientProxy.Font.height()) {//Page up + scrollY += ClientProxy.Font.height() * 2; + } + if ((i == mc.gameSettings.keyBindBack.getKeyCode() || i == 209) && scrollY > 0) {//Page down + scrollY -= ClientProxy.Font.height() * 2; + } + } - if(i == 28){ - handleDialogSelection(); - } - if (closeOnEsc && (i == 1 || isInventoryKey(i))){ + if (i == 28) { + handleDialogSelection(); + } + if (closeOnEsc && (i == 1 || isInventoryKey(i))) { PacketClient.sendClient(new DialogSelectPacket(dialog.id, -1)); - closed(); + closed(); close(); } super.keyTyped(c, i); } @Override - public void mouseClicked(int i,int j,int k){ - if(selected == -1 && options.isEmpty() || selected >= 0) { - scrollY = 0; - handleDialogSelection(); - } + public void mouseClicked(int i, int j, int k) { + if (selected == -1 && options.isEmpty() || selected >= 0) { + scrollY = 0; + handleDialogSelection(); + } } - private void handleDialogSelection(){ - int optionId = -1; - if(dialog.showWheel) - optionId = selected; - else if(!options.isEmpty()) - optionId = options.get(selected); + + private void handleDialogSelection() { + int optionId = -1; + if (dialog.showWheel) + optionId = selected; + else if (!options.isEmpty()) + optionId = options.get(selected); PacketClient.sendClient(new DialogSelectPacket(dialog.id, optionId)); - if(dialog == null || !dialog.hasOtherOptions() || options.isEmpty()){ - closed(); - close(); - return; - } - DialogOption option = dialog.options.get(optionId); - if(option == null || option.optionType != EnumOptionType.DialogOption){ - closed(); - close(); - return; - } + if (dialog == null || !dialog.hasOtherOptions() || options.isEmpty()) { + closed(); + close(); + return; + } + DialogOption option = dialog.options.get(optionId); + if (option == null || option.optionType != EnumOptionType.DialogOption) { + closed(); + close(); + return; + } - if (!dialog.showPreviousBlocks) { - lineBlocks.clear(); - } - lineBlocks.add(new TextBlockClient(player.getDisplayName(), option.title, dialog.textWidth, option.optionColor, player, npc)); - gradualText = ""; - currentBlock = lineBlocks.size()-1; - currentLine = 0; - gradualTextTime = 0; + if (!dialog.showPreviousBlocks) { + lineBlocks.clear(); + } + lineBlocks.add(new TextBlockClient(player.getDisplayName(), option.title, dialog.textWidth, option.optionColor, player, npc)); + gradualText = ""; + currentBlock = lineBlocks.size() - 1; + currentLine = 0; + gradualTextTime = 0; - instantBlockPos = lineBlocks.size()-1; - instantLinePos = 0; - calculateRowHeight(); - textPauseTime = 0; + instantBlockPos = lineBlocks.size() - 1; + instantLinePos = 0; + calculateRowHeight(); + textPauseTime = 0; - NoppesUtil.clickSound(); + NoppesUtil.clickSound(); } - private void closed(){ - grabMouse(false); + + private void closed() { + grabMouse(false); PacketClient.sendClient(new CheckPlayerValue(CheckPlayerValue.Type.CheckQuestCompletion)); } - public void save() { + public void save() { - } + } - public void appendDialog(Dialog dialog) { - closeOnEsc = !dialog.disableEsc; - this.dialogImages.clear(); - this.dialog = dialog; - this.options = new ArrayList(); + public void appendDialog(Dialog dialog) { + closeOnEsc = !dialog.disableEsc; + this.dialogImages.clear(); + this.dialog = dialog; + this.options = new ArrayList(); - if(dialog.sound != null && !dialog.sound.isEmpty()){ - MusicController.Instance.stopMusic(); - MusicController.Instance.playSound(dialog.sound, (float)npc.posX, (float)npc.posY, (float)npc.posZ); - } - - if (!dialog.showPreviousBlocks) { - lineBlocks.clear(); - } - lineBlocks.add(new TextBlockClient(npc, dialog, player, npc)); - gradualText = ""; - currentBlock = lineBlocks.size()-1; - currentLine = 0; - gradualTextTime = 0; - - for(int slot:dialog.options.keySet()){ - DialogOption option = dialog.options.get(slot); - if(option == null || option.optionType == EnumOptionType.Disabled) - continue; - options.add(slot); - } - calculateRowHeight(); - - grabMouse(dialog.showWheel); - } - private void calculateRowHeight(){ - totalRows = 0; - for(TextBlockClient block : lineBlocks){ - totalRows += block.lines.size() + 1; + if (dialog.sound != null && !dialog.sound.isEmpty()) { + MusicController.Instance.stopMusic(); + MusicController.Instance.playSound(dialog.sound, (float) npc.posX, (float) npc.posY, (float) npc.posZ); } - } + + if (!dialog.showPreviousBlocks) { + lineBlocks.clear(); + } + lineBlocks.add(new TextBlockClient(npc, dialog, player, npc)); + gradualText = ""; + currentBlock = lineBlocks.size() - 1; + currentLine = 0; + gradualTextTime = 0; + + for (int slot : dialog.options.keySet()) { + DialogOption option = dialog.options.get(slot); + if (option == null || option.optionType == EnumOptionType.Disabled) + continue; + options.add(slot); + } + calculateRowHeight(); + + grabMouse(dialog.showWheel); + } + + private void calculateRowHeight() { + totalRows = 0; + for (TextBlockClient block : lineBlocks) { + totalRows += block.lines.size() + 1; + } + } @Override - public void close(){ + public void close() { super.close(); - if(parent != null) + if (parent != null) NoppesUtil.openGUI(player, parent); MusicController.Instance.stopAllSounds(); } - @Override - public void setClose(int i, NBTTagCompound data) { - grabMouse(false); - } + @Override + public void setClose(int i, NBTTagCompound data) { + grabMouse(false); + } } diff --git a/src/main/java/noppes/npcs/client/gui/player/GuiMailbox.java b/src/main/java/noppes/npcs/client/gui/player/GuiMailbox.java index e54ef412a..babf6b3a0 100644 --- a/src/main/java/noppes/npcs/client/gui/player/GuiMailbox.java +++ b/src/main/java/noppes/npcs/client/gui/player/GuiMailbox.java @@ -16,24 +16,24 @@ import java.util.Collections; import java.util.Comparator; import java.util.List; -public class GuiMailbox extends GuiNPCInterface implements IGuiData, ICustomScrollListener, GuiYesNoCallback{ +public class GuiMailbox extends GuiNPCInterface implements IGuiData, ICustomScrollListener, GuiYesNoCallback { private GuiCustomScroll scroll; private PlayerMailData data; private PlayerMail selected; - public GuiMailbox() { - super(); + public GuiMailbox() { + super(); xSize = 256; setBackground("menubg.png"); MailActionPacket.RequestMailData(); - } - public void initGui() - { + } + + public void initGui() { super.initGui(); - if(scroll == null){ - scroll = new GuiCustomScroll(this,0); - scroll.setSize(165, 186); + if (scroll == null) { + scroll = new GuiCustomScroll(this, 0); + scroll.setSize(165, 186); } scroll.guiLeft = guiLeft + 4; scroll.guiTop = guiTop + 4; @@ -44,114 +44,115 @@ public class GuiMailbox extends GuiNPCInterface implements IGuiData, ICustomScro this.addLabel(new GuiNpcLabel(0, title, guiLeft + x, guiTop - 8)); - if(selected != null){ - this.addLabel(new GuiNpcLabel(3, StatCollector.translateToLocal("mailbox.sender") + ":", guiLeft + 170, guiTop + 6)); - this.addLabel(new GuiNpcLabel(1, selected.sender, guiLeft + 174, guiTop + 18)); - this.addLabel(new GuiNpcLabel(2, StatCollector.translateToLocalFormatted("mailbox.timesend",getTimePast()), guiLeft + 174, guiTop + 30)); + if (selected != null) { + this.addLabel(new GuiNpcLabel(3, StatCollector.translateToLocal("mailbox.sender") + ":", guiLeft + 170, guiTop + 6)); + this.addLabel(new GuiNpcLabel(1, selected.sender, guiLeft + 174, guiTop + 18)); + this.addLabel(new GuiNpcLabel(2, StatCollector.translateToLocalFormatted("mailbox.timesend", getTimePast()), guiLeft + 174, guiTop + 30)); } - this.addButton(new GuiNpcButton(0, guiLeft + 4, guiTop + 192,82,20, "mailbox.read")); - this.addButton(new GuiNpcButton(1, guiLeft + 88, guiTop + 192,82,20, "selectWorld.deleteButton")); + this.addButton(new GuiNpcButton(0, guiLeft + 4, guiTop + 192, 82, 20, "mailbox.read")); + this.addButton(new GuiNpcButton(1, guiLeft + 88, guiTop + 192, 82, 20, "selectWorld.deleteButton")); getButton(1).setEnabled(selected != null); } private String getTimePast() { - if(selected.timePast > 86400000){ - int days = (int) (selected.timePast / 86400000); - if(days == 1) - return days + " " + StatCollector.translateToLocal("mailbox.day"); - else - return days + " " + StatCollector.translateToLocal("mailbox.days"); - } - if(selected.timePast > 3600000){ - int hours = (int) (selected.timePast / 3600000); - if(hours == 1) - return hours + " " + StatCollector.translateToLocal("mailbox.hour"); - else - return hours + " " + StatCollector.translateToLocal("mailbox.hours"); - } - int minutes = (int) (selected.timePast / 60000); - if(minutes == 1) - return minutes + " " + StatCollector.translateToLocal("mailbox.minute"); - else - return minutes + " " + StatCollector.translateToLocal("mailbox.minutes"); - } - @Override - public void confirmClicked(boolean flag, int i) - { - if(flag && selected != null){ - MailActionPacket.DeleteMail(selected.time, selected.sender); - selected = null; - } - NoppesUtil.openGUI(player, this); - } - protected void actionPerformed(GuiButton guibutton) - { - int id = guibutton.id; - if(scroll.selected < 0) - return; - if(id == 0){ - GuiMailmanWrite.parent = this; - GuiMailmanWrite.mail = selected; - MailActionPacket.OpenMail(selected.time, selected.sender); - selected = null; - scroll.selected = -1; - } - if(id == 1){ - GuiYesNo guiyesno = new GuiYesNo(this, "Confirm", StatCollector.translateToLocal("gui.delete"), 0); - displayGuiScreen(guiyesno); - } + if (selected.timePast > 86400000) { + int days = (int) (selected.timePast / 86400000); + if (days == 1) + return days + " " + StatCollector.translateToLocal("mailbox.day"); + else + return days + " " + StatCollector.translateToLocal("mailbox.days"); + } + if (selected.timePast > 3600000) { + int hours = (int) (selected.timePast / 3600000); + if (hours == 1) + return hours + " " + StatCollector.translateToLocal("mailbox.hour"); + else + return hours + " " + StatCollector.translateToLocal("mailbox.hours"); + } + int minutes = (int) (selected.timePast / 60000); + if (minutes == 1) + return minutes + " " + StatCollector.translateToLocal("mailbox.minute"); + else + return minutes + " " + StatCollector.translateToLocal("mailbox.minutes"); } @Override - public void mouseClicked(int i, int j, int k) - { - super.mouseClicked(i, j, k); - scroll.mouseClicked(i, j, k); + public void confirmClicked(boolean flag, int i) { + if (flag && selected != null) { + MailActionPacket.DeleteMail(selected.time, selected.sender); + selected = null; + } + NoppesUtil.openGUI(player, this); } + + protected void actionPerformed(GuiButton guibutton) { + int id = guibutton.id; + if (scroll.selected < 0) + return; + if (id == 0) { + GuiMailmanWrite.parent = this; + GuiMailmanWrite.mail = selected; + MailActionPacket.OpenMail(selected.time, selected.sender); + selected = null; + scroll.selected = -1; + } + if (id == 1) { + GuiYesNo guiyesno = new GuiYesNo(this, "Confirm", StatCollector.translateToLocal("gui.delete"), 0); + displayGuiScreen(guiyesno); + } + } + @Override - public void keyTyped(char c, int i) - { - if (i == 1 || isInventoryKey(i)) - { + public void mouseClicked(int i, int j, int k) { + super.mouseClicked(i, j, k); + scroll.mouseClicked(i, j, k); + } + + @Override + public void keyTyped(char c, int i) { + if (i == 1 || isInventoryKey(i)) { close(); } } - @Override - public void save() {} - - @Override - public void setGuiData(NBTTagCompound compound) { - PlayerMailData data = new PlayerMailData(); - data.loadNBTData(compound); - List list = new ArrayList(); - Collections.sort(data.playermail, new Comparator(){ - public int compare(PlayerMail o1, PlayerMail o2){ - if(o1.time == o2.time) - return 0; - return o1.time > o2.time ? -1 : 1; - } - }); - for(PlayerMail mail : data.playermail){ - list.add(mail.subject); - } + @Override + public void save() { + } - this.data = data; - scroll.clear(); - selected = null; - scroll.setUnsortedList(list); - } - @Override - public void customScrollClicked(int i, int j, int k, - GuiCustomScroll guiCustomScroll) { - selected = data.playermail.get(guiCustomScroll.selected); - initGui(); + @Override + public void setGuiData(NBTTagCompound compound) { + PlayerMailData data = new PlayerMailData(); + data.loadNBTData(compound); - if(selected != null && !selected.beenRead){ - selected.beenRead = true; + List list = new ArrayList(); + Collections.sort(data.playermail, new Comparator() { + public int compare(PlayerMail o1, PlayerMail o2) { + if (o1.time == o2.time) + return 0; + return o1.time > o2.time ? -1 : 1; + } + }); + for (PlayerMail mail : data.playermail) { + list.add(mail.subject); + } + + this.data = data; + scroll.clear(); + selected = null; + scroll.setUnsortedList(list); + } + + @Override + public void customScrollClicked(int i, int j, int k, + GuiCustomScroll guiCustomScroll) { + selected = data.playermail.get(guiCustomScroll.selected); + initGui(); + + if (selected != null && !selected.beenRead) { + selected.beenRead = true; MailActionPacket.ReadMail(selected.time, selected.sender); - } - } + } + } } diff --git a/src/main/java/noppes/npcs/client/gui/player/GuiMailmanWrite.java b/src/main/java/noppes/npcs/client/gui/player/GuiMailmanWrite.java index 3f2bf588b..d80138a5b 100644 --- a/src/main/java/noppes/npcs/client/gui/player/GuiMailmanWrite.java +++ b/src/main/java/noppes/npcs/client/gui/player/GuiMailmanWrite.java @@ -21,14 +21,15 @@ import org.lwjgl.input.Keyboard; import org.lwjgl.opengl.GL11; @SideOnly(Side.CLIENT) -public class GuiMailmanWrite extends GuiContainerNPCInterface implements ITextfieldListener, IGuiError, IGuiClose, GuiYesNoCallback -{ +public class GuiMailmanWrite extends GuiContainerNPCInterface implements ITextfieldListener, IGuiError, IGuiClose, GuiYesNoCallback { private static final ResourceLocation bookGuiTextures = new ResourceLocation("textures/gui/book.png"); private static final ResourceLocation bookWidgets = new ResourceLocation("textures/gui/widgets.png"); private static final ResourceLocation bookInventory = new ResourceLocation("textures/gui/container/inventory.png"); - /** Update ticks since the gui was opened */ + /** + * Update ticks since the gui was opened + */ private int updateCount; private int bookImageWidth = 192; private int bookImageHeight = 192; @@ -41,38 +42,35 @@ public class GuiMailmanWrite extends GuiContainerNPCInterface implements ITextfi private boolean canEdit; private boolean canSend; - /** The GuiButton to sign this book. */ + /** + * The GuiButton to sign this book. + */ public static GuiScreen parent; - public static PlayerMail mail = new PlayerMail(); + public static PlayerMail mail = new PlayerMail(); private Minecraft mc = Minecraft.getMinecraft(); - private String username = ""; - private GuiNpcLabel error; + private String username = ""; + private GuiNpcLabel error; - public GuiMailmanWrite(ContainerMail container, boolean canEdit, boolean canSend) - { - super(null, container); - title = ""; + public GuiMailmanWrite(ContainerMail container, boolean canEdit, boolean canSend) { + super(null, container); + title = ""; this.canEdit = canEdit; this.canSend = canSend; - if(mail.message.hasKey("pages")) - this.bookPages = mail.message.getTagList("pages", 8); + if (mail.message.hasKey("pages")) + this.bookPages = mail.message.getTagList("pages", 8); - if (this.bookPages != null) - { - this.bookPages = (NBTTagList)this.bookPages.copy(); + if (this.bookPages != null) { + this.bookPages = (NBTTagList) this.bookPages.copy(); this.bookTotalPages = this.bookPages.tagCount(); - if (this.bookTotalPages < 1) - { + if (this.bookTotalPages < 1) { this.bookTotalPages = 1; } - } - else - { + } else { this.bookPages = new NBTTagList(); this.bookPages.appendTag(new NBTTagString("")); this.bookTotalPages = 1; @@ -82,11 +80,11 @@ public class GuiMailmanWrite extends GuiContainerNPCInterface implements ITextfi drawDefaultBackground = false; closeOnEsc = true; } + /** * Called from the main game loop to update the screen. */ - public void updateScreen() - { + public void updateScreen() { super.updateScreen(); ++this.updateCount; } @@ -94,40 +92,39 @@ public class GuiMailmanWrite extends GuiContainerNPCInterface implements ITextfi /** * Adds the buttons (and other controls) to the screen in question. */ - public void initGui() - { - super.initGui(); + public void initGui() { + super.initGui(); this.buttonList.clear(); Keyboard.enableRepeatEvents(true); - if(canEdit && !canSend) - addLabel(new GuiNpcLabel(0, "mailbox.sender", guiLeft + 170, guiTop + 32, 0)); - else - addLabel(new GuiNpcLabel(0, "mailbox.username", guiLeft + 170, guiTop + 32, 0)); + if (canEdit && !canSend) + addLabel(new GuiNpcLabel(0, "mailbox.sender", guiLeft + 170, guiTop + 32, 0)); + else + addLabel(new GuiNpcLabel(0, "mailbox.username", guiLeft + 170, guiTop + 32, 0)); - if(canEdit && !canSend) - addTextField(new GuiNpcTextField(2, this, fontRendererObj, guiLeft + 170, guiTop + 42, 114, 20, mail.sender)); - else if(canEdit) - addTextField(new GuiNpcTextField(0, this, fontRendererObj, guiLeft + 170, guiTop + 42, 114, 20, username)); - else - addLabel(new GuiNpcLabel(10, mail.sender, guiLeft + 170, guiTop + 42, 0)); + if (canEdit && !canSend) + addTextField(new GuiNpcTextField(2, this, fontRendererObj, guiLeft + 170, guiTop + 42, 114, 20, mail.sender)); + else if (canEdit) + addTextField(new GuiNpcTextField(0, this, fontRendererObj, guiLeft + 170, guiTop + 42, 114, 20, username)); + else + addLabel(new GuiNpcLabel(10, mail.sender, guiLeft + 170, guiTop + 42, 0)); - addLabel(new GuiNpcLabel(1, "mailbox.subject", guiLeft + 170, guiTop + 72, 0)); - if(canEdit) - addTextField(new GuiNpcTextField(1, this, fontRendererObj, guiLeft + 170, guiTop + 82, 114, 20, mail.subject)); - else - addLabel(new GuiNpcLabel(11, mail.subject, guiLeft + 170, guiTop + 82, 0)); + addLabel(new GuiNpcLabel(1, "mailbox.subject", guiLeft + 170, guiTop + 72, 0)); + if (canEdit) + addTextField(new GuiNpcTextField(1, this, fontRendererObj, guiLeft + 170, guiTop + 82, 114, 20, mail.subject)); + else + addLabel(new GuiNpcLabel(11, mail.subject, guiLeft + 170, guiTop + 82, 0)); - addLabel(error = new GuiNpcLabel(2, "", guiLeft + 170, guiTop + 114, 0xFF0000)); - if(canEdit && !canSend) - addButton(new GuiNpcButton(0, this.guiLeft + 200, guiTop + 171, 60, 20, "gui.done")); - else if(canEdit) - addButton(new GuiNpcButton(0, this.guiLeft + 200, guiTop + 171, 60, 20, "mailbox.send")); + addLabel(error = new GuiNpcLabel(2, "", guiLeft + 170, guiTop + 114, 0xFF0000)); + if (canEdit && !canSend) + addButton(new GuiNpcButton(0, this.guiLeft + 200, guiTop + 171, 60, 20, "gui.done")); + else if (canEdit) + addButton(new GuiNpcButton(0, this.guiLeft + 200, guiTop + 171, 60, 20, "mailbox.send")); - if(!canEdit && !canSend) - addButton(new GuiNpcButton(4, this.guiLeft + 200, guiTop + 171, 60, 20, "selectWorld.deleteButton")); - if(!canEdit || canSend) - addButton(new GuiNpcButton(3, this.guiLeft + 200, guiTop + 194, 60, 20, "gui.cancel")); + if (!canEdit && !canSend) + addButton(new GuiNpcButton(4, this.guiLeft + 200, guiTop + 171, 60, 20, "selectWorld.deleteButton")); + if (!canEdit || canSend) + addButton(new GuiNpcButton(3, this.guiLeft + 200, guiTop + 194, 60, 20, "gui.cancel")); this.buttonList.add(this.buttonNextPage = new GuiButtonNextPage(1, guiLeft + 120, guiTop + 156, true)); this.buttonList.add(this.buttonPreviousPage = new GuiButtonNextPage(2, guiLeft + 38, guiTop + 156, false)); @@ -137,73 +134,56 @@ public class GuiMailmanWrite extends GuiContainerNPCInterface implements ITextfi /** * Called when the screen is unloaded. Used to disable keyboard repeat events */ - public void onGuiClosed() - { + public void onGuiClosed() { Keyboard.enableRepeatEvents(false); } - private void updateButtons() - { + private void updateButtons() { this.buttonNextPage.setVisible(this.currPage < this.bookTotalPages - 1 || this.canEdit); this.buttonPreviousPage.setVisible(this.currPage > 0); } - @Override - public void confirmClicked(boolean flag, int i) - { - if(flag){ + @Override + public void confirmClicked(boolean flag, int i) { + if (flag) { MailActionPacket.DeleteMail(mail.time, mail.sender); - close(); - } - else - NoppesUtil.openGUI(player, this); + close(); + } else + NoppesUtil.openGUI(player, this); } /** * Fired when a control is clicked. This is the equivalent of ActionListener.actionPerformed(ActionEvent e). */ @Override - protected void actionPerformed(GuiButton par1GuiButton) - { - if (par1GuiButton.enabled) - { - int id = par1GuiButton.id; - if(id == 0){ - mail.message.setTag("pages", bookPages); - if(canSend) + protected void actionPerformed(GuiButton par1GuiButton) { + if (par1GuiButton.enabled) { + int id = par1GuiButton.id; + if (id == 0) { + mail.message.setTag("pages", bookPages); + if (canSend) MailActionPacket.SendMail(this.username, mail.writeNBT()); - else - close(); - } - if (id == 3) - { + else + close(); + } + if (id == 3) { close(); } - if (id == 4) - { + if (id == 4) { GuiYesNo guiyesno = new GuiYesNo(this, "Confirm", StatCollector.translateToLocal("gui.delete"), 0); displayGuiScreen(guiyesno); - } - else if (id == 1) - { - if (this.currPage < this.bookTotalPages - 1) - { + } else if (id == 1) { + if (this.currPage < this.bookTotalPages - 1) { ++this.currPage; - } - else if (this.canEdit) - { + } else if (this.canEdit) { this.addNewPage(); - if (this.currPage < this.bookTotalPages - 1) - { + if (this.currPage < this.bookTotalPages - 1) { ++this.currPage; } } - } - else if (id == 2) - { - if (this.currPage > 0) - { + } else if (id == 2) { + if (this.currPage > 0) { --this.currPage; } } @@ -212,10 +192,8 @@ public class GuiMailmanWrite extends GuiContainerNPCInterface implements ITextfi } } - private void addNewPage() - { - if (this.bookPages != null && this.bookPages.tagCount() < 50) - { + private void addNewPage() { + if (this.bookPages != null && this.bookPages.tagCount() < 50) { this.bookPages.appendTag(new NBTTagString("")); ++this.bookTotalPages; } @@ -224,32 +202,27 @@ public class GuiMailmanWrite extends GuiContainerNPCInterface implements ITextfi /** * Fired when a key is typed. This is the equivalent of KeyListener.keyTyped(KeyEvent e). */ - public void keyTyped(char par1, int par2) - { - if(!GuiNpcTextField.isFieldActive() && canEdit) - this.keyTypedInBook(par1, par2); - else - super.keyTyped(par1, par2); + public void keyTyped(char par1, int par2) { + if (!GuiNpcTextField.isFieldActive() && canEdit) + this.keyTypedInBook(par1, par2); + else + super.keyTyped(par1, par2); } /** * Processes keystrokes when editing the text of a book */ - private void keyTypedInBook(char par1, int par2) - { - switch (par1) - { + private void keyTypedInBook(char par1, int par2) { + switch (par1) { case 22: this.func_74160_b(GuiScreen.getClipboardString());//getClipboardString return; default: - switch (par2) - { + switch (par2) { case 14: String s = this.func_74158_i(); - if (s.length() > 0) - { + if (s.length() > 0) { this.func_74159_a(s.substring(0, s.length() - 1)); } @@ -259,42 +232,33 @@ public class GuiMailmanWrite extends GuiContainerNPCInterface implements ITextfi this.func_74160_b("\n"); return; default: - if (ChatAllowedCharacters.isAllowedCharacter(par1)) - { + if (ChatAllowedCharacters.isAllowedCharacter(par1)) { this.func_74160_b(Character.toString(par1)); } } } } - private String func_74158_i() - { - if (this.bookPages != null && this.currPage >= 0 && this.currPage < this.bookPages.tagCount()) - { + private String func_74158_i() { + if (this.bookPages != null && this.currPage >= 0 && this.currPage < this.bookPages.tagCount()) { return this.bookPages.getStringTagAt(this.currPage); - } - else - { + } else { return ""; } } - private void func_74159_a(String par1Str) - { - if (this.bookPages != null && this.currPage >= 0 && this.currPage < this.bookPages.tagCount()) - { - bookPages.func_150304_a(currPage, new NBTTagString(par1Str)); + private void func_74159_a(String par1Str) { + if (this.bookPages != null && this.currPage >= 0 && this.currPage < this.bookPages.tagCount()) { + bookPages.func_150304_a(currPage, new NBTTagString(par1Str)); } } - private void func_74160_b(String par1Str) - { + private void func_74160_b(String par1Str) { String s1 = this.func_74158_i(); String s2 = s1 + par1Str; int i = mc.fontRenderer.splitStringWidth(s2 + "" + EnumChatFormatting.BLACK + "_", 118); - if (i <= 118 && s2.length() < 256) - { + if (i <= 118 && s2.length() < 256) { this.func_74159_a(s2); } } @@ -302,13 +266,12 @@ public class GuiMailmanWrite extends GuiContainerNPCInterface implements ITextfi /** * Draws the screen and all the components in it. */ - public void drawScreen(int par1, int par2, float par3) - { + public void drawScreen(int par1, int par2, float par3) { this.drawWorldBackground(0); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); this.mc.getTextureManager().bindTexture(bookGuiTextures); this.drawTexturedModalRect(guiLeft + 130, guiTop + 22, 0, 0, this.bookImageWidth, this.bookImageHeight / 3); - this.drawTexturedModalRect(guiLeft + 130, guiTop + 22 + bookImageHeight/3, 0, bookImageHeight / 2, this.bookImageWidth, this.bookImageHeight / 2); + this.drawTexturedModalRect(guiLeft + 130, guiTop + 22 + bookImageHeight / 3, 0, bookImageHeight / 2, this.bookImageWidth, this.bookImageHeight / 2); this.drawTexturedModalRect(guiLeft, guiTop + 2, 0, 0, this.bookImageWidth, this.bookImageHeight); @@ -319,27 +282,21 @@ public class GuiMailmanWrite extends GuiContainerNPCInterface implements ITextfi String s1; int l; - s = I18n.format("book.pageIndicator", new Object[] {Integer.valueOf(this.currPage + 1), Integer.valueOf(this.bookTotalPages)}); + s = I18n.format("book.pageIndicator", new Object[]{Integer.valueOf(this.currPage + 1), Integer.valueOf(this.bookTotalPages)}); s1 = ""; - if (this.bookPages != null && this.currPage >= 0 && this.currPage < this.bookPages.tagCount()) - { + if (this.bookPages != null && this.currPage >= 0 && this.currPage < this.bookPages.tagCount()) { s1 = this.bookPages.getStringTagAt(this.currPage); } - if(canEdit){ - if (mc.fontRenderer.getBidiFlag()) - { - s1 = s1 + "_"; - } - else if (this.updateCount / 6 % 2 == 0) - { - s1 = s1 + "" + EnumChatFormatting.BLACK + "_"; - } - else - { - s1 = s1 + "" + EnumChatFormatting.GRAY + "_"; - } + if (canEdit) { + if (mc.fontRenderer.getBidiFlag()) { + s1 = s1 + "_"; + } else if (this.updateCount / 6 % 2 == 0) { + s1 = s1 + "" + EnumChatFormatting.BLACK + "_"; + } else { + s1 = s1 + "" + EnumChatFormatting.GRAY + "_"; + } } l = mc.fontRenderer.getStringWidth(s); @@ -351,44 +308,44 @@ public class GuiMailmanWrite extends GuiContainerNPCInterface implements ITextfi this.mc.getTextureManager().bindTexture(bookWidgets); - for(int i = 0; i < 4; i++) - this.drawTexturedModalRect(guiLeft + 175 + i * 24, guiTop + 134, 0, 22, 24, 24); + for (int i = 0; i < 4; i++) + this.drawTexturedModalRect(guiLeft + 175 + i * 24, guiTop + 134, 0, 22, 24, 24); super.drawScreen(par1, par2, par3); } - public void close(){ - mc.displayGuiScreen(parent); - parent = null; - mail = new PlayerMail(); + public void close() { + mc.displayGuiScreen(parent); + parent = null; + mail = new PlayerMail(); } - @Override - public void unFocused(GuiNpcTextField textField) { - if(textField.id == 0) - username = textField.getText(); - if(textField.id == 1) - mail.subject = textField.getText(); - if(textField.id == 2) - mail.sender = textField.getText(); - } + @Override + public void unFocused(GuiNpcTextField textField) { + if (textField.id == 0) + username = textField.getText(); + if (textField.id == 1) + mail.subject = textField.getText(); + if (textField.id == 2) + mail.sender = textField.getText(); + } - @Override - public void setError(int i, NBTTagCompound data) { - if(i == 0) - error.label = StatCollector.translateToLocal("mailbox.errorUsername"); - if(i == 1) - error.label = StatCollector.translateToLocal("mailbox.errorSubject"); - } + @Override + public void setError(int i, NBTTagCompound data) { + if (i == 0) + error.label = StatCollector.translateToLocal("mailbox.errorUsername"); + if (i == 1) + error.label = StatCollector.translateToLocal("mailbox.errorSubject"); + } - @Override - public void setClose(int i, NBTTagCompound data) { - player.addChatMessage(new ChatComponentTranslation("mailbox.succes", data.getString("username"))); - } + @Override + public void setClose(int i, NBTTagCompound data) { + player.addChatMessage(new ChatComponentTranslation("mailbox.succes", data.getString("username"))); + } - @Override - public void save() { + @Override + public void save() { - } + } } diff --git a/src/main/java/noppes/npcs/client/gui/player/GuiNPCBankChest.java b/src/main/java/noppes/npcs/client/gui/player/GuiNPCBankChest.java index 1db1ff318..e13fb9a68 100644 --- a/src/main/java/noppes/npcs/client/gui/player/GuiNPCBankChest.java +++ b/src/main/java/noppes/npcs/client/gui/player/GuiNPCBankChest.java @@ -17,18 +17,16 @@ import noppes.npcs.entity.EntityNPCInterface; import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; -public class GuiNPCBankChest extends GuiContainerNPCInterface implements IGuiData -{ - private final ResourceLocation resource = new ResourceLocation("customnpcs","textures/gui/bankchest.png"); +public class GuiNPCBankChest extends GuiContainerNPCInterface implements IGuiData { + private final ResourceLocation resource = new ResourceLocation("customnpcs", "textures/gui/bankchest.png"); private ContainerNPCBankInterface container; private int availableSlots = 0; private int maxSlots = 1; private int unlockedSlots = 1; private ItemStack currency; - public GuiNPCBankChest(EntityNPCInterface npc,ContainerNPCBankInterface container) - { - super(npc,container); + public GuiNPCBankChest(EntityNPCInterface npc, ContainerNPCBankInterface container) { + super(npc, container); this.container = container; this.title = ""; allowUserInput = false; //allowUserInput @@ -36,122 +34,120 @@ public class GuiNPCBankChest extends GuiContainerNPCInterface implements IGuiDat closeOnEsc = true; } + @Override - public void initGui(){ - super.initGui(); - availableSlots = 0; - if(maxSlots > 1){ - for(int i = 0; i < maxSlots ; i++){ - GuiNpcButton button = new GuiNpcButton(i, guiLeft - 50, guiTop + 10 + i * 24, 50, 20, "Tab " + (i+1)); - if( i > unlockedSlots) - button.setEnabled(false); - addButton(button); - availableSlots++; - } - if(availableSlots == 1) - buttonList.clear(); - } - if(!container.isAvailable()){ - addButton(new GuiNpcButton(8, guiLeft + 48, guiTop + 48,80,20, StatCollector.translateToLocal("bank.unlock"))); + public void initGui() { + super.initGui(); + availableSlots = 0; + if (maxSlots > 1) { + for (int i = 0; i < maxSlots; i++) { + GuiNpcButton button = new GuiNpcButton(i, guiLeft - 50, guiTop + 10 + i * 24, 50, 20, "Tab " + (i + 1)); + if (i > unlockedSlots) + button.setEnabled(false); + addButton(button); + availableSlots++; + } + if (availableSlots == 1) + buttonList.clear(); } - else if(container.canBeUpgraded()){ - addButton(new GuiNpcButton(9, guiLeft + 48, guiTop + 48,80,20, StatCollector.translateToLocal("bank.upgrade"))); + if (!container.isAvailable()) { + addButton(new GuiNpcButton(8, guiLeft + 48, guiTop + 48, 80, 20, StatCollector.translateToLocal("bank.unlock"))); + } else if (container.canBeUpgraded()) { + addButton(new GuiNpcButton(9, guiLeft + 48, guiTop + 48, 80, 20, StatCollector.translateToLocal("bank.upgrade"))); + } + if (maxSlots > 1) { + getButton(container.slot).visible = false; + getButton(container.slot).setEnabled(false); } - if(maxSlots > 1){ - getButton(container.slot).visible = false; - getButton(container.slot).setEnabled(false); - } } + @Override - public void actionPerformed(GuiButton guibutton) - { - super.actionPerformed(guibutton); - int id = guibutton.id; - if(id < 6){ - close(); + public void actionPerformed(GuiButton guibutton) { + super.actionPerformed(guibutton); + int id = guibutton.id; + if (id < 6) { + close(); BankActionPacket.Open(container.bankid, id); - } - if(id == 8){ + } + if (id == 8) { BankActionPacket.Unlock(); - } - if(id == 9){ + } + if (id == 9) { BankActionPacket.Upgrade(); - } + } } @Override - protected void drawGuiContainerBackgroundLayer(float f, int i, int j) - { + protected void drawGuiContainerBackgroundLayer(float f, int i, int j) { GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); mc.renderEngine.bindTexture(resource); int l = (width - xSize) / 2; int i1 = (height - ySize) / 2; drawTexturedModalRect(l, i1, 0, 0, xSize, 6); - if(!container.isAvailable()){ - drawTexturedModalRect(l, i1 + 6, 0, 6, xSize, 64); - drawTexturedModalRect(l, i1 + 70, 0, 124, xSize, 222-124); - int x = guiLeft + 30; - int y = guiTop + 8; - fontRendererObj.drawString(StatCollector.translateToLocal("bank.unlockCosts")+":", x , y + 4 , CustomNpcResourceListener.DefaultTextColor); - drawItem(x + 90,y,currency,i,j); + if (!container.isAvailable()) { + drawTexturedModalRect(l, i1 + 6, 0, 6, xSize, 64); + drawTexturedModalRect(l, i1 + 70, 0, 124, xSize, 222 - 124); + int x = guiLeft + 30; + int y = guiTop + 8; + fontRendererObj.drawString(StatCollector.translateToLocal("bank.unlockCosts") + ":", x, y + 4, CustomNpcResourceListener.DefaultTextColor); + drawItem(x + 90, y, currency, i, j); + } else if (container.isUpgraded()) { + drawTexturedModalRect(l, i1 + 60, 0, 60, xSize, 162); + drawTexturedModalRect(l, i1 + 6, 0, 60, xSize, 64); + } else if (container.canBeUpgraded()) { + drawTexturedModalRect(l, i1 + 6, 0, 6, xSize, 216); + int x = guiLeft + 30; + int y = guiTop + 8; + fontRendererObj.drawString(StatCollector.translateToLocal("bank.upgradeCosts") + ":", x, y + 4, CustomNpcResourceListener.DefaultTextColor); + drawItem(x + 90, y, currency, i, j); + } else { + drawTexturedModalRect(l, i1 + 6, 0, 60, xSize, 162); } - else if(container.isUpgraded()){ - drawTexturedModalRect(l, i1 + 60, 0, 60, xSize, 162); - drawTexturedModalRect(l, i1 + 6, 0, 60, xSize, 64); - } - else if(container.canBeUpgraded()){ - drawTexturedModalRect(l, i1 + 6, 0, 6, xSize, 216); - int x = guiLeft + 30; - int y = guiTop + 8; - fontRendererObj.drawString(StatCollector.translateToLocal("bank.upgradeCosts") + ":", x , y + 4 , CustomNpcResourceListener.DefaultTextColor); - drawItem(x + 90,y,currency,i,j); - } - else{ - drawTexturedModalRect(l, i1 + 6, 0, 60, xSize, 162); - } - if(maxSlots > 1){ - for(int ii = 0; ii < maxSlots ; ii++){ - if(availableSlots == ii) - break; - fontRendererObj.drawString("Tab " + (ii+1), guiLeft - 40, guiTop + 16 + ii * 24 , 0xFFFFFF); - } + if (maxSlots > 1) { + for (int ii = 0; ii < maxSlots; ii++) { + if (availableSlots == ii) + break; + fontRendererObj.drawString("Tab " + (ii + 1), guiLeft - 40, guiTop + 16 + ii * 24, 0xFFFFFF); + } } super.drawGuiContainerBackgroundLayer(f, i, j); } - private void drawItem(int x, int y, ItemStack item, int mouseX, int mouseY){ - if(item == null) - return; + + private void drawItem(int x, int y, ItemStack item, int mouseX, int mouseY) { + if (item == null) + return; RenderHelper.enableGUIStandardItemLighting(); GL11.glEnable(GL12.GL_RESCALE_NORMAL); GL11.glEnable(GL11.GL_COLOR_MATERIAL); GL11.glEnable(GL11.GL_LIGHTING); GL11.glColor4f(1, 1, 1, 1); - itemRender.renderItemAndEffectIntoGUI(fontRendererObj, mc.renderEngine, item, x,y); - itemRender.renderItemOverlayIntoGUI(fontRendererObj, mc.renderEngine, item, x,y); + itemRender.renderItemAndEffectIntoGUI(fontRendererObj, mc.renderEngine, item, x, y); + itemRender.renderItemOverlayIntoGUI(fontRendererObj, mc.renderEngine, item, x, y); - if (this.func_146978_c(x - guiLeft, y - guiTop, 16, 16, mouseX, mouseY)) - { + if (this.func_146978_c(x - guiLeft, y - guiTop, 16, 16, mouseX, mouseY)) { this.renderToolTip(item, mouseX, mouseY); } RenderHelper.disableStandardItemLighting(); GL11.glColor4f(1, 1, 1, 1); } - @Override - public void save() { - return; - } - @Override - public void setGuiData(NBTTagCompound compound) { - maxSlots = compound.getInteger("MaxSlots"); - unlockedSlots = compound.getInteger("UnlockedSlots"); - if(compound.hasKey("Currency")) - currency = NoppesUtilServer.readItem(compound.getCompoundTag("Currency")); - else - currency = null; - if(container.currency != null) - container.currency.item = currency; - initGui(); - } + + @Override + public void save() { + return; + } + + @Override + public void setGuiData(NBTTagCompound compound) { + maxSlots = compound.getInteger("MaxSlots"); + unlockedSlots = compound.getInteger("UnlockedSlots"); + if (compound.hasKey("Currency")) + currency = NoppesUtilServer.readItem(compound.getCompoundTag("Currency")); + else + currency = null; + if (container.currency != null) + container.currency.item = currency; + initGui(); + } } diff --git a/src/main/java/noppes/npcs/client/gui/player/GuiNPCTrader.java b/src/main/java/noppes/npcs/client/gui/player/GuiNPCTrader.java index a0e3f44cb..d23b15398 100644 --- a/src/main/java/noppes/npcs/client/gui/player/GuiNPCTrader.java +++ b/src/main/java/noppes/npcs/client/gui/player/GuiNPCTrader.java @@ -13,13 +13,13 @@ import noppes.npcs.roles.RoleTrader; import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; -public class GuiNPCTrader extends GuiContainerNPCInterface{ - private final ResourceLocation resource = new ResourceLocation("customnpcs","textures/gui/trader.png"); - private final ResourceLocation slot = new ResourceLocation("customnpcs","textures/gui/slot.png"); - private RoleTrader role; - private ContainerNPCTrader container; - - public GuiNPCTrader(EntityNPCInterface npc, ContainerNPCTrader container){ +public class GuiNPCTrader extends GuiContainerNPCInterface { + private final ResourceLocation resource = new ResourceLocation("customnpcs", "textures/gui/trader.png"); + private final ResourceLocation slot = new ResourceLocation("customnpcs", "textures/gui/slot.png"); + private RoleTrader role; + private ContainerNPCTrader container; + + public GuiNPCTrader(EntityNPCInterface npc, ContainerNPCTrader container) { super(npc, container); this.container = container; role = (RoleTrader) npc.roleInterface; @@ -30,7 +30,7 @@ public class GuiNPCTrader extends GuiContainerNPCInterface{ } @Override - protected void drawGuiContainerBackgroundLayer(float f, int i, int j){ + protected void drawGuiContainerBackgroundLayer(float f, int i, int j) { this.drawWorldBackground(0); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); mc.renderEngine.bindTexture(resource); @@ -41,100 +41,99 @@ public class GuiNPCTrader extends GuiContainerNPCInterface{ GL11.glEnable(GL11.GL_LIGHTING); mc.renderEngine.bindTexture(slot); - for(int slot = 0; slot < 18; slot++){ - int x = guiLeft + slot%3 * 72 + 10; - int y = guiTop + slot/3 * 21 + 6; - - ItemStack item = role.inventoryCurrency.items.get(slot); - ItemStack item2 = role.inventoryCurrency.items.get(slot + 18); - if(item == null){ - item = item2; - item2 = null; - } - if(NoppesUtilPlayer.compareItems(item, item2, false, false)){ - item = item.copy(); - item.stackSize += item2.stackSize; - item2 = null; - } + for (int slot = 0; slot < 18; slot++) { + int x = guiLeft + slot % 3 * 72 + 10; + int y = guiTop + slot / 3 * 21 + 6; - ItemStack sold = role.inventorySold.items.get(slot); - GL11.glColor4f(1, 1, 1, 1); - mc.renderEngine.bindTexture(this.slot); - drawTexturedModalRect(x + 42, y, 0, 0, 18, 18); - if(item != null && sold != null){ - RenderHelper.enableGUIStandardItemLighting(); - - if(item2 != null){ - itemRender.renderItemAndEffectIntoGUI(fontRendererObj, mc.renderEngine, item2, x, y + 1); - itemRender.renderItemOverlayIntoGUI(fontRendererObj, mc.renderEngine, item2, x, y + 1); - } - GL11.glColor4f(1, 1, 1, 1); - itemRender.renderItemAndEffectIntoGUI(fontRendererObj, mc.renderEngine, item, x + 18, y + 1); - itemRender.renderItemOverlayIntoGUI(fontRendererObj, mc.renderEngine, item, x + 18, y + 1); - RenderHelper.disableStandardItemLighting(); - - fontRendererObj.drawString("=", x + 36, y + 5, CustomNpcResourceListener.DefaultTextColor); + ItemStack item = role.inventoryCurrency.items.get(slot); + ItemStack item2 = role.inventoryCurrency.items.get(slot + 18); + if (item == null) { + item = item2; + item2 = null; + } + if (NoppesUtilPlayer.compareItems(item, item2, false, false)) { + item = item.copy(); + item.stackSize += item2.stackSize; + item2 = null; + } - } - } + ItemStack sold = role.inventorySold.items.get(slot); + GL11.glColor4f(1, 1, 1, 1); + mc.renderEngine.bindTexture(this.slot); + drawTexturedModalRect(x + 42, y, 0, 0, 18, 18); + if (item != null && sold != null) { + RenderHelper.enableGUIStandardItemLighting(); + + if (item2 != null) { + itemRender.renderItemAndEffectIntoGUI(fontRendererObj, mc.renderEngine, item2, x, y + 1); + itemRender.renderItemOverlayIntoGUI(fontRendererObj, mc.renderEngine, item2, x, y + 1); + } + GL11.glColor4f(1, 1, 1, 1); + itemRender.renderItemAndEffectIntoGUI(fontRendererObj, mc.renderEngine, item, x + 18, y + 1); + itemRender.renderItemOverlayIntoGUI(fontRendererObj, mc.renderEngine, item, x + 18, y + 1); + RenderHelper.disableStandardItemLighting(); + + fontRendererObj.drawString("=", x + 36, y + 5, CustomNpcResourceListener.DefaultTextColor); + + } + } GL11.glEnable(GL11.GL_LIGHTING); GL11.glEnable(GL11.GL_DEPTH_TEST); RenderHelper.enableStandardItemLighting(); - super.drawGuiContainerBackgroundLayer(f, i, j); + super.drawGuiContainerBackgroundLayer(f, i, j); } + @Override - protected void drawGuiContainerForegroundLayer(int par1, int par2){ - for(int slot = 0; slot < 18; slot++){ - int x = slot%3 * 72 + 10; - int y = slot/3 * 21 + 6; - - ItemStack item = role.inventoryCurrency.items.get(slot); - ItemStack item2 = role.inventoryCurrency.items.get(slot + 18); - if(item == null){ - item = item2; - item2 = null; - } - if(NoppesUtilPlayer.compareItems(item, item2, role.ignoreDamage, role.ignoreNBT)){ - item = item.copy(); - item.stackSize += item2.stackSize; - item2 = null; - } - ItemStack sold = role.inventorySold.items.get(slot); - if(item == null || sold == null) - continue; + protected void drawGuiContainerForegroundLayer(int par1, int par2) { + for (int slot = 0; slot < 18; slot++) { + int x = slot % 3 * 72 + 10; + int y = slot / 3 * 21 + 6; - if(this.func_146978_c(x + 43, y + 1, 16, 16, par1, par2)){ - if(!container.canBuy(slot, player)){ - GL11.glTranslatef(0, 0, 300); - if(item != null && !NoppesUtilPlayer.compareItems(player, item, role.ignoreDamage, role.ignoreNBT)) - this.drawGradientRect(x + 17, y, x + 35, y + 18, 0x70771010, 0x70771010); - if(item2 != null && !NoppesUtilPlayer.compareItems(player, item2, role.ignoreDamage, role.ignoreNBT)) - this.drawGradientRect(x - 1, y, x + 17, y + 18, 0x70771010, 0x70771010); - - String title = StatCollector.translateToLocal("trader.insufficient"); - this.fontRendererObj.drawString(title, (xSize - fontRendererObj.getStringWidth(title))/2, 131, 0xDD0000); - GL11.glTranslatef(0, 0, -300); - } - else if (!container.isSlotEnabled(slot, player)) { - String title = StatCollector.translateToLocal("trader.slotdisabled"); - this.fontRendererObj.drawString(title, (xSize - fontRendererObj.getStringWidth(title))/2, 131, 0xFF4000 ); - } - else{ - String title = StatCollector.translateToLocal("trader.sufficient"); - this.fontRendererObj.drawString(title, (xSize - fontRendererObj.getStringWidth(title))/2, 131, 0x00DD00); - } - } + ItemStack item = role.inventoryCurrency.items.get(slot); + ItemStack item2 = role.inventoryCurrency.items.get(slot + 18); + if (item == null) { + item = item2; + item2 = null; + } + if (NoppesUtilPlayer.compareItems(item, item2, role.ignoreDamage, role.ignoreNBT)) { + item = item.copy(); + item.stackSize += item2.stackSize; + item2 = null; + } + ItemStack sold = role.inventorySold.items.get(slot); + if (item == null || sold == null) + continue; - if (this.func_146978_c(x, y, 16, 16, par1, par2) && item2 != null){ + if (this.func_146978_c(x + 43, y + 1, 16, 16, par1, par2)) { + if (!container.canBuy(slot, player)) { + GL11.glTranslatef(0, 0, 300); + if (item != null && !NoppesUtilPlayer.compareItems(player, item, role.ignoreDamage, role.ignoreNBT)) + this.drawGradientRect(x + 17, y, x + 35, y + 18, 0x70771010, 0x70771010); + if (item2 != null && !NoppesUtilPlayer.compareItems(player, item2, role.ignoreDamage, role.ignoreNBT)) + this.drawGradientRect(x - 1, y, x + 17, y + 18, 0x70771010, 0x70771010); + + String title = StatCollector.translateToLocal("trader.insufficient"); + this.fontRendererObj.drawString(title, (xSize - fontRendererObj.getStringWidth(title)) / 2, 131, 0xDD0000); + GL11.glTranslatef(0, 0, -300); + } else if (!container.isSlotEnabled(slot, player)) { + String title = StatCollector.translateToLocal("trader.slotdisabled"); + this.fontRendererObj.drawString(title, (xSize - fontRendererObj.getStringWidth(title)) / 2, 131, 0xFF4000); + } else { + String title = StatCollector.translateToLocal("trader.sufficient"); + this.fontRendererObj.drawString(title, (xSize - fontRendererObj.getStringWidth(title)) / 2, 131, 0x00DD00); + } + } + + if (this.func_146978_c(x, y, 16, 16, par1, par2) && item2 != null) { this.renderToolTip(item2, par1 - guiLeft, par2 - guiTop); } - if (this.func_146978_c(x + 18, y, 16, 16, par1, par2)){ + if (this.func_146978_c(x + 18, y, 16, 16, par1, par2)) { this.renderToolTip(item, par1 - guiLeft, par2 - guiTop); } - } + } + } + + @Override + public void save() { } - - @Override - public void save() { - } } diff --git a/src/main/java/noppes/npcs/client/gui/player/GuiNpcCarpentryBench.java b/src/main/java/noppes/npcs/client/gui/player/GuiNpcCarpentryBench.java index b40544fa2..6c59de3ca 100644 --- a/src/main/java/noppes/npcs/client/gui/player/GuiNpcCarpentryBench.java +++ b/src/main/java/noppes/npcs/client/gui/player/GuiNpcCarpentryBench.java @@ -10,50 +10,48 @@ import noppes.npcs.containers.ContainerCarpentryBench; import noppes.npcs.controllers.RecipeController; import org.lwjgl.opengl.GL11; -public class GuiNpcCarpentryBench extends GuiContainerNPCInterface -{ - private final ResourceLocation resource = new ResourceLocation("customnpcs","textures/gui/carpentry.png"); +public class GuiNpcCarpentryBench extends GuiContainerNPCInterface { + private final ResourceLocation resource = new ResourceLocation("customnpcs", "textures/gui/carpentry.png"); private ContainerCarpentryBench container; private GuiNpcButton button; - public GuiNpcCarpentryBench(ContainerCarpentryBench container) - { - super(null,container); + public GuiNpcCarpentryBench(ContainerCarpentryBench container) { + super(null, container); this.container = container; this.title = ""; allowUserInput = false;//allowUserInput closeOnEsc = true; ySize = 180; } + @Override - public void initGui(){ - super.initGui(); - addButton(button = new GuiNpcButton(0, guiLeft + 158, guiTop + 4, 12, 20, "...")); + public void initGui() { + super.initGui(); + addButton(button = new GuiNpcButton(0, guiLeft + 158, guiTop + 4, 12, 20, "...")); } - public void buttonEvent(GuiButton guibutton){ - displayGuiScreen(new GuiRecipes()); + public void buttonEvent(GuiButton guibutton) { + displayGuiScreen(new GuiRecipes()); } @Override - protected void drawGuiContainerBackgroundLayer(float f, int i, int j) - { - button.enabled = RecipeController.Instance != null && !RecipeController.Instance.carpentryRecipes.isEmpty(); + protected void drawGuiContainerBackgroundLayer(float f, int i, int j) { + button.enabled = RecipeController.Instance != null && !RecipeController.Instance.carpentryRecipes.isEmpty(); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); mc.renderEngine.bindTexture(resource); int l = (width - xSize) / 2; int i1 = (height - ySize) / 2; String title = StatCollector.translateToLocal("tile.npcCarpentyBench.name"); - if(container.getMetadata() >= 4) - title = StatCollector.translateToLocal("tile.anvil.name"); + if (container.getMetadata() >= 4) + title = StatCollector.translateToLocal("tile.anvil.name"); drawTexturedModalRect(l, i1, 0, 0, xSize, ySize); super.drawGuiContainerBackgroundLayer(f, i, j); - fontRendererObj.drawString(title, guiLeft + 4 , guiTop + 4 , CustomNpcResourceListener.DefaultTextColor); + fontRendererObj.drawString(title, guiLeft + 4, guiTop + 4, CustomNpcResourceListener.DefaultTextColor); fontRendererObj.drawString(StatCollector.translateToLocal("container.inventory"), guiLeft + 4, guiTop + 87, CustomNpcResourceListener.DefaultTextColor); } - @Override - public void save() { - return; - } + @Override + public void save() { + return; + } } diff --git a/src/main/java/noppes/npcs/client/gui/player/GuiNpcFollower.java b/src/main/java/noppes/npcs/client/gui/player/GuiNpcFollower.java index 05d162aa0..d23975a4a 100644 --- a/src/main/java/noppes/npcs/client/gui/player/GuiNpcFollower.java +++ b/src/main/java/noppes/npcs/client/gui/player/GuiNpcFollower.java @@ -19,12 +19,12 @@ import noppes.npcs.roles.RoleFollower; import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; -public class GuiNpcFollower extends GuiContainerNPCInterface implements IGuiData{ - private final ResourceLocation resource = new ResourceLocation("customnpcs","textures/gui/follower.png"); - private EntityNPCInterface npc; - private RoleFollower role; +public class GuiNpcFollower extends GuiContainerNPCInterface implements IGuiData { + private final ResourceLocation resource = new ResourceLocation("customnpcs", "textures/gui/follower.png"); + private EntityNPCInterface npc; + private RoleFollower role; - public GuiNpcFollower(EntityNPCInterface npc,ContainerNPCFollower container){ + public GuiNpcFollower(EntityNPCInterface npc, ContainerNPCFollower container) { super(npc, container); this.npc = npc; role = (RoleFollower) npc.roleInterface; @@ -32,84 +32,87 @@ public class GuiNpcFollower extends GuiContainerNPCInterface implements IGuiDat PacketClient.sendClient(new GetNPCRole()); } + @Override - public void initGui(){ - super.initGui(); + public void initGui() { + super.initGui(); buttonList.clear(); - addButton(new GuiNpcButton(4, guiLeft + 100, guiTop+ 110, 50, 20, new String[]{StatCollector.translateToLocal("follower.waiting"),StatCollector.translateToLocal("follower.following")},role.isFollowing?1:0)); - if(!role.infiniteDays) - addButton(new GuiNpcButton(5, guiLeft + 8, guiTop+ 30, 50, 20, StatCollector.translateToLocal("follower.hire"))); + addButton(new GuiNpcButton(4, guiLeft + 100, guiTop + 110, 50, 20, new String[]{StatCollector.translateToLocal("follower.waiting"), StatCollector.translateToLocal("follower.following")}, role.isFollowing ? 1 : 0)); + if (!role.infiniteDays) + addButton(new GuiNpcButton(5, guiLeft + 8, guiTop + 30, 50, 20, StatCollector.translateToLocal("follower.hire"))); } + @Override - public void actionPerformed(GuiButton guibutton){ - super.actionPerformed(guibutton); - int id = guibutton.id; - if(id == 4){ + public void actionPerformed(GuiButton guibutton) { + super.actionPerformed(guibutton); + int id = guibutton.id; + if (id == 4) { PacketClient.sendClient(new FollowerPacket(FollowerPacket.Action.State)); } - if(id == 5){ + if (id == 5) { PacketClient.sendClient(new FollowerPacket(FollowerPacket.Action.Extend)); } } @Override - protected void drawGuiContainerForegroundLayer(int par1, int par2){ - fontRendererObj.drawString(StatCollector.translateToLocal("follower.health")+": " + npc.getHealth()+"/"+ npc.getMaxHealth(), 62, 70, CustomNpcResourceListener.DefaultTextColor); - if(!role.infiniteDays){ - if(role.getDaysLeft() <= 1) - fontRendererObj.drawString(StatCollector.translateToLocal("follower.daysleft")+": " + StatCollector.translateToLocal("follower.lastday"), 62, 94, CustomNpcResourceListener.DefaultTextColor); - else - fontRendererObj.drawString(StatCollector.translateToLocal("follower.daysleft") + ": " + (role.getDaysLeft()-1), 62, 94, CustomNpcResourceListener.DefaultTextColor); - } + protected void drawGuiContainerForegroundLayer(int par1, int par2) { + fontRendererObj.drawString(StatCollector.translateToLocal("follower.health") + ": " + npc.getHealth() + "/" + npc.getMaxHealth(), 62, 70, CustomNpcResourceListener.DefaultTextColor); + if (!role.infiniteDays) { + if (role.getDaysLeft() <= 1) + fontRendererObj.drawString(StatCollector.translateToLocal("follower.daysleft") + ": " + StatCollector.translateToLocal("follower.lastday"), 62, 94, CustomNpcResourceListener.DefaultTextColor); + else + fontRendererObj.drawString(StatCollector.translateToLocal("follower.daysleft") + ": " + (role.getDaysLeft() - 1), 62, 94, CustomNpcResourceListener.DefaultTextColor); + } } @Override - protected void drawGuiContainerBackgroundLayer(float f, int i, int j){ + protected void drawGuiContainerBackgroundLayer(float f, int i, int j) { GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); mc.renderEngine.bindTexture(resource); - int l = guiLeft; - int i1 = guiTop; + int l = guiLeft; + int i1 = guiTop; drawTexturedModalRect(l, i1, 0, 0, xSize, ySize); - int index = 0; - if(!role.infiniteDays){ - for(int id : role.inventory.items.keySet()){ - ItemStack itemstack = role.inventory.items.get(id); - if(itemstack == null) - continue; - int days = 1; - if(role.rates.containsKey(id)) - days = role.rates.get(id); + int index = 0; + if (!role.infiniteDays) { + for (int id : role.inventory.items.keySet()) { + ItemStack itemstack = role.inventory.items.get(id); + if (itemstack == null) + continue; + int days = 1; + if (role.rates.containsKey(id)) + days = role.rates.get(id); - int yOffset = index * 20; + int yOffset = index * 20; - int x = guiLeft + 68; - int y = guiTop + yOffset + 4; - RenderHelper.enableGUIStandardItemLighting(); - GL11.glEnable(GL12.GL_RESCALE_NORMAL); - GL11.glEnable(GL11.GL_COLOR_MATERIAL); - GL11.glEnable(GL11.GL_LIGHTING); - itemRender.renderItemIntoGUI(fontRendererObj, mc.renderEngine, itemstack, x + 11,y); - itemRender.renderItemOverlayIntoGUI(fontRendererObj, mc.renderEngine, itemstack, x+11,y); - RenderHelper.disableStandardItemLighting(); - GL11.glDisable(32826 /*GL_RESCALE_NORMAL_EXT*/); + int x = guiLeft + 68; + int y = guiTop + yOffset + 4; + RenderHelper.enableGUIStandardItemLighting(); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + GL11.glEnable(GL11.GL_COLOR_MATERIAL); + GL11.glEnable(GL11.GL_LIGHTING); + itemRender.renderItemIntoGUI(fontRendererObj, mc.renderEngine, itemstack, x + 11, y); + itemRender.renderItemOverlayIntoGUI(fontRendererObj, mc.renderEngine, itemstack, x + 11, y); + RenderHelper.disableStandardItemLighting(); + GL11.glDisable(32826 /*GL_RESCALE_NORMAL_EXT*/); - String daysS = days + " " + ((days == 1)?StatCollector.translateToLocal("follower.day"):StatCollector.translateToLocal("follower.days")); - fontRendererObj.drawString(" = "+daysS, x + 27, y + 4, CustomNpcResourceListener.DefaultTextColor); - //fontRenderer.drawString(quantity, x + 0 + (12-fontRenderer.getStringWidth(quantity))/2, y + 4, 0x404040); + String daysS = days + " " + ((days == 1) ? StatCollector.translateToLocal("follower.day") : StatCollector.translateToLocal("follower.days")); + fontRendererObj.drawString(" = " + daysS, x + 27, y + 4, CustomNpcResourceListener.DefaultTextColor); + //fontRenderer.drawString(quantity, x + 0 + (12-fontRenderer.getStringWidth(quantity))/2, y + 4, 0x404040); - index++; - } - } - this.drawNpc(33, 131); + index++; + } + } + this.drawNpc(33, 131); } - @Override - public void save() { + @Override + public void save() { - } - @Override - public void setGuiData(NBTTagCompound compound) { - npc.roleInterface.readFromNBT(compound); - initGui(); - } + } + + @Override + public void setGuiData(NBTTagCompound compound) { + npc.roleInterface.readFromNBT(compound); + initGui(); + } } diff --git a/src/main/java/noppes/npcs/client/gui/player/GuiNpcFollowerHire.java b/src/main/java/noppes/npcs/client/gui/player/GuiNpcFollowerHire.java index 261e2d9bb..5858cda26 100644 --- a/src/main/java/noppes/npcs/client/gui/player/GuiNpcFollowerHire.java +++ b/src/main/java/noppes/npcs/client/gui/player/GuiNpcFollowerHire.java @@ -15,87 +15,82 @@ import noppes.npcs.entity.EntityNPCInterface; import noppes.npcs.roles.RoleFollower; import org.lwjgl.opengl.GL11; -public class GuiNpcFollowerHire extends GuiContainerNPCInterface -{ - private final ResourceLocation resource = new ResourceLocation("customnpcs","textures/gui/followerhire.png"); - private EntityNPCInterface npc; - private ContainerNPCFollowerHire container; - private RoleFollower role; - public GuiNpcFollowerHire(EntityNPCInterface npc,ContainerNPCFollowerHire container) - { +public class GuiNpcFollowerHire extends GuiContainerNPCInterface { + private final ResourceLocation resource = new ResourceLocation("customnpcs", "textures/gui/followerhire.png"); + private EntityNPCInterface npc; + private ContainerNPCFollowerHire container; + private RoleFollower role; + + public GuiNpcFollowerHire(EntityNPCInterface npc, ContainerNPCFollowerHire container) { super(npc, container); this.container = container; this.npc = npc; role = (RoleFollower) npc.roleInterface; closeOnEsc = true; } - public void initGui() - { - super.initGui(); - addButton(new GuiNpcButton(5, guiLeft + 26, guiTop+ 60, 50, 20, StatCollector.translateToLocal("follower.hire"))); + + public void initGui() { + super.initGui(); + addButton(new GuiNpcButton(5, guiLeft + 26, guiTop + 60, 50, 20, StatCollector.translateToLocal("follower.hire"))); } @Override - public void actionPerformed(GuiButton guibutton) - { - super.actionPerformed(guibutton); - if(guibutton.id == 5) - { + public void actionPerformed(GuiButton guibutton) { + super.actionPerformed(guibutton); + if (guibutton.id == 5) { PacketClient.sendClient(new FollowerPacket(FollowerPacket.Action.Hire)); - close(); + close(); } } @Override - protected void drawGuiContainerForegroundLayer(int par1, int par2) - { + protected void drawGuiContainerForegroundLayer(int par1, int par2) { //fontRenderer.drawString("Inventory", 8, (ySize - 96) + 2, 0x404040); } @Override - protected void drawGuiContainerBackgroundLayer(float f, int i, int j) - { + protected void drawGuiContainerBackgroundLayer(float f, int i, int j) { GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); mc.renderEngine.bindTexture(resource); int l = (width - xSize) / 2; int i1 = (height - ySize) / 2; drawTexturedModalRect(l, i1, 0, 0, xSize, ySize); - int index = 0; - for(int id : role.inventory.items.keySet()){ - ItemStack itemstack = role.inventory.items.get(id); - if(itemstack == null) - continue; - int days = 1; - if(role.rates.containsKey(id)) - days = role.rates.get(id); + int index = 0; + for (int id : role.inventory.items.keySet()) { + ItemStack itemstack = role.inventory.items.get(id); + if (itemstack == null) + continue; + int days = 1; + if (role.rates.containsKey(id)) + days = role.rates.get(id); - int yOffset = index * 26; + int yOffset = index * 26; - int x = guiLeft + 78; - int y = guiTop + yOffset + 10; + int x = guiLeft + 78; + int y = guiTop + yOffset + 10; GL11.glEnable(32826 /*GL_RESCALE_NORMAL_EXT*/); RenderHelper.enableGUIStandardItemLighting(); - itemRender.renderItemIntoGUI(fontRendererObj, mc.renderEngine, itemstack, x + 11,y); - itemRender.renderItemOverlayIntoGUI(fontRendererObj, mc.renderEngine, itemstack, x+11,y); + itemRender.renderItemIntoGUI(fontRendererObj, mc.renderEngine, itemstack, x + 11, y); + itemRender.renderItemOverlayIntoGUI(fontRendererObj, mc.renderEngine, itemstack, x + 11, y); RenderHelper.disableStandardItemLighting(); GL11.glDisable(32826 /*GL_RESCALE_NORMAL_EXT*/); - String daysS = days + " " + ((days == 1)?StatCollector.translateToLocal("follower.day"):StatCollector.translateToLocal("follower.days")); - fontRendererObj.drawString(" = "+daysS, x + 27, y + 4, CustomNpcResourceListener.DefaultTextColor); - //fontRenderer.drawString(quantity, x + 0 + (12-fontRenderer.getStringWidth(quantity))/2, y + 4, 0x404040); + String daysS = days + " " + ((days == 1) ? StatCollector.translateToLocal("follower.day") : StatCollector.translateToLocal("follower.days")); + fontRendererObj.drawString(" = " + daysS, x + 27, y + 4, CustomNpcResourceListener.DefaultTextColor); + //fontRenderer.drawString(quantity, x + 0 + (12-fontRenderer.getStringWidth(quantity))/2, y + 4, 0x404040); - if (this.func_146978_c(x - guiLeft + 11, y - guiTop, 16, 16, mouseX, mouseY)) - { - this.renderToolTip(itemstack, mouseX, mouseY); - } - index++; - } + if (this.func_146978_c(x - guiLeft + 11, y - guiTop, 16, 16, mouseX, mouseY)) { + this.renderToolTip(itemstack, mouseX, mouseY); + } + index++; + } } - @Override - public void save() { - return; - } + + @Override + public void save() { + return; + } } diff --git a/src/main/java/noppes/npcs/client/gui/player/GuiQuestCompletion.java b/src/main/java/noppes/npcs/client/gui/player/GuiQuestCompletion.java index 698badc81..66767e7cf 100644 --- a/src/main/java/noppes/npcs/client/gui/player/GuiQuestCompletion.java +++ b/src/main/java/noppes/npcs/client/gui/player/GuiQuestCompletion.java @@ -12,72 +12,73 @@ import noppes.npcs.client.gui.util.ITopButtonListener; import noppes.npcs.controllers.data.Quest; import org.lwjgl.opengl.GL11; -public class GuiQuestCompletion extends GuiNPCInterface implements ITopButtonListener{ +public class GuiQuestCompletion extends GuiNPCInterface implements ITopButtonListener { private Quest quest; - private final ResourceLocation resource = new ResourceLocation("customnpcs","textures/gui/smallbg.png"); + private final ResourceLocation resource = new ResourceLocation("customnpcs", "textures/gui/smallbg.png"); - public GuiQuestCompletion(Quest quest) { - super(); + public GuiQuestCompletion(Quest quest) { + super(); xSize = 176; ySize = 222; this.quest = quest; this.drawDefaultBackground = false; title = ""; - } - public void initGui() - { + } + + public void initGui() { super.initGui(); String questTitle = quest.title; int left = (xSize - this.fontRendererObj.getStringWidth(questTitle)) / 2; - this.addLabel(new GuiNpcLabel(0,questTitle, guiLeft + left, guiTop + 4)); - + this.addLabel(new GuiNpcLabel(0, questTitle, guiLeft + left, guiTop + 4)); + this.addButton(new GuiNpcButton(0, guiLeft + 38, guiTop + ySize - 24, 100, 20, StatCollector.translateToLocal("quest.complete"))); } - public void drawScreen(int i, int j, float f) - { - drawDefaultBackground(); + + public void drawScreen(int i, int j, float f) { + drawDefaultBackground(); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); mc.renderEngine.bindTexture(resource); drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize); - drawHorizontalLine(guiLeft + 4, guiLeft + 170, guiTop + 13, + 0xFF000000 + CustomNpcResourceListener.DefaultTextColor); - - + drawHorizontalLine(guiLeft + 4, guiLeft + 170, guiTop + 13, +0xFF000000 + CustomNpcResourceListener.DefaultTextColor); + + drawQuestText(); super.drawScreen(i, j, f); } - private void drawQuestText(){ + + private void drawQuestText() { int xoffset = guiLeft + 4; - TextBlockClient block = new TextBlockClient(quest.completeText, 172, true, player); - int yoffset = guiTop + 20; - for(int i = 0; i < block.lines.size(); i++){ - String text = block.lines.get(i).getFormattedText(); - fontRendererObj.drawString(text, guiLeft + 4, guiTop + 16 + (i * fontRendererObj.FONT_HEIGHT), CustomNpcResourceListener.DefaultTextColor); - } - } - @Override - protected void actionPerformed(GuiButton guibutton) - { - if(guibutton.id == 0){ - close(); - } - } - protected void drawGuiContainerBackgroundLayer(float f, int i, int j) - { - + TextBlockClient block = new TextBlockClient(quest.completeText, 172, true, player); + int yoffset = guiTop + 20; + for (int i = 0; i < block.lines.size(); i++) { + String text = block.lines.get(i).getFormattedText(); + fontRendererObj.drawString(text, guiLeft + 4, guiTop + 16 + (i * fontRendererObj.FONT_HEIGHT), CustomNpcResourceListener.DefaultTextColor); + } } @Override - public void keyTyped(char c, int i) - { - if (i == 1 || isInventoryKey(i)){ + protected void actionPerformed(GuiButton guibutton) { + if (guibutton.id == 0) { close(); } } - @Override - public void save() { - } + protected void drawGuiContainerBackgroundLayer(float f, int i, int j) { + + } + + @Override + public void keyTyped(char c, int i) { + if (i == 1 || isInventoryKey(i)) { + close(); + } + } + + @Override + public void save() { + + } } diff --git a/src/main/java/noppes/npcs/client/gui/player/GuiRecipes.java b/src/main/java/noppes/npcs/client/gui/player/GuiRecipes.java index 1302aa678..635e40fe8 100644 --- a/src/main/java/noppes/npcs/client/gui/player/GuiRecipes.java +++ b/src/main/java/noppes/npcs/client/gui/player/GuiRecipes.java @@ -22,87 +22,88 @@ import java.util.Arrays; import java.util.List; @SideOnly(Side.CLIENT) -public class GuiRecipes extends GuiNPCInterface -{ - private static final ResourceLocation resource = new ResourceLocation("customnpcs","textures/gui/slot.png"); +public class GuiRecipes extends GuiNPCInterface { + private static final ResourceLocation resource = new ResourceLocation("customnpcs", "textures/gui/slot.png"); private int page = 0; private GuiNpcLabel label; private GuiNpcButton left, right; private List recipes = new ArrayList(); - private String search = ""; + private String search = ""; - public GuiRecipes(){ + public GuiRecipes() { this.ySize = 182; this.xSize = 256; setBackground("recipes.png"); this.closeOnEsc = true; - recipes.addAll(RecipeController.Instance.carpentryRecipes.values()); + recipes.addAll(RecipeController.Instance.carpentryRecipes.values()); } + @Override - public void initGui(){ - super.initGui(); - guiTop += 10; + public void initGui() { + super.initGui(); + guiTop += 10; - addTextField(new GuiNpcTextField(3, this, fontRendererObj, guiLeft + 2, guiTop - 25, 250, 20, search)); + addTextField(new GuiNpcTextField(3, this, fontRendererObj, guiLeft + 2, guiTop - 25, 250, 20, search)); - addLabel(new GuiNpcLabel(0, "Recipe List", guiLeft + 5, guiTop + 5)); - addLabel(label = new GuiNpcLabel(1, "", guiLeft + 5, guiTop + 168)); + addLabel(new GuiNpcLabel(0, "Recipe List", guiLeft + 5, guiTop + 5)); + addLabel(label = new GuiNpcLabel(1, "", guiLeft + 5, guiTop + 168)); addButton(this.left = new GuiButtonNextPage(1, guiLeft + 150, guiTop + 164, true)); addButton(this.right = new GuiButtonNextPage(2, guiLeft + 80, guiTop + 164, false)); updateButton(); } - private void updateButton(){ - right.visible = right.enabled = page > 0; - left.visible = left.enabled = page + 1 < MathHelper.ceiling_float_int(recipes.size() / 4f); + + private void updateButton() { + right.visible = right.enabled = page > 0; + left.visible = left.enabled = page + 1 < MathHelper.ceiling_float_int(recipes.size() / 4f); } - public void keyTyped(char c, int i) - { - super.keyTyped(c, i); - if(search.equals(getTextField(3).getText())) - return; - search = getTextField(3).getText().toLowerCase(); - recipes = getSearchList(); - updateButton(); - } + public void keyTyped(char c, int i) { + super.keyTyped(c, i); + if (search.equals(getTextField(3).getText())) + return; + search = getTextField(3).getText().toLowerCase(); + recipes = getSearchList(); + updateButton(); + } - private List getSearchList(){ - if(search.isEmpty()){ - return new ArrayList(RecipeController.Instance.carpentryRecipes.values()); - } - List list = new ArrayList(); - for(IRecipe recipe : RecipeController.Instance.carpentryRecipes.values()){ - if(recipe.getRecipeOutput() == null) - continue; + private List getSearchList() { + if (search.isEmpty()) { + return new ArrayList(RecipeController.Instance.carpentryRecipes.values()); + } + List list = new ArrayList(); + for (IRecipe recipe : RecipeController.Instance.carpentryRecipes.values()) { + if (recipe.getRecipeOutput() == null) + continue; - if(recipe.getRecipeOutput().getDisplayName() == null) - continue; + if (recipe.getRecipeOutput().getDisplayName() == null) + continue; - if(recipe.getRecipeOutput().getDisplayName().trim().equals("")) - continue; + if (recipe.getRecipeOutput().getDisplayName().trim().equals("")) + continue; - if(recipe.getRecipeOutput().getDisplayName().toLowerCase().contains(search.toLowerCase())) - list.add(recipe); - } - return list; - } + if (recipe.getRecipeOutput().getDisplayName().toLowerCase().contains(search.toLowerCase())) + list.add(recipe); + } + return list; + } - protected void actionPerformed(GuiButton button){ - if(!button.enabled) - return; + protected void actionPerformed(GuiButton button) { + if (!button.enabled) + return; - if(button == right) - page--; - if(button == left) - page++; + if (button == right) + page--; + if (button == left) + page++; updateButton(); } private static class ItemOverlayData { public final int x, y; public final ItemStack item; + public ItemOverlayData(int x, int y, ItemStack item) { this.x = x; this.y = y; @@ -128,12 +129,12 @@ public class GuiRecipes extends GuiNPCInterface } @Override - public void drawScreen(int xMouse, int yMouse, float f){ - super.drawScreen(xMouse, yMouse, f); - mc.renderEngine.bindTexture(resource); + public void drawScreen(int xMouse, int yMouse, float f) { + super.drawScreen(xMouse, yMouse, f); + mc.renderEngine.bindTexture(resource); - label.label = page + 1 + "/" + MathHelper.ceiling_float_int(recipes.size() / 4f); - label.x = guiLeft + (256 - Minecraft.getMinecraft().fontRenderer.getStringWidth(label.label)) / 2; + label.label = page + 1 + "/" + MathHelper.ceiling_float_int(recipes.size() / 4f); + label.x = guiLeft + (256 - Minecraft.getMinecraft().fontRenderer.getStringWidth(label.label)) / 2; List itemOverlays = new ArrayList(); List textOverlays = new ArrayList(); @@ -150,8 +151,8 @@ public class GuiRecipes extends GuiNPCInterface int y = guiTop + 15 + (i % 2) * 76; drawItem(irecipe.getRecipeOutput(), x + 98, y + 28, xMouse, yMouse); - if (func_146978_c((x+98) - guiLeft, (y+28) - guiTop, 16, 16, xMouse, yMouse)) { - itemOverlays.add(new ItemOverlayData(x+98, y+28, irecipe.getRecipeOutput())); + if (func_146978_c((x + 98) - guiLeft, (y + 28) - guiTop, 16, 16, xMouse, yMouse)) { + itemOverlays.add(new ItemOverlayData(x + 98, y + 28, irecipe.getRecipeOutput())); } if (irecipe instanceof RecipeCarpentry) { @@ -169,8 +170,8 @@ public class GuiRecipes extends GuiNPCInterface iconStr = "!"; iconColor = CustomNpcResourceListener.DefaultTextColor; } - int iconWidth = (int)(fontRendererObj.getStringWidth(iconStr) * scale); - int iconHeight = (int)(fontRendererObj.FONT_HEIGHT * scale); + int iconWidth = (int) (fontRendererObj.getStringWidth(iconStr) * scale); + int iconHeight = (int) (fontRendererObj.FONT_HEIGHT * scale); // Center the icon below the output slot (16x16 slot). int iconX = outputX + (16 - iconWidth) / 2; int iconY = outputY + 16; @@ -207,8 +208,8 @@ public class GuiRecipes extends GuiNPCInterface if (item == null) continue; drawItem(item, gridX + j * 18 + 1, gridY + k * 18 + 1, xMouse, yMouse); - if (func_146978_c((gridX+j*18+1)-guiLeft, (gridY+k*18+1)-guiTop, 16, 16, xMouse, yMouse)) { - itemOverlays.add(new ItemOverlayData(gridX+j*18+1, gridY+k*18+1, item)); + if (func_146978_c((gridX + j * 18 + 1) - guiLeft, (gridY + k * 18 + 1) - guiTop, 16, 16, xMouse, yMouse)) { + itemOverlays.add(new ItemOverlayData(gridX + j * 18 + 1, gridY + k * 18 + 1, item)); } } } @@ -225,8 +226,8 @@ public class GuiRecipes extends GuiNPCInterface } } - private void drawItem(ItemStack item, int x, int y, int xMouse, int yMouse){ - GL11.glPushMatrix(); + private void drawItem(ItemStack item, int x, int y, int xMouse, int yMouse) { + GL11.glPushMatrix(); GL11.glEnable(GL12.GL_RESCALE_NORMAL); RenderHelper.enableGUIStandardItemLighting(); itemRender.zLevel = 100.0F; @@ -235,16 +236,16 @@ public class GuiRecipes extends GuiNPCInterface itemRender.zLevel = 0.0F; RenderHelper.disableStandardItemLighting(); GL11.glDisable(GL12.GL_RESCALE_NORMAL); - GL11.glPopMatrix(); + GL11.glPopMatrix(); } - private void drawOverlay(ItemStack item, int x, int y, int xMouse, int yMouse){ - if (this.func_146978_c(x - guiLeft, y - guiTop, 16, 16, xMouse, yMouse)){ + private void drawOverlay(ItemStack item, int x, int y, int xMouse, int yMouse) { + if (this.func_146978_c(x - guiLeft, y - guiTop, 16, 16, xMouse, yMouse)) { this.renderToolTip(item, xMouse, yMouse); } } - protected boolean func_146978_c(int p_146978_1_, int p_146978_2_, int p_146978_3_, int p_146978_4_, int p_146978_5_, int p_146978_6_) - { + + protected boolean func_146978_c(int p_146978_1_, int p_146978_2_, int p_146978_3_, int p_146978_4_, int p_146978_5_, int p_146978_6_) { int k1 = this.guiLeft; int l1 = this.guiTop; p_146978_5_ -= k1; @@ -252,7 +253,7 @@ public class GuiRecipes extends GuiNPCInterface return p_146978_5_ >= p_146978_1_ - 1 && p_146978_5_ < p_146978_1_ + p_146978_3_ + 1 && p_146978_6_ >= p_146978_2_ - 1 && p_146978_6_ < p_146978_2_ + p_146978_4_ + 1; } - @Override - public void save() { - } + @Override + public void save() { + } } diff --git a/src/main/java/noppes/npcs/client/gui/player/GuiTransportSelection.java b/src/main/java/noppes/npcs/client/gui/player/GuiTransportSelection.java index 49d1eed04..3c726c33d 100644 --- a/src/main/java/noppes/npcs/client/gui/player/GuiTransportSelection.java +++ b/src/main/java/noppes/npcs/client/gui/player/GuiTransportSelection.java @@ -13,32 +13,32 @@ import org.lwjgl.opengl.GL11; import java.util.HashMap; import java.util.Vector; -public class GuiTransportSelection extends GuiNPCInterface implements ITopButtonListener,IScrollData{ +public class GuiTransportSelection extends GuiNPCInterface implements ITopButtonListener, IScrollData { - private final ResourceLocation resource = new ResourceLocation("customnpcs","textures/gui/smallbg.png"); + private final ResourceLocation resource = new ResourceLocation("customnpcs", "textures/gui/smallbg.png"); protected int xSize; protected int guiLeft; protected int guiTop; private GuiCustomScroll scroll; - public GuiTransportSelection(EntityNPCInterface npc) { - super(npc); + public GuiTransportSelection(EntityNPCInterface npc) { + super(npc); xSize = 176; this.drawDefaultBackground = false; title = ""; - } - public void initGui() - { + } + + public void initGui() { super.initGui(); guiLeft = (width - xSize) / 2; guiTop = (height - 222) / 2; //String name = "Location: " + npc.getDataWatcher().getWatchableObjectString(11); String name = ""; - addLabel(new GuiNpcLabel(0,name, guiLeft + (xSize - this.fontRendererObj.getStringWidth(name))/2, guiTop + 10)); - addButton(new GuiNpcButton(0, guiLeft+ 10, guiTop + 192,156,20, StatCollector.translateToLocal("transporter.travel"))); - if(scroll == null) - scroll = new GuiCustomScroll(this,0); + addLabel(new GuiNpcLabel(0, name, guiLeft + (xSize - this.fontRendererObj.getStringWidth(name)) / 2, guiTop + 10)); + addButton(new GuiNpcButton(0, guiLeft + 10, guiTop + 192, 156, 20, StatCollector.translateToLocal("transporter.travel"))); + if (scroll == null) + scroll = new GuiCustomScroll(this, 0); scroll.setSize(156, 165); scroll.guiLeft = guiLeft + 10; scroll.guiTop = guiTop + 20; @@ -46,9 +46,8 @@ public class GuiTransportSelection extends GuiNPCInterface implements ITopButton } @Override - public void drawScreen(int i, int j, float f) - { - drawDefaultBackground(); + public void drawScreen(int i, int j, float f) { + drawDefaultBackground(); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); mc.renderEngine.bindTexture(resource); drawTexturedModalRect(guiLeft, guiTop, 0, 0, 176, 222); @@ -56,45 +55,45 @@ public class GuiTransportSelection extends GuiNPCInterface implements ITopButton } @Override - protected void actionPerformed(GuiButton guibutton) - { - GuiNpcButton button = (GuiNpcButton) guibutton; - String sel = scroll.getSelected(); - if(button.id == 0 && sel != null){ + protected void actionPerformed(GuiButton guibutton) { + GuiNpcButton button = (GuiNpcButton) guibutton; + String sel = scroll.getSelected(); + if (button.id == 0 && sel != null) { close(); PacketClient.sendClient(new TransportPacket(sel)); - } + } } -// @Override + + // @Override // protected void drawGuiContainerBackgroundLayer(float f, int i, int j) // { // } @Override - public void mouseClicked(int i, int j, int k) - { - super.mouseClicked(i, j, k); - scroll.mouseClicked(i, j, k); + public void mouseClicked(int i, int j, int k) { + super.mouseClicked(i, j, k); + scroll.mouseClicked(i, j, k); } + @Override - public void keyTyped(char c, int i) - { - if (i == 1 || isInventoryKey(i)) - { + public void keyTyped(char c, int i) { + if (i == 1 || isInventoryKey(i)) { close(); } } - @Override - public void save() { - } - @Override - public void setData(Vector list, HashMap data, EnumScrollData type) { - scroll.setList(list); - } - @Override - public void setSelected(String selected) { + @Override + public void save() { + } + + @Override + public void setData(Vector list, HashMap data, EnumScrollData type) { + scroll.setList(list); + } + + @Override + public void setSelected(String selected) { - } + } } diff --git a/src/main/java/noppes/npcs/client/gui/player/companion/GuiNpcCompanionInv.java b/src/main/java/noppes/npcs/client/gui/player/companion/GuiNpcCompanionInv.java index d002b3bd1..1bee093bf 100644 --- a/src/main/java/noppes/npcs/client/gui/player/companion/GuiNpcCompanionInv.java +++ b/src/main/java/noppes/npcs/client/gui/player/companion/GuiNpcCompanionInv.java @@ -11,81 +11,81 @@ import noppes.npcs.entity.EntityNPCInterface; import noppes.npcs.roles.RoleCompanion; import org.lwjgl.opengl.GL11; -public class GuiNpcCompanionInv extends GuiContainerNPCInterface{ - private final ResourceLocation resource = new ResourceLocation("customnpcs", "textures/gui/companioninv.png"); - private final ResourceLocation slot = new ResourceLocation("customnpcs", "textures/gui/slot.png"); - private EntityNPCInterface npc; - private RoleCompanion role; +public class GuiNpcCompanionInv extends GuiContainerNPCInterface { + private final ResourceLocation resource = new ResourceLocation("customnpcs", "textures/gui/companioninv.png"); + private final ResourceLocation slot = new ResourceLocation("customnpcs", "textures/gui/slot.png"); + private EntityNPCInterface npc; + private RoleCompanion role; - public GuiNpcCompanionInv(EntityNPCInterface npc, - ContainerNPCCompanion container) { - super(npc, container); - this.npc = npc; - role = (RoleCompanion) npc.roleInterface; - closeOnEsc = true; - xSize = 171; - ySize = 166; - } + public GuiNpcCompanionInv(EntityNPCInterface npc, + ContainerNPCCompanion container) { + super(npc, container); + this.npc = npc; + role = (RoleCompanion) npc.roleInterface; + closeOnEsc = true; + xSize = 171; + ySize = 166; + } - @Override - public void initGui() { - super.initGui(); - GuiNpcCompanionStats.addTopMenu(role, this, 3); - - } + @Override + public void initGui() { + super.initGui(); + GuiNpcCompanionStats.addTopMenu(role, this, 3); - @Override - public void actionPerformed(GuiButton guibutton) { - super.actionPerformed(guibutton); - int id = guibutton.id; - if(id == 1){ - CustomNpcs.proxy.openGui(npc, EnumGuiType.Companion); - } - if(id == 2){ - CustomNpcs.proxy.openGui(npc, EnumGuiType.CompanionTalent); - } - } + } - @Override - protected void drawGuiContainerForegroundLayer(int par1, int par2) { - - } + @Override + public void actionPerformed(GuiButton guibutton) { + super.actionPerformed(guibutton); + int id = guibutton.id; + if (id == 1) { + CustomNpcs.proxy.openGui(npc, EnumGuiType.Companion); + } + if (id == 2) { + CustomNpcs.proxy.openGui(npc, EnumGuiType.CompanionTalent); + } + } - @Override - protected void drawGuiContainerBackgroundLayer(float f, int xMouse, int yMouse) { + @Override + protected void drawGuiContainerForegroundLayer(int par1, int par2) { + + } + + @Override + protected void drawGuiContainerBackgroundLayer(float f, int xMouse, int yMouse) { this.drawWorldBackground(0); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - mc.renderEngine.bindTexture(resource); - drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize); - mc.renderEngine.bindTexture(slot); - if(role.getTalentLevel(EnumCompanionTalent.ARMOR) > 0){ - for(int i = 0; i < 4; i++){ - drawTexturedModalRect(guiLeft + 5, guiTop + 7 + i * 18 , 0, 0, 18, 18); - } - } - if(role.getTalentLevel(EnumCompanionTalent.SWORD) > 0){ - drawTexturedModalRect(guiLeft + 78, guiTop + 16, 0, npc.inventory.weapons.get(0) == null?18:0, 18, 18); - } - if(role.getTalentLevel(EnumCompanionTalent.RANGED) > 0){ - - } - if(role.talents.containsKey(EnumCompanionTalent.INVENTORY)){ - int size = (role.getTalentLevel(EnumCompanionTalent.INVENTORY) + 1) * 2; - for(int i = 0; i < size; i++){ - drawTexturedModalRect(guiLeft + 113 + i % 3 * 18, guiTop + 7 + i / 3 * 18 , 0, 0, 18, 18); - } - } + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + mc.renderEngine.bindTexture(resource); + drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize); + mc.renderEngine.bindTexture(slot); + if (role.getTalentLevel(EnumCompanionTalent.ARMOR) > 0) { + for (int i = 0; i < 4; i++) { + drawTexturedModalRect(guiLeft + 5, guiTop + 7 + i * 18, 0, 0, 18, 18); + } + } + if (role.getTalentLevel(EnumCompanionTalent.SWORD) > 0) { + drawTexturedModalRect(guiLeft + 78, guiTop + 16, 0, npc.inventory.weapons.get(0) == null ? 18 : 0, 18, 18); + } + if (role.getTalentLevel(EnumCompanionTalent.RANGED) > 0) { - super.drawNpc(52, 70); - } + } + if (role.talents.containsKey(EnumCompanionTalent.INVENTORY)) { + int size = (role.getTalentLevel(EnumCompanionTalent.INVENTORY) + 1) * 2; + for (int i = 0; i < size; i++) { + drawTexturedModalRect(guiLeft + 113 + i % 3 * 18, guiTop + 7 + i / 3 * 18, 0, 0, 18, 18); + } + } - @Override - public void drawScreen(int i, int j, float f) { - super.drawScreen(i, j, f); - } + super.drawNpc(52, 70); + } - @Override - public void save() { - - } + @Override + public void drawScreen(int i, int j, float f) { + super.drawScreen(i, j, f); + } + + @Override + public void save() { + + } } diff --git a/src/main/java/noppes/npcs/client/gui/player/companion/GuiNpcCompanionStats.java b/src/main/java/noppes/npcs/client/gui/player/companion/GuiNpcCompanionStats.java index 11215c505..591fe8f82 100644 --- a/src/main/java/noppes/npcs/client/gui/player/companion/GuiNpcCompanionStats.java +++ b/src/main/java/noppes/npcs/client/gui/player/companion/GuiNpcCompanionStats.java @@ -19,144 +19,144 @@ import noppes.npcs.entity.EntityNPCInterface; import noppes.npcs.roles.RoleCompanion; public class GuiNpcCompanionStats extends GuiNPCInterface implements IGuiData { - private RoleCompanion role; - private boolean isEating = false; + private RoleCompanion role; + private boolean isEating = false; - public GuiNpcCompanionStats(EntityNPCInterface npc) { - super(npc); - role = (RoleCompanion) npc.roleInterface; - closeOnEsc = true; - setBackground("companion.png"); - xSize = 171; - ySize = 166; + public GuiNpcCompanionStats(EntityNPCInterface npc) { + super(npc); + role = (RoleCompanion) npc.roleInterface; + closeOnEsc = true; + setBackground("companion.png"); + xSize = 171; + ySize = 166; PacketClient.sendClient(new GetNPCRole()); - } + } - @Override - public void initGui() { - super.initGui(); - int y = guiTop + 10; - addLabel(new GuiNpcLabel(0, NoppesStringUtils.translate("gui.name", ": ",npc.display.name), guiLeft + 4, y)); - addLabel(new GuiNpcLabel(1, NoppesStringUtils.translate("companion.owner", ": ",role.ownerName), guiLeft + 4, y+=12)); - addLabel(new GuiNpcLabel(2, NoppesStringUtils.translate("companion.age", ": ", role.ticksActive / 18000 + " (", role.stage.name, ")" ), guiLeft + 4, y+=12)); - addLabel(new GuiNpcLabel(3, NoppesStringUtils.translate("companion.strength", ": ", npc.stats.getAttackStrength()), guiLeft + 4, y+=12)); - addLabel(new GuiNpcLabel(4, NoppesStringUtils.translate("companion.level", ": ", role.getTotalLevel()), guiLeft + 4, y+=12)); - addLabel(new GuiNpcLabel(5, NoppesStringUtils.translate("job.name", ": ", "gui.none"), guiLeft + 4, y+=12)); + @Override + public void initGui() { + super.initGui(); + int y = guiTop + 10; + addLabel(new GuiNpcLabel(0, NoppesStringUtils.translate("gui.name", ": ", npc.display.name), guiLeft + 4, y)); + addLabel(new GuiNpcLabel(1, NoppesStringUtils.translate("companion.owner", ": ", role.ownerName), guiLeft + 4, y += 12)); + addLabel(new GuiNpcLabel(2, NoppesStringUtils.translate("companion.age", ": ", role.ticksActive / 18000 + " (", role.stage.name, ")"), guiLeft + 4, y += 12)); + addLabel(new GuiNpcLabel(3, NoppesStringUtils.translate("companion.strength", ": ", npc.stats.getAttackStrength()), guiLeft + 4, y += 12)); + addLabel(new GuiNpcLabel(4, NoppesStringUtils.translate("companion.level", ": ", role.getTotalLevel()), guiLeft + 4, y += 12)); + addLabel(new GuiNpcLabel(5, NoppesStringUtils.translate("job.name", ": ", "gui.none"), guiLeft + 4, y += 12)); - addTopMenu(role, this, 1); + addTopMenu(role, this, 1); - } + } - public static void addTopMenu(RoleCompanion role, GuiScreen screen, int active){ - if(screen instanceof GuiNPCInterface){ - GuiNPCInterface gui = (GuiNPCInterface) screen; - GuiMenuTopIconButton button; - gui.addTopButton(button = new GuiMenuTopIconButton(1, gui.guiLeft + 4, gui.guiTop - 27, "menu.stats", new ItemStack(CustomItems.letter))); - gui.addTopButton(button = new GuiMenuTopIconButton(2, button, "companion.talent", new ItemStack(CustomItems.spellHoly))); - if(role.hasInv()) - gui.addTopButton(button = new GuiMenuTopIconButton(3, button, "inv.inventory", new ItemStack(CustomItems.bag))); - if(role.job != EnumCompanionJobs.NONE) - gui.addTopButton(new GuiMenuTopIconButton(4, button, "job.name", new ItemStack(CustomItems.bag))); - gui.getTopButton(active).active = true; - } - if(screen instanceof GuiContainerNPCInterface){ - GuiContainerNPCInterface gui = (GuiContainerNPCInterface) screen; - GuiMenuTopIconButton button; - gui.addTopButton(button = new GuiMenuTopIconButton(1, gui.guiLeft + 4, gui.guiTop - 27, "menu.stats", new ItemStack(CustomItems.letter))); - gui.addTopButton(button = new GuiMenuTopIconButton(2, button, "companion.talent", new ItemStack(CustomItems.spellHoly))); - if(role.hasInv()) - gui.addTopButton(button = new GuiMenuTopIconButton(3, button, "inv.inventory", new ItemStack(CustomItems.bag))); - if(role.job != EnumCompanionJobs.NONE) - gui.addTopButton(new GuiMenuTopIconButton(4, button, "job.name", new ItemStack(CustomItems.bag))); - gui.getTopButton(active).active = true; - } - } - - @Override - public void actionPerformed(GuiButton guibutton) { - super.actionPerformed(guibutton); - int id = guibutton.id; - if(id == 2){ - CustomNpcs.proxy.openGui(npc, EnumGuiType.CompanionTalent); - } - if(id == 3){ - CompanionActionPacket.OpenInventory(); - } - } - - @Override - public void drawScreen(int i, int j, float f) { - super.drawScreen(i, j, f); - if(isEating && !role.isEating()){ - PacketClient.sendClient(new GetNPCRole()); - } - - isEating = role.isEating(); - super.drawNpc(34, 150); - int y = drawHealth(guiTop + 88); - } - - private int drawHealth(int y){ - this.mc.getTextureManager().bindTexture(icons); - - int max = role.getTotalArmorValue(); - if(role.talents.containsKey(EnumCompanionTalent.ARMOR) || max > 0){ - for (int i = 0; i < 10; ++i){ - int x = guiLeft + 66 + i * 10; - - if (i * 2 + 1 < max){ - this.drawTexturedModalRect(x, y, 34, 9, 9, 9); - } - - if (i * 2 + 1 == max){ - this.drawTexturedModalRect(x, y, 25, 9, 9, 9); - } - - if (i * 2 + 1 > max){ - this.drawTexturedModalRect(x, y, 16, 9, 9, 9); - } - - } - y += 10; - } - - max = MathHelper.ceiling_float_int(npc.getMaxHealth()); - int k = (int)npc.getHealth(); - float scale = 1; - if(max > 40){ - scale = max / 40f; - k = (int) (k / scale); - max = 40; + public static void addTopMenu(RoleCompanion role, GuiScreen screen, int active) { + if (screen instanceof GuiNPCInterface) { + GuiNPCInterface gui = (GuiNPCInterface) screen; + GuiMenuTopIconButton button; + gui.addTopButton(button = new GuiMenuTopIconButton(1, gui.guiLeft + 4, gui.guiTop - 27, "menu.stats", new ItemStack(CustomItems.letter))); + gui.addTopButton(button = new GuiMenuTopIconButton(2, button, "companion.talent", new ItemStack(CustomItems.spellHoly))); + if (role.hasInv()) + gui.addTopButton(button = new GuiMenuTopIconButton(3, button, "inv.inventory", new ItemStack(CustomItems.bag))); + if (role.job != EnumCompanionJobs.NONE) + gui.addTopButton(new GuiMenuTopIconButton(4, button, "job.name", new ItemStack(CustomItems.bag))); + gui.getTopButton(active).active = true; } - for(int i = 0; i < max; i++){ - int x = guiLeft + 66 + i % 20 * 5; - int offset = i / 20 * 10; - this.drawTexturedModalRect(x, y + offset, 52 + i % 2 * 5, 9, i % 2 == 1?4:5, 9); - if(k > i) - this.drawTexturedModalRect(x, y + offset, 52 + i % 2 * 5, 0, i % 2 == 1?4:5, 9); + if (screen instanceof GuiContainerNPCInterface) { + GuiContainerNPCInterface gui = (GuiContainerNPCInterface) screen; + GuiMenuTopIconButton button; + gui.addTopButton(button = new GuiMenuTopIconButton(1, gui.guiLeft + 4, gui.guiTop - 27, "menu.stats", new ItemStack(CustomItems.letter))); + gui.addTopButton(button = new GuiMenuTopIconButton(2, button, "companion.talent", new ItemStack(CustomItems.spellHoly))); + if (role.hasInv()) + gui.addTopButton(button = new GuiMenuTopIconButton(3, button, "inv.inventory", new ItemStack(CustomItems.bag))); + if (role.job != EnumCompanionJobs.NONE) + gui.addTopButton(new GuiMenuTopIconButton(4, button, "job.name", new ItemStack(CustomItems.bag))); + gui.getTopButton(active).active = true; + } + } + + @Override + public void actionPerformed(GuiButton guibutton) { + super.actionPerformed(guibutton); + int id = guibutton.id; + if (id == 2) { + CustomNpcs.proxy.openGui(npc, EnumGuiType.CompanionTalent); + } + if (id == 3) { + CompanionActionPacket.OpenInventory(); + } + } + + @Override + public void drawScreen(int i, int j, float f) { + super.drawScreen(i, j, f); + if (isEating && !role.isEating()) { + PacketClient.sendClient(new GetNPCRole()); + } + + isEating = role.isEating(); + super.drawNpc(34, 150); + int y = drawHealth(guiTop + 88); + } + + private int drawHealth(int y) { + this.mc.getTextureManager().bindTexture(icons); + + int max = role.getTotalArmorValue(); + if (role.talents.containsKey(EnumCompanionTalent.ARMOR) || max > 0) { + for (int i = 0; i < 10; ++i) { + int x = guiLeft + 66 + i * 10; + + if (i * 2 + 1 < max) { + this.drawTexturedModalRect(x, y, 34, 9, 9, 9); + } + + if (i * 2 + 1 == max) { + this.drawTexturedModalRect(x, y, 25, 9, 9, 9); + } + + if (i * 2 + 1 > max) { + this.drawTexturedModalRect(x, y, 16, 9, 9, 9); + } + + } + y += 10; + } + + max = MathHelper.ceiling_float_int(npc.getMaxHealth()); + int k = (int) npc.getHealth(); + float scale = 1; + if (max > 40) { + scale = max / 40f; + k = (int) (k / scale); + max = 40; + } + for (int i = 0; i < max; i++) { + int x = guiLeft + 66 + i % 20 * 5; + int offset = i / 20 * 10; + this.drawTexturedModalRect(x, y + offset, 52 + i % 2 * 5, 9, i % 2 == 1 ? 4 : 5, 9); + if (k > i) + this.drawTexturedModalRect(x, y + offset, 52 + i % 2 * 5, 0, i % 2 == 1 ? 4 : 5, 9); } k = role.foodstats.getFoodLevel(); y += 10; - if(max > 20) + if (max > 20) y += 10; - for(int i = 0; i < 20; i++){ - int x = guiLeft + 66 + i % 20 * 5; - this.drawTexturedModalRect(x, y, 16 + i % 2 * 5, 27, i % 2 == 1?4:5, 9); - if(k > i) - this.drawTexturedModalRect(x, y, 52 + i % 2 * 5, 27, i % 2 == 1?4:5, 9); + for (int i = 0; i < 20; i++) { + int x = guiLeft + 66 + i % 20 * 5; + this.drawTexturedModalRect(x, y, 16 + i % 2 * 5, 27, i % 2 == 1 ? 4 : 5, 9); + if (k > i) + this.drawTexturedModalRect(x, y, 52 + i % 2 * 5, 27, i % 2 == 1 ? 4 : 5, 9); } return y; - } + } - @Override - public void save() { + @Override + public void save() { - } + } - @Override - public void setGuiData(NBTTagCompound compound) { - role.readFromNBT(compound); - } + @Override + public void setGuiData(NBTTagCompound compound) { + role.readFromNBT(compound); + } } diff --git a/src/main/java/noppes/npcs/client/gui/player/companion/GuiNpcCompanionTalents.java b/src/main/java/noppes/npcs/client/gui/player/companion/GuiNpcCompanionTalents.java index 9478240f2..37f7f9570 100644 --- a/src/main/java/noppes/npcs/client/gui/player/companion/GuiNpcCompanionTalents.java +++ b/src/main/java/noppes/npcs/client/gui/player/companion/GuiNpcCompanionTalents.java @@ -26,163 +26,164 @@ import org.lwjgl.opengl.GL12; import java.util.HashMap; import java.util.Map; -public class GuiNpcCompanionTalents extends GuiNPCInterface{ - private RoleCompanion role; - private Map talents = new HashMap(); - private GuiNpcButton selected; +public class GuiNpcCompanionTalents extends GuiNPCInterface { + private RoleCompanion role; + private Map talents = new HashMap(); + private GuiNpcButton selected; - public GuiNpcCompanionTalents(EntityNPCInterface npc) { - super(npc); - role = (RoleCompanion) npc.roleInterface; - closeOnEsc = true; - setBackground("companion_empty.png"); - xSize = 171; - ySize = 166; - } + public GuiNpcCompanionTalents(EntityNPCInterface npc) { + super(npc); + role = (RoleCompanion) npc.roleInterface; + closeOnEsc = true; + setBackground("companion_empty.png"); + xSize = 171; + ySize = 166; + } - @Override - public void initGui() { - super.initGui(); - talents.clear(); - int y = guiTop + 12; + @Override + public void initGui() { + super.initGui(); + talents.clear(); + int y = guiTop + 12; - addLabel(new GuiNpcLabel(0, NoppesStringUtils.translate("quest.exp", ": "), guiLeft + 4, guiTop + 10)); + addLabel(new GuiNpcLabel(0, NoppesStringUtils.translate("quest.exp", ": "), guiLeft + 4, guiTop + 10)); - GuiNpcCompanionStats.addTopMenu(role, this, 2); - int i = 0; - for(EnumCompanionTalent e : role.talents.keySet()){ - addTalent(i++, e); - } - } + GuiNpcCompanionStats.addTopMenu(role, this, 2); + int i = 0; + for (EnumCompanionTalent e : role.talents.keySet()) { + addTalent(i++, e); + } + } - private void addTalent(int i, EnumCompanionTalent talent){ - int y = guiTop + 28 + i/2 * 26; - int x = guiLeft + 4 + i % 2 * 84; - talents.put(i, new GuiTalent(role, talent, x, y)); - if(role.getTalentLevel(talent) < 5){ - addButton(new GuiNpcButton(i + 10, x + 26, y, 14, 14, "+")); - y += 8; - } - addLabel(new GuiNpcLabel(i, role.talents.get(talent) + "/" + role.getNextLevel(talent), x + 26, y + 8)); - } + private void addTalent(int i, EnumCompanionTalent talent) { + int y = guiTop + 28 + i / 2 * 26; + int x = guiLeft + 4 + i % 2 * 84; + talents.put(i, new GuiTalent(role, talent, x, y)); + if (role.getTalentLevel(talent) < 5) { + addButton(new GuiNpcButton(i + 10, x + 26, y, 14, 14, "+")); + y += 8; + } + addLabel(new GuiNpcLabel(i, role.talents.get(talent) + "/" + role.getNextLevel(talent), x + 26, y + 8)); + } - @Override - public void actionPerformed(GuiButton guibutton) { - super.actionPerformed(guibutton); - int id = guibutton.id; - if(id == 1){ - CustomNpcs.proxy.openGui(npc, EnumGuiType.Companion); - } - if(id == 3){ + @Override + public void actionPerformed(GuiButton guibutton) { + super.actionPerformed(guibutton); + int id = guibutton.id; + if (id == 1) { + CustomNpcs.proxy.openGui(npc, EnumGuiType.Companion); + } + if (id == 3) { CompanionActionPacket.OpenInventory(); - } - if(id >= 10){ - selected = (GuiNpcButton) guibutton; - lastPressedTime = startPressedTime = mc.theWorld.getWorldTime(); - addExperience(1); - } - } + } + if (id >= 10) { + selected = (GuiNpcButton) guibutton; + lastPressedTime = startPressedTime = mc.theWorld.getWorldTime(); + addExperience(1); + } + } - private void addExperience(int exp){ - EnumCompanionTalent talent = talents.get(selected.id - 10).talent; - if(!role.canAddExp(-exp) && role.currentExp <= 0) - return; - if(exp > role.currentExp) - exp = role.currentExp; - CompanionActionPacket.TalentExp(talent, exp); - role.talents.put(talent, role.talents.get(talent) + exp); - role.addExp(-exp); - getLabel(selected.id - 10).label = role.talents.get(talent) + "/" + role.getNextLevel(talent); - } + private void addExperience(int exp) { + EnumCompanionTalent talent = talents.get(selected.id - 10).talent; + if (!role.canAddExp(-exp) && role.currentExp <= 0) + return; + if (exp > role.currentExp) + exp = role.currentExp; + CompanionActionPacket.TalentExp(talent, exp); + role.talents.put(talent, role.talents.get(talent) + exp); + role.addExp(-exp); + getLabel(selected.id - 10).label = role.talents.get(talent) + "/" + role.getNextLevel(talent); + } - private long lastPressedTime = 0; - private long startPressedTime = 0; - @Override - public void drawScreen(int i, int j, float f) { - super.drawScreen(i, j, f); - if(selected != null && mc.theWorld.getWorldTime() - startPressedTime > 4 && lastPressedTime < mc.theWorld.getWorldTime() && mc.theWorld.getWorldTime() % 4 == 0){ - if(selected.mousePressed(mc, i, j) && Mouse.isButtonDown(0)){ - lastPressedTime = mc.theWorld.getWorldTime(); - if(lastPressedTime - startPressedTime < 20) - addExperience(1); - else if(lastPressedTime - startPressedTime < 40) - addExperience(2); - else if(lastPressedTime - startPressedTime < 60) - addExperience(4); - else if(lastPressedTime - startPressedTime < 90) - addExperience(8); - else if(lastPressedTime - startPressedTime < 140) - addExperience(14); - else - addExperience(28); - } - else{ - lastPressedTime = 0; - selected = null; - } - } + private long lastPressedTime = 0; + private long startPressedTime = 0; + + @Override + public void drawScreen(int i, int j, float f) { + super.drawScreen(i, j, f); + if (selected != null && mc.theWorld.getWorldTime() - startPressedTime > 4 && lastPressedTime < mc.theWorld.getWorldTime() && mc.theWorld.getWorldTime() % 4 == 0) { + if (selected.mousePressed(mc, i, j) && Mouse.isButtonDown(0)) { + lastPressedTime = mc.theWorld.getWorldTime(); + if (lastPressedTime - startPressedTime < 20) + addExperience(1); + else if (lastPressedTime - startPressedTime < 40) + addExperience(2); + else if (lastPressedTime - startPressedTime < 60) + addExperience(4); + else if (lastPressedTime - startPressedTime < 90) + addExperience(8); + else if (lastPressedTime - startPressedTime < 140) + addExperience(14); + else + addExperience(28); + } else { + lastPressedTime = 0; + selected = null; + } + } mc.getTextureManager().bindTexture(Gui.icons); this.drawTexturedModalRect(guiLeft + 4, guiTop + 20, 10, 64, 162, 5); - if (role.currentExp > 0){ - float v = 1f * role.currentExp / role.getMaxExp(); - if(v > 1) - v = 1; - this.drawTexturedModalRect(guiLeft + 4, guiTop + 20, 10, 69, (int)(v * 162), 5); + if (role.currentExp > 0) { + float v = 1f * role.currentExp / role.getMaxExp(); + if (v > 1) + v = 1; + this.drawTexturedModalRect(guiLeft + 4, guiTop + 20, 10, 69, (int) (v * 162), 5); } String s = role.currentExp + "\\" + role.getMaxExp(); mc.fontRenderer.drawString(s, guiLeft + xSize / 2 - mc.fontRenderer.getStringWidth(s) / 2, guiTop + 10, CustomNpcResourceListener.DefaultTextColor); - for(GuiTalent talent : talents.values()){ - talent.drawScreen(i, j, f); - } - } + for (GuiTalent talent : talents.values()) { + talent.drawScreen(i, j, f); + } + } - @Override - public void save() { + @Override + public void save() { - } + } - public static class GuiTalent extends GuiScreen{ - private EnumCompanionTalent talent; - private int x, y; - private RoleCompanion role; - private static final ResourceLocation resource = new ResourceLocation("customnpcs:textures/gui/talent.png"); - public GuiTalent(RoleCompanion role, EnumCompanionTalent talent, int x, int y){ - this.talent = talent; - this.x = x; - this.y = y; - this.role = role; - } + public static class GuiTalent extends GuiScreen { + private EnumCompanionTalent talent; + private int x, y; + private RoleCompanion role; + private static final ResourceLocation resource = new ResourceLocation("customnpcs:textures/gui/talent.png"); - @Override - public void drawScreen(int i, int j, float f) { - Minecraft mc = Minecraft.getMinecraft(); - mc.getTextureManager().bindTexture(resource); + public GuiTalent(RoleCompanion role, EnumCompanionTalent talent, int x, int y) { + this.talent = talent; + this.x = x; + this.y = y; + this.role = role; + } - ItemStack item = talent.item; - if(item.getItem() == null) - item = new ItemStack(Blocks.dirt); - GL11.glPushMatrix(); - GL11.glColor3f(1F, 1F, 1F); - GL11.glEnable(GL11.GL_BLEND); - boolean hover = x < i && x + 24 > i && y < j && y + 24 > j; - this.drawTexturedModalRect(x, y, 0, hover?24:0, 24, 24); - this.zLevel = 100.0F; - itemRender.zLevel = 100.0F; - GL11.glEnable(GL11.GL_LIGHTING); - GL11.glEnable(GL12.GL_RESCALE_NORMAL); - RenderHelper.enableGUIStandardItemLighting(); - itemRender.renderItemAndEffectIntoGUI(mc.fontRenderer, mc.getTextureManager(), item, x + 4, y + 4); - itemRender.renderItemOverlayIntoGUI(mc.fontRenderer, mc.getTextureManager(), item, x + 4, y + 4); - RenderHelper.disableStandardItemLighting(); - GL11.glDisable(GL11.GL_LIGHTING); - GL11.glTranslatef(0, 0, 200); + @Override + public void drawScreen(int i, int j, float f) { + Minecraft mc = Minecraft.getMinecraft(); + mc.getTextureManager().bindTexture(resource); + + ItemStack item = talent.item; + if (item.getItem() == null) + item = new ItemStack(Blocks.dirt); + GL11.glPushMatrix(); + GL11.glColor3f(1F, 1F, 1F); + GL11.glEnable(GL11.GL_BLEND); + boolean hover = x < i && x + 24 > i && y < j && y + 24 > j; + this.drawTexturedModalRect(x, y, 0, hover ? 24 : 0, 24, 24); + this.zLevel = 100.0F; + itemRender.zLevel = 100.0F; + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + RenderHelper.enableGUIStandardItemLighting(); + itemRender.renderItemAndEffectIntoGUI(mc.fontRenderer, mc.getTextureManager(), item, x + 4, y + 4); + itemRender.renderItemOverlayIntoGUI(mc.fontRenderer, mc.getTextureManager(), item, x + 4, y + 4); + RenderHelper.disableStandardItemLighting(); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glTranslatef(0, 0, 200); this.drawCenteredString(mc.fontRenderer, role.getTalentLevel(talent) + "", x + 20, y + 16, 0xFFFFFF); - itemRender.zLevel = 0.0F; - this.zLevel = 0.0F; - GL11.glPopMatrix(); - } - } + itemRender.zLevel = 0.0F; + this.zLevel = 0.0F; + GL11.glPopMatrix(); + } + } } diff --git a/src/main/java/noppes/npcs/client/gui/player/inventory/GuiCNPCInventory.java b/src/main/java/noppes/npcs/client/gui/player/inventory/GuiCNPCInventory.java index 4783e7cff..666056506 100644 --- a/src/main/java/noppes/npcs/client/gui/player/inventory/GuiCNPCInventory.java +++ b/src/main/java/noppes/npcs/client/gui/player/inventory/GuiCNPCInventory.java @@ -17,7 +17,7 @@ import tconstruct.client.tabs.InventoryTabCustomNpc; import tconstruct.client.tabs.TabRegistry; public class GuiCNPCInventory extends GuiNPCInterface { - public static final ResourceLocation specialIcons = new ResourceLocation("customnpcs","textures/gui/icons.png"); + public static final ResourceLocation specialIcons = new ResourceLocation("customnpcs", "textures/gui/icons.png"); public static int activeTab = -100; protected Minecraft mc = Minecraft.getMinecraft(); @@ -30,9 +30,9 @@ public class GuiCNPCInventory extends GuiNPCInterface { drawDefaultBackground = false; } - public void initGui(){ + public void initGui() { super.initGui(); - guiTop +=10; + guiTop += 10; TabRegistry.updateTabValues(guiLeft, guiTop, InventoryTabCustomNpc.class); TabRegistry.addTabsToList(buttonList); @@ -46,7 +46,7 @@ public class GuiCNPCInventory extends GuiNPCInterface { questsButton.renderResource = specialIcons; addSideButton(questsButton); - if(ClientCacheHandler.allowParties){ + if (ClientCacheHandler.allowParties) { y += 21; GuiMenuSideButton partyButton = new GuiMenuSideButton(-101, guiLeft + xSize + 37, this.guiTop + y, 22, 22, ""); partyButton.rightSided = true; @@ -54,7 +54,7 @@ public class GuiCNPCInventory extends GuiNPCInterface { partyButton.renderResource = specialIcons; addSideButton(partyButton); } - if(ConfigClient.enableFactionTab){ + if (ConfigClient.enableFactionTab) { y += 21; GuiMenuSideButton factionButton = new GuiMenuSideButton(-102, guiLeft + xSize + 37, this.guiTop + y, 22, 22, ""); factionButton.rightSided = true; @@ -63,7 +63,7 @@ public class GuiCNPCInventory extends GuiNPCInterface { factionButton.renderResource = specialIcons; addSideButton(factionButton); } - if(ClientCacheHandler.allowProfiles){ + if (ClientCacheHandler.allowProfiles) { y += 21; GuiMenuSideButton profileButton = new GuiMenuSideButton(-104, guiLeft + xSize + 37, this.guiTop + y, 22, 22, ""); profileButton.rightSided = true; @@ -108,7 +108,7 @@ public class GuiCNPCInventory extends GuiNPCInterface { updateEffectBar(); super.drawScreen(mouseX, mouseY, partialTicks); if (!ConfigClient.HideEffectsBar && effectBar != null && !effectBar.entries.isEmpty()) { - if(activeTab != -100) + if (activeTab != -100) effectBar.drawScreen(mouseX, mouseY, partialTicks); } } @@ -130,7 +130,7 @@ public class GuiCNPCInventory extends GuiNPCInterface { @Override - protected void actionPerformed(GuiButton guibutton){ + protected void actionPerformed(GuiButton guibutton) { if (guibutton.id <= -100) { if (guibutton.id == -100 && activeTab != -100) { activeTab = -100; @@ -156,5 +156,6 @@ public class GuiCNPCInventory extends GuiNPCInterface { } @Override - public void save() {} + public void save() { + } } diff --git a/src/main/java/noppes/npcs/client/gui/player/inventory/GuiFaction.java b/src/main/java/noppes/npcs/client/gui/player/inventory/GuiFaction.java index f8a4969d6..395387b1d 100644 --- a/src/main/java/noppes/npcs/client/gui/player/inventory/GuiFaction.java +++ b/src/main/java/noppes/npcs/client/gui/player/inventory/GuiFaction.java @@ -19,179 +19,174 @@ import java.util.ArrayList; public class GuiFaction extends GuiCNPCInventory implements IGuiData { - private final ResourceLocation resource = new ResourceLocation("customnpcs","textures/gui/standardbg.png"); + private final ResourceLocation resource = new ResourceLocation("customnpcs", "textures/gui/standardbg.png"); private ArrayList playerFactions = new ArrayList(); - private int page = 0; - private int pages = 1; + private int page = 0; + private int pages = 1; - private GuiButtonNextPage buttonNextPage; - private GuiButtonNextPage buttonPreviousPage; + private GuiButtonNextPage buttonNextPage; + private GuiButtonNextPage buttonPreviousPage; - public GuiFaction() { - super(); - xSize = 280; - ySize = 180; + public GuiFaction() { + super(); + xSize = 280; + ySize = 180; this.drawDefaultBackground = false; title = ""; PacketClient.sendClient(new CheckPlayerValue(CheckPlayerValue.Type.Faction)); - } + } - @Override - public void initGui() - { - super.initGui(); + @Override + public void initGui() { + super.initGui(); this.buttonList.add(buttonNextPage = new GuiButtonNextPage(1, (guiLeft + (xSize + 35) / 2) + 25, guiTop + 170, true)); this.buttonList.add(buttonPreviousPage = new GuiButtonNextPage(2, (guiLeft + (xSize + 35) / 2) - 40, guiTop + 170, false)); updateButtons(); } - @Override - public void drawScreen(int i, int j, float f) - { - drawDefaultBackground(); + @Override + public void drawScreen(int i, int j, float f) { + drawDefaultBackground(); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - mc.renderEngine.bindTexture(resource); - drawTexturedModalRect(guiLeft, guiTop, 0, 0, 252, 195); - drawTexturedModalRect(guiLeft + 252, guiTop, 188, 0, 67, 195); + mc.renderEngine.bindTexture(resource); + drawTexturedModalRect(guiLeft, guiTop, 0, 0, 252, 195); + drawTexturedModalRect(guiLeft + 252, guiTop, 188, 0, 67, 195); - if(playerFactions.isEmpty()){ - String noFaction = StatCollector.translateToLocal("faction.nostanding"); - fontRendererObj.drawString(noFaction,guiLeft + (xSize - fontRendererObj.getStringWidth(noFaction)) / 2,guiTop + 80, CustomNpcResourceListener.DefaultTextColor); - } - else - renderScreen(); + if (playerFactions.isEmpty()) { + String noFaction = StatCollector.translateToLocal("faction.nostanding"); + fontRendererObj.drawString(noFaction, guiLeft + (xSize - fontRendererObj.getStringWidth(noFaction)) / 2, guiTop + 80, CustomNpcResourceListener.DefaultTextColor); + } else + renderScreen(); super.drawScreen(i, j, f); } - private void renderScreen(){ + private void renderScreen() { int size = 10; - if(playerFactions.size() % 10 != 0 && page == pages) - size = playerFactions.size() % 10; + if (playerFactions.size() % 10 != 0 && page == pages) + size = playerFactions.size() % 10; - int hLine = 5; - if(size < 5){ - hLine = size; - } + int hLine = 5; + if (size < 5) { + hLine = size; + } - int count = -1; - for(int id = 0 ; id < size; id++){ - count++; + int count = -1; + for (int id = 0; id < size; id++) { + count++; - Faction faction = playerFactions.get((page - 1) * 10 + id); - String name = faction.name; - String points = " : " + faction.defaultPoints; + Faction faction = playerFactions.get((page - 1) * 10 + id); + String name = faction.name; + String points = " : " + faction.defaultPoints; - String standing = StatCollector.translateToLocal("faction.friendly"); - int color = 0x00FF00; - if(faction.defaultPoints < faction.neutralPoints){ - standing = StatCollector.translateToLocal("faction.unfriendly"); - color = 0xFF0000; - points += "/" + faction.neutralPoints; - } - else if(faction.defaultPoints < faction.friendlyPoints){ - standing = StatCollector.translateToLocal("faction.neutral"); - color = 0xF2FF00; - points += "/" + faction.friendlyPoints; - } - else{ - points += "/-"; - } + String standing = StatCollector.translateToLocal("faction.friendly"); + int color = 0x00FF00; + if (faction.defaultPoints < faction.neutralPoints) { + standing = StatCollector.translateToLocal("faction.unfriendly"); + color = 0xFF0000; + points += "/" + faction.neutralPoints; + } else if (faction.defaultPoints < faction.friendlyPoints) { + standing = StatCollector.translateToLocal("faction.neutral"); + color = 0xF2FF00; + points += "/" + faction.friendlyPoints; + } else { + points += "/-"; + } - drawVerticalLine(guiLeft + (xSize + 45) / 2, (guiTop + ySize - 15), guiTop + 13, 0xFF000000 + CustomNpcResourceListener.DefaultTextColor); - if(count < 5){ - drawHorizontalLine(guiLeft + 2, guiLeft + xSize + 35, guiTop + 14 + count * 30, 0xFF000000 + CustomNpcResourceListener.DefaultTextColor); - fontRendererObj.drawString(name, guiLeft + (xSize + 45 - fontRendererObj.getStringWidth(name)) / 4, guiTop + 19 + count * 30, faction.color); + drawVerticalLine(guiLeft + (xSize + 45) / 2, (guiTop + ySize - 15), guiTop + 13, 0xFF000000 + CustomNpcResourceListener.DefaultTextColor); + if (count < 5) { + drawHorizontalLine(guiLeft + 2, guiLeft + xSize + 35, guiTop + 14 + count * 30, 0xFF000000 + CustomNpcResourceListener.DefaultTextColor); + fontRendererObj.drawString(name, guiLeft + (xSize + 45 - fontRendererObj.getStringWidth(name)) / 4, guiTop + 19 + count * 30, faction.color); - fontRendererObj.drawString(standing, (guiLeft + (xSize + 45) / 4) - fontRendererObj.getStringWidth(standing), guiTop + 33 + count * 30, color); - fontRendererObj.drawString(points, (guiLeft + (xSize + 45) / 4), guiTop + 33 + count * 30, CustomNpcResourceListener.DefaultTextColor); - } - else { - fontRendererObj.drawString(name, guiLeft + 3*(xSize + 45 - fontRendererObj.getStringWidth(name)) / 4, guiTop + 19 + (count - 5) * 30, faction.color); + fontRendererObj.drawString(standing, (guiLeft + (xSize + 45) / 4) - fontRendererObj.getStringWidth(standing), guiTop + 33 + count * 30, color); + fontRendererObj.drawString(points, (guiLeft + (xSize + 45) / 4), guiTop + 33 + count * 30, CustomNpcResourceListener.DefaultTextColor); + } else { + fontRendererObj.drawString(name, guiLeft + 3 * (xSize + 45 - fontRendererObj.getStringWidth(name)) / 4, guiTop + 19 + (count - 5) * 30, faction.color); - fontRendererObj.drawString(standing, (guiLeft + 3*(xSize + 45) / 4) - fontRendererObj.getStringWidth(standing) - 10, guiTop + 33 + (count - 5) * 30, color); - fontRendererObj.drawString(points, (guiLeft + 3*(xSize + 45) / 4) - 10, guiTop + 33 + (count - 5) * 30, CustomNpcResourceListener.DefaultTextColor); - } + fontRendererObj.drawString(standing, (guiLeft + 3 * (xSize + 45) / 4) - fontRendererObj.getStringWidth(standing) - 10, guiTop + 33 + (count - 5) * 30, color); + fontRendererObj.drawString(points, (guiLeft + 3 * (xSize + 45) / 4) - 10, guiTop + 33 + (count - 5) * 30, CustomNpcResourceListener.DefaultTextColor); + } - drawHorizontalLine(guiLeft + 2, guiLeft + xSize + 35, guiTop + 14 + hLine * 30, 0xFF000000 + CustomNpcResourceListener.DefaultTextColor); - } + drawHorizontalLine(guiLeft + 2, guiLeft + xSize + 35, guiTop + 14 + hLine * 30, 0xFF000000 + CustomNpcResourceListener.DefaultTextColor); + } - if(pages > 1){ - String s = page +"/" + pages; - fontRendererObj.drawString(s, guiLeft + (xSize + 45 - fontRendererObj.getStringWidth(s)) / 2, guiTop + 175, CustomNpcResourceListener.DefaultTextColor); + if (pages > 1) { + String s = page + "/" + pages; + fontRendererObj.drawString(s, guiLeft + (xSize + 45 - fontRendererObj.getStringWidth(s)) / 2, guiTop + 175, CustomNpcResourceListener.DefaultTextColor); } } @Override - protected void actionPerformed(GuiButton guibutton){ - if(guibutton instanceof AbstractTab) + protected void actionPerformed(GuiButton guibutton) { + if (guibutton instanceof AbstractTab) return; if (guibutton.id <= -100) { super.actionPerformed(guibutton); return; } - if(!(guibutton instanceof GuiButtonNextPage)) - return; - int id = guibutton.id; - if(id == 1){ - page++; - } - if(id == 2){ - page--; - } - updateButtons(); + if (!(guibutton instanceof GuiButtonNextPage)) + return; + int id = guibutton.id; + if (id == 1) { + page++; + } + if (id == 2) { + page--; + } + updateButtons(); } - private void updateButtons(){ - buttonNextPage.setVisible(page < pages); - buttonPreviousPage.setVisible(page > 1); + + private void updateButtons() { + buttonNextPage.setVisible(page < pages); + buttonPreviousPage.setVisible(page > 1); } - protected void drawGuiContainerBackgroundLayer(float f, int i, int j) - { + + protected void drawGuiContainerBackgroundLayer(float f, int i, int j) { } @Override - public void keyTyped(char c, int i) - { - if (i == 1 || isInventoryKey(i)) - { + public void keyTyped(char c, int i) { + if (i == 1 || isInventoryKey(i)) { close(); } } - @Override - public void save() { - } - @Override - public void setGuiData(NBTTagCompound compound) { - playerFactions = new ArrayList(); - NBTTagList list = compound.getTagList("FactionList", 10); - for(int i = 0; i < list.tagCount(); i++){ - Faction faction = new Faction(); - faction.readNBT(list.getCompoundTagAt(i)); - playerFactions.add(faction); - } - PlayerFactionData data = new PlayerFactionData(); - data.loadNBTData(compound); - for(int id : data.factionData.keySet()){ - int points = data.factionData.get(id); - for(Faction faction : playerFactions){ - if(faction.id == id) - faction.defaultPoints = points; - } - } + @Override + public void save() { + } - pages = (playerFactions.size() - 1) / 10 ; - pages++; + @Override + public void setGuiData(NBTTagCompound compound) { + playerFactions = new ArrayList(); - page = 1; + NBTTagList list = compound.getTagList("FactionList", 10); + for (int i = 0; i < list.tagCount(); i++) { + Faction faction = new Faction(); + faction.readNBT(list.getCompoundTagAt(i)); + playerFactions.add(faction); + } + PlayerFactionData data = new PlayerFactionData(); + data.loadNBTData(compound); + for (int id : data.factionData.keySet()) { + int points = data.factionData.get(id); + for (Faction faction : playerFactions) { + if (faction.id == id) + faction.defaultPoints = points; + } + } - updateButtons(); - } + pages = (playerFactions.size() - 1) / 10; + pages++; + + page = 1; + + updateButtons(); + } } diff --git a/src/main/java/noppes/npcs/client/gui/player/inventory/GuiParty.java b/src/main/java/noppes/npcs/client/gui/player/inventory/GuiParty.java index 58348542a..18c1a36be 100644 --- a/src/main/java/noppes/npcs/client/gui/player/inventory/GuiParty.java +++ b/src/main/java/noppes/npcs/client/gui/player/inventory/GuiParty.java @@ -22,8 +22,8 @@ import tconstruct.client.tabs.AbstractTab; import java.util.*; -public class GuiParty extends GuiCNPCInventory implements ITextfieldListener,ICustomScrollListener, IPartyData, GuiYesNoCallback { - private final ResourceLocation resource = new ResourceLocation("customnpcs","textures/gui/standardbg.png"); +public class GuiParty extends GuiCNPCInventory implements ITextfieldListener, ICustomScrollListener, IPartyData, GuiYesNoCallback { + private final ResourceLocation resource = new ResourceLocation("customnpcs", "textures/gui/standardbg.png"); private final EntityPlayer player; private boolean receivedData; @@ -54,7 +54,7 @@ public class GuiParty extends GuiCNPCInventory implements ITextfieldListener,ICu PacketClient.sendClient(new PartyInfoPacket()); } - public void initGui(){ + public void initGui() { super.initGui(); this.selectedInvite = this.selectedPlayer = null; @@ -65,7 +65,7 @@ public class GuiParty extends GuiCNPCInventory implements ITextfieldListener,ICu // //create party button // - GuiNpcButton createPartyButton = new GuiNpcButton(200, guiLeft + xSize/2 + 40, guiTop + ySize/2 + 20, "party.createParty"); + GuiNpcButton createPartyButton = new GuiNpcButton(200, guiLeft + xSize / 2 + 40, guiTop + ySize / 2 + 20, "party.createParty"); createPartyButton.width = 100; this.addButton(createPartyButton); @@ -120,7 +120,7 @@ public class GuiParty extends GuiCNPCInventory implements ITextfieldListener,ICu guiLeft + 284 - fontRendererObj.getStringWidth(textString), getButton(405).yPosition + 3)); getButton(405).visible = getLabel(406).enabled = !getButton(400).visible; - if(isLeader){ + if (isLeader) { GuiNpcButton disbandButton = new GuiNpcButton(410, guiLeft + 164, arrowButtonsY + 19, "party.dropQuest"); disbandButton.width = 135; this.addButton(disbandButton); @@ -172,7 +172,7 @@ public class GuiParty extends GuiCNPCInventory implements ITextfieldListener,ICu this.addButton(leaveButton); } - if (party.getIsLocked()){ + if (party.getIsLocked()) { GuiNpcButton trackButton = new GuiNpcButton(415, guiLeft + 5, guiTop + ySize - 8 - 23, new String[]{"party.track", "quest.tracking"}, data.trackedQuestKey.equals("P" + ":" + trackedQuestKey) ? 1 : 0); trackButton.width = 135; this.addButton(trackButton); @@ -216,8 +216,8 @@ public class GuiParty extends GuiCNPCInventory implements ITextfieldListener,ICu } @Override - protected void actionPerformed(GuiButton guibutton){ - if(guibutton instanceof AbstractTab) + protected void actionPerformed(GuiButton guibutton) { + if (guibutton instanceof AbstractTab) return; Party party = ClientCacheHandler.party; @@ -303,7 +303,7 @@ public class GuiParty extends GuiCNPCInventory implements ITextfieldListener,ICu } @Override - public void drawScreen(int i, int j, float f){ + public void drawScreen(int i, int j, float f) { renderTicks++; drawDefaultBackground(); @@ -313,17 +313,17 @@ public class GuiParty extends GuiCNPCInventory implements ITextfieldListener,ICu drawTexturedModalRect(guiLeft + 252, guiTop, 188, 0, 67, 195); super.drawScreen(i, j, f); - if(!receivedData){ + if (!receivedData) { String periods = ""; - for (int k = 0; k < (renderTicks/10)%4; k++) { + for (int k = 0; k < (renderTicks / 10) % 4; k++) { periods += "."; } - fontRendererObj.drawString(StatCollector.translateToLocal("gui.loading") + periods,guiLeft + xSize/2,guiTop + 80, CustomNpcResourceListener.DefaultTextColor); + fontRendererObj.drawString(StatCollector.translateToLocal("gui.loading") + periods, guiLeft + xSize / 2, guiTop + 80, CustomNpcResourceListener.DefaultTextColor); return; } if (ClientCacheHandler.party == null) { - drawTextBlock("party.messageNoParty", guiLeft + 155, guiTop + ySize/2 - 20, 160); + drawTextBlock("party.messageNoParty", guiLeft + 155, guiTop + ySize / 2 - 20, 160); } else if (ClientCacheHandler.party.getQuest() != null) { Quest quest = (Quest) ClientCacheHandler.party.getQuest(); if (showQuestText) { @@ -343,31 +343,30 @@ public class GuiParty extends GuiCNPCInventory implements ITextfieldListener,ICu private void drawProgress() { String complete = this.questCompleteWith; - if(complete != null && !complete.isEmpty()) + if (complete != null && !complete.isEmpty()) fontRendererObj.drawString(StatCollector.translateToLocalFormatted("quest.completewith", complete), guiLeft + 144, guiTop + 105, CustomNpcResourceListener.DefaultTextColor); int yoffset = guiTop + 22; - for(String process : this.questLogStatus){ + for (String process : this.questLogStatus) { int index = process.lastIndexOf(":"); - if(index > 0){ + if (index > 0) { String name = process.substring(0, index); String trans = StatCollector.translateToLocal(name); - if(!trans.equals(name)) + if (!trans.equals(name)) name = trans; trans = StatCollector.translateToLocal("entity." + name + ".name"); - if(!trans.equals("entity." + name + ".name")){ + if (!trans.equals("entity." + name + ".name")) { name = trans; } process = name + process.substring(index); } - fontRendererObj.drawString("- " + process, guiLeft + 144, yoffset , CustomNpcResourceListener.DefaultTextColor); + fontRendererObj.drawString("- " + process, guiLeft + 144, yoffset, CustomNpcResourceListener.DefaultTextColor); yoffset += 10; } } @Override - public void keyTyped(char c, int i) - { + public void keyTyped(char c, int i) { super.keyTyped(c, i); if (!GuiNpcTextField.isFieldActive()) { if (i == 1 || i == mc.gameSettings.keyBindInventory.getKeyCode()) // inventory key @@ -453,7 +452,7 @@ public class GuiParty extends GuiCNPCInventory implements ITextfieldListener,ICu @Override public void save() { if (this.partyChanged) { - if(ClientCacheHandler.party != null) + if (ClientCacheHandler.party != null) PacketClient.sendClient(new PartySavePacket(ClientCacheHandler.party.writeClientNBT())); } if (!Objects.equals(this.originalTracked, data.trackedQuestKey)) { diff --git a/src/main/java/noppes/npcs/client/gui/player/inventory/GuiProfiles.java b/src/main/java/noppes/npcs/client/gui/player/inventory/GuiProfiles.java index a4518901f..aef3502e8 100644 --- a/src/main/java/noppes/npcs/client/gui/player/inventory/GuiProfiles.java +++ b/src/main/java/noppes/npcs/client/gui/player/inventory/GuiProfiles.java @@ -1,11 +1,10 @@ package noppes.npcs.client.gui.player.inventory; -import kamkeel.npcs.network.packets.player.profile.*; -import noppes.npcs.api.handler.data.ISlot; -import kamkeel.npcs.controllers.data.profile.ProfileInfoEntry; import kamkeel.npcs.controllers.data.profile.Profile; +import kamkeel.npcs.controllers.data.profile.ProfileInfoEntry; import kamkeel.npcs.controllers.data.profile.Slot; import kamkeel.npcs.network.PacketClient; +import kamkeel.npcs.network.packets.player.profile.*; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiYesNo; import net.minecraft.client.gui.GuiYesNoCallback; @@ -13,6 +12,7 @@ import net.minecraft.client.gui.ScaledResolution; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.ResourceLocation; import net.minecraft.util.StatCollector; +import noppes.npcs.api.handler.data.ISlot; import noppes.npcs.client.CustomNpcResourceListener; import noppes.npcs.client.NoppesUtil; import noppes.npcs.client.gui.SubGuiEditText; @@ -29,7 +29,7 @@ import java.util.List; public class GuiProfiles extends GuiCNPCInventory implements ISubGuiListener, ICustomScrollListener, IGuiData, GuiYesNoCallback { - private final ResourceLocation resource = new ResourceLocation("customnpcs","textures/gui/standardbg.png"); + private final ResourceLocation resource = new ResourceLocation("customnpcs", "textures/gui/standardbg.png"); private GuiCustomScroll scroll; public HashMap data = new HashMap<>(); private String selected = null; @@ -46,28 +46,27 @@ public class GuiProfiles extends GuiCNPCInventory implements ISubGuiListener, IC private int lastMouseY = 0; // Last recorded mouse Y position when dragging public GuiProfiles() { - super(); - xSize = 280; - ySize = 180; + super(); + xSize = 280; + ySize = 180; this.drawDefaultBackground = false; title = ""; PacketClient.sendClient(new ProfileGetPacket()); PacketClient.sendClient(new ProfileGetInfoPacket()); - } + } - @Override - public void initGui() - { - super.initGui(); + @Override + public void initGui() { + super.initGui(); int y = guiTop + 4; - this.addButton(new GuiNpcButton(1,guiLeft + 4, y += 144, 60, 20, "gui.change")); - this.addButton(new GuiNpcButton(2,guiLeft + 4 + 63, y, 60, 20, "gui.rename")); - this.addButton(new GuiNpcButton(3,guiLeft + 4 + 63, y += 22, 60, 20, "gui.remove")); - this.addButton(new GuiNpcButton(4,guiLeft + 4, y, 60, 20, "gui.create")); + this.addButton(new GuiNpcButton(1, guiLeft + 4, y += 144, 60, 20, "gui.change")); + this.addButton(new GuiNpcButton(2, guiLeft + 4 + 63, y, 60, 20, "gui.rename")); + this.addButton(new GuiNpcButton(3, guiLeft + 4 + 63, y += 22, 60, 20, "gui.remove")); + this.addButton(new GuiNpcButton(4, guiLeft + 4, y, 60, 20, "gui.create")); - if(scroll == null){ - scroll = new GuiCustomScroll(this,0); + if (scroll == null) { + scroll = new GuiCustomScroll(this, 0); scroll.setSize(123, 141); } scroll.guiLeft = guiLeft + 4; @@ -77,8 +76,8 @@ public class GuiProfiles extends GuiCNPCInventory implements ISubGuiListener, IC } @Override - protected void actionPerformed(GuiButton guibutton){ - if(guibutton instanceof AbstractTab) + protected void actionPerformed(GuiButton guibutton) { + if (guibutton instanceof AbstractTab) return; if (guibutton.id <= -100) { @@ -86,22 +85,22 @@ public class GuiProfiles extends GuiCNPCInventory implements ISubGuiListener, IC return; } - if(guibutton.id == 4){ + if (guibutton.id == 4) { GuiYesNo guiyesno = new GuiYesNo(this, StatCollector.translateToLocal("profile.create.message"), StatCollector.translateToLocal("gui.sure"), 104); displayGuiScreen(guiyesno); } - if(this.slot == null) + if (this.slot == null) return; - if(guibutton.id == 1){ + if (guibutton.id == 1) { GuiYesNo guiyesno = new GuiYesNo(this, slot.getName(), StatCollector.translateToLocal("profile.change.message"), 101); displayGuiScreen(guiyesno); } - if(guibutton.id == 2){ + if (guibutton.id == 2) { setSubGui(new SubGuiEditText(slot.getName())); } - if(guibutton.id == 3){ + if (guibutton.id == 3) { GuiYesNo guiyesno = new GuiYesNo(this, slot.getName(), StatCollector.translateToLocal("gui.delete"), 103); displayGuiScreen(guiyesno); } @@ -169,7 +168,7 @@ public class GuiProfiles extends GuiCNPCInventory implements ISubGuiListener, IC fontRendererObj.drawString(result, resultX, y, resultColor, false); y += spacing; - if(slot.isTemporary()){ + if (slot.isTemporary()) { label = StatCollector.translateToLocal("profile.temporary"); result = (String.valueOf(slot.isTemporary())).toUpperCase(); labelColor = 0xfc60dd; @@ -222,7 +221,7 @@ public class GuiProfiles extends GuiCNPCInventory implements ISubGuiListener, IC @Override public void handleMouseInput() { super.handleMouseInput(); - if(isMouseOverScrollBox(mouseX, mouseY)){ + if (isMouseOverScrollBox(mouseX, mouseY)) { int delta = Mouse.getEventDWheel(); if (delta != 0) { scrollY -= delta / 7; @@ -266,16 +265,16 @@ public class GuiProfiles extends GuiCNPCInventory implements ISubGuiListener, IC } @Override - public void keyTyped(char c, int i) - { + public void keyTyped(char c, int i) { super.keyTyped(c, i); - if (i == 1 || (!hasSubGui() && isInventoryKey(i))) - { + if (i == 1 || (!hasSubGui() && isInventoryKey(i))) { close(); } } - @Override - public void save() {} + + @Override + public void save() { + } @Override public void confirmClicked(boolean result, int id) { @@ -286,18 +285,18 @@ public class GuiProfiles extends GuiCNPCInventory implements ISubGuiListener, IC // Create Slot PacketClient.sendClient(new ProfileCreatePacket()); } - if(slot == null) + if (slot == null) return; - if(id == 101){ + if (id == 101) { // Change Slot PacketClient.sendClient(new ProfileChangePacket(slot.getId())); } - if(id == 102 && rename != null && !rename.equalsIgnoreCase(slot.getName())){ + if (id == 102 && rename != null && !rename.equalsIgnoreCase(slot.getName())) { // Rename Slot PacketClient.sendClient(new ProfileRenamePacket(slot.getId(), rename)); } - if(id == 103){ + if (id == 103) { // Delete Slot PacketClient.sendClient(new ProfileRemovePacket(slot.getId())); } @@ -305,9 +304,9 @@ public class GuiProfiles extends GuiCNPCInventory implements ISubGuiListener, IC @Override public void subGuiClosed(SubGuiInterface subgui) { - if(subgui instanceof SubGuiEditText){ - if(!((SubGuiEditText)subgui).cancelled){ - rename = ((SubGuiEditText)subgui).text; + if (subgui instanceof SubGuiEditText) { + if (!((SubGuiEditText) subgui).cancelled) { + rename = ((SubGuiEditText) subgui).text; GuiYesNo guiyesno = new GuiYesNo(this, rename, StatCollector.translateToLocal("profile.rename.message"), 102); displayGuiScreen(guiyesno); } @@ -319,9 +318,9 @@ public class GuiProfiles extends GuiCNPCInventory implements ISubGuiListener, IC if (guiCustomScroll.id == 0) { slot = null; selected = scroll.getSelected(); - if (profile != null && selected != null && !selected.isEmpty()){ - for(ISlot checkSlot : profile.getSlots().values()){ - if(checkSlot.getId() == data.get(selected)){ + if (profile != null && selected != null && !selected.isEmpty()) { + for (ISlot checkSlot : profile.getSlots().values()) { + if (checkSlot.getId() == data.get(selected)) { slot = (Slot) checkSlot; break; } @@ -331,28 +330,29 @@ public class GuiProfiles extends GuiCNPCInventory implements ISubGuiListener, IC } @Override - public void customScrollDoubleClicked(String selection, GuiCustomScroll scroll) {} + public void customScrollDoubleClicked(String selection, GuiCustomScroll scroll) { + } public void setGuiData(NBTTagCompound compound) { this.slot = null; - if(compound.hasKey("PROFILE")){ + if (compound.hasKey("PROFILE")) { // Load Profile this.profile = new Profile(mc.thePlayer, compound); this.data = new HashMap<>(); String currentSlot = "\u00A7e"; String otherSlot = "\u00A7f"; - for(ISlot slot1 : profile.getSlots().values()){ + for (ISlot slot1 : profile.getSlots().values()) { String name = slot1.getId() + " - " + slot1.getName(); - if(profile.currentSlotId == slot1.getId()) + if (profile.currentSlotId == slot1.getId()) name = currentSlot + name; else name = otherSlot + name; this.data.put(name, slot1.getId()); } - } else if(compound.hasKey("PROFILE_INFO")){ + } else if (compound.hasKey("PROFILE_INFO")) { slotInfoMap = ProfileGetInfoPacket.readProfileInfo(compound); } - if(scroll != null){ + if (scroll != null) { scroll.setSelected(""); } initGui(); diff --git a/src/main/java/noppes/npcs/client/gui/player/inventory/GuiQuestLog.java b/src/main/java/noppes/npcs/client/gui/player/inventory/GuiQuestLog.java index 55583f14e..0b65ec305 100644 --- a/src/main/java/noppes/npcs/client/gui/player/inventory/GuiQuestLog.java +++ b/src/main/java/noppes/npcs/client/gui/player/inventory/GuiQuestLog.java @@ -28,56 +28,57 @@ import java.util.*; public class GuiQuestLog extends GuiCNPCInventory implements ICustomScrollListener, IGuiData, IPartyData, GuiYesNoCallback { - private final ResourceLocation resource = new ResourceLocation("customnpcs","textures/gui/standardbg.png"); + private final ResourceLocation resource = new ResourceLocation("customnpcs", "textures/gui/standardbg.png"); private EntityPlayer player; private GuiCustomScroll scroll; - private HashMap sideButtons = new HashMap(); - private QuestLogData data = new QuestLogData(); - private boolean noQuests = false; - private byte questPages = 1; + private HashMap sideButtons = new HashMap(); + private QuestLogData data = new QuestLogData(); + private boolean noQuests = false; + private byte questPages = 1; private static long lastClicked = System.currentTimeMillis(); private boolean isPartySet = false; - private HashMap questAlertsOnOpen; + private HashMap questAlertsOnOpen; private String trackedQuestKeyOnOpen; private float sideButtonScroll = 0; private float destSideButtonScroll = 0; - public GuiQuestLog() { - super(); - this.player = mc.thePlayer; + public GuiQuestLog() { + super(); + this.player = mc.thePlayer; xSize = 280; ySize = 180; drawDefaultBackground = false; PacketClient.sendClient(new CheckPlayerValue(CheckPlayerValue.Type.QuestLog)); } - public void initGui(){ + + public void initGui() { super.initGui(); - sideButtons.clear(); + sideButtons.clear(); noQuests = false; - if(data.categories.isEmpty()){ - noQuests = true; - return; + if (data.categories.isEmpty()) { + noQuests = true; + return; } List categories = new ArrayList(); categories.addAll(data.categories.keySet()); - Collections.sort(categories,String.CASE_INSENSITIVE_ORDER); + Collections.sort(categories, String.CASE_INSENSITIVE_ORDER); int i = 0; - for(String category : categories){ - if(data.selectedCategory.isEmpty()) - data.selectedCategory = category; - sideButtons.put(i, new GuiMenuSideButton(i,guiLeft - 69, this.guiTop +2 + i*21, 70,22, category)); + for (String category : categories) { + if (data.selectedCategory.isEmpty()) + data.selectedCategory = category; + sideButtons.put(i, new GuiMenuSideButton(i, guiLeft - 69, this.guiTop + 2 + i * 21, 70, 22, category)); i++; } sideButtons.get(categories.indexOf(data.selectedCategory)).active = true; - if(scroll == null) - scroll = new GuiCustomScroll(this,0); + if (scroll == null) + scroll = new GuiCustomScroll(this, 0); scroll.setList(data.categories.get(data.selectedCategory)); scroll.setSize(134, 174); @@ -93,10 +94,10 @@ public class GuiQuestLog extends GuiCNPCInventory implements ICustomScrollListen boolean showParty = false; boolean showTrackAlerts = true; - if(data.partyQuests.containsKey(data.selectedCategory + ":" + data.selectedQuest)){ + if (data.partyQuests.containsKey(data.selectedCategory + ":" + data.selectedQuest)) { showParty = true; - if(data.partyOptions.containsKey(data.selectedCategory + ":" + data.selectedQuest)){ - if(data.partyOptions.get(data.selectedCategory + ":" + data.selectedQuest).get(0).contains("only")){ + if (data.partyOptions.containsKey(data.selectedCategory + ":" + data.selectedQuest)) { + if (data.partyOptions.get(data.selectedCategory + ":" + data.selectedQuest).get(0).contains("only")) { showTrackAlerts = false; } } @@ -130,17 +131,17 @@ public class GuiQuestLog extends GuiCNPCInventory implements ICustomScrollListen GuiNpcButton alertButton = new GuiNpcButton(5, guiLeft + 205, guiTop + 151, 50, 20, new String[]{"quest.alerts", "quest.noAlerts"}, data.getQuestAlerts() ? 0 : 1); addButton(alertButton); - if(getButton(1) != null) + if (getButton(1) != null) getButton(1).visible = questPages == 1 && data.hasSelectedQuest(); - if(getButton(2) != null) + if (getButton(2) != null) getButton(2).visible = questPages == 2 && data.hasSelectedQuest(); if (getButton(3) != null) getButton(3).visible = !data.selectedQuest.isEmpty() && getButton(1).visible; - if(getButton(4) != null){ + if (getButton(4) != null) { getButton(4).visible = !data.selectedQuest.isEmpty() && getButton(1).visible; getButton(4).enabled = showTrackAlerts && !isPartySet; } - if(getButton(5) != null){ + if (getButton(5) != null) { getButton(5).visible = getButton(4).visible; getButton(5).enabled = showTrackAlerts && !isPartySet; } @@ -155,7 +156,7 @@ public class GuiQuestLog extends GuiCNPCInventory implements ICustomScrollListen if (flag) { if (i == 0) { String key = data.selectedCategory + ":" + data.selectedQuest; - if(data.partyQuests.containsKey(key)){ + if (data.partyQuests.containsKey(key)) { int questID = data.partyQuests.get(key); PacketClient.sendClient(new PartySetQuestPacket(questID)); } @@ -166,8 +167,8 @@ public class GuiQuestLog extends GuiCNPCInventory implements ICustomScrollListen } @Override - protected void actionPerformed(GuiButton guibutton){ - if(guibutton instanceof AbstractTab) + protected void actionPerformed(GuiButton guibutton) { + if (guibutton instanceof AbstractTab) return; if (guibutton.id <= -100) { @@ -175,26 +176,22 @@ public class GuiQuestLog extends GuiCNPCInventory implements ICustomScrollListen return; } - if(lastClicked > System.currentTimeMillis() - 5){ + if (lastClicked > System.currentTimeMillis() - 5) { return; } - if(guibutton.id == 11){ + if (guibutton.id == 11) { questPages = 1; lastClicked = System.currentTimeMillis(); - } - else if(guibutton.id == 10){ + } else if (guibutton.id == 10) { questPages = 0; - } - else if(guibutton.id == 1){ + } else if (guibutton.id == 1) { questPages = 2; - } - else if(guibutton.id == 2){ + } else if (guibutton.id == 2) { questPages = 1; lastClicked = System.currentTimeMillis(); } - if (guibutton.id == 3) - { + if (guibutton.id == 3) { if (Objects.equals(ClientCacheHandler.party.getCurrentQuestName(), data.selectedQuest)) { PacketClient.sendClient(new PartySetQuestPacket(-1)); } else { @@ -202,32 +199,33 @@ public class GuiQuestLog extends GuiCNPCInventory implements ICustomScrollListen displayGuiScreen(yesnoDisband); } } - if(guibutton.id == 4){ + if (guibutton.id == 4) { if (!data.trackedQuestKey.equals(data.selectedCategory + ":" + data.selectedQuest)) { data.trackedQuestKey = data.selectedCategory + ":" + data.selectedQuest; } else { data.trackedQuestKey = ""; } } - if(guibutton.id == 5){ + if (guibutton.id == 5) { data.toggleQuestAlerts(); } initGui(); } + @Override - public void drawScreen(int i, int j, float f){ - if(scroll != null) - scroll.visible = !noQuests; - drawDefaultBackground(); + public void drawScreen(int i, int j, float f) { + if (scroll != null) + scroll.visible = !noQuests; + drawDefaultBackground(); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); mc.renderEngine.bindTexture(resource); drawTexturedModalRect(guiLeft, guiTop, 0, 0, 252, 195); drawTexturedModalRect(guiLeft + 252, guiTop, 188, 0, 67, 195); super.drawScreen(i, j, f); - if(noQuests){ - fontRendererObj.drawString(StatCollector.translateToLocal("quest.noquests"),guiLeft + 84,guiTop + 80, CustomNpcResourceListener.DefaultTextColor); - return; + if (noQuests) { + fontRendererObj.drawString(StatCollector.translateToLocal("quest.noquests"), guiLeft + 84, guiTop + 80, CustomNpcResourceListener.DefaultTextColor); + return; } // Define constants for smoothing the scroll @@ -256,17 +254,17 @@ public class GuiQuestLog extends GuiCNPCInventory implements ICustomScrollListen } } - fontRendererObj.drawString(data.selectedCategory,guiLeft + 5,guiTop + 5, CustomNpcResourceListener.DefaultTextColor); + fontRendererObj.drawString(data.selectedCategory, guiLeft + 5, guiTop + 5, CustomNpcResourceListener.DefaultTextColor); - if(!data.hasSelectedQuest()) - return; + if (!data.hasSelectedQuest()) + return; if (questPages == 1) { - drawProgress(); - String title = StatCollector.translateToLocal("gui.text"); - fontRendererObj.drawString(title, guiLeft + 284 - fontRendererObj.getStringWidth(title), guiTop + 179, CustomNpcResourceListener.DefaultTextColor); + drawProgress(); + String title = StatCollector.translateToLocal("gui.text"); + fontRendererObj.drawString(title, guiLeft + 284 - fontRendererObj.getStringWidth(title), guiTop + 179, CustomNpcResourceListener.DefaultTextColor); - if(data.partyQuests.containsKey(data.selectedCategory + ":" + data.selectedQuest)){ + if (data.partyQuests.containsKey(data.selectedCategory + ":" + data.selectedQuest)) { title = StatCollector.translateToLocal("party.party"); fontRendererObj.drawString(title, guiLeft + 170, guiTop + 179, CustomNpcResourceListener.DefaultTextColor); } @@ -275,9 +273,9 @@ public class GuiQuestLog extends GuiCNPCInventory implements ICustomScrollListen String title = StatCollector.translateToLocal("quest.objectives"); fontRendererObj.drawString(title, guiLeft + 284 - fontRendererObj.getStringWidth(title), guiTop + 179, CustomNpcResourceListener.DefaultTextColor); } else { - drawQuestText(); - String title = StatCollector.translateToLocal("quest.objectives"); - fontRendererObj.drawString(title, guiLeft + 170, guiTop + 179, CustomNpcResourceListener.DefaultTextColor); + drawQuestText(); + String title = StatCollector.translateToLocal("quest.objectives"); + fontRendererObj.drawString(title, guiLeft + 170, guiTop + 179, CustomNpcResourceListener.DefaultTextColor); } GL11.glPushMatrix(); @@ -285,90 +283,90 @@ public class GuiQuestLog extends GuiCNPCInventory implements ICustomScrollListen GL11.glScalef(1.24f, 1.24f, 1.24f); fontRendererObj.drawString(data.selectedQuest, (130 - fontRendererObj.getStringWidth(data.selectedQuest)) / 2, 4, CustomNpcResourceListener.DefaultTextColor); GL11.glPopMatrix(); - drawHorizontalLine(guiLeft + 142, guiLeft + 312, guiTop + 17, + 0xFF000000 + CustomNpcResourceListener.DefaultTextColor); + drawHorizontalLine(guiLeft + 142, guiLeft + 312, guiTop + 17, +0xFF000000 + CustomNpcResourceListener.DefaultTextColor); } - private void drawQuestText(){ - TextBlockClient block = new TextBlockClient(data.getQuestText(), 174, true, player); + private void drawQuestText() { + TextBlockClient block = new TextBlockClient(data.getQuestText(), 174, true, player); int yoffset = guiTop + 5; - for(int i = 0; i < block.lines.size(); i++){ - String text = block.lines.get(i).getFormattedText(); - fontRendererObj.drawString(text, guiLeft + 142, guiTop + 20 + (i * fontRendererObj.FONT_HEIGHT), CustomNpcResourceListener.DefaultTextColor); - } + for (int i = 0; i < block.lines.size(); i++) { + String text = block.lines.get(i).getFormattedText(); + fontRendererObj.drawString(text, guiLeft + 142, guiTop + 20 + (i * fontRendererObj.FONT_HEIGHT), CustomNpcResourceListener.DefaultTextColor); + } } private void drawProgress() { String complete = data.getComplete(); - if(complete != null && !complete.isEmpty()) - fontRendererObj.drawString(StatCollector.translateToLocalFormatted("quest.completewith", complete), guiLeft + 144, guiTop + 105, CustomNpcResourceListener.DefaultTextColor); + if (complete != null && !complete.isEmpty()) + fontRendererObj.drawString(StatCollector.translateToLocalFormatted("quest.completewith", complete), guiLeft + 144, guiTop + 105, CustomNpcResourceListener.DefaultTextColor); - int yoffset = guiTop + 22; - for(String process : data.getQuestStatus()){ - int index = process.lastIndexOf(":"); - if(index > 0){ - String name = process.substring(0, index); - String trans = StatCollector.translateToLocal(name); - if(!trans.equals(name)) - name = trans; - trans = StatCollector.translateToLocal("entity." + name + ".name"); - if(!trans.equals("entity." + name + ".name")){ - name = trans; - } - process = name + process.substring(index); - } - fontRendererObj.drawString("- " + process, guiLeft + 144, yoffset , CustomNpcResourceListener.DefaultTextColor); - yoffset += 10; - } - } - - private void drawPartyOptions() { int yoffset = guiTop + 22; - for(String process : data.getPartyOptions()){ - List parts = Arrays.asList(process.split(":")); - String drawString = StatCollector.translateToLocal(parts.get(0)) + ": " + StatCollector.translateToLocal(parts.get(1)); - fontRendererObj.drawString("- " + drawString, guiLeft + 144, yoffset , CustomNpcResourceListener.DefaultTextColor); + for (String process : data.getQuestStatus()) { + int index = process.lastIndexOf(":"); + if (index > 0) { + String name = process.substring(0, index); + String trans = StatCollector.translateToLocal(name); + if (!trans.equals(name)) + name = trans; + trans = StatCollector.translateToLocal("entity." + name + ".name"); + if (!trans.equals("entity." + name + ".name")) { + name = trans; + } + process = name + process.substring(index); + } + fontRendererObj.drawString("- " + process, guiLeft + 144, yoffset, CustomNpcResourceListener.DefaultTextColor); yoffset += 10; } } - protected void drawGuiContainerBackgroundLayer(float f, int i, int j) - { + private void drawPartyOptions() { + int yoffset = guiTop + 22; + for (String process : data.getPartyOptions()) { + List parts = Arrays.asList(process.split(":")); + String drawString = StatCollector.translateToLocal(parts.get(0)) + ": " + StatCollector.translateToLocal(parts.get(1)); + fontRendererObj.drawString("- " + drawString, guiLeft + 144, yoffset, CustomNpcResourceListener.DefaultTextColor); + yoffset += 10; + } } + + protected void drawGuiContainerBackgroundLayer(float f, int i, int j) { + } + @Override - public void mouseClicked(int i, int j, int k) - { - super.mouseClicked(i, j, k); - if (k == 0){ - if(scroll != null) - scroll.mouseClicked(i, j, k); - for (GuiMenuSideButton button : new ArrayList(sideButtons.values())){ - if (button.mousePressed(mc, i, j)){ - sideButtonPressed(button); + public void mouseClicked(int i, int j, int k) { + super.mouseClicked(i, j, k); + if (k == 0) { + if (scroll != null) + scroll.mouseClicked(i, j, k); + for (GuiMenuSideButton button : new ArrayList(sideButtons.values())) { + if (button.mousePressed(mc, i, j)) { + sideButtonPressed(button); } } } } + private void sideButtonPressed(GuiMenuSideButton button) { - if(button.active) - return; - NoppesUtil.clickSound(); + if (button.active) + return; + NoppesUtil.clickSound(); data.selectedCategory = button.displayString; data.selectedQuest = ""; - if(scroll != null) + if (scroll != null) scroll.selected = -1; this.initGui(); } - @Override - public void customScrollClicked(int i, int j, int k, GuiCustomScroll scroll) { - if(!scroll.hasSelected()) - return; - data.selectedQuest = scroll.getSelected(); - initGui(); - } @Override - public void keyTyped(char c, int i) - { + public void customScrollClicked(int i, int j, int k, GuiCustomScroll scroll) { + if (!scroll.hasSelected()) + return; + data.selectedQuest = scroll.getSelected(); + initGui(); + } + + @Override + public void keyTyped(char c, int i) { if (i == 1 || i == mc.gameSettings.keyBindInventory.getKeyCode()) // inventory key { mc.displayGuiScreen(null); @@ -376,15 +374,15 @@ public class GuiQuestLog extends GuiCNPCInventory implements ICustomScrollListen } } - @Override - public void setGuiData(NBTTagCompound compound) { + @Override + public void setGuiData(NBTTagCompound compound) { QuestLogData data = new QuestLogData(); data.readNBT(compound); this.data = data; this.questAlertsOnOpen = new HashMap<>(data.questAlerts); this.trackedQuestKeyOnOpen = data.trackedQuestKey; initGui(); - } + } @Override public void setPartyData(NBTTagCompound compound) { @@ -403,15 +401,15 @@ public class GuiQuestLog extends GuiCNPCInventory implements ICustomScrollListen } @Override - public void save() { + public void save() { if (this.data != null && - (!Objects.equals(this.questAlertsOnOpen, data.questAlerts) || + (!Objects.equals(this.questAlertsOnOpen, data.questAlerts) || !Objects.equals(this.trackedQuestKeyOnOpen, data.trackedQuestKey))) { NBTTagCompound compound = new NBTTagCompound(); compound.setTag("Alerts", NBTTags.nbtStringStringMap(data.questAlerts)); PacketClient.sendClient(new QuestLogToServerPacket(compound, this.data.trackedQuestKey)); } - } + } public boolean isMouseInScrollZone(int x, int y) { diff --git a/src/main/java/noppes/npcs/client/gui/player/inventory/GuiSettings.java b/src/main/java/noppes/npcs/client/gui/player/inventory/GuiSettings.java index 23636b87c..088d73d87 100644 --- a/src/main/java/noppes/npcs/client/gui/player/inventory/GuiSettings.java +++ b/src/main/java/noppes/npcs/client/gui/player/inventory/GuiSettings.java @@ -14,40 +14,38 @@ import noppes.npcs.client.gui.util.GuiNpcLabel; import noppes.npcs.client.gui.util.GuiNpcTextField; import noppes.npcs.client.gui.util.ITextfieldListener; import noppes.npcs.config.ConfigClient; -import noppes.npcs.config.ConfigMain; import org.lwjgl.opengl.GL11; import tconstruct.client.tabs.AbstractTab; public class GuiSettings extends GuiCNPCInventory implements ITextfieldListener, GuiYesNoCallback { - private final ResourceLocation resource = new ResourceLocation("customnpcs","textures/gui/standardbg.png"); + private final ResourceLocation resource = new ResourceLocation("customnpcs", "textures/gui/standardbg.png"); - public GuiSettings() { - super(); - xSize = 280; - ySize = 180; + public GuiSettings() { + super(); + xSize = 280; + ySize = 180; this.drawDefaultBackground = false; title = ""; - } + } - @Override - public void initGui() - { - super.initGui(); + @Override + public void initGui() { + super.initGui(); int y = 0; this.addLabel(new GuiNpcLabel(1, "settings.chatBubbles", guiLeft + 8, guiTop + 14 + y)); - this.addButton(new GuiNpcButton(1, guiLeft + 105, guiTop + 9 + y, 50, 20, new String[]{"gui.no", "gui.yes"}, ConfigClient.EnableChatBubbles?1:0)); + this.addButton(new GuiNpcButton(1, guiLeft + 105, guiTop + 9 + y, 50, 20, new String[]{"gui.no", "gui.yes"}, ConfigClient.EnableChatBubbles ? 1 : 0)); - this.addLabel(new GuiNpcLabel(90,"settings.hud", guiLeft + 8 + 155, guiTop + 14 + y)); + this.addLabel(new GuiNpcLabel(90, "settings.hud", guiLeft + 8 + 155, guiTop + 14 + y)); this.addButton(new GuiNpcButton(90, guiLeft + 107 + 160, guiTop + 9 + y, 45, 20, "gui.edit")); y += 22; this.addLabel(new GuiNpcLabel(2, "settings.dialogSound", guiLeft + 8, guiTop + 14 + y)); - this.addButton(new GuiNpcButton(2, guiLeft + 105, guiTop + 9 + y, 50, 20, new String[]{"gui.no", "gui.yes"}, ConfigClient.DialogSound?1:0)); + this.addButton(new GuiNpcButton(2, guiLeft + 105, guiTop + 9 + y, 50, 20, new String[]{"gui.no", "gui.yes"}, ConfigClient.DialogSound ? 1 : 0)); y += 22; - this.addLabel(new GuiNpcLabel(10,"settings.dialogSpeed", guiLeft + 8, guiTop + 14 + y)); + this.addLabel(new GuiNpcLabel(10, "settings.dialogSpeed", guiLeft + 8, guiTop + 14 + y)); this.addTextField(new GuiNpcTextField(10, this, this.fontRendererObj, guiLeft + 107, guiTop + 9 + y, 45, 20, ConfigClient.DialogSpeed + "")); getTextField(10).integersOnly = true; getTextField(10).setMinMaxDefault(1, 20, 10); @@ -56,17 +54,17 @@ public class GuiSettings extends GuiCNPCInventory implements ITextfieldListener, y += 22; this.addLabel(new GuiNpcLabel(6, "settings.chatAlerts", guiLeft + 8, guiTop + 14 + y)); - this.addButton(new GuiNpcButton(6, guiLeft + 105, guiTop + 9 + y, 50, 20, new String[]{"gui.no", "gui.yes"}, ConfigClient.ChatAlerts?1:0)); + this.addButton(new GuiNpcButton(6, guiLeft + 105, guiTop + 9 + y, 50, 20, new String[]{"gui.no", "gui.yes"}, ConfigClient.ChatAlerts ? 1 : 0)); y += 22; this.addLabel(new GuiNpcLabel(7, "settings.bannerAlerts", guiLeft + 8, guiTop + 14 + y)); - this.addButton(new GuiNpcButton(7, guiLeft + 105, guiTop + 9 + y, 50, 20, new String[]{"gui.no", "gui.yes"}, ConfigClient.BannerAlerts?1:0)); + this.addButton(new GuiNpcButton(7, guiLeft + 105, guiTop + 9 + y, 50, 20, new String[]{"gui.no", "gui.yes"}, ConfigClient.BannerAlerts ? 1 : 0)); y += 22; this.addLabel(new GuiNpcLabel(8, "settings.effectsBar", guiLeft + 8, guiTop + 14 + y)); - this.addButton(new GuiNpcButton(8, guiLeft + 105, guiTop + 9 + y, 50, 20, new String[]{"gui.no", "gui.yes"}, ConfigClient.HideEffectsBar?1:0)); + this.addButton(new GuiNpcButton(8, guiLeft + 105, guiTop + 9 + y, 50, 20, new String[]{"gui.no", "gui.yes"}, ConfigClient.HideEffectsBar ? 1 : 0)); y += 22; @@ -75,14 +73,13 @@ public class GuiSettings extends GuiCNPCInventory implements ITextfieldListener, this.addButton(new GuiNpcButton(4, guiLeft + 8 + 155, guiTop + 9 + y, 150, 20, "settings.clearTrack")); } - @Override - public void drawScreen(int i, int j, float f) - { - drawDefaultBackground(); + @Override + public void drawScreen(int i, int j, float f) { + drawDefaultBackground(); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - mc.renderEngine.bindTexture(resource); - drawTexturedModalRect(guiLeft, guiTop, 0, 0, 252, 195); - drawTexturedModalRect(guiLeft + 252, guiTop, 188, 0, 67, 195); + mc.renderEngine.bindTexture(resource); + drawTexturedModalRect(guiLeft, guiTop, 0, 0, 252, 195); + drawTexturedModalRect(guiLeft + 252, guiTop, 188, 0, 67, 195); super.drawScreen(i, j, f); } @@ -106,46 +103,46 @@ public class GuiSettings extends GuiCNPCInventory implements ITextfieldListener, } @Override - protected void actionPerformed(GuiButton btn){ - if(btn instanceof AbstractTab) + protected void actionPerformed(GuiButton btn) { + if (btn instanceof AbstractTab) return; if (btn.id <= -100) { super.actionPerformed(btn); return; } - if(!(btn instanceof GuiNpcButton)) + if (!(btn instanceof GuiNpcButton)) return; GuiNpcButton button = (GuiNpcButton) btn; - if(button.id == 1){ + if (button.id == 1) { ConfigClient.EnableChatBubbles = button.getValue() == 1; ConfigClient.EnableChatBubblesProperty.set(ConfigClient.EnableChatBubbles); } - if(button.id == 2){ + if (button.id == 2) { ConfigClient.DialogSound = button.getValue() == 1; ConfigClient.DialogSoundProperty.set(ConfigClient.DialogSound); } - if(button.id == 4){ + if (button.id == 4) { GuiYesNo yesNoTrack = new GuiYesNo(this, "Confirm", StatCollector.translateToLocal("settings.confirmClearTrack"), 0); displayGuiScreen(yesNoTrack); } - if(button.id == 5){ + if (button.id == 5) { GuiYesNo yesNoSkin = new GuiYesNo(this, "Confirm", StatCollector.translateToLocal("settings.confirmClearSkin"), 1); displayGuiScreen(yesNoSkin); } - if(button.id == 6){ + if (button.id == 6) { ConfigClient.ChatAlerts = button.getValue() == 1; ConfigClient.ChatAlertsProperty.set(ConfigClient.ChatAlerts); } - if(button.id == 7){ + if (button.id == 7) { ConfigClient.BannerAlerts = button.getValue() == 1; ConfigClient.BannerAlertsProperty.set(ConfigClient.BannerAlerts); } - if(button.id == 8){ + if (button.id == 8) { ConfigClient.HideEffectsBar = button.getValue() == 1; ConfigClient.HideEffectsBarProperty.set(ConfigClient.HideEffectsBar); } - if(button.id == 90){ + if (button.id == 90) { mc.displayGuiScreen(new GuiHudEditor(this)); } @@ -154,22 +151,21 @@ public class GuiSettings extends GuiCNPCInventory implements ITextfieldListener, @Override - public void keyTyped(char c, int i) - { + public void keyTyped(char c, int i) { super.keyTyped(c, i); - if (i == 1 || isInventoryKey(i)) - { + if (i == 1 || isInventoryKey(i)) { close(); } } - @Override - public void save() {} + @Override + public void save() { + } @Override public void unFocused(GuiNpcTextField textfield) { - if(textfield.id == 10){ + if (textfield.id == 10) { ConfigClient.DialogSpeed = textfield.getInteger(); ConfigClient.DialogSpeedProperty.set(ConfigClient.DialogSound); } diff --git a/src/main/java/noppes/npcs/client/gui/questtypes/GuiNpcQuestTypeDialog.java b/src/main/java/noppes/npcs/client/gui/questtypes/GuiNpcQuestTypeDialog.java index 3aa5d0fea..1c8f2dcb9 100644 --- a/src/main/java/noppes/npcs/client/gui/questtypes/GuiNpcQuestTypeDialog.java +++ b/src/main/java/noppes/npcs/client/gui/questtypes/GuiNpcQuestTypeDialog.java @@ -16,90 +16,90 @@ import noppes.npcs.quests.QuestDialog; import java.util.HashMap; -public class GuiNpcQuestTypeDialog extends SubGuiInterface implements GuiSelectionListener, IGuiData -{ - private GuiScreen parent; - private QuestDialog quest; +public class GuiNpcQuestTypeDialog extends SubGuiInterface implements GuiSelectionListener, IGuiData { + private GuiScreen parent; + private QuestDialog quest; - private HashMap data = new HashMap(); + private HashMap data = new HashMap(); public GuiNpcQuestTypeDialog(EntityNPCInterface npc, Quest q, GuiScreen parent) { - this.npc = npc; - this.parent = parent; - title = "Quest Dialog Setup"; + this.npc = npc; + this.parent = parent; + title = "Quest Dialog Setup"; - quest = (QuestDialog) q.questInterface; + quest = (QuestDialog) q.questInterface; - setBackground("menubg.png"); - xSize = 256; - ySize = 216; - closeOnEsc = true; + setBackground("menubg.png"); + xSize = 256; + ySize = 216; + closeOnEsc = true; PacketClient.sendClient(new QuestDialogGetTitlePacket( - quest.dialogs.getOrDefault(0, -1), - quest.dialogs.getOrDefault(1, -1), - quest.dialogs.getOrDefault(2, -1)) + quest.dialogs.getOrDefault(0, -1), + quest.dialogs.getOrDefault(1, -1), + quest.dialogs.getOrDefault(2, -1)) ); - } + } - public void initGui() { - super.initGui(); - for (int i = 0; i < 3; i++) { - String title = "dialog.selectoption"; - if(data.containsKey(i)) - title = data.get(i); - this.addButton(new GuiNpcButton(i + 9, guiLeft + 10, guiTop + 55 + i * 22, 20, 20, "X")); - this.addButton(new GuiNpcButton(i + 3, guiLeft + 34, guiTop + 55 + i * 22, 210, 20, title)); + public void initGui() { + super.initGui(); + for (int i = 0; i < 3; i++) { + String title = "dialog.selectoption"; + if (data.containsKey(i)) + title = data.get(i); + this.addButton(new GuiNpcButton(i + 9, guiLeft + 10, guiTop + 55 + i * 22, 20, 20, "X")); + this.addButton(new GuiNpcButton(i + 3, guiLeft + 34, guiTop + 55 + i * 22, 210, 20, title)); - } - this.addButton(new GuiNpcButton(0, guiLeft + 150, guiTop + 190, 98, 20, "gui.back")); + } + this.addButton(new GuiNpcButton(0, guiLeft + 150, guiTop + 190, 98, 20, "gui.back")); - } + } - private int selectedSlot; - protected void actionPerformed(GuiButton guibutton) { - GuiNpcButton button = (GuiNpcButton) guibutton; - if (button.id == 0) { - close(); - } - if (button.id >= 3 && button.id < 9) { - selectedSlot = button.id - 3; - int id = -1; - if(quest.dialogs.containsKey(selectedSlot)) - id = quest.dialogs.get(selectedSlot); + private int selectedSlot; + + protected void actionPerformed(GuiButton guibutton) { + GuiNpcButton button = (GuiNpcButton) guibutton; + if (button.id == 0) { + close(); + } + if (button.id >= 3 && button.id < 9) { + selectedSlot = button.id - 3; + int id = -1; + if (quest.dialogs.containsKey(selectedSlot)) + id = quest.dialogs.get(selectedSlot); setSubGui(new GuiDialogSelection(id)); - } - if (button.id >= 9 && button.id < 15) { - int slot = button.id - 9; - quest.dialogs.remove(slot); - data.remove(slot); - save(); - initGui(); - } - } + } + if (button.id >= 9 && button.id < 15) { + int slot = button.id - 9; + quest.dialogs.remove(slot); + data.remove(slot); + save(); + initGui(); + } + } - public void save() { - } + public void save() { + } - @Override - public void selected(int id, String name) { - quest.dialogs.put(selectedSlot, id); - data.put(selectedSlot, name); - } + @Override + public void selected(int id, String name) { + quest.dialogs.put(selectedSlot, id); + data.put(selectedSlot, name); + } - @Override - public void setGuiData(NBTTagCompound compound) { - data.clear(); - if(compound.hasKey("1")){ - data.put(0, compound.getString("1")); - } - if(compound.hasKey("2")){ - data.put(1, compound.getString("2")); - } - if(compound.hasKey("3")){ - data.put(2, compound.getString("3")); - } - initGui(); - } + @Override + public void setGuiData(NBTTagCompound compound) { + data.clear(); + if (compound.hasKey("1")) { + data.put(0, compound.getString("1")); + } + if (compound.hasKey("2")) { + data.put(1, compound.getString("2")); + } + if (compound.hasKey("3")) { + data.put(2, compound.getString("3")); + } + initGui(); + } } diff --git a/src/main/java/noppes/npcs/client/gui/questtypes/GuiNpcQuestTypeItem.java b/src/main/java/noppes/npcs/client/gui/questtypes/GuiNpcQuestTypeItem.java index b1da79ffa..d57f6f12d 100644 --- a/src/main/java/noppes/npcs/client/gui/questtypes/GuiNpcQuestTypeItem.java +++ b/src/main/java/noppes/npcs/client/gui/questtypes/GuiNpcQuestTypeItem.java @@ -11,63 +11,62 @@ import noppes.npcs.entity.EntityNPCInterface; import noppes.npcs.quests.QuestItem; import org.lwjgl.opengl.GL11; -public class GuiNpcQuestTypeItem extends GuiContainerNPCInterface implements ITextfieldListener -{ - private Quest quest; - private static final ResourceLocation field_110422_t = new ResourceLocation("customnpcs","textures/gui/followersetup.png"); - public GuiNpcQuestTypeItem(EntityNPCInterface npc,ContainerNpcQuestTypeItem container){ - super(npc,container); +public class GuiNpcQuestTypeItem extends GuiContainerNPCInterface implements ITextfieldListener { + private Quest quest; + private static final ResourceLocation field_110422_t = new ResourceLocation("customnpcs", "textures/gui/followersetup.png"); + + public GuiNpcQuestTypeItem(EntityNPCInterface npc, ContainerNpcQuestTypeItem container) { + super(npc, container); this.quest = GuiNPCManageQuest.quest; title = ""; ySize = 202; closeOnEsc = false; } - + @Override - public void initGui(){ + public void initGui() { super.initGui(); addLabel(new GuiNpcLabel(0, "quest.takeitems", guiLeft + 4, guiTop + 8)); - addButton(new GuiNpcButton(0, guiLeft + 90, guiTop + 3, 60, 20, new String[]{ "gui.yes","gui.no"}, ((QuestItem)quest.questInterface).leaveItems?1:0)); + addButton(new GuiNpcButton(0, guiLeft + 90, guiTop + 3, 60, 20, new String[]{"gui.yes", "gui.no"}, ((QuestItem) quest.questInterface).leaveItems ? 1 : 0)); addLabel(new GuiNpcLabel(1, "gui.ignoreDamage", guiLeft + 4, guiTop + 29)); - addButton(new GuiNpcButtonYesNo(1, guiLeft + 90, guiTop + 24, 50, 20, ((QuestItem)quest.questInterface).ignoreDamage)); + addButton(new GuiNpcButtonYesNo(1, guiLeft + 90, guiTop + 24, 50, 20, ((QuestItem) quest.questInterface).ignoreDamage)); addLabel(new GuiNpcLabel(2, "gui.ignoreNBT", guiLeft + 62, guiTop + 51)); - addButton(new GuiNpcButtonYesNo(2, guiLeft + 120, guiTop + 46, 50, 20, ((QuestItem)quest.questInterface).ignoreNBT)); - + addButton(new GuiNpcButtonYesNo(2, guiLeft + 120, guiTop + 46, 50, 20, ((QuestItem) quest.questInterface).ignoreNBT)); + addButton(new GuiNpcButton(5, guiLeft, guiTop + ySize, 98, 20, "gui.back")); } @Override - public void actionPerformed(GuiButton guibutton){ - if(guibutton.id == 0){ - ((QuestItem)quest.questInterface).leaveItems = ((GuiNpcButton)guibutton).getValue() == 1; + public void actionPerformed(GuiButton guibutton) { + if (guibutton.id == 0) { + ((QuestItem) quest.questInterface).leaveItems = ((GuiNpcButton) guibutton).getValue() == 1; } - if(guibutton.id == 1){ - ((QuestItem)quest.questInterface).ignoreDamage = ((GuiNpcButtonYesNo)guibutton).getBoolean(); + if (guibutton.id == 1) { + ((QuestItem) quest.questInterface).ignoreDamage = ((GuiNpcButtonYesNo) guibutton).getBoolean(); } - if(guibutton.id == 2){ - ((QuestItem)quest.questInterface).ignoreNBT = ((GuiNpcButtonYesNo)guibutton).getBoolean(); + if (guibutton.id == 2) { + ((QuestItem) quest.questInterface).ignoreNBT = ((GuiNpcButtonYesNo) guibutton).getBoolean(); } - if(guibutton.id == 5){ - NoppesUtil.openGUI(player,GuiNPCManageQuest.Instance); + if (guibutton.id == 5) { + NoppesUtil.openGUI(player, GuiNPCManageQuest.Instance); } } @Override - protected void drawGuiContainerBackgroundLayer(float f, int i, int j) - { + protected void drawGuiContainerBackgroundLayer(float f, int i, int j) { this.drawWorldBackground(0); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); mc.renderEngine.bindTexture(field_110422_t); int l = (width - xSize) / 2; int i1 = (height - ySize) / 2; drawTexturedModalRect(l, i1, 0, 0, xSize, ySize); - super.drawGuiContainerBackgroundLayer(f, i, j); + super.drawGuiContainerBackgroundLayer(f, i, j); } - - @Override - public void save() { + + @Override + public void save() { // HashMap map = new HashMap(); // for(int i= 0;i < container.invMatrix.getSizeInventory();i++){ // ItemStack item = container.invMatrix.getStackInSlot(i); @@ -76,9 +75,10 @@ public class GuiNpcQuestTypeItem extends GuiContainerNPCInterface implements ITe // } // ((QuestItem)quest.questInterface).items = map; // QuestController.saveQuest(quest); - } - @Override - public void unFocused(GuiNpcTextField textfield) { - quest.rewardExp = textfield.getInteger(); - } + } + + @Override + public void unFocused(GuiNpcTextField textfield) { + quest.rewardExp = textfield.getInteger(); + } } diff --git a/src/main/java/noppes/npcs/client/gui/questtypes/GuiNpcQuestTypeKill.java b/src/main/java/noppes/npcs/client/gui/questtypes/GuiNpcQuestTypeKill.java index c1e8381ad..bf4829130 100644 --- a/src/main/java/noppes/npcs/client/gui/questtypes/GuiNpcQuestTypeKill.java +++ b/src/main/java/noppes/npcs/client/gui/questtypes/GuiNpcQuestTypeKill.java @@ -15,128 +15,130 @@ import java.util.ArrayList; import java.util.Map; import java.util.TreeMap; -public class GuiNpcQuestTypeKill extends SubGuiInterface implements ITextfieldListener, ICustomScrollListener -{ - private GuiScreen parent; - private GuiCustomScroll scroll; +public class GuiNpcQuestTypeKill extends SubGuiInterface implements ITextfieldListener, ICustomScrollListener { + private GuiScreen parent; + private GuiCustomScroll scroll; - private QuestKill quest; + private QuestKill quest; - private GuiNpcTextField lastSelected; + private GuiNpcTextField lastSelected; - public GuiNpcQuestTypeKill(EntityNPCInterface npc, Quest q, GuiScreen parent) { - this.npc = npc; - this.parent = parent; - title = "Quest Kill Setup"; + public GuiNpcQuestTypeKill(EntityNPCInterface npc, Quest q, GuiScreen parent) { + this.npc = npc; + this.parent = parent; + title = "Quest Kill Setup"; - quest = (QuestKill) q.questInterface; + quest = (QuestKill) q.questInterface; - setBackground("largebg.png"); - bgScale = 1.7F; - bgScaleX = 1.1F; + setBackground("largebg.png"); + bgScale = 1.7F; + bgScaleX = 1.1F; - xSize = 300; - ySize = 300; - closeOnEsc = true; - } + xSize = 300; + ySize = 300; + closeOnEsc = true; + } - public void initGui() { - super.initGui(); + public void initGui() { + super.initGui(); - guiTop -= 20; + guiTop -= 20; - int i = 0; - addLabel(new GuiNpcLabel(0, "You can fill in npc or player names too", guiLeft + 4, guiTop + 20)); - for (String name : quest.targets.keySet()) { - this.addTextField(new GuiNpcTextField(i, this, fontRendererObj, guiLeft + 4, guiTop + 40 + i * 22, 180, 20, name)); - this.addTextField(new GuiNpcTextField(i + 12, this, fontRendererObj, guiLeft + 186, guiTop + 40 + i * 22, 24, 20, quest.targets.get(name) + "")); - this.getTextField(i+12).integersOnly = true; - this.getTextField(i+12).setMinMaxDefault(1, Integer.MAX_VALUE, 1); - i++; - } - - for(;i < 12; i++){ - this.addTextField(new GuiNpcTextField(i, this, fontRendererObj, guiLeft + 4, guiTop + 40 + i * 22, 180, 20, "")); - this.addTextField(new GuiNpcTextField(i + 12, this, fontRendererObj, guiLeft + 186, guiTop + 40 + i * 22, 24, 20, "1")); - this.getTextField(i+12).integersOnly = true; - this.getTextField(i+12).setMinMaxDefault(1, Integer.MAX_VALUE, 1); - } - Map data = EntityList.stringToClassMapping; - ArrayList list = new ArrayList(); - for(Object name : data.keySet()){ - Class c = (Class) data.get(name); - try { - if(EntityLivingBase.class.isAssignableFrom(c) && !EntityNPCInterface.class.isAssignableFrom(c) && c.getConstructor(new Class[] {World.class}) != null && !Modifier.isAbstract(c.getModifiers())) - list.add(name.toString()); - } catch (SecurityException e) { - e.printStackTrace(); - } catch (NoSuchMethodException e) { - } + int i = 0; + addLabel(new GuiNpcLabel(0, "You can fill in npc or player names too", guiLeft + 4, guiTop + 20)); + for (String name : quest.targets.keySet()) { + this.addTextField(new GuiNpcTextField(i, this, fontRendererObj, guiLeft + 4, guiTop + 40 + i * 22, 180, 20, name)); + this.addTextField(new GuiNpcTextField(i + 12, this, fontRendererObj, guiLeft + 186, guiTop + 40 + i * 22, 24, 20, quest.targets.get(name) + "")); + this.getTextField(i + 12).integersOnly = true; + this.getTextField(i + 12).setMinMaxDefault(1, Integer.MAX_VALUE, 1); + i++; } - if(scroll == null) - scroll = new GuiCustomScroll(this,0); + + for (; i < 12; i++) { + this.addTextField(new GuiNpcTextField(i, this, fontRendererObj, guiLeft + 4, guiTop + 40 + i * 22, 180, 20, "")); + this.addTextField(new GuiNpcTextField(i + 12, this, fontRendererObj, guiLeft + 186, guiTop + 40 + i * 22, 24, 20, "1")); + this.getTextField(i + 12).integersOnly = true; + this.getTextField(i + 12).setMinMaxDefault(1, Integer.MAX_VALUE, 1); + } + Map data = EntityList.stringToClassMapping; + ArrayList list = new ArrayList(); + for (Object name : data.keySet()) { + Class c = (Class) data.get(name); + try { + if (EntityLivingBase.class.isAssignableFrom(c) && !EntityNPCInterface.class.isAssignableFrom(c) && c.getConstructor(new Class[]{World.class}) != null && !Modifier.isAbstract(c.getModifiers())) + list.add(name.toString()); + } catch (SecurityException e) { + e.printStackTrace(); + } catch (NoSuchMethodException e) { + } + } + if (scroll == null) + scroll = new GuiCustomScroll(this, 0); scroll.setList(list); scroll.setSize(130, 198); scroll.guiLeft = guiLeft + 220; scroll.guiTop = guiTop + 40; addScroll(scroll); - guiTop += 50; - this.addButton(new GuiNpcButton(0, guiLeft + 4, guiTop + 310, 98, 20, "gui.back")); - this.addButton(new GuiNpcButton(1, guiLeft + 4, guiTop + 260, 98, 20, new String[]{"Any", "NPCs", "Custom"}, quest.targetType)); + guiTop += 50; + this.addButton(new GuiNpcButton(0, guiLeft + 4, guiTop + 310, 98, 20, "gui.back")); + this.addButton(new GuiNpcButton(1, guiLeft + 4, guiTop + 260, 98, 20, new String[]{"Any", "NPCs", "Custom"}, quest.targetType)); - this.addTextField(new GuiNpcTextField(36, this, fontRendererObj, guiLeft + 4, guiTop + 282, 180, 20, quest.customTargetType)); - this.getTextField(36).setVisible(this.getButton(1).getValue() == 2); + this.addTextField(new GuiNpcTextField(36, this, fontRendererObj, guiLeft + 4, guiTop + 282, 180, 20, quest.customTargetType)); + this.getTextField(36).setVisible(this.getButton(1).getValue() == 2); - guiTop -= 50; + guiTop -= 50; - scroll.visible = GuiNpcTextField.isFieldActive(); - } - - protected void actionPerformed(GuiButton guibutton) { - super.actionPerformed(guibutton); - if (guibutton.id == 0) { - close(); - } - if (guibutton.id == 1) { - quest.targetType = this.getButton(1).getValue(); - this.getTextField(36).setVisible(this.getButton(1).getValue() == 2); - } - } - public void mouseClicked(int i, int j, int k) - { - super.mouseClicked(i, j, k); - scroll.visible = GuiNpcTextField.isFieldActive(); + scroll.visible = GuiNpcTextField.isFieldActive(); } - public void save() { - } - @Override - public void unFocused(GuiNpcTextField guiNpcTextField) { - if(guiNpcTextField.id < 12) - lastSelected = guiNpcTextField; + protected void actionPerformed(GuiButton guibutton) { + super.actionPerformed(guibutton); + if (guibutton.id == 0) { + close(); + } + if (guibutton.id == 1) { + quest.targetType = this.getButton(1).getValue(); + this.getTextField(36).setVisible(this.getButton(1).getValue() == 2); + } + } - if(guiNpcTextField.id == 36) - quest.customTargetType = guiNpcTextField.getText(); + public void mouseClicked(int i, int j, int k) { + super.mouseClicked(i, j, k); + scroll.visible = GuiNpcTextField.isFieldActive(); + } - saveTargets(); - } - private void saveTargets(){ - TreeMap map = new TreeMap(); - for(int i = 0; i< 12; i++){ - String name = getTextField(i).getText(); - if(name.isEmpty()) - continue; - map.put(name, getTextField(i+12).getInteger()); - } - quest.targets = map; - } - @Override - public void customScrollClicked(int i, int j, int k, GuiCustomScroll guiCustomScroll) { - if(lastSelected == null) - return; - lastSelected.setText(guiCustomScroll.getSelected()); - saveTargets(); - } + public void save() { + } + + @Override + public void unFocused(GuiNpcTextField guiNpcTextField) { + if (guiNpcTextField.id < 12) + lastSelected = guiNpcTextField; + + if (guiNpcTextField.id == 36) + quest.customTargetType = guiNpcTextField.getText(); + + saveTargets(); + } + + private void saveTargets() { + TreeMap map = new TreeMap(); + for (int i = 0; i < 12; i++) { + String name = getTextField(i).getText(); + if (name.isEmpty()) + continue; + map.put(name, getTextField(i + 12).getInteger()); + } + quest.targets = map; + } + + @Override + public void customScrollClicked(int i, int j, int k, GuiCustomScroll guiCustomScroll) { + if (lastSelected == null) + return; + lastSelected.setText(guiCustomScroll.getSelected()); + saveTargets(); + } } diff --git a/src/main/java/noppes/npcs/client/gui/questtypes/GuiNpcQuestTypeLocation.java b/src/main/java/noppes/npcs/client/gui/questtypes/GuiNpcQuestTypeLocation.java index 47fb986f4..4afbc1040 100644 --- a/src/main/java/noppes/npcs/client/gui/questtypes/GuiNpcQuestTypeLocation.java +++ b/src/main/java/noppes/npcs/client/gui/questtypes/GuiNpcQuestTypeLocation.java @@ -7,54 +7,53 @@ import noppes.npcs.controllers.data.Quest; import noppes.npcs.entity.EntityNPCInterface; import noppes.npcs.quests.QuestLocation; -public class GuiNpcQuestTypeLocation extends SubGuiInterface implements ITextfieldListener -{ - private GuiScreen parent; - - private QuestLocation quest; +public class GuiNpcQuestTypeLocation extends SubGuiInterface implements ITextfieldListener { + private GuiScreen parent; + + private QuestLocation quest; public GuiNpcQuestTypeLocation(EntityNPCInterface npc, Quest q, - GuiScreen parent) { - this.npc = npc; - this.parent = parent; - title = "Quest Location Setup"; - - quest = (QuestLocation) q.questInterface; + GuiScreen parent) { + this.npc = npc; + this.parent = parent; + title = "Quest Location Setup"; - setBackground("menubg.png"); - xSize = 256; - ySize = 216; - closeOnEsc = true; - } + quest = (QuestLocation) q.questInterface; - public void initGui() { - super.initGui(); + setBackground("menubg.png"); + xSize = 256; + ySize = 216; + closeOnEsc = true; + } - addLabel(new GuiNpcLabel(0, "Fill in the name of your Location Quest Block", guiLeft + 4, guiTop + 50)); - this.addTextField(new GuiNpcTextField(0, this, fontRendererObj, guiLeft + 4, guiTop + 70, 180, 20, quest.location)); - this.addTextField(new GuiNpcTextField(1, this, fontRendererObj, guiLeft + 4, guiTop + 92, 180, 20, quest.location2)); - this.addTextField(new GuiNpcTextField(2, this, fontRendererObj, guiLeft + 4, guiTop + 114, 180, 20, quest.location3)); - this.addButton(new GuiNpcButton(0, guiLeft + 150, guiTop + 190, 98, 20, "gui.back")); - } + public void initGui() { + super.initGui(); - protected void actionPerformed(GuiButton guibutton) { - super.actionPerformed(guibutton); - if (guibutton.id == 0) { - close(); - } - } - - public void save() { - } + addLabel(new GuiNpcLabel(0, "Fill in the name of your Location Quest Block", guiLeft + 4, guiTop + 50)); + this.addTextField(new GuiNpcTextField(0, this, fontRendererObj, guiLeft + 4, guiTop + 70, 180, 20, quest.location)); + this.addTextField(new GuiNpcTextField(1, this, fontRendererObj, guiLeft + 4, guiTop + 92, 180, 20, quest.location2)); + this.addTextField(new GuiNpcTextField(2, this, fontRendererObj, guiLeft + 4, guiTop + 114, 180, 20, quest.location3)); + this.addButton(new GuiNpcButton(0, guiLeft + 150, guiTop + 190, 98, 20, "gui.back")); + } - @Override - public void unFocused(GuiNpcTextField textfield) { - if(textfield.id == 0) - quest.location = textfield.getText(); - if(textfield.id == 1) - quest.location2 = textfield.getText(); - if(textfield.id == 2) - quest.location3 = textfield.getText(); - } + protected void actionPerformed(GuiButton guibutton) { + super.actionPerformed(guibutton); + if (guibutton.id == 0) { + close(); + } + } + + public void save() { + } + + @Override + public void unFocused(GuiNpcTextField textfield) { + if (textfield.id == 0) + quest.location = textfield.getText(); + if (textfield.id == 1) + quest.location2 = textfield.getText(); + if (textfield.id == 2) + quest.location3 = textfield.getText(); + } } diff --git a/src/main/java/noppes/npcs/client/gui/questtypes/GuiNpcQuestTypeManual.java b/src/main/java/noppes/npcs/client/gui/questtypes/GuiNpcQuestTypeManual.java index a05a38c72..4c4730888 100644 --- a/src/main/java/noppes/npcs/client/gui/questtypes/GuiNpcQuestTypeManual.java +++ b/src/main/java/noppes/npcs/client/gui/questtypes/GuiNpcQuestTypeManual.java @@ -9,78 +9,77 @@ import noppes.npcs.quests.QuestManual; import java.util.TreeMap; -public class GuiNpcQuestTypeManual extends SubGuiInterface implements ITextfieldListener -{ - private GuiScreen parent; +public class GuiNpcQuestTypeManual extends SubGuiInterface implements ITextfieldListener { + private GuiScreen parent; - private QuestManual quest; + private QuestManual quest; - private GuiNpcTextField lastSelected; + private GuiNpcTextField lastSelected; public GuiNpcQuestTypeManual(EntityNPCInterface npc, Quest q, GuiScreen parent) { - this.npc = npc; - this.parent = parent; - title = "Quest Manual Setup"; + this.npc = npc; + this.parent = parent; + title = "Quest Manual Setup"; - quest = (QuestManual) q.questInterface; + quest = (QuestManual) q.questInterface; - setBackground("menubg.png"); - xSize = 356; - ySize = 216; - closeOnEsc = true; - } + setBackground("menubg.png"); + xSize = 356; + ySize = 216; + closeOnEsc = true; + } - @Override - public void initGui() { - super.initGui(); - int i = 0; - addLabel(new GuiNpcLabel(0, "You can fill in npc or player names too", guiLeft + 4, guiTop + 50)); - for (String name : quest.manuals.keySet()) { - this.addTextField(new GuiNpcTextField(i, this, fontRendererObj, guiLeft + 4, guiTop + 70 + i * 22, 180, 20, name)); - this.addTextField(new GuiNpcTextField(i + 3, this, fontRendererObj, guiLeft + 186, guiTop + 70 + i * 22, 24, 20, quest.manuals.get(name) + "")); - this.getTextField(i+3).integersOnly = true; - this.getTextField(i+3).setMinMaxDefault(1, Integer.MAX_VALUE, 1); - i++; - } + @Override + public void initGui() { + super.initGui(); + int i = 0; + addLabel(new GuiNpcLabel(0, "You can fill in npc or player names too", guiLeft + 4, guiTop + 50)); + for (String name : quest.manuals.keySet()) { + this.addTextField(new GuiNpcTextField(i, this, fontRendererObj, guiLeft + 4, guiTop + 70 + i * 22, 180, 20, name)); + this.addTextField(new GuiNpcTextField(i + 3, this, fontRendererObj, guiLeft + 186, guiTop + 70 + i * 22, 24, 20, quest.manuals.get(name) + "")); + this.getTextField(i + 3).integersOnly = true; + this.getTextField(i + 3).setMinMaxDefault(1, Integer.MAX_VALUE, 1); + i++; + } - for(;i < 3; i++){ - this.addTextField(new GuiNpcTextField(i, this, fontRendererObj, guiLeft + 4, guiTop + 70 + i * 22, 180, 20, "")); - this.addTextField(new GuiNpcTextField(i + 3, this, fontRendererObj, guiLeft + 186, guiTop + 70 + i * 22, 24, 20, "1")); - this.getTextField(i+3).integersOnly = true; - this.getTextField(i+3).setMinMaxDefault(1, Integer.MAX_VALUE, 1); - } - this.addButton(new GuiNpcButton(0, guiLeft + 4, guiTop + 140, 98, 20, "gui.back")); + for (; i < 3; i++) { + this.addTextField(new GuiNpcTextField(i, this, fontRendererObj, guiLeft + 4, guiTop + 70 + i * 22, 180, 20, "")); + this.addTextField(new GuiNpcTextField(i + 3, this, fontRendererObj, guiLeft + 186, guiTop + 70 + i * 22, 24, 20, "1")); + this.getTextField(i + 3).integersOnly = true; + this.getTextField(i + 3).setMinMaxDefault(1, Integer.MAX_VALUE, 1); + } + this.addButton(new GuiNpcButton(0, guiLeft + 4, guiTop + 140, 98, 20, "gui.back")); - } + } - @Override - protected void actionPerformed(GuiButton guibutton) { - super.actionPerformed(guibutton); - if (guibutton.id == 0) { - close(); - } - } + @Override + protected void actionPerformed(GuiButton guibutton) { + super.actionPerformed(guibutton); + if (guibutton.id == 0) { + close(); + } + } - @Override - public void save() { - } + @Override + public void save() { + } - @Override - public void unFocused(GuiNpcTextField guiNpcTextField) { - if(guiNpcTextField.id < 3) - lastSelected = guiNpcTextField; + @Override + public void unFocused(GuiNpcTextField guiNpcTextField) { + if (guiNpcTextField.id < 3) + lastSelected = guiNpcTextField; - saveTargets(); - } + saveTargets(); + } - private void saveTargets(){ - TreeMap map = new TreeMap(); - for(int i = 0; i< 3; i++){ - String name = getTextField(i).getText(); - if(name.isEmpty()) - continue; - map.put(name, getTextField(i+3).getInteger()); - } - quest.manuals = map; - } + private void saveTargets() { + TreeMap map = new TreeMap(); + for (int i = 0; i < 3; i++) { + String name = getTextField(i).getText(); + if (name.isEmpty()) + continue; + map.put(name, getTextField(i + 3).getInteger()); + } + quest.manuals = map; + } } diff --git a/src/main/java/noppes/npcs/client/gui/roles/GuiNpcBankSetup.java b/src/main/java/noppes/npcs/client/gui/roles/GuiNpcBankSetup.java index 50619dd0f..db909ba52 100644 --- a/src/main/java/noppes/npcs/client/gui/roles/GuiNpcBankSetup.java +++ b/src/main/java/noppes/npcs/client/gui/roles/GuiNpcBankSetup.java @@ -18,70 +18,63 @@ import java.util.HashMap; import java.util.Vector; -public class GuiNpcBankSetup extends GuiNPCInterface2 implements IScrollData,ICustomScrollListener -{ - private GuiCustomScroll scroll; - private HashMap data = new HashMap(); - private RoleBank role; +public class GuiNpcBankSetup extends GuiNPCInterface2 implements IScrollData, ICustomScrollListener { + private GuiCustomScroll scroll; + private HashMap data = new HashMap(); + private RoleBank role; - public GuiNpcBankSetup(EntityNPCInterface npc) - { - super(npc); + public GuiNpcBankSetup(EntityNPCInterface npc) { + super(npc); PacketClient.sendClient(new BanksGetPacket()); - role = (RoleBank) npc.roleInterface; + role = (RoleBank) npc.roleInterface; } - public void initGui() - { + public void initGui() { super.initGui(); - if(scroll == null) - scroll = new GuiCustomScroll(this,0); + if (scroll == null) + scroll = new GuiCustomScroll(this, 0); scroll.setSize(200, 152); scroll.guiLeft = guiLeft + 85; scroll.guiTop = guiTop + 20; addScroll(scroll); } - protected void actionPerformed(GuiButton guibutton) - { + protected void actionPerformed(GuiButton guibutton) { } - @Override - public void setData(Vector list, HashMap data, EnumScrollData type) - { - String name = null; - Bank bank = role.getBank(); - if(bank != null) - name = bank.name; - this.data = data; - scroll.setList(list); + @Override + public void setData(Vector list, HashMap data, EnumScrollData type) { + String name = null; + Bank bank = role.getBank(); + if (bank != null) + name = bank.name; + this.data = data; + scroll.setList(list); - if(name != null) - setSelected(name); - } - - public void mouseClicked(int i, int j, int k) - { - super.mouseClicked(i, j, k); - if(k == 0 && scroll != null) - scroll.mouseClicked(i, j, k); + if (name != null) + setSelected(name); } - @Override - public void setSelected(String selected) { - scroll.setSelected(selected); - } + public void mouseClicked(int i, int j, int k) { + super.mouseClicked(i, j, k); + if (k == 0 && scroll != null) + scroll.mouseClicked(i, j, k); + } - @Override - public void customScrollClicked(int i, int j, int k, GuiCustomScroll guiCustomScroll) { - if(guiCustomScroll.id == 0) - { - role.bankId = data.get(scroll.getSelected()); - save(); - } - } + @Override + public void setSelected(String selected) { + scroll.setSelected(selected); + } - public void save() { + @Override + public void customScrollClicked(int i, int j, int k, GuiCustomScroll guiCustomScroll) { + if (guiCustomScroll.id == 0) { + role.bankId = data.get(scroll.getSelected()); + save(); + } + } + + public void save() { PacketClient.sendClient(new RoleSavePacket(role.writeToNBT(new NBTTagCompound()))); - } + } } diff --git a/src/main/java/noppes/npcs/client/gui/roles/GuiNpcBard.java b/src/main/java/noppes/npcs/client/gui/roles/GuiNpcBard.java index 37317a08f..1a44021cc 100644 --- a/src/main/java/noppes/npcs/client/gui/roles/GuiNpcBard.java +++ b/src/main/java/noppes/npcs/client/gui/roles/GuiNpcBard.java @@ -8,88 +8,79 @@ import noppes.npcs.client.gui.util.*; import noppes.npcs.entity.EntityNPCInterface; import noppes.npcs.roles.JobBard; -public class GuiNpcBard extends GuiNPCInterface2 implements ISubGuiListener -{ - private JobBard job; +public class GuiNpcBard extends GuiNPCInterface2 implements ISubGuiListener { + private JobBard job; - public GuiNpcBard(EntityNPCInterface npc) - { - super(npc); - job = (JobBard) npc.jobInterface; + public GuiNpcBard(EntityNPCInterface npc) { + super(npc); + job = (JobBard) npc.jobInterface; } - public void initGui() - { - super.initGui(); + public void initGui() { + super.initGui(); - this.addButton(new GuiNpcButton(1, guiLeft + 55, guiTop + 15,20,20, "X")); - addLabel(new GuiNpcLabel(0,job.song, guiLeft + 80, guiTop + 20)); - this.addButton(new GuiNpcButton(0, guiLeft + 75, guiTop + 50, "gui.selectSound")); + this.addButton(new GuiNpcButton(1, guiLeft + 55, guiTop + 15, 20, 20, "X")); + addLabel(new GuiNpcLabel(0, job.song, guiLeft + 80, guiTop + 20)); + this.addButton(new GuiNpcButton(0, guiLeft + 75, guiTop + 50, "gui.selectSound")); - this.addButton(new GuiNpcButton(2, guiLeft + 75, guiTop + 71, new String[]{"gui.none","item.npcBanjo.name","item.npcViolin.name","item.npcGuitar.name","item.npcHarp.name","item.npcFrenchHorn.name"}, job.getInstrument().ordinal())); - this.addButton(new GuiNpcButton(3, guiLeft + 75, guiTop + 92, new String[]{"bard.jukebox","bard.background"}, job.isStreamer?0:1)); + this.addButton(new GuiNpcButton(2, guiLeft + 75, guiTop + 71, new String[]{"gui.none", "item.npcBanjo.name", "item.npcViolin.name", "item.npcGuitar.name", "item.npcHarp.name", "item.npcFrenchHorn.name"}, job.getInstrument().ordinal())); + this.addButton(new GuiNpcButton(3, guiLeft + 75, guiTop + 92, new String[]{"bard.jukebox", "bard.background"}, job.isStreamer ? 0 : 1)); - addLabel(new GuiNpcLabel(2,"bard.ondistance", guiLeft + 60, guiTop + 143)); - addTextField(new GuiNpcTextField(2,this, this.fontRendererObj, guiLeft+160, guiTop + 138, 40, 20, job.minRange + "")); + addLabel(new GuiNpcLabel(2, "bard.ondistance", guiLeft + 60, guiTop + 143)); + addTextField(new GuiNpcTextField(2, this, this.fontRendererObj, guiLeft + 160, guiTop + 138, 40, 20, job.minRange + "")); getTextField(2).integersOnly = true; getTextField(2).setMinMaxDefault(2, Integer.MAX_VALUE, 5); - addLabel(new GuiNpcLabel(4,"bard.hasoff", guiLeft + 60, guiTop + 166)); - addButton(new GuiNpcButton(4, guiLeft + 160, guiTop + 161, 60, 20, new String[]{"gui.no","gui.yes"}, job.hasOffRange?1:0)); + addLabel(new GuiNpcLabel(4, "bard.hasoff", guiLeft + 60, guiTop + 166)); + addButton(new GuiNpcButton(4, guiLeft + 160, guiTop + 161, 60, 20, new String[]{"gui.no", "gui.yes"}, job.hasOffRange ? 1 : 0)); - addLabel(new GuiNpcLabel(3,"bard.offdistance", guiLeft + 60, guiTop + 189)); - addTextField(new GuiNpcTextField(3,this, this.fontRendererObj, guiLeft+160, guiTop + 184, 40, 20, job.maxRange + "")); + addLabel(new GuiNpcLabel(3, "bard.offdistance", guiLeft + 60, guiTop + 189)); + addTextField(new GuiNpcTextField(3, this, this.fontRendererObj, guiLeft + 160, guiTop + 184, 40, 20, job.maxRange + "")); getTextField(3).integersOnly = true; getTextField(3).setMinMaxDefault(2, Integer.MAX_VALUE, 10); - getLabel(3).enabled = job.hasOffRange; - getTextField(3).enabled = job.hasOffRange; + getLabel(3).enabled = job.hasOffRange; + getTextField(3).enabled = job.hasOffRange; } - protected void actionPerformed(GuiButton guibutton) - { - GuiNpcButton button = (GuiNpcButton) guibutton; - if(button.id == 0) - { + protected void actionPerformed(GuiButton guibutton) { + GuiNpcButton button = (GuiNpcButton) guibutton; + if (button.id == 0) { setSubGui(new GuiSoundSelection(job.song)); MusicController.Instance.stopMusic(); } - if(button.id == 1) - { - job.song = ""; - getLabel(0).label = ""; - MusicController.Instance.stopMusic(); + if (button.id == 1) { + job.song = ""; + getLabel(0).label = ""; + MusicController.Instance.stopMusic(); } - if(button.id == 2) - { - job.setInstrument(button.getValue()); + if (button.id == 2) { + job.setInstrument(button.getValue()); } - if(button.id == 3) - { - job.isStreamer = button.getValue() == 0; - initGui(); + if (button.id == 3) { + job.isStreamer = button.getValue() == 0; + initGui(); } - if(button.id == 4) - { - job.hasOffRange = button.getValue() == 1; - initGui(); + if (button.id == 4) { + job.hasOffRange = button.getValue() == 1; + initGui(); } } @Override - public void save() { - job.minRange = getTextField(2).getInteger(); - job.maxRange = getTextField(3).getInteger(); + public void save() { + job.minRange = getTextField(2).getInteger(); + job.maxRange = getTextField(3).getInteger(); - if(job.minRange > job.maxRange) - job.maxRange = job.minRange; + if (job.minRange > job.maxRange) + job.maxRange = job.minRange; MusicController.Instance.stopAllSounds(); JobSavePacket.saveJob(job); - } + } @Override public void close() { @@ -100,7 +91,7 @@ public class GuiNpcBard extends GuiNPCInterface2 implements ISubGuiListener @Override public void subGuiClosed(SubGuiInterface subgui) { GuiSoundSelection gss = (GuiSoundSelection) subgui; - if(gss.selectedResource != null) { + if (gss.selectedResource != null) { job.song = gss.selectedResource.toString(); getLabel(0).label = job.song; initGui(); diff --git a/src/main/java/noppes/npcs/client/gui/roles/GuiNpcCompanion.java b/src/main/java/noppes/npcs/client/gui/roles/GuiNpcCompanion.java index f17b3052e..f35532ec3 100644 --- a/src/main/java/noppes/npcs/client/gui/roles/GuiNpcCompanion.java +++ b/src/main/java/noppes/npcs/client/gui/roles/GuiNpcCompanion.java @@ -15,112 +15,113 @@ import noppes.npcs.roles.RoleCompanion; import java.util.ArrayList; import java.util.List; -public class GuiNpcCompanion extends GuiNPCInterface2 implements ITextfieldListener, ISliderListener{ - private RoleCompanion role; - private List talents = new ArrayList(); - public GuiNpcCompanion(EntityNPCInterface npc){ - super(npc); - role = (RoleCompanion) npc.roleInterface; +public class GuiNpcCompanion extends GuiNPCInterface2 implements ITextfieldListener, ISliderListener { + private RoleCompanion role; + private List talents = new ArrayList(); + + public GuiNpcCompanion(EntityNPCInterface npc) { + super(npc); + role = (RoleCompanion) npc.roleInterface; } @Override - public void initGui(){ - super.initGui(); - talents.clear(); - int y = guiTop + 4; + public void initGui() { + super.initGui(); + talents.clear(); + int y = guiTop + 4; - addButton(new GuiNpcButton(0, guiLeft + 70, y, 90, 20, new String[]{EnumCompanionStage.BABY.name, EnumCompanionStage.CHILD.name, EnumCompanionStage.TEEN.name, EnumCompanionStage.ADULT.name, EnumCompanionStage.FULLGROWN.name}, role.stage.ordinal())); - addLabel(new GuiNpcLabel(0, "companion.stage", guiLeft + 4, y + 5)); - addButton(new GuiNpcButton(1, guiLeft + 162, y, 90, 20, "gui.update")); + addButton(new GuiNpcButton(0, guiLeft + 70, y, 90, 20, new String[]{EnumCompanionStage.BABY.name, EnumCompanionStage.CHILD.name, EnumCompanionStage.TEEN.name, EnumCompanionStage.ADULT.name, EnumCompanionStage.FULLGROWN.name}, role.stage.ordinal())); + addLabel(new GuiNpcLabel(0, "companion.stage", guiLeft + 4, y + 5)); + addButton(new GuiNpcButton(1, guiLeft + 162, y, 90, 20, "gui.update")); - addButton(new GuiNpcButton(2, guiLeft + 70, y += 22, 90, 20, new String[]{"gui.no", "gui.yes"}, role.canAge?1:0)); - addLabel(new GuiNpcLabel(2, "companion.age", guiLeft + 4, y + 5)); - if(role.canAge){ - addTextField(new GuiNpcTextField(2, this, guiLeft + 162, y, 140, 20, role.ticksActive + "")); - getTextField(2).integersOnly = true; - getTextField(2).setMinMaxDefault(0, Integer.MAX_VALUE, 0); - } + addButton(new GuiNpcButton(2, guiLeft + 70, y += 22, 90, 20, new String[]{"gui.no", "gui.yes"}, role.canAge ? 1 : 0)); + addLabel(new GuiNpcLabel(2, "companion.age", guiLeft + 4, y + 5)); + if (role.canAge) { + addTextField(new GuiNpcTextField(2, this, guiLeft + 162, y, 140, 20, role.ticksActive + "")); + getTextField(2).integersOnly = true; + getTextField(2).setMinMaxDefault(0, Integer.MAX_VALUE, 0); + } - talents.add(new GuiTalent(role, EnumCompanionTalent.INVENTORY, guiLeft + 4, y+=26)); - addSlider(new GuiNpcSlider(this, 10, guiLeft + 30, y + 2, 100, 20, role.getExp(EnumCompanionTalent.INVENTORY)/5000f)); + talents.add(new GuiTalent(role, EnumCompanionTalent.INVENTORY, guiLeft + 4, y += 26)); + addSlider(new GuiNpcSlider(this, 10, guiLeft + 30, y + 2, 100, 20, role.getExp(EnumCompanionTalent.INVENTORY) / 5000f)); - talents.add(new GuiTalent(role, EnumCompanionTalent.ARMOR, guiLeft + 4, y+=26)); - addSlider(new GuiNpcSlider(this, 11, guiLeft + 30, y + 2, 100, 20, role.getExp(EnumCompanionTalent.ARMOR)/5000f)); + talents.add(new GuiTalent(role, EnumCompanionTalent.ARMOR, guiLeft + 4, y += 26)); + addSlider(new GuiNpcSlider(this, 11, guiLeft + 30, y + 2, 100, 20, role.getExp(EnumCompanionTalent.ARMOR) / 5000f)); - talents.add(new GuiTalent(role, EnumCompanionTalent.SWORD, guiLeft + 4, y+=26)); - addSlider(new GuiNpcSlider(this, 12, guiLeft + 30, y + 2, 100, 20, role.getExp(EnumCompanionTalent.SWORD)/5000f)); + talents.add(new GuiTalent(role, EnumCompanionTalent.SWORD, guiLeft + 4, y += 26)); + addSlider(new GuiNpcSlider(this, 12, guiLeft + 30, y + 2, 100, 20, role.getExp(EnumCompanionTalent.SWORD) / 5000f)); // talents.add(new GuiTalent(role, EnumCompanionTalent.RANGED, guiLeft + 4, y+=26)); // addSlider(new GuiNpcSlider(this, 13, guiLeft + 30, y + 2, 100, 20, role.getExp(EnumCompanionTalent.RANGED)/5000f)); } @Override - public void buttonEvent(GuiButton guibutton){ - if(guibutton.id == 0){ - GuiNpcButton button = (GuiNpcButton) guibutton; - role.matureTo(EnumCompanionStage.values()[button.getValue()]); - if(role.canAge) - role.ticksActive = role.stage.matureAge; - initGui(); - } - if(guibutton.id == 1){ + public void buttonEvent(GuiButton guibutton) { + if (guibutton.id == 0) { + GuiNpcButton button = (GuiNpcButton) guibutton; + role.matureTo(EnumCompanionStage.values()[button.getValue()]); + if (role.canAge) + role.ticksActive = role.stage.matureAge; + initGui(); + } + if (guibutton.id == 1) { PacketClient.sendClient(new RoleCompanionUpdatePacket(role.stage)); - } - if(guibutton.id == 2){ - GuiNpcButton button = (GuiNpcButton) guibutton; - role.canAge = button.getValue() == 1; - initGui(); - } + } + if (guibutton.id == 2) { + GuiNpcButton button = (GuiNpcButton) guibutton; + role.canAge = button.getValue() == 1; + initGui(); + } } - @Override - public void unFocused(GuiNpcTextField textfield) { - if(textfield.id == 2){ - role.ticksActive = textfield.getInteger(); - } - } - @Override - public void drawScreen(int i, int j, float f) { - super.drawScreen(i, j, f); - for(GuiTalent talent : talents){ - talent.drawScreen(i, j, f); - } - } + @Override + public void unFocused(GuiNpcTextField textfield) { + if (textfield.id == 2) { + role.ticksActive = textfield.getInteger(); + } + } @Override - public void elementClicked(){ + public void drawScreen(int i, int j, float f) { + super.drawScreen(i, j, f); + for (GuiTalent talent : talents) { + talent.drawScreen(i, j, f); + } + } + + @Override + public void elementClicked() { } @Override - public void save() { + public void save() { PacketClient.sendClient(new RoleSavePacket(role.writeToNBT(new NBTTagCompound()))); - } + } - @Override - public void mouseDragged(GuiNpcSlider slider) { - if(slider.sliderValue <= 0){ - slider.setString("gui.disabled"); - role.talents.remove(EnumCompanionTalent.values()[slider.id - 10]); - } - else{ - slider.displayString = (int)(slider.sliderValue * 50) * 100 + " exp"; - role.setExp(EnumCompanionTalent.values()[slider.id - 10], (int)(slider.sliderValue * 50) * 100); - } - } + @Override + public void mouseDragged(GuiNpcSlider slider) { + if (slider.sliderValue <= 0) { + slider.setString("gui.disabled"); + role.talents.remove(EnumCompanionTalent.values()[slider.id - 10]); + } else { + slider.displayString = (int) (slider.sliderValue * 50) * 100 + " exp"; + role.setExp(EnumCompanionTalent.values()[slider.id - 10], (int) (slider.sliderValue * 50) * 100); + } + } - @Override - public void mousePressed(GuiNpcSlider slider) { + @Override + public void mousePressed(GuiNpcSlider slider) { - } + } - @Override - public void mouseReleased(GuiNpcSlider slider) { + @Override + public void mouseReleased(GuiNpcSlider slider) { - } + } } diff --git a/src/main/java/noppes/npcs/client/gui/roles/GuiNpcConversation.java b/src/main/java/noppes/npcs/client/gui/roles/GuiNpcConversation.java index 1948c26b0..546125193 100644 --- a/src/main/java/noppes/npcs/client/gui/roles/GuiNpcConversation.java +++ b/src/main/java/noppes/npcs/client/gui/roles/GuiNpcConversation.java @@ -9,124 +9,124 @@ import noppes.npcs.entity.EntityNPCInterface; import noppes.npcs.roles.JobConversation; import noppes.npcs.roles.JobConversation.ConversationLine; -public class GuiNpcConversation extends GuiNPCInterface2 implements ITextfieldListener, GuiSelectionListener -{ - private JobConversation job; +public class GuiNpcConversation extends GuiNPCInterface2 implements ITextfieldListener, GuiSelectionListener { + private JobConversation job; - private int slot = -1; + private int slot = -1; - public GuiNpcConversation(EntityNPCInterface npc){ - super(npc); - job = (JobConversation) npc.jobInterface; + public GuiNpcConversation(EntityNPCInterface npc) { + super(npc); + job = (JobConversation) npc.jobInterface; } - public void initGui(){ - super.initGui(); + public void initGui() { + super.initGui(); - addLabel(new GuiNpcLabel(40, "gui.name", guiLeft + 40, guiTop + 4)); - addLabel(new GuiNpcLabel(41, "gui.name", guiLeft + 240, guiTop + 4)); + addLabel(new GuiNpcLabel(40, "gui.name", guiLeft + 40, guiTop + 4)); + addLabel(new GuiNpcLabel(41, "gui.name", guiLeft + 240, guiTop + 4)); - addLabel(new GuiNpcLabel(42, "conversation.delay", guiLeft + 164, guiTop + 4)); - addLabel(new GuiNpcLabel(43, "conversation.delay", guiLeft + 364, guiTop + 4)); + addLabel(new GuiNpcLabel(42, "conversation.delay", guiLeft + 164, guiTop + 4)); + addLabel(new GuiNpcLabel(43, "conversation.delay", guiLeft + 364, guiTop + 4)); - for (int i = 0; i < 14; i++) { - ConversationLine line = job.getLine(i); - int offset = i >=7 ?200:0; - this.addLabel(new GuiNpcLabel(i, "" + (i + 1), guiLeft + 5 + offset - (i > 8?6:0), guiTop + 18 + i % 7 * 22)); - this.addTextField(new GuiNpcTextField(i, this, this.fontRendererObj, guiLeft + 13 + offset, guiTop + 13 + i % 7 * 22, 100, 20, line.npc)); - this.addButton(new GuiNpcButton(i, guiLeft + 115 + offset, guiTop + 13 + i % 7 * 22, 46, 20, "conversation.line")); + for (int i = 0; i < 14; i++) { + ConversationLine line = job.getLine(i); + int offset = i >= 7 ? 200 : 0; + this.addLabel(new GuiNpcLabel(i, "" + (i + 1), guiLeft + 5 + offset - (i > 8 ? 6 : 0), guiTop + 18 + i % 7 * 22)); + this.addTextField(new GuiNpcTextField(i, this, this.fontRendererObj, guiLeft + 13 + offset, guiTop + 13 + i % 7 * 22, 100, 20, line.npc)); + this.addButton(new GuiNpcButton(i, guiLeft + 115 + offset, guiTop + 13 + i % 7 * 22, 46, 20, "conversation.line")); - if(i > 0){ - this.addTextField(new GuiNpcTextField(i + 14, this, this.fontRendererObj, guiLeft + 164 + offset, guiTop + 13 + i % 7 * 22, 30, 20, line.delay + "")); - this.getTextField(i + 14).integersOnly = true; - this.getTextField(i + 14).setMinMaxDefault(5, 1000, 40); - } - } - addLabel(new GuiNpcLabel(50, "conversation.delay", guiLeft + 202, guiTop + 175)); - addTextField(new GuiNpcTextField(50, this, fontRendererObj, guiLeft + 260, guiTop + 170, 40, 20, job.generalDelay + "")); - getTextField(50).integersOnly = true; - getTextField(50).setMinMaxDefault(10, Integer.MAX_VALUE, 12000); + if (i > 0) { + this.addTextField(new GuiNpcTextField(i + 14, this, this.fontRendererObj, guiLeft + 164 + offset, guiTop + 13 + i % 7 * 22, 30, 20, line.delay + "")); + this.getTextField(i + 14).integersOnly = true; + this.getTextField(i + 14).setMinMaxDefault(5, 1000, 40); + } + } + addLabel(new GuiNpcLabel(50, "conversation.delay", guiLeft + 202, guiTop + 175)); + addTextField(new GuiNpcTextField(50, this, fontRendererObj, guiLeft + 260, guiTop + 170, 40, 20, job.generalDelay + "")); + getTextField(50).integersOnly = true; + getTextField(50).setMinMaxDefault(10, Integer.MAX_VALUE, 12000); - addLabel(new GuiNpcLabel(54, "gui.range", guiLeft + 202, guiTop + 196)); - addTextField(new GuiNpcTextField(54, this, fontRendererObj, guiLeft + 260, guiTop + 191, 40, 20, job.range + "")); - getTextField(54).integersOnly = true; - getTextField(54).setMinMaxDefault(4, Integer.MAX_VALUE, 20); + addLabel(new GuiNpcLabel(54, "gui.range", guiLeft + 202, guiTop + 196)); + addTextField(new GuiNpcTextField(54, this, fontRendererObj, guiLeft + 260, guiTop + 191, 40, 20, job.range + "")); + getTextField(54).integersOnly = true; + getTextField(54).setMinMaxDefault(4, Integer.MAX_VALUE, 20); - addLabel(new GuiNpcLabel(51, "quest.quest", guiLeft + 13, guiTop + 175)); - String title = job.questTitle; - if(title.isEmpty()) - title = "gui.select"; - addButton(new GuiNpcButton(51, guiLeft + 70, guiTop + 170, 100, 20, title)); - addButton(new GuiNpcButton(52, guiLeft + 171, guiTop + 170, 20, 20, "X")); + addLabel(new GuiNpcLabel(51, "quest.quest", guiLeft + 13, guiTop + 175)); + String title = job.questTitle; + if (title.isEmpty()) + title = "gui.select"; + addButton(new GuiNpcButton(51, guiLeft + 70, guiTop + 170, 100, 20, title)); + addButton(new GuiNpcButton(52, guiLeft + 171, guiTop + 170, 20, 20, "X")); - addLabel(new GuiNpcLabel(53, "availability.name", guiLeft + 13, guiTop + 196)); - addButton(new GuiNpcButton(53, guiLeft + 110, guiTop + 191, 60, 20, "selectServer.edit")); + addLabel(new GuiNpcLabel(53, "availability.name", guiLeft + 13, guiTop + 196)); + addButton(new GuiNpcButton(53, guiLeft + 110, guiTop + 191, 60, 20, "selectServer.edit")); - addButton(new GuiNpcButton(55, guiLeft + 310, guiTop + 181, 96, 20, new String[]{"gui.always", "gui.playernearby"}, job.mode)); + addButton(new GuiNpcButton(55, guiLeft + 310, guiTop + 181, 96, 20, new String[]{"gui.always", "gui.playernearby"}, job.mode)); } - protected void actionPerformed(GuiButton guibutton){ - GuiNpcButton button = (GuiNpcButton) guibutton; - if(button.id >= 0 && button.id < 14){ - slot = button.id; - ConversationLine line = job.getLine(slot); - setSubGui(new SubGuiNpcConversationLine(line.text, line.sound)); - } - if(button.id == 51){ + protected void actionPerformed(GuiButton guibutton) { + GuiNpcButton button = (GuiNpcButton) guibutton; + if (button.id >= 0 && button.id < 14) { + slot = button.id; + ConversationLine line = job.getLine(slot); + setSubGui(new SubGuiNpcConversationLine(line.text, line.sound)); + } + if (button.id == 51) { setSubGui(new GuiQuestSelection(job.quest)); } - if(button.id == 52){ - job.quest = -1; - job.questTitle = ""; - initGui(); - } - if(button.id == 53){ - setSubGui(new SubGuiNpcAvailability(job.availability)); - } - if(button.id == 55){ - job.mode = button.getValue(); - } + if (button.id == 52) { + job.quest = -1; + job.questTitle = ""; + initGui(); + } + if (button.id == 53) { + setSubGui(new SubGuiNpcAvailability(job.availability)); + } + if (button.id == 55) { + job.mode = button.getValue(); + } } - @Override - public void selected(int ob, String name) { + + @Override + public void selected(int ob, String name) { job.quest = ob; job.questTitle = name; initGui(); - } + } @Override - public void closeSubGui(SubGuiInterface gui) { - super.closeSubGui(gui); - if(gui instanceof SubGuiNpcConversationLine){ - SubGuiNpcConversationLine sub = (SubGuiNpcConversationLine) gui; - ConversationLine line = job.getLine(slot); - line.text = sub.line; - line.sound = sub.sound; - } - } + public void closeSubGui(SubGuiInterface gui) { + super.closeSubGui(gui); + if (gui instanceof SubGuiNpcConversationLine) { + SubGuiNpcConversationLine sub = (SubGuiNpcConversationLine) gui; + ConversationLine line = job.getLine(slot); + line.text = sub.line; + line.sound = sub.sound; + } + } @Override - public void save() { + public void save() { JobSavePacket.saveJob(job); - } + } - @Override - public void unFocused(GuiNpcTextField textfield) { - if(textfield.id >= 0 && textfield.id < 14){ - ConversationLine line = job.getLine(textfield.id); - line.npc = textfield.getText(); - } - if(textfield.id >= 14 && textfield.id < 28){ - ConversationLine line = job.getLine(textfield.id - 14); - line.delay = textfield.getInteger(); - } - if(textfield.id == 50){ - job.generalDelay = textfield.getInteger(); - } - if(textfield.id == 54){ - job.range = textfield.getInteger(); - } - } + @Override + public void unFocused(GuiNpcTextField textfield) { + if (textfield.id >= 0 && textfield.id < 14) { + ConversationLine line = job.getLine(textfield.id); + line.npc = textfield.getText(); + } + if (textfield.id >= 14 && textfield.id < 28) { + ConversationLine line = job.getLine(textfield.id - 14); + line.delay = textfield.getInteger(); + } + if (textfield.id == 50) { + job.generalDelay = textfield.getInteger(); + } + if (textfield.id == 54) { + job.range = textfield.getInteger(); + } + } } diff --git a/src/main/java/noppes/npcs/client/gui/roles/GuiNpcFollowerJob.java b/src/main/java/noppes/npcs/client/gui/roles/GuiNpcFollowerJob.java index a995ce380..c41b728c4 100644 --- a/src/main/java/noppes/npcs/client/gui/roles/GuiNpcFollowerJob.java +++ b/src/main/java/noppes/npcs/client/gui/roles/GuiNpcFollowerJob.java @@ -8,24 +8,22 @@ import noppes.npcs.roles.JobFollower; import java.util.ArrayList; import java.util.List; -public class GuiNpcFollowerJob extends GuiNPCInterface2 implements ICustomScrollListener -{ - private JobFollower job; - private GuiCustomScroll scroll; - public GuiNpcFollowerJob(EntityNPCInterface npc) - { - super(npc); - job = (JobFollower) npc.jobInterface; +public class GuiNpcFollowerJob extends GuiNPCInterface2 implements ICustomScrollListener { + private JobFollower job; + private GuiCustomScroll scroll; + + public GuiNpcFollowerJob(EntityNPCInterface npc) { + super(npc); + job = (JobFollower) npc.jobInterface; } - public void initGui() - { - super.initGui(); + public void initGui() { + super.initGui(); - addLabel(new GuiNpcLabel(1,"gui.name", guiLeft + 6, guiTop + 110)); - addTextField(new GuiNpcTextField(1,this, this.fontRendererObj, guiLeft + 50, guiTop + 105, 200, 20, job.name)); + addLabel(new GuiNpcLabel(1, "gui.name", guiLeft + 6, guiTop + 110)); + addTextField(new GuiNpcTextField(1, this, this.fontRendererObj, guiLeft + 50, guiTop + 105, 200, 20, job.name)); - scroll = new GuiCustomScroll(this,0); + scroll = new GuiCustomScroll(this, 0); scroll.setSize(143, 208); scroll.guiLeft = guiLeft + 268; scroll.guiTop = guiTop + 4; @@ -33,25 +31,25 @@ public class GuiNpcFollowerJob extends GuiNPCInterface2 implements ICustomScroll List names = new ArrayList(); List list = npc.worldObj.getEntitiesWithinAABB(EntityNPCInterface.class, npc.boundingBox.expand(40, 40, 40)); - for(EntityNPCInterface npc : list){ - if(npc == this.npc || names.contains(npc.display.name)) - continue; - names.add(npc.display.name); + for (EntityNPCInterface npc : list) { + if (npc == this.npc || names.contains(npc.display.name)) + continue; + names.add(npc.display.name); } scroll.setList(names); } @Override - public void save() { - job.name = getTextField(1).getText(); + public void save() { + job.name = getTextField(1).getText(); JobSavePacket.saveJob(job); - } + } - @Override - public void customScrollClicked(int i, int j, int k, - GuiCustomScroll guiCustomScroll) { - getTextField(1).setText(guiCustomScroll.getSelected()); - } + @Override + public void customScrollClicked(int i, int j, int k, + GuiCustomScroll guiCustomScroll) { + getTextField(1).setText(guiCustomScroll.getSelected()); + } } diff --git a/src/main/java/noppes/npcs/client/gui/roles/GuiNpcFollowerSetup.java b/src/main/java/noppes/npcs/client/gui/roles/GuiNpcFollowerSetup.java index 5664d3549..2f18bdbff 100644 --- a/src/main/java/noppes/npcs/client/gui/roles/GuiNpcFollowerSetup.java +++ b/src/main/java/noppes/npcs/client/gui/roles/GuiNpcFollowerSetup.java @@ -14,36 +14,35 @@ import noppes.npcs.roles.RoleFollower; import java.util.HashMap; -public class GuiNpcFollowerSetup extends GuiContainerNPCInterface2 -{ - private RoleFollower role; - private static final ResourceLocation field_110422_t = new ResourceLocation("textures/gui/followersetup.png"); - public GuiNpcFollowerSetup(EntityNPCInterface npc,ContainerNPCFollowerSetup container) - { +public class GuiNpcFollowerSetup extends GuiContainerNPCInterface2 { + private RoleFollower role; + private static final ResourceLocation field_110422_t = new ResourceLocation("textures/gui/followersetup.png"); + + public GuiNpcFollowerSetup(EntityNPCInterface npc, ContainerNPCFollowerSetup container) { super(npc, container); - ySize = 200; + ySize = 200; role = (RoleFollower) npc.roleInterface; setBackground("followersetup.png"); } - public void initGui() - { - super.initGui(); - for(int i = 0; i < 3; i++){ - int x = guiLeft + 66; - int y = guiTop + 37; - y += i * 25; - GuiNpcTextField tf = new GuiNpcTextField(i,this, fontRendererObj,x, y, 24, 20, "1"); - tf.integersOnly = true; - tf.setMinMaxDefault(1, Integer.MAX_VALUE, 1); - addTextField(tf); + + public void initGui() { + super.initGui(); + for (int i = 0; i < 3; i++) { + int x = guiLeft + 66; + int y = guiTop + 37; + y += i * 25; + GuiNpcTextField tf = new GuiNpcTextField(i, this, fontRendererObj, x, y, 24, 20, "1"); + tf.integersOnly = true; + tf.setMinMaxDefault(1, Integer.MAX_VALUE, 1); + addTextField(tf); } int i = 0; - for(int day : role.rates.values()){ - getTextField(i).setText(day + ""); - i++; + for (int day : role.rates.values()) { + getTextField(i).setText(day + ""); + i++; } - addTextField(new GuiNpcTextField(3,this, fontRendererObj,guiLeft + 100, guiTop + 6, 286, 20, role.dialogHire)); - addTextField(new GuiNpcTextField(4,this, fontRendererObj,guiLeft + 100, guiTop + 30, 286, 20, role.dialogFarewell)); + addTextField(new GuiNpcTextField(3, this, fontRendererObj, guiLeft + 100, guiTop + 6, 286, 20, role.dialogHire)); + addTextField(new GuiNpcTextField(4, this, fontRendererObj, guiLeft + 100, guiTop + 30, 286, 20, role.dialogFarewell)); addLabel(new GuiNpcLabel(7, "follower.infiniteDays", guiLeft + 180, guiTop + 80)); addButton(new GuiNpcButtonYesNo(7, guiLeft + 260, guiTop + 75, role.infiniteDays)); @@ -59,45 +58,45 @@ public class GuiNpcFollowerSetup extends GuiContainerNPCInterface2 } @Override - protected void actionPerformed(GuiButton guibutton){ - if(guibutton.id == 7){ - role.infiniteDays = ((GuiNpcButtonYesNo)guibutton).getBoolean(); - } - if(guibutton.id == 8){ - role.disableGui = ((GuiNpcButtonYesNo)guibutton).getBoolean(); - } - if(guibutton.id == 9){ - role.refuseSoulStone = !((GuiNpcButtonYesNo)guibutton).getBoolean(); - } - if(guibutton.id == 10){ - role.killed(); - } + protected void actionPerformed(GuiButton guibutton) { + if (guibutton.id == 7) { + role.infiniteDays = ((GuiNpcButtonYesNo) guibutton).getBoolean(); + } + if (guibutton.id == 8) { + role.disableGui = ((GuiNpcButtonYesNo) guibutton).getBoolean(); + } + if (guibutton.id == 9) { + role.refuseSoulStone = !((GuiNpcButtonYesNo) guibutton).getBoolean(); + } + if (guibutton.id == 10) { + role.killed(); + } } @Override - protected void drawGuiContainerForegroundLayer(int par1, int par2) - { + protected void drawGuiContainerForegroundLayer(int par1, int par2) { } - @Override - public void save() { - HashMap map = new HashMap(); - for(int i= 0;i < role.inventory.getSizeInventory();i++){ - ItemStack item = role.inventory.getStackInSlot(i); - if(item != null){ - int days = 1; - if(!getTextField(i).isEmpty() && getTextField(i).isInteger()) - days = getTextField(i).getInteger(); - if(days <= 0) - days = 1; + @Override + public void save() { + HashMap map = new HashMap(); + for (int i = 0; i < role.inventory.getSizeInventory(); i++) { + ItemStack item = role.inventory.getStackInSlot(i); + if (item != null) { - map.put(i,days); - } + int days = 1; + if (!getTextField(i).isEmpty() && getTextField(i).isInteger()) + days = getTextField(i).getInteger(); + if (days <= 0) + days = 1; + + map.put(i, days); + } } - role.rates = map; - role.dialogHire = getTextField(3).getText(); - role.dialogFarewell = getTextField(4).getText(); + role.rates = map; + role.dialogHire = getTextField(3).getText(); + role.dialogFarewell = getTextField(4).getText(); PacketClient.sendClient(new RoleSavePacket(role.writeToNBT(new NBTTagCompound()))); - } + } } diff --git a/src/main/java/noppes/npcs/client/gui/roles/GuiNpcGuard.java b/src/main/java/noppes/npcs/client/gui/roles/GuiNpcGuard.java index 5ff37fc03..215d4ae77 100644 --- a/src/main/java/noppes/npcs/client/gui/roles/GuiNpcGuard.java +++ b/src/main/java/noppes/npcs/client/gui/roles/GuiNpcGuard.java @@ -14,127 +14,127 @@ import noppes.npcs.roles.JobGuard; import java.util.ArrayList; import java.util.List; -public class GuiNpcGuard extends GuiNPCInterface2{ - private JobGuard role; - private GuiCustomScroll scroll1; - private GuiCustomScroll scroll2; +public class GuiNpcGuard extends GuiNPCInterface2 { + private JobGuard role; + private GuiCustomScroll scroll1; + private GuiCustomScroll scroll2; - public GuiNpcGuard(EntityNPCInterface npc){ - super(npc); - role = (JobGuard) npc.jobInterface; + public GuiNpcGuard(EntityNPCInterface npc) { + super(npc); + role = (JobGuard) npc.jobInterface; } - public void initGui(){ - super.initGui(); - this.addLabel(new GuiNpcLabel(0, "guard.animals", guiLeft + 10, guiTop + 9)); - this.addButton(new GuiNpcButton(0, guiLeft + 85, guiTop + 4, 50, 20, new String[]{"gui.no", "gui.yes"},role.attacksAnimals?1:0)); + public void initGui() { + super.initGui(); + this.addLabel(new GuiNpcLabel(0, "guard.animals", guiLeft + 10, guiTop + 9)); + this.addButton(new GuiNpcButton(0, guiLeft + 85, guiTop + 4, 50, 20, new String[]{"gui.no", "gui.yes"}, role.attacksAnimals ? 1 : 0)); - this.addLabel(new GuiNpcLabel(1, "guard.mobs", guiLeft + 140, guiTop + 9)); - this.addButton(new GuiNpcButton(1, guiLeft + 222, guiTop + 4, 50, 20, new String[]{"gui.no", "gui.yes"},role.attackHostileMobs?1:0)); + this.addLabel(new GuiNpcLabel(1, "guard.mobs", guiLeft + 140, guiTop + 9)); + this.addButton(new GuiNpcButton(1, guiLeft + 222, guiTop + 4, 50, 20, new String[]{"gui.no", "gui.yes"}, role.attackHostileMobs ? 1 : 0)); - this.addLabel(new GuiNpcLabel(2, "guard.creepers", guiLeft + 275, guiTop + 9)); - this.addButton(new GuiNpcButton(2, guiLeft + 360, guiTop + 4, 50, 20, new String[]{"gui.no", "gui.yes"},role.attackCreepers?1:0)); - getButton(2).enabled = role.attackHostileMobs; + this.addLabel(new GuiNpcLabel(2, "guard.creepers", guiLeft + 275, guiTop + 9)); + this.addButton(new GuiNpcButton(2, guiLeft + 360, guiTop + 4, 50, 20, new String[]{"gui.no", "gui.yes"}, role.attackCreepers ? 1 : 0)); + getButton(2).enabled = role.attackHostileMobs; - this.addLabel(new GuiNpcLabel(3, "guard.specifictargets", guiLeft + 10, guiTop + 31)); - this.addButton(new GuiNpcButton(3, guiLeft + 85, guiTop + 26, 50, 20, new String[]{"gui.no", "gui.yes"},role.specific?1:0)); + this.addLabel(new GuiNpcLabel(3, "guard.specifictargets", guiLeft + 10, guiTop + 31)); + this.addButton(new GuiNpcButton(3, guiLeft + 85, guiTop + 26, 50, 20, new String[]{"gui.no", "gui.yes"}, role.specific ? 1 : 0)); - if(role.specific){ - if(scroll1 == null){ - scroll1 = new GuiCustomScroll(this,0); - scroll1.setSize(175, 154); - } - scroll1.guiLeft = guiLeft + 4; - scroll1.guiTop = guiTop + 58; - this.addScroll(scroll1); - addLabel(new GuiNpcLabel(11, "guard.availableTargets", guiLeft + 4, guiTop + 48)); + if (role.specific) { + if (scroll1 == null) { + scroll1 = new GuiCustomScroll(this, 0); + scroll1.setSize(175, 154); + } + scroll1.guiLeft = guiLeft + 4; + scroll1.guiTop = guiTop + 58; + this.addScroll(scroll1); + addLabel(new GuiNpcLabel(11, "guard.availableTargets", guiLeft + 4, guiTop + 48)); - if(scroll2 == null){ - scroll2 = new GuiCustomScroll(this,1); - scroll2.setSize(175, 154); - } - scroll2.guiLeft = guiLeft + 235; - scroll2.guiTop = guiTop + 58; - this.addScroll(scroll2); - addLabel(new GuiNpcLabel(12, "guard.currentTargets", guiLeft + 235, guiTop + 48)); + if (scroll2 == null) { + scroll2 = new GuiCustomScroll(this, 1); + scroll2.setSize(175, 154); + } + scroll2.guiLeft = guiLeft + 235; + scroll2.guiTop = guiTop + 58; + this.addScroll(scroll2); + addLabel(new GuiNpcLabel(12, "guard.currentTargets", guiLeft + 235, guiTop + 48)); - List all = new ArrayList(); - for(Object entity : EntityList.stringToClassMapping.keySet()){ - String name = "entity." + entity + ".name"; - Class cl = (Class) EntityList.stringToClassMapping.get(entity); - if(role.targets.contains(name) || EntityNPCInterface.class.isAssignableFrom(cl)) - continue; - if(EntityLivingBase.class.isAssignableFrom(cl)) - all.add(name); - } - scroll1.setList(all); - scroll2.setList(role.targets); + List all = new ArrayList(); + for (Object entity : EntityList.stringToClassMapping.keySet()) { + String name = "entity." + entity + ".name"; + Class cl = (Class) EntityList.stringToClassMapping.get(entity); + if (role.targets.contains(name) || EntityNPCInterface.class.isAssignableFrom(cl)) + continue; + if (EntityLivingBase.class.isAssignableFrom(cl)) + all.add(name); + } + scroll1.setList(all); + scroll2.setList(role.targets); - addButton(new GuiNpcButton(11, guiLeft + 180, guiTop + 80, 55, 20, ">")); - addButton(new GuiNpcButton(12, guiLeft + 180, guiTop + 102, 55, 20, "<")); + addButton(new GuiNpcButton(11, guiLeft + 180, guiTop + 80, 55, 20, ">")); + addButton(new GuiNpcButton(12, guiLeft + 180, guiTop + 102, 55, 20, "<")); - addButton(new GuiNpcButton(13, guiLeft + 180, guiTop + 130, 55, 20, ">>")); - addButton(new GuiNpcButton(14, guiLeft + 180, guiTop + 152, 55, 20, "<<")); - } + addButton(new GuiNpcButton(13, guiLeft + 180, guiTop + 130, 55, 20, ">>")); + addButton(new GuiNpcButton(14, guiLeft + 180, guiTop + 152, 55, 20, "<<")); + } } - protected void actionPerformed(GuiButton guibutton){ - GuiNpcButton button = (GuiNpcButton) guibutton; - if(button.id == 0){ - role.attacksAnimals = button.getValue()==1; + protected void actionPerformed(GuiButton guibutton) { + GuiNpcButton button = (GuiNpcButton) guibutton; + if (button.id == 0) { + role.attacksAnimals = button.getValue() == 1; } - if(button.id == 1){ - role.attackHostileMobs = button.getValue()==1; - initGui(); + if (button.id == 1) { + role.attackHostileMobs = button.getValue() == 1; + initGui(); } - if(button.id == 2){ - role.attackCreepers = button.getValue()==1; + if (button.id == 2) { + role.attackCreepers = button.getValue() == 1; } - if(button.id == 3){ - role.specific = button.getValue()==1; - initGui(); + if (button.id == 3) { + role.specific = button.getValue() == 1; + initGui(); } - if(button.id == 11){ - if(scroll1.hasSelected()){ - role.targets.add(scroll1.getSelected()); - scroll1.selected = -1; - scroll1.selected = -1; - initGui(); - } - } - if(button.id == 12){ - if(scroll2.hasSelected()){ - role.targets.remove(scroll2.getSelected()); - scroll2.selected = -1; - initGui(); - } - } - if(button.id == 13){ - role.targets.clear(); - List all = new ArrayList(); - for(Object entity : EntityList.stringToClassMapping.keySet()){ - String name = "entity." + entity + ".name"; - Class cl = (Class) EntityList.stringToClassMapping.get(entity); - if(EntityLivingBase.class.isAssignableFrom(cl)) - all.add(name); - } - role.targets = all; - scroll1.selected = -1; - scroll2.selected = -1; - initGui(); - } - if(button.id == 14){ - role.targets.clear(); - scroll1.selected = -1; - scroll2.selected = -1; - initGui(); - } + if (button.id == 11) { + if (scroll1.hasSelected()) { + role.targets.add(scroll1.getSelected()); + scroll1.selected = -1; + scroll1.selected = -1; + initGui(); + } + } + if (button.id == 12) { + if (scroll2.hasSelected()) { + role.targets.remove(scroll2.getSelected()); + scroll2.selected = -1; + initGui(); + } + } + if (button.id == 13) { + role.targets.clear(); + List all = new ArrayList(); + for (Object entity : EntityList.stringToClassMapping.keySet()) { + String name = "entity." + entity + ".name"; + Class cl = (Class) EntityList.stringToClassMapping.get(entity); + if (EntityLivingBase.class.isAssignableFrom(cl)) + all.add(name); + } + role.targets = all; + scroll1.selected = -1; + scroll2.selected = -1; + initGui(); + } + if (button.id == 14) { + role.targets.clear(); + scroll1.selected = -1; + scroll2.selected = -1; + initGui(); + } } - public void save() { + public void save() { JobSavePacket.saveJob(role); - } + } } diff --git a/src/main/java/noppes/npcs/client/gui/roles/GuiNpcHealer.java b/src/main/java/noppes/npcs/client/gui/roles/GuiNpcHealer.java index 05c41b644..1ea3d5ad6 100644 --- a/src/main/java/noppes/npcs/client/gui/roles/GuiNpcHealer.java +++ b/src/main/java/noppes/npcs/client/gui/roles/GuiNpcHealer.java @@ -7,43 +7,42 @@ import noppes.npcs.client.gui.util.GuiNpcTextField; import noppes.npcs.entity.EntityNPCInterface; import noppes.npcs.roles.JobHealer; -public class GuiNpcHealer extends GuiNPCInterface2 -{ - private JobHealer job; - public GuiNpcHealer(EntityNPCInterface npc) - { - super(npc); - job = (JobHealer) npc.jobInterface; +public class GuiNpcHealer extends GuiNPCInterface2 { + private JobHealer job; + + public GuiNpcHealer(EntityNPCInterface npc) { + super(npc); + job = (JobHealer) npc.jobInterface; } - public void initGui() - { - super.initGui(); + public void initGui() { + super.initGui(); - addLabel(new GuiNpcLabel(1,"Healing Speed:", guiLeft + 60, guiTop + 110)); - addTextField(new GuiNpcTextField(1,this, this.fontRendererObj, guiLeft+130, guiTop + 105, 40, 20, job.speed + "")); + addLabel(new GuiNpcLabel(1, "Healing Speed:", guiLeft + 60, guiTop + 110)); + addTextField(new GuiNpcTextField(1, this, this.fontRendererObj, guiLeft + 130, guiTop + 105, 40, 20, job.speed + "")); getTextField(1).integersOnly = true; getTextField(1).setMinMaxDefault(1, Integer.MAX_VALUE, 8); - addLabel(new GuiNpcLabel(2,"Range:", guiLeft + 60, guiTop + 133)); - addTextField(new GuiNpcTextField(2,this, this.fontRendererObj, guiLeft+130, guiTop + 128, 40, 20, job.range + "")); + addLabel(new GuiNpcLabel(2, "Range:", guiLeft + 60, guiTop + 133)); + addTextField(new GuiNpcTextField(2, this, this.fontRendererObj, guiLeft + 130, guiTop + 128, 40, 20, job.range + "")); getTextField(2).integersOnly = true; getTextField(2).setMinMaxDefault(2, Integer.MAX_VALUE, 5); } + @Override - public void elementClicked(){ + public void elementClicked() { } @Override - public void save() { - job.speed = getTextField(1).getInteger(); - job.range = getTextField(2).getInteger(); + public void save() { + job.speed = getTextField(1).getInteger(); + job.range = getTextField(2).getInteger(); JobSavePacket.saveJob(job); - } + } } diff --git a/src/main/java/noppes/npcs/client/gui/roles/GuiNpcItemGiver.java b/src/main/java/noppes/npcs/client/gui/roles/GuiNpcItemGiver.java index 5b518dc2b..11ae9440e 100644 --- a/src/main/java/noppes/npcs/client/gui/roles/GuiNpcItemGiver.java +++ b/src/main/java/noppes/npcs/client/gui/roles/GuiNpcItemGiver.java @@ -14,80 +14,75 @@ import noppes.npcs.roles.JobItemGiver; import java.util.ArrayList; import java.util.List; -public class GuiNpcItemGiver extends GuiContainerNPCInterface2 -{ - private JobItemGiver role; - public GuiNpcItemGiver(EntityNPCInterface npc, ContainerNpcItemGiver container) - { - super(npc,container); - ySize = 200; - role = (JobItemGiver) npc.jobInterface; - setBackground("npcitemgiver.png"); +public class GuiNpcItemGiver extends GuiContainerNPCInterface2 { + private JobItemGiver role; + + public GuiNpcItemGiver(EntityNPCInterface npc, ContainerNpcItemGiver container) { + super(npc, container); + ySize = 200; + role = (JobItemGiver) npc.jobInterface; + setBackground("npcitemgiver.png"); } - public void initGui() - { - super.initGui(); - this.addButton(new GuiNpcButton(0, guiLeft + 6, guiTop + 6, 140,20, new String[]{"Random Item","All Items","Give Not Owned Items","Give When Doesnt Own Any","Chained"},role.givingMethod)); - this.addButton(new GuiNpcButton(1, guiLeft + 6, guiTop + 29, 140,20, new String[]{"Timer","Give Only Once","Daily"},role.cooldownType)); + public void initGui() { + super.initGui(); + this.addButton(new GuiNpcButton(0, guiLeft + 6, guiTop + 6, 140, 20, new String[]{"Random Item", "All Items", "Give Not Owned Items", "Give When Doesnt Own Any", "Chained"}, role.givingMethod)); + this.addButton(new GuiNpcButton(1, guiLeft + 6, guiTop + 29, 140, 20, new String[]{"Timer", "Give Only Once", "Daily"}, role.cooldownType)); - addTextField(new GuiNpcTextField(0, this, fontRendererObj, guiLeft + 55, guiTop + 54, 90, 20, role.cooldown + "")); - getTextField(0).integersOnly = true; - addLabel(new GuiNpcLabel(0,"Cooldown:", guiLeft + 6, guiTop + 59)); - addLabel(new GuiNpcLabel(1,"Items to give", guiLeft + 46, guiTop + 79)); + addTextField(new GuiNpcTextField(0, this, fontRendererObj, guiLeft + 55, guiTop + 54, 90, 20, role.cooldown + "")); + getTextField(0).integersOnly = true; + addLabel(new GuiNpcLabel(0, "Cooldown:", guiLeft + 6, guiTop + 59)); + addLabel(new GuiNpcLabel(1, "Items to give", guiLeft + 46, guiTop + 79)); getTextField(0).integersOnly = true; int i = 0; - for(String line : role.lines){ - addTextField(new GuiNpcTextField(i+1, this, fontRendererObj, guiLeft + 150, guiTop + 6 + i * 24, 236, 20,line)); - i++; + for (String line : role.lines) { + addTextField(new GuiNpcTextField(i + 1, this, fontRendererObj, guiLeft + 150, guiTop + 6 + i * 24, 236, 20, line)); + i++; } - for(;i <3; i++){ - addTextField(new GuiNpcTextField(i+1, this, fontRendererObj, guiLeft + 150, guiTop + 6 + i * 24, 236, 20,"")); + for (; i < 3; i++) { + addTextField(new GuiNpcTextField(i + 1, this, fontRendererObj, guiLeft + 150, guiTop + 6 + i * 24, 236, 20, "")); } - getTextField(0).enabled = role.isOnTimer(); - getLabel(0).enabled = role.isOnTimer(); + getTextField(0).enabled = role.isOnTimer(); + getLabel(0).enabled = role.isOnTimer(); - addLabel(new GuiNpcLabel(4, "availability.options", guiLeft + 180, guiTop + 101)); - addButton(new GuiNpcButton(4, guiLeft + 280, guiTop + 96, 50, 20, "selectServer.edit")); + addLabel(new GuiNpcLabel(4, "availability.options", guiLeft + 180, guiTop + 101)); + addButton(new GuiNpcButton(4, guiLeft + 280, guiTop + 96, 50, 20, "selectServer.edit")); } - public void actionPerformed(GuiButton guibutton) - { - GuiNpcButton button = (GuiNpcButton) guibutton; - if(button.id == 0) - { - role.givingMethod = button.getValue(); + public void actionPerformed(GuiButton guibutton) { + GuiNpcButton button = (GuiNpcButton) guibutton; + if (button.id == 0) { + role.givingMethod = button.getValue(); } - if(button.id == 1) - { - role.cooldownType = button.getValue(); - getTextField(0).enabled = role.isOnTimer(); - getLabel(0).enabled = role.isOnTimer(); + if (button.id == 1) { + role.cooldownType = button.getValue(); + getTextField(0).enabled = role.isOnTimer(); + getLabel(0).enabled = role.isOnTimer(); } - if(button.id == 4){ - setSubGui(new SubGuiNpcAvailability(role.availability)); + if (button.id == 4) { + setSubGui(new SubGuiNpcAvailability(role.availability)); } } - public void save() { + public void save() { - List lines = new ArrayList(); - for(int i = 1; i < 4; i++){ - GuiNpcTextField tf = getTextField(i); - if(!tf.isEmpty()) - lines.add(tf.getText()); - } - role.lines = lines; - int cc = 10; - if(!getTextField(0).isEmpty() && getTextField(0).isInteger()) - cc = getTextField(0).getInteger(); + List lines = new ArrayList(); + for (int i = 1; i < 4; i++) { + GuiNpcTextField tf = getTextField(i); + if (!tf.isEmpty()) + lines.add(tf.getText()); + } + role.lines = lines; + int cc = 10; + if (!getTextField(0).isEmpty() && getTextField(0).isInteger()) + cc = getTextField(0).getInteger(); - role.cooldown = cc; + role.cooldown = cc; JobSavePacket.saveJob(role); - } + } } diff --git a/src/main/java/noppes/npcs/client/gui/roles/GuiNpcSpawner.java b/src/main/java/noppes/npcs/client/gui/roles/GuiNpcSpawner.java index 105a52be6..0901b38b2 100644 --- a/src/main/java/noppes/npcs/client/gui/roles/GuiNpcSpawner.java +++ b/src/main/java/noppes/npcs/client/gui/roles/GuiNpcSpawner.java @@ -13,220 +13,214 @@ import noppes.npcs.entity.EntityNPCInterface; import noppes.npcs.roles.JobSpawner; -public class GuiNpcSpawner extends GuiNPCInterface2 implements ITextfieldListener, IGuiData -{ - private JobSpawner job; +public class GuiNpcSpawner extends GuiNPCInterface2 implements ITextfieldListener, IGuiData { + private JobSpawner job; - private int slot = -1; + private int slot = -1; - public String title1 = "gui.selectnpc"; - public String title2 = "gui.selectnpc"; - public String title3 = "gui.selectnpc"; - public String title4 = "gui.selectnpc"; - public String title5 = "gui.selectnpc"; - public String title6 = "gui.selectnpc"; - public String title7 = "gui.selectnpc"; - public String title8 = "gui.selectnpc"; + public String title1 = "gui.selectnpc"; + public String title2 = "gui.selectnpc"; + public String title3 = "gui.selectnpc"; + public String title4 = "gui.selectnpc"; + public String title5 = "gui.selectnpc"; + public String title6 = "gui.selectnpc"; + public String title7 = "gui.selectnpc"; + public String title8 = "gui.selectnpc"; - public GuiNpcSpawner(EntityNPCInterface npc) - { - super(npc); - job = (JobSpawner) npc.jobInterface; + public GuiNpcSpawner(EntityNPCInterface npc) { + super(npc); + job = (JobSpawner) npc.jobInterface; } - public void initGui() - { - super.initGui(); + public void initGui() { + super.initGui(); - int y = guiTop + 6; + int y = guiTop + 6; - this.addButton(new GuiNpcButton(20, guiLeft + 20, y,20,20, "X")); + this.addButton(new GuiNpcButton(20, guiLeft + 20, y, 20, 20, "X")); addLabel(new GuiNpcLabel(0, "1:", guiLeft + 4, y + 5)); - this.addButton(new GuiNpcButton(0, guiLeft + 45, y, 140, 20, title1)); + this.addButton(new GuiNpcButton(0, guiLeft + 45, y, 140, 20, title1)); - addLabel(new GuiNpcLabel(6, "spawner.diesafter", guiLeft + 4 + 190, y + 5)); - this.addButton(new GuiNpcButton(26, guiLeft + 370, y,40,20, new String[]{"gui.yes","gui.no"}, job.doesntDie?1:0)); + addLabel(new GuiNpcLabel(6, "spawner.diesafter", guiLeft + 4 + 190, y + 5)); + this.addButton(new GuiNpcButton(26, guiLeft + 370, y, 40, 20, new String[]{"gui.yes", "gui.no"}, job.doesntDie ? 1 : 0)); - y += 23; - this.addButton(new GuiNpcButton(21, guiLeft + 20, y,20,20, "X")); + y += 23; + this.addButton(new GuiNpcButton(21, guiLeft + 20, y, 20, 20, "X")); addLabel(new GuiNpcLabel(1, "2:", guiLeft + 4, y + 5)); - this.addButton(new GuiNpcButton(1, guiLeft + 45, y, 140, 20, title2)); + this.addButton(new GuiNpcButton(1, guiLeft + 45, y, 140, 20, title2)); - addLabel(new GuiNpcLabel(11, "spawner.despawn", guiLeft + 4 + 190, y + 5)); - this.addButton(new GuiNpcButton(11, guiLeft + 370, y,40,20, new String[]{"gui.no","gui.yes"}, job.despawnOnTargetLost?1:0)); + addLabel(new GuiNpcLabel(11, "spawner.despawn", guiLeft + 4 + 190, y + 5)); + this.addButton(new GuiNpcButton(11, guiLeft + 370, y, 40, 20, new String[]{"gui.no", "gui.yes"}, job.despawnOnTargetLost ? 1 : 0)); - y += 23; - this.addButton(new GuiNpcButton(22, guiLeft + 20, y,20,20, "X")); + y += 23; + this.addButton(new GuiNpcButton(22, guiLeft + 20, y, 20, 20, "X")); addLabel(new GuiNpcLabel(2, "3:", guiLeft + 4, y + 5)); - this.addButton(new GuiNpcButton(2, guiLeft + 45, y, 140, 20, title3)); + this.addButton(new GuiNpcButton(2, guiLeft + 45, y, 140, 20, title3)); - addLabel(new GuiNpcLabel(27, "spawner.despawnsummon", guiLeft + 4 + 190, y + 5)); - this.addButton(new GuiNpcButton(27, guiLeft + 370, y,40,20, new String[]{"gui.no","gui.yes"}, job.despawnOnSummonerDeath ?0:1)); + addLabel(new GuiNpcLabel(27, "spawner.despawnsummon", guiLeft + 4 + 190, y + 5)); + this.addButton(new GuiNpcButton(27, guiLeft + 370, y, 40, 20, new String[]{"gui.no", "gui.yes"}, job.despawnOnSummonerDeath ? 0 : 1)); - y += 23; - this.addButton(new GuiNpcButton(23, guiLeft + 20, y,20,20, "X")); + y += 23; + this.addButton(new GuiNpcButton(23, guiLeft + 20, y, 20, 20, "X")); addLabel(new GuiNpcLabel(3, "4:", guiLeft + 4, y + 5)); - this.addButton(new GuiNpcButton(3, guiLeft + 45, y, 140, 20, title4)); + this.addButton(new GuiNpcButton(3, guiLeft + 45, y, 140, 20, title4)); - y += 23; - this.addButton(new GuiNpcButton(24, guiLeft + 20, y,20,20, "X")); + y += 23; + this.addButton(new GuiNpcButton(24, guiLeft + 20, y, 20, 20, "X")); addLabel(new GuiNpcLabel(4, "5:", guiLeft + 4, y + 5)); - this.addButton(new GuiNpcButton(4, guiLeft + 45, y, 140, 20, title5)); + this.addButton(new GuiNpcButton(4, guiLeft + 45, y, 140, 20, title5)); - y += 23; - this.addButton(new GuiNpcButton(25, guiLeft + 20, y,20,20, "X")); + y += 23; + this.addButton(new GuiNpcButton(25, guiLeft + 20, y, 20, 20, "X")); addLabel(new GuiNpcLabel(5, "6:", guiLeft + 4, y + 5)); - this.addButton(new GuiNpcButton(5, guiLeft + 45, y, 140, 20, title6)); + this.addButton(new GuiNpcButton(5, guiLeft + 45, y, 140, 20, title6)); - y += 23; - y += 23; + y += 23; + y += 23; - addLabel(new GuiNpcLabel(7,StatCollector.translateToLocal("spawner.posoffset")+" X:", guiLeft + 4 + 190, y + 5)); - addTextField(new GuiNpcTextField(7,this, fontRendererObj, guiLeft + 99 + 190, y, 24, 20, job.xOffset + "")); - getTextField(7).integersOnly = true; + addLabel(new GuiNpcLabel(7, StatCollector.translateToLocal("spawner.posoffset") + " X:", guiLeft + 4 + 190, y + 5)); + addTextField(new GuiNpcTextField(7, this, fontRendererObj, guiLeft + 99 + 190, y, 24, 20, job.xOffset + "")); + getTextField(7).integersOnly = true; getTextField(7).setMinMaxDefault(-9, 9, 0); - addLabel(new GuiNpcLabel(8,"Y:", guiLeft + 125 + 190, y + 5)); - addTextField(new GuiNpcTextField(8,this, fontRendererObj, guiLeft + 135 + 190, y, 24, 20, job.yOffset + "")); - getTextField(8).integersOnly = true; + addLabel(new GuiNpcLabel(8, "Y:", guiLeft + 125 + 190, y + 5)); + addTextField(new GuiNpcTextField(8, this, fontRendererObj, guiLeft + 135 + 190, y, 24, 20, job.yOffset + "")); + getTextField(8).integersOnly = true; getTextField(8).setMinMaxDefault(-9, 9, 0); - addLabel(new GuiNpcLabel(9,"Z:", guiLeft + 161 + 190, y + 5)); - addTextField(new GuiNpcTextField(9,this, fontRendererObj, guiLeft + 171 + 190, y, 24, 20, job.zOffset + "")); - getTextField(9).integersOnly = true; + addLabel(new GuiNpcLabel(9, "Z:", guiLeft + 161 + 190, y + 5)); + addTextField(new GuiNpcTextField(9, this, fontRendererObj, guiLeft + 171 + 190, y, 24, 20, job.zOffset + "")); + getTextField(9).integersOnly = true; getTextField(9).setMinMaxDefault(-9, 9, 0); - y += 23; + y += 23; addLabel(new GuiNpcLabel(10, "spawner.type", guiLeft + 4 + 190, y + 5)); addButton(new GuiNpcButton(10, guiLeft + 80 + 190, y, 100, 20, new String[]{"spawner.one", "spawner.all", "spawner.random", "spawner.summoner"}, job.spawnType)); - if(job.despawnOnSummonerDeath){ - job.doesntDie = true; - getButton(26).setEnabled(false); - getButton(26).setDisplay(1); - } + if (job.despawnOnSummonerDeath) { + job.doesntDie = true; + getButton(26).setEnabled(false); + getButton(26).setDisplay(1); + } - if(job.spawnType == 3){ - job.doesntDie = true; - getButton(26).setEnabled(false); - getButton(26).setDisplay(1); + if (job.spawnType == 3) { + job.doesntDie = true; + getButton(26).setEnabled(false); + getButton(26).setDisplay(1); - job.despawnOnTargetLost = false; - getButton(11).setEnabled(false); - getButton(11).setDisplay(0); + job.despawnOnTargetLost = false; + getButton(11).setEnabled(false); + getButton(11).setDisplay(0); - job.despawnOnSummonerDeath = false; - getButton(27).setEnabled(false); - getButton(27).setDisplay(0); - } + job.despawnOnSummonerDeath = false; + getButton(27).setEnabled(false); + getButton(27).setDisplay(0); + } } - @Override - public void elementClicked(){ - } - - protected void actionPerformed(GuiButton guibutton){ - GuiNpcButton button = (GuiNpcButton) guibutton; - if(button.id >= 0 && button.id < 6){ - slot = button.id + 1; - setSubGui(new GuiNpcMobSpawnerSelector()); - } - if(button.id >= 20 && button.id < 26){ - int removeID = button.id - 19; - job.setJobCompound(removeID, null); - PacketClient.sendClient(new JobSpawnerRemovePacket(button.id - 19)); - } - if(button.id == 26){ - job.doesntDie = button.getValue() == 1; - } - if(button.id == 27){ - job.despawnOnSummonerDeath = button.getValue() == 1; - if(job.despawnOnSummonerDeath){ - job.doesntDie = true; - getButton(26).setEnabled(false); - getButton(26).setDisplay(1); - } - else { - if(job.spawnType != 3){ - getButton(26).setEnabled(true); - } - } - } - if(button.id == 10){ - job.spawnType = button.getValue(); - if(job.spawnType == 3){ - job.doesntDie = true; - getButton(26).setEnabled(false); - getButton(26).setDisplay(1); - - job.despawnOnTargetLost = false; - getButton(11).setEnabled(false); - getButton(11).setDisplay(0); - - job.despawnOnSummonerDeath = false; - getButton(27).setEnabled(false); - getButton(27).setDisplay(0); - } - else { - if(!job.despawnOnSummonerDeath){ - getButton(26).setEnabled(true); - } - getButton(11).setEnabled(true); - getButton(27).setEnabled(true); - } - } - if(button.id == 11){ - job.despawnOnTargetLost = button.getValue() == 1; - } - } - - public void closeSubGui(SubGuiInterface gui) { - super.closeSubGui(gui); - GuiNpcMobSpawnerSelector selector = (GuiNpcMobSpawnerSelector) gui; - if(selector.isServer){ - String selected = selector.getSelected(); - if(selected != null) - PacketClient.sendClient(new JobSpawnerAddPacket(selector.isServer, selected, selector.activeTab, slot)); - } - else{ - NBTTagCompound compound = selector.getCompound(); - if(compound != null){ - job.setJobCompound(slot, compound); - PacketClient.sendClient(new JobSpawnerAddPacket(selector.isServer, slot, compound)); - } - } - initGui(); - } - @Override - public void save() { - NBTTagCompound compound = job.writeToNBT(new NBTTagCompound()); - job.cleanCompound(compound); + public void elementClicked() { + } + + protected void actionPerformed(GuiButton guibutton) { + GuiNpcButton button = (GuiNpcButton) guibutton; + if (button.id >= 0 && button.id < 6) { + slot = button.id + 1; + setSubGui(new GuiNpcMobSpawnerSelector()); + } + if (button.id >= 20 && button.id < 26) { + int removeID = button.id - 19; + job.setJobCompound(removeID, null); + PacketClient.sendClient(new JobSpawnerRemovePacket(button.id - 19)); + } + if (button.id == 26) { + job.doesntDie = button.getValue() == 1; + } + if (button.id == 27) { + job.despawnOnSummonerDeath = button.getValue() == 1; + if (job.despawnOnSummonerDeath) { + job.doesntDie = true; + getButton(26).setEnabled(false); + getButton(26).setDisplay(1); + } else { + if (job.spawnType != 3) { + getButton(26).setEnabled(true); + } + } + } + if (button.id == 10) { + job.spawnType = button.getValue(); + if (job.spawnType == 3) { + job.doesntDie = true; + getButton(26).setEnabled(false); + getButton(26).setDisplay(1); + + job.despawnOnTargetLost = false; + getButton(11).setEnabled(false); + getButton(11).setDisplay(0); + + job.despawnOnSummonerDeath = false; + getButton(27).setEnabled(false); + getButton(27).setDisplay(0); + } else { + if (!job.despawnOnSummonerDeath) { + getButton(26).setEnabled(true); + } + getButton(11).setEnabled(true); + getButton(27).setEnabled(true); + } + } + if (button.id == 11) { + job.despawnOnTargetLost = button.getValue() == 1; + } + } + + public void closeSubGui(SubGuiInterface gui) { + super.closeSubGui(gui); + GuiNpcMobSpawnerSelector selector = (GuiNpcMobSpawnerSelector) gui; + if (selector.isServer) { + String selected = selector.getSelected(); + if (selected != null) + PacketClient.sendClient(new JobSpawnerAddPacket(selector.isServer, selected, selector.activeTab, slot)); + } else { + NBTTagCompound compound = selector.getCompound(); + if (compound != null) { + job.setJobCompound(slot, compound); + PacketClient.sendClient(new JobSpawnerAddPacket(selector.isServer, slot, compound)); + } + } + initGui(); + } + + @Override + public void save() { + NBTTagCompound compound = job.writeToNBT(new NBTTagCompound()); + job.cleanCompound(compound); PacketClient.sendClient(new JobSavePacket(compound)); - } + } - @Override - public void unFocused(GuiNpcTextField textfield) { - if(textfield.id == 7){ - job.xOffset = textfield.getInteger(); - } - if(textfield.id == 8){ - job.yOffset = textfield.getInteger(); - } - if(textfield.id == 9){ - job.zOffset = textfield.getInteger(); - } - save(); - } + @Override + public void unFocused(GuiNpcTextField textfield) { + if (textfield.id == 7) { + job.xOffset = textfield.getInteger(); + } + if (textfield.id == 8) { + job.yOffset = textfield.getInteger(); + } + if (textfield.id == 9) { + job.zOffset = textfield.getInteger(); + } + save(); + } - @Override - public void setGuiData(NBTTagCompound compound) { - title1 = compound.getString("Title1"); - title2 = compound.getString("Title2"); - title3 = compound.getString("Title3"); - title4 = compound.getString("Title4"); - title5 = compound.getString("Title5"); - title6 = compound.getString("Title6"); - initGui(); - } + @Override + public void setGuiData(NBTTagCompound compound) { + title1 = compound.getString("Title1"); + title2 = compound.getString("Title2"); + title3 = compound.getString("Title3"); + title4 = compound.getString("Title4"); + title5 = compound.getString("Title5"); + title6 = compound.getString("Title6"); + initGui(); + } } diff --git a/src/main/java/noppes/npcs/client/gui/roles/GuiNpcTraderSetup.java b/src/main/java/noppes/npcs/client/gui/roles/GuiNpcTraderSetup.java index 38e270d18..4d9729982 100644 --- a/src/main/java/noppes/npcs/client/gui/roles/GuiNpcTraderSetup.java +++ b/src/main/java/noppes/npcs/client/gui/roles/GuiNpcTraderSetup.java @@ -1,4 +1,3 @@ - package noppes.npcs.client.gui.roles; import kamkeel.npcs.network.PacketClient; @@ -14,21 +13,21 @@ import noppes.npcs.entity.EntityNPCInterface; import noppes.npcs.roles.RoleTrader; import org.lwjgl.opengl.GL11; -public class GuiNpcTraderSetup extends GuiContainerNPCInterface2 implements ITextfieldListener{ +public class GuiNpcTraderSetup extends GuiContainerNPCInterface2 implements ITextfieldListener { - private final ResourceLocation slot = new ResourceLocation("customnpcs","textures/gui/slot.png"); - private RoleTrader role; + private final ResourceLocation slot = new ResourceLocation("customnpcs", "textures/gui/slot.png"); + private RoleTrader role; - public GuiNpcTraderSetup(EntityNPCInterface npc, ContainerNPCTraderSetup container){ + public GuiNpcTraderSetup(EntityNPCInterface npc, ContainerNPCTraderSetup container) { super(npc, container); - ySize = 220; - menuYOffset = 10; - role = container.role; + ySize = 220; + menuYOffset = 10; + role = container.role; } - @Override - public void initGui(){ - super.initGui(); + @Override + public void initGui() { + super.initGui(); buttonList.clear(); setBackground("tradersetup.png"); addLabel(new GuiNpcLabel(0, "role.marketname", guiLeft + 214, guiTop + 150)); @@ -44,58 +43,58 @@ public class GuiNpcTraderSetup extends GuiContainerNPCInterface2 implements ITex addButton(new GuiNpcButtonYesNo(3, guiLeft + 340, guiTop + 68, role.recordHistory)); } - @Override - public void drawScreen(int i, int j, float f){ - guiTop += 10; - super.drawScreen(i, j, f); - guiTop -= 10; + @Override + public void drawScreen(int i, int j, float f) { + guiTop += 10; + super.drawScreen(i, j, f); + guiTop -= 10; } @Override - public void actionPerformed(GuiButton guibutton){ - if(guibutton.id == 1){ - role.ignoreDamage = ((GuiNpcButtonYesNo)guibutton).getBoolean(); - } - if(guibutton.id == 2){ - role.ignoreNBT = ((GuiNpcButtonYesNo)guibutton).getBoolean(); - } - if(guibutton.id == 3){ - role.recordHistory = ((GuiNpcButtonYesNo)guibutton).getBoolean(); + public void actionPerformed(GuiButton guibutton) { + if (guibutton.id == 1) { + role.ignoreDamage = ((GuiNpcButtonYesNo) guibutton).getBoolean(); + } + if (guibutton.id == 2) { + role.ignoreNBT = ((GuiNpcButtonYesNo) guibutton).getBoolean(); + } + if (guibutton.id == 3) { + role.recordHistory = ((GuiNpcButtonYesNo) guibutton).getBoolean(); } } - @Override - protected void drawGuiContainerBackgroundLayer(float f, int i, int j){ - super.drawGuiContainerBackgroundLayer(f, i, j); + @Override + protected void drawGuiContainerBackgroundLayer(float f, int i, int j) { + super.drawGuiContainerBackgroundLayer(f, i, j); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - for(int slot = 0; slot < 18; slot++){ - int x = guiLeft + slot%3 * 94 + 7; - int y = guiTop + slot/3 * 22 + 4; + for (int slot = 0; slot < 18; slot++) { + int x = guiLeft + slot % 3 * 94 + 7; + int y = guiTop + slot / 3 * 22 + 4; - mc.renderEngine.bindTexture(this.slot); - GL11.glColor4f(1, 1, 1, 1); - drawTexturedModalRect(x - 1, y, 0, 0, 18, 18); - drawTexturedModalRect(x + 17, y, 0, 0, 18, 18); + mc.renderEngine.bindTexture(this.slot); + GL11.glColor4f(1, 1, 1, 1); + drawTexturedModalRect(x - 1, y, 0, 0, 18, 18); + drawTexturedModalRect(x + 17, y, 0, 0, 18, 18); fontRendererObj.drawString("=", x + 36, y + 5, CustomNpcResourceListener.DefaultTextColor); - mc.renderEngine.bindTexture(this.slot); - GL11.glColor4f(1, 1, 1, 1); - drawTexturedModalRect(x + 42, y, 0, 0, 18, 18); - } + mc.renderEngine.bindTexture(this.slot); + GL11.glColor4f(1, 1, 1, 1); + drawTexturedModalRect(x + 42, y, 0, 0, 18, 18); + } } - @Override - public void save() { + @Override + public void save() { PacketClient.sendClient(new TraderMarketSavePacket(role.marketName, false)); PacketClient.sendClient(new RoleSavePacket(role.writeToNBT(new NBTTagCompound()))); - } + } - @Override - public void unFocused(GuiNpcTextField guiNpcTextField) { - String name = guiNpcTextField.getText(); - if(!name.equalsIgnoreCase(role.marketName)){ - role.marketName = name; + @Override + public void unFocused(GuiNpcTextField guiNpcTextField) { + String name = guiNpcTextField.getText(); + if (!name.equalsIgnoreCase(role.marketName)) { + role.marketName = name; PacketClient.sendClient(new TraderMarketSavePacket(role.marketName, true)); } - } + } } diff --git a/src/main/java/noppes/npcs/client/gui/roles/GuiNpcTransporter.java b/src/main/java/noppes/npcs/client/gui/roles/GuiNpcTransporter.java index ce3a680a6..6be4a1f75 100644 --- a/src/main/java/noppes/npcs/client/gui/roles/GuiNpcTransporter.java +++ b/src/main/java/noppes/npcs/client/gui/roles/GuiNpcTransporter.java @@ -14,74 +14,77 @@ import noppes.npcs.entity.EntityNPCInterface; import java.util.HashMap; import java.util.Vector; -public class GuiNpcTransporter extends GuiNPCInterface2 implements IScrollData, IGuiData{ - private GuiCustomScroll scroll; - public TransportLocation location = new TransportLocation(); - private HashMap data = new HashMap(); +public class GuiNpcTransporter extends GuiNPCInterface2 implements IScrollData, IGuiData { + private GuiCustomScroll scroll; + public TransportLocation location = new TransportLocation(); + private HashMap data = new HashMap(); - public GuiNpcTransporter(EntityNPCInterface npc){ - super(npc); + public GuiNpcTransporter(EntityNPCInterface npc) { + super(npc); PacketClient.sendClient(new TransportCategoriesGetPacket()); PacketClient.sendClient(new TransportGetLocationPacket()); } - public void initGui(){ + public void initGui() { super.initGui(); Vector list = new Vector(); list.addAll(data.keySet()); - if(scroll == null){ - scroll = new GuiCustomScroll(this,0); - scroll.setSize(143, 208); + if (scroll == null) { + scroll = new GuiCustomScroll(this, 0); + scroll.setSize(143, 208); } scroll.guiLeft = guiLeft + 214; scroll.guiTop = guiTop + 4; addScroll(scroll); - addLabel(new GuiNpcLabel(0,"gui.name", guiLeft + 4, height + 8)); + addLabel(new GuiNpcLabel(0, "gui.name", guiLeft + 4, height + 8)); addTextField(new GuiNpcTextField(0, this, fontRendererObj, guiLeft + 60, guiTop + 3, 140, 20, location.name)); - addButton(new GuiNpcButton(0, guiLeft + 4, guiTop + 31, new String[]{"transporter.discovered","transporter.start","transporter.interaction"}, location.type)); + addButton(new GuiNpcButton(0, guiLeft + 4, guiTop + 31, new String[]{"transporter.discovered", "transporter.start", "transporter.interaction"}, location.type)); } - protected void actionPerformed(GuiButton guibutton) - { - GuiNpcButton button = (GuiNpcButton) guibutton; - if(button.id == 0){ - location.type = button.getValue(); - } + protected void actionPerformed(GuiButton guibutton) { + GuiNpcButton button = (GuiNpcButton) guibutton; + if (button.id == 0) { + location.type = button.getValue(); + } } - @Override - public void save() { - if(!scroll.hasSelected()) - return; - String name = getTextField(0).getText(); - if(!name.isEmpty()) - location.name = name; - location.posX = player.posX; - location.posY = player.posY; - location.posZ = player.posZ; - location.dimension = player.dimension; + @Override + public void save() { + if (!scroll.hasSelected()) + return; + String name = getTextField(0).getText(); + if (!name.isEmpty()) + location.name = name; - int cat = data.get(scroll.getSelected()); + location.posX = player.posX; + location.posY = player.posY; + location.posZ = player.posZ; + location.dimension = player.dimension; + + int cat = data.get(scroll.getSelected()); PacketClient.sendClient(new TransportSavePacket(cat, location.writeNBT())); - } - @Override - public void setData(Vector list, HashMap data, EnumScrollData type) { - this.data = data; - this.scroll.setList(list); - } - @Override - public void setSelected(String selected) { - scroll.setSelected(selected); - } - @Override - public void setGuiData(NBTTagCompound compound) { - TransportLocation loc = new TransportLocation(); - loc.readNBT(compound); - location = loc; - initGui(); - } + } + + @Override + public void setData(Vector list, HashMap data, EnumScrollData type) { + this.data = data; + this.scroll.setList(list); + } + + @Override + public void setSelected(String selected) { + scroll.setSelected(selected); + } + + @Override + public void setGuiData(NBTTagCompound compound) { + TransportLocation loc = new TransportLocation(); + loc.readNBT(compound); + location = loc; + initGui(); + } } diff --git a/src/main/java/noppes/npcs/client/gui/roles/SubGuiNpcConversationLine.java b/src/main/java/noppes/npcs/client/gui/roles/SubGuiNpcConversationLine.java index 844535882..d98457bbd 100644 --- a/src/main/java/noppes/npcs/client/gui/roles/SubGuiNpcConversationLine.java +++ b/src/main/java/noppes/npcs/client/gui/roles/SubGuiNpcConversationLine.java @@ -5,29 +5,29 @@ import noppes.npcs.client.gui.select.GuiSoundSelection; import noppes.npcs.client.gui.util.*; public class SubGuiNpcConversationLine extends SubGuiInterface implements ITextfieldListener, ISubGuiListener { - public String line; - public String sound; + public String line; + public String sound; - public SubGuiNpcConversationLine(String line, String sound){ - this.line = line; - this.sound = sound; - setBackground("menubg.png"); - xSize = 256; - ySize = 216; - closeOnEsc = true; + public SubGuiNpcConversationLine(String line, String sound) { + this.line = line; + this.sound = sound; + setBackground("menubg.png"); + xSize = 256; + ySize = 216; + closeOnEsc = true; } - public void initGui(){ + public void initGui() { super.initGui(); - addLabel(new GuiNpcLabel(0, "Line", guiLeft + 4, guiTop+ 10)); + addLabel(new GuiNpcLabel(0, "Line", guiLeft + 4, guiTop + 10)); addTextField(new GuiNpcTextField(0, this, fontRendererObj, guiLeft + 4, guiTop + 22, 200, 20, line)); addButton(new GuiNpcButton(1, guiLeft + 4, guiTop + 55, 90, 20, "Select Sound")); addButton(new GuiNpcButton(2, guiLeft + 96, guiTop + 55, 20, 20, "X")); addLabel(new GuiNpcLabel(1, sound, guiLeft + 4, guiTop + 81)); - addButton(new GuiNpcButton(66, guiLeft + 162, guiTop + 192, 90, 20, "gui.done")); + addButton(new GuiNpcButton(66, guiLeft + 162, guiTop + 192, 90, 20, "gui.done")); } @Override @@ -36,24 +36,24 @@ public class SubGuiNpcConversationLine extends SubGuiInterface implements ITextf } @Override - protected void actionPerformed(GuiButton guibutton){ - int id = guibutton.id; - if(id == 1){ + protected void actionPerformed(GuiButton guibutton) { + int id = guibutton.id; + if (id == 1) { setSubGui(new GuiSoundSelection(sound)); } - if(id == 2){ - sound = ""; - initGui(); + if (id == 2) { + sound = ""; + initGui(); } - if(id == 66){ - close(); + if (id == 66) { + close(); } } @Override public void subGuiClosed(SubGuiInterface subgui) { GuiSoundSelection gss = (GuiSoundSelection) subgui; - if(gss.selectedResource != null) { + if (gss.selectedResource != null) { sound = gss.selectedResource.toString(); initGui(); } diff --git a/src/main/java/noppes/npcs/client/gui/script/EventGuiScriptList.java b/src/main/java/noppes/npcs/client/gui/script/EventGuiScriptList.java index b75c53976..530a3a2be 100644 --- a/src/main/java/noppes/npcs/client/gui/script/EventGuiScriptList.java +++ b/src/main/java/noppes/npcs/client/gui/script/EventGuiScriptList.java @@ -22,16 +22,16 @@ public class EventGuiScriptList extends SubGuiInterface { this.setBackground("menubg.png"); this.xSize = 346; this.ySize = 216; - if(scripts == null) { + if (scripts == null) { scripts = new ArrayList(); } - this.scripts = (List)scripts; + this.scripts = (List) scripts; } public void initGui() { super.initGui(); - if(this.scroll1 == null) { + if (this.scroll1 == null) { this.scroll1 = new GuiCustomScroll(this, 0); this.scroll1.setSize(140, 180); } @@ -40,7 +40,7 @@ public class EventGuiScriptList extends SubGuiInterface { this.scroll1.guiTop = this.guiTop + 14; this.addScroll(this.scroll1); this.addLabel(new GuiNpcLabel(1, "script.availableScripts", this.guiLeft + 4, this.guiTop + 4)); - if(this.scroll2 == null) { + if (this.scroll2 == null) { this.scroll2 = new GuiCustomScroll(this, 1); this.scroll2.setSize(140, 180); } @@ -61,26 +61,26 @@ public class EventGuiScriptList extends SubGuiInterface { } protected void actionPerformed(GuiButton guibutton) { - GuiNpcButton button = (GuiNpcButton)guibutton; - if(button.id == 1 && this.scroll1.hasSelected()) { + GuiNpcButton button = (GuiNpcButton) guibutton; + if (button.id == 1 && this.scroll1.hasSelected()) { this.container.scripts.add(this.scroll1.getSelected()); this.scroll1.selected = -1; this.scroll2.selected = -1; this.initGui(); } - if(button.id == 2 && this.scroll2.hasSelected()) { + if (button.id == 2 && this.scroll2.hasSelected()) { this.container.scripts.remove(this.scroll2.getSelected()); this.scroll2.selected = -1; this.initGui(); } - if(button.id == 3) { + if (button.id == 3) { this.container.scripts.clear(); Iterator var3 = this.scripts.iterator(); - while(var3.hasNext()) { - String script = (String)var3.next(); + while (var3.hasNext()) { + String script = (String) var3.next(); this.container.scripts.add(script); } @@ -89,14 +89,14 @@ public class EventGuiScriptList extends SubGuiInterface { this.initGui(); } - if(button.id == 4) { + if (button.id == 4) { this.container.scripts.clear(); this.scroll1.selected = -1; this.scroll2.selected = -1; this.initGui(); } - if(button.id == 66) { + if (button.id == 66) { this.close(); } diff --git a/src/main/java/noppes/npcs/client/gui/script/GuiNPCEventScripts.java b/src/main/java/noppes/npcs/client/gui/script/GuiNPCEventScripts.java index 2a2420a83..282ffe792 100644 --- a/src/main/java/noppes/npcs/client/gui/script/GuiNPCEventScripts.java +++ b/src/main/java/noppes/npcs/client/gui/script/GuiNPCEventScripts.java @@ -52,7 +52,7 @@ public class GuiNPCEventScripts extends GuiScriptInterface { script.getScripts().add(new ScriptContainer(script)); } } - script.getScripts().set(tab,container); + script.getScripts().set(tab, container); initGui(); } } diff --git a/src/main/java/noppes/npcs/client/gui/script/GuiScriptAllNPCs.java b/src/main/java/noppes/npcs/client/gui/script/GuiScriptAllNPCs.java index c4220720a..8e3f11894 100644 --- a/src/main/java/noppes/npcs/client/gui/script/GuiScriptAllNPCs.java +++ b/src/main/java/noppes/npcs/client/gui/script/GuiScriptAllNPCs.java @@ -48,7 +48,7 @@ public class GuiScriptAllNPCs extends GuiScriptInterface { script.getScripts().add(new ScriptContainer(script)); } } - script.getScripts().set(tab,container); + script.getScripts().set(tab, container); initGui(); } } diff --git a/src/main/java/noppes/npcs/client/gui/script/GuiScriptBlock.java b/src/main/java/noppes/npcs/client/gui/script/GuiScriptBlock.java index d9cf8ff6c..5f9744c03 100644 --- a/src/main/java/noppes/npcs/client/gui/script/GuiScriptBlock.java +++ b/src/main/java/noppes/npcs/client/gui/script/GuiScriptBlock.java @@ -5,7 +5,6 @@ import net.minecraft.nbt.NBTTagCompound; import noppes.npcs.blocks.tiles.TileScripted; - public class GuiScriptBlock extends GuiScriptInterface { private TileScripted tileScripted; diff --git a/src/main/java/noppes/npcs/client/gui/script/GuiScriptEffect.java b/src/main/java/noppes/npcs/client/gui/script/GuiScriptEffect.java index d686ef5f5..7cc692a8e 100644 --- a/src/main/java/noppes/npcs/client/gui/script/GuiScriptEffect.java +++ b/src/main/java/noppes/npcs/client/gui/script/GuiScriptEffect.java @@ -10,11 +10,9 @@ import net.minecraft.nbt.NBTTagList; import net.minecraft.util.StatCollector; import noppes.npcs.NBTTags; import noppes.npcs.NoppesStringUtils; -import noppes.npcs.client.NoppesUtil; import noppes.npcs.client.gui.global.GuiNPCManageEffects; import noppes.npcs.client.gui.util.*; import noppes.npcs.controllers.ScriptContainer; -import noppes.npcs.controllers.ScriptController; import noppes.npcs.controllers.data.CustomEffect; import noppes.npcs.controllers.data.EffectScript; @@ -51,16 +49,16 @@ public class GuiScriptEffect extends GuiNPCInterface implements GuiYesNoCallback } public void initGui() { - this.ySize = (int)((double)this.xSize * 0.56); - if ((double)this.ySize > (double)this.height * 0.95) { - this.ySize = (int)((double)this.height * 0.95); - this.xSize = (int)((double)this.ySize / 0.56); + this.ySize = (int) ((double) this.xSize * 0.56); + if ((double) this.ySize > (double) this.height * 0.95) { + this.ySize = (int) ((double) this.height * 0.95); + this.xSize = (int) ((double) this.ySize / 0.56); } - this.bgScale = (float)this.xSize / 400.0F; + this.bgScale = (float) this.xSize / 400.0F; super.initGui(); this.guiTop += 10; - int yoffset = (int)((double)this.ySize * 0.02); + int yoffset = (int) ((double) this.ySize * 0.02); GuiMenuTopButton top; this.addTopButton(top = new GuiMenuTopButton(0, this.guiLeft + 4, this.guiTop - 17, "gui.settings")); int topXoffset = 0; @@ -94,7 +92,7 @@ public class GuiScriptEffect extends GuiNPCInterface implements GuiYesNoCallback hookLabel.color = 11184810; this.addLabel(hookLabel); ScriptContainer container = this.scriptHandler.container; - GuiScriptTextArea ta = new GuiScriptTextArea(this, 2, this.guiLeft + 1 + yoffset, this.guiTop + yoffset, this.xSize - 108 - yoffset, (int)((double)this.ySize * 0.96) - yoffset * 2, container == null ? "" : container.script); + GuiScriptTextArea ta = new GuiScriptTextArea(this, 2, this.guiLeft + 1 + yoffset, this.guiTop + yoffset, this.xSize - 108 - yoffset, (int) ((double) this.ySize * 0.96) - yoffset * 2, container == null ? "" : container.script); ta.enableCodeHighlighting(); ta.setListener(this); this.addTextField(ta); @@ -108,7 +106,7 @@ public class GuiScriptEffect extends GuiNPCInterface implements GuiYesNoCallback this.getButton(107).enabled = false; GuiCustomScroll scroll = (new GuiCustomScroll(this, 0)).setUnselectable(); - scroll.setSize(100, (int)((double)this.ySize * 0.54) - yoffset * 2); + scroll.setSize(100, (int) ((double) this.ySize * 0.54) - yoffset * 2); scroll.guiLeft = left1; scroll.guiTop = this.guiTop + 88 + yoffset; if (container != null) { @@ -117,7 +115,7 @@ public class GuiScriptEffect extends GuiNPCInterface implements GuiYesNoCallback this.addScroll(scroll); } else { - GuiNpcTextArea var8 = new GuiNpcTextArea(2, this, this.guiLeft + 4 + yoffset, this.guiTop + 6 + yoffset, this.xSize - 160 - yoffset, (int)((float)this.ySize * 0.92F) - yoffset * 2, this.getConsoleText()); + GuiNpcTextArea var8 = new GuiNpcTextArea(2, this, this.guiLeft + 4 + yoffset, this.guiTop + 6 + yoffset, this.xSize - 160 - yoffset, (int) ((float) this.ySize * 0.92F) - yoffset * 2, this.getConsoleText()); var8.enabled = false; this.addTextField(var8); int var9 = this.guiLeft + this.xSize - 150; @@ -164,9 +162,9 @@ public class GuiScriptEffect extends GuiNPCInterface implements GuiYesNoCallback StringBuilder builder = new StringBuilder(); Iterator var3 = map.entrySet().iterator(); - while(var3.hasNext()) { - Map.Entry entry = (Map.Entry)var3.next(); - builder.insert(0, new Date((Long)entry.getKey()) + (String)entry.getValue() + "\n"); + while (var3.hasNext()) { + Map.Entry entry = (Map.Entry) var3.next(); + builder.insert(0, new Date((Long) entry.getKey()) + (String) entry.getValue() + "\n"); } return builder.toString(); @@ -175,8 +173,8 @@ public class GuiScriptEffect extends GuiNPCInterface implements GuiYesNoCallback private int getScriptIndex() { int i = 0; - for(Iterator var2 = this.languages.keySet().iterator(); var2.hasNext(); ++i) { - String language = (String)var2.next(); + for (Iterator var2 = this.languages.keySet().iterator(); var2.hasNext(); ++i) { + String language = (String) var2.next(); if (language.equalsIgnoreCase(this.scriptHandler.getLanguage())) { return i; } @@ -280,11 +278,11 @@ public class GuiScriptEffect extends GuiNPCInterface implements GuiYesNoCallback } if (guibutton.id == 104) { - this.scriptHandler.setEnabled(((GuiNpcButton)guibutton).getValue() == 1); + this.scriptHandler.setEnabled(((GuiNpcButton) guibutton).getValue() == 1); } if (guibutton.id == 105) { - container1 = new GuiYesNo(this, "", ((GuiNpcButton)guibutton).displayString, 10); + container1 = new GuiYesNo(this, "", ((GuiNpcButton) guibutton).displayString, 10); this.displayGuiScreen(container1); } @@ -335,12 +333,12 @@ public class GuiScriptEffect extends GuiNPCInterface implements GuiYesNoCallback NBTTagList data = compound.getTagList("Languages", 10); HashMap languages = new HashMap(); - for(int i = 0; i < data.tagCount(); ++i) { + for (int i = 0; i < data.tagCount(); ++i) { NBTTagCompound comp = data.getCompoundTagAt(i); ArrayList scripts = new ArrayList(); NBTTagList list = comp.getTagList("Scripts", 8); - for(int j = 0; j < list.tagCount(); ++j) { + for (int j = 0; j < list.tagCount(); ++j) { scripts.add(list.getStringTagAt(j)); } diff --git a/src/main/java/noppes/npcs/client/gui/script/GuiScriptForge.java b/src/main/java/noppes/npcs/client/gui/script/GuiScriptForge.java index d26499219..6c1175e71 100644 --- a/src/main/java/noppes/npcs/client/gui/script/GuiScriptForge.java +++ b/src/main/java/noppes/npcs/client/gui/script/GuiScriptForge.java @@ -39,17 +39,17 @@ public class GuiScriptForge extends GuiScriptInterface { e.printStackTrace(); } - for(ClassPath.ClassInfo e1 : list){ + for (ClassPath.ClassInfo e1 : list) { ClassPath.ClassInfo classLoader = e1; Class infoClass = classLoader.load(); ArrayList c = new ArrayList(Arrays.asList(infoClass.getDeclaredClasses())); - if(c.isEmpty()) { + if (c.isEmpty()) { c.add(infoClass); } Iterator var10 = c.iterator(); - while(var10.hasNext()) { + while (var10.hasNext()) { Class c1 = (Class) var10.next(); - if(!EntityEvent.EntityConstructing.class.isAssignableFrom(c1) && !WorldEvent.PotentialSpawns.class.isAssignableFrom(c1) && !TickEvent.RenderTickEvent.class.isAssignableFrom(c1) && !TickEvent.ClientTickEvent.class.isAssignableFrom(c1) && !FMLNetworkEvent.ClientCustomPacketEvent.class.isAssignableFrom(c1) && !ItemTooltipEvent.class.isAssignableFrom(c1) && Event.class.isAssignableFrom(c1) && !Modifier.isAbstract(c1.getModifiers()) && Modifier.isPublic(c1.getModifiers()) && !ChunkEvent.class.isAssignableFrom(c1) && !ChunkWatchEvent.class.isAssignableFrom(c1) && !ChunkDataEvent.class.isAssignableFrom(c1)) { + if (!EntityEvent.EntityConstructing.class.isAssignableFrom(c1) && !WorldEvent.PotentialSpawns.class.isAssignableFrom(c1) && !TickEvent.RenderTickEvent.class.isAssignableFrom(c1) && !TickEvent.ClientTickEvent.class.isAssignableFrom(c1) && !FMLNetworkEvent.ClientCustomPacketEvent.class.isAssignableFrom(c1) && !ItemTooltipEvent.class.isAssignableFrom(c1) && Event.class.isAssignableFrom(c1) && !Modifier.isAbstract(c1.getModifiers()) && Modifier.isPublic(c1.getModifiers()) && !ChunkEvent.class.isAssignableFrom(c1) && !ChunkWatchEvent.class.isAssignableFrom(c1) && !ChunkDataEvent.class.isAssignableFrom(c1)) { String eventName = c1.getName(); int i = eventName.lastIndexOf("."); eventName = StringUtils.uncapitalize(eventName.substring(i + 1).replace("$", "")); @@ -78,7 +78,7 @@ public class GuiScriptForge extends GuiScriptInterface { script.getScripts().add(new ScriptContainer(script)); } } - script.getScripts().set(tab,container); + script.getScripts().set(tab, container); initGui(); } } diff --git a/src/main/java/noppes/npcs/client/gui/script/GuiScriptGlobal.java b/src/main/java/noppes/npcs/client/gui/script/GuiScriptGlobal.java index 0683ef87c..15aec96dd 100644 --- a/src/main/java/noppes/npcs/client/gui/script/GuiScriptGlobal.java +++ b/src/main/java/noppes/npcs/client/gui/script/GuiScriptGlobal.java @@ -14,7 +14,7 @@ import java.util.HashMap; public class GuiScriptGlobal extends GuiNPCInterface implements IGuiData { private final ResourceLocation resource = new ResourceLocation("customnpcs", "textures/gui/smallbg.png"); - private HashMap> scriptGuiClasses = new HashMap<>(); + private HashMap> scriptGuiClasses = new HashMap<>(); public GuiScriptGlobal() { this.xSize = 176; @@ -48,7 +48,7 @@ public class GuiScriptGlobal extends GuiNPCInterface implements IGuiData { //For examples of what kind of GUI class to create, look at GuiScriptForge. public void addScriptGui(Class guiClass, String buttonText, boolean enabled) { int buttonId = this.buttons.size(); - this.scriptGuiClasses.put(buttonId,guiClass); + this.scriptGuiClasses.put(buttonId, guiClass); GuiNpcButton npcButton = new GuiNpcButton(buttonId, this.guiLeft + 38, this.guiTop + 80 + (buttonId - 2) * 30, 100, 20, buttonText); npcButton.setEnabled(enabled); @@ -77,7 +77,8 @@ public class GuiScriptGlobal extends GuiNPCInterface implements IGuiData { try { Class guiClass = this.scriptGuiClasses.get(guibutton.id); this.displayGuiScreen((GuiScreen) guiClass.newInstance()); - } catch (Exception ignored) {} + } catch (Exception ignored) { + } } } diff --git a/src/main/java/noppes/npcs/client/gui/script/GuiScriptInterface.java b/src/main/java/noppes/npcs/client/gui/script/GuiScriptInterface.java index dabf86bf8..a0f1d3f1a 100644 --- a/src/main/java/noppes/npcs/client/gui/script/GuiScriptInterface.java +++ b/src/main/java/noppes/npcs/client/gui/script/GuiScriptInterface.java @@ -35,50 +35,50 @@ public class GuiScriptInterface extends GuiNPCInterface implements GuiYesNoCallb public void initGui() { //this.xSize = (int)((double)this.width * 0.88D); - this.ySize = (int)((double)this.xSize * 0.56D); - if((double)this.ySize > (double)this.height * 0.95D) { - this.ySize = (int)((double)this.height * 0.95D); - this.xSize = (int)((double)this.ySize / 0.56D); + this.ySize = (int) ((double) this.xSize * 0.56D); + if ((double) this.ySize > (double) this.height * 0.95D) { + this.ySize = (int) ((double) this.height * 0.95D); + this.xSize = (int) ((double) this.ySize / 0.56D); } - this.bgScale = (float)this.xSize / 400.0F; + this.bgScale = (float) this.xSize / 400.0F; super.initGui(); this.guiTop += 10; - int yoffset = (int)((double)this.ySize * 0.02D); + int yoffset = (int) ((double) this.ySize * 0.02D); GuiMenuTopButton top; this.addTopButton(top = new GuiMenuTopButton(0, this.guiLeft + 4, this.guiTop - 17, "gui.settings")); int topXoffset = 0; int topYoffset = 0; - for(int ta = 0; ta < this.handler.getScripts().size(); ++ta) { - if(ta%20 == 0 && ta > 0) { + for (int ta = 0; ta < this.handler.getScripts().size(); ++ta) { + if (ta % 20 == 0 && ta > 0) { topYoffset -= 20; - topXoffset -= top.width+20*22; + topXoffset -= top.width + 20 * 22; } - this.addTopButton(top = new GuiMenuTopButton(ta + 1, top.xPosition+top.width + topXoffset, top.yPosition + topYoffset, ta + 1 + "")); + this.addTopButton(top = new GuiMenuTopButton(ta + 1, top.xPosition + top.width + topXoffset, top.yPosition + topYoffset, ta + 1 + "")); topXoffset = 0; topYoffset = 0; scriptLimit = ta + 2; } - if(this.handler.getScripts().size() < 100) - this.addTopButton(new GuiMenuTopButton(scriptLimit, top.xPosition+top.width, top.yPosition, "+")); + if (this.handler.getScripts().size() < 100) + this.addTopButton(new GuiMenuTopButton(scriptLimit, top.xPosition + top.width, top.yPosition, "+")); top = this.getTopButton(this.activeTab); - if(top == null) { + if (top == null) { this.activeTab = 0; top = this.getTopButton(0); } top.active = true; - if(this.activeTab > 0) { + if (this.activeTab > 0) { GuiCustomScroll hooks = new GuiCustomScroll(this, 1); hooks.allowUserInput = false; hooks.setSize(108, 198); hooks.guiLeft = guiLeft - 110; hooks.guiTop = guiTop + 14; - if(handler instanceof ForgeDataScript) { + if (handler instanceof ForgeDataScript) { hooks.setSize(238, 198); hooks.guiLeft = guiLeft - 240; } @@ -89,8 +89,8 @@ public class GuiScriptInterface extends GuiNPCInterface implements GuiYesNoCallb hookLabel.color = 0xaaaaaa; addLabel(hookLabel); - ScriptContainer container = (ScriptContainer)this.handler.getScripts().get(this.activeTab - 1); - GuiScriptTextArea ta = new GuiScriptTextArea(this,2, guiLeft + 1 + yoffset, guiTop + yoffset, xSize - 108 - yoffset, (int) (ySize * 0.96) - yoffset * 2, container == null?"":container.script); + ScriptContainer container = (ScriptContainer) this.handler.getScripts().get(this.activeTab - 1); + GuiScriptTextArea ta = new GuiScriptTextArea(this, 2, guiLeft + 1 + yoffset, guiTop + yoffset, xSize - 108 - yoffset, (int) (ySize * 0.96) - yoffset * 2, container == null ? "" : container.script); ta.enableCodeHighlighting(); ta.setListener(this); @@ -103,16 +103,16 @@ public class GuiScriptInterface extends GuiNPCInterface implements GuiYesNoCallb this.addButton(new GuiNpcButton(105, left1 + 61, this.guiTop + 21 + yoffset, 60, 20, "gui.remove")); this.addButton(new GuiNpcButton(107, left1, this.guiTop + 66 + yoffset, 80, 20, "script.loadscript")); GuiCustomScroll scroll = (new GuiCustomScroll(this, 0)).setUnselectable(); - scroll.setSize(100, (int)((double)this.ySize * 0.54D) - yoffset * 2); + scroll.setSize(100, (int) ((double) this.ySize * 0.54D) - yoffset * 2); scroll.guiLeft = left1; scroll.guiTop = this.guiTop + 88 + yoffset; - if(container != null) { + if (container != null) { scroll.setList(container.scripts); } this.addScroll(scroll); } else { - GuiNpcTextArea var8 = new GuiNpcTextArea(2, this, this.guiLeft + 4 + yoffset, this.guiTop + 6 + yoffset, this.xSize - 160 - yoffset, (int)((float)this.ySize * 0.92F) - yoffset * 2, this.getConsoleText()); + GuiNpcTextArea var8 = new GuiNpcTextArea(2, this, this.guiLeft + 4 + yoffset, this.guiTop + 6 + yoffset, this.xSize - 160 - yoffset, (int) ((float) this.ySize * 0.92F) - yoffset * 2, this.getConsoleText()); var8.canEdit = false; var8.setFocused(true); this.addTextField(var8); @@ -120,11 +120,11 @@ public class GuiScriptInterface extends GuiNPCInterface implements GuiYesNoCallb this.addButton(new GuiNpcButton(100, var9, this.guiTop + 125, 60, 20, "gui.copy")); this.addButton(new GuiNpcButton(102, var9, this.guiTop + 146, 60, 20, "gui.clear")); this.addLabel(new GuiNpcLabel(1, "script.language", var9, this.guiTop + 15)); - this.addButton(new GuiNpcButton(103, var9 + 60, this.guiTop + 10, 80, 20, (String[])this.languages.keySet().toArray(new String[this.languages.keySet().size()]), this.getScriptIndex())); + this.addButton(new GuiNpcButton(103, var9 + 60, this.guiTop + 10, 80, 20, (String[]) this.languages.keySet().toArray(new String[this.languages.keySet().size()]), this.getScriptIndex())); this.getButton(103).enabled = this.languages.size() > 0; this.addLabel(new GuiNpcLabel(2, "gui.enabled", var9, this.guiTop + 36)); - this.addButton(new GuiNpcButton(104, var9 + 60, this.guiTop + 31, 50, 20, new String[]{"gui.no", "gui.yes"}, this.handler.getEnabled()?1:0)); - if(this.player.worldObj.isRemote) { + this.addButton(new GuiNpcButton(104, var9 + 60, this.guiTop + 31, 50, 20, new String[]{"gui.no", "gui.yes"}, this.handler.getEnabled() ? 1 : 0)); + if (this.player.worldObj.isRemote) { this.addButton(new GuiNpcButton(106, var9, this.guiTop + 55, 150, 20, "script.openfolder")); } @@ -139,16 +139,17 @@ public class GuiScriptInterface extends GuiNPCInterface implements GuiYesNoCallb } public String previousHookClicked = ""; + @Override public void customScrollClicked(int i, int j, int k, GuiCustomScroll scroll) { String hook = scroll.getSelected(); - if(previousHookClicked.equals(hook)){ + if (previousHookClicked.equals(hook)) { String addString = ""; - if(!this.getTextField(2).getText().isEmpty()) + if (!this.getTextField(2).getText().isEmpty()) addString += "\n"; - addString += "function "+hook+"(event) {\n \n}\n"; + addString += "function " + hook + "(event) {\n \n}\n"; - this.getTextField(2).setText(this.getTextField(2).getText()+addString); + this.getTextField(2).setText(this.getTextField(2).getText() + addString); previousHookClicked = ""; } else { previousHookClicked = hook; @@ -165,9 +166,9 @@ public class GuiScriptInterface extends GuiNPCInterface implements GuiYesNoCallb StringBuilder builder = new StringBuilder(); Iterator var3 = map.entrySet().iterator(); - while(var3.hasNext()) { - Entry entry = (Entry)var3.next(); - builder.insert(0, new Date((Long)entry.getKey()) + (String)entry.getValue() + "\n"); + while (var3.hasNext()) { + Entry entry = (Entry) var3.next(); + builder.insert(0, new Date((Long) entry.getKey()) + (String) entry.getValue() + "\n"); } return builder.toString(); @@ -176,9 +177,9 @@ public class GuiScriptInterface extends GuiNPCInterface implements GuiYesNoCallb private int getScriptIndex() { int i = 0; - for(Iterator var2 = this.languages.keySet().iterator(); var2.hasNext(); ++i) { - String language = (String)var2.next(); - if(language.equalsIgnoreCase(this.handler.getLanguage())) { + for (Iterator var2 = this.languages.keySet().iterator(); var2.hasNext(); ++i) { + String language = (String) var2.next(); + if (language.equalsIgnoreCase(this.handler.getLanguage())) { return i; } } @@ -187,34 +188,34 @@ public class GuiScriptInterface extends GuiNPCInterface implements GuiYesNoCallb } public void confirmClicked(boolean flag, int i) { - if(flag) { - if(i == 0) { + if (flag) { + if (i == 0) { this.openLink("https://www.curseforge.com/minecraft/mc-mods/customnpc-plus"); } - if(i == 1) { + if (i == 1) { this.openLink("https://kamkeel.github.io/CustomNPC-Plus/"); } - if(i == 2) { + if (i == 2) { this.openLink("https://kamkeel.github.io/CustomNPC-Plus/"); } - if(i == 3) { + if (i == 3) { this.openLink("http://www.minecraftforge.net/forum/index.php/board,122.0.html"); } - if(i == 10) { + if (i == 10) { this.handler.getScripts().remove(this.activeTab - 1); this.activeTab = 0; } - if(i == 101) { + if (i == 101) { (this.getTextField(2)).setText(NoppesStringUtils.getClipboardContents()); this.setScript(); } - if(i == 102) { + if (i == 102) { ScriptContainer container; - if(this.activeTab > 0) { - container = (ScriptContainer)this.handler.getScripts().get(this.activeTab - 1); + if (this.activeTab > 0) { + container = (ScriptContainer) this.handler.getScripts().get(this.activeTab - 1); container.script = ""; } else { this.handler.clearConsole(); @@ -231,80 +232,80 @@ public class GuiScriptInterface extends GuiNPCInterface implements GuiYesNoCallb @Override protected void actionPerformed(GuiButton guibutton) { - if(guibutton.id >= 0 && guibutton.id < scriptLimit) { + if (guibutton.id >= 0 && guibutton.id < scriptLimit) { this.setScript(); this.activeTab = guibutton.id; this.initGui(); } - if(guibutton.id == scriptLimit) { + if (guibutton.id == scriptLimit) { this.handler.getScripts().add(new ScriptContainer(this.handler)); this.activeTab = this.handler.getScripts().size(); this.initGui(); } - if(guibutton.id == 109) { + if (guibutton.id == 109) { this.displayGuiScreen(new GuiConfirmOpenLink(this, "https://kamkeel.github.io/CustomNPC-Plus/", 0, true)); } - if(guibutton.id == 110) { + if (guibutton.id == 110) { this.displayGuiScreen(new GuiConfirmOpenLink(this, "https://github.com/KAMKEEL/CustomNPC-Plus-API", 1, true)); } - if(guibutton.id == 111) { + if (guibutton.id == 111) { this.displayGuiScreen(new GuiConfirmOpenLink(this, "https://github.com/Noppes/CustomNPCsAPI", 2, true)); } - if(guibutton.id == 112) { + if (guibutton.id == 112) { this.displayGuiScreen(new GuiConfirmOpenLink(this, "http://www.minecraftforge.net/forum/index.php/board,122.0.html", 3, true)); } - if(guibutton.id == 100) { + if (guibutton.id == 100) { NoppesStringUtils.setClipboardContents((this.getTextField(2)).getText()); } - if(guibutton.id == 101) { + if (guibutton.id == 101) { GuiYesNo guiyesno = new GuiYesNo(this, StatCollector.translateToLocal("gui.paste"), StatCollector.translateToLocal("gui.sure"), 101); displayGuiScreen(guiyesno); } ScriptContainer container; - if(guibutton.id == 102) { + if (guibutton.id == 102) { GuiYesNo guiyesno = new GuiYesNo(this, StatCollector.translateToLocal("gui.clear"), StatCollector.translateToLocal("gui.sure"), 102); displayGuiScreen(guiyesno); } - if(guibutton.id == 103) { - this.handler.setLanguage(((GuiNpcButton)guibutton).displayString); + if (guibutton.id == 103) { + this.handler.setLanguage(((GuiNpcButton) guibutton).displayString); } - if(guibutton.id == 104) { - this.handler.setEnabled((((GuiNpcButton)guibutton).getValue() == 1)); + if (guibutton.id == 104) { + this.handler.setEnabled((((GuiNpcButton) guibutton).getValue() == 1)); } - if(guibutton.id == 105) { - GuiYesNo container1 = new GuiYesNo(this, "", ((GuiNpcButton)guibutton).displayString, 10); + if (guibutton.id == 105) { + GuiYesNo container1 = new GuiYesNo(this, "", ((GuiNpcButton) guibutton).displayString, 10); this.displayGuiScreen(container1); } - if(guibutton.id == 106) { + if (guibutton.id == 106) { NoppesUtil.openFolder(ScriptController.Instance.dir); } - if(guibutton.id == 107) { - container = (ScriptContainer)this.handler.getScripts().get(this.activeTab - 1); - if(container == null) { + if (guibutton.id == 107) { + container = (ScriptContainer) this.handler.getScripts().get(this.activeTab - 1); + if (container == null) { this.handler.getScripts().add(container = new ScriptContainer(this.handler)); } - this.setSubGui(new EventGuiScriptList((List)this.languages.get(this.handler.getLanguage()), container)); + this.setSubGui(new EventGuiScriptList((List) this.languages.get(this.handler.getLanguage()), container)); } } private void setScript() { - if(this.activeTab > 0) { - ScriptContainer container = (ScriptContainer)this.handler.getScripts().get(this.activeTab - 1); - if(container == null) { + if (this.activeTab > 0) { + ScriptContainer container = (ScriptContainer) this.handler.getScripts().get(this.activeTab - 1); + if (container == null) { this.handler.getScripts().add(container = new ScriptContainer(this.handler)); } @@ -320,12 +321,12 @@ public class GuiScriptInterface extends GuiNPCInterface implements GuiYesNoCallb NBTTagList data = compound.getTagList("Languages", 10); HashMap languages = new HashMap(); - for(int i = 0; i < data.tagCount(); ++i) { + for (int i = 0; i < data.tagCount(); ++i) { NBTTagCompound comp = data.getCompoundTagAt(i); ArrayList scripts = new ArrayList(); NBTTagList list = comp.getTagList("Scripts", 8); - for(int j = 0; j < list.tagCount(); ++j) { + for (int j = 0; j < list.tagCount(); ++j) { scripts.add(list.getStringTagAt(j)); } @@ -341,8 +342,8 @@ public class GuiScriptInterface extends GuiNPCInterface implements GuiYesNoCallb } public void textUpdate(String text) { - ScriptContainer container = (ScriptContainer)this.handler.getScripts().get(this.activeTab - 1); - if(container != null) { + ScriptContainer container = (ScriptContainer) this.handler.getScripts().get(this.activeTab - 1); + if (container != null) { container.script = text; } @@ -351,7 +352,7 @@ public class GuiScriptInterface extends GuiNPCInterface implements GuiYesNoCallb @Override public void saveText(String text) { ScriptContainer container = handler.getScripts().get(activeTab); - if(container != null) + if (container != null) container.script = text; initGui(); } diff --git a/src/main/java/noppes/npcs/client/gui/script/GuiScriptItem.java b/src/main/java/noppes/npcs/client/gui/script/GuiScriptItem.java index 2880df5d8..6f3ad27ea 100644 --- a/src/main/java/noppes/npcs/client/gui/script/GuiScriptItem.java +++ b/src/main/java/noppes/npcs/client/gui/script/GuiScriptItem.java @@ -37,11 +37,10 @@ public class GuiScriptItem extends GuiScriptInterface { } public void setGuiData(NBTTagCompound compound) { - if(compound.hasKey("ItemScriptConsole")){ + if (compound.hasKey("ItemScriptConsole")) { consoleText = NBTTags.GetLongStringMap(compound.getTagList("ItemScriptConsole", 10)); initGui(); - } - else { + } else { this.item.setMCNbt(compound); this.item.loadScriptData(); super.setGuiData(compound); @@ -58,17 +57,17 @@ public class GuiScriptItem extends GuiScriptInterface { StringBuilder builder = new StringBuilder(); Iterator var3 = map.entrySet().iterator(); - while(var3.hasNext()) { - Map.Entry entry = (Map.Entry)var3.next(); - builder.insert(0, new Date((Long)entry.getKey()) + (String)entry.getValue() + "\n"); + while (var3.hasNext()) { + Map.Entry entry = (Map.Entry) var3.next(); + builder.insert(0, new Date((Long) entry.getKey()) + (String) entry.getValue() + "\n"); } return builder.toString(); } public void confirmClicked(boolean flag, int i) { - if(i == 102) { - if (activeTab <= 0){ + if (i == 102) { + if (activeTab <= 0) { consoleText = new HashMap<>(); ItemScriptErrorPacket.Clear(); } diff --git a/src/main/java/noppes/npcs/client/gui/script/GuiScriptLinkedItem.java b/src/main/java/noppes/npcs/client/gui/script/GuiScriptLinkedItem.java index 0542a1bf5..dfb1b2900 100644 --- a/src/main/java/noppes/npcs/client/gui/script/GuiScriptLinkedItem.java +++ b/src/main/java/noppes/npcs/client/gui/script/GuiScriptLinkedItem.java @@ -62,16 +62,16 @@ public class GuiScriptLinkedItem extends GuiNPCInterface implements GuiYesNoCall } public void initGui() { - this.ySize = (int)((double)this.xSize * 0.56); - if ((double)this.ySize > (double)this.height * 0.95) { - this.ySize = (int)((double)this.height * 0.95); - this.xSize = (int)((double)this.ySize / 0.56); + this.ySize = (int) ((double) this.xSize * 0.56); + if ((double) this.ySize > (double) this.height * 0.95) { + this.ySize = (int) ((double) this.height * 0.95); + this.xSize = (int) ((double) this.ySize / 0.56); } - this.bgScale = (float)this.xSize / 400.0F; + this.bgScale = (float) this.xSize / 400.0F; super.initGui(); this.guiTop += 10; - int yoffset = (int)((double)this.ySize * 0.02); + int yoffset = (int) ((double) this.ySize * 0.02); GuiMenuTopButton top; this.addTopButton(top = new GuiMenuTopButton(0, this.guiLeft + 4, this.guiTop - 17, "gui.settings")); int topXoffset = 0; @@ -105,7 +105,7 @@ public class GuiScriptLinkedItem extends GuiNPCInterface implements GuiYesNoCall hookLabel.color = 11184810; this.addLabel(hookLabel); ScriptContainer container = this.scriptHandler.container; - GuiScriptTextArea ta = new GuiScriptTextArea(this, 2, this.guiLeft + 1 + yoffset, this.guiTop + yoffset, this.xSize - 108 - yoffset, (int)((double)this.ySize * 0.96) - yoffset * 2, container == null ? "" : container.script); + GuiScriptTextArea ta = new GuiScriptTextArea(this, 2, this.guiLeft + 1 + yoffset, this.guiTop + yoffset, this.xSize - 108 - yoffset, (int) ((double) this.ySize * 0.96) - yoffset * 2, container == null ? "" : container.script); ta.enableCodeHighlighting(); ta.setListener(this); this.addTextField(ta); @@ -119,7 +119,7 @@ public class GuiScriptLinkedItem extends GuiNPCInterface implements GuiYesNoCall this.getButton(107).enabled = false; GuiCustomScroll scroll = (new GuiCustomScroll(this, 0)).setUnselectable(); - scroll.setSize(100, (int)((double)this.ySize * 0.54) - yoffset * 2); + scroll.setSize(100, (int) ((double) this.ySize * 0.54) - yoffset * 2); scroll.guiLeft = left1; scroll.guiTop = this.guiTop + 88 + yoffset; if (container != null) { @@ -128,7 +128,7 @@ public class GuiScriptLinkedItem extends GuiNPCInterface implements GuiYesNoCall this.addScroll(scroll); } else { - GuiNpcTextArea var8 = new GuiNpcTextArea(2, this, this.guiLeft + 4 + yoffset, this.guiTop + 6 + yoffset, this.xSize - 160 - yoffset, (int)((float)this.ySize * 0.92F) - yoffset * 2, this.getConsoleText()); + GuiNpcTextArea var8 = new GuiNpcTextArea(2, this, this.guiLeft + 4 + yoffset, this.guiTop + 6 + yoffset, this.xSize - 160 - yoffset, (int) ((float) this.ySize * 0.92F) - yoffset * 2, this.getConsoleText()); var8.enabled = false; this.addTextField(var8); int var9 = this.guiLeft + this.xSize - 150; @@ -175,9 +175,9 @@ public class GuiScriptLinkedItem extends GuiNPCInterface implements GuiYesNoCall StringBuilder builder = new StringBuilder(); Iterator var3 = map.entrySet().iterator(); - while(var3.hasNext()) { - Map.Entry entry = (Map.Entry)var3.next(); - builder.insert(0, new Date((Long)entry.getKey()) + (String)entry.getValue() + "\n"); + while (var3.hasNext()) { + Map.Entry entry = (Map.Entry) var3.next(); + builder.insert(0, new Date((Long) entry.getKey()) + (String) entry.getValue() + "\n"); } return builder.toString(); @@ -186,8 +186,8 @@ public class GuiScriptLinkedItem extends GuiNPCInterface implements GuiYesNoCall private int getScriptIndex() { int i = 0; - for(Iterator var2 = this.languages.keySet().iterator(); var2.hasNext(); ++i) { - String language = (String)var2.next(); + for (Iterator var2 = this.languages.keySet().iterator(); var2.hasNext(); ++i) { + String language = (String) var2.next(); if (language.equalsIgnoreCase(this.scriptHandler.getLanguage())) { return i; } @@ -291,11 +291,11 @@ public class GuiScriptLinkedItem extends GuiNPCInterface implements GuiYesNoCall } if (guibutton.id == 104) { - this.scriptHandler.setEnabled(((GuiNpcButton)guibutton).getValue() == 1); + this.scriptHandler.setEnabled(((GuiNpcButton) guibutton).getValue() == 1); } if (guibutton.id == 105) { - container1 = new GuiYesNo(this, "", ((GuiNpcButton)guibutton).displayString, 10); + container1 = new GuiYesNo(this, "", ((GuiNpcButton) guibutton).displayString, 10); this.displayGuiScreen(container1); } @@ -346,12 +346,12 @@ public class GuiScriptLinkedItem extends GuiNPCInterface implements GuiYesNoCall NBTTagList data = compound.getTagList("Languages", 10); HashMap languages = new HashMap(); - for(int i = 0; i < data.tagCount(); ++i) { + for (int i = 0; i < data.tagCount(); ++i) { NBTTagCompound comp = data.getCompoundTagAt(i); ArrayList scripts = new ArrayList(); NBTTagList list = comp.getTagList("Scripts", 8); - for(int j = 0; j < list.tagCount(); ++j) { + for (int j = 0; j < list.tagCount(); ++j) { scripts.add(list.getStringTagAt(j)); } diff --git a/src/main/java/noppes/npcs/client/gui/script/GuiScriptPlayers.java b/src/main/java/noppes/npcs/client/gui/script/GuiScriptPlayers.java index ab9910159..5ff01dac8 100644 --- a/src/main/java/noppes/npcs/client/gui/script/GuiScriptPlayers.java +++ b/src/main/java/noppes/npcs/client/gui/script/GuiScriptPlayers.java @@ -11,7 +11,7 @@ import noppes.npcs.controllers.data.PlayerDataScript; import java.util.List; public class GuiScriptPlayers extends GuiScriptInterface { - private PlayerDataScript script = new PlayerDataScript((EntityPlayer)null); + private PlayerDataScript script = new PlayerDataScript((EntityPlayer) null); public GuiScriptPlayers() { hookList.add(EnumScriptType.INIT.function); @@ -99,7 +99,7 @@ public class GuiScriptPlayers extends GuiScriptInterface { script.getScripts().add(new ScriptContainer(script)); } } - script.getScripts().set(tab,container); + script.getScripts().set(tab, container); initGui(); } } diff --git a/src/main/java/noppes/npcs/client/gui/select/GuiDialogSelection.java b/src/main/java/noppes/npcs/client/gui/select/GuiDialogSelection.java index 7a94a046b..a98a80f4d 100644 --- a/src/main/java/noppes/npcs/client/gui/select/GuiDialogSelection.java +++ b/src/main/java/noppes/npcs/client/gui/select/GuiDialogSelection.java @@ -12,79 +12,79 @@ import java.util.HashMap; import java.util.List; public class GuiDialogSelection extends SubGuiInterface implements ICustomScrollListener { - private HashMap categoryData = new HashMap(); - private HashMap dialogData = new HashMap(); + private HashMap categoryData = new HashMap(); + private HashMap dialogData = new HashMap(); - private GuiCustomScroll scrollCategories; - private GuiCustomScroll scrollDialogs; + private GuiCustomScroll scrollCategories; + private GuiCustomScroll scrollDialogs; - private DialogCategory selectedCategory; - public Dialog selectedDialog; + private DialogCategory selectedCategory; + public Dialog selectedDialog; - private GuiSelectionListener listener; + private GuiSelectionListener listener; private String catSearch = ""; private String dialogSearch = ""; - public GuiDialogSelection(int dialog){ - drawDefaultBackground = false; - title = ""; - setBackground("menubg.png"); + public GuiDialogSelection(int dialog) { + drawDefaultBackground = false; + title = ""; + setBackground("menubg.png"); xSize = 366; ySize = 226; - this.selectedDialog = DialogController.Instance.dialogs.get(dialog); - if(selectedDialog != null) { - selectedCategory = selectedDialog.category; - } + this.selectedDialog = DialogController.Instance.dialogs.get(dialog); + if (selectedDialog != null) { + selectedCategory = selectedDialog.category; + } } @Override - public void initGui(){ + public void initGui() { super.initGui(); - if(parent instanceof GuiSelectionListener){ - listener = (GuiSelectionListener) parent; - } + if (parent instanceof GuiSelectionListener) { + listener = (GuiSelectionListener) parent; + } this.addLabel(new GuiNpcLabel(0, "gui.categories", guiLeft + 8, guiTop + 4)); this.addLabel(new GuiNpcLabel(1, "dialog.dialogs", guiLeft + 184, guiTop + 4)); this.addButton(new GuiNpcButton(2, guiLeft + xSize - 56, guiTop + ySize - 35, 50, 20, "gui.done")); this.addButton(new GuiNpcButton(3, guiLeft + xSize - 108, guiTop + ySize - 35, 50, 20, "gui.cancel")); - HashMap categoryData = new HashMap(); - HashMap dialogData = new HashMap(); + HashMap categoryData = new HashMap(); + HashMap dialogData = new HashMap(); - for(DialogCategory category : DialogController.Instance.categories.values()) { - categoryData.put(category.title, category); - } - this.categoryData = categoryData; + for (DialogCategory category : DialogController.Instance.categories.values()) { + categoryData.put(category.title, category); + } + this.categoryData = categoryData; - if(selectedCategory != null) { - for(Dialog dialog : selectedCategory.dialogs.values()) { - dialogData.put(dialog.title, dialog); - } - } - this.dialogData = dialogData; + if (selectedCategory != null) { + for (Dialog dialog : selectedCategory.dialogs.values()) { + dialogData.put(dialog.title, dialog); + } + } + this.dialogData = dialogData; - if(scrollCategories == null){ - scrollCategories = new GuiCustomScroll(this,0, 0); + if (scrollCategories == null) { + scrollCategories = new GuiCustomScroll(this, 0, 0); scrollCategories.setSize(177, 153); } scrollCategories.setList(getCatSearch()); - if(selectedCategory != null) { - scrollCategories.setSelected(selectedCategory.title); + if (selectedCategory != null) { + scrollCategories.setSelected(selectedCategory.title); } scrollCategories.guiLeft = guiLeft + 4; scrollCategories.guiTop = guiTop + 14; this.addScroll(scrollCategories); addTextField(new GuiNpcTextField(33, this, fontRendererObj, guiLeft + 4, guiTop + 169, 177, 20, catSearch)); - if(scrollDialogs == null){ - scrollDialogs = new GuiCustomScroll(this,1,0); - scrollDialogs.setSize(177, 153); + if (scrollDialogs == null) { + scrollDialogs = new GuiCustomScroll(this, 1, 0); + scrollDialogs.setSize(177, 153); } scrollDialogs.setList(getDialogSearch()); - if(selectedDialog != null) { - scrollDialogs.setSelected(selectedDialog.title); + if (selectedDialog != null) { + scrollDialogs.setSelected(selectedDialog.title); } scrollDialogs.guiLeft = guiLeft + 182; scrollDialogs.guiTop = guiTop + 14; @@ -93,21 +93,20 @@ public class GuiDialogSelection extends SubGuiInterface implements ICustomScroll } @Override - public void keyTyped(char c, int i) - { + public void keyTyped(char c, int i) { super.keyTyped(c, i); - if(getTextField(33) != null){ - if(getTextField(33).isFocused()){ - if(catSearch.equals(getTextField(33).getText())) + if (getTextField(33) != null) { + if (getTextField(33).isFocused()) { + if (catSearch.equals(getTextField(33).getText())) return; catSearch = getTextField(33).getText().toLowerCase(); scrollCategories.resetScroll(); scrollCategories.setList(getCatSearch()); } } - if(getTextField(44) != null){ - if(getTextField(44).isFocused()){ - if(dialogSearch.equals(getTextField(44).getText())) + if (getTextField(44) != null) { + if (getTextField(44).isFocused()) { + if (dialogSearch.equals(getTextField(44).getText())) return; dialogSearch = getTextField(44).getText().toLowerCase(); scrollDialogs.resetScroll(); @@ -116,72 +115,71 @@ public class GuiDialogSelection extends SubGuiInterface implements ICustomScroll } } - private List getCatSearch(){ - if(catSearch.isEmpty()){ + private List getCatSearch() { + if (catSearch.isEmpty()) { return Lists.newArrayList(categoryData.keySet()); } List list = new ArrayList(); - for(String name : Lists.newArrayList(categoryData.keySet())){ - if(name.toLowerCase().contains(catSearch)) + for (String name : Lists.newArrayList(categoryData.keySet())) { + if (name.toLowerCase().contains(catSearch)) list.add(name); } return list; } - private List getDialogSearch(){ - if(selectedCategory == null){ + private List getDialogSearch() { + if (selectedCategory == null) { return Lists.newArrayList(dialogData.keySet()); } - if(dialogSearch.isEmpty()){ + if (dialogSearch.isEmpty()) { return new ArrayList(Lists.newArrayList(dialogData.keySet())); } List list = new ArrayList(); - for(String name : Lists.newArrayList(dialogData.keySet())){ - if(name.toLowerCase().contains(dialogSearch)) + for (String name : Lists.newArrayList(dialogData.keySet())) { + if (name.toLowerCase().contains(dialogSearch)) list.add(name); } return list; } - @Override - public void customScrollClicked(int i, int j, int k, GuiCustomScroll guiCustomScroll) { - if(guiCustomScroll.id == 0){ - selectedCategory = categoryData.get(scrollCategories.getSelected()); - selectedDialog = null; - scrollDialogs.selected = -1; + @Override + public void customScrollClicked(int i, int j, int k, GuiCustomScroll guiCustomScroll) { + if (guiCustomScroll.id == 0) { + selectedCategory = categoryData.get(scrollCategories.getSelected()); + selectedDialog = null; + scrollDialogs.selected = -1; scrollDialogs.resetScroll(); getTextField(44).setText(""); dialogSearch = ""; - } - if(guiCustomScroll.id == 1){ - selectedDialog = dialogData.get(scrollDialogs.getSelected()); - } - initGui(); - } - - @Override - public void customScrollDoubleClicked(String selection, GuiCustomScroll scroll) { - if(selectedDialog == null) - return; - if(listener != null) { - listener.selected(selectedDialog.id, selectedDialog.title); - } - close(); - } + } + if (guiCustomScroll.id == 1) { + selectedDialog = dialogData.get(scrollDialogs.getSelected()); + } + initGui(); + } @Override - protected void actionPerformed(GuiButton guibutton){ - int id = guibutton.id; - if(id == 2){ - if(selectedDialog != null) { + public void customScrollDoubleClicked(String selection, GuiCustomScroll scroll) { + if (selectedDialog == null) + return; + if (listener != null) { + listener.selected(selectedDialog.id, selectedDialog.title); + } + close(); + } + + @Override + protected void actionPerformed(GuiButton guibutton) { + int id = guibutton.id; + if (id == 2) { + if (selectedDialog != null) { customScrollDoubleClicked(null, null); - } - else { + } else { close(); } } - if(id == 3){ + if (id == 3) { close(); } } diff --git a/src/main/java/noppes/npcs/client/gui/select/GuiQuestSelection.java b/src/main/java/noppes/npcs/client/gui/select/GuiQuestSelection.java index 5fa1fda5c..58548069c 100644 --- a/src/main/java/noppes/npcs/client/gui/select/GuiQuestSelection.java +++ b/src/main/java/noppes/npcs/client/gui/select/GuiQuestSelection.java @@ -12,79 +12,79 @@ import java.util.HashMap; import java.util.List; public class GuiQuestSelection extends SubGuiInterface implements ICustomScrollListener { - private HashMap categoryData = new HashMap(); - private HashMap questData = new HashMap(); + private HashMap categoryData = new HashMap(); + private HashMap questData = new HashMap(); - private GuiCustomScroll scrollCategories; - private GuiCustomScroll scrollQuests; + private GuiCustomScroll scrollCategories; + private GuiCustomScroll scrollQuests; - private QuestCategory selectedCategory; - public Quest selectedQuest; + private QuestCategory selectedCategory; + public Quest selectedQuest; - private GuiSelectionListener listener; + private GuiSelectionListener listener; private String catSearch = ""; private String questSearch = ""; - public GuiQuestSelection(int quest){ - drawDefaultBackground = false; - title = ""; - setBackground("menubg.png"); + public GuiQuestSelection(int quest) { + drawDefaultBackground = false; + title = ""; + setBackground("menubg.png"); xSize = 366; ySize = 226; - this.selectedQuest = QuestController.Instance.quests.get(quest); - if(selectedQuest != null) { - selectedCategory = selectedQuest.category; - } + this.selectedQuest = QuestController.Instance.quests.get(quest); + if (selectedQuest != null) { + selectedCategory = selectedQuest.category; + } } @Override - public void initGui(){ + public void initGui() { super.initGui(); - if(parent instanceof GuiSelectionListener){ - listener = (GuiSelectionListener) parent; - } + if (parent instanceof GuiSelectionListener) { + listener = (GuiSelectionListener) parent; + } this.addLabel(new GuiNpcLabel(0, "gui.categories", guiLeft + 8, guiTop + 4)); this.addLabel(new GuiNpcLabel(1, "quest.quests", guiLeft + 184, guiTop + 4)); this.addButton(new GuiNpcButton(2, guiLeft + xSize - 56, guiTop + ySize - 35, 50, 20, "gui.done")); this.addButton(new GuiNpcButton(3, guiLeft + xSize - 108, guiTop + ySize - 35, 50, 20, "gui.cancel")); - HashMap categoryData = new HashMap(); - HashMap questData = new HashMap(); + HashMap categoryData = new HashMap(); + HashMap questData = new HashMap(); - for(QuestCategory category : QuestController.Instance.categories.values()) { - categoryData.put(category.title, category); - } - this.categoryData = categoryData; + for (QuestCategory category : QuestController.Instance.categories.values()) { + categoryData.put(category.title, category); + } + this.categoryData = categoryData; - if(selectedCategory != null) { - for(Quest quest : selectedCategory.quests.values()) { - questData.put(quest.title, quest); - } - } - this.questData = questData; + if (selectedCategory != null) { + for (Quest quest : selectedCategory.quests.values()) { + questData.put(quest.title, quest); + } + } + this.questData = questData; - if(scrollCategories == null){ - scrollCategories = new GuiCustomScroll(this,0, 0); - scrollCategories.setSize(177, 153); + if (scrollCategories == null) { + scrollCategories = new GuiCustomScroll(this, 0, 0); + scrollCategories.setSize(177, 153); } scrollCategories.setList(getCatSearch()); - if(selectedCategory != null) { - scrollCategories.setSelected(selectedCategory.title); + if (selectedCategory != null) { + scrollCategories.setSelected(selectedCategory.title); } scrollCategories.guiLeft = guiLeft + 4; scrollCategories.guiTop = guiTop + 14; this.addScroll(scrollCategories); addTextField(new GuiNpcTextField(33, this, fontRendererObj, guiLeft + 4, guiTop + 169, 177, 20, catSearch)); - if(scrollQuests == null){ - scrollQuests = new GuiCustomScroll(this,1, 0); - scrollQuests.setSize(177, 153); + if (scrollQuests == null) { + scrollQuests = new GuiCustomScroll(this, 1, 0); + scrollQuests.setSize(177, 153); } scrollQuests.setList(getQuestSearch()); - if(selectedQuest != null) { - scrollQuests.setSelected(selectedQuest.title); + if (selectedQuest != null) { + scrollQuests.setSelected(selectedQuest.title); } scrollQuests.guiLeft = guiLeft + 182; scrollQuests.guiTop = guiTop + 14; @@ -93,21 +93,20 @@ public class GuiQuestSelection extends SubGuiInterface implements ICustomScrollL } @Override - public void keyTyped(char c, int i) - { + public void keyTyped(char c, int i) { super.keyTyped(c, i); - if(getTextField(33) != null){ - if(getTextField(33).isFocused()){ - if(catSearch.equals(getTextField(33).getText())) + if (getTextField(33) != null) { + if (getTextField(33).isFocused()) { + if (catSearch.equals(getTextField(33).getText())) return; catSearch = getTextField(33).getText().toLowerCase(); scrollCategories.resetScroll(); scrollCategories.setList(getCatSearch()); } } - if(getTextField(44) != null){ - if(getTextField(44).isFocused()){ - if(questSearch.equals(getTextField(44).getText())) + if (getTextField(44) != null) { + if (getTextField(44).isFocused()) { + if (questSearch.equals(getTextField(44).getText())) return; questSearch = getTextField(44).getText().toLowerCase(); scrollQuests.resetScroll(); @@ -116,72 +115,71 @@ public class GuiQuestSelection extends SubGuiInterface implements ICustomScrollL } } - private List getCatSearch(){ - if(catSearch.isEmpty()){ + private List getCatSearch() { + if (catSearch.isEmpty()) { return Lists.newArrayList(categoryData.keySet()); } List list = new ArrayList(); - for(String name : Lists.newArrayList(categoryData.keySet())){ - if(name.toLowerCase().contains(catSearch)) + for (String name : Lists.newArrayList(categoryData.keySet())) { + if (name.toLowerCase().contains(catSearch)) list.add(name); } return list; } - private List getQuestSearch(){ - if(selectedCategory == null){ + private List getQuestSearch() { + if (selectedCategory == null) { return Lists.newArrayList(questData.keySet()); } - if(questSearch.isEmpty()){ + if (questSearch.isEmpty()) { return new ArrayList(Lists.newArrayList(questData.keySet())); } List list = new ArrayList(); - for(String name : Lists.newArrayList(questData.keySet())){ - if(name.toLowerCase().contains(questSearch)) + for (String name : Lists.newArrayList(questData.keySet())) { + if (name.toLowerCase().contains(questSearch)) list.add(name); } return list; } - @Override - public void customScrollClicked(int i, int j, int k, GuiCustomScroll guiCustomScroll) { - if(guiCustomScroll.id == 0){ - selectedCategory = categoryData.get(scrollCategories.getSelected()); - selectedQuest = null; - scrollQuests.selected = -1; + @Override + public void customScrollClicked(int i, int j, int k, GuiCustomScroll guiCustomScroll) { + if (guiCustomScroll.id == 0) { + selectedCategory = categoryData.get(scrollCategories.getSelected()); + selectedQuest = null; + scrollQuests.selected = -1; scrollQuests.resetScroll(); getTextField(44).setText(""); questSearch = ""; - } - if(guiCustomScroll.id == 1){ - selectedQuest = questData.get(scrollQuests.getSelected()); - } - initGui(); - } - - @Override - public void customScrollDoubleClicked(String selection, GuiCustomScroll scroll) { - if(selectedQuest == null) - return; - if(listener != null) { - listener.selected(selectedQuest.id, selectedQuest.title); - } - close(); - } + } + if (guiCustomScroll.id == 1) { + selectedQuest = questData.get(scrollQuests.getSelected()); + } + initGui(); + } @Override - protected void actionPerformed(GuiButton guibutton){ - int id = guibutton.id; - if(id == 2){ - if(selectedQuest != null) { - customScrollDoubleClicked(null, null); - } - else { - close(); - } + public void customScrollDoubleClicked(String selection, GuiCustomScroll scroll) { + if (selectedQuest == null) + return; + if (listener != null) { + listener.selected(selectedQuest.id, selectedQuest.title); } - if(id == 3){ + close(); + } + + @Override + protected void actionPerformed(GuiButton guibutton) { + int id = guibutton.id; + if (id == 2) { + if (selectedQuest != null) { + customScrollDoubleClicked(null, null); + } else { + close(); + } + } + if (id == 3) { close(); } } diff --git a/src/main/java/noppes/npcs/client/gui/select/GuiSoundSelection.java b/src/main/java/noppes/npcs/client/gui/select/GuiSoundSelection.java index 11573e2a4..695bd0bca 100644 --- a/src/main/java/noppes/npcs/client/gui/select/GuiSoundSelection.java +++ b/src/main/java/noppes/npcs/client/gui/select/GuiSoundSelection.java @@ -72,7 +72,7 @@ public class GuiSoundSelection extends SubGuiInterface implements ICustomScrollL } @Override - public void initGui(){ + public void initGui() { super.initGui(); this.addButton(new GuiNpcButton(2, guiLeft + xSize - 45, guiTop + ySize - 35, 40, 20, "gui.done")); this.addButton(new GuiNpcButton(1, guiLeft + 4, guiTop + ySize - 35, 70, 20, "gui.play")); @@ -109,11 +109,11 @@ public class GuiSoundSelection extends SubGuiInterface implements ICustomScrollL } @Override - protected void actionPerformed(GuiButton guibutton){ + protected void actionPerformed(GuiButton guibutton) { super.actionPerformed(guibutton); if (guibutton.id == 1) { MusicController.Instance.stopMusic(); - MusicController.Instance.playSound(selectedResource.toString(), (float)player.posX, (float)player.posY, (float)player.posZ); + MusicController.Instance.playSound(selectedResource.toString(), (float) player.posX, (float) player.posY, (float) player.posZ); } if (guibutton.id == 2) { close(); @@ -152,18 +152,18 @@ public class GuiSoundSelection extends SubGuiInterface implements ICustomScrollL @Override public void keyTyped(char c, int i) { super.keyTyped(c, i); - if(getTextField(55) != null){ - if(getTextField(55).isFocused()){ - if(catSearch.equals(getTextField(55).getText())) + if (getTextField(55) != null) { + if (getTextField(55).isFocused()) { + if (catSearch.equals(getTextField(55).getText())) return; catSearch = getTextField(55).getText().toLowerCase(); scrollCategories.resetScroll(); scrollCategories.setList(getCatSearch()); } } - if(getTextField(66) != null){ - if(getTextField(66).isFocused()){ - if(soundSearch.equals(getTextField(66).getText())) + if (getTextField(66) != null) { + if (getTextField(66).isFocused()) { + if (soundSearch.equals(getTextField(66).getText())) return; soundSearch = getTextField(66).getText().toLowerCase(); scrollSounds.resetScroll(); @@ -172,28 +172,28 @@ public class GuiSoundSelection extends SubGuiInterface implements ICustomScrollL } } - private List getCatSearch(){ - if(catSearch.isEmpty()){ + private List getCatSearch() { + if (catSearch.isEmpty()) { return new ArrayList(this.domains.keySet()); } List list = new ArrayList(); - for(String name : this.domains.keySet()){ - if(name.toLowerCase().contains(catSearch)) + for (String name : this.domains.keySet()) { + if (name.toLowerCase().contains(catSearch)) list.add(name); } return list; } - private List getSoundSearch(){ - if(selectedDomain == null){ + private List getSoundSearch() { + if (selectedDomain == null) { return new ArrayList(); } - if(soundSearch.isEmpty()){ + if (soundSearch.isEmpty()) { return new ArrayList(this.domains.get(selectedDomain)); } List list = new ArrayList(); - for(String name : this.domains.get(selectedDomain)){ - if(name.toLowerCase().contains(soundSearch)) + for (String name : this.domains.get(selectedDomain)) { + if (name.toLowerCase().contains(soundSearch)) list.add(name); } return list; diff --git a/src/main/java/noppes/npcs/client/gui/select/GuiTextureSelection.java b/src/main/java/noppes/npcs/client/gui/select/GuiTextureSelection.java index 00a946f7a..c258c8b24 100644 --- a/src/main/java/noppes/npcs/client/gui/select/GuiTextureSelection.java +++ b/src/main/java/noppes/npcs/client/gui/select/GuiTextureSelection.java @@ -47,7 +47,7 @@ public class GuiTextureSelection extends SubGuiInterface implements ICustomScrol private static HashMap> cachedDomains = new HashMap<>(); public static HashMap cachedTextures = new HashMap<>(); - public GuiTextureSelection(EntityNPCInterface npc, String texture){ + public GuiTextureSelection(EntityNPCInterface npc, String texture) { this.npc = npc; drawDefaultBackground = false; title = ""; @@ -57,69 +57,65 @@ public class GuiTextureSelection extends SubGuiInterface implements ICustomScrol // First, try to use cached domain data if it exists and is recent long now = System.currentTimeMillis(); - if(cachedDomains != null && now - lastCacheTime < CACHE_DURATION) { + if (cachedDomains != null && now - lastCacheTime < CACHE_DURATION) { domains.putAll(cachedDomains); textures.putAll(cachedTextures); - } - else { + } else { // Build the domains and textures maps SimpleReloadableResourceManager simplemanager = (SimpleReloadableResourceManager) Minecraft.getMinecraft().getResourceManager(); Map map = ObfuscationReflectionHelper.getPrivateValue(SimpleReloadableResourceManager.class, simplemanager, 2); HashSet set = new HashSet(); - for(String name: map.keySet()){ - if(!(map.get(name) instanceof FallbackResourceManager)) + for (String name : map.keySet()) { + if (!(map.get(name) instanceof FallbackResourceManager)) continue; FallbackResourceManager manager = (FallbackResourceManager) map.get(name); List list = ObfuscationReflectionHelper.getPrivateValue(FallbackResourceManager.class, manager, 0); - for(IResourcePack pack : list){ - if(pack instanceof AbstractResourcePack){ + for (IResourcePack pack : list) { + if (pack instanceof AbstractResourcePack) { AbstractResourcePack p = (AbstractResourcePack) pack; File file = NPCResourceHelper.getPackFile(p); - if(file != null) + if (file != null) set.add(file.getAbsolutePath()); } } } - for(String file : set){ + for (String file : set) { File f = new File(file); - if(f.isDirectory()) { + if (f.isDirectory()) { checkFolder(new File(f, "assets"), f.getAbsolutePath().length()); - } - else { + } else { progressFile(f); } } for (ModContainer mod : Loader.instance().getModList()) { - if(mod.getSource().exists()) + if (mod.getSource().exists()) progressFile(mod.getSource()); } ResourcePackRepository repos = Minecraft.getMinecraft().getResourcePackRepository(); repos.updateRepositoryEntriesAll(); List list = repos.getRepositoryEntries(); - for(ResourcePackRepository.Entry entry : list) { + for (ResourcePackRepository.Entry entry : list) { File file = new File(repos.getDirResourcepacks(), entry.getResourcePackName()); - if(file.exists()){ + if (file.exists()) { progressFile(file); } } checkFolder(new File(CustomNpcs.Dir, "assets"), CustomNpcs.Dir.getAbsolutePath().length()); URL url = DefaultResourcePack.class.getResource("/"); - if(url != null) { + if (url != null) { File f = decodeFile(url.getFile()); - if(f.isDirectory()) { + if (f.isDirectory()) { checkFolder(new File(f, "assets"), url.getFile().length()); - } - else { + } else { progressFile(f); } } url = CraftingManager.class.getResource("/assets/.mcassetsroot"); - if(url != null) { + if (url != null) { File f = decodeFile(url.getFile()); - if(f.isDirectory()) { + if (f.isDirectory()) { checkFolder(new File(f, "assets"), url.getFile().length()); - } - else { + } else { progressFile(f); } } @@ -129,10 +125,10 @@ public class GuiTextureSelection extends SubGuiInterface implements ICustomScrol lastCacheTime = now; } - if(texture != null && !texture.isEmpty()){ + if (texture != null && !texture.isEmpty()) { selectedResource = new ResourceLocation(texture); selectedDomain = selectedResource.getResourceDomain(); - if(!domains.containsKey(selectedDomain)) { + if (!domains.containsKey(selectedDomain)) { selectedDomain = null; } int i = selectedResource.getResourcePath().lastIndexOf('/'); @@ -141,56 +137,55 @@ public class GuiTextureSelection extends SubGuiInterface implements ICustomScrol } private File decodeFile(String url) { - if(url.startsWith("file:")) { + if (url.startsWith("file:")) { url = url.substring(5); } url = url.replace('/', File.separatorChar); int i = url.indexOf('!'); - if(i > 0) { + if (i > 0) { url = url.substring(0, i); } try { url = URLDecoder.decode(url, StandardCharsets.UTF_8.name()); - } catch (UnsupportedEncodingException ignored) {} + } catch (UnsupportedEncodingException ignored) { + } return new File(url); } @Override - public void initGui(){ + public void initGui() { super.initGui(); - if(selectedDomain != null) { + if (selectedDomain != null) { title = selectedDomain + ":" + location; - } - else { + } else { title = ""; } this.addButton(new GuiNpcButton(2, guiLeft + 264, guiTop + 170, 90, 20, "gui.done")); this.addButton(new GuiNpcButton(1, guiLeft + 264, guiTop + 190, 90, 20, "gui.cancel")); - if(scrollCategories == null){ + if (scrollCategories == null) { scrollCategories = new GuiCustomScroll(this, 0); scrollCategories.setSize(120, 200); } - if(selectedDomain == null) { + if (selectedDomain == null) { scrollCategories.setList(Lists.newArrayList(domains.keySet())); - if(selectedDomain != null) { + if (selectedDomain != null) { scrollCategories.setSelected(selectedDomain); } - } - else { + } else { List list = new ArrayList(); list.add(up); List data = domains.get(selectedDomain); - for(TextureData td : data) { - if(location.isEmpty() || td.path.startsWith(location) && !td.path.equals(location)) { + for (TextureData td : data) { + if (location.isEmpty() || td.path.startsWith(location) && !td.path.equals(location)) { String path = td.path.substring(location.length()); int i = path.indexOf('/'); - if(i < 0) + if (i < 0) continue; path = path.substring(0, i); - if(!path.isEmpty() && !list.contains(path)) { + if (!path.isEmpty() && !list.contains(path)) { list.add(path); } } @@ -201,27 +196,27 @@ public class GuiTextureSelection extends SubGuiInterface implements ICustomScrol scrollCategories.guiTop = guiTop + 14; this.addScroll(scrollCategories); - if(scrollTextures == null){ + if (scrollTextures == null) { scrollTextures = new GuiCustomScroll(this, 1); scrollTextures.setSize(130, 200); } - if(selectedDomain != null) { + if (selectedDomain != null) { textures.clear(); List data = domains.get(selectedDomain); List list = new ArrayList(); String loc = location; - if(scrollCategories.hasSelected() && !scrollCategories.getSelected().equals(up)) { + if (scrollCategories.hasSelected() && !scrollCategories.getSelected().equals(up)) { loc += scrollCategories.getSelected() + '/'; } - for(TextureData td : data) { - if(td.path.equals(loc) && !list.contains(td.name)) { + for (TextureData td : data) { + if (td.path.equals(loc) && !list.contains(td.name)) { list.add(td.name); textures.put(td.name, td); } } scrollTextures.setList(list); } - if(selectedResource != null) { + if (selectedResource != null) { scrollTextures.setSelected(selectedResource.getResourcePath()); } scrollTextures.guiLeft = guiLeft + 125; @@ -230,9 +225,9 @@ public class GuiTextureSelection extends SubGuiInterface implements ICustomScrol } @Override - protected void actionPerformed(GuiButton guibutton){ + protected void actionPerformed(GuiButton guibutton) { super.actionPerformed(guibutton); - if(guibutton.id == 2){ + if (guibutton.id == 2) { npc.display.setSkinTexture(selectedResource.toString()); } npc.textureLocation = null; @@ -241,7 +236,7 @@ public class GuiTextureSelection extends SubGuiInterface implements ICustomScrol } @Override - public void drawScreen(int i, int j, float f){ + public void drawScreen(int i, int j, float f) { super.drawScreen(i, j, f); npc.textureLocation = selectedResource; drawNpc(npc, 307, 150, 1.5F, 0); @@ -249,13 +244,12 @@ public class GuiTextureSelection extends SubGuiInterface implements ICustomScrol @Override public void customScrollClicked(int i, int j, int k, GuiCustomScroll scroll) { - if(scroll == scrollTextures) { - if(scroll.id == 1){ + if (scroll == scrollTextures) { + if (scroll.id == 1) { TextureData data = textures.get(scroll.getSelected()); selectedResource = new ResourceLocation(selectedDomain, data.absoluteName); } - } - else { + } else { initGui(); scrollTextures.resetScroll(); } @@ -263,49 +257,44 @@ public class GuiTextureSelection extends SubGuiInterface implements ICustomScrol @Override public void customScrollDoubleClicked(String selection, GuiCustomScroll scroll) { - if(scroll == scrollCategories) { - if(selectedDomain == null) { + if (scroll == scrollCategories) { + if (selectedDomain == null) { selectedDomain = selection; - } - else if(selection.equals(up)) { + } else if (selection.equals(up)) { int i = location.lastIndexOf('/', location.length() - 2); - if(i < 0) { - if(location.isEmpty()) { + if (i < 0) { + if (location.isEmpty()) { selectedDomain = null; } location = ""; - } - else { + } else { location = location.substring(0, i + 1); } - } - else { + } else { location = location + selection + '/'; } scrollCategories.selected = -1; scrollTextures.selected = -1; initGui(); - } - else { + } else { npc.display.setSkinTexture(selectedResource.toString()); close(); parent.initGui(); } } - private void progressFile(File file){ + private void progressFile(File file) { try { if (!file.isDirectory() && (file.getName().endsWith(".jar") || file.getName().endsWith(".zip"))) { ZipFile zip = new ZipFile(file); Enumeration entries = zip.entries(); - while(entries.hasMoreElements()){ + while (entries.hasMoreElements()) { ZipEntry zipentry = entries.nextElement(); String entryName = zipentry.getName(); addFile(entryName); } zip.close(); - } - else if(file.isDirectory()){ + } else if (file.isDirectory()) { int length = file.getAbsolutePath().length(); checkFolder(file, length); } @@ -314,35 +303,34 @@ public class GuiTextureSelection extends SubGuiInterface implements ICustomScrol } } - private void checkFolder(File file, int length){ + private void checkFolder(File file, int length) { File[] files = file.listFiles(); - if(files == null){ + if (files == null) { return; } - for(File f : files){ + for (File f : files) { String name = null; try { name = f.getAbsolutePath().substring(length); name = name.replace("\\", "/"); - if(!name.startsWith("/")) + if (!name.startsWith("/")) name = "/" + name; - if(f.isDirectory()){ + if (f.isDirectory()) { addFile(name + "/"); checkFolder(f, length); - } - else + } else addFile(name); - } - catch(Throwable e) { + } catch (Throwable e) { LogWriter.error("error with: " + name); } } } + private void addFile(String name) { - if(name.startsWith("/")) { + if (name.startsWith("/")) { name = name.substring(1); } - if(!name.startsWith("assets/") || !name.endsWith(".png")) { + if (!name.startsWith("assets/") || !name.endsWith(".png")) { return; } name = name.substring(7); @@ -351,17 +339,17 @@ public class GuiTextureSelection extends SubGuiInterface implements ICustomScrol name = name.substring(i + 1); List list = domains.get(domain); - if(list == null) { + if (list == null) { domains.put(domain, list = new ArrayList()); } boolean contains = false; - for(TextureData data : list) { - if(data.absoluteName.equals(name)) { + for (TextureData data : list) { + if (data.absoluteName.equals(name)) { contains = true; break; } } - if(!contains) + if (!contains) list.add(new TextureData(domain, name)); } @@ -370,6 +358,7 @@ public class GuiTextureSelection extends SubGuiInterface implements ICustomScrol String absoluteName; String name; String path; + public TextureData(String domain, String absoluteName) { this.domain = domain; int i = absoluteName.lastIndexOf('/'); diff --git a/src/main/java/noppes/npcs/client/gui/util/GuiButtonBiDirectional.java b/src/main/java/noppes/npcs/client/gui/util/GuiButtonBiDirectional.java index b703dfff9..c1d60fc66 100644 --- a/src/main/java/noppes/npcs/client/gui/util/GuiButtonBiDirectional.java +++ b/src/main/java/noppes/npcs/client/gui/util/GuiButtonBiDirectional.java @@ -4,78 +4,75 @@ import net.minecraft.client.Minecraft; import net.minecraft.util.ResourceLocation; import org.lwjgl.opengl.GL11; -public class GuiButtonBiDirectional extends GuiNpcButton{ - public static final ResourceLocation resource = new ResourceLocation("customnpcs:textures/gui/arrowbuttons.png"); +public class GuiButtonBiDirectional extends GuiNpcButton { + public static final ResourceLocation resource = new ResourceLocation("customnpcs:textures/gui/arrowbuttons.png"); + + public GuiButtonBiDirectional(int id, int x, int y, int width, int height, String[] arr, int current) { + super(id, x, y, width, height, arr, current); + } - public GuiButtonBiDirectional(int id, int x, int y, int width, int height, String[] arr, int current) { - super(id, x, y, width, height, arr, current); - } - @Override - public void drawButton(Minecraft mc, int mouseX, int mouseY){ + public void drawButton(Minecraft mc, int mouseX, int mouseY) { if (!this.visible) - return; + return; boolean hover = mouseX >= this.xPosition && mouseY >= this.yPosition && mouseX < this.xPosition + this.width && mouseY < this.yPosition + this.height; - + boolean hoverL = mouseX >= this.xPosition && mouseY >= this.yPosition && mouseX < this.xPosition + 11 && mouseY < this.yPosition + this.height; boolean hoverR = !hoverL && mouseX >= this.xPosition + width - 11 && mouseY >= this.yPosition && mouseX < this.xPosition + this.width && mouseY < this.yPosition + this.height; - + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); mc.getTextureManager().bindTexture(resource); - this.drawTexturedModalRect(this.xPosition, this.yPosition, 0, hoverL?40:20, 11, 20); - - this.drawTexturedModalRect(this.xPosition + width - 11, this.yPosition, 11, hoverR?40:20, 11, 20); - + this.drawTexturedModalRect(this.xPosition, this.yPosition, 0, hoverL ? 40 : 20, 11, 20); + + this.drawTexturedModalRect(this.xPosition + width - 11, this.yPosition, 11, hoverR ? 40 : 20, 11, 20); + int l = 0xffffff; - if (packedFGColour != 0){ + if (packedFGColour != 0) { l = packedFGColour; - } - else if (!this.enabled){ + } else if (!this.enabled) { l = 10526880; - } - else if (hover){ + } else if (hover) { l = 16777120; } String text = ""; float maxWidth = this.width - 36; - if(mc.fontRenderer.getStringWidth(displayString) > maxWidth){ - for(int h = 0; h < displayString.length(); h++){ - char c = displayString.charAt(h); - text += c; - if(mc.fontRenderer.getStringWidth(text) > maxWidth) - break; - } - text += "..."; - } - else - text = displayString; - if(hover) - text = (char)167 + "n" + text; - + if (mc.fontRenderer.getStringWidth(displayString) > maxWidth) { + for (int h = 0; h < displayString.length(); h++) { + char c = displayString.charAt(h); + text += c; + if (mc.fontRenderer.getStringWidth(text) > maxWidth) + break; + } + text += "..."; + } else + text = displayString; + if (hover) + text = (char) 167 + "n" + text; + this.drawCenteredString(mc.fontRenderer, text, this.xPosition + this.width / 2, this.yPosition + (this.height - 8) / 2, l); } - + @Override - public boolean mousePressed(Minecraft minecraft, int mouseX, int mouseY){ - int value = getValue(); - boolean bo = super.mousePressed(minecraft, mouseX, mouseY); - if(bo && display != null && display.length != 0){ + public boolean mousePressed(Minecraft minecraft, int mouseX, int mouseY) { + int value = getValue(); + boolean bo = super.mousePressed(minecraft, mouseX, mouseY); + if (bo && display != null && display.length != 0) { boolean hoverL = mouseX >= this.xPosition && mouseY >= this.yPosition && mouseX < this.xPosition + 11 && mouseY < this.yPosition + this.height; boolean hoverR = !hoverL && mouseX >= this.xPosition + 11 && mouseY >= this.yPosition && mouseX < this.xPosition + this.width && mouseY < this.yPosition + this.height; - if(hoverR) - value = (value+1) % display.length; - if(hoverL){ - if(value <= 0) - value = display.length; - value--; + if (hoverR) + value = (value + 1) % display.length; + if (hoverL) { + if (value <= 0) + value = display.length; + value--; } - this.setDisplay(value); - } - return bo; + this.setDisplay(value); + } + return bo; } } diff --git a/src/main/java/noppes/npcs/client/gui/util/GuiButtonNextPage.java b/src/main/java/noppes/npcs/client/gui/util/GuiButtonNextPage.java index 67b50575a..9d7bec9f9 100644 --- a/src/main/java/noppes/npcs/client/gui/util/GuiButtonNextPage.java +++ b/src/main/java/noppes/npcs/client/gui/util/GuiButtonNextPage.java @@ -4,34 +4,29 @@ import net.minecraft.client.Minecraft; import net.minecraft.util.ResourceLocation; import org.lwjgl.opengl.GL11; -public class GuiButtonNextPage extends GuiNpcButton{ +public class GuiButtonNextPage extends GuiNpcButton { private final boolean field_146151_o; private static final ResourceLocation field_110405_a = new ResourceLocation("textures/gui/book.png"); - public GuiButtonNextPage(int par1, int par2, int par3, boolean par4) - { + public GuiButtonNextPage(int par1, int par2, int par3, boolean par4) { super(par1, par2, par3, 23, 13, ""); this.field_146151_o = par4; } @Override - public void drawButton(Minecraft p_146112_1_, int p_146112_2_, int p_146112_3_) - { - if (this.visible) - { + public void drawButton(Minecraft p_146112_1_, int p_146112_2_, int p_146112_3_) { + if (this.visible) { boolean flag = p_146112_2_ >= this.xPosition && p_146112_3_ >= this.yPosition && p_146112_2_ < this.xPosition + this.width && p_146112_3_ < this.yPosition + this.height; GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); p_146112_1_.getTextureManager().bindTexture(field_110405_a); int k = 0; int l = 192; - if (flag) - { + if (flag) { k += 23; } - if (!this.field_146151_o) - { + if (!this.field_146151_o) { l += 13; } diff --git a/src/main/java/noppes/npcs/client/gui/util/GuiContainerNPCInterface.java b/src/main/java/noppes/npcs/client/gui/util/GuiContainerNPCInterface.java index a8a3c7731..b4049bc8a 100644 --- a/src/main/java/noppes/npcs/client/gui/util/GuiContainerNPCInterface.java +++ b/src/main/java/noppes/npcs/client/gui/util/GuiContainerNPCInterface.java @@ -22,34 +22,32 @@ import org.lwjgl.opengl.GL12; import java.util.ArrayList; import java.util.HashMap; -public abstract class GuiContainerNPCInterface extends GuiContainer -{ - public boolean drawDefaultBackground = false; - public int guiLeft,guiTop; - public EntityClientPlayerMP player; - public EntityNPCInterface npc; - private HashMap buttons = new HashMap(); - private HashMap topbuttons = new HashMap(); - private HashMap textfields = new HashMap(); - private HashMap labels = new HashMap(); - private HashMap scrolls = new HashMap(); - private HashMap sliders = new HashMap(); - public String title; - public boolean closeOnEsc = false; - private SubGuiInterface subgui; - public int mouseX, mouseY; +public abstract class GuiContainerNPCInterface extends GuiContainer { + public boolean drawDefaultBackground = false; + public int guiLeft, guiTop; + public EntityClientPlayerMP player; + public EntityNPCInterface npc; + private HashMap buttons = new HashMap(); + private HashMap topbuttons = new HashMap(); + private HashMap textfields = new HashMap(); + private HashMap labels = new HashMap(); + private HashMap scrolls = new HashMap(); + private HashMap sliders = new HashMap(); + public String title; + public boolean closeOnEsc = false; + private SubGuiInterface subgui; + public int mouseX, mouseY; - public GuiContainerNPCInterface(EntityNPCInterface npc,Container cont) - { - super(cont); - this.player = Minecraft.getMinecraft().thePlayer; - this.npc = npc; - title = "Npc Mainmenu"; + public GuiContainerNPCInterface(EntityNPCInterface npc, Container cont) { + super(cont); + this.player = Minecraft.getMinecraft().thePlayer; + this.npc = npc; + title = "Npc Mainmenu"; } - public void initGui() - { - super.initGui(); - GuiNpcTextField.unfocus(); + + public void initGui() { + super.initGui(); + GuiNpcTextField.unfocus(); buttonList.clear(); buttons.clear(); topbuttons.clear(); @@ -59,242 +57,263 @@ public abstract class GuiContainerNPCInterface extends GuiContainer textfields.clear(); Keyboard.enableRepeatEvents(true); - if(subgui != null){ - subgui.setWorldAndResolution(mc, width, height); - subgui.initGui(); - } + if (subgui != null) { + subgui.setWorldAndResolution(mc, width, height); + subgui.initGui(); + } buttonList.clear(); - guiLeft = (width - xSize)/2; + guiLeft = (width - xSize) / 2; guiTop = (height - ySize) / 2; } - public ResourceLocation getResource(String texture){ - return new ResourceLocation("customnpcs","textures/gui/" + texture); + + public ResourceLocation getResource(String texture) { + return new ResourceLocation("customnpcs", "textures/gui/" + texture); } - public void updateScreen(){ - for(GuiNpcTextField tf : new ArrayList(textfields.values())) - if(tf.enabled) - tf.updateCursorCounter(); + + public void updateScreen() { + for (GuiNpcTextField tf : new ArrayList(textfields.values())) + if (tf.enabled) + tf.updateCursorCounter(); super.updateScreen(); } @Override - protected void mouseClicked(int i, int j, int k) - { - if(subgui != null) - subgui.mouseClicked(i,j,k); - else{ - for(GuiNpcTextField tf : new ArrayList(textfields.values())) - if(tf.enabled) - tf.mouseClicked(i, j, k); - if (k == 0){ - for(GuiCustomScroll scroll : new ArrayList(scrolls.values())){ - scroll.mouseClicked(i, j, k); - } - } - mouseEvent(i,j,k); - super.mouseClicked(i, j, k); - } + protected void mouseClicked(int i, int j, int k) { + if (subgui != null) + subgui.mouseClicked(i, j, k); + else { + for (GuiNpcTextField tf : new ArrayList(textfields.values())) + if (tf.enabled) + tf.mouseClicked(i, j, k); + if (k == 0) { + for (GuiCustomScroll scroll : new ArrayList(scrolls.values())) { + scroll.mouseClicked(i, j, k); + } + } + mouseEvent(i, j, k); + super.mouseClicked(i, j, k); + } } - public void mouseEvent(int i, int j, int k){}; + + public void mouseEvent(int i, int j, int k) { + } + + ; @Override - protected void keyTyped(char c, int i) - { - if(subgui != null) - subgui.keyTyped(c,i); - else{ - for(GuiNpcTextField tf : new ArrayList(textfields.values())) - tf.textboxKeyTyped(c, i); + protected void keyTyped(char c, int i) { + if (subgui != null) + subgui.keyTyped(c, i); + else { + for (GuiNpcTextField tf : new ArrayList(textfields.values())) + tf.textboxKeyTyped(c, i); - if (closeOnEsc && (i == 1 || i == mc.gameSettings.keyBindInventory.getKeyCode() && !GuiNpcTextField.isFieldActive())) - close(); - } + if (closeOnEsc && (i == 1 || i == mc.gameSettings.keyBindInventory.getKeyCode() && !GuiNpcTextField.isFieldActive())) + close(); + } } @Override - protected void actionPerformed(GuiButton guibutton) { - if(subgui != null) - subgui.buttonEvent(guibutton); - else - buttonEvent(guibutton); - } - public void buttonEvent(GuiButton guibutton){}; + protected void actionPerformed(GuiButton guibutton) { + if (subgui != null) + subgui.buttonEvent(guibutton); + else + buttonEvent(guibutton); + } - public void close(){ - Keyboard.enableRepeatEvents(false); - GuiNpcTextField.unfocus(); - save(); - player.closeScreen(); + public void buttonEvent(GuiButton guibutton) { + } + + ; + + public void close() { + Keyboard.enableRepeatEvents(false); + GuiNpcTextField.unfocus(); + save(); + player.closeScreen(); displayGuiScreen(null); mc.setIngameFocus(); } - public void addButton(GuiNpcButton button){ - buttons.put(button.id,button); - buttonList.add(button); + + public void addButton(GuiNpcButton button) { + buttons.put(button.id, button); + buttonList.add(button); } - public void addTopButton(GuiMenuTopButton button){ - topbuttons.put(button.id,button); - buttonList.add(button); + + public void addTopButton(GuiMenuTopButton button) { + topbuttons.put(button.id, button); + buttonList.add(button); } - public GuiNpcButton getButton(int i) { - return buttons.get(i); - } - public void addTextField(GuiNpcTextField tf){ - textfields.put(tf.id,tf); + + public GuiNpcButton getButton(int i) { + return buttons.get(i); } - public GuiNpcTextField getTextField(int i){ - return textfields.get(i); + + public void addTextField(GuiNpcTextField tf) { + textfields.put(tf.id, tf); } + + public GuiNpcTextField getTextField(int i) { + return textfields.get(i); + } + public void addLabel(GuiNpcLabel label) { - labels.put(label.id, label); - } - public GuiNpcLabel getLabel(int i){ - return labels.get(i); + labels.put(label.id, label); } - public GuiMenuTopButton getTopButton(int i) { - return topbuttons.get(i); - } - public void addSlider(GuiNpcSlider slider){ - sliders.put(slider.id,slider); - buttonList.add(slider); + public GuiNpcLabel getLabel(int i) { + return labels.get(i); } - public GuiNpcSlider getSlider(int i) { - return sliders.get(i); - } - public void addScroll(GuiCustomScroll scroll) { + public GuiMenuTopButton getTopButton(int i) { + return topbuttons.get(i); + } + + public void addSlider(GuiNpcSlider slider) { + sliders.put(slider.id, slider); + buttonList.add(slider); + } + + public GuiNpcSlider getSlider(int i) { + return sliders.get(i); + } + + public void addScroll(GuiCustomScroll scroll) { scroll.setWorldAndResolution(mc, 350, 250); scrolls.put(scroll.id, scroll); - } - public GuiCustomScroll getScroll(int id){ - return scrolls.get(id); - } + } + + public GuiCustomScroll getScroll(int id) { + return scrolls.get(id); + } @Override - protected void drawGuiContainerForegroundLayer(int par1, int par2){ + protected void drawGuiContainerForegroundLayer(int par1, int par2) { } @Override - protected void drawGuiContainerBackgroundLayer(float f, int i, int j){ + protected void drawGuiContainerBackgroundLayer(float f, int i, int j) { drawCenteredString(fontRendererObj, StatCollector.translateToLocal(title), width / 2, guiTop - 8, 0xffffff); - for(GuiNpcLabel label : new ArrayList(labels.values())) - label.drawLabel(this,fontRendererObj); - for(GuiNpcTextField tf : new ArrayList(textfields.values())) - tf.drawTextBox(i, j); - for(GuiCustomScroll scroll : new ArrayList(scrolls.values())) - scroll.drawScreen(i, j, f, hasSubGui()?0:Mouse.getDWheel()); + for (GuiNpcLabel label : new ArrayList(labels.values())) + label.drawLabel(this, fontRendererObj); + for (GuiNpcTextField tf : new ArrayList(textfields.values())) + tf.drawTextBox(i, j); + for (GuiCustomScroll scroll : new ArrayList(scrolls.values())) + scroll.drawScreen(i, j, f, hasSubGui() ? 0 : Mouse.getDWheel()); } + public abstract void save(); @Override - public void drawScreen(int i, int j, float f){ - mouseX = i; - mouseY = j; - Container container = this.inventorySlots; - if(subgui != null){ - this.inventorySlots = new ContainerEmpty(); + public void drawScreen(int i, int j, float f) { + mouseX = i; + mouseY = j; + Container container = this.inventorySlots; + if (subgui != null) { + this.inventorySlots = new ContainerEmpty(); } super.drawScreen(i, j, f); - zLevel = 0; + zLevel = 0; GL11.glColor4f(1, 1, 1, 1); - if(subgui != null){ - this.inventorySlots = container; + if (subgui != null) { + this.inventorySlots = container; RenderHelper.disableStandardItemLighting(); - subgui.drawScreen(i,j,f); + subgui.drawScreen(i, j, f); } } @Override - public void drawDefaultBackground() - { - if(drawDefaultBackground && subgui == null) - super.drawDefaultBackground(); + public void drawDefaultBackground() { + if (drawDefaultBackground && subgui == null) + super.drawDefaultBackground(); } - public FontRenderer getFontRenderer() { - return this.fontRendererObj; - } - public void closeSubGui(SubGuiInterface gui) { - subgui = null; - } - public boolean hasSubGui() { - return subgui != null; - } - public SubGuiInterface getSubGui() { - if(hasSubGui() && subgui.hasSubGui()) - return subgui.getSubGui(); - return subgui; - } - - public void displayGuiScreen(GuiScreen gui) { - this.mc.displayGuiScreen(gui); - } - - public void setSubGui(SubGuiInterface gui){ - subgui = gui; - subgui.setWorldAndResolution(mc, width, height); - subgui.parent = this; - initGui(); + public FontRenderer getFontRenderer() { + return this.fontRendererObj; } - public void drawNpc(int x, int y){ + public void closeSubGui(SubGuiInterface gui) { + subgui = null; + } + + public boolean hasSubGui() { + return subgui != null; + } + + public SubGuiInterface getSubGui() { + if (hasSubGui() && subgui.hasSubGui()) + return subgui.getSubGui(); + return subgui; + } + + public void displayGuiScreen(GuiScreen gui) { + this.mc.displayGuiScreen(gui); + } + + public void setSubGui(SubGuiInterface gui) { + subgui = gui; + subgui.setWorldAndResolution(mc, width, height); + subgui.parent = this; + initGui(); + } + + public void drawNpc(int x, int y) { npc.isDrawn = true; - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - GL11.glEnable(GL11.GL_COLOR_MATERIAL); - GL11.glPushMatrix(); - GL11.glTranslatef(guiLeft + x, guiTop + y, 50F); - float scale = 1; - if (npc.height > 2.4) - scale = 2 / npc.height; - GL11.glScalef(-30 * scale, 30 * scale, 30 * scale); - GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); - float f2 = npc.renderYawOffset; - float f3 = npc.rotationYaw; - float f4 = npc.rotationPitch; - float f7 = npc.rotationYawHead; - float f5 = (float) (guiLeft + x) - mouseX; - float f6 = (float) ((guiTop + y) - 50) - mouseY; - int orientation = 0; - if(npc != null){ - if(npc.ais != null){ - orientation = npc.ais.orientation; - npc.ais.orientation = 0; - } - } - GL11.glRotatef(135F, 0.0F, 1.0F, 0.0F); - RenderHelper.enableStandardItemLighting(); - GL11.glRotatef(-135F, 0.0F, 1.0F, 0.0F); - GL11.glRotatef(-(float) Math.atan(f6 / 40F) * 20F, 1.0F, 0.0F, 0.0F); - npc.renderYawOffset = (float) Math.atan(f5 / 40F) * 20F; - npc.rotationYaw = (float) Math.atan(f5 / 40F) * 40F; - npc.rotationPitch = -(float) Math.atan(f6 / 40F) * 20F; - npc.rotationYawHead = npc.rotationYaw; - GL11.glTranslatef(0.0F, npc.yOffset, 0.0F); - RenderManager.instance.playerViewY = 180F; - RenderManager.instance.renderEntityWithPosYaw(npc, 0, 0, 0, 0, 1); - npc.renderYawOffset = f2; - npc.rotationYaw = f3; - npc.rotationPitch = f4; - npc.rotationYawHead = f7; - if(npc != null){ - if(npc.ais != null){ - npc.ais.orientation = orientation; - } - } + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GL11.glEnable(GL11.GL_COLOR_MATERIAL); + GL11.glPushMatrix(); + GL11.glTranslatef(guiLeft + x, guiTop + y, 50F); + float scale = 1; + if (npc.height > 2.4) + scale = 2 / npc.height; + GL11.glScalef(-30 * scale, 30 * scale, 30 * scale); + GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); + float f2 = npc.renderYawOffset; + float f3 = npc.rotationYaw; + float f4 = npc.rotationPitch; + float f7 = npc.rotationYawHead; + float f5 = (float) (guiLeft + x) - mouseX; + float f6 = (float) ((guiTop + y) - 50) - mouseY; + int orientation = 0; + if (npc != null) { + if (npc.ais != null) { + orientation = npc.ais.orientation; + npc.ais.orientation = 0; + } + } + GL11.glRotatef(135F, 0.0F, 1.0F, 0.0F); + RenderHelper.enableStandardItemLighting(); + GL11.glRotatef(-135F, 0.0F, 1.0F, 0.0F); + GL11.glRotatef(-(float) Math.atan(f6 / 40F) * 20F, 1.0F, 0.0F, 0.0F); + npc.renderYawOffset = (float) Math.atan(f5 / 40F) * 20F; + npc.rotationYaw = (float) Math.atan(f5 / 40F) * 40F; + npc.rotationPitch = -(float) Math.atan(f6 / 40F) * 20F; + npc.rotationYawHead = npc.rotationYaw; + GL11.glTranslatef(0.0F, npc.yOffset, 0.0F); + RenderManager.instance.playerViewY = 180F; + RenderManager.instance.renderEntityWithPosYaw(npc, 0, 0, 0, 0, 1); + npc.renderYawOffset = f2; + npc.rotationYaw = f3; + npc.rotationPitch = f4; + npc.rotationYawHead = f7; + if (npc != null) { + if (npc.ais != null) { + npc.ais.orientation = orientation; + } + } npc.isDrawn = false; - GL11.glPopMatrix(); - RenderHelper.disableStandardItemLighting(); - GL11.glDisable(GL12.GL_RESCALE_NORMAL); + GL11.glPopMatrix(); + RenderHelper.disableStandardItemLighting(); + GL11.glDisable(GL12.GL_RESCALE_NORMAL); - OpenGlHelper.setActiveTexture(OpenGlHelper.lightmapTexUnit); - GL11.glDisable(GL11.GL_TEXTURE_2D); - OpenGlHelper.setActiveTexture(OpenGlHelper.defaultTexUnit); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - } + OpenGlHelper.setActiveTexture(OpenGlHelper.lightmapTexUnit); + GL11.glDisable(GL11.GL_TEXTURE_2D); + OpenGlHelper.setActiveTexture(OpenGlHelper.defaultTexUnit); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + } } diff --git a/src/main/java/noppes/npcs/client/gui/util/GuiContainerNPCInterface2.java b/src/main/java/noppes/npcs/client/gui/util/GuiContainerNPCInterface2.java index fd153fd98..3455e4986 100644 --- a/src/main/java/noppes/npcs/client/gui/util/GuiContainerNPCInterface2.java +++ b/src/main/java/noppes/npcs/client/gui/util/GuiContainerNPCInterface2.java @@ -6,67 +6,64 @@ import noppes.npcs.client.gui.roles.GuiNpcTraderSetup; import noppes.npcs.entity.EntityNPCInterface; import org.lwjgl.opengl.GL11; -public abstract class GuiContainerNPCInterface2 extends GuiContainerNPCInterface -{ - private ResourceLocation background = new ResourceLocation("customnpcs","textures/gui/menubg.png"); - private final ResourceLocation defaultBackground = new ResourceLocation("customnpcs","textures/gui/menubg.png"); - private final ResourceLocation defaultBackground2 = new ResourceLocation("customnpcs","textures/gui/menubg2.png"); +public abstract class GuiContainerNPCInterface2 extends GuiContainerNPCInterface { + private ResourceLocation background = new ResourceLocation("customnpcs", "textures/gui/menubg.png"); + private final ResourceLocation defaultBackground = new ResourceLocation("customnpcs", "textures/gui/menubg.png"); + private final ResourceLocation defaultBackground2 = new ResourceLocation("customnpcs", "textures/gui/menubg2.png"); private GuiNpcMenu menu; - public int menuYOffset = 0; + public int menuYOffset = 0; - public GuiContainerNPCInterface2(EntityNPCInterface npc,Container cont) - { - this(npc, cont, -1); + public GuiContainerNPCInterface2(EntityNPCInterface npc, Container cont) { + this(npc, cont, -1); } - public GuiContainerNPCInterface2(EntityNPCInterface npc,Container cont,int activeMenu) - { - super(npc, cont); - this.xSize = 420; - this.menu = new GuiNpcMenu(this,activeMenu,npc); - title = ""; + + public GuiContainerNPCInterface2(EntityNPCInterface npc, Container cont, int activeMenu) { + super(npc, cont); + this.xSize = 420; + this.menu = new GuiNpcMenu(this, activeMenu, npc); + title = ""; drawDefaultBackground = true; } - public void setBackground(String texture){ - background = new ResourceLocation("customnpcs","textures/gui/" + texture); - } - public ResourceLocation getResource(String texture){ - return new ResourceLocation("customnpcs","textures/gui/" + texture); + + public void setBackground(String texture) { + background = new ResourceLocation("customnpcs", "textures/gui/" + texture); } - @Override - public void initGui() - { - super.initGui(); + public ResourceLocation getResource(String texture) { + return new ResourceLocation("customnpcs", "textures/gui/" + texture); + } + + @Override + public void initGui() { + super.initGui(); menu.initGui(guiLeft, guiTop + menuYOffset, xSize); } @Override - protected void mouseClicked(int i, int j, int k) - { - super.mouseClicked(i, j, k); - if(!hasSubGui()) - menu.mouseClicked(i, j, k); + protected void mouseClicked(int i, int j, int k) { + super.mouseClicked(i, j, k); + if (!hasSubGui()) + menu.mouseClicked(i, j, k); } - public void delete(){ - npc.delete(); + public void delete() { + npc.delete(); displayGuiScreen(null); mc.setIngameFocus(); } @Override - protected void drawGuiContainerBackgroundLayer(float f, int i, int j) - { + protected void drawGuiContainerBackgroundLayer(float f, int i, int j) { GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); mc.renderEngine.bindTexture(background); drawTexturedModalRect(guiLeft, guiTop, 0, 0, 256, 256); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); mc.renderEngine.bindTexture(defaultBackground2); - if(this instanceof GuiNpcTraderSetup) - drawTexturedModalRect(guiLeft + xSize-210, guiTop, 46, 0, 256, 220); + if (this instanceof GuiNpcTraderSetup) + drawTexturedModalRect(guiLeft + xSize - 210, guiTop, 46, 0, 256, 220); else - drawTexturedModalRect(guiLeft + xSize-230, guiTop, 26, 0, 256, 220); + drawTexturedModalRect(guiLeft + xSize - 230, guiTop, 26, 0, 256, 220); menu.drawElements(fontRendererObj, i, j, mc, f); diff --git a/src/main/java/noppes/npcs/client/gui/util/GuiCustomScroll.java b/src/main/java/noppes/npcs/client/gui/util/GuiCustomScroll.java index a98f2c329..bb83ef292 100644 --- a/src/main/java/noppes/npcs/client/gui/util/GuiCustomScroll.java +++ b/src/main/java/noppes/npcs/client/gui/util/GuiCustomScroll.java @@ -11,11 +11,10 @@ import java.util.*; import static noppes.npcs.client.gui.util.GuiNPCInterface.resizingActive; -public class GuiCustomScroll extends GuiScreen -{ - public static final ResourceLocation resource = new ResourceLocation("customnpcs","textures/gui/misc.png"); +public class GuiCustomScroll extends GuiScreen { + public static final ResourceLocation resource = new ResourceLocation("customnpcs", "textures/gui/misc.png"); public List list; - public final HashMap colors = new HashMap<>(); + public final HashMap colors = new HashMap<>(); public int id; public int guiLeft = 0; @@ -35,15 +34,14 @@ public class GuiCustomScroll extends GuiScreen public boolean multipleSelection = false; private ICustomScrollListener listener; private boolean isSorted = true; - public boolean visible = true; - private boolean selectable = true; + public boolean visible = true; + private boolean selectable = true; private boolean hasSubGUI = false; private int lastClickedItem; private long lastClickedTime = 0; - public GuiCustomScroll(GuiScreen parent, int id) - { + public GuiCustomScroll(GuiScreen parent, int id) { width = 176; height = 166; xSize = 176; @@ -55,45 +53,44 @@ public class GuiCustomScroll extends GuiScreen scrollY = 0; scrollHeight = 0; isScrolling = false; - if(parent instanceof ICustomScrollListener) - listener = (ICustomScrollListener) parent; + if (parent instanceof ICustomScrollListener) + listener = (ICustomScrollListener) parent; this.list = new ArrayList(); this.id = id; } - public GuiCustomScroll(GuiScreen parent, int id, boolean multipleSelection) - { - this(parent,id); - this.multipleSelection = multipleSelection; + + public GuiCustomScroll(GuiScreen parent, int id, boolean multipleSelection) { + this(parent, id); + this.multipleSelection = multipleSelection; } - public GuiCustomScroll(GuiScreen parent, int id, int allowHover) - { - this(parent,id); + public GuiCustomScroll(GuiScreen parent, int id, int allowHover) { + this(parent, id); this.hoverableText = true; } - public void setSize(int x, int y){ - ySize = y; - xSize = x; + public void setSize(int x, int y) { + ySize = y; + xSize = x; listHeight = 14 * list.size(); - if(listHeight > 0) - scrollHeight = (int) (((double)(ySize - 8) / (double)listHeight) * (ySize-8)); + if (listHeight > 0) + scrollHeight = (int) (((double) (ySize - 8) / (double) listHeight) * (ySize - 8)); else - scrollHeight = Integer.MAX_VALUE; + scrollHeight = Integer.MAX_VALUE; maxScrollY = listHeight - (ySize - 8) - 1; } - public void drawScreen(int i, int j, float f, int mouseScrolled){ - if(!visible) - return; + public void drawScreen(int i, int j, float f, int mouseScrolled) { + if (!visible) + return; - drawGradientRect(guiLeft, guiTop, xSize+guiLeft ,ySize+guiTop, 0xc0101010, 0xd0101010); + drawGradientRect(guiLeft, guiTop, xSize + guiLeft, ySize + guiTop, 0xc0101010, 0xd0101010); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); mc.renderEngine.bindTexture(resource); - if(scrollHeight < ySize - 8){ + if (scrollHeight < ySize - 8) { drawScrollBar(); } GL11.glPushMatrix(); @@ -103,155 +100,143 @@ public class GuiCustomScroll extends GuiScreen GL11.glTranslatef(guiLeft, guiTop, 0.0F); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - if(selectable) - hover = getMouseOver(i,j); + if (selectable) + hover = getMouseOver(i, j); drawItems(); - if(oldHover != hover){ + if (oldHover != hover) { oldHover = hover; hoverCount = 0; - } - else { - if(hoverCount < 110) + } else { + if (hoverCount < 110) hoverCount++; } - if(!hasSubGUI && hover != -1 && hoverableText && hoverCount > 100){ + if (!hasSubGUI && hover != -1 && hoverableText && hoverCount > 100) { String displayString = StatCollector.translateToLocal(list.get(hover)); GL11.glColor4f(1, 1, 1, 1); List lines = TextSplitter.splitText(displayString, 30); - super.drawHoveringText(lines, i-guiLeft, j-guiTop, this.fontRendererObj); + super.drawHoveringText(lines, i - guiLeft, j - guiTop, this.fontRendererObj); GL11.glDisable(GL11.GL_LIGHTING); } GL11.glPopMatrix(); - if(scrollHeight < ySize - 8){ - i -= guiLeft; - j -= guiTop; - if(Mouse.isButtonDown(0) && !resizingActive){ - if(i >= xSize-9 && i < xSize-4 && j >= 4 && j < ySize){ + if (scrollHeight < ySize - 8) { + i -= guiLeft; + j -= guiTop; + if (Mouse.isButtonDown(0) && !resizingActive) { + if (i >= xSize - 9 && i < xSize - 4 && j >= 4 && j < ySize) { isScrolling = true; } - } - else + } else isScrolling = false; - if(isScrolling){ - scrollY = (((j - 8) * listHeight) / (ySize-8)) - (scrollHeight); - if(scrollY < 0){ + if (isScrolling) { + scrollY = (((j - 8) * listHeight) / (ySize - 8)) - (scrollHeight); + if (scrollY < 0) { scrollY = 0; } - if(scrollY > maxScrollY){ + if (scrollY > maxScrollY) { scrollY = maxScrollY; } } - if(mouseScrolled != 0){ - scrollY += mouseScrolled > 0?-14:14; - if(scrollY > maxScrollY) + if (mouseScrolled != 0) { + scrollY += mouseScrolled > 0 ? -14 : 14; + if (scrollY > maxScrollY) scrollY = maxScrollY; - if(scrollY < 0) + if (scrollY < 0) scrollY = 0; } } } - public void drawHover(int i, int j){ - if(!visible) + public void drawHover(int i, int j) { + if (!visible) return; - if(!hoverableText) + if (!hoverableText) return; GL11.glPushMatrix(); GL11.glTranslatef(guiLeft, guiTop, 0.0F); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - if(oldHover != hover){ + if (oldHover != hover) { oldHover = hover; hoverCount = 0; - } - else { - if(hoverCount < 110) + } else { + if (hoverCount < 110) hoverCount++; } - if(!hasSubGUI && hover != -1 && hoverableText && hoverCount > 100){ + if (!hasSubGUI && hover != -1 && hoverableText && hoverCount > 100) { String displayString = StatCollector.translateToLocal(list.get(hover)); GL11.glColor4f(1, 1, 1, 1); List lines = TextSplitter.splitText(displayString, 30); - super.drawHoveringText(lines, i-guiLeft, j-guiTop, this.fontRendererObj); + super.drawHoveringText(lines, i - guiLeft, j - guiTop, this.fontRendererObj); GL11.glDisable(GL11.GL_LIGHTING); } GL11.glPopMatrix(); } - public boolean mouseInOption(int i, int j, int k) - { + public boolean mouseInOption(int i, int j, int k) { int l = 4; int i1 = ((14 * k + 4) - scrollY); return i >= l - 1 && i < l + xSize - 11 && j >= i1 - 1 && j < i1 + 8; } - protected void drawItems() - { - for(int i = 0; i < list.size(); i++) - { + protected void drawItems() { + for (int i = 0; i < list.size(); i++) { int j = 4; int k = (14 * i + 4) - scrollY; - if(k >= 4 && k + 12 < ySize) - { - int xOffset = scrollHeight < ySize - 8?0:10; - String displayString = StatCollector.translateToLocal(list.get(i)); + if (k >= 4 && k + 12 < ySize) { + int xOffset = scrollHeight < ySize - 8 ? 0 : 10; + String displayString = StatCollector.translateToLocal(list.get(i)); String text = ""; float maxWidth = (xSize + xOffset - 8) * 0.8f; - if(fontRendererObj.getStringWidth(displayString) > maxWidth){ - for(int h = 0; h < displayString.length(); h++){ - char c = displayString.charAt(h); - text += c; - if(fontRendererObj.getStringWidth(text) > maxWidth) - break; - } - if(displayString.length() > text.length()) - text += "..."; - } - else - text = displayString; - if((multipleSelection && selectedList.contains(text)) || (!multipleSelection && selected == i)) { - drawVerticalLine(j-2, k-4, k + 10, 0xffffffff); - drawVerticalLine(j + xSize - 18 + xOffset, k - 4, k + 10, 0xffffffff); - drawHorizontalLine(j - 2, j + xSize - 18 + xOffset, k - 3 , 0xffffffff); - drawHorizontalLine(j - 2, j + xSize - 18 + xOffset, k + 10 , 0xffffffff); - fontRendererObj.drawString(text, j , k, 0xffffff); - } - else if(i == hover){ - fontRendererObj.drawString(text, j , k, 0x00ff00); - } - else - fontRendererObj.drawString(text, j , k, 0xffffff); + if (fontRendererObj.getStringWidth(displayString) > maxWidth) { + for (int h = 0; h < displayString.length(); h++) { + char c = displayString.charAt(h); + text += c; + if (fontRendererObj.getStringWidth(text) > maxWidth) + break; + } + if (displayString.length() > text.length()) + text += "..."; + } else + text = displayString; + if ((multipleSelection && selectedList.contains(text)) || (!multipleSelection && selected == i)) { + drawVerticalLine(j - 2, k - 4, k + 10, 0xffffffff); + drawVerticalLine(j + xSize - 18 + xOffset, k - 4, k + 10, 0xffffffff); + drawHorizontalLine(j - 2, j + xSize - 18 + xOffset, k - 3, 0xffffffff); + drawHorizontalLine(j - 2, j + xSize - 18 + xOffset, k + 10, 0xffffffff); + fontRendererObj.drawString(text, j, k, 0xffffff); + } else if (i == hover) { + fontRendererObj.drawString(text, j, k, 0x00ff00); + } else + fontRendererObj.drawString(text, j, k, 0xffffff); } } } - public String getSelected(){ - if(selected == -1 || selected >= list.size() ) - return null; - return list.get(selected); + public String getSelected() { + if (selected == -1 || selected >= list.size()) + return null; + return list.get(selected); } - private int getMouseOver(int i, int j){ - i -= guiLeft; - j -= guiTop; - //fontRenderer.drawString(".", i , j, 0xffffff); - if(i >= 4 && i < xSize - 4 && j >= 4 && j < ySize) - { - for(int j1 = 0; j1 < list.size(); j1++) - { - if(!mouseInOption(i, j, j1)) - { + + private int getMouseOver(int i, int j) { + i -= guiLeft; + j -= guiTop; + //fontRenderer.drawString(".", i , j, 0xffffff); + if (i >= 4 && i < xSize - 4 && j >= 4 && j < ySize) { + for (int j1 = 0; j1 < list.size(); j1++) { + if (!mouseInOption(i, j, j1)) { continue; } @@ -260,32 +245,31 @@ public class GuiCustomScroll extends GuiScreen } - return -1; + return -1; } - public void mouseClicked(int i, int j, int k) - { - if(resizingActive) + public void mouseClicked(int i, int j, int k) { + if (resizingActive) return; - if(k != 0 || hover < 0) - return; - if(multipleSelection) { - if(selectedList.contains(list.get(hover))) { - selectedList.remove(list.get(hover)); - } else { - selectedList.add(list.get(hover)); - } - } else { - if(hover >= 0) - selected = hover; - hover = -1; - } + if (k != 0 || hover < 0) + return; + if (multipleSelection) { + if (selectedList.contains(list.get(hover))) { + selectedList.remove(list.get(hover)); + } else { + selectedList.add(list.get(hover)); + } + } else { + if (hover >= 0) + selected = hover; + hover = -1; + } - if(listener != null) { + if (listener != null) { long time = System.currentTimeMillis(); listener.customScrollClicked(i, j, k, this); - if(selected >= 0 && selected == lastClickedItem && time - lastClickedTime < 500) { + if (selected >= 0 && selected == lastClickedItem && time - lastClickedTime < 500) { listener.customScrollDoubleClicked(list.get(selected), this); } lastClickedTime = time; @@ -293,94 +277,99 @@ public class GuiCustomScroll extends GuiScreen } } - private void drawScrollBar() - { + private void drawScrollBar() { int i = guiLeft + xSize - 9; - int j = guiTop + (int)(((double)scrollY / (double)listHeight) * (double)(ySize-8)) + 4; + int j = guiTop + (int) (((double) scrollY / (double) listHeight) * (double) (ySize - 8)) + 4; int k = j; drawTexturedModalRect(i, k, xSize, 9, 5, 1); - for(k++; k < (j + scrollHeight) - 1; k++) - { + for (k++; k < (j + scrollHeight) - 1; k++) { drawTexturedModalRect(i, k, xSize, 10, 5, 1); } drawTexturedModalRect(i, k, xSize, 11, 5, 1); } - public boolean hasSelected() { - return selected >= 0; - } + public boolean hasSelected() { - public void setList(List list){ - isSorted = true; + return selected >= 0; + } + + public void setList(List list) { + isSorted = true; list.removeAll(Collections.singleton(null)); Collections.sort(list, String.CASE_INSENSITIVE_ORDER); - this.list = list; - setSize(xSize,ySize); - } + this.list = list; + setSize(xSize, ySize); + } - public void setList(List list, boolean ascending, boolean caseOrder){ + public void setList(List list, boolean ascending, boolean caseOrder) { isSorted = true; - if(caseOrder){ + if (caseOrder) { Collections.sort(list, String.CASE_INSENSITIVE_ORDER); } - if(!ascending){ + if (!ascending) { Collections.reverse(list); } this.list = list; - setSize(xSize,ySize); + setSize(xSize, ySize); } - public void setUnsortedList(List list){ - isSorted = false; - this.list = list; - setSize(xSize,ySize); - } - public void replace(String old, String name) { - String select = getSelected(); - list.remove(old); - list.add(name); - if(isSorted) - Collections.sort(list,String.CASE_INSENSITIVE_ORDER); - if(old.equals(select)) - select = name; + public void setUnsortedList(List list) { + isSorted = false; + this.list = list; + setSize(xSize, ySize); + } - selected = list.indexOf(select); - setSize(xSize,ySize); - } - public void setSelected(String name) { - selected = list.indexOf(name); - } - public void clear() { + public void replace(String old, String name) { + String select = getSelected(); + list.remove(old); + list.add(name); + if (isSorted) + Collections.sort(list, String.CASE_INSENSITIVE_ORDER); + if (old.equals(select)) + select = name; + + selected = list.indexOf(select); + setSize(xSize, ySize); + } + + public void setSelected(String name) { + selected = list.indexOf(name); + } + + public void clear() { list = new ArrayList(); - selected = -1; - scrollY = 0; - setSize(xSize,ySize); - } - public List getList() { - return list; - } - public HashSet getSelectedList() { - return selectedList; - } - public void setSelectedList(HashSet selectedList) { - this.selectedList = selectedList; - } - public GuiCustomScroll setUnselectable() { - selectable = false; - return this; - } + selected = -1; + scrollY = 0; + setSize(xSize, ySize); + } + + public List getList() { + return list; + } + + public HashSet getSelectedList() { + return selectedList; + } + + public void setSelectedList(HashSet selectedList) { + this.selectedList = selectedList; + } + + public GuiCustomScroll setUnselectable() { + selectable = false; + return this; + } public boolean isMouseOver(int x, int y) { return x >= this.guiLeft && x <= this.guiLeft + this.xSize && y >= this.guiTop && y <= this.guiTop + this.ySize; } - public void resetScroll(){ + public void resetScroll() { scrollY = 0; } - public void updateSubGUI(boolean hasSubGUI) - { + public void updateSubGUI(boolean hasSubGUI) { this.hasSubGUI = hasSubGUI; } } diff --git a/src/main/java/noppes/npcs/client/gui/util/GuiCustomScrollCloner.java b/src/main/java/noppes/npcs/client/gui/util/GuiCustomScrollCloner.java index 4635fce02..a69d449e7 100644 --- a/src/main/java/noppes/npcs/client/gui/util/GuiCustomScrollCloner.java +++ b/src/main/java/noppes/npcs/client/gui/util/GuiCustomScrollCloner.java @@ -14,54 +14,50 @@ public class GuiCustomScrollCloner extends GuiCustomScroll { this.parent = parent; } - protected void drawItems() - { + protected void drawItems() { int l = 0; - for(int i = 0; i < list.size(); i++) - { + for (int i = 0; i < list.size(); i++) { int j = 4; int k = (14 * l + 4) - scrollY; l++; - if(k >= 4 && k + 12 < ySize) - { + if (k >= 4 && k + 12 < ySize) { - int xOffset = scrollHeight < ySize - 8?0:10; + int xOffset = scrollHeight < ySize - 8 ? 0 : 10; String displayString = StatCollector.translateToLocal(list.get(i)); String text = ""; float maxWidth = (xSize + xOffset - 8) * 0.8f; - if(fontRendererObj.getStringWidth(displayString) > maxWidth){ - for(int h = 0; h < displayString.length(); h++){ + if (fontRendererObj.getStringWidth(displayString) > maxWidth) { + for (int h = 0; h < displayString.length(); h++) { char c = displayString.charAt(h); text += c; - if(fontRendererObj.getStringWidth(text) > maxWidth) + if (fontRendererObj.getStringWidth(text) > maxWidth) break; } - if(displayString.length() > text.length()) + if (displayString.length() > text.length()) text += "..."; - } - else + } else text = displayString; - if((multipleSelection && selectedList.contains(text)) || (!multipleSelection && selected == i)) { - drawVerticalLine(j-2, k-4, k + 10, 0xffffffff); + if ((multipleSelection && selectedList.contains(text)) || (!multipleSelection && selected == i)) { + drawVerticalLine(j - 2, k - 4, k + 10, 0xffffffff); drawVerticalLine(j + xSize - 18 + xOffset, k - 4, k + 10, 0xffffffff); - drawHorizontalLine(j - 2, j + xSize - 18 + xOffset, k - 3 , 0xffffffff); - drawHorizontalLine(j - 2, j + xSize - 18 + xOffset, k + 10 , 0xffffffff); - fontRendererObj.drawString(text, j , k, this.colors.getOrDefault(text, 0xffffff)); - } else if(i == hover) { + drawHorizontalLine(j - 2, j + xSize - 18 + xOffset, k - 3, 0xffffffff); + drawHorizontalLine(j - 2, j + xSize - 18 + xOffset, k + 10, 0xffffffff); + fontRendererObj.drawString(text, j, k, this.colors.getOrDefault(text, 0xffffff)); + } else if (i == hover) { fontRendererObj.drawString(text, j, k, 0x00ff00); } else { fontRendererObj.drawString(text, j, k, this.colors.getOrDefault(text, 0xffffff)); } - if((this.parent.getShowingClones() == 0 || this.parent.getShowingClones() == 2) && this.parent.tagMap != null){ + if ((this.parent.getShowingClones() == 0 || this.parent.getShowingClones() == 2) && this.parent.tagMap != null) { int tagStartX = j + fontRendererObj.getStringWidth(displayString) + 3; - if(GuiNpcMobSpawner.displayTags == 0 || GuiNpcMobSpawner.displayTags == 1){ + if (GuiNpcMobSpawner.displayTags == 0 || GuiNpcMobSpawner.displayTags == 1) { if (this.parent.tagMap.hasClone(list.get(i))) { - for (UUID tagUUID : this.parent.tagMap.getUUIDsList(list.get(i))){ + for (UUID tagUUID : this.parent.tagMap.getUUIDsList(list.get(i))) { Tag tag = this.parent.tags.get(tagUUID); - if(tag != null){ - if(GuiNpcMobSpawner.displayTags == 1 || !tag.getIsHidden()){ + if (tag != null) { + if (GuiNpcMobSpawner.displayTags == 1 || !tag.getIsHidden()) { fontRendererObj.drawString("[" + tag.name + "]", tagStartX, k, tag.color); tagStartX += fontRendererObj.getStringWidth("[" + tag.name + "]") + 3; } diff --git a/src/main/java/noppes/npcs/client/gui/util/GuiDiagram.java b/src/main/java/noppes/npcs/client/gui/util/GuiDiagram.java index f4c585526..2f6aacb08 100644 --- a/src/main/java/noppes/npcs/client/gui/util/GuiDiagram.java +++ b/src/main/java/noppes/npcs/client/gui/util/GuiDiagram.java @@ -10,12 +10,13 @@ import org.lwjgl.input.Mouse; import org.lwjgl.opengl.GL11; import java.awt.*; -import java.util.*; import java.util.List; +import java.util.Queue; +import java.util.*; /** * Abstract GUI class for drawing diagrams with icons (nodes) and connections (arrows). - * + *

* This revised version ensures that non‑Chart layouts use the full diagram bounds for positioning * (so that the outer icons lie flush with the edges) and that curved arrow drawing selects the * best control point (using both curveAngle and its negative) to avoid icons. @@ -60,6 +61,7 @@ public abstract class GuiDiagram extends Gui { public void setCurvedArrows(boolean curved) { this.curvedArrows = curved; } + public void setCurveAngle(int angle) { this.curveAngle = angle; } @@ -88,6 +90,7 @@ public abstract class GuiDiagram extends Gui { // --- Data Providers (subclasses must implement) --- protected abstract List createIcons(); + protected abstract List createConnections(); protected final List getIcons() { @@ -96,6 +99,7 @@ public abstract class GuiDiagram extends Gui { } return iconsCache; } + protected final List getConnections() { if (connectionsCache == null) { connectionsCache = createConnections(); @@ -108,7 +112,9 @@ public abstract class GuiDiagram extends Gui { */ protected abstract void renderIcon(DiagramIcon icon, int posX, int posY, IconRenderState state); - protected List getIconTooltip(DiagramIcon icon) { return null; } + protected List getIconTooltip(DiagramIcon icon) { + return null; + } protected List getConnectionTooltip(DiagramConnection conn) { List tooltip = new ArrayList<>(); @@ -125,9 +131,13 @@ public abstract class GuiDiagram extends Gui { } return tooltip; } - protected String getIconName(DiagramIcon icon) { return "Icon " + icon.id; } + + protected String getIconName(DiagramIcon icon) { + return "Icon " + icon.id; + } // --- Layout Calculation --- + /** * For non‑CHART layouts, returns a mapping from node ID to (x,y) position. */ @@ -284,6 +294,7 @@ public abstract class GuiDiagram extends Gui { } return graph; } + private List> getConnectedComponents(Map> graph) { Set visited = new HashSet<>(); List> components = new ArrayList<>(); @@ -296,6 +307,7 @@ public abstract class GuiDiagram extends Gui { } return components; } + private void dfsComponent(Integer current, Map> graph, Set visited, Set comp) { visited.add(current); comp.add(current); @@ -304,6 +316,7 @@ public abstract class GuiDiagram extends Gui { dfsComponent(neighbor, graph, visited, comp); } } + private boolean isCycle(Set cluster, Map> graph) { if (cluster.size() < 3) return false; for (Integer node : cluster) { @@ -315,6 +328,7 @@ public abstract class GuiDiagram extends Gui { } return true; } + private boolean isTree(Set cluster, Map> graph) { int edgeCount = 0; for (Integer node : cluster) { @@ -325,6 +339,7 @@ public abstract class GuiDiagram extends Gui { edgeCount /= 2; return edgeCount == cluster.size() - 1; } + private boolean isSquare(Set cluster) { int n = cluster.size(); int sqrt = (int) Math.round(Math.sqrt(n)); @@ -488,8 +503,8 @@ public abstract class GuiDiagram extends Gui { double[] d = disp.get(id); double dispLength = Math.sqrt(d[0] * d[0] + d[1] * d[1]); if (dispLength < 0.01) dispLength = 0.01; - int newX = positions.get(id).x + (int)((d[0] / dispLength) * Math.min(dispLength, temperature)); - int newY = positions.get(id).y + (int)((d[1] / dispLength) * Math.min(dispLength, temperature)); + int newX = positions.get(id).x + (int) ((d[0] / dispLength) * Math.min(dispLength, temperature)); + int newY = positions.get(id).y + (int) ((d[1] / dispLength) * Math.min(dispLength, temperature)); newX = Math.max(compX, Math.min(compX + compWidth, newX)); newY = Math.max(compY, Math.min(compY + compHeight, newY)); positions.get(id).x = newX; @@ -588,9 +603,9 @@ public abstract class GuiDiagram extends Gui { List levelIcons = entry.getValue(); levelIcons.sort(Comparator.comparingInt(icon -> icon.priority)); int m = levelIcons.size(); - int posY = (m > 0 && maxLevel > 0) ? y + (int)((height * level) / (maxLevel)) : y + height / 2; + int posY = (m > 0 && maxLevel > 0) ? y + (int) ((height * level) / (maxLevel)) : y + height / 2; for (int i = 0; i < m; i++) { - int posX = (m > 1) ? x + (int)((width * i) / (m - 1.0)) : x + width / 2; + int posX = (m > 1) ? x + (int) ((width * i) / (m - 1.0)) : x + width / 2; positions.put(levelIcons.get(i).id, new Point(posX, posY)); } } @@ -598,6 +613,7 @@ public abstract class GuiDiagram extends Gui { } // --- Curved Arrow Helpers --- + /** * Computes a quadratic Bezier control point given endpoints and an angle (in degrees). */ @@ -608,8 +624,8 @@ public abstract class GuiDiagram extends Gui { double angleRad = Math.toRadians(angleDegrees); double offset = len * Math.tan(angleRad) / 2; double perpX = -dy / len, perpY = dx / len; - return new Point((x1 + x2) / 2 + (int)(perpX * offset), - (y1 + y2) / 2 + (int)(perpY * offset)); + return new Point((x1 + x2) / 2 + (int) (perpX * offset), + (y1 + y2) / 2 + (int) (perpY * offset)); } /** @@ -642,7 +658,11 @@ public abstract class GuiDiagram extends Gui { float r = ((color >> 16) & 0xFF) / 255f; float g = ((color >> 8) & 0xFF) / 255f; float b = (color & 0xFF) / 255f; - if (dim) { r *= 0.4f; g *= 0.4f; b *= 0.4f; } + if (dim) { + r *= 0.4f; + g *= 0.4f; + b *= 0.4f; + } GL11.glColor4f(r, g, b, 1f); GL11.glBegin(GL11.GL_LINES); GL11.glVertex2i(x1, y1); @@ -669,14 +689,18 @@ public abstract class GuiDiagram extends Gui { float rr = ((color >> 16) & 0xFF) / 255f; float gg = ((color >> 8) & 0xFF) / 255f; float bb = (color & 0xFF) / 255f; - if (dim) { rr *= 0.4f; gg *= 0.4f; bb *= 0.4f; } + if (dim) { + rr *= 0.4f; + gg *= 0.4f; + bb *= 0.4f; + } GL11.glColor4f(rr, gg, bb, 1f); GL11.glBegin(GL11.GL_LINE_STRIP); for (int i = 0; i <= segments; i++) { double t = (double) i / segments; - int bx = (int)((1 - t) * (1 - t) * x1 + 2 * (1 - t) * t * control.x + t * t * x2); - int by = (int)((1 - t) * (1 - t) * y1 + 2 * (1 - t) * t * control.y + t * t * y2); + int bx = (int) ((1 - t) * (1 - t) * x1 + 2 * (1 - t) * t * control.x + t * t * x2); + int by = (int) ((1 - t) * (1 - t) * y1 + 2 * (1 - t) * t * control.y + t * t * y2); GL11.glVertex2i(bx, by); } GL11.glEnd(); @@ -711,19 +735,23 @@ public abstract class GuiDiagram extends Gui { double dBy = 2 * (1 - t) * (control.y - y1) + 2 * t * (y2 - control.y); angle = Math.atan2(dBy, dBx); } - float defenderEdgeX = x2 - (slotSize / 2f) * (float)Math.cos(angle); - float defenderEdgeY = y2 - (slotSize / 2f) * (float)Math.sin(angle); + float defenderEdgeX = x2 - (slotSize / 2f) * (float) Math.cos(angle); + float defenderEdgeY = y2 - (slotSize / 2f) * (float) Math.sin(angle); int arrowSize = 6; - float leftX = defenderEdgeX - arrowSize * (float)Math.cos(angle - Math.PI / 6); - float leftY = defenderEdgeY - arrowSize * (float)Math.sin(angle - Math.PI / 6); - float rightX = defenderEdgeX - arrowSize * (float)Math.cos(angle + Math.PI / 6); - float rightY = defenderEdgeY - arrowSize * (float)Math.sin(angle + Math.PI / 6); + float leftX = defenderEdgeX - arrowSize * (float) Math.cos(angle - Math.PI / 6); + float leftY = defenderEdgeY - arrowSize * (float) Math.sin(angle - Math.PI / 6); + float rightX = defenderEdgeX - arrowSize * (float) Math.cos(angle + Math.PI / 6); + float rightY = defenderEdgeY - arrowSize * (float) Math.sin(angle + Math.PI / 6); GL11.glPushAttrib(GL11.GL_ENABLE_BIT); GL11.glDisable(GL11.GL_TEXTURE_2D); float rr = ((color >> 16) & 0xFF) / 255f; float gg = ((color >> 8) & 0xFF) / 255f; float bb = (color & 0xFF) / 255f; - if (dim) { rr *= 0.4f; gg *= 0.4f; bb *= 0.4f; } + if (dim) { + rr *= 0.4f; + gg *= 0.4f; + bb *= 0.4f; + } GL11.glColor4f(rr, gg, bb, 1f); GL11.glDisable(GL11.GL_CULL_FACE); GL11.glBegin(GL11.GL_TRIANGLES); @@ -747,13 +775,14 @@ public abstract class GuiDiagram extends Gui { drawVerticalLine(slotX + slotSize - 1 - i, slotY + i, slotY + slotSize - i, iconBorderColor); } } + protected int mixColors(int color1, int color2, float ratio) { int a1 = (color1 >> 24) & 0xFF, r1 = (color1 >> 16) & 0xFF, g1 = (color1 >> 8) & 0xFF, b1 = color1 & 0xFF; int a2 = (color2 >> 24) & 0xFF, r2 = (color2 >> 16) & 0xFF, g2 = (color2 >> 8) & 0xFF, b2 = color2 & 0xFF; - int a = (int)(a1 + (a2 - a1) * ratio); - int r = (int)(r1 + (r2 - r1) * ratio); - int g = (int)(g1 + (g2 - g1) * ratio); - int b = (int)(b1 + (b2 - b1) * ratio); + int a = (int) (a1 + (a2 - a1) * ratio); + int r = (int) (r1 + (r2 - r1) * ratio); + int g = (int) (g1 + (g2 - g1) * ratio); + int b = (int) (b1 + (b2 - b1) * ratio); return (a << 24) | (r << 16) | (g << 8) | b; } @@ -762,9 +791,9 @@ public abstract class GuiDiagram extends Gui { double minDist = Double.MAX_VALUE; Point prev = null; for (int i = 0; i <= segments; i++) { - double t = (double)i / segments; - int x = (int)((1 - t) * (1 - t) * start.x + 2 * (1 - t) * t * control.x + t * t * end.x); - int y = (int)((1 - t) * (1 - t) * start.y + 2 * (1 - t) * t * control.y + t * t * end.y); + double t = (double) i / segments; + int x = (int) ((1 - t) * (1 - t) * start.x + 2 * (1 - t) * t * control.x + t * t * end.x); + int y = (int) ((1 - t) * (1 - t) * start.y + 2 * (1 - t) * t * control.y + t * t * end.y); Point curr = new Point(x, y); if (prev != null) { double d = distancePointToSegment(px, py, prev, curr); @@ -774,15 +803,23 @@ public abstract class GuiDiagram extends Gui { } return minDist; } + private double distancePointToSegment(int px, int py, Point a, Point b) { double A = px - a.x, B = py - a.y, C = b.x - a.x, D = b.y - a.y; double dot = A * C + B * D; double lenSq = C * C + D * D; double param = (lenSq != 0) ? (dot / lenSq) : -1; double xx, yy; - if (param < 0) { xx = a.x; yy = a.y; } - else if (param > 1) { xx = b.x; yy = b.y; } - else { xx = a.x + param * C; yy = a.y + param * D; } + if (param < 0) { + xx = a.x; + yy = a.y; + } else if (param > 1) { + xx = b.x; + yy = b.y; + } else { + xx = a.x + param * C; + yy = a.y + param * D; + } double dx = px - xx, dy = py - yy; return Math.sqrt(dx * dx + dy * dy); } @@ -824,8 +861,8 @@ public abstract class GuiDiagram extends Gui { int factor = sr.getScaleFactor(); Map positions = calculatePositions(); int centerX = x + width / 2, centerY = y + height / 2; - int effectiveMouseX = (int)(((float)mouseX - (centerX + panX)) / zoom + centerX); - int effectiveMouseY = (int)(((float)mouseY - (centerY + panY)) / zoom + centerY); + int effectiveMouseX = (int) (((float) mouseX - (centerX + panX)) / zoom + centerX); + int effectiveMouseY = (int) (((float) mouseY - (centerY + panY)) / zoom + centerY); Integer hoveredIconId = null; int hoveredConnFrom = -1, hoveredConnTo = -1; Set selectedIconIds = new HashSet<>(); @@ -947,12 +984,14 @@ public abstract class GuiDiagram extends Gui { } return null; } + protected DiagramConnection getConnectionByIds(int idFrom, int idTo) { for (DiagramConnection conn : getConnections()) { if (conn.idFrom == idFrom && conn.idTo == idTo) return conn; } return null; } + protected int getConnectionColor(DiagramConnection conn) { float percent = conn.percent; if (percent <= 0.10f) return 0xFF80FF80; @@ -963,21 +1002,29 @@ public abstract class GuiDiagram extends Gui { ratio = Math.min(1f, Math.max(0f, ratio)); int r1 = 0xFF, g1 = 0xA5, b1 = 0x00; int r2 = 0xFF, g2 = 0x00, b2 = 0x00; - int r = r1 + (int)((r2 - r1) * ratio); - int g = g1 + (int)((g2 - g1) * ratio); - int b = b1 + (int)((b2 - b1) * ratio); + int r = r1 + (int) ((r2 - r1) * ratio); + int g = g1 + (int) ((g2 - g1) * ratio); + int b = b1 + (int) ((b2 - b1) * ratio); return (0xFF << 24) | (r << 16) | (g << 8) | b; } } + private double pointLineDistance(int px, int py, int x1, int y1, int x2, int y2) { double A = px - x1, B = py - y1, C = x2 - x1, D = y2 - y1; double dot = A * C + B * D; double lenSq = C * C + D * D; double param = (lenSq != 0) ? (dot / lenSq) : -1; double xx, yy; - if (param < 0) { xx = x1; yy = y1; } - else if (param > 1) { xx = x2; yy = y2; } - else { xx = x1 + param * C; yy = y1 + param * D; } + if (param < 0) { + xx = x1; + yy = y1; + } else if (param > 1) { + xx = x2; + yy = y2; + } else { + xx = x1 + param * C; + yy = y1 + param * D; + } double dx = px - xx, dy = py - yy; return Math.sqrt(dx * dx + dy * dy); } @@ -991,8 +1038,8 @@ public abstract class GuiDiagram extends Gui { Point pos = calculatePositions().get(icon.id); if (pos == null) continue; int centerX = x + width / 2, centerY = y + height / 2; - int effectiveX = (int)(((float)mouseX - (centerX + panX)) / zoom + centerX); - int effectiveY = (int)(((float)mouseY - (centerY + panY)) / zoom + centerY); + int effectiveX = (int) (((float) mouseX - (centerX + panX)) / zoom + centerX); + int effectiveY = (int) (((float) mouseY - (centerY + panY)) / zoom + centerY); int slotX = pos.x - slotSize / 2, slotY = pos.y - slotSize / 2; if (effectiveX >= slotX && effectiveX < slotX + slotSize && effectiveY >= slotY && effectiveY < slotY + slotSize) { @@ -1010,7 +1057,9 @@ public abstract class GuiDiagram extends Gui { } return false; } + protected DiagramIcon currentlyPressedIcon = null; + public void mouseClickMove(int mouseX, int mouseY, int mouseButton, long timeSinceLastClick) { if (parent != null && parent.hasSubGui()) return; if (dragging) { @@ -1022,6 +1071,7 @@ public abstract class GuiDiagram extends Gui { } if (currentlyPressedIcon != null) onIconHeld(currentlyPressedIcon); } + public void mouseReleased(int mouseX, int mouseY, int state) { if (parent != null && parent.hasSubGui()) return; if (currentlyPressedIcon != null) { @@ -1030,32 +1080,46 @@ public abstract class GuiDiagram extends Gui { } dragging = false; } + public boolean isWithin(int mouseX, int mouseY) { if (parent.hasSubGui()) return false; return mouseX >= x && mouseX <= x + width && mouseY >= y && mouseY <= y + height; } + public void handleMouseScroll(int scrollDelta) { zoom += scrollDelta * 0.0009f; if (zoom < 0.5f) zoom = 0.5f; if (zoom > 2.0f) zoom = 2.0f; } - protected void drawHoveringText(List textLines, int mouseX, int mouseY, FontRenderer font) {} + + protected void drawHoveringText(List textLines, int mouseX, int mouseY, FontRenderer font) { + } // --- Flag Setters --- public void setShowArrowHeads(boolean showArrowHeads) { this.showArrowHeads = showArrowHeads; } + public void setUseColorScaling(boolean useColorScaling) { this.useColorScaling = useColorScaling; } // --- Icon and Connection Event Callbacks --- - protected void onIconClick(DiagramIcon icon) {} - protected void onIconHeld(DiagramIcon icon) {} - protected void onIconRelease(DiagramIcon icon) {} - protected void onIconHover(DiagramIcon icon) {} - protected void onConnectionHover(DiagramConnection conn) {} + protected void onIconClick(DiagramIcon icon) { + } + + protected void onIconHeld(DiagramIcon icon) { + } + + protected void onIconRelease(DiagramIcon icon) { + } + + protected void onIconHover(DiagramIcon icon) { + } + + protected void onConnectionHover(DiagramConnection conn) { + } // --- Inner Helper Classes --- public static class DiagramIcon { @@ -1064,7 +1128,11 @@ public abstract class GuiDiagram extends Gui { public boolean pressable = false; public int index = 0; public int priority = 0; - public DiagramIcon(int id) { this.id = id; } + + public DiagramIcon(int id) { + this.id = id; + } + public DiagramIcon(int id, int index, int priority) { this.id = id; this.index = index; @@ -1076,6 +1144,7 @@ public abstract class GuiDiagram extends Gui { public int idFrom, idTo; public float percent; public String hoverText; + public DiagramConnection(int idFrom, int idTo, float percent, String hoverText) { this.idFrom = idFrom; this.idTo = idTo; diff --git a/src/main/java/noppes/npcs/client/gui/util/GuiEffectBar.java b/src/main/java/noppes/npcs/client/gui/util/GuiEffectBar.java index 7aa4119a2..a390ddfc1 100644 --- a/src/main/java/noppes/npcs/client/gui/util/GuiEffectBar.java +++ b/src/main/java/noppes/npcs/client/gui/util/GuiEffectBar.java @@ -5,7 +5,6 @@ import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.gui.ScaledResolution; import net.minecraft.client.renderer.texture.TextureManager; -import net.minecraft.util.ResourceLocation; import noppes.npcs.client.ClientCacheHandler; import noppes.npcs.client.renderer.ImageData; import noppes.npcs.controllers.data.CustomEffect; @@ -111,7 +110,7 @@ public class GuiEffectBar extends GuiScreen { // Draw vertical scrollbar if (totalHeight > height) { int scrollBarWidth = 4; - int scrollBarX = x + width - scrollBarWidth - 2 + 10 ; + int scrollBarX = x + width - scrollBarWidth - 2 + 10; drawRect(scrollBarX, y, scrollBarX + scrollBarWidth, y + height, 0xFF333333); int thumbHeight = Math.max(20, height * height / totalHeight); int thumbY = y + (scrollY * (height - thumbHeight)) / (totalHeight - height); @@ -205,6 +204,7 @@ public class GuiEffectBar extends GuiScreen { public static class EffectEntry { public CustomEffect effect; public PlayerEffect playerEffect; + public EffectEntry(CustomEffect effect, PlayerEffect playerEffect) { this.effect = effect; this.playerEffect = playerEffect; diff --git a/src/main/java/noppes/npcs/client/gui/util/GuiHoverText.java b/src/main/java/noppes/npcs/client/gui/util/GuiHoverText.java index 8ed276b6b..8e5d3f722 100644 --- a/src/main/java/noppes/npcs/client/gui/util/GuiHoverText.java +++ b/src/main/java/noppes/npcs/client/gui/util/GuiHoverText.java @@ -7,35 +7,37 @@ import org.lwjgl.opengl.GL11; import java.util.ArrayList; import java.util.List; -public class GuiHoverText extends GuiScreen{ - private int x, y; - public int id; +public class GuiHoverText extends GuiScreen { + private int x, y; + public int id; protected static final ResourceLocation buttonTextures = new ResourceLocation("customnpcs:textures/gui/info.png"); - private String text; - public GuiHoverText(int id, String text, int x, int y){ - this.text = text; - this.id = id; - this.x = x; - this.y = y; - } - - @Override - public void drawScreen(int par1, int par2, float par3){ - GL11.glColor4f(1, 1, 1, 1); + private String text; + + public GuiHoverText(int id, String text, int x, int y) { + this.text = text; + this.id = id; + this.x = x; + this.y = y; + } + + @Override + public void drawScreen(int par1, int par2, float par3) { + GL11.glColor4f(1, 1, 1, 1); mc.getTextureManager().bindTexture(buttonTextures); this.drawTexturedModalRect(this.x, this.y, 0, 0, 12, 12); - - if(inArea(x, y, 12, 12, par1, par2)){ - List lines = new ArrayList(); - lines.add(text); - this.drawHoveringText(lines, x + 8, y + 6, this.fontRendererObj); - GL11.glDisable(GL11.GL_LIGHTING); + + if (inArea(x, y, 12, 12, par1, par2)) { + List lines = new ArrayList(); + lines.add(text); + this.drawHoveringText(lines, x + 8, y + 6, this.fontRendererObj); + GL11.glDisable(GL11.GL_LIGHTING); } } - public boolean inArea(int x, int y, int width, int height, int mouseX, int mouseY){ - if(mouseX < x || mouseX > x + width || mouseY < y || mouseY > y + height) - return false; - return true; - } + + public boolean inArea(int x, int y, int width, int height, int mouseX, int mouseY) { + if (mouseX < x || mouseX > x + width || mouseY < y || mouseY > y + height) + return false; + return true; + } } diff --git a/src/main/java/noppes/npcs/client/gui/util/GuiMenuSideButton.java b/src/main/java/noppes/npcs/client/gui/util/GuiMenuSideButton.java index 3359f2880..0aa6c7d3d 100644 --- a/src/main/java/noppes/npcs/client/gui/util/GuiMenuSideButton.java +++ b/src/main/java/noppes/npcs/client/gui/util/GuiMenuSideButton.java @@ -9,9 +9,9 @@ import net.minecraft.util.ResourceLocation; import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; -public class GuiMenuSideButton extends GuiNpcButton{ - public static final ResourceLocation resource = new ResourceLocation("customnpcs","textures/gui/menusidebutton.png"); - public static final ResourceLocation resource2 = new ResourceLocation("customnpcs","textures/gui/menusidebutton2.png"); +public class GuiMenuSideButton extends GuiNpcButton { + public static final ResourceLocation resource = new ResourceLocation("customnpcs", "textures/gui/menusidebutton.png"); + public static final ResourceLocation resource2 = new ResourceLocation("customnpcs", "textures/gui/menusidebutton2.png"); public boolean active; public boolean rightSided; @@ -20,40 +20,40 @@ public class GuiMenuSideButton extends GuiNpcButton{ public int renderIconPosX = 0; public int renderIconPosY = 0; - public GuiMenuSideButton(int id, int x, int y, String s){ + public GuiMenuSideButton(int id, int x, int y, String s) { this(id, x, y, 200, 20, s); } - public GuiMenuSideButton(int id, int x, int y, int width, int height, String s){ - super(id, x, y, width, height, s); + public GuiMenuSideButton(int id, int x, int y, int width, int height, String s) { + super(id, x, y, width, height, s); active = false; } @Override - public int getHoverState(boolean flag){ + public int getHoverState(boolean flag) { if (active) return 0; return super.getHoverState(flag); } @Override - public void drawButton(Minecraft minecraft, int i, int j){ - if (!visible){ + public void drawButton(Minecraft minecraft, int i, int j) { + if (!visible) { return; } FontRenderer fontrenderer = minecraft.fontRenderer; GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - int width = this.width + (active?2:0); + int width = this.width + (active ? 2 : 0); field_146123_n = i >= xPosition && j >= yPosition && i < xPosition + width && j < yPosition + height; int k = getHoverState(field_146123_n); if (this.rightSided) { minecraft.renderEngine.bindTexture(resource2); - drawTexturedModalRect(xPosition, yPosition, 197 - width, k * 22, width, height); + drawTexturedModalRect(xPosition, yPosition, 197 - width, k * 22, width, height); } else { minecraft.renderEngine.bindTexture(resource); - drawTexturedModalRect(xPosition, yPosition, 0, k * 22, width, height); + drawTexturedModalRect(xPosition, yPosition, 0, k * 22, width, height); } mouseDragged(minecraft, i, j); @@ -61,7 +61,7 @@ public class GuiMenuSideButton extends GuiNpcButton{ if (this.renderResource != null) { this.zLevel = 100.0F; minecraft.renderEngine.bindTexture(renderResource); - drawTexturedModalRect(xPosition + 2, yPosition + height/2 - 8, renderIconPosX, renderIconPosY, 16, 16); + drawTexturedModalRect(xPosition + 2, yPosition + height / 2 - 8, renderIconPosX, renderIconPosY, 16, 16); this.zLevel = 0.0F; } @@ -74,9 +74,9 @@ public class GuiMenuSideButton extends GuiNpcButton{ GL11.glEnable(GL11.GL_LIGHTING); GL11.glEnable(GL12.GL_RESCALE_NORMAL); itemRenderer.renderItemAndEffectIntoGUI(minecraft.fontRenderer, - minecraft.renderEngine, this.renderStack, xPosition + 2, yPosition + height/2 - 8); + minecraft.renderEngine, this.renderStack, xPosition + 2, yPosition + height / 2 - 8); itemRenderer.renderItemOverlayIntoGUI(minecraft.fontRenderer, - minecraft.renderEngine, this.renderStack, xPosition + 2, yPosition + height/2 - 8); + minecraft.renderEngine, this.renderStack, xPosition + 2, yPosition + height / 2 - 8); GL11.glDisable(GL11.GL_LIGHTING); GL11.glEnable(GL11.GL_BLEND); itemRenderer.zLevel = 0.0F; @@ -86,39 +86,36 @@ public class GuiMenuSideButton extends GuiNpcButton{ String text = ""; float maxWidth = width * 0.75f; - if(fontrenderer.getStringWidth(displayString) > maxWidth){ - for(int h = 0; h < displayString.length(); h++){ - char c = displayString.charAt(h); - if(fontrenderer.getStringWidth(text + c) > maxWidth) - break; - text += c; - } - text += "..."; - } - else - text = displayString; - if (active){ + if (fontrenderer.getStringWidth(displayString) > maxWidth) { + for (int h = 0; h < displayString.length(); h++) { + char c = displayString.charAt(h); + if (fontrenderer.getStringWidth(text + c) > maxWidth) + break; + text += c; + } + text += "..."; + } else + text = displayString; + if (active) { drawCenteredString(fontrenderer, text, xPosition + width / 2, yPosition + (height - 8) / 2, 0xffffa0); - } - else if (field_146123_n){ + } else if (field_146123_n) { drawCenteredString(fontrenderer, text, xPosition + width / 2, yPosition + (height - 8) / 2, 0xffffa0); - } - else{ + } else { drawCenteredString(fontrenderer, text, xPosition + width / 2, yPosition + (height - 8) / 2, 0xe0e0e0); } } @Override - protected void mouseDragged(Minecraft minecraft, int i, int j){ + protected void mouseDragged(Minecraft minecraft, int i, int j) { } @Override - public void mouseReleased(int i, int j){ + public void mouseReleased(int i, int j) { } @Override - public boolean mousePressed(Minecraft minecraft, int i, int j){ + public boolean mousePressed(Minecraft minecraft, int i, int j) { return !active && visible && field_146123_n; } } diff --git a/src/main/java/noppes/npcs/client/gui/util/GuiMenuTopButton.java b/src/main/java/noppes/npcs/client/gui/util/GuiMenuTopButton.java index 33604c02c..413ca7b39 100644 --- a/src/main/java/noppes/npcs/client/gui/util/GuiMenuTopButton.java +++ b/src/main/java/noppes/npcs/client/gui/util/GuiMenuTopButton.java @@ -7,9 +7,8 @@ import net.minecraft.util.ResourceLocation; import net.minecraft.util.StatCollector; import org.lwjgl.opengl.GL11; -public class GuiMenuTopButton extends GuiNpcButton -{ - public static final ResourceLocation resource = new ResourceLocation("customnpcs","textures/gui/menutopbutton.png"); +public class GuiMenuTopButton extends GuiNpcButton { + public static final ResourceLocation resource = new ResourceLocation("customnpcs", "textures/gui/menutopbutton.png"); protected int height; public boolean active; public boolean hover = false; @@ -17,95 +16,80 @@ public class GuiMenuTopButton extends GuiNpcButton public IButtonListener listener; - public GuiMenuTopButton(int i, int j, int k, String s) - { - super(i,j,k,StatCollector.translateToLocal(s)); + public GuiMenuTopButton(int i, int j, int k, String s) { + super(i, j, k, StatCollector.translateToLocal(s)); active = false; width = Minecraft.getMinecraft().fontRenderer.getStringWidth(displayString) + 12; height = 20; } - public GuiMenuTopButton(int i, GuiButton parent, String s) - { - this(i, parent.xPosition + parent.width, parent.yPosition, s); + + public GuiMenuTopButton(int i, GuiButton parent, String s) { + this(i, parent.xPosition + parent.width, parent.yPosition, s); } public GuiMenuTopButton(int i, GuiButton parent, String s, - IButtonListener listener) { - this(i, parent, s); - this.listener = listener; - } + IButtonListener listener) { + this(i, parent, s); + this.listener = listener; + } @Override - public int getHoverState(boolean flag) - { + public int getHoverState(boolean flag) { byte byte0 = 1; - if(!enabled) + if (!enabled) return byte0; - if (active) - { + if (active) { byte0 = 0; - } - else if (flag) - { + } else if (flag) { byte0 = 2; } return byte0; } @Override - public void drawButton(Minecraft minecraft, int i, int j) - { - if (!getVisible()) - { + public void drawButton(Minecraft minecraft, int i, int j) { + if (!getVisible()) { return; } GL11.glPushMatrix(); minecraft.renderEngine.bindTexture(resource); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - int height = this.height - (active?0:2); + int height = this.height - (active ? 0 : 2); hover = i >= xPosition && j >= yPosition && i < xPosition + getWidth() && j < yPosition + height; int k = getHoverState(hover); - drawTexturedModalRect(xPosition, yPosition, 0, k * 20, getWidth() / 2, height); - drawTexturedModalRect(xPosition + getWidth() / 2, yPosition, 200 - getWidth() / 2, k * 20, getWidth() / 2, height); + drawTexturedModalRect(xPosition, yPosition, 0, k * 20, getWidth() / 2, height); + drawTexturedModalRect(xPosition + getWidth() / 2, yPosition, 200 - getWidth() / 2, k * 20, getWidth() / 2, height); mouseDragged(minecraft, i, j); FontRenderer fontrenderer = minecraft.fontRenderer; - if(rotated) - GL11.glRotatef(90, 1, 0, 0); - if (active) - { + if (rotated) + GL11.glRotatef(90, 1, 0, 0); + if (active) { drawCenteredString(fontrenderer, displayString, xPosition + getWidth() / 2, yPosition + (height - 8) / 2, 0xffffa0); - } - else if (hover && enabled) - { + } else if (hover && enabled) { drawCenteredString(fontrenderer, displayString, xPosition + getWidth() / 2, yPosition + (height - 8) / 2, 0xffffa0); - } - else - { + } else { drawCenteredString(fontrenderer, displayString, xPosition + getWidth() / 2, yPosition + (height - 8) / 2, 0xe0e0e0); } GL11.glPopMatrix(); } - @Override - protected void mouseDragged(Minecraft minecraft, int i, int j) - { + @Override + protected void mouseDragged(Minecraft minecraft, int i, int j) { } @Override - public void mouseReleased(int i, int j) - { + public void mouseReleased(int i, int j) { } @Override - public boolean mousePressed(Minecraft minecraft, int i, int j) - { - boolean bo = !active && getVisible() && hover; - if(bo && listener != null){ - listener.actionPerformed(this); - return false; - } + public boolean mousePressed(Minecraft minecraft, int i, int j) { + boolean bo = !active && getVisible() && hover; + if (bo && listener != null) { + listener.actionPerformed(this); + return false; + } return bo; } } diff --git a/src/main/java/noppes/npcs/client/gui/util/GuiMenuTopIconButton.java b/src/main/java/noppes/npcs/client/gui/util/GuiMenuTopIconButton.java index e2bf4005c..c49509d94 100644 --- a/src/main/java/noppes/npcs/client/gui/util/GuiMenuTopIconButton.java +++ b/src/main/java/noppes/npcs/client/gui/util/GuiMenuTopIconButton.java @@ -15,54 +15,54 @@ import java.util.Arrays; import java.util.Iterator; import java.util.List; -public class GuiMenuTopIconButton extends GuiMenuTopButton{ +public class GuiMenuTopIconButton extends GuiMenuTopButton { private static final ResourceLocation resource = new ResourceLocation("textures/gui/container/creative_inventory/tabs.png"); protected static RenderItem itemRender = new RenderItem(); private ItemStack item; - - public GuiMenuTopIconButton(int i, int x, int y, String s, ItemStack item) { - super(i, x, y, s); - width = 28; - height = 28; - this.item = item; - } - - public GuiMenuTopIconButton(int i, GuiButton parent, String s, ItemStack item){ - super(i,parent, s); - width = 28; - height = 28; - this.item = item; + + public GuiMenuTopIconButton(int i, int x, int y, String s, ItemStack item) { + super(i, x, y, s); + width = 28; + height = 28; + this.item = item; + } + + public GuiMenuTopIconButton(int i, GuiButton parent, String s, ItemStack item) { + super(i, parent, s); + width = 28; + height = 28; + this.item = item; } public GuiMenuTopIconButton(int i, int x, int y, String s, IButtonListener listener, ItemStack item) { - super(i, x, y, s); - width = 28; - height = 28; - this.item = item; - this.listener = listener; - } + super(i, x, y, s); + width = 28; + height = 28; + this.item = item; + this.listener = listener; + } public GuiMenuTopIconButton(int i, GuiButton parent, String s, - IButtonListener listener, ItemStack item) { - super(i, parent, s, listener); - width = 28; - height = 28; - this.item = item; - } + IButtonListener listener, ItemStack item) { + super(i, parent, s, listener); + width = 28; + height = 28; + this.item = item; + } - @Override - public void drawButton(Minecraft minecraft, int i, int j){ - if (!getVisible()){ + @Override + public void drawButton(Minecraft minecraft, int i, int j) { + if (!getVisible()) { return; } - if(item.getItem() == null) - item = new ItemStack(Blocks.dirt); + if (item.getItem() == null) + item = new ItemStack(Blocks.dirt); hover = i >= xPosition && j >= yPosition && i < xPosition + getWidth() && j < yPosition + height; Minecraft mc = Minecraft.getMinecraft(); - if(hover && !active){ - int x = i + mc.fontRenderer.getStringWidth(displayString); + if (hover && !active) { + int x = i + mc.fontRenderer.getStringWidth(displayString); GL11.glTranslatef(x, yPosition + 2, 0); - drawHoveringText(Arrays.asList(new String[] {displayString}), 0, 0, mc.fontRenderer); + drawHoveringText(Arrays.asList(new String[]{displayString}), 0, 0, mc.fontRenderer); GL11.glTranslatef(-x, -(yPosition + 2), 0); } mc.getTextureManager().bindTexture(resource); @@ -70,7 +70,7 @@ public class GuiMenuTopIconButton extends GuiMenuTopButton{ GL11.glColor4f(1F, 1F, 1F, 1F); GL11.glEnable(GL11.GL_BLEND); GL11.glDisable(GL11.GL_LIGHTING); - this.drawTexturedModalRect(xPosition, yPosition + (active?2:0), 0, active?32:0, 28, 28); + this.drawTexturedModalRect(xPosition, yPosition + (active ? 2 : 0), 0, active ? 32 : 0, 28, 28); this.zLevel = 100.0F; itemRender.zLevel = 100.0F; GL11.glEnable(GL11.GL_LIGHTING); @@ -78,18 +78,17 @@ public class GuiMenuTopIconButton extends GuiMenuTopButton{ RenderHelper.enableGUIStandardItemLighting(); itemRender.renderItemAndEffectIntoGUI(mc.fontRenderer, mc.getTextureManager(), item, xPosition + 6, yPosition + 10); itemRender.renderItemOverlayIntoGUI(mc.fontRenderer, mc.getTextureManager(), item, xPosition + 6, yPosition + 10); - RenderHelper.disableStandardItemLighting(); + RenderHelper.disableStandardItemLighting(); GL11.glDisable(GL11.GL_LIGHTING); itemRender.zLevel = 0.0F; this.zLevel = 0.0F; GL11.glPopMatrix(); - + } - protected void drawHoveringText(List p_146283_1_, int p_146283_2_, int p_146283_3_, FontRenderer font) - { - if (!p_146283_1_.isEmpty()) - { + + protected void drawHoveringText(List p_146283_1_, int p_146283_2_, int p_146283_3_, FontRenderer font) { + if (!p_146283_1_.isEmpty()) { GL11.glDisable(GL12.GL_RESCALE_NORMAL); RenderHelper.disableStandardItemLighting(); GL11.glDisable(GL11.GL_LIGHTING); @@ -97,13 +96,11 @@ public class GuiMenuTopIconButton extends GuiMenuTopButton{ int k = 0; Iterator iterator = p_146283_1_.iterator(); - while (iterator.hasNext()) - { - String s = (String)iterator.next(); + while (iterator.hasNext()) { + String s = (String) iterator.next(); int l = font.getStringWidth(s); - if (l > k) - { + if (l > k) { k = l; } } @@ -112,18 +109,15 @@ public class GuiMenuTopIconButton extends GuiMenuTopButton{ int k2 = p_146283_3_ - 12; int i1 = 8; - if (p_146283_1_.size() > 1) - { + if (p_146283_1_.size() > 1) { i1 += 2 + (p_146283_1_.size() - 1) * 10; } - if (j2 + k > this.width) - { + if (j2 + k > this.width) { j2 -= 28 + k; } - if (k2 + i1 + 6 > this.height) - { + if (k2 + i1 + 6 > this.height) { k2 = this.height - i1 - 6; } @@ -142,13 +136,11 @@ public class GuiMenuTopIconButton extends GuiMenuTopButton{ this.drawGradientRect(j2 - 3, k2 - 3, j2 + k + 3, k2 - 3 + 1, k1, k1); this.drawGradientRect(j2 - 3, k2 + i1 + 2, j2 + k + 3, k2 + i1 + 3, l1, l1); - for (int i2 = 0; i2 < p_146283_1_.size(); ++i2) - { - String s1 = (String)p_146283_1_.get(i2); + for (int i2 = 0; i2 < p_146283_1_.size(); ++i2) { + String s1 = (String) p_146283_1_.get(i2); font.drawStringWithShadow(s1, j2, k2, -1); - if (i2 == 0) - { + if (i2 == 0) { k2 += 2; } diff --git a/src/main/java/noppes/npcs/client/gui/util/GuiModelInterface.java b/src/main/java/noppes/npcs/client/gui/util/GuiModelInterface.java index f419f3b24..e7a32e4b4 100644 --- a/src/main/java/noppes/npcs/client/gui/util/GuiModelInterface.java +++ b/src/main/java/noppes/npcs/client/gui/util/GuiModelInterface.java @@ -73,7 +73,7 @@ public class GuiModelInterface extends GuiNPCInterface { private long start = -1; public boolean isMouseOverRenderer(int x, int y) { - if(!allowRotate){ + if (!allowRotate) { return false; } // Center of the entity rendering diff --git a/src/main/java/noppes/npcs/client/gui/util/GuiModelInterface2.java b/src/main/java/noppes/npcs/client/gui/util/GuiModelInterface2.java index ae1578679..16d3af9d7 100644 --- a/src/main/java/noppes/npcs/client/gui/util/GuiModelInterface2.java +++ b/src/main/java/noppes/npcs/client/gui/util/GuiModelInterface2.java @@ -14,77 +14,78 @@ import org.lwjgl.input.Mouse; import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; -public class GuiModelInterface2 extends GuiNPCInterface2{ - public ModelData playerdata; +public class GuiModelInterface2 extends GuiNPCInterface2 { + public ModelData playerdata; - private static float rotation = 0; + private static float rotation = 0; - private GuiNpcButton left,right,zoom,unzoom; + private GuiNpcButton left, right, zoom, unzoom; - private static float zoomed = 60; + private static float zoomed = 60; - public int xOffset = 0; + public int xOffset = 0; public int yOffset = 0; - public EntityNPCInterface npc; + public EntityNPCInterface npc; - public GuiModelInterface2(EntityNPCInterface npc){ + public GuiModelInterface2(EntityNPCInterface npc) { super(npc); - this.npc = npc; - playerdata = ((EntityCustomNpc)npc).modelData; - //xSize = 380; - drawDefaultBackground = false; - } + this.npc = npc; + playerdata = ((EntityCustomNpc) npc).modelData; + //xSize = 380; + drawDefaultBackground = false; + } @Override public void initGui() { - super.initGui(); + super.initGui(); - addButton(unzoom = new GuiNpcButton(666, guiLeft + 148 + xOffset, guiTop + 200 + yOffset, 20, 20, "-")); - addButton(zoom = new GuiNpcButton(667, guiLeft + 214 + xOffset, guiTop + 200 + yOffset, 20, 20, "+")); - addButton(left = new GuiNpcButton(668, guiLeft + 170 + xOffset, guiTop + 200 + yOffset, 20, 20, "<")); - addButton(right = new GuiNpcButton(669, guiLeft + 192 + xOffset, guiTop + 200 + yOffset, 20, 20, ">")); + addButton(unzoom = new GuiNpcButton(666, guiLeft + 148 + xOffset, guiTop + 200 + yOffset, 20, 20, "-")); + addButton(zoom = new GuiNpcButton(667, guiLeft + 214 + xOffset, guiTop + 200 + yOffset, 20, 20, "+")); + addButton(left = new GuiNpcButton(668, guiLeft + 170 + xOffset, guiTop + 200 + yOffset, 20, 20, "<")); + addButton(right = new GuiNpcButton(669, guiLeft + 192 + xOffset, guiTop + 200 + yOffset, 20, 20, ">")); } @Override protected void actionPerformed(GuiButton btn) { - if(btn.id == 670){ - close(); - } + if (btn.id == 670) { + close(); + } } + @Override - public boolean doesGuiPauseGame() - { + public boolean doesGuiPauseGame() { return false; } - private long start = -1; - @Override - public void drawScreen(int par1, int par2, float par3) - { - if(Mouse.isButtonDown(0)){ - if(left.mousePressed(mc, par1, par2)) - rotation+=par3 * 2; - else if(right.mousePressed(mc, par1, par2)) - rotation-=par3 * 2; - else if(zoom.mousePressed(mc, par1, par2)) - zoomed+=par3 * 2; - else if(unzoom.mousePressed(mc, par1, par2) && zoomed > 10) - zoomed-=par3 * 2; - } + private long start = -1; + + @Override + public void drawScreen(int par1, int par2, float par3) { + if (Mouse.isButtonDown(0)) { + if (left.mousePressed(mc, par1, par2)) + rotation += par3 * 2; + else if (right.mousePressed(mc, par1, par2)) + rotation -= par3 * 2; + else if (zoom.mousePressed(mc, par1, par2)) + zoomed += par3 * 2; + else if (unzoom.mousePressed(mc, par1, par2) && zoomed > 10) + zoomed -= par3 * 2; + + } super.drawScreen(par1, par2, par3); GL11.glColor4f(1, 1, 1, 1); - EntityLivingBase entity = playerdata.getEntity(npc); - if(entity == null) - entity = this.npc; + EntityLivingBase entity = playerdata.getEntity(npc); + if (entity == null) + entity = this.npc; - EntityUtil.Copy(npc, entity); + EntityUtil.Copy(npc, entity); - int l = guiLeft + 190 + xOffset; - int i1 = guiTop + 180 + yOffset; + int l = guiLeft + 190 + xOffset; + int i1 = guiTop + 180 + yOffset; GL11.glEnable(GL11.GL_COLOR_MATERIAL); GL11.glPushMatrix(); GL11.glTranslatef(l, i1, 50F); @@ -96,24 +97,23 @@ public class GuiModelInterface2 extends GuiNPCInterface2{ float f3 = entity.rotationYaw; float f4 = entity.rotationPitch; float f7 = entity.rotationYawHead; - float f5 = (float)(l) - par1; - float f6 = (float)(i1 - 50) - par2; + float f5 = (float) (l) - par1; + float f6 = (float) (i1 - 50) - par2; GL11.glRotatef(135F, 0.0F, 1.0F, 0.0F); RenderHelper.enableStandardItemLighting(); GL11.glRotatef(-135F, 0.0F, 1.0F, 0.0F); - GL11.glRotatef(-(float)Math.atan(f6 / 80F) * 20F, 1.0F, 0.0F, 0.0F); + GL11.glRotatef(-(float) Math.atan(f6 / 80F) * 20F, 1.0F, 0.0F, 0.0F); entity.prevRenderYawOffset = entity.renderYawOffset = rotation; - entity.prevRotationYaw = entity.rotationYaw = (float)Math.atan(f5 / 80F) * 40F + rotation; - entity.rotationPitch = -(float)Math.atan(f6 / 80F) * 20F; + entity.prevRotationYaw = entity.rotationYaw = (float) Math.atan(f5 / 80F) * 40F + rotation; + entity.rotationPitch = -(float) Math.atan(f6 / 80F) * 20F; entity.prevRotationYawHead = entity.rotationYawHead = entity.rotationYaw; GL11.glTranslatef(0.0F, entity.yOffset, 0.0F); RenderManager.instance.playerViewY = 180F; - try{ + try { RenderManager.instance.renderEntityWithPosYaw(entity, 0.0D, 0.0D, 0.0D, 0.0F, 1.0F); - } - catch(Exception e){ - playerdata.setEntityClass(null); + } catch (Exception e) { + playerdata.setEntityClass(null); } entity.prevRenderYawOffset = entity.renderYawOffset = f2; entity.prevRotationYaw = entity.rotationYaw = f3; @@ -135,32 +135,31 @@ public class GuiModelInterface2 extends GuiNPCInterface2{ int xPosGradient = guiLeft + 10; int yPosGradient = guiTop + 10; - drawGradientRect(xPosGradient, yPosGradient, 200 + xPosGradient ,180 + yPosGradient, 0xc0101010, 0xd0101010); + drawGradientRect(xPosGradient, yPosGradient, 200 + xPosGradient, 180 + yPosGradient, 0xc0101010, 0xd0101010); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); } @Override - public void keyTyped(char par1, int par2) - { - super.keyTyped(par1, par2); - if (par2 == 1) - { - close(); + public void keyTyped(char par1, int par2) { + super.keyTyped(par1, par2); + if (par2 == 1) { + close(); } } - public void close(){ - this.mc.displayGuiScreen((GuiScreen)null); + + public void close() { + this.mc.displayGuiScreen((GuiScreen) null); this.mc.setIngameFocus(); } - @Override - public void save() { + @Override + public void save() { - } + } - public void setSave(boolean saveNPC){ - if(this.getMenu() != null){ + public void setSave(boolean saveNPC) { + if (this.getMenu() != null) { this.getMenu().saveNPC = saveNPC; } } diff --git a/src/main/java/noppes/npcs/client/gui/util/GuiNPCInterface.java b/src/main/java/noppes/npcs/client/gui/util/GuiNPCInterface.java index d605aaa76..7ceedfca2 100644 --- a/src/main/java/noppes/npcs/client/gui/util/GuiNPCInterface.java +++ b/src/main/java/noppes/npcs/client/gui/util/GuiNPCInterface.java @@ -180,7 +180,8 @@ public abstract class GuiNPCInterface extends GuiScreen { super.mouseMovedOrUp(mouseX, mouseY, state); } - public void mouseEvent(int i, int j, int k){} + public void mouseEvent(int i, int j, int k) { + } @Override protected void actionPerformed(GuiButton guibutton) { @@ -191,7 +192,8 @@ public abstract class GuiNPCInterface extends GuiScreen { } } - public void buttonEvent(GuiButton guibutton){} + public void buttonEvent(GuiButton guibutton) { + } @Override public void keyTyped(char c, int i) { diff --git a/src/main/java/noppes/npcs/client/gui/util/GuiNPCInterface2.java b/src/main/java/noppes/npcs/client/gui/util/GuiNPCInterface2.java index da766c681..7c9f1d43e 100644 --- a/src/main/java/noppes/npcs/client/gui/util/GuiNPCInterface2.java +++ b/src/main/java/noppes/npcs/client/gui/util/GuiNPCInterface2.java @@ -4,47 +4,48 @@ import net.minecraft.util.ResourceLocation; import noppes.npcs.entity.EntityNPCInterface; import org.lwjgl.opengl.GL11; -public abstract class GuiNPCInterface2 extends GuiNPCInterface -{ - private ResourceLocation background = new ResourceLocation("customnpcs:textures/gui/menubg.png"); - private GuiNpcMenu menu; +public abstract class GuiNPCInterface2 extends GuiNPCInterface { + private ResourceLocation background = new ResourceLocation("customnpcs:textures/gui/menubg.png"); + private GuiNpcMenu menu; - public GuiNPCInterface2(EntityNPCInterface npc){ - this(npc, -1); + public GuiNPCInterface2(EntityNPCInterface npc) { + this(npc, -1); } - public GuiNPCInterface2(EntityNPCInterface npc, int activeMenu){ - super(npc); - xSize = 420; - ySize = 200; - menu = new GuiNpcMenu(this, activeMenu, npc); + + public GuiNPCInterface2(EntityNPCInterface npc, int activeMenu) { + super(npc); + xSize = 420; + ySize = 200; + menu = new GuiNpcMenu(this, activeMenu, npc); } + @Override - public void initGui(){ - super.initGui(); + public void initGui() { + super.initGui(); menu.initGui(guiLeft, guiTop, xSize); } @Override - public void mouseClicked(int i, int j, int k){ - if(!hasSubGui()) - menu.mouseClicked(i, j, k); + public void mouseClicked(int i, int j, int k) { + if (!hasSubGui()) + menu.mouseClicked(i, j, k); super.mouseClicked(i, j, k); } - public void delete(){ - npc.delete(); + public void delete() { + npc.delete(); displayGuiScreen(null); mc.setIngameFocus(); } + public abstract void save(); @Override - public void drawScreen(int i, int j, float f) - { - if(drawDefaultBackground) - drawDefaultBackground(); //drawDefaultBackground + public void drawScreen(int i, int j, float f) { + if (drawDefaultBackground) + drawDefaultBackground(); //drawDefaultBackground drawBackground(); menu.drawElements(getFontRenderer(), i, j, mc, f); @@ -59,10 +60,10 @@ public abstract class GuiNPCInterface2 extends GuiNPCInterface GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); mc.renderEngine.bindTexture(background); drawTexturedModalRect(guiLeft, guiTop, 0, 0, 200, 220); - drawTexturedModalRect(guiLeft + xSize-230, guiTop, 26, 0, 230, 220); + drawTexturedModalRect(guiLeft + xSize - 230, guiTop, 26, 0, 230, 220); } - protected GuiNpcMenu getMenu(){ + protected GuiNpcMenu getMenu() { return this.menu; } } diff --git a/src/main/java/noppes/npcs/client/gui/util/GuiNPCStringSlot.java b/src/main/java/noppes/npcs/client/gui/util/GuiNPCStringSlot.java index 3c8030217..c60a14c2c 100644 --- a/src/main/java/noppes/npcs/client/gui/util/GuiNPCStringSlot.java +++ b/src/main/java/noppes/npcs/client/gui/util/GuiNPCStringSlot.java @@ -6,41 +6,40 @@ import net.minecraft.client.renderer.Tessellator; import java.util.*; -public class GuiNPCStringSlot extends GuiSlot -{ +public class GuiNPCStringSlot extends GuiSlot { - private List list; /* synthetic field */ + private List list; /* synthetic field */ public String selected; public HashSet selectedList; private boolean multiSelect; private GuiNPCInterface parent; public int size; - public GuiNPCStringSlot(Collection list,GuiNPCInterface parent,boolean multiSelect, int size) - { + + public GuiNPCStringSlot(Collection list, GuiNPCInterface parent, boolean multiSelect, int size) { super(Minecraft.getMinecraft(), parent.width, parent.height, 32, parent.height - 64, size); selectedList = new HashSet(); this.parent = parent; this.list = new ArrayList(list); - Collections.sort(this.list,String.CASE_INSENSITIVE_ORDER); + Collections.sort(this.list, String.CASE_INSENSITIVE_ORDER); this.multiSelect = multiSelect; this.size = size; } - public void setList(List list){ - Collections.sort(list,String.CASE_INSENSITIVE_ORDER); + + public void setList(List list) { + Collections.sort(list, String.CASE_INSENSITIVE_ORDER); this.list = list; selected = ""; } @Override - protected int getSize() - { + protected int getSize() { return list.size(); } + private long prevTime = 0; @Override - protected void elementClicked(int i, boolean flag, int j, int k) - { + protected void elementClicked(int i, boolean flag, int j, int k) { // GuiSelectWorld.onElementSelected(parentWorldGui, i); // boolean flag1 = GuiSelectWorld.getSelectedWorld(parentWorldGui) >= 0 && GuiSelectWorld.getSelectedWorld(parentWorldGui) < getSize(); // GuiSelectWorld.getSelectButton(parentWorldGui).enabled = flag1; @@ -50,52 +49,48 @@ public class GuiNPCStringSlot extends GuiSlot // { // parentWorldGui.selectWorld(i); // } - long time = System.currentTimeMillis(); - if(selected != null && selected.equals(list.get(i)) && time - prevTime < 400 ) - parent.doubleClicked(); - selected = list.get(i); - if(selectedList.contains(selected)) - selectedList.remove(selected); - else - selectedList.add(selected); - parent.elementClicked(); - prevTime = time; + long time = System.currentTimeMillis(); + if (selected != null && selected.equals(list.get(i)) && time - prevTime < 400) + parent.doubleClicked(); + selected = list.get(i); + if (selectedList.contains(selected)) + selectedList.remove(selected); + else + selectedList.add(selected); + parent.elementClicked(); + prevTime = time; } @Override - protected boolean isSelected(int i) - { - if(!multiSelect){ - if(selected == null) - return false; - return selected.equals(list.get(i)); - } - else{ - return selectedList.contains(list.get(i)); - } + protected boolean isSelected(int i) { + if (!multiSelect) { + if (selected == null) + return false; + return selected.equals(list.get(i)); + } else { + return selectedList.contains(list.get(i)); + } } @Override - protected int getContentHeight() - { + protected int getContentHeight() { return list.size() * size; } @Override - protected void drawBackground() - { + protected void drawBackground() { parent.drawDefaultBackground(); } @Override - protected void drawSlot(int i, int j, int k, int l, Tessellator tessellator, int var6, int var7) { - String s = list.get(i); - //if(!parent.drawSlot(i, j, k, l, tessellator, s)) - parent.drawString(parent.getFontRenderer(), s, j + 50, k + 3, 0xFFFFFF); + protected void drawSlot(int i, int j, int k, int l, Tessellator tessellator, int var6, int var7) { + String s = list.get(i); + //if(!parent.drawSlot(i, j, k, l, tessellator, s)) + parent.drawString(parent.getFontRenderer(), s, j + 50, k + 3, 0xFFFFFF); + } + + public void clear() { + list.clear(); } - public void clear() { - list.clear(); - } - } diff --git a/src/main/java/noppes/npcs/client/gui/util/GuiNpcButtonYesNo.java b/src/main/java/noppes/npcs/client/gui/util/GuiNpcButtonYesNo.java index 1ae40534d..908313441 100644 --- a/src/main/java/noppes/npcs/client/gui/util/GuiNpcButtonYesNo.java +++ b/src/main/java/noppes/npcs/client/gui/util/GuiNpcButtonYesNo.java @@ -1,16 +1,16 @@ package noppes.npcs.client.gui.util; -public class GuiNpcButtonYesNo extends GuiNpcButton{ +public class GuiNpcButtonYesNo extends GuiNpcButton { - public GuiNpcButtonYesNo(int id, int x, int y, boolean bo) { - this(id, x, y, 50, 20, bo); - } - - public GuiNpcButtonYesNo(int id, int x, int y, int width, int height, boolean bo) { - super(id, x, y, width, height, new String[]{"gui.no", "gui.yes"}, bo?1:0); - } - - public boolean getBoolean(){ - return getValue() == 1; - } + public GuiNpcButtonYesNo(int id, int x, int y, boolean bo) { + this(id, x, y, 50, 20, bo); + } + + public GuiNpcButtonYesNo(int id, int x, int y, int width, int height, boolean bo) { + super(id, x, y, width, height, new String[]{"gui.no", "gui.yes"}, bo ? 1 : 0); + } + + public boolean getBoolean() { + return getValue() == 1; + } } diff --git a/src/main/java/noppes/npcs/client/gui/util/GuiNpcLabel.java b/src/main/java/noppes/npcs/client/gui/util/GuiNpcLabel.java index b44132653..d5b6cfcdf 100644 --- a/src/main/java/noppes/npcs/client/gui/util/GuiNpcLabel.java +++ b/src/main/java/noppes/npcs/client/gui/util/GuiNpcLabel.java @@ -7,27 +7,30 @@ import net.minecraft.util.StatCollector; import noppes.npcs.client.CustomNpcResourceListener; public class GuiNpcLabel { - public String label; - public int x,y,color; - public boolean enabled = true; - public int id; + public String label; + public int x, y, color; + public boolean enabled = true; + public int id; - public GuiNpcLabel(int id, Object label, int x, int y, int color){ - this.id = id; - this.label = StatCollector.translateToLocal(label.toString()); - this.x = x; - this.y = y; - this.color = color; - } - public GuiNpcLabel(int id, Object label, int x, int y){ - this(id, label, x, y, CustomNpcResourceListener.DefaultTextColor); - } - public void drawLabel(GuiScreen gui, FontRenderer fontRenderer) { - if(enabled) - fontRenderer.drawString(label, x, y, color); - } - public void center(int width) { - int size = Minecraft.getMinecraft().fontRenderer.getStringWidth(label); - x += (width - size) / 2; - } + public GuiNpcLabel(int id, Object label, int x, int y, int color) { + this.id = id; + this.label = StatCollector.translateToLocal(label.toString()); + this.x = x; + this.y = y; + this.color = color; + } + + public GuiNpcLabel(int id, Object label, int x, int y) { + this(id, label, x, y, CustomNpcResourceListener.DefaultTextColor); + } + + public void drawLabel(GuiScreen gui, FontRenderer fontRenderer) { + if (enabled) + fontRenderer.drawString(label, x, y, color); + } + + public void center(int width) { + int size = Minecraft.getMinecraft().fontRenderer.getStringWidth(label); + x += (width - size) / 2; + } } diff --git a/src/main/java/noppes/npcs/client/gui/util/GuiNpcSlider.java b/src/main/java/noppes/npcs/client/gui/util/GuiNpcSlider.java index 74b2d383e..4288d47bf 100644 --- a/src/main/java/noppes/npcs/client/gui/util/GuiNpcSlider.java +++ b/src/main/java/noppes/npcs/client/gui/util/GuiNpcSlider.java @@ -8,113 +8,113 @@ import org.lwjgl.input.Mouse; import org.lwjgl.opengl.GL11; public class GuiNpcSlider extends GuiButton { - private ISliderListener listener; - public int id; - + private ISliderListener listener; + public int id; + public float sliderValue = 1.0F; public boolean dragging; - - public GuiNpcSlider(GuiScreen parent, int id, int xPos, int yPos, String displayString, float sliderValue) { - super(id, xPos, yPos, 150, 20, NoppesStringUtils.translate(displayString)); - this.id = id; - this.sliderValue = sliderValue; - if(parent instanceof ISliderListener) - listener = (ISliderListener) parent; - } - public GuiNpcSlider(GuiScreen parent, int id, int xPos, int yPos, int width, int height, String displayString, float sliderValue) { + public GuiNpcSlider(GuiScreen parent, int id, int xPos, int yPos, String displayString, float sliderValue) { + super(id, xPos, yPos, 150, 20, NoppesStringUtils.translate(displayString)); + this.id = id; + this.sliderValue = sliderValue; + if (parent instanceof ISliderListener) + listener = (ISliderListener) parent; + } + + public GuiNpcSlider(GuiScreen parent, int id, int xPos, int yPos, int width, int height, String displayString, float sliderValue) { super(id, xPos, yPos, width, height, NoppesStringUtils.translate(displayString)); this.id = id; this.sliderValue = sliderValue; - if(parent instanceof ISliderListener) + if (parent instanceof ISliderListener) listener = (ISliderListener) parent; } - - public GuiNpcSlider(GuiScreen parent, int id, int xPos, int yPos, float sliderValue) { - this(parent, id, xPos, yPos, "", sliderValue); - if(listener != null) - listener.mouseDragged(this); - } - - public GuiNpcSlider(GuiScreen parent, int id, int xPos, int yPos, int width, int height, float sliderValue) { - this(parent, id, xPos, yPos, "", sliderValue); - this.width = width; - this.height = height; - if(listener != null) - listener.mouseDragged(this); - } - - @Override - public void mouseDragged(Minecraft mc, int par2, int par3){ - if (!this.visible) - return; - - mc.getTextureManager().bindTexture(buttonTextures); - if (this.dragging){ - this.sliderValue = (float)(par2 - (this.xPosition + 4)) / (float)(this.width - 8); - if (this.sliderValue < 0.0F){ + public GuiNpcSlider(GuiScreen parent, int id, int xPos, int yPos, float sliderValue) { + this(parent, id, xPos, yPos, "", sliderValue); + if (listener != null) + listener.mouseDragged(this); + } + + public GuiNpcSlider(GuiScreen parent, int id, int xPos, int yPos, int width, int height, float sliderValue) { + this(parent, id, xPos, yPos, "", sliderValue); + this.width = width; + this.height = height; + if (listener != null) + listener.mouseDragged(this); + } + + @Override + public void mouseDragged(Minecraft mc, int par2, int par3) { + if (!this.visible) + return; + + mc.getTextureManager().bindTexture(buttonTextures); + if (this.dragging) { + this.sliderValue = (float) (par2 - (this.xPosition + 4)) / (float) (this.width - 8); + + if (this.sliderValue < 0.0F) { this.sliderValue = 0.0F; } - if (this.sliderValue > 1.0F){ + if (this.sliderValue > 1.0F) { this.sliderValue = 1.0F; } - if(listener != null) - listener.mouseDragged(this); - - if(!Mouse.isButtonDown(0)){ - this.func_146111_b(0, 0); - } + if (listener != null) + listener.mouseDragged(this); + + if (!Mouse.isButtonDown(0)) { + this.func_146111_b(0, 0); + } } GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - this.drawTexturedModalRect(this.xPosition + (int)(this.sliderValue * (float)(this.width - 8)), this.yPosition, 0, 66, 4, 20); - this.drawTexturedModalRect(this.xPosition + (int)(this.sliderValue * (float)(this.width - 8)) + 4, this.yPosition, 196, 66, 4, 20); + this.drawTexturedModalRect(this.xPosition + (int) (this.sliderValue * (float) (this.width - 8)), this.yPosition, 0, 66, 4, 20); + this.drawTexturedModalRect(this.xPosition + (int) (this.sliderValue * (float) (this.width - 8)) + 4, this.yPosition, 196, 66, 4, 20); } - - public String getDisplayString(){ - return displayString; - } - public void setString(String str) { - displayString = NoppesStringUtils.translate(str); - } - - @Override - public boolean mousePressed(Minecraft par1Minecraft, int par2, int par3){ - if (this.enabled && this.visible && par2 >= this.xPosition && par3 >= this.yPosition && par2 < this.xPosition + this.width && par3 < this.yPosition + this.height){ - this.sliderValue = (float)(par2 - (this.xPosition + 4)) / (float)(this.width - 8); - if (this.sliderValue < 0.0F){ + public String getDisplayString() { + return displayString; + } + + public void setString(String str) { + displayString = NoppesStringUtils.translate(str); + } + + @Override + public boolean mousePressed(Minecraft par1Minecraft, int par2, int par3) { + if (this.enabled && this.visible && par2 >= this.xPosition && par3 >= this.yPosition && par2 < this.xPosition + this.width && par3 < this.yPosition + this.height) { + this.sliderValue = (float) (par2 - (this.xPosition + 4)) / (float) (this.width - 8); + + if (this.sliderValue < 0.0F) { this.sliderValue = 0.0F; } - if (this.sliderValue > 1.0F){ + if (this.sliderValue > 1.0F) { this.sliderValue = 1.0F; } - if(listener != null) - listener.mousePressed(this); + if (listener != null) + listener.mousePressed(this); this.dragging = true; return true; } return false; } - - @Override - public void func_146111_b(int par1, int par2) - { - this.dragging = false; - - if(listener != null) - listener.mouseReleased(this); - } - + @Override - public int getHoverState(boolean par1){ + public void func_146111_b(int par1, int par2) { + this.dragging = false; + + if (listener != null) + listener.mouseReleased(this); + } + + @Override + public int getHoverState(boolean par1) { return 0; } } diff --git a/src/main/java/noppes/npcs/client/gui/util/GuiNpcTextArea.java b/src/main/java/noppes/npcs/client/gui/util/GuiNpcTextArea.java index 076306b86..18584f85d 100644 --- a/src/main/java/noppes/npcs/client/gui/util/GuiNpcTextArea.java +++ b/src/main/java/noppes/npcs/client/gui/util/GuiNpcTextArea.java @@ -15,154 +15,151 @@ import java.util.ArrayList; import java.util.List; public class GuiNpcTextArea extends GuiNpcTextField { - public boolean inMenu = true; - public boolean numbersOnly = false; - private int posX,posY,width,height; + public boolean inMenu = true; + public boolean numbersOnly = false; + private int posX, posY, width, height; private int cursorCounter; - private FontContainer font; - private int cursorPosition = 0; - private int listHeight; - private float scrolledY = 0; - private int startClick = -1; - private boolean clickVerticalBar = false; - private boolean wrapLine = true; - private List lines = new ArrayList<>(); + private FontContainer font; + private int cursorPosition = 0; + private int listHeight; + private float scrolledY = 0; + private int startClick = -1; + private boolean clickVerticalBar = false; + private boolean wrapLine = true; + private List lines = new ArrayList<>(); - public GuiNpcTextArea(int id,GuiScreen guiscreen, int i, int j, int k, int l, String s) { - super(id,guiscreen, i, j, k, l, s); - posX = i; - posY = j; - width = k; - listHeight = height = l; - this.font = ClientProxy.Font; - setMaxStringLength(Integer.MAX_VALUE); - this.setText(s); - } + public GuiNpcTextArea(int id, GuiScreen guiscreen, int i, int j, int k, int l, String s) { + super(id, guiscreen, i, j, k, l, s); + posX = i; + posY = j; + width = k; + listHeight = height = l; + this.font = ClientProxy.Font; + setMaxStringLength(Integer.MAX_VALUE); + this.setText(s); + } - @Override - public void setText(String text) { - super.setText(text); + @Override + public void setText(String text) { + super.setText(text); - updateLineList(); - } + updateLineList(); + } - public void updateLineList() { - List list = new ArrayList(); - StringBuilder line = new StringBuilder(); - for(char c : getText().toCharArray()){ - if(c == '\r' || c == '\n'){ - list.add(line.toString()); - line = new StringBuilder(); - } - else - line.append(c); - } - list.add(line.toString()); - lines = list; - } + public void updateLineList() { + List list = new ArrayList(); + StringBuilder line = new StringBuilder(); + for (char c : getText().toCharArray()) { + if (c == '\r' || c == '\n') { + list.add(line.toString()); + line = new StringBuilder(); + } else + line.append(c); + } + list.add(line.toString()); + lines = list; + } - @Override - public void updateCursorCounter(){ + @Override + public void updateCursorCounter() { cursorCounter++; } - @Override - public boolean textboxKeyTyped(char c, int i){ - if (isFocused() && canEdit){ - String originalText = getText(); - this.setText(originalText); - if(c == '\r' || c == '\n'){ - this.setText(originalText.substring(0, cursorPosition) + c + originalText.substring(cursorPosition)); - } - this.setCursorPositionZero(); - this.moveCursorBy(cursorPosition); - boolean bo = super.textboxKeyTyped(c, i); - updateLineList(); - String newText = getText(); - if(i != Keyboard.KEY_DELETE) - cursorPosition += newText.length() - originalText.length(); - if(i == Keyboard.KEY_LEFT && cursorPosition > 0) - cursorPosition--; - if(i == Keyboard.KEY_RIGHT && cursorPosition < newText.length()) - cursorPosition++; - return bo; - - } - return false; - } - - @Override - public void mouseClicked(int i, int j, int k){ - boolean wasFocused = isFocused(); - super.mouseClicked(i, j, k); - - if(hoverVerticalScrollBar(i, j)){ - clickVerticalBar = true; - startClick = -1; - return; - } - - int x = i - posX; - int y = (j - posY - 4) / font.height() + getStartLineY(); - cursorPosition = 0; - int charCount = 0; - int lineCount = 0; - int maxSize = width - (isScrolling()?14:4); - for(int g = 0; g < lines.size(); g++){ - String wholeLine = lines.get(g); - String line = ""; - for(char c : wholeLine.toCharArray()){ - cursorPosition = charCount; - if(font.width(line + c) > maxSize && wrapLine){ - lineCount++; - line = ""; - if(y < lineCount){ - break; - } - } - if(lineCount == y && x <= font.width(line + c)) - return; - charCount++; - line += c; - - } - cursorPosition = charCount; - - - - lineCount++; - charCount++; - if(y < lineCount){ - break; + @Override + public boolean textboxKeyTyped(char c, int i) { + if (isFocused() && canEdit) { + String originalText = getText(); + this.setText(originalText); + if (c == '\r' || c == '\n') { + this.setText(originalText.substring(0, cursorPosition) + c + originalText.substring(cursorPosition)); } - } - if(y >= lineCount) - cursorPosition = getText().length(); + this.setCursorPositionZero(); + this.moveCursorBy(cursorPosition); + boolean bo = super.textboxKeyTyped(c, i); + updateLineList(); + String newText = getText(); + if (i != Keyboard.KEY_DELETE) + cursorPosition += newText.length() - originalText.length(); + if (i == Keyboard.KEY_LEFT && cursorPosition > 0) + cursorPosition--; + if (i == Keyboard.KEY_RIGHT && cursorPosition < newText.length()) + cursorPosition++; + return bo; + + } + return false; } - private List getLines(){ - List list = new ArrayList(); - String line = ""; - for(char c : getText().toCharArray()){ - if(c == '\r' || c == '\n'){ - list.add(line); - line = ""; - } - else - line += c; - } - list.add(line); - return list; - } + @Override + public void mouseClicked(int i, int j, int k) { + boolean wasFocused = isFocused(); + super.mouseClicked(i, j, k); - private int getStartLineY(){ - if(!isScrolling()) - scrolledY = 0; - return MathHelper.ceiling_double_int(scrolledY * (listHeight) / font.height()); - } + if (hoverVerticalScrollBar(i, j)) { + clickVerticalBar = true; + startClick = -1; + return; + } - @Override - public void drawTextBox(int mouseX, int mouseY) { + int x = i - posX; + int y = (j - posY - 4) / font.height() + getStartLineY(); + cursorPosition = 0; + int charCount = 0; + int lineCount = 0; + int maxSize = width - (isScrolling() ? 14 : 4); + for (int g = 0; g < lines.size(); g++) { + String wholeLine = lines.get(g); + String line = ""; + for (char c : wholeLine.toCharArray()) { + cursorPosition = charCount; + if (font.width(line + c) > maxSize && wrapLine) { + lineCount++; + line = ""; + if (y < lineCount) { + break; + } + } + if (lineCount == y && x <= font.width(line + c)) + return; + charCount++; + line += c; + + } + cursorPosition = charCount; + + + lineCount++; + charCount++; + if (y < lineCount) { + break; + } + } + if (y >= lineCount) + cursorPosition = getText().length(); + } + + private List getLines() { + List list = new ArrayList(); + String line = ""; + for (char c : getText().toCharArray()) { + if (c == '\r' || c == '\n') { + list.add(line); + line = ""; + } else + line += c; + } + list.add(line); + return list; + } + + private int getStartLineY() { + if (!isScrolling()) + scrolledY = 0; + return MathHelper.ceiling_double_int(scrolledY * (listHeight) / font.height()); + } + + @Override + public void drawTextBox(int mouseX, int mouseY) { drawRect(posX - 1, posY - 1, posX + width + 1, posY + height + 1, 0xffa0a0a0); drawRect(posX, posY, posX + width, posY + height, 0xff000000); @@ -176,122 +173,119 @@ public class GuiNpcTextArea extends GuiNpcTextField { int charCount = 0; int lineCount = 0; - int maxSize = width - (isScrolling()?14:4); - for(int i = 0; i < lines.size(); i++){ - String wholeLine = lines.get(i); - String line = ""; - for(char c : wholeLine.toCharArray()){ - if(font.width(line + c) > maxSize && wrapLine){ - if(lineCount >= startLine && lineCount < maxLine) - drawString(null, line, posX + 4, posY + 4 + ((lineCount - startLine) * font.height()), color); - line = ""; - lineCount++; - } - if(flag && charCount == cursorPosition && lineCount >= startLine && lineCount < maxLine && canEdit){ - int xx = posX + font.width(line) + 4; - int yy = posY + ((lineCount - startLine) * font.height()) + 4; - if(getText().length() == cursorPosition){ - font.drawString("_", xx, yy, color); - } - else{ - drawCursorVertical(xx, yy, xx + 1, yy + font.height()); - } - } - charCount++; - line += c; - } - if(lineCount >= startLine && lineCount < maxLine){ - drawString(null, line, posX + 4, posY + 4 + ((lineCount - startLine) * (font.height())), color); - if(flag && charCount == cursorPosition && canEdit){ - int xx = posX + font.width(line) + 4; - int yy = posY + ((lineCount - startLine) * font.height()) + 4; - if(getText().length() == cursorPosition){ - font.drawString("_", xx, yy, color); - } - else{ - drawCursorVertical(xx, yy, xx + 1, yy + font.height()); - } - } - } - lineCount++; - charCount++; + int maxSize = width - (isScrolling() ? 14 : 4); + for (int i = 0; i < lines.size(); i++) { + String wholeLine = lines.get(i); + String line = ""; + for (char c : wholeLine.toCharArray()) { + if (font.width(line + c) > maxSize && wrapLine) { + if (lineCount >= startLine && lineCount < maxLine) + drawString(null, line, posX + 4, posY + 4 + ((lineCount - startLine) * font.height()), color); + line = ""; + lineCount++; + } + if (flag && charCount == cursorPosition && lineCount >= startLine && lineCount < maxLine && canEdit) { + int xx = posX + font.width(line) + 4; + int yy = posY + ((lineCount - startLine) * font.height()) + 4; + if (getText().length() == cursorPosition) { + font.drawString("_", xx, yy, color); + } else { + drawCursorVertical(xx, yy, xx + 1, yy + font.height()); + } + } + charCount++; + line += c; + } + if (lineCount >= startLine && lineCount < maxLine) { + drawString(null, line, posX + 4, posY + 4 + ((lineCount - startLine) * (font.height())), color); + if (flag && charCount == cursorPosition && canEdit) { + int xx = posX + font.width(line) + 4; + int yy = posY + ((lineCount - startLine) * font.height()) + 4; + if (getText().length() == cursorPosition) { + font.drawString("_", xx, yy, color); + } else { + drawCursorVertical(xx, yy, xx + 1, yy + font.height()); + } + } + } + lineCount++; + charCount++; } int k2 = Mouse.getDWheel(); - if(k2 != 0 && isFocused()){ - addScrollY(k2 < 0?-10:10); + if (k2 != 0 && isFocused()) { + addScrollY(k2 < 0 ? -10 : 10); } - if(Mouse.isButtonDown(0)){ - if(clickVerticalBar){ - if(startClick >= 0) - addScrollY(startClick - (mouseY - posY)); + if (Mouse.isButtonDown(0)) { + if (clickVerticalBar) { + if (startClick >= 0) + addScrollY(startClick - (mouseY - posY)); - if(hoverVerticalScrollBar(mouseX, mouseY)) - startClick = mouseY - posY; + if (hoverVerticalScrollBar(mouseX, mouseY)) + startClick = mouseY - posY; - startClick = mouseY - posY; - } - } - else - clickVerticalBar = false; + startClick = mouseY - posY; + } + } else + clickVerticalBar = false; listHeight = lineCount * font.height(); drawVerticalScrollBar(); } - public void drawString(FontRenderer fontRendererIn, String text, int x, int y, int color){ - GL11.glColor4f(1, 1, 1, 1); - font.drawString(text, x, y, color); - //super.drawString(fontRendererIn, text, x, y, color); + public void drawString(FontRenderer fontRendererIn, String text, int x, int y, int color) { + GL11.glColor4f(1, 1, 1, 1); + font.drawString(text, x, y, color); + //super.drawString(fontRendererIn, text, x, y, color); } - private boolean isScrolling() { - return listHeight > height - 4; - } + private boolean isScrolling() { + return listHeight > height - 4; + } - private void addScrollY(int scrolled){ - scrolledY -= 1f * scrolled / height; + private void addScrollY(int scrolled) { + scrolledY -= 1f * scrolled / height; - if(scrolledY < 0) - scrolledY = 0; + if (scrolledY < 0) + scrolledY = 0; - float max = 1 - 1f * (height + 2) / listHeight; - if(scrolledY > max ) - scrolledY = max; - } + float max = 1 - 1f * (height + 2) / listHeight; + if (scrolledY > max) + scrolledY = max; + } - private boolean hoverVerticalScrollBar(int x, int y){ - if(listHeight <= height - 4) - return false; + private boolean hoverVerticalScrollBar(int x, int y) { + if (listHeight <= height - 4) + return false; - if(posY < y && posY + height > y && x < posX + width && x > posX + (width - 8)) - return true; + if (posY < y && posY + height > y && x < posX + width && x > posX + (width - 8)) + return true; - return false; - } + return false; + } - private void drawCursorVertical(int p_146188_1_, int p_146188_2_, int p_146188_3_, int p_146188_4_){ + private void drawCursorVertical(int p_146188_1_, int p_146188_2_, int p_146188_3_, int p_146188_4_) { int i1; - if (p_146188_1_ < p_146188_3_){ + if (p_146188_1_ < p_146188_3_) { i1 = p_146188_1_; p_146188_1_ = p_146188_3_; p_146188_3_ = i1; } - if (p_146188_2_ < p_146188_4_){ + if (p_146188_2_ < p_146188_4_) { i1 = p_146188_2_; p_146188_2_ = p_146188_4_; p_146188_4_ = i1; } - if (p_146188_3_ > this.posX + this.width){ + if (p_146188_3_ > this.posX + this.width) { p_146188_3_ = this.posX + this.width; } - if (p_146188_1_ > this.posX + this.width){ + if (p_146188_1_ > this.posX + this.width) { p_146188_1_ = this.posX + this.width; } @@ -301,27 +295,29 @@ public class GuiNpcTextArea extends GuiNpcTextField { GL11.glEnable(GL11.GL_COLOR_LOGIC_OP); GL11.glLogicOp(GL11.GL_OR_REVERSE); tessellator.startDrawingQuads(); - tessellator.addVertex((double)p_146188_1_, (double)p_146188_4_, 0.0D); - tessellator.addVertex((double)p_146188_3_, (double)p_146188_4_, 0.0D); - tessellator.addVertex((double)p_146188_3_, (double)p_146188_2_, 0.0D); - tessellator.addVertex((double)p_146188_1_, (double)p_146188_2_, 0.0D); + tessellator.addVertex((double) p_146188_1_, (double) p_146188_4_, 0.0D); + tessellator.addVertex((double) p_146188_3_, (double) p_146188_4_, 0.0D); + tessellator.addVertex((double) p_146188_3_, (double) p_146188_2_, 0.0D); + tessellator.addVertex((double) p_146188_1_, (double) p_146188_2_, 0.0D); tessellator.draw(); GL11.glDisable(GL11.GL_COLOR_LOGIC_OP); GL11.glEnable(GL11.GL_TEXTURE_2D); } - private int getVerticalBarSize(){ - return (int) (1f * height / listHeight * (height - 4)); + + private int getVerticalBarSize() { + return (int) (1f * height / listHeight * (height - 4)); } - private void drawVerticalScrollBar(){ - if(listHeight <= height - 4) - return; + + private void drawVerticalScrollBar() { + if (listHeight <= height - 4) + return; Minecraft.getMinecraft().renderEngine.bindTexture(GuiCustomScroll.resource); int x = posX + width - 6; int y = (int) (posY + scrolledY * height) + 2; GL11.glColor4f(1, 1, 1, 1); int sbSize = getVerticalBarSize(); drawTexturedModalRect(x, y, width, 9, 5, 1); - for(int k = 0; k < sbSize; k++){ + for (int k = 0; k < sbSize; k++) { drawTexturedModalRect(x, y + k, width, 10, 5, 1); } drawTexturedModalRect(x, y, width, 11, 5, 1); diff --git a/src/main/java/noppes/npcs/client/gui/util/GuiScriptTextArea.java b/src/main/java/noppes/npcs/client/gui/util/GuiScriptTextArea.java index 364ad8083..205351715 100644 --- a/src/main/java/noppes/npcs/client/gui/util/GuiScriptTextArea.java +++ b/src/main/java/noppes/npcs/client/gui/util/GuiScriptTextArea.java @@ -55,65 +55,59 @@ public class GuiScriptTextArea extends GuiNpcTextField { this.undoing = false; } - public void drawTextBox(int xMouse, int yMouse){ - if(!visible) + public void drawTextBox(int xMouse, int yMouse) { + if (!visible) return; drawRect(x - 1, y - 1, x + width + 1, y + height + 1, 0xffa0a0a0); drawRect(x, y, x + width, y + height, 0xff000000); container.visibleLines = height / container.lineHeight; - if(listener instanceof GuiNPCInterface){ + if (listener instanceof GuiNPCInterface) { int k2 = ((GuiNPCInterface) listener).mouseScroll = Mouse.getDWheel(); - if(k2 != 0) { - this.scrolledLine -= k2/40; + if (k2 != 0) { + this.scrolledLine -= k2 / 40; this.scrolledLine = Math.max(Math.min(this.scrolledLine, this.container.linesCount - this.height / this.container.lineHeight), 0); } } - if(clicked){ + if (clicked) { clicked = Mouse.isButtonDown(0); int i = getSelectionPos(xMouse, yMouse); - if(i != cursorPosition){ - if(doubleClicked){ + if (i != cursorPosition) { + if (doubleClicked) { startSelection = endSelection = cursorPosition; doubleClicked = false; } setCursor(i, true); } - } - else if(doubleClicked){ + } else if (doubleClicked) { doubleClicked = false; } - if(clickScrolling){ + if (clickScrolling) { clickScrolling = Mouse.isButtonDown(0); int diff = container.linesCount - container.visibleLines; - scrolledLine = Math.min(Math.max((int)(1f * diff * (yMouse - y) / height), 0), diff); + scrolledLine = Math.min(Math.max((int) (1f * diff * (yMouse - y) / height), 0), diff); } int startBracket = 0, endBracket = 0; - if(endSelection - startSelection == 1 || startSelection == endSelection && startSelection < text.length()){ + if (endSelection - startSelection == 1 || startSelection == endSelection && startSelection < text.length()) { char c = text.charAt(startSelection); int found = 0; - if(c == '{'){ + if (c == '{') { found = findClosingBracket(text.substring(startSelection), '{', '}'); - } - else if(c == '['){ + } else if (c == '[') { found = findClosingBracket(text.substring(startSelection), '[', ']'); - } - else if(c == '('){ + } else if (c == '(') { found = findClosingBracket(text.substring(startSelection), '(', ')'); - } - else if(c == '}'){ + } else if (c == '}') { found = findOpeningBracket(text.substring(0, startSelection + 1), '{', '}'); - } - else if(c == ']'){ + } else if (c == ']') { found = findOpeningBracket(text.substring(0, startSelection + 1), '[', ']'); - } - else if(c == ')'){ + } else if (c == ')') { found = findOpeningBracket(text.substring(0, startSelection + 1), '(', ')'); } - if(found != 0){ + if (found != 0) { startBracket = startSelection; endBracket = startSelection + found; } @@ -122,37 +116,37 @@ public class GuiScriptTextArea extends GuiNpcTextField { List list = new ArrayList(container.lines); String wordHightLight = null; - if(startSelection != endSelection){ + if (startSelection != endSelection) { Matcher m = container.regexWord.matcher(text); - while(m.find()){ - if(m.start() == startSelection && m.end() == endSelection){ + while (m.find()) { + if (m.start() == startSelection && m.end() == endSelection) { wordHightLight = text.substring(startSelection, endSelection); } } } - for(int i = 0; i < list.size(); i++){ + for (int i = 0; i < list.size(); i++) { LineData data = list.get(i); String line = data.text; int w = line.length(); - if(startBracket != endBracket){ - if(startBracket >= data.start && startBracket < data.end){ + if (startBracket != endBracket) { + if (startBracket >= data.start && startBracket < data.end) { int s = ClientProxy.Font.width(line.substring(0, startBracket - data.start)); int e = ClientProxy.Font.width(line.substring(0, startBracket - data.start + 1)) + 1; int posY = y + 1 + (i - scrolledLine) * container.lineHeight; drawRect(x + 1 + s, posY, x + 1 + e, posY + container.lineHeight + 1, 0x9900cc00); } - if(endBracket >= data.start && endBracket < data.end){ + if (endBracket >= data.start && endBracket < data.end) { int s = ClientProxy.Font.width(line.substring(0, endBracket - data.start)); int e = ClientProxy.Font.width(line.substring(0, endBracket - data.start + 1)) + 1; int posY = y + 1 + (i - scrolledLine) * container.lineHeight; drawRect(x + 1 + s, posY, x + 1 + e, posY + container.lineHeight + 1, 0x9900cc00); } } - if(i >= scrolledLine && i < scrolledLine + container.visibleLines){ - if(wordHightLight != null){ + if (i >= scrolledLine && i < scrolledLine + container.visibleLines) { + if (wordHightLight != null) { Matcher m = container.regexWord.matcher(line); - while(m.find()){ - if(line.substring(m.start(), m.end()).equals(wordHightLight)){ + while (m.find()) { + if (line.substring(m.start(), m.end()).equals(wordHightLight)) { int s = ClientProxy.Font.width(line.substring(0, m.start())); int e = ClientProxy.Font.width(line.substring(0, m.end())) + 1; int posY = y + 1 + (i - scrolledLine) * container.lineHeight; @@ -160,8 +154,8 @@ public class GuiScriptTextArea extends GuiNpcTextField { } } } - if(startSelection != endSelection && endSelection > data.start && startSelection <= data.end){ - if(startSelection < data.end){ + if (startSelection != endSelection && endSelection > data.start && startSelection <= data.end) { + if (startSelection < data.end) { int s = ClientProxy.Font.width(line.substring(0, Math.max(startSelection - data.start, 0))); int e = ClientProxy.Font.width(line.substring(0, Math.min(endSelection - data.start, w))) + 1; int posY = y + 1 + (i - scrolledLine) * container.lineHeight; @@ -171,19 +165,19 @@ public class GuiScriptTextArea extends GuiNpcTextField { int yPos = y + (i - scrolledLine) * container.lineHeight + 1; data.drawString(x + 1, yPos, 0xFFe0e0e0); - if(active && isEnabled() && (cursorCounter / 6) % 2 == 0 && cursorPosition >= data.start && cursorPosition < data.end){ + if (active && isEnabled() && (cursorCounter / 6) % 2 == 0 && cursorPosition >= data.start && cursorPosition < data.end) { int posX = x + ClientProxy.Font.width(line.substring(0, cursorPosition - data.start)); drawRect(posX + 1, yPos, posX + 2, yPos + 1 + container.lineHeight, -3092272); } } } - if(hasVerticalScrollbar()){ + if (hasVerticalScrollbar()) { Minecraft.getMinecraft().renderEngine.bindTexture(GuiCustomScroll.resource); int sbSize = Math.max((int) (1f * container.visibleLines / container.linesCount * height), 2); int posX = x + width - 6; - int posY = (int) (y + 1f * scrolledLine / container.linesCount * (height - 4)) + 1; + int posY = (int) (y + 1f * scrolledLine / container.linesCount * (height - 4)) + 1; drawRect(posX, posY, posX + 5, posY + sbSize, 0xFFe0e0e0); } @@ -193,13 +187,13 @@ public class GuiScriptTextArea extends GuiNpcTextField { int found = 0; char[] chars = str.toCharArray(); - for(int i = 0; i < chars.length; ++i) { + for (int i = 0; i < chars.length; ++i) { char c = chars[i]; - if(c == s) { + if (c == s) { ++found; - } else if(c == e) { + } else if (c == e) { --found; - if(found == 0) { + if (found == 0) { return i; } } @@ -212,13 +206,13 @@ public class GuiScriptTextArea extends GuiNpcTextField { int found = 0; char[] chars = str.toCharArray(); - for(int i = chars.length - 1; i >= 0; --i) { + for (int i = chars.length - 1; i >= 0; --i) { char c = chars[i]; - if(c == e) { + if (c == e) { ++found; - } else if(c == s) { + } else if (c == s) { --found; - if(found == 0) { + if (found == 0) { return i - chars.length + 1; } } @@ -232,17 +226,17 @@ public class GuiScriptTextArea extends GuiNpcTextField { yMouse -= this.y + 1; ArrayList list = new ArrayList(this.container.lines); - for(int i = 0; i < list.size(); ++i) { - LineData data = (LineData)list.get(i); - if(i >= this.scrolledLine && i < this.scrolledLine + this.container.visibleLines) { + for (int i = 0; i < list.size(); ++i) { + LineData data = (LineData) list.get(i); + if (i >= this.scrolledLine && i < this.scrolledLine + this.container.visibleLines) { int yPos = (i - this.scrolledLine) * this.container.lineHeight; - if(yMouse >= yPos && yMouse < yPos + this.container.lineHeight) { + if (yMouse >= yPos && yMouse < yPos + this.container.lineHeight) { int lineWidth = 0; char[] chars = data.text.toCharArray(); - for(int j = 1; j <= chars.length; ++j) { + for (int j = 1; j <= chars.length; ++j) { int w = ClientProxy.Font.width(data.text.substring(0, j)); - if(xMouse < lineWidth + (w - lineWidth) / 2) { + if (xMouse < lineWidth + (w - lineWidth) / 2) { return data.start + j - 1; } @@ -259,25 +253,25 @@ public class GuiScriptTextArea extends GuiNpcTextField { @Override public boolean textboxKeyTyped(char c, int i) { - if(!active) + if (!active) return false; - if(this.isKeyComboCtrlA(i)){ + if (this.isKeyComboCtrlA(i)) { startSelection = cursorPosition = 0; endSelection = text.length(); return true; } - if(!isEnabled()) + if (!isEnabled()) return false; String original = text; - if(i == Keyboard.KEY_LEFT){ + if (i == Keyboard.KEY_LEFT) { int j = 1; - if(isCtrlKeyDown()){ + if (isCtrlKeyDown()) { Matcher m = container.regexWord.matcher(text.substring(0, cursorPosition)); - while(m.find()){ - if(m.start() == m.end()) + while (m.find()) { + if (m.start() == m.end()) continue; j = cursorPosition - m.start(); } @@ -285,40 +279,40 @@ public class GuiScriptTextArea extends GuiNpcTextField { setCursor(cursorPosition - j, GuiScreen.isShiftKeyDown()); return true; } - if(i == Keyboard.KEY_RIGHT){ + if (i == Keyboard.KEY_RIGHT) { int j = 1; - if(isCtrlKeyDown()){ + if (isCtrlKeyDown()) { Matcher m = container.regexWord.matcher(text.substring(cursorPosition)); - if(m.find() && m.start() > 0 || m.find()){ + if (m.find() && m.start() > 0 || m.find()) { j = m.start(); } } setCursor(cursorPosition + j, GuiScreen.isShiftKeyDown()); return true; } - if(i == Keyboard.KEY_UP){ + if (i == Keyboard.KEY_UP) { setCursor(cursorUp(), GuiScreen.isShiftKeyDown()); return true; } - if(i == Keyboard.KEY_DOWN){ + if (i == Keyboard.KEY_DOWN) { setCursor(cursorDown(), GuiScreen.isShiftKeyDown()); return true; } - if(i == Keyboard.KEY_DELETE){ + if (i == Keyboard.KEY_DELETE) { String s = getSelectionAfterText(); - if(!s.isEmpty() && startSelection == endSelection) + if (!s.isEmpty() && startSelection == endSelection) s = s.substring(1); setText(getSelectionBeforeText() + s); endSelection = cursorPosition = startSelection; return true; } - if(isKeyComboCtrlBackspace(i)){ + if (isKeyComboCtrlBackspace(i)) { String s = getSelectionBeforeText(); - if(startSelection > 0 && startSelection == endSelection){ + if (startSelection > 0 && startSelection == endSelection) { int nearestCondition = cursorPosition; int g; boolean cursorInWhitespace = Character.isWhitespace(s.charAt(cursorPosition - 1)); - if(cursorInWhitespace){ + if (cursorInWhitespace) { // Find the nearest word if we are starting in whitespace for (g = cursorPosition - 1; g >= 0; g--) { char currentChar = s.charAt(g); @@ -326,20 +320,19 @@ public class GuiScriptTextArea extends GuiNpcTextField { nearestCondition = g; break; } - if(g == 0){ + if (g == 0) { nearestCondition = 0; } } - } - else { + } else { // Find the nearest blank space or new line for (g = cursorPosition - 1; g >= 0; g--) { char currentChar = s.charAt(g); - if (Character.isWhitespace(currentChar) || currentChar == '\n') { + if (Character.isWhitespace(currentChar) || currentChar == '\n') { nearestCondition = g; break; } - if(g == 0){ + if (g == 0) { nearestCondition = 0; } } @@ -353,9 +346,9 @@ public class GuiScriptTextArea extends GuiNpcTextField { endSelection = cursorPosition = startSelection; return true; } - if(i == Keyboard.KEY_BACK){ + if (i == Keyboard.KEY_BACK) { String s = getSelectionBeforeText(); - if(startSelection > 0 && startSelection == endSelection){ + if (startSelection > 0 && startSelection == endSelection) { s = s.substring(0, s.length() - 1); startSelection--; } @@ -363,8 +356,8 @@ public class GuiScriptTextArea extends GuiNpcTextField { endSelection = cursorPosition = startSelection; return true; } - if(this.isKeyComboCtrlX(i)){ - if(startSelection != endSelection){ + if (this.isKeyComboCtrlX(i)) { + if (startSelection != endSelection) { NoppesStringUtils.setClipboardContents(text.substring(startSelection, endSelection)); String s = getSelectionBeforeText(); setText(s + getSelectionAfterText()); @@ -373,18 +366,18 @@ public class GuiScriptTextArea extends GuiNpcTextField { } return true; } - if(this.isKeyComboCtrlC(i)){ - if(startSelection != endSelection){ + if (this.isKeyComboCtrlC(i)) { + if (startSelection != endSelection) { NoppesStringUtils.setClipboardContents(text.substring(startSelection, endSelection)); } return true; } - if(this.isKeyComboCtrlV(i)){ + if (this.isKeyComboCtrlV(i)) { addText(NoppesStringUtils.getClipboardContents()); return true; } - if(i == Keyboard.KEY_Z && isCtrlKeyDown()){ - if(undoList.isEmpty()) + if (i == Keyboard.KEY_Z && isCtrlKeyDown()) { + if (undoList.isEmpty()) return false; undoing = true; redoList.add(new UndoData(this.text, this.cursorPosition)); @@ -394,8 +387,8 @@ public class GuiScriptTextArea extends GuiNpcTextField { undoing = false; return true; } - if(i == Keyboard.KEY_Y && isCtrlKeyDown()){ - if(redoList.isEmpty()) + if (i == Keyboard.KEY_Y && isCtrlKeyDown()) { + if (redoList.isEmpty()) return false; undoing = true; undoList.add(new UndoData(this.text, this.cursorPosition)); @@ -405,51 +398,44 @@ public class GuiScriptTextArea extends GuiNpcTextField { undoing = false; return true; } - if(i == Keyboard.KEY_TAB){ + if (i == Keyboard.KEY_TAB) { addText(" "); } - if(i == Keyboard.KEY_RETURN){ + if (i == Keyboard.KEY_RETURN) { addText(Character.toString('\n') + getIndentCurrentLine()); } - if(ChatAllowedCharacters.isAllowedCharacter(c)){ + if (ChatAllowedCharacters.isAllowedCharacter(c)) { addText(Character.toString(c)); } return true; } - private boolean isShiftKeyDown() - { + private boolean isShiftKeyDown() { return Keyboard.isKeyDown(42) || Keyboard.isKeyDown(54); } - private boolean isAltKeyDown() - { + private boolean isAltKeyDown() { return Keyboard.isKeyDown(56) || Keyboard.isKeyDown(184); } - private boolean isKeyComboCtrlX(int keyID) - { + private boolean isKeyComboCtrlX(int keyID) { return keyID == 45 && isCtrlKeyDown() && !isShiftKeyDown() && !isAltKeyDown(); } - private boolean isKeyComboCtrlBackspace(int keyID) - { + private boolean isKeyComboCtrlBackspace(int keyID) { return keyID == Keyboard.KEY_BACK && isCtrlKeyDown() && !isShiftKeyDown() && !isAltKeyDown(); } - private boolean isKeyComboCtrlV(int keyID) - { + private boolean isKeyComboCtrlV(int keyID) { return keyID == 47 && isCtrlKeyDown() && !isShiftKeyDown() && !isAltKeyDown(); } - private boolean isKeyComboCtrlC(int keyID) - { + private boolean isKeyComboCtrlC(int keyID) { return keyID == 46 && isCtrlKeyDown() && !isShiftKeyDown() && !isAltKeyDown(); } - private boolean isKeyComboCtrlA(int keyID) - { + private boolean isKeyComboCtrlA(int keyID) { return keyID == 30 && isCtrlKeyDown() && !isShiftKeyDown() && !isAltKeyDown(); } @@ -458,15 +444,15 @@ public class GuiScriptTextArea extends GuiNpcTextField { LineData data; do { - if(!var1.hasNext()) { + if (!var1.hasNext()) { return ""; } - data = (LineData)var1.next(); - } while(this.cursorPosition <= data.start || this.cursorPosition > data.end); + data = (LineData) var1.next(); + } while (this.cursorPosition <= data.start || this.cursorPosition > data.end); int i; - for(i = 0; i < data.text.length() && data.text.charAt(i) == 32; ++i) { + for (i = 0; i < data.text.length() && data.text.charAt(i) == 32; ++i) { ; } @@ -475,18 +461,18 @@ public class GuiScriptTextArea extends GuiNpcTextField { private void setCursor(int i, boolean select) { i = Math.min(Math.max(i, 0), this.text.length()); - if(i != this.cursorPosition) { - if(!select) { + if (i != this.cursorPosition) { + if (!select) { this.endSelection = this.startSelection = this.cursorPosition = i; } else { int diff = this.cursorPosition - i; - if(this.cursorPosition == this.startSelection) { + if (this.cursorPosition == this.startSelection) { this.startSelection -= diff; - } else if(this.cursorPosition == this.endSelection) { + } else if (this.cursorPosition == this.endSelection) { this.endSelection -= diff; } - if(this.startSelection > this.endSelection) { + if (this.startSelection > this.endSelection) { int j = this.endSelection; this.endSelection = this.startSelection; this.startSelection = j; @@ -503,10 +489,10 @@ public class GuiScriptTextArea extends GuiNpcTextField { } private int cursorUp() { - for(int i = 0; i < this.container.lines.size(); ++i) { - LineData data = (LineData)this.container.lines.get(i); - if(this.cursorPosition >= data.start && this.cursorPosition < data.end) { - if(i == 0) { + for (int i = 0; i < this.container.lines.size(); ++i) { + LineData data = (LineData) this.container.lines.get(i); + if (this.cursorPosition >= data.start && this.cursorPosition < data.end) { + if (i == 0) { return 0; } @@ -519,9 +505,9 @@ public class GuiScriptTextArea extends GuiNpcTextField { } private int cursorDown() { - for(int i = 0; i < this.container.lines.size(); ++i) { - LineData data = (LineData)this.container.lines.get(i); - if(this.cursorPosition >= data.start && this.cursorPosition < data.end) { + for (int i = 0; i < this.container.lines.size(); ++i) { + LineData data = (LineData) this.container.lines.get(i); + if (this.cursorPosition >= data.start && this.cursorPosition < data.end) { int var10000 = this.cursorPosition - data.start; return this.getSelectionPos(this.x + 1 + ClientProxy.Font.width(data.text.substring(0, this.cursorPosition - data.start)), this.y + 1 + (i + 1 - this.scrolledLine) * this.container.lineHeight); } @@ -531,7 +517,7 @@ public class GuiScriptTextArea extends GuiNpcTextField { } public String getSelectionBeforeText() { - return this.startSelection == 0?"":this.text.substring(0, this.startSelection); + return this.startSelection == 0 ? "" : this.text.substring(0, this.startSelection); } public String getSelectionAfterText() { @@ -540,20 +526,20 @@ public class GuiScriptTextArea extends GuiNpcTextField { public void mouseClicked(int xMouse, int yMouse, int mouseButton) { this.active = xMouse >= this.x && xMouse < this.x + this.width && yMouse >= this.y && yMouse < this.y + this.height; - if(this.active) { + if (this.active) { this.startSelection = this.endSelection = this.cursorPosition = this.getSelectionPos(xMouse, yMouse); this.clicked = mouseButton == 0; this.doubleClicked = false; long time = System.currentTimeMillis(); - if(this.clicked && this.container.linesCount * this.container.lineHeight > this.height && xMouse > this.x + this.width - 8) { + if (this.clicked && this.container.linesCount * this.container.lineHeight > this.height && xMouse > this.x + this.width - 8) { this.clicked = false; this.clickScrolling = true; - } else if(time - this.lastClicked < 500L) { + } else if (time - this.lastClicked < 500L) { this.doubleClicked = true; Matcher m = this.container.regexWord.matcher(this.text); - while(m.find()) { - if(this.cursorPosition > m.start() && this.cursorPosition < m.end()) { + while (m.find()) { + if (this.cursorPosition > m.start() && this.cursorPosition < m.end()) { this.startSelection = m.start(); this.endSelection = m.end(); break; @@ -577,12 +563,12 @@ public class GuiScriptTextArea extends GuiNpcTextField { text = text.replace("\r", ""); text = text.replace("\t", " "); - if(this.text == null || !this.text.equals(text)) { - if(this.listener != null) { + if (this.text == null || !this.text.equals(text)) { + if (this.listener != null) { this.listener.textUpdate(text); } - if(!this.undoing) { + if (!this.undoing) { this.undoList.add(new GuiScriptTextArea.UndoData(this.text, this.cursorPosition)); this.redoList.clear(); } @@ -590,11 +576,11 @@ public class GuiScriptTextArea extends GuiNpcTextField { this.text = text; this.container = new TextContainer(text); this.container.init(this.width, this.height); - if(this.enableCodeHighlighting) { + if (this.enableCodeHighlighting) { this.container.formatCodeText(); } - if(this.scrolledLine > this.container.linesCount - this.container.visibleLines) { + if (this.scrolledLine > this.container.linesCount - this.container.visibleLines) { this.scrolledLine = Math.max(0, this.container.linesCount - this.container.visibleLines); } diff --git a/src/main/java/noppes/npcs/client/gui/util/GuiSelectionListener.java b/src/main/java/noppes/npcs/client/gui/util/GuiSelectionListener.java index 5d3c727c5..e8e78ff87 100644 --- a/src/main/java/noppes/npcs/client/gui/util/GuiSelectionListener.java +++ b/src/main/java/noppes/npcs/client/gui/util/GuiSelectionListener.java @@ -1,5 +1,5 @@ package noppes.npcs.client.gui.util; public interface GuiSelectionListener { - public void selected(int id, String name); + public void selected(int id, String name); } diff --git a/src/main/java/noppes/npcs/client/gui/util/GuiTexturedButton.java b/src/main/java/noppes/npcs/client/gui/util/GuiTexturedButton.java index eab7748bf..4ee005dd7 100644 --- a/src/main/java/noppes/npcs/client/gui/util/GuiTexturedButton.java +++ b/src/main/java/noppes/npcs/client/gui/util/GuiTexturedButton.java @@ -55,9 +55,9 @@ public class GuiTexturedButton extends GuiNpcButton { this.alpha = 1.0F; if (texture != null && !texture.isEmpty()) { this.location = new ResourceLocation(texture); - if(texture.startsWith("https://")){ + if (texture.startsWith("https://")) { TextureManager texturemanager = Minecraft.getMinecraft().getTextureManager(); - ITextureObject object = new ImageDownloadAlt(null, texture, new ResourceLocation("customnpcs:textures/gui/invisible.png"), new ImageBufferDownloadAlt(true,false)); + ITextureObject object = new ImageDownloadAlt(null, texture, new ResourceLocation("customnpcs:textures/gui/invisible.png"), new ImageBufferDownloadAlt(true, false)); texturemanager.loadTexture(this.location, object); } else { try { @@ -71,15 +71,13 @@ public class GuiTexturedButton extends GuiNpcButton { } } - public void drawButton(Minecraft mc, int mouseX, int mouseY) - { - if (!this.visible) - { + public void drawButton(Minecraft mc, int mouseX, int mouseY) { + if (!this.visible) { return; } this.field_146123_n = mouseX >= this.xPosition && mouseY >= this.yPosition && mouseX < this.xPosition + this.width * this.scale && mouseY < this.yPosition + this.height * this.scale; - if(imageDownloadAlt != null && isUrl && !gotWidthHeight){ + if (imageDownloadAlt != null && isUrl && !gotWidthHeight) { getURLWidthHeight(); } @@ -89,67 +87,61 @@ public class GuiTexturedButton extends GuiNpcButton { } GL11.glPushMatrix(); - if (this.location != null) { - mc.getTextureManager().bindTexture(this.location); - this.drawTexturedModalRect(0, 0, this.textureX, this.textureY, this.width, this.height); - GL11.glTranslated(0.0D, 0.0D, 0.1D); - this.drawCenteredString(mc.fontRenderer, this.label, this.width / 2, (this.height - 8) / 2, this.color); - } else { - FontRenderer fontrenderer = mc.fontRenderer; - mc.getTextureManager().bindTexture(buttonTextures); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - int k = this.getHoverState(this.field_146123_n); - GL11.glEnable(GL11.GL_BLEND); - OpenGlHelper.glBlendFunc(770, 771, 1, 0); - this.drawTexturedModalRect(0, 0, 0, 46 + k * 20, this.width / 2, this.height); - this.drawTexturedModalRect(this.width / 2, 0, 200 - this.width / 2, 46 + k * 20, this.width / 2, this.height); - this.mouseDragged(mc, mouseX, mouseY); - int l = 14737632; + if (this.location != null) { + mc.getTextureManager().bindTexture(this.location); + this.drawTexturedModalRect(0, 0, this.textureX, this.textureY, this.width, this.height); + GL11.glTranslated(0.0D, 0.0D, 0.1D); + this.drawCenteredString(mc.fontRenderer, this.label, this.width / 2, (this.height - 8) / 2, this.color); + } else { + FontRenderer fontrenderer = mc.fontRenderer; + mc.getTextureManager().bindTexture(buttonTextures); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + int k = this.getHoverState(this.field_146123_n); + GL11.glEnable(GL11.GL_BLEND); + OpenGlHelper.glBlendFunc(770, 771, 1, 0); + this.drawTexturedModalRect(0, 0, 0, 46 + k * 20, this.width / 2, this.height); + this.drawTexturedModalRect(this.width / 2, 0, 200 - this.width / 2, 46 + k * 20, this.width / 2, this.height); + this.mouseDragged(mc, mouseX, mouseY); + int l = 14737632; - if (packedFGColour != 0) - { - l = packedFGColour; - } - else if (!this.enabled) - { - l = 10526880; - } - else if (this.field_146123_n) - { - l = 16777120; - } - - this.drawCenteredString(fontrenderer, this.displayString, this.xPosition + this.width / 2, this.yPosition + (this.height - 8) / 2, l); + if (packedFGColour != 0) { + l = packedFGColour; + } else if (!this.enabled) { + l = 10526880; + } else if (this.field_146123_n) { + l = 16777120; } + + this.drawCenteredString(fontrenderer, this.displayString, this.xPosition + this.width / 2, this.yPosition + (this.height - 8) / 2, l); + } GL11.glPopMatrix(); } - public void drawTexturedModalRect(int x, int y, int textureX, int textureY, int width, int height) - { + public void drawTexturedModalRect(int x, int y, int textureX, int textureY, int width, int height) { GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glPushMatrix(); float red = (color >> 16 & 255) / 255f; - float green = (color >> 8 & 255) / 255f; + float green = (color >> 8 & 255) / 255f; float blue = (color & 255) / 255f; - GL11.glColor4f(red,green,blue,this.alpha); + GL11.glColor4f(red, green, blue, this.alpha); - float u1 = (float)textureX/(float)totalWidth; - float u2 = u1 + (float)width/(float)totalWidth; - float v1 = (float)textureY/(float)totalHeight; - float v2 = v1 + (float)height/(float)totalHeight; + float u1 = (float) textureX / (float) totalWidth; + float u2 = u1 + (float) width / (float) totalWidth; + float v1 = (float) textureY / (float) totalHeight; + float v2 = v1 + (float) height / (float) totalHeight; if (this.location != null && this.enabled) { if (this.field_146123_n) { - v1 = (float)(textureY + 2 * this.height)/(float)totalHeight; + v1 = (float) (textureY + 2 * this.height) / (float) totalHeight; } else { - v1 = (float)(textureY + this.height)/(float)totalHeight; + v1 = (float) (textureY + this.height) / (float) totalHeight; } - v2 = v1 + (float)height/(float)totalHeight; + v2 = v1 + (float) height / (float) totalHeight; } GL11.glTranslatef(x + this.xPosition - u1 * totalWidth * this.scale, y + this.yPosition - v1 * totalHeight * this.scale, this.zLevel); - GL11.glScalef(this.scale,this.scale,1.0F); + GL11.glScalef(this.scale, this.scale, 1.0F); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); Tessellator tessellator = Tessellator.instance; tessellator.startDrawingQuads(); @@ -164,9 +156,8 @@ public class GuiTexturedButton extends GuiNpcButton { } @Override - public boolean mousePressed(Minecraft minecraft, int i, int j) - { - return super.mousePressed(minecraft,i,j) || this.field_146123_n; + public boolean mousePressed(Minecraft minecraft, int i, int j) { + return super.mousePressed(minecraft, i, j) || this.field_146123_n; } public void getWidthHeight() throws IOException { @@ -189,8 +180,8 @@ public class GuiTexturedButton extends GuiNpcButton { } } - public void getURLWidthHeight(){ - if(imageDownloadAlt.getBufferedImage() != null) { + public void getURLWidthHeight() { + if (imageDownloadAlt.getBufferedImage() != null) { gotWidthHeight = true; this.totalWidth = imageDownloadAlt.getBufferedImage().getWidth(); this.totalHeight = imageDownloadAlt.getBufferedImage().getHeight(); @@ -198,7 +189,7 @@ public class GuiTexturedButton extends GuiNpcButton { } } - public void correctWidthHeight(){ + public void correctWidthHeight() { totalWidth = Math.max(totalWidth, 1); totalHeight = Math.max(totalHeight, 1); this.width = width < 0 ? totalWidth : width; diff --git a/src/main/java/noppes/npcs/client/gui/util/GuiToggleButton.java b/src/main/java/noppes/npcs/client/gui/util/GuiToggleButton.java index c9bb6c91c..58093bc31 100644 --- a/src/main/java/noppes/npcs/client/gui/util/GuiToggleButton.java +++ b/src/main/java/noppes/npcs/client/gui/util/GuiToggleButton.java @@ -122,7 +122,7 @@ public class GuiToggleButton extends GuiNpcButton { // Knob width equals half of the button (20 pixels). int knobWidth = FIXED_WIDTH / 2; // The knob slides from xPosition (OFF) to xPosition + (FIXED_WIDTH - knobWidth) (ON). - int knobX = this.xPosition + (int)((FIXED_WIDTH - knobWidth) * animProgress); + int knobX = this.xPosition + (int) ((FIXED_WIDTH - knobWidth) * animProgress); int knobY = this.yPosition; // Draw the knob with no tint. diff --git a/src/main/java/noppes/npcs/client/gui/util/IButtonListener.java b/src/main/java/noppes/npcs/client/gui/util/IButtonListener.java index 84a8a2c01..6c4b1d17d 100644 --- a/src/main/java/noppes/npcs/client/gui/util/IButtonListener.java +++ b/src/main/java/noppes/npcs/client/gui/util/IButtonListener.java @@ -3,5 +3,5 @@ package noppes.npcs.client.gui.util; import net.minecraft.client.gui.GuiButton; public interface IButtonListener { - public void actionPerformed(GuiButton button); + public void actionPerformed(GuiButton button); } diff --git a/src/main/java/noppes/npcs/client/gui/util/ICustomScrollListener.java b/src/main/java/noppes/npcs/client/gui/util/ICustomScrollListener.java index d47a0f5ab..be94fd53b 100644 --- a/src/main/java/noppes/npcs/client/gui/util/ICustomScrollListener.java +++ b/src/main/java/noppes/npcs/client/gui/util/ICustomScrollListener.java @@ -1,10 +1,10 @@ package noppes.npcs.client.gui.util; - public interface ICustomScrollListener { - void customScrollClicked(int i, int j, int k, GuiCustomScroll guiCustomScroll); + void customScrollClicked(int i, int j, int k, GuiCustomScroll guiCustomScroll); - default void customScrollDoubleClicked(String selection, GuiCustomScroll scroll){} + default void customScrollDoubleClicked(String selection, GuiCustomScroll scroll) { + } } diff --git a/src/main/java/noppes/npcs/client/gui/util/IGuiClose.java b/src/main/java/noppes/npcs/client/gui/util/IGuiClose.java index 29a09a21f..61b8de415 100644 --- a/src/main/java/noppes/npcs/client/gui/util/IGuiClose.java +++ b/src/main/java/noppes/npcs/client/gui/util/IGuiClose.java @@ -3,5 +3,5 @@ package noppes.npcs.client.gui.util; import net.minecraft.nbt.NBTTagCompound; public interface IGuiClose { - public void setClose(int i, NBTTagCompound data); + public void setClose(int i, NBTTagCompound data); } diff --git a/src/main/java/noppes/npcs/client/gui/util/IGuiData.java b/src/main/java/noppes/npcs/client/gui/util/IGuiData.java index 5984f6aae..36ba683ac 100644 --- a/src/main/java/noppes/npcs/client/gui/util/IGuiData.java +++ b/src/main/java/noppes/npcs/client/gui/util/IGuiData.java @@ -3,5 +3,5 @@ package noppes.npcs.client.gui.util; import net.minecraft.nbt.NBTTagCompound; public interface IGuiData { - public void setGuiData(NBTTagCompound compound); + public void setGuiData(NBTTagCompound compound); } diff --git a/src/main/java/noppes/npcs/client/gui/util/IGuiError.java b/src/main/java/noppes/npcs/client/gui/util/IGuiError.java index 5d4ff0f53..3a5a68a1f 100644 --- a/src/main/java/noppes/npcs/client/gui/util/IGuiError.java +++ b/src/main/java/noppes/npcs/client/gui/util/IGuiError.java @@ -3,5 +3,5 @@ package noppes.npcs.client.gui.util; import net.minecraft.nbt.NBTTagCompound; public interface IGuiError { - public void setError(int i, NBTTagCompound data); + public void setError(int i, NBTTagCompound data); } diff --git a/src/main/java/noppes/npcs/client/gui/util/IJTextAreaListener.java b/src/main/java/noppes/npcs/client/gui/util/IJTextAreaListener.java index 311ebafb4..a4d5593ec 100644 --- a/src/main/java/noppes/npcs/client/gui/util/IJTextAreaListener.java +++ b/src/main/java/noppes/npcs/client/gui/util/IJTextAreaListener.java @@ -1,5 +1,5 @@ package noppes.npcs.client.gui.util; public interface IJTextAreaListener { - public void saveText(String text); + public void saveText(String text); } diff --git a/src/main/java/noppes/npcs/client/gui/util/IPartyData.java b/src/main/java/noppes/npcs/client/gui/util/IPartyData.java index be4b5e46f..b96751a9e 100644 --- a/src/main/java/noppes/npcs/client/gui/util/IPartyData.java +++ b/src/main/java/noppes/npcs/client/gui/util/IPartyData.java @@ -3,5 +3,5 @@ package noppes.npcs.client.gui.util; import net.minecraft.nbt.NBTTagCompound; public interface IPartyData { - public void setPartyData(NBTTagCompound compound); + public void setPartyData(NBTTagCompound compound); } diff --git a/src/main/java/noppes/npcs/client/gui/util/IPlayerDataInfo.java b/src/main/java/noppes/npcs/client/gui/util/IPlayerDataInfo.java index cd7949934..de8834d02 100644 --- a/src/main/java/noppes/npcs/client/gui/util/IPlayerDataInfo.java +++ b/src/main/java/noppes/npcs/client/gui/util/IPlayerDataInfo.java @@ -6,10 +6,15 @@ import java.util.Map; public interface IPlayerDataInfo { void setQuestData(Map questCategories, Map questActive, Map questFinished); + void setDialogData(Map dialogCategories, Map dialogRead); + void setTransportData(Map transportCategories, Map transportLocations); + void setBankData(Map bankData); + void setFactionData(Map factionData); + void setMagicData(MagicData magicData); } diff --git a/src/main/java/noppes/npcs/client/gui/util/IScrollData.java b/src/main/java/noppes/npcs/client/gui/util/IScrollData.java index cacac8359..1df06aac5 100644 --- a/src/main/java/noppes/npcs/client/gui/util/IScrollData.java +++ b/src/main/java/noppes/npcs/client/gui/util/IScrollData.java @@ -6,6 +6,7 @@ import java.util.HashMap; import java.util.Vector; public interface IScrollData { - public void setData(Vector list, HashMap data, EnumScrollData type); - public void setSelected(String selected); + public void setData(Vector list, HashMap data, EnumScrollData type); + + public void setSelected(String selected); } diff --git a/src/main/java/noppes/npcs/client/gui/util/ISliderListener.java b/src/main/java/noppes/npcs/client/gui/util/ISliderListener.java index 1a08bcbb2..6481a6929 100644 --- a/src/main/java/noppes/npcs/client/gui/util/ISliderListener.java +++ b/src/main/java/noppes/npcs/client/gui/util/ISliderListener.java @@ -3,10 +3,10 @@ package noppes.npcs.client.gui.util; public interface ISliderListener { - void mouseDragged(GuiNpcSlider guiNpcSlider); - - void mousePressed(GuiNpcSlider guiNpcSlider); - - void mouseReleased(GuiNpcSlider guiNpcSlider); - + void mouseDragged(GuiNpcSlider guiNpcSlider); + + void mousePressed(GuiNpcSlider guiNpcSlider); + + void mouseReleased(GuiNpcSlider guiNpcSlider); + } diff --git a/src/main/java/noppes/npcs/client/gui/util/ISubGuiListener.java b/src/main/java/noppes/npcs/client/gui/util/ISubGuiListener.java index e4f0486cd..cb5c94eb1 100644 --- a/src/main/java/noppes/npcs/client/gui/util/ISubGuiListener.java +++ b/src/main/java/noppes/npcs/client/gui/util/ISubGuiListener.java @@ -1,5 +1,5 @@ package noppes.npcs.client.gui.util; public interface ISubGuiListener { - public void subGuiClosed(SubGuiInterface subgui); + public void subGuiClosed(SubGuiInterface subgui); } diff --git a/src/main/java/noppes/npcs/client/gui/util/ITextfieldListener.java b/src/main/java/noppes/npcs/client/gui/util/ITextfieldListener.java index 43763a6f0..55f988e7a 100644 --- a/src/main/java/noppes/npcs/client/gui/util/ITextfieldListener.java +++ b/src/main/java/noppes/npcs/client/gui/util/ITextfieldListener.java @@ -1,9 +1,8 @@ package noppes.npcs.client.gui.util; - public interface ITextfieldListener { - void unFocused(GuiNpcTextField textfield); + void unFocused(GuiNpcTextField textfield); } diff --git a/src/main/java/noppes/npcs/client/gui/util/ITopButtonListener.java b/src/main/java/noppes/npcs/client/gui/util/ITopButtonListener.java index c28e3f168..6ef5ce876 100644 --- a/src/main/java/noppes/npcs/client/gui/util/ITopButtonListener.java +++ b/src/main/java/noppes/npcs/client/gui/util/ITopButtonListener.java @@ -2,6 +2,6 @@ package noppes.npcs.client.gui.util; public interface ITopButtonListener { - void mouseClicked(int i, int j, int k); + void mouseClicked(int i, int j, int k); } diff --git a/src/main/java/noppes/npcs/client/gui/util/SubGuiInterface.java b/src/main/java/noppes/npcs/client/gui/util/SubGuiInterface.java index b826c3ebb..8b35c65dc 100644 --- a/src/main/java/noppes/npcs/client/gui/util/SubGuiInterface.java +++ b/src/main/java/noppes/npcs/client/gui/util/SubGuiInterface.java @@ -2,35 +2,36 @@ package noppes.npcs.client.gui.util; import net.minecraft.client.gui.GuiScreen; -public class SubGuiInterface extends GuiNPCInterface{ - public GuiScreen parent; - - @Override - public void save() { - - } - @Override - public void close() { - if(parent instanceof ISubGuiListener) - ((ISubGuiListener)parent).subGuiClosed(this); - - if(parent instanceof GuiNPCInterface) - ((GuiNPCInterface)parent).closeSubGui(this); - else if(parent instanceof GuiContainerNPCInterface) - ((GuiContainerNPCInterface)parent).closeSubGui(this); - else - super.close(); - - } - - public GuiScreen getParent(){ - if(parent instanceof SubGuiInterface) - return ((SubGuiInterface)parent).getParent(); - return parent; - } +public class SubGuiInterface extends GuiNPCInterface { + public GuiScreen parent; - @Override - public void drawScreen(int i, int j, float f){ - super.drawScreen(i, j, f); + @Override + public void save() { + + } + + @Override + public void close() { + if (parent instanceof ISubGuiListener) + ((ISubGuiListener) parent).subGuiClosed(this); + + if (parent instanceof GuiNPCInterface) + ((GuiNPCInterface) parent).closeSubGui(this); + else if (parent instanceof GuiContainerNPCInterface) + ((GuiContainerNPCInterface) parent).closeSubGui(this); + else + super.close(); + + } + + public GuiScreen getParent() { + if (parent instanceof SubGuiInterface) + return ((SubGuiInterface) parent).getParent(); + return parent; + } + + @Override + public void drawScreen(int i, int j, float f) { + super.drawScreen(i, j, f); } } diff --git a/src/main/java/noppes/npcs/client/gui/util/SubGuiNpcCooldownPicker.java b/src/main/java/noppes/npcs/client/gui/util/SubGuiNpcCooldownPicker.java index 35df31263..36d902f58 100644 --- a/src/main/java/noppes/npcs/client/gui/util/SubGuiNpcCooldownPicker.java +++ b/src/main/java/noppes/npcs/client/gui/util/SubGuiNpcCooldownPicker.java @@ -26,24 +26,24 @@ public class SubGuiNpcCooldownPicker extends SubGuiInterface implements ITextfie super.initGui(); int days = 0, hours = 0, minutes = 0, seconds = 0; - if(isMCCustom) { + if (isMCCustom) { long currentMillis = cooldownValue * 50; - days = (int)(currentMillis / 86400000L); + days = (int) (currentMillis / 86400000L); long remainder = currentMillis % 86400000L; - hours = (int)(remainder / 3600000L); + hours = (int) (remainder / 3600000L); remainder %= 3600000L; - minutes = (int)(remainder / 60000L); + minutes = (int) (remainder / 60000L); remainder %= 60000L; - seconds = (int)(remainder / 1000L); + seconds = (int) (remainder / 1000L); } else { // For RL custom cooldown, currentCooldown is stored in milliseconds. - days = (int)(cooldownValue / 86400000L); + days = (int) (cooldownValue / 86400000L); long remainder = cooldownValue % 86400000L; - hours = (int)(remainder / 3600000L); + hours = (int) (remainder / 3600000L); remainder %= 3600000L; - minutes = (int)(remainder / 60000L); + minutes = (int) (remainder / 60000L); remainder %= 60000L; - seconds = (int)(remainder / 1000L); + seconds = (int) (remainder / 1000L); } int y = guiTop + 20; @@ -82,19 +82,19 @@ public class SubGuiNpcCooldownPicker extends SubGuiInterface implements ITextfie @Override public void buttonEvent(GuiButton button) { - if(button.id == 0) { + if (button.id == 0) { close(); } } - public void close(){ + public void close() { int inputDays = parseInt(daysField.getText()); int inputHours = parseInt(hoursField.getText()); int inputMinutes = parseInt(minutesField.getText()); int inputSeconds = parseInt(secondsField.getText()); // Calculate total time in milliseconds. long totalMillis = inputDays * 86400000L + inputHours * 3600000L + inputMinutes * 60000L + inputSeconds * 1000L; - if(isMCCustom) { + if (isMCCustom) { // Convert real milliseconds to ticks. cooldownValue = totalMillis / 50; } else { @@ -111,7 +111,7 @@ public class SubGuiNpcCooldownPicker extends SubGuiInterface implements ITextfie private int parseInt(String text) { try { return Integer.parseInt(text); - } catch(Exception e) { + } catch (Exception e) { return 0; } } diff --git a/src/main/java/noppes/npcs/client/gui/util/TextContainer.java b/src/main/java/noppes/npcs/client/gui/util/TextContainer.java index 5eee41b99..dc66332cb 100644 --- a/src/main/java/noppes/npcs/client/gui/util/TextContainer.java +++ b/src/main/java/noppes/npcs/client/gui/util/TextContainer.java @@ -30,24 +30,24 @@ public class TextContainer { public int linesCount; - public TextContainer(String text){ + public TextContainer(String text) { this.text = text.replaceAll("\\r?\\n|\\r", "\n"); } - public void init(int width, int height){ + public void init(int width, int height) { lineHeight = ClientProxy.Font.height(); - if(lineHeight == 0) + if (lineHeight == 0) lineHeight = 12; String[] split = text.split("\n"); int totalChars = 0; - for(String l : split){ + for (String l : split) { StringBuilder line = new StringBuilder(); Matcher m = regexWord.matcher(l); int i = 0; - while(m.find()){ + while (m.find()) { String word = l.substring(i, m.start()); - if(ClientProxy.Font.width(line + word) > width - 10){ + if (ClientProxy.Font.width(line + word) > width - 10) { lines.add(new LineData(line.toString(), totalChars, totalChars + line.length())); totalChars += line.length(); line = new StringBuilder(); @@ -67,7 +67,7 @@ public class TextContainer { public void formatCodeText() { MarkUp markup = null; int start = 0; - while((markup = getNextMatching(start)) != null) { + while ((markup = getNextMatching(start)) != null) { makeup.add(markup); start = markup.end; } @@ -77,39 +77,39 @@ public class TextContainer { MarkUp markup = null; String s = text.substring(start); Matcher matcher = regexNumber.matcher(s); - if(matcher.find()) { + if (matcher.find()) { markup = new MarkUp(matcher.start(), matcher.end(), '6', 0); } matcher = regexFunction.matcher(s); - if(matcher.find()){ + if (matcher.find()) { MarkUp markup2 = new MarkUp(matcher.start(), matcher.end(), '2', 0); - if(compareMarkUps(markup, markup2)) { + if (compareMarkUps(markup, markup2)) { markup = markup2; } } matcher = regexType.matcher(s); - if(matcher.find()){ + if (matcher.find()) { MarkUp markup2 = new MarkUp(matcher.start(), matcher.end(), '3', 0); - if(compareMarkUps(markup, markup2)) { + if (compareMarkUps(markup, markup2)) { markup = markup2; } } matcher = regexString.matcher(s); - if(matcher.find()){ + if (matcher.find()) { MarkUp markup2 = new MarkUp(matcher.start(), matcher.end(), '4', 7); - if(compareMarkUps(markup, markup2)) { + if (compareMarkUps(markup, markup2)) { markup = markup2; } } matcher = regexComment.matcher(s); - if(matcher.find()){ + if (matcher.find()) { MarkUp markup2 = new MarkUp(matcher.start(), matcher.end(), '8', 7); - if(compareMarkUps(markup, markup2)) { + if (compareMarkUps(markup, markup2)) { markup = markup2; } } - if(markup != null) { + if (markup != null) { markup.start += start; markup.end += start; } @@ -117,22 +117,22 @@ public class TextContainer { } public boolean compareMarkUps(MarkUp mu1, MarkUp mu2) { - if(mu1 == null) + if (mu1 == null) return true; return mu1.start > mu2.start; } - public void addMakeUp(int start, int end, char c, int level){ - if(!removeConflictingMarkUp(start, end, level)) + public void addMakeUp(int start, int end, char c, int level) { + if (!removeConflictingMarkUp(start, end, level)) return; makeup.add(new MarkUp(start, end, c, level)); } - private boolean removeConflictingMarkUp(int start, int end, int level){ + private boolean removeConflictingMarkUp(int start, int end, int level) { List conflicting = new ArrayList(); - for(MarkUp m : makeup){ - if(start >= m.start && start <= m.end || end >= m.start && end <= m.end || start < m.start && end > m.start){ - if(level < m.level || level == m.level && m.start <= start) + for (MarkUp m : makeup) { + if (start >= m.start && start <= m.end || end >= m.start && end <= m.end || start < m.start && end > m.start) { + if (level < m.level || level == m.level && m.start <= start) return false; conflicting.add(m); } @@ -145,7 +145,7 @@ public class TextContainer { public String text; public int start, end; - public LineData(String text, int start, int end){ + public LineData(String text, int start, int end) { this.text = text; this.start = start; this.end = end; @@ -155,19 +155,19 @@ public class TextContainer { ClientProxy.Font.drawString(this.getFormattedString(), x, y, color); } - public String getFormattedString(){ + public String getFormattedString() { StringBuilder builder = new StringBuilder(text); int found = 0; - for(MarkUp entry : makeup){ - if(entry.start >= start && entry.start < end){ + for (MarkUp entry : makeup) { + if (entry.start >= start && entry.start < end) { builder.insert(entry.start - start + found * 2, Character.toString(colorChar) + Character.toString(entry.c)); found++; } - if(entry.start < start && entry.end > start){ + if (entry.start < start && entry.end > start) { builder.insert(0, Character.toString(colorChar) + Character.toString(entry.c)); found++; } - if(entry.end >= start && entry.end < end){ + if (entry.end >= start && entry.end < end) { builder.insert(entry.end - start + found * 2, Character.toString(colorChar) + Character.toString('r')); found++; } @@ -180,7 +180,7 @@ public class TextContainer { public int start, end, level; public char c; - public MarkUp(int start, int end, char c, int level){ + public MarkUp(int start, int end, char c, int level) { this.start = start; this.end = end; this.c = c; diff --git a/src/main/java/noppes/npcs/client/model/ModelMPM.java b/src/main/java/noppes/npcs/client/model/ModelMPM.java index a74784678..2b29220e6 100644 --- a/src/main/java/noppes/npcs/client/model/ModelMPM.java +++ b/src/main/java/noppes/npcs/client/model/ModelMPM.java @@ -30,983 +30,963 @@ import java.util.Random; import static noppes.npcs.client.ClientProxy.bindTexture; -public class ModelMPM extends ModelNPCMale{ - private ModelPartInterface wings; - private ModelPartInterface mohawk; - private ModelPartInterface hair; - private ModelPartInterface beard; - private ModelPartInterface breasts; - private ModelPartInterface snout; - private ModelPartInterface ears; - private ModelPartInterface fin; - private ModelPartInterface skirt; - private ModelPartInterface horns; +public class ModelMPM extends ModelNPCMale { + private ModelPartInterface wings; + private ModelPartInterface mohawk; + private ModelPartInterface hair; + private ModelPartInterface beard; + private ModelPartInterface breasts; + private ModelPartInterface snout; + private ModelPartInterface ears; + private ModelPartInterface fin; + private ModelPartInterface skirt; + private ModelPartInterface horns; - private ModelPartInterface clawsR; - private ModelPartInterface clawsL; + private ModelPartInterface clawsR; + private ModelPartInterface clawsL; - // New - public ModelRenderer bipedBodywear; - public ModelRenderer bipedRightArmWear; - public ModelRenderer bipedLeftArmWear; - public ModelRenderer bipedRightLegWear; - public ModelRenderer bipedLeftLegWear; + // New + public ModelRenderer bipedBodywear; + public ModelRenderer bipedRightArmWear; + public ModelRenderer bipedLeftArmWear; + public ModelRenderer bipedRightLegWear; + public ModelRenderer bipedLeftLegWear; - private ModelScaleRenderer headwear; - private ModelScaleRenderer bodywear; - private final ModelScaleRenderer solidLeftArmWear; - private final ModelScaleRenderer solidRightArmWear; - private final ModelScaleRenderer solidLeftLegWear; - private final ModelScaleRenderer solidRightLegWear; + private ModelScaleRenderer headwear; + private ModelScaleRenderer bodywear; + private final ModelScaleRenderer solidLeftArmWear; + private final ModelScaleRenderer solidRightArmWear; + private final ModelScaleRenderer solidLeftLegWear; + private final ModelScaleRenderer solidRightLegWear; public ModelLegs legs; public ModelTail tail; - public ModelBase entityModel; - public EntityLivingBase entity; + public ModelBase entityModel; + public EntityLivingBase entity; - public boolean currentlyPlayerTexture; + public boolean currentlyPlayerTexture; - public boolean isArmor; - public boolean isAlexArmor; - public float alpha = 1; + public boolean isArmor; + public boolean isAlexArmor; + public float alpha = 1; - // Steve 64x64 and Alex 64x64 - public ModelMPM(float par1, boolean alex) { + // Steve 64x64 and Alex 64x64 + public ModelMPM(float par1, boolean alex) { - super(par1, alex); - isArmor = par1 > 0; - float par2 = 0; + super(par1, alex); + isArmor = par1 > 0; + float par2 = 0; - this.bipedCloak = new ModelRenderer(this, 0, 0); - this.bipedCloak.setTextureSize(64,32); - this.bipedCloak.addBox(-5.0F, 0.0F, -1.0F, 10, 16, 1, par1); + this.bipedCloak = new ModelRenderer(this, 0, 0); + this.bipedCloak.setTextureSize(64, 32); + this.bipedCloak.addBox(-5.0F, 0.0F, -1.0F, 10, 16, 1, par1); - this.bipedEars = new ModelRenderer(this, 24, 0); - this.bipedEars.addBox(-3.0F, -6.0F, -1.0F, 6, 6, 1, par1); + this.bipedEars = new ModelRenderer(this, 24, 0); + this.bipedEars.addBox(-3.0F, -6.0F, -1.0F, 6, 6, 1, par1); - this.bipedHead = (new ModelScaleRenderer(this, 0, 0)); - this.bipedHead.addBox(-4.0F, -8.0F, -4.0F, 8, 8, 8, par1); - this.bipedHead.setRotationPoint(0.0F, 0.0F + par2, 0.0F); + this.bipedHead = (new ModelScaleRenderer(this, 0, 0)); + this.bipedHead.addBox(-4.0F, -8.0F, -4.0F, 8, 8, 8, par1); + this.bipedHead.setRotationPoint(0.0F, 0.0F + par2, 0.0F); - this.bipedHeadwear = (new ModelScaleRenderer(this, 32, 0)); - this.bipedHeadwear.addBox(-4.0F, -8.0F, -4.0F, 8, 8, 8, par1 + 0.5F); - this.bipedHeadwear.setRotationPoint(0.0F, 0.0F + par2, 0.0F); + this.bipedHeadwear = (new ModelScaleRenderer(this, 32, 0)); + this.bipedHeadwear.addBox(-4.0F, -8.0F, -4.0F, 8, 8, 8, par1 + 0.5F); + this.bipedHeadwear.setRotationPoint(0.0F, 0.0F + par2, 0.0F); - this.bipedBody = (new ModelScaleRenderer(this, 16, 16)); - this.bipedBody.addBox(-4.0F, 0.0F, -2.0F, 8, 12, 4, par1); - this.bipedBody.setRotationPoint(0.0F, 0.0F + par2, 0.0F); + this.bipedBody = (new ModelScaleRenderer(this, 16, 16)); + this.bipedBody.addBox(-4.0F, 0.0F, -2.0F, 8, 12, 4, par1); + this.bipedBody.setRotationPoint(0.0F, 0.0F + par2, 0.0F); - // New Extension - this.bipedBodywear = (new ModelScaleRenderer(this, 16, 32)); - this.bipedBodywear.addBox(-4.0F, 0.0F, -2.0F, 8, 12, 4, par1 + 0.5F); - this.bipedBody.addChild(this.bipedBodywear); + // New Extension + this.bipedBodywear = (new ModelScaleRenderer(this, 16, 32)); + this.bipedBodywear.addBox(-4.0F, 0.0F, -2.0F, 8, 12, 4, par1 + 0.5F); + this.bipedBody.addChild(this.bipedBodywear); - bodywear = new ModelBodywear(this, 64, 64); - this.bipedBody.addChild(bodywear); + bodywear = new ModelBodywear(this, 64, 64); + this.bipedBody.addChild(bodywear); - // Steve 64x64 Model or Alex 64x64 Model - if (alex){ - // Alex Version - this.bipedRightArm = (new ModelScaleRenderer(this, 40, 16)); - this.bipedRightArm.addBox(-2.0F, -2.0F, -2.0F, 3, 12, 4, par1); - // this.bipedRightArm.setRotationPoint(-5.0F, 2.5F + par2, 0.0F); + // Steve 64x64 Model or Alex 64x64 Model + if (alex) { + // Alex Version + this.bipedRightArm = (new ModelScaleRenderer(this, 40, 16)); + this.bipedRightArm.addBox(-2.0F, -2.0F, -2.0F, 3, 12, 4, par1); + // this.bipedRightArm.setRotationPoint(-5.0F, 2.5F + par2, 0.0F); - this.bipedLeftArm = new ModelScaleRenderer(this, 32, 48); - this.bipedLeftArm.addBox(-1.0F, -2.0F, -2.0F, 3, 12, 4, par1); - this.bipedLeftArm.setRotationPoint(5.0F, 2.5F + par2, 0.0F); + this.bipedLeftArm = new ModelScaleRenderer(this, 32, 48); + this.bipedLeftArm.addBox(-1.0F, -2.0F, -2.0F, 3, 12, 4, par1); + this.bipedLeftArm.setRotationPoint(5.0F, 2.5F + par2, 0.0F); - this.bipedRightArmWear = (new ModelScaleRenderer(this, 40, 32)); - this.bipedRightArmWear.addBox(-2.0F, -2.0F, -2.0F, 3, 12, 4, par1 + 0.25F); - this.bipedRightArm.addChild(this.bipedRightArmWear); - this.solidRightArmWear = new ModelLimbWear(this,"arm","right","Alex"); - this.bipedRightArm.addChild(this.solidRightArmWear); + this.bipedRightArmWear = (new ModelScaleRenderer(this, 40, 32)); + this.bipedRightArmWear.addBox(-2.0F, -2.0F, -2.0F, 3, 12, 4, par1 + 0.25F); + this.bipedRightArm.addChild(this.bipedRightArmWear); + this.solidRightArmWear = new ModelLimbWear(this, "arm", "right", "Alex"); + this.bipedRightArm.addChild(this.solidRightArmWear); - this.bipedLeftArmWear = new ModelScaleRenderer(this, 48, 48); - this.bipedLeftArmWear.addBox(-1.0F, -2.0F, -2.0F, 3, 12, 4, par1 + 0.25F); - this.bipedLeftArm.addChild(this.bipedLeftArmWear); - this.solidLeftArmWear = new ModelLimbWear(this,"arm","left","Alex"); - this.bipedLeftArm.addChild(this.solidLeftArmWear); - } - else{ - // Steve Version - this.bipedRightArm = (new ModelScaleRenderer(this, 40, 16)); - this.bipedRightArm.addBox(-3.0F, -2.0F, -2.0F, 4, 12, 4, par1); - this.bipedRightArm.setRotationPoint(-5.0F, 2.0F + par2, 0.0F); + this.bipedLeftArmWear = new ModelScaleRenderer(this, 48, 48); + this.bipedLeftArmWear.addBox(-1.0F, -2.0F, -2.0F, 3, 12, 4, par1 + 0.25F); + this.bipedLeftArm.addChild(this.bipedLeftArmWear); + this.solidLeftArmWear = new ModelLimbWear(this, "arm", "left", "Alex"); + this.bipedLeftArm.addChild(this.solidLeftArmWear); + } else { + // Steve Version + this.bipedRightArm = (new ModelScaleRenderer(this, 40, 16)); + this.bipedRightArm.addBox(-3.0F, -2.0F, -2.0F, 4, 12, 4, par1); + this.bipedRightArm.setRotationPoint(-5.0F, 2.0F + par2, 0.0F); - this.bipedLeftArm = new ModelScaleRenderer(this, 32, 48); - this.bipedLeftArm.addBox(-1.0F, -2.0F, -2.0F, 4, 12, 4, par1); - this.bipedLeftArm.setRotationPoint(5.0F, 2.0F + par2, 0.0F); + this.bipedLeftArm = new ModelScaleRenderer(this, 32, 48); + this.bipedLeftArm.addBox(-1.0F, -2.0F, -2.0F, 4, 12, 4, par1); + this.bipedLeftArm.setRotationPoint(5.0F, 2.0F + par2, 0.0F); - this.bipedRightArmWear = (new ModelScaleRenderer(this, 40, 32)); - this.bipedRightArmWear.addBox(-3.0F, -2.0F, -2.0F, 4, 12, 4, par1 + 0.25F); - this.bipedRightArm.addChild(this.bipedRightArmWear); - this.solidRightArmWear = new ModelLimbWear(this,"arm","right","Steve"); - this.bipedRightArm.addChild(this.solidRightArmWear); + this.bipedRightArmWear = (new ModelScaleRenderer(this, 40, 32)); + this.bipedRightArmWear.addBox(-3.0F, -2.0F, -2.0F, 4, 12, 4, par1 + 0.25F); + this.bipedRightArm.addChild(this.bipedRightArmWear); + this.solidRightArmWear = new ModelLimbWear(this, "arm", "right", "Steve"); + this.bipedRightArm.addChild(this.solidRightArmWear); - this.bipedLeftArmWear = new ModelScaleRenderer(this, 48, 48); - this.bipedLeftArmWear.addBox(-1.0F, -2.0F, -2.0F, 4, 12, 4, par1 + 0.25F); - this.bipedLeftArm.addChild(this.bipedLeftArmWear); - this.solidLeftArmWear = new ModelLimbWear(this,"arm","left","Steve"); - this.bipedLeftArm.addChild(this.solidLeftArmWear); - } + this.bipedLeftArmWear = new ModelScaleRenderer(this, 48, 48); + this.bipedLeftArmWear.addBox(-1.0F, -2.0F, -2.0F, 4, 12, 4, par1 + 0.25F); + this.bipedLeftArm.addChild(this.bipedLeftArmWear); + this.solidLeftArmWear = new ModelLimbWear(this, "arm", "left", "Steve"); + this.bipedLeftArm.addChild(this.solidLeftArmWear); + } - this.bipedRightLeg = (new ModelScaleRenderer(this, 0, 16)); - this.bipedRightLeg.addBox(-2.08F, 0.0F, -2.0F, 4, 12, 4, par1); - this.bipedRightLeg.setRotationPoint(-1.9F, 12.0F + par2, 0.0F); + this.bipedRightLeg = (new ModelScaleRenderer(this, 0, 16)); + this.bipedRightLeg.addBox(-2.08F, 0.0F, -2.0F, 4, 12, 4, par1); + this.bipedRightLeg.setRotationPoint(-1.9F, 12.0F + par2, 0.0F); - this.bipedLeftLeg = new ModelScaleRenderer(this, 16, 48); - this.bipedLeftLeg.addBox(-1.92F, 0.0F, -2.0F, 4, 12, 4, par1); - this.bipedLeftLeg.setRotationPoint(1.9F, 12.0F + par2, 0.0F); + this.bipedLeftLeg = new ModelScaleRenderer(this, 16, 48); + this.bipedLeftLeg.addBox(-1.92F, 0.0F, -2.0F, 4, 12, 4, par1); + this.bipedLeftLeg.setRotationPoint(1.9F, 12.0F + par2, 0.0F); - this.bipedRightLegWear = (new ModelScaleRenderer(this, 0, 32)); - this.bipedRightLegWear.addBox(-2.08F, 0.0F, -2.0F, 4, 12, 4, par1 + 0.25F); - this.bipedRightLeg.addChild(this.bipedRightLegWear); - this.solidRightLegWear = new ModelLimbWear(this,"leg","right","Steve"); - this.bipedRightLeg.addChild(this.solidRightLegWear); + this.bipedRightLegWear = (new ModelScaleRenderer(this, 0, 32)); + this.bipedRightLegWear.addBox(-2.08F, 0.0F, -2.0F, 4, 12, 4, par1 + 0.25F); + this.bipedRightLeg.addChild(this.bipedRightLegWear); + this.solidRightLegWear = new ModelLimbWear(this, "leg", "right", "Steve"); + this.bipedRightLeg.addChild(this.solidRightLegWear); - this.bipedLeftLegWear = new ModelScaleRenderer(this, 0, 48); - this.bipedLeftLegWear.addBox(-1.92F, 0.0F, -2.0F, 4, 12, 4, par1 + 0.25F); - this.bipedLeftLeg.addChild(this.bipedLeftLegWear); - this.solidLeftLegWear = new ModelLimbWear(this,"leg","left","Steve"); - this.bipedLeftLeg.addChild(this.solidLeftLegWear); + this.bipedLeftLegWear = new ModelScaleRenderer(this, 0, 48); + this.bipedLeftLegWear.addBox(-1.92F, 0.0F, -2.0F, 4, 12, 4, par1 + 0.25F); + this.bipedLeftLeg.addChild(this.bipedLeftLegWear); + this.solidLeftLegWear = new ModelLimbWear(this, "leg", "left", "Steve"); + this.bipedLeftLeg.addChild(this.solidLeftLegWear); - headwear = new ModelHeadwear(this); - legs = new ModelLegs(this, (ModelScaleRenderer)bipedRightLeg, (ModelScaleRenderer)bipedLeftLeg, 64, 64); + headwear = new ModelHeadwear(this); + legs = new ModelLegs(this, (ModelScaleRenderer) bipedRightLeg, (ModelScaleRenderer) bipedLeftLeg, 64, 64); - this.bipedBody.addChild(breasts = new ModelBreasts(this, 64, 64)); - if(!isArmor){ - this.bipedHead.addChild(ears = new ModelEars(this)); - this.bipedHead.addChild(mohawk = new ModelMohawk(this)); - this.bipedHead.addChild(hair = new ModelHair(this)); - this.bipedHead.addChild(beard = new ModelBeard(this)); + this.bipedBody.addChild(breasts = new ModelBreasts(this, 64, 64)); + if (!isArmor) { + this.bipedHead.addChild(ears = new ModelEars(this)); + this.bipedHead.addChild(mohawk = new ModelMohawk(this)); + this.bipedHead.addChild(hair = new ModelHair(this)); + this.bipedHead.addChild(beard = new ModelBeard(this)); - // Completed - this.bipedHead.addChild(snout = new ModelSnout(this)); - this.bipedHead.addChild(horns = new ModelHorns(this)); + // Completed + this.bipedHead.addChild(snout = new ModelSnout(this)); + this.bipedHead.addChild(horns = new ModelHorns(this)); - // Completed - tail = new ModelTail(this); + // Completed + tail = new ModelTail(this); - this.bipedBody.addChild(wings = new ModelWings(this)); - this.bipedBody.addChild(fin = new ModelFin(this)); + this.bipedBody.addChild(wings = new ModelWings(this)); + this.bipedBody.addChild(fin = new ModelFin(this)); - // Fix This - this.bipedBody.addChild(skirt = new ModelSkirt(this)); - this.bipedLeftArm.addChild(clawsL = new ModelClaws(this, false)); - this.bipedRightArm.addChild(clawsR = new ModelClaws(this, true)); - } - } + // Fix This + this.bipedBody.addChild(skirt = new ModelSkirt(this)); + this.bipedLeftArm.addChild(clawsL = new ModelClaws(this, false)); + this.bipedRightArm.addChild(clawsR = new ModelClaws(this, true)); + } + } - // Steve 64x32 - public ModelMPM(float par1, int alexArms) { + // Steve 64x32 + public ModelMPM(float par1, int alexArms) { - super(par1); - isArmor = par1 > 0; - if (isArmor && alexArms == 1) { - isAlexArmor = true; - } + super(par1); + isArmor = par1 > 0; + if (isArmor && alexArms == 1) { + isAlexArmor = true; + } - float par2 = 0; + float par2 = 0; - this.bipedCloak = new ModelRenderer(this, 0, 0); - this.bipedCloak.setTextureSize(64,32); - this.bipedCloak.addBox(-5.0F, 0.0F, -1.0F, 10, 16, 1, par1); + this.bipedCloak = new ModelRenderer(this, 0, 0); + this.bipedCloak.setTextureSize(64, 32); + this.bipedCloak.addBox(-5.0F, 0.0F, -1.0F, 10, 16, 1, par1); - this.bipedEars = new ModelRenderer(this, 24, 0); - this.bipedEars.addBox(-3.0F, -6.0F, -1.0F, 6, 6, 1, par1); + this.bipedEars = new ModelRenderer(this, 24, 0); + this.bipedEars.addBox(-3.0F, -6.0F, -1.0F, 6, 6, 1, par1); - this.bipedHead = (new ModelScaleRenderer(this, 0, 0)); - this.bipedHead.addBox(-4.0F, -8.0F, -4.0F, 8, 8, 8, par1); - this.bipedHead.setRotationPoint(0.0F, 0.0F + par2, 0.0F); + this.bipedHead = (new ModelScaleRenderer(this, 0, 0)); + this.bipedHead.addBox(-4.0F, -8.0F, -4.0F, 8, 8, 8, par1); + this.bipedHead.setRotationPoint(0.0F, 0.0F + par2, 0.0F); - this.bipedHeadwear = (new ModelScaleRenderer(this, 32, 0)); - this.bipedHeadwear.addBox(-4.0F, -8.0F, -4.0F, 8, 8, 8, par1 + 0.5F); - this.bipedHeadwear.setRotationPoint(0.0F, 0.0F + par2, 0.0F); + this.bipedHeadwear = (new ModelScaleRenderer(this, 32, 0)); + this.bipedHeadwear.addBox(-4.0F, -8.0F, -4.0F, 8, 8, 8, par1 + 0.5F); + this.bipedHeadwear.setRotationPoint(0.0F, 0.0F + par2, 0.0F); - this.bipedBody = (new ModelScaleRenderer(this, 16, 16)); - this.bipedBody.addBox(-4.0F, 0.0F, -2.0F, 8, 12, 4, par1); - this.bipedBody.setRotationPoint(0.0F, 0.0F + par2, 0.0F); + this.bipedBody = (new ModelScaleRenderer(this, 16, 16)); + this.bipedBody.addBox(-4.0F, 0.0F, -2.0F, 8, 12, 4, par1); + this.bipedBody.setRotationPoint(0.0F, 0.0F + par2, 0.0F); - if (alexArms == 0) { - this.bipedRightArm = new ModelScaleRenderer(this, 40, 16); - this.bipedRightArm.addBox(-3.0F, -2.0F, -2.0F, 4, 12, 4, par1); - this.bipedRightArm.setRotationPoint(-5.0F, 2.0F + par2, 0.0F); + if (alexArms == 0) { + this.bipedRightArm = new ModelScaleRenderer(this, 40, 16); + this.bipedRightArm.addBox(-3.0F, -2.0F, -2.0F, 4, 12, 4, par1); + this.bipedRightArm.setRotationPoint(-5.0F, 2.0F + par2, 0.0F); - this.bipedLeftArm = new ModelScaleRenderer(this, 40, 16); - this.bipedLeftArm.mirror = true; - this.bipedLeftArm.addBox(-1.0F, -2.0F, -2.0F, 4, 12, 4, par1); - this.bipedLeftArm.setRotationPoint(5.0F, 2.0F + par2, 0.0F); - } else { - this.bipedRightArm = (new ModelScaleRenderer(this, 40, 16)); - this.bipedLeftArm = new ModelScaleRenderer(this, 40, 16); - this.bipedLeftArm.mirror = true; + this.bipedLeftArm = new ModelScaleRenderer(this, 40, 16); + this.bipedLeftArm.mirror = true; + this.bipedLeftArm.addBox(-1.0F, -2.0F, -2.0F, 4, 12, 4, par1); + this.bipedLeftArm.setRotationPoint(5.0F, 2.0F + par2, 0.0F); + } else { + this.bipedRightArm = (new ModelScaleRenderer(this, 40, 16)); + this.bipedLeftArm = new ModelScaleRenderer(this, 40, 16); + this.bipedLeftArm.mirror = true; - if (isArmor) { - this.bipedLeftArm.setRotationPoint(5.0F, 2.5F + par2, 0.0F); - this.bipedRightArm.addBox(-4.5F, -2.0F, -2.0F, 4, 12, 4, par1); - this.bipedLeftArm.addBox(0.25F, -2.0F, -2.0F, 4, 12, 4, par1); - } else { - this.bipedLeftArm.setRotationPoint(5.0F, 2.5F + par2, 0.0F); - this.bipedRightArm.addBox(-2.0F, -2.0F, -2.0F, 3, 12, 4, par1); - this.bipedLeftArm.addBox(-1.0F, -2.0F, -2.0F, 3, 12, 4, par1); - } - } + if (isArmor) { + this.bipedLeftArm.setRotationPoint(5.0F, 2.5F + par2, 0.0F); + this.bipedRightArm.addBox(-4.5F, -2.0F, -2.0F, 4, 12, 4, par1); + this.bipedLeftArm.addBox(0.25F, -2.0F, -2.0F, 4, 12, 4, par1); + } else { + this.bipedLeftArm.setRotationPoint(5.0F, 2.5F + par2, 0.0F); + this.bipedRightArm.addBox(-2.0F, -2.0F, -2.0F, 3, 12, 4, par1); + this.bipedLeftArm.addBox(-1.0F, -2.0F, -2.0F, 3, 12, 4, par1); + } + } - this.bipedRightLeg = new ModelScaleRenderer(this, 0, 16); - this.bipedRightLeg.addBox(-2.0F, 0.0F, -2.0F, 4, 12, 4, par1); - this.bipedRightLeg.setRotationPoint(-1.9F, 12.0F + par2, 0.0F); + this.bipedRightLeg = new ModelScaleRenderer(this, 0, 16); + this.bipedRightLeg.addBox(-2.0F, 0.0F, -2.0F, 4, 12, 4, par1); + this.bipedRightLeg.setRotationPoint(-1.9F, 12.0F + par2, 0.0F); - this.bipedLeftLeg = new ModelScaleRenderer(this, 0, 16); - this.bipedLeftLeg.mirror = true; - this.bipedLeftLeg.addBox(-2.0F, 0.0F, -2.0F, 4, 12, 4, par1); - this.bipedLeftLeg.setRotationPoint(1.9F, 12.0F + par2, 0.0F); + this.bipedLeftLeg = new ModelScaleRenderer(this, 0, 16); + this.bipedLeftLeg.mirror = true; + this.bipedLeftLeg.addBox(-2.0F, 0.0F, -2.0F, 4, 12, 4, par1); + this.bipedLeftLeg.setRotationPoint(1.9F, 12.0F + par2, 0.0F); - // Body - this.bipedBodywear = (new ModelScaleRenderer(this, 0, 0)); - this.bipedBody.addChild(this.bipedBodywear); + // Body + this.bipedBodywear = (new ModelScaleRenderer(this, 0, 0)); + this.bipedBody.addChild(this.bipedBodywear); - bodywear = new ModelBodywear(this, 0, 0); - this.bipedBody.addChild(bodywear); + bodywear = new ModelBodywear(this, 0, 0); + this.bipedBody.addChild(bodywear); - // Arms - this.bipedRightArmWear = (new ModelScaleRenderer(this, 0, 0)); - this.bipedRightArm.addChild(this.bipedRightArmWear); - this.solidRightArmWear = (new ModelScaleRenderer(this, 0, 0)); - this.bipedRightArm.addChild(this.solidRightArmWear); - this.bipedLeftArmWear = new ModelScaleRenderer(this, 0, 0); - this.bipedLeftArm.addChild(this.bipedLeftArmWear); - this.solidLeftArmWear = (new ModelScaleRenderer(this, 0, 0)); - this.bipedLeftArm.addChild(this.solidLeftArmWear); + // Arms + this.bipedRightArmWear = (new ModelScaleRenderer(this, 0, 0)); + this.bipedRightArm.addChild(this.bipedRightArmWear); + this.solidRightArmWear = (new ModelScaleRenderer(this, 0, 0)); + this.bipedRightArm.addChild(this.solidRightArmWear); + this.bipedLeftArmWear = new ModelScaleRenderer(this, 0, 0); + this.bipedLeftArm.addChild(this.bipedLeftArmWear); + this.solidLeftArmWear = (new ModelScaleRenderer(this, 0, 0)); + this.bipedLeftArm.addChild(this.solidLeftArmWear); - // Legs - this.bipedRightLegWear = (new ModelScaleRenderer(this, 0, 0)); - this.bipedRightLeg.addChild(this.bipedRightLegWear); - this.solidRightLegWear = new ModelScaleRenderer(this, 0, 0); - this.bipedRightLeg.addChild(this.solidRightLegWear); - this.bipedLeftLegWear = new ModelScaleRenderer(this, 0, 0); - this.bipedLeftLeg.addChild(this.bipedLeftLegWear); - this.solidLeftLegWear = new ModelScaleRenderer(this, 0, 0); - this.bipedLeftLeg.addChild(this.solidLeftLegWear); + // Legs + this.bipedRightLegWear = (new ModelScaleRenderer(this, 0, 0)); + this.bipedRightLeg.addChild(this.bipedRightLegWear); + this.solidRightLegWear = new ModelScaleRenderer(this, 0, 0); + this.bipedRightLeg.addChild(this.solidRightLegWear); + this.bipedLeftLegWear = new ModelScaleRenderer(this, 0, 0); + this.bipedLeftLeg.addChild(this.bipedLeftLegWear); + this.solidLeftLegWear = new ModelScaleRenderer(this, 0, 0); + this.bipedLeftLeg.addChild(this.solidLeftLegWear); - headwear = new ModelHeadwear(this, true); - legs = new ModelLegs(this, (ModelScaleRenderer)bipedRightLeg, (ModelScaleRenderer)bipedLeftLeg, 64, 32); + headwear = new ModelHeadwear(this, true); + legs = new ModelLegs(this, (ModelScaleRenderer) bipedRightLeg, (ModelScaleRenderer) bipedLeftLeg, 64, 32); - this.bipedBody.addChild(breasts = new ModelBreasts(this, 64, 32)); - if(!isArmor){ - this.bipedHead.addChild(ears = new ModelEars(this)); - this.bipedHead.addChild(mohawk = new ModelMohawk(this)); - this.bipedHead.addChild(hair = new ModelHair(this)); - this.bipedHead.addChild(beard = new ModelBeard(this)); + this.bipedBody.addChild(breasts = new ModelBreasts(this, 64, 32)); + if (!isArmor) { + this.bipedHead.addChild(ears = new ModelEars(this)); + this.bipedHead.addChild(mohawk = new ModelMohawk(this)); + this.bipedHead.addChild(hair = new ModelHair(this)); + this.bipedHead.addChild(beard = new ModelBeard(this)); - // Completed - this.bipedHead.addChild(snout = new ModelSnout(this)); - this.bipedHead.addChild(horns = new ModelHorns(this)); + // Completed + this.bipedHead.addChild(snout = new ModelSnout(this)); + this.bipedHead.addChild(horns = new ModelHorns(this)); - // Completed - tail = new ModelTail(this); + // Completed + tail = new ModelTail(this); - this.bipedBody.addChild(wings = new ModelWings(this)); - this.bipedBody.addChild(fin = new ModelFin(this)); + this.bipedBody.addChild(wings = new ModelWings(this)); + this.bipedBody.addChild(fin = new ModelFin(this)); - // Fix This - this.bipedBody.addChild(skirt = new ModelSkirt(this)); - this.bipedLeftArm.addChild(clawsL = new ModelClaws(this, false)); - this.bipedRightArm.addChild(clawsR = new ModelClaws(this, true)); - } - } + // Fix This + this.bipedBody.addChild(skirt = new ModelSkirt(this)); + this.bipedLeftArm.addChild(clawsL = new ModelClaws(this, false)); + this.bipedRightArm.addChild(clawsR = new ModelClaws(this, true)); + } + } - private void setPlayerData(EntityCustomNpc entity){ - if(!isArmor){ - mohawk.setData(entity.modelData, entity); - beard.setData(entity.modelData, entity); - hair.setData(entity.modelData, entity); - snout.setData(entity.modelData, entity); - tail.setData(entity); - fin.setData(entity.modelData, entity); - wings.setData(entity.modelData, entity); - ears.setData(entity.modelData, entity); - clawsL.setData(entity.modelData, entity); - clawsR.setData(entity.modelData, entity); - skirt.setData(entity.modelData, entity); - horns.setData(entity.modelData, entity); - } - breasts.setData(entity.modelData, entity); - legs.setData(entity); - } + private void setPlayerData(EntityCustomNpc entity) { + if (!isArmor) { + mohawk.setData(entity.modelData, entity); + beard.setData(entity.modelData, entity); + hair.setData(entity.modelData, entity); + snout.setData(entity.modelData, entity); + tail.setData(entity); + fin.setData(entity.modelData, entity); + wings.setData(entity.modelData, entity); + ears.setData(entity.modelData, entity); + clawsL.setData(entity.modelData, entity); + clawsR.setData(entity.modelData, entity); + skirt.setData(entity.modelData, entity); + horns.setData(entity.modelData, entity); + } + breasts.setData(entity.modelData, entity); + legs.setData(entity); + } - @Override - public void render(Entity par1Entity, float par2, float par3, float par4, float par5, float par6, float par7){ - EntityCustomNpc npc = (EntityCustomNpc) par1Entity; - EntityPlayer player = Minecraft.getMinecraft().thePlayer; - if(npc.scriptInvisibleToPlayer(Minecraft.getMinecraft().thePlayer) && (player.getHeldItem() == null || player.getHeldItem().getItem() != CustomItems.wand)) - return; + @Override + public void render(Entity par1Entity, float par2, float par3, float par4, float par5, float par6, float par7) { + EntityCustomNpc npc = (EntityCustomNpc) par1Entity; + EntityPlayer player = Minecraft.getMinecraft().thePlayer; + if (npc.scriptInvisibleToPlayer(Minecraft.getMinecraft().thePlayer) && (player.getHeldItem() == null || player.getHeldItem().getItem() != CustomItems.wand)) + return; - if(entityModel != null){ - GL11.glPushMatrix(); - AnimationData animationData = npc.display.animationData; - if (animationData.isActive()) { - Animation animation = animationData.animation; - Frame frame = animation.frames.get(animation.currentFrame); - if (frame.frameParts.containsKey(EnumAnimationPart.FULL_MODEL)) { - FramePart part = frame.frameParts.get(EnumAnimationPart.FULL_MODEL); + if (entityModel != null) { + GL11.glPushMatrix(); + AnimationData animationData = npc.display.animationData; + if (animationData.isActive()) { + Animation animation = animationData.animation; + Frame frame = animation.frames.get(animation.currentFrame); + if (frame.frameParts.containsKey(EnumAnimationPart.FULL_MODEL)) { + FramePart part = frame.frameParts.get(EnumAnimationPart.FULL_MODEL); if (!this.isArmor) { part.interpolateOffset(); part.interpolateAngles(); } - float pi = 180 / (float) Math.PI; - GL11.glTranslatef(part.prevPivots[0], part.prevPivots[1], part.prevPivots[2]); - GL11.glRotatef(part.prevRotations[0] * pi, 1, 0, 0); - GL11.glRotatef(part.prevRotations[1] * pi, 0, 1, 0); - GL11.glRotatef(part.prevRotations[2] * pi, 0, 0, 1); - } - } - if(!isArmor){ - entityModel.isChild = entity.isChild(); - entityModel.onGround = onGround; - entityModel.isRiding = isRiding; - if(entityModel instanceof ModelBiped){ - ModelBiped biped = (ModelBiped) entityModel; - biped.aimedBow = aimedBow; - biped.heldItemLeft = heldItemLeft; - biped.heldItemRight = heldItemRight; - biped.isSneak = isSneak; - } - entityModel.render(entity, par2, par3, par4, par5, par6, par7); + float pi = 180 / (float) Math.PI; + GL11.glTranslatef(part.prevPivots[0], part.prevPivots[1], part.prevPivots[2]); + GL11.glRotatef(part.prevRotations[0] * pi, 1, 0, 0); + GL11.glRotatef(part.prevRotations[1] * pi, 0, 1, 0); + GL11.glRotatef(part.prevRotations[2] * pi, 0, 0, 1); + } + } + if (!isArmor) { + entityModel.isChild = entity.isChild(); + entityModel.onGround = onGround; + entityModel.isRiding = isRiding; + if (entityModel instanceof ModelBiped) { + ModelBiped biped = (ModelBiped) entityModel; + biped.aimedBow = aimedBow; + biped.heldItemLeft = heldItemLeft; + biped.heldItemRight = heldItemRight; + biped.isSneak = isSneak; + } + entityModel.render(entity, par2, par3, par4, par5, par6, par7); - if (!npc.display.skinOverlayData.overlayList.isEmpty()) { - for (ISkinOverlay overlayData : npc.display.skinOverlayData.overlayList.values()) { - try { - if (((SkinOverlay)overlayData).texture.isEmpty()) - continue; + if (!npc.display.skinOverlayData.overlayList.isEmpty()) { + for (ISkinOverlay overlayData : npc.display.skinOverlayData.overlayList.values()) { + try { + if (((SkinOverlay) overlayData).texture.isEmpty()) + continue; - ImageData imageData = ClientCacheHandler.getImageData(((SkinOverlay)overlayData).texture); - if (!imageData.imageLoaded()) - continue; + ImageData imageData = ClientCacheHandler.getImageData(((SkinOverlay) overlayData).texture); + if (!imageData.imageLoaded()) + continue; - try { - imageData.renderEngineBind(); - } catch (Exception e) { continue; } + try { + imageData.renderEngineBind(); + } catch (Exception e) { + continue; + } - // Overlay & Glow - GL11.glEnable(GL11.GL_BLEND); - if (overlayData.getBlend()) { - GL11.glBlendFunc(GL11.GL_ONE, GL11.GL_ONE); - } else { - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - } - GL11.glAlphaFunc(GL11.GL_GREATER, 0.003921569F); + // Overlay & Glow + GL11.glEnable(GL11.GL_BLEND); + if (overlayData.getBlend()) { + GL11.glBlendFunc(GL11.GL_ONE, GL11.GL_ONE); + } else { + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + } + GL11.glAlphaFunc(GL11.GL_GREATER, 0.003921569F); - if (overlayData.getGlow()) { - GL11.glDisable(GL11.GL_LIGHTING); - Minecraft.getMinecraft().entityRenderer.disableLightmap((double) 0); - } + if (overlayData.getGlow()) { + GL11.glDisable(GL11.GL_LIGHTING); + Minecraft.getMinecraft().entityRenderer.disableLightmap((double) 0); + } - GL11.glColor4f(1.0F, 1.0F, 1.0F, overlayData.getAlpha()); + GL11.glColor4f(1.0F, 1.0F, 1.0F, overlayData.getAlpha()); - GL11.glDepthMask(!npc.isInvisible()); + GL11.glDepthMask(!npc.isInvisible()); - GL11.glPushMatrix(); - GL11.glMatrixMode(GL11.GL_TEXTURE); - GL11.glLoadIdentity(); - GL11.glTranslatef(npc.display.overlayRenderTicks * 0.001F * overlayData.getSpeedX(), npc.display.overlayRenderTicks * 0.001F * overlayData.getSpeedY(), 0.0F); - GL11.glScalef(overlayData.getTextureScaleX(), overlayData.getTextureScaleY(), 1.0F); + GL11.glPushMatrix(); + GL11.glMatrixMode(GL11.GL_TEXTURE); + GL11.glLoadIdentity(); + GL11.glTranslatef(npc.display.overlayRenderTicks * 0.001F * overlayData.getSpeedX(), npc.display.overlayRenderTicks * 0.001F * overlayData.getSpeedY(), 0.0F); + GL11.glScalef(overlayData.getTextureScaleX(), overlayData.getTextureScaleY(), 1.0F); - GL11.glMatrixMode(GL11.GL_MODELVIEW); - float scale = 1.005f * overlayData.getSize(); - GL11.glTranslatef(overlayData.getOffsetX(), overlayData.getOffsetY(), overlayData.getOffsetZ()); - GL11.glScalef(scale, scale, scale); - entityModel.render(entity, par2, par3, par4, par5, par6, par7); - GL11.glPopMatrix(); + GL11.glMatrixMode(GL11.GL_MODELVIEW); + float scale = 1.005f * overlayData.getSize(); + GL11.glTranslatef(overlayData.getOffsetX(), overlayData.getOffsetY(), overlayData.getOffsetZ()); + GL11.glScalef(scale, scale, scale); + entityModel.render(entity, par2, par3, par4, par5, par6, par7); + GL11.glPopMatrix(); - GL11.glMatrixMode(GL11.GL_TEXTURE); - GL11.glLoadIdentity(); - GL11.glMatrixMode(GL11.GL_MODELVIEW); + GL11.glMatrixMode(GL11.GL_TEXTURE); + GL11.glLoadIdentity(); + GL11.glMatrixMode(GL11.GL_MODELVIEW); - GL11.glEnable(GL11.GL_LIGHTING); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - GL11.glDepthFunc(GL11.GL_LEQUAL); - GL11.glDisable(GL11.GL_BLEND); - GL11.glAlphaFunc(GL11.GL_GREATER, 0.1F); - Minecraft.getMinecraft().entityRenderer.enableLightmap((double) 0); - } catch (Exception ignored) { - } - } - npc.display.overlayRenderTicks++; - } - } - GL11.glPopMatrix(); - } else { - alpha = npc.isInvisible() && !npc.isInvisibleToPlayer(player) ? 0.15f : 1; + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GL11.glDepthFunc(GL11.GL_LEQUAL); + GL11.glDisable(GL11.GL_BLEND); + GL11.glAlphaFunc(GL11.GL_GREATER, 0.1F); + Minecraft.getMinecraft().entityRenderer.enableLightmap((double) 0); + } catch (Exception ignored) { + } + } + npc.display.overlayRenderTicks++; + } + } + GL11.glPopMatrix(); + } else { + alpha = npc.isInvisible() && !npc.isInvisibleToPlayer(player) ? 0.15f : 1; - setPlayerData(npc); - currentlyPlayerTexture = true; - this.setRotationAngles(par2, par3, par4, par5, par6, par7, par1Entity); - if(npc.modelData.enableRotation && !npc.display.animationData.isActive()){ - if(isRotationActive(npc)){ - float pi = (float) Math.PI; + setPlayerData(npc); + currentlyPlayerTexture = true; + this.setRotationAngles(par2, par3, par4, par5, par6, par7, par1Entity); + if (npc.modelData.enableRotation && !npc.display.animationData.isActive()) { + if (isRotationActive(npc)) { + float pi = (float) Math.PI; - if(!npc.modelData.rotation.head.disabled){ - bipedHeadwear.rotateAngleX = bipedHead.rotateAngleX = npc.modelData.rotation.head.rotationX * pi; - bipedHeadwear.rotateAngleY = bipedHead.rotateAngleY = npc.modelData.rotation.head.rotationY * pi; - bipedHeadwear.rotateAngleZ = bipedHead.rotateAngleZ = npc.modelData.rotation.head.rotationZ * pi; - } + if (!npc.modelData.rotation.head.disabled) { + bipedHeadwear.rotateAngleX = bipedHead.rotateAngleX = npc.modelData.rotation.head.rotationX * pi; + bipedHeadwear.rotateAngleY = bipedHead.rotateAngleY = npc.modelData.rotation.head.rotationY * pi; + bipedHeadwear.rotateAngleZ = bipedHead.rotateAngleZ = npc.modelData.rotation.head.rotationZ * pi; + } - if(!npc.modelData.rotation.body.disabled){ - bipedBody.rotateAngleX = npc.modelData.rotation.body.rotationX * pi; - bipedBody.rotateAngleY = npc.modelData.rotation.body.rotationY * pi; - bipedBody.rotateAngleZ = npc.modelData.rotation.body.rotationZ * pi; - } + if (!npc.modelData.rotation.body.disabled) { + bipedBody.rotateAngleX = npc.modelData.rotation.body.rotationX * pi; + bipedBody.rotateAngleY = npc.modelData.rotation.body.rotationY * pi; + bipedBody.rotateAngleZ = npc.modelData.rotation.body.rotationZ * pi; + } - if(!npc.modelData.rotation.larm.disabled){ - bipedLeftArm.rotateAngleX = npc.modelData.rotation.larm.rotationX * pi; - bipedLeftArm.rotateAngleY = npc.modelData.rotation.larm.rotationY * pi; - bipedLeftArm.rotateAngleZ = npc.modelData.rotation.larm.rotationZ * pi; + if (!npc.modelData.rotation.larm.disabled) { + bipedLeftArm.rotateAngleX = npc.modelData.rotation.larm.rotationX * pi; + bipedLeftArm.rotateAngleY = npc.modelData.rotation.larm.rotationY * pi; + bipedLeftArm.rotateAngleZ = npc.modelData.rotation.larm.rotationZ * pi; - if(!npc.display.disableLivingAnimation){ - this.bipedLeftArm.rotateAngleZ -= MathHelper.cos(par3 * 0.09F) * 0.05F + 0.05F; - this.bipedLeftArm.rotateAngleX -= MathHelper.sin(par3 * 0.067F) * 0.05F; - } - } + if (!npc.display.disableLivingAnimation) { + this.bipedLeftArm.rotateAngleZ -= MathHelper.cos(par3 * 0.09F) * 0.05F + 0.05F; + this.bipedLeftArm.rotateAngleX -= MathHelper.sin(par3 * 0.067F) * 0.05F; + } + } - if(!npc.modelData.rotation.rarm.disabled){ - bipedRightArm.rotateAngleX = npc.modelData.rotation.rarm.rotationX * pi; - bipedRightArm.rotateAngleY = npc.modelData.rotation.rarm.rotationY * pi; - bipedRightArm.rotateAngleZ = npc.modelData.rotation.rarm.rotationZ * pi; + if (!npc.modelData.rotation.rarm.disabled) { + bipedRightArm.rotateAngleX = npc.modelData.rotation.rarm.rotationX * pi; + bipedRightArm.rotateAngleY = npc.modelData.rotation.rarm.rotationY * pi; + bipedRightArm.rotateAngleZ = npc.modelData.rotation.rarm.rotationZ * pi; - if(!npc.display.disableLivingAnimation){ - this.bipedRightArm.rotateAngleZ += MathHelper.cos(par3 * 0.09F) * 0.05F + 0.05F; - this.bipedRightArm.rotateAngleX += MathHelper.sin(par3 * 0.067F) * 0.05F; - } - } + if (!npc.display.disableLivingAnimation) { + this.bipedRightArm.rotateAngleZ += MathHelper.cos(par3 * 0.09F) * 0.05F + 0.05F; + this.bipedRightArm.rotateAngleX += MathHelper.sin(par3 * 0.067F) * 0.05F; + } + } - if(!npc.modelData.rotation.rleg.disabled){ - bipedRightLeg.rotateAngleX = npc.modelData.rotation.rleg.rotationX * pi; - bipedRightLeg.rotateAngleY = npc.modelData.rotation.rleg.rotationY * pi; - bipedRightLeg.rotateAngleZ = npc.modelData.rotation.rleg.rotationZ * pi; - } + if (!npc.modelData.rotation.rleg.disabled) { + bipedRightLeg.rotateAngleX = npc.modelData.rotation.rleg.rotationX * pi; + bipedRightLeg.rotateAngleY = npc.modelData.rotation.rleg.rotationY * pi; + bipedRightLeg.rotateAngleZ = npc.modelData.rotation.rleg.rotationZ * pi; + } - if(!npc.modelData.rotation.lleg.disabled){ - bipedLeftLeg.rotateAngleX = npc.modelData.rotation.lleg.rotationX * pi; - bipedLeftLeg.rotateAngleY = npc.modelData.rotation.lleg.rotationY * pi; - bipedLeftLeg.rotateAngleZ = npc.modelData.rotation.lleg.rotationZ * pi; - } - } - } - renderHead(npc, par7); - renderArms(npc, par7,false); - renderBody(npc, par7); - renderLegs(npc, par7); - renderCloak(npc, par7); - } + if (!npc.modelData.rotation.lleg.disabled) { + bipedLeftLeg.rotateAngleX = npc.modelData.rotation.lleg.rotationX * pi; + bipedLeftLeg.rotateAngleY = npc.modelData.rotation.lleg.rotationY * pi; + bipedLeftLeg.rotateAngleZ = npc.modelData.rotation.lleg.rotationZ * pi; + } + } + } + renderHead(npc, par7); + renderArms(npc, par7, false); + renderBody(npc, par7); + renderLegs(npc, par7); + renderCloak(npc, par7); + } - } - @Override - public void setRotationAngles(float par1, float par2, float par3, float par4, float par5, float par6, Entity entity) - { - EntityCustomNpc npc = (EntityCustomNpc) entity; - isRiding = npc.isRiding(); - if(isSneak && (npc.currentAnimation == EnumAnimation.CRAWLING || npc.currentAnimation == EnumAnimation.LYING)) - isSneak = false; + } - // Body Rotations - this.bipedBody.rotationPointX = 0; - this.bipedBody.rotationPointY = 0; - this.bipedBody.rotationPointZ = 0; - this.bipedBody.rotateAngleX = 0; - this.bipedBody.rotateAngleY = 0; - this.bipedBody.rotateAngleZ = 0; + @Override + public void setRotationAngles(float par1, float par2, float par3, float par4, float par5, float par6, Entity entity) { + EntityCustomNpc npc = (EntityCustomNpc) entity; + isRiding = npc.isRiding(); + if (isSneak && (npc.currentAnimation == EnumAnimation.CRAWLING || npc.currentAnimation == EnumAnimation.LYING)) + isSneak = false; - this.bipedBodywear.rotationPointX = 0; - this.bipedBodywear.rotationPointY = 0; - this.bipedBodywear.rotationPointZ = 0; - this.bipedBodywear.rotateAngleX = 0; - this.bipedBodywear.rotateAngleY = 0; - this.bipedBodywear.rotateAngleZ = 0; + // Body Rotations + this.bipedBody.rotationPointX = 0; + this.bipedBody.rotationPointY = 0; + this.bipedBody.rotationPointZ = 0; + this.bipedBody.rotateAngleX = 0; + this.bipedBody.rotateAngleY = 0; + this.bipedBody.rotateAngleZ = 0; - // Head Rotations - this.bipedHead.rotationPointX = 0; - this.bipedHead.rotationPointY = 0; - this.bipedHead.rotationPointZ = 0; - this.bipedHead.rotateAngleX = 0; - this.bipedHead.rotateAngleY = 0; - this.bipedHead.rotateAngleZ = 0; + this.bipedBodywear.rotationPointX = 0; + this.bipedBodywear.rotationPointY = 0; + this.bipedBodywear.rotationPointZ = 0; + this.bipedBodywear.rotateAngleX = 0; + this.bipedBodywear.rotateAngleY = 0; + this.bipedBodywear.rotateAngleZ = 0; - this.bipedHeadwear.rotationPointX = 0; - this.bipedHeadwear.rotationPointY = 0; - this.bipedHeadwear.rotationPointZ = 0; - this.bipedHeadwear.rotateAngleX = 0; - this.bipedHeadwear.rotateAngleY = 0; - this.bipedHeadwear.rotateAngleZ = 0; + // Head Rotations + this.bipedHead.rotationPointX = 0; + this.bipedHead.rotationPointY = 0; + this.bipedHead.rotationPointZ = 0; + this.bipedHead.rotateAngleX = 0; + this.bipedHead.rotateAngleY = 0; + this.bipedHead.rotateAngleZ = 0; - // Leg Rotations - this.bipedLeftLeg.rotationPointX = 1.9F; - this.bipedLeftLeg.rotationPointY = 12; - this.bipedLeftLeg.rotationPointZ = 0; - this.bipedLeftLeg.rotateAngleX = 0; - this.bipedLeftLeg.rotateAngleY = 0; - this.bipedLeftLeg.rotateAngleZ = 0; + this.bipedHeadwear.rotationPointX = 0; + this.bipedHeadwear.rotationPointY = 0; + this.bipedHeadwear.rotationPointZ = 0; + this.bipedHeadwear.rotateAngleX = 0; + this.bipedHeadwear.rotateAngleY = 0; + this.bipedHeadwear.rotateAngleZ = 0; - this.bipedLeftLegWear.rotationPointX = 0; - this.bipedLeftLegWear.rotationPointY = 0; - this.bipedLeftLegWear.rotationPointZ = 0; - this.bipedLeftLegWear.rotateAngleX = 0; - this.bipedLeftLegWear.rotateAngleY = 0; - this.bipedLeftLegWear.rotateAngleZ = 0; + // Leg Rotations + this.bipedLeftLeg.rotationPointX = 1.9F; + this.bipedLeftLeg.rotationPointY = 12; + this.bipedLeftLeg.rotationPointZ = 0; + this.bipedLeftLeg.rotateAngleX = 0; + this.bipedLeftLeg.rotateAngleY = 0; + this.bipedLeftLeg.rotateAngleZ = 0; - this.bipedRightLeg.rotationPointX = -1.9F; - this.bipedRightLeg.rotationPointY = 12; - this.bipedRightLeg.rotationPointZ = 0; - this.bipedRightLeg.rotateAngleX = 0; - this.bipedRightLeg.rotateAngleY = 0; - this.bipedRightLeg.rotateAngleZ = 0; + this.bipedLeftLegWear.rotationPointX = 0; + this.bipedLeftLegWear.rotationPointY = 0; + this.bipedLeftLegWear.rotationPointZ = 0; + this.bipedLeftLegWear.rotateAngleX = 0; + this.bipedLeftLegWear.rotateAngleY = 0; + this.bipedLeftLegWear.rotateAngleZ = 0; - this.bipedRightLegWear.rotationPointX = 0; - this.bipedRightLegWear.rotationPointY = 0; - this.bipedRightLegWear.rotationPointZ = 0; - this.bipedRightLegWear.rotateAngleX = 0; - this.bipedRightLegWear.rotateAngleY = 0; - this.bipedRightLegWear.rotateAngleZ = 0; + this.bipedRightLeg.rotationPointX = -1.9F; + this.bipedRightLeg.rotationPointY = 12; + this.bipedRightLeg.rotationPointZ = 0; + this.bipedRightLeg.rotateAngleX = 0; + this.bipedRightLeg.rotateAngleY = 0; + this.bipedRightLeg.rotateAngleZ = 0; - // Arm Rotations - this.bipedLeftArm.rotationPointX = 5; - this.bipedLeftArm.rotationPointY = 2; - this.bipedLeftArm.rotationPointZ = 0; - this.bipedLeftArm.rotateAngleX = 0; - this.bipedLeftArm.rotateAngleY = 0; - this.bipedLeftArm.rotateAngleZ = 0; + this.bipedRightLegWear.rotationPointX = 0; + this.bipedRightLegWear.rotationPointY = 0; + this.bipedRightLegWear.rotationPointZ = 0; + this.bipedRightLegWear.rotateAngleX = 0; + this.bipedRightLegWear.rotateAngleY = 0; + this.bipedRightLegWear.rotateAngleZ = 0; - this.bipedLeftArmWear.rotationPointX = 0; - this.bipedLeftArmWear.rotationPointY = 0; - this.bipedLeftArmWear.rotationPointZ = 0; - this.bipedLeftArmWear.rotateAngleX = 0; - this.bipedLeftArmWear.rotateAngleY = 0; - this.bipedLeftArmWear.rotateAngleZ = 0; + // Arm Rotations + this.bipedLeftArm.rotationPointX = 5; + this.bipedLeftArm.rotationPointY = 2; + this.bipedLeftArm.rotationPointZ = 0; + this.bipedLeftArm.rotateAngleX = 0; + this.bipedLeftArm.rotateAngleY = 0; + this.bipedLeftArm.rotateAngleZ = 0; - this.bipedRightArm.rotationPointX = -5; - this.bipedRightArm.rotationPointY = 2; - this.bipedRightArm.rotationPointZ = 0; - this.bipedRightArm.rotateAngleX = 0; - this.bipedRightArm.rotateAngleY = 0; - this.bipedRightArm.rotateAngleZ = 0; + this.bipedLeftArmWear.rotationPointX = 0; + this.bipedLeftArmWear.rotationPointY = 0; + this.bipedLeftArmWear.rotationPointZ = 0; + this.bipedLeftArmWear.rotateAngleX = 0; + this.bipedLeftArmWear.rotateAngleY = 0; + this.bipedLeftArmWear.rotateAngleZ = 0; - this.bipedRightArmWear.rotationPointX = 0; - this.bipedRightArmWear.rotationPointY = 0; - this.bipedRightArmWear.rotationPointZ = 0; - this.bipedRightArmWear.rotateAngleX = 0; - this.bipedRightArmWear.rotateAngleY = 0; - this.bipedRightArmWear.rotateAngleZ = 0; + this.bipedRightArm.rotationPointX = -5; + this.bipedRightArm.rotationPointY = 2; + this.bipedRightArm.rotationPointZ = 0; + this.bipedRightArm.rotateAngleX = 0; + this.bipedRightArm.rotateAngleY = 0; + this.bipedRightArm.rotateAngleZ = 0; - super.setRotationAngles(par1, par2, par3, par4, par5, par6, entity); + this.bipedRightArmWear.rotationPointX = 0; + this.bipedRightArmWear.rotationPointY = 0; + this.bipedRightArmWear.rotationPointZ = 0; + this.bipedRightArmWear.rotateAngleX = 0; + this.bipedRightArmWear.rotateAngleY = 0; + this.bipedRightArmWear.rotateAngleZ = 0; - if(!isArmor){ - hair.setRotationAngles(par1, par2, par3, par4, par5, par6, entity); - beard.setRotationAngles(par1, par2, par3, par4, par5, par6, entity); - wings.setRotationAngles(par1, par2, par3, par4, par5, par6, entity); - tail.setRotationAngles(par1, par2, par3, par4, par5, par6, entity); - skirt.setRotationAngles(par1, par2, par3, par4, par5, par6, entity); - } - legs.setRotationAngles(par1, par2, par3, par4, par5, par6, entity); + super.setRotationAngles(par1, par2, par3, par4, par5, par6, entity); - if(isSleeping(entity)){ - if(bipedHead.rotateAngleX < 0){ - bipedHead.rotateAngleX = 0; - bipedHeadwear.rotateAngleX = 0; - } - } - else if(npc.currentAnimation == EnumAnimation.CRY) - bipedHeadwear.rotateAngleX = bipedHead.rotateAngleX = 0.7f; + if (!isArmor) { + hair.setRotationAngles(par1, par2, par3, par4, par5, par6, entity); + beard.setRotationAngles(par1, par2, par3, par4, par5, par6, entity); + wings.setRotationAngles(par1, par2, par3, par4, par5, par6, entity); + tail.setRotationAngles(par1, par2, par3, par4, par5, par6, entity); + skirt.setRotationAngles(par1, par2, par3, par4, par5, par6, entity); + } + legs.setRotationAngles(par1, par2, par3, par4, par5, par6, entity); - else if(npc.currentAnimation == EnumAnimation.HUG){ - AniHug.setRotationAngles(par1, par2, par3, par4, par5, par6, entity, this); - } + if (isSleeping(entity)) { + if (bipedHead.rotateAngleX < 0) { + bipedHead.rotateAngleX = 0; + bipedHeadwear.rotateAngleX = 0; + } + } else if (npc.currentAnimation == EnumAnimation.CRY) + bipedHeadwear.rotateAngleX = bipedHead.rotateAngleX = 0.7f; - else if(npc.currentAnimation == EnumAnimation.CRAWLING) - AniCrawling.setRotationAngles(par1, par2, par3, par4, par5, par6, entity, this); + else if (npc.currentAnimation == EnumAnimation.HUG) { + AniHug.setRotationAngles(par1, par2, par3, par4, par5, par6, entity, this); + } else if (npc.currentAnimation == EnumAnimation.CRAWLING) + AniCrawling.setRotationAngles(par1, par2, par3, par4, par5, par6, entity, this); - else if(npc.currentAnimation == EnumAnimation.WAVING){ - bipedRightArm.rotateAngleX = -0.1f; - bipedRightArm.rotateAngleY = 0; - bipedRightArm.rotateAngleZ = (float) (Math.PI - 1f - Math.sin(entity.ticksExisted * 0.27f) * 0.5f ); - } - else if(isSneak){ - this.bipedBody.rotateAngleX = 0.5F / npc.modelData.modelScale.body.scaleY; - } + else if (npc.currentAnimation == EnumAnimation.WAVING) { + bipedRightArm.rotateAngleX = -0.1f; + bipedRightArm.rotateAngleY = 0; + bipedRightArm.rotateAngleZ = (float) (Math.PI - 1f - Math.sin(entity.ticksExisted * 0.27f) * 0.5f); + } else if (isSneak) { + this.bipedBody.rotateAngleX = 0.5F / npc.modelData.modelScale.body.scaleY; + } - AnimationData animationData = npc.display.animationData; - if (animationData.isActive()) { - Animation animation = animationData.animation; - Frame frame = animation.frames.get(animation.currentFrame); + AnimationData animationData = npc.display.animationData; + if (animationData.isActive()) { + Animation animation = animationData.animation; + Frame frame = animation.frames.get(animation.currentFrame); - HashMap animPartToModel = new HashMap<>(); - animPartToModel.put(EnumAnimationPart.HEAD,bipedHead); - animPartToModel.put(EnumAnimationPart.BODY,bipedBody); - animPartToModel.put(EnumAnimationPart.LEFT_ARM,bipedLeftArm); - animPartToModel.put(EnumAnimationPart.RIGHT_ARM,bipedRightArm); - animPartToModel.put(EnumAnimationPart.LEFT_LEG,bipedLeftLeg); - animPartToModel.put(EnumAnimationPart.RIGHT_LEG,bipedRightLeg); + HashMap animPartToModel = new HashMap<>(); + animPartToModel.put(EnumAnimationPart.HEAD, bipedHead); + animPartToModel.put(EnumAnimationPart.BODY, bipedBody); + animPartToModel.put(EnumAnimationPart.LEFT_ARM, bipedLeftArm); + animPartToModel.put(EnumAnimationPart.RIGHT_ARM, bipedRightArm); + animPartToModel.put(EnumAnimationPart.LEFT_LEG, bipedLeftLeg); + animPartToModel.put(EnumAnimationPart.RIGHT_LEG, bipedRightLeg); - FramePart[] frameParts = frame.frameParts.values().toArray(new FramePart[0]); - for (FramePart part : frameParts) { - if (part != null) { - if (part.part != EnumAnimationPart.FULL_MODEL) { - ModelRenderer modelRenderer = animPartToModel.get(part.part); + FramePart[] frameParts = frame.frameParts.values().toArray(new FramePart[0]); + for (FramePart part : frameParts) { + if (part != null) { + if (part.part != EnumAnimationPart.FULL_MODEL) { + ModelRenderer modelRenderer = animPartToModel.get(part.part); if (!this.isArmor) { part.interpolateAngles(); } - modelRenderer.rotateAngleX = part.prevRotations[0]; - modelRenderer.rotateAngleY = part.prevRotations[1]; - modelRenderer.rotateAngleZ = part.prevRotations[2]; - } else if (!this.isArmor) { - part.interpolateAngles(); - } - } - } + modelRenderer.rotateAngleX = part.prevRotations[0]; + modelRenderer.rotateAngleY = part.prevRotations[1]; + modelRenderer.rotateAngleZ = part.prevRotations[2]; + } else if (!this.isArmor) { + part.interpolateAngles(); + } + } + } - frameParts = frame.frameParts.values().toArray(new FramePart[0]); - for (FramePart part : frameParts) { - if (part != null) { - if (part.part != EnumAnimationPart.FULL_MODEL) { - ModelRenderer modelRenderer = animPartToModel.get(part.part); + frameParts = frame.frameParts.values().toArray(new FramePart[0]); + for (FramePart part : frameParts) { + if (part != null) { + if (part.part != EnumAnimationPart.FULL_MODEL) { + ModelRenderer modelRenderer = animPartToModel.get(part.part); if (!this.isArmor) { part.interpolateOffset(); } - modelRenderer.rotationPointX += part.prevPivots[0]; - modelRenderer.rotationPointY += part.prevPivots[1]; - modelRenderer.rotationPointZ += part.prevPivots[2]; - } else if (!this.isArmor) { - part.interpolateOffset(); - } - } - } + modelRenderer.rotationPointX += part.prevPivots[0]; + modelRenderer.rotationPointY += part.prevPivots[1]; + modelRenderer.rotationPointZ += part.prevPivots[2]; + } else if (!this.isArmor) { + part.interpolateOffset(); + } + } + } - if (frame.frameParts.containsKey(EnumAnimationPart.FULL_MODEL) && !this.isArmor) { - FramePart part = frame.frameParts.get(EnumAnimationPart.FULL_MODEL); + if (frame.frameParts.containsKey(EnumAnimationPart.FULL_MODEL) && !this.isArmor) { + FramePart part = frame.frameParts.get(EnumAnimationPart.FULL_MODEL); if (!this.isArmor) { part.interpolateOffset(); part.interpolateAngles(); } - float pi = 180 / (float) Math.PI; - GL11.glTranslatef(part.prevPivots[0],part.prevPivots[1],part.prevPivots[2]); - GL11.glRotatef(part.prevRotations[0] * pi,1,0,0); - GL11.glRotatef(part.prevRotations[1] * pi,0,1,0); - GL11.glRotatef(part.prevRotations[2] * pi,0,0,1); - } - } - } + float pi = 180 / (float) Math.PI; + GL11.glTranslatef(part.prevPivots[0], part.prevPivots[1], part.prevPivots[2]); + GL11.glRotatef(part.prevRotations[0] * pi, 1, 0, 0); + GL11.glRotatef(part.prevRotations[1] * pi, 0, 1, 0); + GL11.glRotatef(part.prevRotations[2] * pi, 0, 0, 1); + } + } + } - public void setLivingAnimations(EntityLivingBase par1EntityLivingBase, float par2, float par3, float par4) - { - if(entityModel != null){ - entityModel.setLivingAnimations(entity, par2, par3, par4); - } - else{ - EntityCustomNpc npc = (EntityCustomNpc) par1EntityLivingBase; - if(!isArmor){ - ModelPartData partData = npc.modelData.getPartData("tail"); - if(partData != null) - tail.setLivingAnimations(partData, par1EntityLivingBase, par2, par3, par4); - } - } - } + public void setLivingAnimations(EntityLivingBase par1EntityLivingBase, float par2, float par3, float par4) { + if (entityModel != null) { + entityModel.setLivingAnimations(entity, par2, par3, par4); + } else { + EntityCustomNpc npc = (EntityCustomNpc) par1EntityLivingBase; + if (!isArmor) { + ModelPartData partData = npc.modelData.getPartData("tail"); + if (partData != null) + tail.setLivingAnimations(partData, par1EntityLivingBase, par2, par3, par4); + } + } + } - public void loadPlayerTexture(EntityCustomNpc npc){ - if(!isArmor && !currentlyPlayerTexture){ - bindTexture(npc.textureLocation); - currentlyPlayerTexture = true; - } - } + public void loadPlayerTexture(EntityCustomNpc npc) { + if (!isArmor && !currentlyPlayerTexture) { + bindTexture(npc.textureLocation); + currentlyPlayerTexture = true; + } + } - public void copyAnglesPivots(ModelRenderer to, ModelRenderer from) { - if (to == null || from == null) - return; + public void copyAnglesPivots(ModelRenderer to, ModelRenderer from) { + if (to == null || from == null) + return; - to.rotateAngleX = from.rotateAngleX; - to.rotateAngleY = from.rotateAngleY; - to.rotateAngleZ = from.rotateAngleZ; - to.rotationPointX = from.rotationPointX; - to.rotationPointY = from.rotationPointY; - to.rotationPointZ = from.rotationPointZ; - } + to.rotateAngleX = from.rotateAngleX; + to.rotateAngleY = from.rotateAngleY; + to.rotateAngleZ = from.rotateAngleZ; + to.rotationPointX = from.rotationPointX; + to.rotationPointY = from.rotationPointY; + to.rotationPointZ = from.rotationPointZ; + } public void renderHead(EntityCustomNpc entity, float f) { - loadPlayerTexture(entity); - float x = 0; - float y = entity.modelData.getBodyY(); - float z = 0; + loadPlayerTexture(entity); + float x = 0; + float y = entity.modelData.getBodyY(); + float z = 0; - GL11.glPushMatrix(); - if(entity.currentAnimation == EnumAnimation.DANCING){ - float dancing = entity.ticksExisted / 4f; - GL11.glTranslatef((float)Math.sin(dancing) * 0.075F, (float)Math.abs(Math.cos(dancing)) * 0.125F - 0.02F, (float)(-Math.abs(Math.cos(dancing))) * 0.075F); - } - ModelScalePart head = entity.modelData.modelScale.head; + GL11.glPushMatrix(); + if (entity.currentAnimation == EnumAnimation.DANCING) { + float dancing = entity.ticksExisted / 4f; + GL11.glTranslatef((float) Math.sin(dancing) * 0.075F, (float) Math.abs(Math.cos(dancing)) * 0.125F - 0.02F, (float) (-Math.abs(Math.cos(dancing))) * 0.075F); + } + ModelScalePart head = entity.modelData.modelScale.head; - this.copyAnglesPivots(headwear,bipedHead); - this.copyAnglesPivots(bipedHeadwear,bipedHead); + this.copyAnglesPivots(headwear, bipedHead); + this.copyAnglesPivots(bipedHeadwear, bipedHead); - // Hide Head - ((ModelScaleRenderer)this.bipedHead).isHidden = entity.modelData.hideHead == 1; + // Hide Head + ((ModelScaleRenderer) this.bipedHead).isHidden = entity.modelData.hideHead == 1; - if(bipedHeadwear.showModel && !bipedHeadwear.isHidden){ - if(entity.modelData.headwear == 1 || isArmor){ - ((ModelScaleRenderer)this.bipedHeadwear).setConfig(head,x,y,z); - ((ModelScaleRenderer)this.bipedHeadwear).render(f); - } - else if(entity.modelData.headwear == 2){ - this.headwear.setConfig(head,x,y,z); - this.headwear.render(f); - } - } - ((ModelScaleRenderer)this.bipedHead).setConfig(head,x,y,z); - ((ModelScaleRenderer)this.bipedHead).render(f); + if (bipedHeadwear.showModel && !bipedHeadwear.isHidden) { + if (entity.modelData.headwear == 1 || isArmor) { + ((ModelScaleRenderer) this.bipedHeadwear).setConfig(head, x, y, z); + ((ModelScaleRenderer) this.bipedHeadwear).render(f); + } else if (entity.modelData.headwear == 2) { + this.headwear.setConfig(head, x, y, z); + this.headwear.render(f); + } + } + ((ModelScaleRenderer) this.bipedHead).setConfig(head, x, y, z); + ((ModelScaleRenderer) this.bipedHead).render(f); - GL11.glPopMatrix(); - } + GL11.glPopMatrix(); + } - public void renderBody(EntityCustomNpc entity, float f) { - loadPlayerTexture(entity); - float x = 0; - float y = entity.modelData.getBodyY(); - float z = 0; - GL11.glPushMatrix(); + public void renderBody(EntityCustomNpc entity, float f) { + loadPlayerTexture(entity); + float x = 0; + float y = entity.modelData.getBodyY(); + float z = 0; + GL11.glPushMatrix(); - if(entity.currentAnimation == EnumAnimation.DANCING){ - float dancing = entity.ticksExisted / 4f; - GL11.glTranslatef((float)Math.sin(dancing) * 0.015F, 0.0F, 0.0F); - } + if (entity.currentAnimation == EnumAnimation.DANCING) { + float dancing = entity.ticksExisted / 4f; + GL11.glTranslatef((float) Math.sin(dancing) * 0.015F, 0.0F, 0.0F); + } - ModelScalePart body = entity.modelData.modelScale.body; + ModelScalePart body = entity.modelData.modelScale.body; - // Hide Body - ((ModelScaleRenderer)this.bipedBody).isHidden = entity.modelData.hideBody == 1; + // Hide Body + ((ModelScaleRenderer) this.bipedBody).isHidden = entity.modelData.hideBody == 1; - // Hide Bodywear - this.bipedBodywear.isHidden = entity.modelData.bodywear != 1; - this.bodywear.isHidden = entity.modelData.bodywear != 2; + // Hide Bodywear + this.bipedBodywear.isHidden = entity.modelData.bodywear != 1; + this.bodywear.isHidden = entity.modelData.bodywear != 2; - ((ModelScaleRenderer)this.bipedBody).setConfig(body,x,y,z); - ((ModelScaleRenderer)this.bipedBody).render(f); + ((ModelScaleRenderer) this.bipedBody).setConfig(body, x, y, z); + ((ModelScaleRenderer) this.bipedBody).render(f); - GL11.glPopMatrix(); - } - public void renderArms(EntityCustomNpc entity, float f, boolean bo){ - ModelScalePart arms = entity.modelData.modelScale.arms; + GL11.glPopMatrix(); + } - float x = (1 - entity.modelData.modelScale.body.scaleX) * 0.25f + (1 - arms.scaleX) * 0.075f; - float y = entity.modelData.getBodyY() + (1 - arms.scaleY) * -0.1f; - float z = 0; + public void renderArms(EntityCustomNpc entity, float f, boolean bo) { + ModelScalePart arms = entity.modelData.modelScale.arms; - GL11.glPushMatrix(); + float x = (1 - entity.modelData.modelScale.body.scaleX) * 0.25f + (1 - arms.scaleX) * 0.075f; + float y = entity.modelData.getBodyY() + (1 - arms.scaleY) * -0.1f; + float z = 0; - if (isAlexArmor) { - GL11.glScalef(0.75F,1.0F,1.0F); - } + GL11.glPushMatrix(); - if(entity.currentAnimation == EnumAnimation.DANCING){ - float dancing = entity.ticksExisted / 4f; - GL11.glTranslatef((float)Math.sin(dancing) * 0.025F, (float)Math.abs(Math.cos(dancing)) * 0.125F - 0.02F, 0.0F); - } + if (isAlexArmor) { + GL11.glScalef(0.75F, 1.0F, 1.0F); + } - // Hide Arms - if(entity.modelData.hideArms == 1){ - ((ModelScaleRenderer)this.bipedRightArm).isHidden = true; - ((ModelScaleRenderer)this.bipedLeftArm).isHidden = true; - } - else if(entity.modelData.hideArms == 2){ - ((ModelScaleRenderer)this.bipedRightArm).isHidden = true; - ((ModelScaleRenderer)this.bipedLeftArm).isHidden = false; - } - else if(entity.modelData.hideArms == 3){ - ((ModelScaleRenderer)this.bipedRightArm).isHidden = false; - ((ModelScaleRenderer)this.bipedLeftArm).isHidden = true; - } - else{ - ((ModelScaleRenderer)this.bipedRightArm).isHidden = false; - ((ModelScaleRenderer)this.bipedLeftArm).isHidden = false; - } + if (entity.currentAnimation == EnumAnimation.DANCING) { + float dancing = entity.ticksExisted / 4f; + GL11.glTranslatef((float) Math.sin(dancing) * 0.025F, (float) Math.abs(Math.cos(dancing)) * 0.125F - 0.02F, 0.0F); + } - // Hide Armwear - if(entity.modelData.armwear == 1){ - ((ModelScaleRenderer)this.bipedRightArmWear).isHidden = entity.modelData.solidArmwear == 1 || entity.modelData.solidArmwear == 3; - ((ModelScaleRenderer)this.bipedLeftArmWear).isHidden = entity.modelData.solidArmwear == 1 || entity.modelData.solidArmwear == 2; + // Hide Arms + if (entity.modelData.hideArms == 1) { + ((ModelScaleRenderer) this.bipedRightArm).isHidden = true; + ((ModelScaleRenderer) this.bipedLeftArm).isHidden = true; + } else if (entity.modelData.hideArms == 2) { + ((ModelScaleRenderer) this.bipedRightArm).isHidden = true; + ((ModelScaleRenderer) this.bipedLeftArm).isHidden = false; + } else if (entity.modelData.hideArms == 3) { + ((ModelScaleRenderer) this.bipedRightArm).isHidden = false; + ((ModelScaleRenderer) this.bipedLeftArm).isHidden = true; + } else { + ((ModelScaleRenderer) this.bipedRightArm).isHidden = false; + ((ModelScaleRenderer) this.bipedLeftArm).isHidden = false; + } - this.solidRightArmWear.isHidden = entity.modelData.solidArmwear == 0 || entity.modelData.solidArmwear == 2; - this.solidLeftArmWear.isHidden = entity.modelData.solidArmwear == 0 || entity.modelData.solidArmwear == 3; - } - else if(entity.modelData.armwear == 2){ - ((ModelScaleRenderer)this.bipedRightArmWear).isHidden = true; - ((ModelScaleRenderer)this.bipedLeftArmWear).isHidden = entity.modelData.solidArmwear == 1 || entity.modelData.solidArmwear == 2; + // Hide Armwear + if (entity.modelData.armwear == 1) { + ((ModelScaleRenderer) this.bipedRightArmWear).isHidden = entity.modelData.solidArmwear == 1 || entity.modelData.solidArmwear == 3; + ((ModelScaleRenderer) this.bipedLeftArmWear).isHidden = entity.modelData.solidArmwear == 1 || entity.modelData.solidArmwear == 2; - this.solidRightArmWear.isHidden = true; - this.solidLeftArmWear.isHidden = entity.modelData.solidArmwear == 0 || entity.modelData.solidArmwear == 3; - } - else if(entity.modelData.armwear == 3){ - ((ModelScaleRenderer)this.bipedRightArmWear).isHidden = entity.modelData.solidArmwear == 1 || entity.modelData.solidArmwear == 3; - ((ModelScaleRenderer)this.bipedLeftArmWear).isHidden = true; + this.solidRightArmWear.isHidden = entity.modelData.solidArmwear == 0 || entity.modelData.solidArmwear == 2; + this.solidLeftArmWear.isHidden = entity.modelData.solidArmwear == 0 || entity.modelData.solidArmwear == 3; + } else if (entity.modelData.armwear == 2) { + ((ModelScaleRenderer) this.bipedRightArmWear).isHidden = true; + ((ModelScaleRenderer) this.bipedLeftArmWear).isHidden = entity.modelData.solidArmwear == 1 || entity.modelData.solidArmwear == 2; - this.solidRightArmWear.isHidden = entity.modelData.solidArmwear == 0 || entity.modelData.solidArmwear == 2; - this.solidLeftArmWear.isHidden = true; - } - else{ - ((ModelScaleRenderer)this.bipedRightArmWear).isHidden = true; - ((ModelScaleRenderer)this.bipedLeftArmWear).isHidden = true; - this.solidRightArmWear.isHidden = true; - this.solidLeftArmWear.isHidden = true; - } + this.solidRightArmWear.isHidden = true; + this.solidLeftArmWear.isHidden = entity.modelData.solidArmwear == 0 || entity.modelData.solidArmwear == 3; + } else if (entity.modelData.armwear == 3) { + ((ModelScaleRenderer) this.bipedRightArmWear).isHidden = entity.modelData.solidArmwear == 1 || entity.modelData.solidArmwear == 3; + ((ModelScaleRenderer) this.bipedLeftArmWear).isHidden = true; + + this.solidRightArmWear.isHidden = entity.modelData.solidArmwear == 0 || entity.modelData.solidArmwear == 2; + this.solidLeftArmWear.isHidden = true; + } else { + ((ModelScaleRenderer) this.bipedRightArmWear).isHidden = true; + ((ModelScaleRenderer) this.bipedLeftArmWear).isHidden = true; + this.solidRightArmWear.isHidden = true; + this.solidLeftArmWear.isHidden = true; + } loadPlayerTexture(entity); - if(!bo){ - ((ModelScaleRenderer)this.bipedLeftArm).setConfig(arms,-x,y,z); - ((ModelScaleRenderer)this.bipedLeftArm).render(f); + if (!bo) { + ((ModelScaleRenderer) this.bipedLeftArm).setConfig(arms, -x, y, z); + ((ModelScaleRenderer) this.bipedLeftArm).render(f); loadPlayerTexture(entity); - ((ModelScaleRenderer)this.bipedRightArm).setConfig(arms,x,y,z); - ((ModelScaleRenderer)this.bipedRightArm).render(f); - } - else{ - ((ModelScaleRenderer)this.bipedRightArm).setConfig(arms,0,0,0); - ((ModelScaleRenderer)this.bipedRightArm).render(f); - } + ((ModelScaleRenderer) this.bipedRightArm).setConfig(arms, x, y, z); + ((ModelScaleRenderer) this.bipedRightArm).render(f); + } else { + ((ModelScaleRenderer) this.bipedRightArm).setConfig(arms, 0, 0, 0); + ((ModelScaleRenderer) this.bipedRightArm).render(f); + } + + GL11.glPopMatrix(); + } - GL11.glPopMatrix(); - } public void renderLegs(EntityCustomNpc entity, float f) { - loadPlayerTexture(entity); - ModelScalePart legs = entity.modelData.modelScale.legs; + loadPlayerTexture(entity); + ModelScalePart legs = entity.modelData.modelScale.legs; - float x = (1 - legs.scaleX) * 0.125f; - float y = entity.modelData.getLegsY(); - float z = 0; + float x = (1 - legs.scaleX) * 0.125f; + float y = entity.modelData.getLegsY(); + float z = 0; - GL11.glPushMatrix(); + GL11.glPushMatrix(); - // Hide Legs - if(entity.modelData.hideLegs == 1){ - ((ModelScaleRenderer)this.bipedRightLeg).isHidden = true; - ((ModelScaleRenderer)this.bipedLeftLeg).isHidden = true; - } - else if(entity.modelData.hideLegs == 2){ - ((ModelScaleRenderer)this.bipedRightLeg).isHidden = true; - ((ModelScaleRenderer)this.bipedLeftLeg).isHidden = false; - } - else if(entity.modelData.hideLegs == 3){ - ((ModelScaleRenderer)this.bipedRightLeg).isHidden = false; - ((ModelScaleRenderer)this.bipedLeftLeg).isHidden = true; - } - else{ - ((ModelScaleRenderer)this.bipedRightLeg).isHidden = false; - ((ModelScaleRenderer)this.bipedLeftLeg).isHidden = false; - } + // Hide Legs + if (entity.modelData.hideLegs == 1) { + ((ModelScaleRenderer) this.bipedRightLeg).isHidden = true; + ((ModelScaleRenderer) this.bipedLeftLeg).isHidden = true; + } else if (entity.modelData.hideLegs == 2) { + ((ModelScaleRenderer) this.bipedRightLeg).isHidden = true; + ((ModelScaleRenderer) this.bipedLeftLeg).isHidden = false; + } else if (entity.modelData.hideLegs == 3) { + ((ModelScaleRenderer) this.bipedRightLeg).isHidden = false; + ((ModelScaleRenderer) this.bipedLeftLeg).isHidden = true; + } else { + ((ModelScaleRenderer) this.bipedRightLeg).isHidden = false; + ((ModelScaleRenderer) this.bipedLeftLeg).isHidden = false; + } - // Hide Legwear - if(entity.modelData.legwear == 1){ - ((ModelScaleRenderer)this.bipedRightLegWear).isHidden = entity.modelData.solidLegwear == 1 || entity.modelData.solidLegwear == 3; - ((ModelScaleRenderer)this.bipedLeftLegWear).isHidden = entity.modelData.solidLegwear == 1 || entity.modelData.solidLegwear == 2; + // Hide Legwear + if (entity.modelData.legwear == 1) { + ((ModelScaleRenderer) this.bipedRightLegWear).isHidden = entity.modelData.solidLegwear == 1 || entity.modelData.solidLegwear == 3; + ((ModelScaleRenderer) this.bipedLeftLegWear).isHidden = entity.modelData.solidLegwear == 1 || entity.modelData.solidLegwear == 2; - this.solidRightLegWear.isHidden = entity.modelData.solidLegwear == 0 || entity.modelData.solidLegwear == 2; - this.solidLeftLegWear.isHidden = entity.modelData.solidLegwear == 0 || entity.modelData.solidLegwear == 3; - } - else if(entity.modelData.legwear == 2){ - ((ModelScaleRenderer)this.bipedRightLegWear).isHidden = true; - ((ModelScaleRenderer)this.bipedLeftLegWear).isHidden = entity.modelData.solidLegwear == 1 || entity.modelData.solidLegwear == 2; + this.solidRightLegWear.isHidden = entity.modelData.solidLegwear == 0 || entity.modelData.solidLegwear == 2; + this.solidLeftLegWear.isHidden = entity.modelData.solidLegwear == 0 || entity.modelData.solidLegwear == 3; + } else if (entity.modelData.legwear == 2) { + ((ModelScaleRenderer) this.bipedRightLegWear).isHidden = true; + ((ModelScaleRenderer) this.bipedLeftLegWear).isHidden = entity.modelData.solidLegwear == 1 || entity.modelData.solidLegwear == 2; - this.solidRightLegWear.isHidden = true; - this.solidLeftLegWear.isHidden = entity.modelData.solidLegwear == 0 || entity.modelData.solidLegwear == 3; - } - else if(entity.modelData.legwear == 3){ - ((ModelScaleRenderer)this.bipedRightLegWear).isHidden = entity.modelData.solidLegwear == 1 || entity.modelData.solidLegwear == 3; - ((ModelScaleRenderer)this.bipedLeftLegWear).isHidden = true; + this.solidRightLegWear.isHidden = true; + this.solidLeftLegWear.isHidden = entity.modelData.solidLegwear == 0 || entity.modelData.solidLegwear == 3; + } else if (entity.modelData.legwear == 3) { + ((ModelScaleRenderer) this.bipedRightLegWear).isHidden = entity.modelData.solidLegwear == 1 || entity.modelData.solidLegwear == 3; + ((ModelScaleRenderer) this.bipedLeftLegWear).isHidden = true; - this.solidRightLegWear.isHidden = entity.modelData.solidLegwear == 0 || entity.modelData.solidLegwear == 2; - this.solidLeftLegWear.isHidden = true; - } - else{ - ((ModelScaleRenderer)this.bipedRightLegWear).isHidden = true; - ((ModelScaleRenderer)this.bipedLeftLegWear).isHidden = true; - this.solidRightLegWear.isHidden = true; - this.solidLeftLegWear.isHidden = true; - } + this.solidRightLegWear.isHidden = entity.modelData.solidLegwear == 0 || entity.modelData.solidLegwear == 2; + this.solidLeftLegWear.isHidden = true; + } else { + ((ModelScaleRenderer) this.bipedRightLegWear).isHidden = true; + ((ModelScaleRenderer) this.bipedLeftLegWear).isHidden = true; + this.solidRightLegWear.isHidden = true; + this.solidLeftLegWear.isHidden = true; + } - this.legs.setConfig(legs,x,y,z); - this.legs.render(f); - if(!isArmor){ - this.tail.setConfig(legs, 0, y, z); - this.tail.render(f); - } - GL11.glPopMatrix(); - } + this.legs.setConfig(legs, x, y, z); + this.legs.render(f); + if (!isArmor) { + this.tail.setConfig(legs, 0, y, z); + this.tail.render(f); + } + GL11.glPopMatrix(); + } - public void renderCloak(EntityCustomNpc npc, float f){ - if (!npc.display.cloakTexture.isEmpty() && !isArmor) - { - ImageData imageData = ClientCacheHandler.getImageData(npc.display.cloakTexture); - if (!imageData.imageLoaded()) - return; + public void renderCloak(EntityCustomNpc npc, float f) { + if (!npc.display.cloakTexture.isEmpty() && !isArmor) { + ImageData imageData = ClientCacheHandler.getImageData(npc.display.cloakTexture); + if (!imageData.imageLoaded()) + return; - try { - imageData.bindTexture(); - } catch (Exception e) { return; - } + try { + imageData.bindTexture(); + } catch (Exception e) { + return; + } - GL11.glPushMatrix(); - GL11.glTranslatef(0.0F, 0.0F, 0.125F); - double d = (npc.field_20066_r + (npc.field_20063_u - npc.field_20066_r) * (double)f) - (npc.prevPosX + (npc.posX - npc.prevPosX) * (double)f); - double d1 = (npc.field_20065_s + (npc.field_20062_v - npc.field_20065_s) * (double)f) - (npc.prevPosY + (npc.posY - npc.prevPosY) * (double)f); - double d2 = (npc.field_20064_t + (npc.field_20061_w - npc.field_20064_t) * (double)f) - (npc.prevPosZ + (npc.posZ - npc.prevPosZ) * (double)f); - float f11 = npc.prevRenderYawOffset + (npc.renderYawOffset - npc.prevRenderYawOffset) * f; - double d3 = MathHelper.sin((f11 * 3.141593F) / 180F); - double d4 = -MathHelper.cos((f11 * 3.141593F) / 180F); - float f14 = (float)(d * d3 + d2 * d4) * 100F; - float f15 = (float)(d * d4 - d2 * d3) * 100F; - if (f14 < 0.0F) - { - f14 = 0.0F; - } - float f16 = npc.prevRotationYaw + (npc.rotationYaw - npc.prevRotationYaw) * f; - float f13 = 5f; - if (npc.isSneaking()) - { - f13 += 25F; - } + GL11.glPushMatrix(); + GL11.glTranslatef(0.0F, 0.0F, 0.125F); + double d = (npc.field_20066_r + (npc.field_20063_u - npc.field_20066_r) * (double) f) - (npc.prevPosX + (npc.posX - npc.prevPosX) * (double) f); + double d1 = (npc.field_20065_s + (npc.field_20062_v - npc.field_20065_s) * (double) f) - (npc.prevPosY + (npc.posY - npc.prevPosY) * (double) f); + double d2 = (npc.field_20064_t + (npc.field_20061_w - npc.field_20064_t) * (double) f) - (npc.prevPosZ + (npc.posZ - npc.prevPosZ) * (double) f); + float f11 = npc.prevRenderYawOffset + (npc.renderYawOffset - npc.prevRenderYawOffset) * f; + double d3 = MathHelper.sin((f11 * 3.141593F) / 180F); + double d4 = -MathHelper.cos((f11 * 3.141593F) / 180F); + float f14 = (float) (d * d3 + d2 * d4) * 100F; + float f15 = (float) (d * d4 - d2 * d3) * 100F; + if (f14 < 0.0F) { + f14 = 0.0F; + } + float f16 = npc.prevRotationYaw + (npc.rotationYaw - npc.prevRotationYaw) * f; + float f13 = 5f; + if (npc.isSneaking()) { + f13 += 25F; + } - GL11.glRotatef(6F + f14 / 2.0F + f13, 1.0F, 0.0F, 0.0F); - GL11.glRotatef(f15 / 2.0F, 0.0F, 0.0F, 1.0F); - GL11.glRotatef(-f15 / 2.0F, 0.0F, 1.0F, 0.0F); - GL11.glRotatef(180F, 0.0F, 1.0F, 0.0F); - super.renderCloak(0.0625F); - GL11.glPopMatrix(); - } - } + GL11.glRotatef(6F + f14 / 2.0F + f13, 1.0F, 0.0F, 0.0F); + GL11.glRotatef(f15 / 2.0F, 0.0F, 0.0F, 1.0F); + GL11.glRotatef(-f15 / 2.0F, 0.0F, 1.0F, 0.0F); + GL11.glRotatef(180F, 0.0F, 1.0F, 0.0F); + super.renderCloak(0.0625F); + GL11.glPopMatrix(); + } + } - @Override - public ModelRenderer getRandomModelBox(Random par1Random) - { - int random = par1Random.nextInt(5); - switch(random){ - case 0: - return bipedRightLeg; - case 1: - return bipedHead; - case 2: - return bipedLeftArm; - case 3: - return bipedRightArm; - case 4: - return bipedLeftLeg; - } + @Override + public ModelRenderer getRandomModelBox(Random par1Random) { + int random = par1Random.nextInt(5); + switch (random) { + case 0: + return bipedRightLeg; + case 1: + return bipedHead; + case 2: + return bipedLeftArm; + case 3: + return bipedRightArm; + case 4: + return bipedLeftLeg; + } - return bipedBody; - } + return bipedBody; + } - public boolean isRotationActive(EntityCustomNpc npc) { - if(!npc.isEntityAlive()) - return false; + public boolean isRotationActive(EntityCustomNpc npc) { + if (!npc.isEntityAlive()) + return false; - if(npc.modelData.rotation.whileAttacking && npc.isAttacking() || npc.modelData.rotation.whileMoving && npc.isWalking() || npc.modelData.rotation.whileStanding && !npc.isWalking()) - return true; - return false; - } + if (npc.modelData.rotation.whileAttacking && npc.isAttacking() || npc.modelData.rotation.whileMoving && npc.isWalking() || npc.modelData.rotation.whileStanding && !npc.isWalking()) + return true; + return false; + } } diff --git a/src/main/java/noppes/npcs/client/model/ModelNPCGolem.java b/src/main/java/noppes/npcs/client/model/ModelNPCGolem.java index e44c719bd..d734f2d73 100644 --- a/src/main/java/noppes/npcs/client/model/ModelNPCGolem.java +++ b/src/main/java/noppes/npcs/client/model/ModelNPCGolem.java @@ -8,16 +8,14 @@ import noppes.npcs.entity.EntityNPCInterface; public class ModelNPCGolem extends ModelNPCMale { - private ModelRenderer bipedLowerBody; - - public ModelNPCGolem(float f) - { - super(f); + private ModelRenderer bipedLowerBody; + + public ModelNPCGolem(float f) { + super(f); } - - public void init(float f, float f1) - { - super.init(f,f1); + + public void init(float f, float f1) { + super.init(f, f1); short short1 = 128; short short2 = 128; float f2 = -7.0F; @@ -37,7 +35,7 @@ public class ModelNPCGolem extends ModelNPCMale { this.bipedLowerBody.setTextureOffset(0, 70).addBox(-4.5F, 10.0F, -3.0F, 9, 5, 6, f + 0.5F); this.bipedLowerBody.setTextureOffset(30, 70).addBox(-4.5F, 6.0F, -3.0F, 9, 9, 6, f + 0.4F); this.bipedRightArm = (new ModelRenderer(this)).setTextureSize(short1, short2); - this.bipedRightArm.setRotationPoint(0.0F, f2, 0.0F); + this.bipedRightArm.setRotationPoint(0.0F, f2, 0.0F); this.bipedRightArm.setTextureOffset(60, 21).addBox(-13.0F, -2.5F, -3.0F, 4, 30, 6, f + 0.2F); this.bipedRightArm.setTextureOffset(80, 21).addBox(-13.0F, -2.5F, -3.0F, 4, 20, 6, f); this.bipedRightArm.setTextureOffset(100, 21).addBox(-13.0F, -2.5F, -3.0F, 4, 20, 6, f + 1.0F); @@ -54,53 +52,48 @@ public class ModelNPCGolem extends ModelNPCMale { this.bipedRightLeg.setTextureOffset(60, 0).setRotationPoint(5.0F, 18.0F + f2, 0.0F); this.bipedRightLeg.addBox(-3.5F, -3.0F, -3.0F, 6, 16, 5, f); } - + @Override - public void render(Entity par1Entity, float par2, float par3, float par4, float par5, float par6, float par7) - { - super.render(par1Entity, par2, par3, par4, par5, par6, par7); - bipedLowerBody.render(par7); + public void render(Entity par1Entity, float par2, float par3, float par4, float par5, float par6, float par7) { + super.render(par1Entity, par2, par3, par4, par5, par6, par7); + bipedLowerBody.render(par7); } @Override - public void setRotationAngles(float par1, float par2, float par3, float par4, float par5, float par6, Entity entity) - { - EntityNPCInterface npc = (EntityNPCInterface) entity; - isRiding = npc.isRiding(); - - if(isSneak && (npc.currentAnimation == EnumAnimation.CRAWLING || npc.currentAnimation == EnumAnimation.LYING)) - isSneak = false; - - bipedHead.rotateAngleY = par4 / (180F / (float)Math.PI); - bipedHead.rotateAngleX = par5 / (180F / (float)Math.PI); + public void setRotationAngles(float par1, float par2, float par3, float par4, float par5, float par6, Entity entity) { + EntityNPCInterface npc = (EntityNPCInterface) entity; + isRiding = npc.isRiding(); + + if (isSneak && (npc.currentAnimation == EnumAnimation.CRAWLING || npc.currentAnimation == EnumAnimation.LYING)) + isSneak = false; + + bipedHead.rotateAngleY = par4 / (180F / (float) Math.PI); + bipedHead.rotateAngleX = par5 / (180F / (float) Math.PI); bipedHeadwear.rotateAngleY = bipedHead.rotateAngleY; bipedHeadwear.rotateAngleX = bipedHead.rotateAngleX; bipedLeftLeg.rotateAngleX = -1.5F * this.func_78172_a(par1, 13.0F) * par2; bipedRightLeg.rotateAngleX = 1.5F * this.func_78172_a(par1, 13.0F) * par2; bipedLeftLeg.rotateAngleY = 0.0F; bipedRightLeg.rotateAngleY = 0.0F; - - float f6 = MathHelper.sin(this.onGround * (float)Math.PI); - float f7 = MathHelper.sin((16.0F - (1.0F - this.onGround) * (1.0F - this.onGround)) * (float)Math.PI); - if (this.onGround > 0.0) - { - this.bipedRightArm.rotateAngleZ = 0.0F; - this.bipedLeftArm.rotateAngleZ = 0.0F; - this.bipedRightArm.rotateAngleY = -(0.1F - f6 * 0.6F); - this.bipedLeftArm.rotateAngleY = 0.1F - f6 * 0.6F; - bipedRightArm.rotateAngleX = 0.0F; - bipedLeftArm.rotateAngleX = 0.0F; - this.bipedRightArm.rotateAngleX = -((float)Math.PI / 2F); - this.bipedLeftArm.rotateAngleX = -((float)Math.PI / 2F); - this.bipedRightArm.rotateAngleX -= f6 * 1.2F - f7 * 0.4F; - this.bipedLeftArm.rotateAngleX -= f6 * 1.2F - f7 * 0.4F; - } - else if (aimedBow) - { + + float f6 = MathHelper.sin(this.onGround * (float) Math.PI); + float f7 = MathHelper.sin((16.0F - (1.0F - this.onGround) * (1.0F - this.onGround)) * (float) Math.PI); + if (this.onGround > 0.0) { + this.bipedRightArm.rotateAngleZ = 0.0F; + this.bipedLeftArm.rotateAngleZ = 0.0F; + this.bipedRightArm.rotateAngleY = -(0.1F - f6 * 0.6F); + this.bipedLeftArm.rotateAngleY = 0.1F - f6 * 0.6F; + bipedRightArm.rotateAngleX = 0.0F; + bipedLeftArm.rotateAngleX = 0.0F; + this.bipedRightArm.rotateAngleX = -((float) Math.PI / 2F); + this.bipedLeftArm.rotateAngleX = -((float) Math.PI / 2F); + this.bipedRightArm.rotateAngleX -= f6 * 1.2F - f7 * 0.4F; + this.bipedLeftArm.rotateAngleX -= f6 * 1.2F - f7 * 0.4F; + } else if (aimedBow) { float f1 = 0.0F; float f3 = 0.0F; bipedRightArm.rotateAngleZ = 0.0F; - bipedRightArm.rotateAngleX = -((float)Math.PI / 2F) + bipedHead.rotateAngleX; + bipedRightArm.rotateAngleX = -((float) Math.PI / 2F) + bipedHead.rotateAngleX; bipedRightArm.rotateAngleX -= f1 * 1.2F - f3 * 0.4F; bipedRightArm.rotateAngleZ += MathHelper.cos(par3 * 0.09F) * 0.05F + 0.05F; bipedRightArm.rotateAngleX += MathHelper.sin(par3 * 0.067F) * 0.05F; @@ -108,31 +101,27 @@ public class ModelNPCGolem extends ModelNPCMale { bipedBody.rotateAngleY = -(0.1F - f1 * 0.6F) + bipedHead.rotateAngleY; bipedRightArm.rotateAngleY = -(0.1F - f1 * 0.6F) + bipedHead.rotateAngleY; bipedLeftArm.rotateAngleY = (0.1F - f1 * 0.6F) + bipedHead.rotateAngleY; - } - else - { - bipedRightArm.rotateAngleX = (-0.2F + 1.5F * this.func_78172_a(par1, 13.0F)) * par2; - bipedLeftArm.rotateAngleX = (-0.2F - 1.5F * this.func_78172_a(par1, 13.0F)) * par2; - bipedBody.rotateAngleY = 0.0F; - bipedRightArm.rotateAngleY = 0.0F; + } else { + bipedRightArm.rotateAngleX = (-0.2F + 1.5F * this.func_78172_a(par1, 13.0F)) * par2; + bipedLeftArm.rotateAngleX = (-0.2F - 1.5F * this.func_78172_a(par1, 13.0F)) * par2; + bipedBody.rotateAngleY = 0.0F; + bipedRightArm.rotateAngleY = 0.0F; bipedLeftArm.rotateAngleY = 0.0F; bipedRightArm.rotateAngleZ = 0.0F; bipedLeftArm.rotateAngleZ = 0.0F; } - - if (isRiding) - { - bipedRightArm.rotateAngleX += -((float)Math.PI / 5F); - bipedLeftArm.rotateAngleX += -((float)Math.PI / 5F); - bipedLeftLeg.rotateAngleX = -((float)Math.PI * 2F / 5F); - bipedRightLeg.rotateAngleX = -((float)Math.PI * 2F / 5F); - bipedLeftLeg.rotateAngleY = ((float)Math.PI / 10F); - bipedRightLeg.rotateAngleY = -((float)Math.PI / 10F); + + if (isRiding) { + bipedRightArm.rotateAngleX += -((float) Math.PI / 5F); + bipedLeftArm.rotateAngleX += -((float) Math.PI / 5F); + bipedLeftLeg.rotateAngleX = -((float) Math.PI * 2F / 5F); + bipedRightLeg.rotateAngleX = -((float) Math.PI * 2F / 5F); + bipedLeftLeg.rotateAngleY = ((float) Math.PI / 10F); + bipedRightLeg.rotateAngleY = -((float) Math.PI / 10F); } } - - private float func_78172_a(float par1, float par2) - { + + private float func_78172_a(float par1, float par2) { return (Math.abs(par1 % par2 - par2 * 0.5F) - par2 * 0.25F) / (par2 * 0.25F); } -} \ No newline at end of file +} diff --git a/src/main/java/noppes/npcs/client/model/ModelNPCMale.java b/src/main/java/noppes/npcs/client/model/ModelNPCMale.java index 18f2d0b3c..d369b46d2 100644 --- a/src/main/java/noppes/npcs/client/model/ModelNPCMale.java +++ b/src/main/java/noppes/npcs/client/model/ModelNPCMale.java @@ -12,8 +12,7 @@ import noppes.npcs.constants.EnumAnimation; import noppes.npcs.entity.EntityNPCInterface; import org.lwjgl.opengl.GL11; -public class ModelNPCMale extends ModelBiped -{ +public class ModelNPCMale extends ModelBiped { public boolean isDancing; public boolean isSleeping; @@ -22,27 +21,24 @@ public class ModelNPCMale extends ModelBiped public float invisible; - public ModelNPCMale(float f) - { + public ModelNPCMale(float f) { init(f, 0.0F); } - public ModelNPCMale(float f, boolean alex) - { + public ModelNPCMale(float f, boolean alex) { super(f, 0.0F, 64, 64); init(f, 0.0F, alex); } @Override - public void setLivingAnimations(EntityLivingBase par1EntityLiving, float f6, float f5, float par9){ + public void setLivingAnimations(EntityLivingBase par1EntityLiving, float f6, float f5, float par9) { animationTick += par9; dancingTicks = CustomNpcs.ticks / 3.978873F; } // 64x64 Skin - public void init(float f, float f1, boolean arms) - { + public void init(float f, float f1, boolean arms) { heldItemLeft = 0; heldItemRight = 0; @@ -70,7 +66,7 @@ public class ModelNPCMale extends ModelBiped bipedBody.addBox(-4F, 0.0F, -2F, 8, 12, 4, f); bipedBody.setRotationPoint(0.0F, 0.0F + f1, 0.0F); - if (arms){ + if (arms) { // Alex Version bipedRightArm = (new ModelScaleRenderer(this, 40, 16)); bipedRightArm.addBox(-2.0F, -2.0F, -2.0F, 3, 12, 4, f); @@ -79,8 +75,7 @@ public class ModelNPCMale extends ModelBiped bipedLeftArm = new ModelScaleRenderer(this, 32, 48); bipedLeftArm.addBox(-1.0F, -2.0F, -2.0F, 3, 12, 4, f); bipedLeftArm.setRotationPoint(5.0F, 2.5F + f1, 0.0F); - } - else{ + } else { // Steve Version bipedRightArm = new ModelRenderer(this, 40, 16); bipedRightArm.addBox(-3F, -2F, -2F, 4, 12, 4, f); @@ -102,8 +97,7 @@ public class ModelNPCMale extends ModelBiped } // 64x32 - public void init(float f, float f1) - { + public void init(float f, float f1) { heldItemLeft = 0; heldItemRight = 0; isSneak = false; @@ -144,13 +138,11 @@ public class ModelNPCMale extends ModelBiped } - - @Override - public void render(Entity par1Entity, float par2, float par3, float par4, float par5, float par6, float par7){ + public void render(Entity par1Entity, float par2, float par3, float par4, float par5, float par6, float par7) { setRotationAngles(par2, par3, par4, par5, par6, par7, par1Entity); - if(!isDancing){ + if (!isDancing) { bipedHead.render(par7); bipedBody.render(par7); bipedRightArm.render(par7); @@ -158,117 +150,113 @@ public class ModelNPCMale extends ModelBiped bipedRightLeg.render(par7); bipedLeftLeg.render(par7); bipedHeadwear.render(par7); - } - else{ + } else { renderHead(par1Entity, par7); renderArms(par1Entity, par7); renderBody(par1Entity, par7); renderLegs(par1Entity, par7); } } - public void renderHead(Entity entityliving,float par7){ - if(isDancing){ + + public void renderHead(Entity entityliving, float par7) { + if (isDancing) { GL11.glPushMatrix(); - GL11.glTranslatef((float)Math.sin(dancingTicks) * 0.075F, (float)Math.abs(Math.cos(dancingTicks)) * 0.125F - 0.02F, (float)(-Math.abs(Math.cos(dancingTicks))) * 0.075F); + GL11.glTranslatef((float) Math.sin(dancingTicks) * 0.075F, (float) Math.abs(Math.cos(dancingTicks)) * 0.125F - 0.02F, (float) (-Math.abs(Math.cos(dancingTicks))) * 0.075F); bipedHead.render(par7); bipedHeadwear.render(par7); GL11.glPopMatrix(); - } - else{ + } else { bipedHead.render(par7); bipedHeadwear.render(par7); } } - public void renderLeftArm(Entity entityliving,float par7){ - if(isDancing){ + + public void renderLeftArm(Entity entityliving, float par7) { + if (isDancing) { GL11.glPushMatrix(); - GL11.glTranslatef((float)Math.sin(dancingTicks) * 0.025F, (float)Math.abs(Math.cos(dancingTicks)) * 0.125F - 0.02F, 0.0F); + GL11.glTranslatef((float) Math.sin(dancingTicks) * 0.025F, (float) Math.abs(Math.cos(dancingTicks)) * 0.125F - 0.02F, 0.0F); bipedLeftArm.render(par7); GL11.glPopMatrix(); - } - else{ + } else { bipedLeftArm.render(par7); } } - public void renderArms(Entity entity,float par7){ - renderLeftArm(entity,par7); - renderRightArm(entity,par7); + + public void renderArms(Entity entity, float par7) { + renderLeftArm(entity, par7); + renderRightArm(entity, par7); } - public void renderRightArm(Entity entityliving,float par7){ - if(isDancing){ + + public void renderRightArm(Entity entityliving, float par7) { + if (isDancing) { GL11.glPushMatrix(); - GL11.glTranslatef((float)Math.sin(dancingTicks) * 0.025F, (float)Math.abs(Math.cos(dancingTicks)) * 0.125F - 0.02F, 0.0F); + GL11.glTranslatef((float) Math.sin(dancingTicks) * 0.025F, (float) Math.abs(Math.cos(dancingTicks)) * 0.125F - 0.02F, 0.0F); bipedRightArm.render(par7); GL11.glPopMatrix(); - } - else{ + } else { bipedRightArm.render(par7); } } - public void renderBody(Entity entityliving,float par7){ - if(isDancing){ + + public void renderBody(Entity entityliving, float par7) { + if (isDancing) { GL11.glPushMatrix(); - GL11.glTranslatef((float)Math.sin(dancingTicks) * 0.015F, 0.0F, 0.0F); + GL11.glTranslatef((float) Math.sin(dancingTicks) * 0.015F, 0.0F, 0.0F); bipedBody.render(par7); GL11.glPopMatrix(); - } - else{ + } else { bipedBody.render(par7); } } - public void renderLegs(Entity entityliving,float par7){ + + public void renderLegs(Entity entityliving, float par7) { bipedRightLeg.render(par7); bipedLeftLeg.render(par7); } - public void setRotationAngles(float par1, float par2, float par3, float par4, float par5, float par6, Entity entity) - { + public void setRotationAngles(float par1, float par2, float par3, float par4, float par5, float par6, Entity entity) { EntityNPCInterface npc = (EntityNPCInterface) entity; isRiding = npc.isRiding(); - if(isSneak && (npc.currentAnimation == EnumAnimation.CRAWLING || npc.currentAnimation == EnumAnimation.LYING)) + if (isSneak && (npc.currentAnimation == EnumAnimation.CRAWLING || npc.currentAnimation == EnumAnimation.LYING)) isSneak = false; - bipedHead.rotateAngleY = par4 / (180F / (float)Math.PI); - bipedHead.rotateAngleX = par5 / (180F / (float)Math.PI); + bipedHead.rotateAngleY = par4 / (180F / (float) Math.PI); + bipedHead.rotateAngleX = par5 / (180F / (float) Math.PI); bipedHeadwear.rotateAngleY = bipedHead.rotateAngleY; bipedHeadwear.rotateAngleX = bipedHead.rotateAngleX; - bipedRightArm.rotateAngleX = MathHelper.cos(par1 * 0.6662F + (float)Math.PI) * 2.0F * par2 * 0.5F; + bipedRightArm.rotateAngleX = MathHelper.cos(par1 * 0.6662F + (float) Math.PI) * 2.0F * par2 * 0.5F; bipedLeftArm.rotateAngleX = MathHelper.cos(par1 * 0.6662F) * 2.0F * par2 * 0.5F; bipedRightArm.rotateAngleZ = 0.0F; bipedLeftArm.rotateAngleZ = 0.0F; bipedRightLeg.rotateAngleX = MathHelper.cos(par1 * 0.6662F) * 1.4F * par2; - bipedLeftLeg.rotateAngleX = MathHelper.cos(par1 * 0.6662F + (float)Math.PI) * 1.4F * par2; + bipedLeftLeg.rotateAngleX = MathHelper.cos(par1 * 0.6662F + (float) Math.PI) * 1.4F * par2; bipedRightLeg.rotateAngleY = 0.0F; bipedLeftLeg.rotateAngleY = 0.0F; - if (isRiding) - { - bipedRightArm.rotateAngleX += -((float)Math.PI / 5F); - bipedLeftArm.rotateAngleX += -((float)Math.PI / 5F); - bipedRightLeg.rotateAngleX = -((float)Math.PI * 2F / 5F); - bipedLeftLeg.rotateAngleX = -((float)Math.PI * 2F / 5F); - bipedRightLeg.rotateAngleY = ((float)Math.PI / 10F); - bipedLeftLeg.rotateAngleY = -((float)Math.PI / 10F); + if (isRiding) { + bipedRightArm.rotateAngleX += -((float) Math.PI / 5F); + bipedLeftArm.rotateAngleX += -((float) Math.PI / 5F); + bipedRightLeg.rotateAngleX = -((float) Math.PI * 2F / 5F); + bipedLeftLeg.rotateAngleX = -((float) Math.PI * 2F / 5F); + bipedRightLeg.rotateAngleY = ((float) Math.PI / 10F); + bipedLeftLeg.rotateAngleY = -((float) Math.PI / 10F); } - if (heldItemLeft != 0) - { - bipedLeftArm.rotateAngleX = bipedLeftArm.rotateAngleX * 0.5F - ((float)Math.PI / 10F) * (float)heldItemLeft; + if (heldItemLeft != 0) { + bipedLeftArm.rotateAngleX = bipedLeftArm.rotateAngleX * 0.5F - ((float) Math.PI / 10F) * (float) heldItemLeft; } - if (heldItemRight != 0) - { - bipedRightArm.rotateAngleX = bipedRightArm.rotateAngleX * 0.5F - ((float)Math.PI / 10F) * (float)heldItemRight; + if (heldItemRight != 0) { + bipedRightArm.rotateAngleX = bipedRightArm.rotateAngleX * 0.5F - ((float) Math.PI / 10F) * (float) heldItemRight; } bipedRightArm.rotateAngleY = 0.0F; bipedLeftArm.rotateAngleY = 0.0F; - if (onGround > -9990F) - { + if (onGround > -9990F) { float f = onGround; - bipedBody.rotateAngleY = MathHelper.sin(MathHelper.sqrt_float(f) * (float)Math.PI * 2.0F) * 0.2F; + bipedBody.rotateAngleY = MathHelper.sin(MathHelper.sqrt_float(f) * (float) Math.PI * 2.0F) * 0.2F; bipedRightArm.rotationPointZ = MathHelper.sin(bipedBody.rotateAngleY) * 5F; bipedRightArm.rotationPointX = -MathHelper.cos(bipedBody.rotateAngleY) * 5F; bipedLeftArm.rotationPointZ = -MathHelper.sin(bipedBody.rotateAngleY) * 5F; @@ -280,15 +268,14 @@ public class ModelNPCMale extends ModelBiped f *= f; f *= f; f = 1.0F - f; - float f2 = MathHelper.sin(f * (float)Math.PI); - float f4 = MathHelper.sin(onGround * (float)Math.PI) * -(bipedHead.rotateAngleX - 0.7F) * 0.75F; - bipedRightArm.rotateAngleX -= (double)f2 * 1.2D + (double)f4; + float f2 = MathHelper.sin(f * (float) Math.PI); + float f4 = MathHelper.sin(onGround * (float) Math.PI) * -(bipedHead.rotateAngleX - 0.7F) * 0.75F; + bipedRightArm.rotateAngleX -= (double) f2 * 1.2D + (double) f4; bipedRightArm.rotateAngleY += bipedBody.rotateAngleY * 2.0F; - bipedRightArm.rotateAngleZ = MathHelper.sin(onGround * (float)Math.PI) * -0.4F; + bipedRightArm.rotateAngleZ = MathHelper.sin(onGround * (float) Math.PI) * -0.4F; } - if (isSneak) - { + if (isSneak) { bipedBody.rotateAngleX = 0.5F; bipedRightLeg.rotateAngleX -= 0.0F; bipedLeftLeg.rotateAngleX -= 0.0F; @@ -299,9 +286,7 @@ public class ModelNPCMale extends ModelBiped bipedRightLeg.rotationPointY = 9F; bipedLeftLeg.rotationPointY = 9F; bipedHead.rotationPointY = 1.0F; - } - else - { + } else { bipedBody.rotateAngleX = 0.0F; bipedRightLeg.rotationPointZ = 0.0F; bipedLeftLeg.rotationPointZ = 0.0F; @@ -315,16 +300,15 @@ public class ModelNPCMale extends ModelBiped bipedRightArm.rotateAngleX += MathHelper.sin(par3 * 0.067F) * 0.05F; bipedLeftArm.rotateAngleX -= MathHelper.sin(par3 * 0.067F) * 0.05F; - if (aimedBow) - { + if (aimedBow) { float f1 = 0.0F; float f3 = 0.0F; bipedRightArm.rotateAngleZ = 0.0F; bipedLeftArm.rotateAngleZ = 0.0F; bipedRightArm.rotateAngleY = -(0.1F - f1 * 0.6F) + bipedHead.rotateAngleY; bipedLeftArm.rotateAngleY = (0.1F - f1 * 0.6F) + bipedHead.rotateAngleY + 0.4F; - bipedRightArm.rotateAngleX = -((float)Math.PI / 2F) + bipedHead.rotateAngleX; - bipedLeftArm.rotateAngleX = -((float)Math.PI / 2F) + bipedHead.rotateAngleX; + bipedRightArm.rotateAngleX = -((float) Math.PI / 2F) + bipedHead.rotateAngleX; + bipedLeftArm.rotateAngleX = -((float) Math.PI / 2F) + bipedHead.rotateAngleX; bipedRightArm.rotateAngleX -= f1 * 1.2F - f3 * 0.4F; bipedLeftArm.rotateAngleX -= f1 * 1.2F - f3 * 0.4F; bipedRightArm.rotateAngleZ += MathHelper.cos(par3 * 0.09F) * 0.05F + 0.05F; @@ -334,8 +318,7 @@ public class ModelNPCMale extends ModelBiped } } - public void renderEars(float f) - { + public void renderEars(float f) { bipedEars.rotateAngleY = bipedHead.rotateAngleY; bipedEars.rotateAngleX = bipedHead.rotateAngleX; bipedEars.rotationPointX = 0.0F; @@ -343,21 +326,19 @@ public class ModelNPCMale extends ModelBiped bipedEars.render(f); } - public void setRotation(ModelRenderer model, float x, float y, float z) - { + public void setRotation(ModelRenderer model, float x, float y, float z) { model.rotateAngleX = x; model.rotateAngleY = y; model.rotateAngleZ = z; } - public void renderCloak(float f) - { + public void renderCloak(float f) { bipedCloak.render(f); } public boolean isSleeping(Entity entity) { - if(entity instanceof EntityPlayer && ((EntityPlayer)entity).isPlayerSleeping()) + if (entity instanceof EntityPlayer && ((EntityPlayer) entity).isPlayerSleeping()) return true; - return ((EntityNPCInterface)entity).currentAnimation == EnumAnimation.LYING; + return ((EntityNPCInterface) entity).currentAnimation == EnumAnimation.LYING; } } diff --git a/src/main/java/noppes/npcs/client/model/ModelNpcCrystal.java b/src/main/java/noppes/npcs/client/model/ModelNpcCrystal.java index 5af36e85d..521a2b3d2 100644 --- a/src/main/java/noppes/npcs/client/model/ModelNpcCrystal.java +++ b/src/main/java/noppes/npcs/client/model/ModelNpcCrystal.java @@ -7,14 +7,12 @@ import net.minecraft.entity.EntityLivingBase; import net.minecraft.util.MathHelper; import org.lwjgl.opengl.GL11; -public class ModelNpcCrystal extends ModelBase -{ +public class ModelNpcCrystal extends ModelBase { private ModelRenderer field_41057_g; private ModelRenderer field_41058_h; private ModelRenderer field_41059_i; - public ModelNpcCrystal(float par1) - { + public ModelNpcCrystal(float par1) { field_41058_h = new ModelRenderer(this, "glass"); field_41058_h.setTextureOffset(0, 0).addBox(-4F, -4F, -4F, 8, 8, 8); field_41057_g = new ModelRenderer(this, "cube"); @@ -22,30 +20,32 @@ public class ModelNpcCrystal extends ModelBase field_41059_i = new ModelRenderer(this, "base"); field_41059_i.setTextureOffset(0, 16).addBox(-6F, 16.0F, -6F, 12, 4, 12); } + float ticks; + @Override - public void setLivingAnimations(EntityLivingBase par1EntityLiving, float f6, float f5, float par9){ - ticks = par9; + public void setLivingAnimations(EntityLivingBase par1EntityLiving, float f6, float f5, float par9) { + ticks = par9; } + /** * Sets the models various rotation angles then renders the model. */ @Override - public void render(Entity par1Entity, float par2, float par3, float par4, float par5, float par6, float par7) - { - + public void render(Entity par1Entity, float par2, float par3, float par4, float par5, float par6, float par7) { + GL11.glPushMatrix(); GL11.glScalef(2.0F, 2.0F, 2.0F); GL11.glTranslatef(0.0F, -0.5F, 0.0F); field_41059_i.render(par7); - float f = (float)par1Entity.ticksExisted + ticks; + float f = (float) par1Entity.ticksExisted + ticks; float f1 = MathHelper.sin(f * 0.2F) / 2.0F + 0.5F; f1 = f1 * f1 + f1; - + par3 = f * 3F; par4 = f1 * 0.2F; - + GL11.glRotatef(par3, 0.0F, 1.0F, 0.0F); GL11.glTranslatef(0.0F, 0.1F + par4, 0.0F); GL11.glRotatef(60F, 0.7071F, 0.0F, 0.7071F); diff --git a/src/main/java/noppes/npcs/client/model/ModelNpcDragon.java b/src/main/java/noppes/npcs/client/model/ModelNpcDragon.java index c2e73ba59..c47057839 100644 --- a/src/main/java/noppes/npcs/client/model/ModelNpcDragon.java +++ b/src/main/java/noppes/npcs/client/model/ModelNpcDragon.java @@ -8,8 +8,7 @@ import net.minecraft.util.MathHelper; import noppes.npcs.entity.EntityNpcDragon; import org.lwjgl.opengl.GL11; -public class ModelNpcDragon extends ModelBase -{ +public class ModelNpcDragon extends ModelBase { private ModelRenderer head; private ModelRenderer neck; @@ -24,11 +23,9 @@ public class ModelNpcDragon extends ModelBase private ModelRenderer wing; private ModelRenderer wingTip; private float field_40317_s; - - - public ModelNpcDragon(float f) - { + + public ModelNpcDragon(float f) { textureWidth = 256; textureHeight = 256; setTextureOffset("body.body", 0, 0); @@ -107,19 +104,17 @@ public class ModelNpcDragon extends ModelBase } @Override - public void setLivingAnimations(EntityLivingBase entityliving, float f, float f1, float f2) - { + public void setLivingAnimations(EntityLivingBase entityliving, float f, float f1, float f2) { field_40317_s = f2; } - + @Override - public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) - { - EntityNpcDragon entitydragon = (EntityNpcDragon)entity; + public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) { + EntityNpcDragon entitydragon = (EntityNpcDragon) entity; GL11.glPushMatrix(); float f6 = entitydragon.field_40173_aw + (entitydragon.field_40172_ax - entitydragon.field_40173_aw) * field_40317_s; - jaw.rotateAngleX = (float)(Math.sin(f6 * (float)Math.PI * 2.0F) + 1.0D) * 0.2F; - float f7 = (float)(Math.sin(f6 * (float)Math.PI * 2.0F - 1.0F) + 1.0D); + jaw.rotateAngleX = (float) (Math.sin(f6 * (float) Math.PI * 2.0F) + 1.0D) * 0.2F; + float f7 = (float) (Math.sin(f6 * (float) Math.PI * 2.0F - 1.0F) + 1.0D); f7 = (f7 * f7 * 1.0F + f7 * 2.0F) * 0.05F; GL11.glTranslatef(0.0F, f7 - 2.0F, -3F); GL11.glRotatef(f7 * 2.0F, 1.0F, 0.0F, 0.0F); @@ -129,25 +124,24 @@ public class ModelNpcDragon extends ModelBase float f11 = 1.5F; double ad[] = entitydragon.func_40160_a(6, field_40317_s); float f12 = func_40307_a(entitydragon.func_40160_a(5, field_40317_s)[0] - entitydragon.func_40160_a(10, field_40317_s)[0]); - float f13 = func_40307_a(entitydragon.func_40160_a(5, field_40317_s)[0] + (double)(f12 / 2.0F)); + float f13 = func_40307_a(entitydragon.func_40160_a(5, field_40317_s)[0] + (double) (f12 / 2.0F)); f8 += 2.0F; float f14 = 0.0F; float f15 = f6 * 3.141593F * 2.0F; f8 = 20F; f9 = -12F; - for(int i = 0; i < 5; i++) - { + for (int i = 0; i < 5; i++) { double ad3[] = entitydragon.func_40160_a(5 - i, field_40317_s); - f14 = (float)Math.cos((float)i * 0.45F + f15) * 0.15F; - neck.rotateAngleY = ((func_40307_a(ad3[0] - ad[0]) * (float)Math.PI) / 180F) * f11; - neck.rotateAngleX = f14 + (((float)(ad3[1] - ad[1]) * (float)Math.PI) / 180F) * f11 * 5F; - neck.rotateAngleZ = ((-func_40307_a(ad3[0] - (double)f13) * (float)Math.PI) / 180F) * f11; + f14 = (float) Math.cos((float) i * 0.45F + f15) * 0.15F; + neck.rotateAngleY = ((func_40307_a(ad3[0] - ad[0]) * (float) Math.PI) / 180F) * f11; + neck.rotateAngleX = f14 + (((float) (ad3[1] - ad[1]) * (float) Math.PI) / 180F) * f11 * 5F; + neck.rotateAngleZ = ((-func_40307_a(ad3[0] - (double) f13) * (float) Math.PI) / 180F) * f11; neck.rotationPointY = f8; neck.rotationPointZ = f9; neck.rotationPointX = f10; - f8 = (float)((double)f8 + Math.sin(neck.rotateAngleX) * 10D); - f9 = (float)((double)f9 - Math.cos(neck.rotateAngleY) * Math.cos(neck.rotateAngleX) * 10D); - f10 = (float)((double)f10 - Math.sin(neck.rotateAngleY) * Math.cos(neck.rotateAngleX) * 10D); + f8 = (float) ((double) f8 + Math.sin(neck.rotateAngleX) * 10D); + f9 = (float) ((double) f9 - Math.cos(neck.rotateAngleY) * Math.cos(neck.rotateAngleX) * 10D); + f10 = (float) ((double) f10 - Math.sin(neck.rotateAngleY) * Math.cos(neck.rotateAngleX) * 10D); neck.render(f5); } @@ -155,96 +149,90 @@ public class ModelNpcDragon extends ModelBase head.rotationPointZ = f9; head.rotationPointX = f10; double ad1[] = entitydragon.func_40160_a(0, field_40317_s); - head.rotateAngleY = ((func_40307_a(ad1[0] - ad[0]) * (float)Math.PI) / 180F) * 1.0F; - head.rotateAngleZ = ((-func_40307_a(ad1[0] - (double)f13) * (float)Math.PI) / 180F) * 1.0F; + head.rotateAngleY = ((func_40307_a(ad1[0] - ad[0]) * (float) Math.PI) / 180F) * 1.0F; + head.rotateAngleZ = ((-func_40307_a(ad1[0] - (double) f13) * (float) Math.PI) / 180F) * 1.0F; head.render(f5); GL11.glPushMatrix(); GL11.glTranslatef(0.0F, 1.0F, 0.0F); - if(entitydragon.onGround) - GL11.glRotatef(-f12 * f11 * 0.3F, 0.0F, 0.0F, 1.0F); + if (entitydragon.onGround) + GL11.glRotatef(-f12 * f11 * 0.3F, 0.0F, 0.0F, 1.0F); else - GL11.glRotatef(-f12 * f11 * 1.0F, 0.0F, 0.0F, 1.0F); - + GL11.glRotatef(-f12 * f11 * 1.0F, 0.0F, 0.0F, 1.0F); + GL11.glTranslatef(0.0F, -1F, 0.0F); body.rotateAngleZ = 0.0F; body.render(f5); - if(entitydragon.onGround){ - for(int j = 0; j < 2; j++) - { - GL11.glEnable(2884 /*GL_CULL_FACE*/); - wing.rotateAngleX = 0.25f; - wing.rotateAngleY = 0.95F; - wing.rotateAngleZ = -0.5f; - wingTip.rotateAngleZ = -0.4f; - frontLeg.rotateAngleX = MathHelper.cos((float) (f * 0.6662F + (j==0?0:Math.PI))) * 0.6F * f1 + 0.45f + f7 * 0.5f ; - frontLegTip.rotateAngleX = -1.3f - f7 * 1.2f ; - frontFoot.rotateAngleX = 0.85f + f7 * 0.5f; - frontLeg.render(f5); + if (entitydragon.onGround) { + for (int j = 0; j < 2; j++) { + GL11.glEnable(2884 /*GL_CULL_FACE*/); + wing.rotateAngleX = 0.25f; + wing.rotateAngleY = 0.95F; + wing.rotateAngleZ = -0.5f; + wingTip.rotateAngleZ = -0.4f; + frontLeg.rotateAngleX = MathHelper.cos((float) (f * 0.6662F + (j == 0 ? 0 : Math.PI))) * 0.6F * f1 + 0.45f + f7 * 0.5f; + frontLegTip.rotateAngleX = -1.3f - f7 * 1.2f; + frontFoot.rotateAngleX = 0.85f + f7 * 0.5f; + frontLeg.render(f5); - rearLeg.rotateAngleX = MathHelper.cos((float) (f * 0.6662F + (j==0?Math.PI:0))) * 0.6F * f1 + 0.75f + f7 * 0.5f; - rearLegTip.rotateAngleX = -1.6f - f7 * 0.8f ; - rearLegTip.rotationPointY = 20; - rearLegTip.rotationPointZ = 2; - rearFoot.rotateAngleX = 0.85f + f7 * 0.2f; - - rearLeg.render(f5); - wing.render(f5); - GL11.glScalef(-1F, 1.0F, 1.0F); - if(j == 0) - { - GL11.glCullFace(1028 /*GL_FRONT*/); - } - } - } - else{ - for(int j = 0; j < 2; j++) - { - GL11.glEnable(2884 /*GL_CULL_FACE*/); - float f16 = f6 * (float)Math.PI * 2.0F; - wing.rotateAngleX = 0.125F - (float)Math.cos(f16) * 0.2F; - wing.rotateAngleY = 0.25F; - wing.rotateAngleZ = (float)(Math.sin(f16) + 0.125D) * 0.8F; - wingTip.rotateAngleZ = -(float)(Math.sin(f16 + 2.0F) + 0.5D) * 0.75F; - rearLegTip.rotationPointY = 32; - rearLegTip.rotationPointZ = -2; - rearLeg.rotateAngleX = 1.0F + f7 * 0.1F; - rearLegTip.rotateAngleX = 0.5F + f7 * 0.1F; - rearFoot.rotateAngleX = 0.75F + f7 * 0.1F; - frontLeg.rotateAngleX = 1.3F + f7 * 0.1F; - frontLegTip.rotateAngleX = -0.5F - f7 * 0.1F; - frontFoot.rotateAngleX = 0.75F + f7 * 0.1F; - wing.render(f5); - frontLeg.render(f5); - rearLeg.render(f5); - GL11.glScalef(-1F, 1.0F, 1.0F); - if(j == 0) - { - GL11.glCullFace(1028 /*GL_FRONT*/); - } - } + rearLeg.rotateAngleX = MathHelper.cos((float) (f * 0.6662F + (j == 0 ? Math.PI : 0))) * 0.6F * f1 + 0.75f + f7 * 0.5f; + rearLegTip.rotateAngleX = -1.6f - f7 * 0.8f; + rearLegTip.rotationPointY = 20; + rearLegTip.rotationPointZ = 2; + rearFoot.rotateAngleX = 0.85f + f7 * 0.2f; + + rearLeg.render(f5); + wing.render(f5); + GL11.glScalef(-1F, 1.0F, 1.0F); + if (j == 0) { + GL11.glCullFace(1028 /*GL_FRONT*/); + } + } + } else { + for (int j = 0; j < 2; j++) { + GL11.glEnable(2884 /*GL_CULL_FACE*/); + float f16 = f6 * (float) Math.PI * 2.0F; + wing.rotateAngleX = 0.125F - (float) Math.cos(f16) * 0.2F; + wing.rotateAngleY = 0.25F; + wing.rotateAngleZ = (float) (Math.sin(f16) + 0.125D) * 0.8F; + wingTip.rotateAngleZ = -(float) (Math.sin(f16 + 2.0F) + 0.5D) * 0.75F; + rearLegTip.rotationPointY = 32; + rearLegTip.rotationPointZ = -2; + rearLeg.rotateAngleX = 1.0F + f7 * 0.1F; + rearLegTip.rotateAngleX = 0.5F + f7 * 0.1F; + rearFoot.rotateAngleX = 0.75F + f7 * 0.1F; + frontLeg.rotateAngleX = 1.3F + f7 * 0.1F; + frontLegTip.rotateAngleX = -0.5F - f7 * 0.1F; + frontFoot.rotateAngleX = 0.75F + f7 * 0.1F; + wing.render(f5); + frontLeg.render(f5); + rearLeg.render(f5); + GL11.glScalef(-1F, 1.0F, 1.0F); + if (j == 0) { + GL11.glCullFace(1028 /*GL_FRONT*/); + } + } } GL11.glPopMatrix(); GL11.glCullFace(1029 /*GL_BACK*/); GL11.glDisable(2884 /*GL_CULL_FACE*/); - f14 = -(float)Math.sin(f6 * 3.141593F * 2.0F) * 0.0F; - f15 = f6 * (float)Math.PI * 2.0F; + f14 = -(float) Math.sin(f6 * 3.141593F * 2.0F) * 0.0F; + f15 = f6 * (float) Math.PI * 2.0F; f8 = 10F; f9 = 60F; f10 = 0.0F; ad = entitydragon.func_40160_a(11, field_40317_s); - for(int k = 0; k < 12; k++) - { + for (int k = 0; k < 12; k++) { double ad2[] = entitydragon.func_40160_a(12 + k, field_40317_s); - f14 = (float)((double)f14 + Math.sin((float)k * 0.45F + f15) * 0.05000000074505806D); - neck.rotateAngleY = ((func_40307_a(ad2[0] - ad[0]) * f11 + 180F) * (float)Math.PI) / 180F; - neck.rotateAngleX = f14 + (((float)(ad2[1] - ad[1]) * (float)Math.PI) / 180F) * f11 * 5F; - neck.rotateAngleZ = ((func_40307_a(ad2[0] - (double)f13) * (float)Math.PI) / 180F) * f11; + f14 = (float) ((double) f14 + Math.sin((float) k * 0.45F + f15) * 0.05000000074505806D); + neck.rotateAngleY = ((func_40307_a(ad2[0] - ad[0]) * f11 + 180F) * (float) Math.PI) / 180F; + neck.rotateAngleX = f14 + (((float) (ad2[1] - ad[1]) * (float) Math.PI) / 180F) * f11 * 5F; + neck.rotateAngleZ = ((func_40307_a(ad2[0] - (double) f13) * (float) Math.PI) / 180F) * f11; neck.rotationPointY = f8; neck.rotationPointZ = f9; neck.rotationPointX = f10; - f8 = (float)((double)f8 + Math.sin(neck.rotateAngleX) * 10D); - f9 = (float)((double)f9 - Math.cos(neck.rotateAngleY) * Math.cos(neck.rotateAngleX) * 10D); - f10 = (float)((double)f10 - Math.sin(neck.rotateAngleY) * Math.cos(neck.rotateAngleX) * 10D); + f8 = (float) ((double) f8 + Math.sin(neck.rotateAngleX) * 10D); + f9 = (float) ((double) f9 - Math.cos(neck.rotateAngleY) * Math.cos(neck.rotateAngleX) * 10D); + f10 = (float) ((double) f10 - Math.sin(neck.rotateAngleY) * Math.cos(neck.rotateAngleX) * 10D); neck.render(f5); } @@ -252,10 +240,11 @@ public class ModelNpcDragon extends ModelBase //} } - private float func_40307_a(double d) - { - for(; d >= 180D; d -= 360D) { } - for(; d < -180D; d += 360D) { } - return (float)d; + private float func_40307_a(double d) { + for (; d >= 180D; d -= 360D) { + } + for (; d < -180D; d += 360D) { + } + return (float) d; } } diff --git a/src/main/java/noppes/npcs/client/model/ModelNpcSlime.java b/src/main/java/noppes/npcs/client/model/ModelNpcSlime.java index 2da8bc315..8af63f364 100644 --- a/src/main/java/noppes/npcs/client/model/ModelNpcSlime.java +++ b/src/main/java/noppes/npcs/client/model/ModelNpcSlime.java @@ -8,34 +8,37 @@ import net.minecraft.entity.Entity; import org.lwjgl.opengl.GL11; @SideOnly(Side.CLIENT) -public class ModelNpcSlime extends ModelBase -{ +public class ModelNpcSlime extends ModelBase { ModelRenderer outerBody; ModelRenderer innerBody; - /** The slime's right eye */ + /** + * The slime's right eye + */ ModelRenderer slimeRightEye; - /** The slime's left eye */ + /** + * The slime's left eye + */ ModelRenderer slimeLeftEye; - /** The slime's mouth */ + /** + * The slime's mouth + */ ModelRenderer slimeMouth; - public ModelNpcSlime(int par1) - { - this.textureHeight = 64; - this.textureWidth = 64; + public ModelNpcSlime(int par1) { + this.textureHeight = 64; + this.textureWidth = 64; outerBody = new ModelRenderer(this, 0, 0); this.outerBody = new ModelRenderer(this, 0, 0); this.outerBody.addBox(-8.0F, 32.0F, -8.0F, 16, 16, 16); //this.outerBody.addBox(-8.0F, 32.0F, -8.0F, 16, 16, 16); - if (par1 > 0) - { + if (par1 > 0) { this.innerBody = new ModelRenderer(this, 0, 32); this.innerBody.addBox(-3.0F, 17.0F, -3.0F, 6, 6, 6); - + this.slimeRightEye = new ModelRenderer(this, 0, 0); this.slimeRightEye.addBox(-3.25F, 18.0F, -3.5F, 2, 2, 2); this.slimeLeftEye = new ModelRenderer(this, 0, 4); @@ -48,20 +51,18 @@ public class ModelNpcSlime extends ModelBase /** * Sets the models various rotation angles then renders the model. */ - public void render(Entity par1Entity, float par2, float par3, float par4, float par5, float par6, float par7) - { + public void render(Entity par1Entity, float par2, float par3, float par4, float par5, float par6, float par7) { this.setRotationAngles(par2, par3, par4, par5, par6, par7, par1Entity); - if(innerBody != null) - this.innerBody.render(par7); - else{ - GL11.glPushMatrix(); - GL11.glScalef(0.5f, 0.5f, 0.5f); - this.outerBody.render(par7); - GL11.glPopMatrix(); + if (innerBody != null) + this.innerBody.render(par7); + else { + GL11.glPushMatrix(); + GL11.glScalef(0.5f, 0.5f, 0.5f); + this.outerBody.render(par7); + GL11.glPopMatrix(); } - if (this.slimeRightEye != null) - { + if (this.slimeRightEye != null) { this.slimeRightEye.render(par7); this.slimeLeftEye.render(par7); this.slimeMouth.render(par7); diff --git a/src/main/java/noppes/npcs/client/model/ModelPony.java b/src/main/java/noppes/npcs/client/model/ModelPony.java index 6efac6dbf..57e47f8bc 100644 --- a/src/main/java/noppes/npcs/client/model/ModelPony.java +++ b/src/main/java/noppes/npcs/client/model/ModelPony.java @@ -21,8 +21,7 @@ import java.awt.*; import java.awt.image.BufferedImage; import java.io.IOException; -public class ModelPony extends ModelBase -{ +public class ModelPony extends ModelBase { private boolean rainboom; private float WingRotateAngleX; @@ -53,13 +52,11 @@ public class ModelPony extends ModelBase public boolean aimedBow; public int heldItemRight; - public ModelPony(float f) - { - init(f,0.0f); + public ModelPony(float f) { + init(f, 0.0f); } - public void init(float strech,float f) - { + public void init(float strech, float f) { float f2 = 0.0F; float f3 = 0.0F; float f4 = 0.0F; @@ -280,22 +277,19 @@ public class ModelPony extends ModelBase } - public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5, Entity entity) - { - EntityNPCInterface npc = (EntityNPCInterface) entity; - isRiding = npc.isRiding(); - - if(isSneak && (npc.currentAnimation == EnumAnimation.CRAWLING || npc.currentAnimation == EnumAnimation.LYING)) - isSneak = false; + public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5, Entity entity) { + EntityNPCInterface npc = (EntityNPCInterface) entity; + isRiding = npc.isRiding(); + + if (isSneak && (npc.currentAnimation == EnumAnimation.CRAWLING || npc.currentAnimation == EnumAnimation.LYING)) + isSneak = false; rainboom = false; float f6; float f7; - if(isSleeping) - { + if (isSleeping) { f6 = 1.4F; f7 = 0.1F; - } else - { + } else { f6 = f3 / 57.29578F; f7 = f4 / 57.29578F; } @@ -314,8 +308,7 @@ public class ModelPony extends ModelBase float f9; float f10; float f11; - if(!isFlying || !isPegasus) - { + if (!isFlying || !isPegasus) { f8 = MathHelper.cos(f * 0.6662F + 3.141593F) * 0.6F * f1; f9 = MathHelper.cos(f * 0.6662F) * 0.6F * f1; f10 = MathHelper.cos(f * 0.6662F) * 0.3F * f1; @@ -325,17 +318,14 @@ public class ModelPony extends ModelBase LeftArm.rotateAngleY = 0.0F; RightLeg.rotateAngleY = 0.0F; LeftLeg.rotateAngleY = 0.0F; - } else - { - if(f1 < 0.9999F) - { + } else { + if (f1 < 0.9999F) { rainboom = false; f8 = MathHelper.sin(0.0F - f1 * 0.5F); f9 = MathHelper.sin(0.0F - f1 * 0.5F); f10 = MathHelper.sin(f1 * 0.5F); f11 = MathHelper.sin(f1 * 0.5F); - } else - { + } else { rainboom = true; f8 = 4.712F; f9 = 4.712F; @@ -347,8 +337,7 @@ public class ModelPony extends ModelBase RightLeg.rotateAngleY = -0.2F; LeftLeg.rotateAngleY = 0.2F; } - if(isSleeping) - { + if (isSleeping) { f8 = 4.712F; f9 = 4.712F; f10 = 1.571F; @@ -362,64 +351,51 @@ public class ModelPony extends ModelBase RightArm.rotateAngleZ = 0.0F; unicornarm.rotateAngleZ = 0.0F; LeftArm.rotateAngleZ = 0.0F; - for(int i = 0; i < Tail.length; i++) - { - if(rainboom) - { + for (int i = 0; i < Tail.length; i++) { + if (rainboom) { Tail[i].rotateAngleZ = 0.0F; - } else - { + } else { Tail[i].rotateAngleZ = MathHelper.cos(f * 0.8F) * 0.2F * f1; } } - if(heldItemRight != 0 && !rainboom && !isUnicorn) - { + if (heldItemRight != 0 && !rainboom && !isUnicorn) { RightArm.rotateAngleX = RightArm.rotateAngleX * 0.5F - 0.3141593F; } float f12 = 0.0F; - if(f5 > -9990F && !isUnicorn) - { + if (f5 > -9990F && !isUnicorn) { f12 = MathHelper.sin(MathHelper.sqrt_float(f5) * 3.141593F * 2.0F) * 0.2F; } - Body.rotateAngleY = (float)((double)f12 * 0.20000000000000001D); - for(int j = 0; j < Bodypiece.length; j++) - { - Bodypiece[j].rotateAngleY = (float)((double)f12 * 0.20000000000000001D); + Body.rotateAngleY = (float) ((double) f12 * 0.20000000000000001D); + for (int j = 0; j < Bodypiece.length; j++) { + Bodypiece[j].rotateAngleY = (float) ((double) f12 * 0.20000000000000001D); } - for(int k = 0; k < LeftWing.length; k++) - { - LeftWing[k].rotateAngleY = (float)((double)f12 * 0.20000000000000001D); + for (int k = 0; k < LeftWing.length; k++) { + LeftWing[k].rotateAngleY = (float) ((double) f12 * 0.20000000000000001D); } - for(int l = 0; l < RightWing.length; l++) - { - RightWing[l].rotateAngleY = (float)((double)f12 * 0.20000000000000001D); + for (int l = 0; l < RightWing.length; l++) { + RightWing[l].rotateAngleY = (float) ((double) f12 * 0.20000000000000001D); } - for(int i1 = 0; i1 < Tail.length; i1++) - { + for (int i1 = 0; i1 < Tail.length; i1++) { Tail[i1].rotateAngleY = f12; } float f13 = MathHelper.sin(Body.rotateAngleY) * 5F; float f14 = MathHelper.cos(Body.rotateAngleY) * 5F; float f15 = 4F; - if(isSneak && !isFlying) - { + if (isSneak && !isFlying) { f15 = 0.0F; } - if(isSleeping) - { + if (isSleeping) { f15 = 2.6F; } - if(rainboom) - { + if (rainboom) { RightArm.rotationPointZ = f13 + 2.0F; LeftArm.rotationPointZ = (0.0F - f13) + 2.0F; - } else - { + } else { RightArm.rotationPointZ = f13 + 1.0F; LeftArm.rotationPointZ = (0.0F - f13) + 1.0F; } @@ -434,8 +410,7 @@ public class ModelPony extends ModelBase LeftArm.rotationPointY = 8F; RightLeg.rotationPointY = 4F; LeftLeg.rotationPointY = 4F; - if(f5 > -9990F) - { + if (f5 > -9990F) { float f16 = f5; f16 = 1.0F - f5; f16 *= f16 * f16; @@ -443,14 +418,12 @@ public class ModelPony extends ModelBase float f22 = MathHelper.sin(f16 * 3.141593F); float f28 = MathHelper.sin(f5 * 3.141593F); float f33 = f28 * -(Head.rotateAngleX - 0.7F) * 0.75F; - if(isUnicorn) - { - unicornarm.rotateAngleX -= (double)f22 * 1.2D + (double)f33; + if (isUnicorn) { + unicornarm.rotateAngleX -= (double) f22 * 1.2D + (double) f33; unicornarm.rotateAngleY += Body.rotateAngleY * 2.0F; unicornarm.rotateAngleZ = f28 * -0.4F; - } else - { - unicornarm.rotateAngleX -= (double)f22 * 1.2D + (double)f33; + } else { + unicornarm.rotateAngleX -= (double) f22 * 1.2D + (double) f33; unicornarm.rotateAngleY += Body.rotateAngleY * 2.0F; unicornarm.rotateAngleZ = f28 * -0.4F; // RightArm.rotateAngleX -= (double)f22 * 1.2D + (double)f33; @@ -458,16 +431,14 @@ public class ModelPony extends ModelBase // RightArm.rotateAngleZ = f28 * -0.4F; } } - if(isSneak && !isFlying) - { + if (isSneak && !isFlying) { float f17 = 0.4F; float f23 = 7F; float f29 = -4F; Body.rotateAngleX = f17; Body.rotationPointY = f23; Body.rotationPointZ = f29; - for(int i3 = 0; i3 < Bodypiece.length; i3++) - { + for (int i3 = 0; i3 < Bodypiece.length; i3++) { Bodypiece[i3].rotateAngleX = f17; Bodypiece[i3].rotationPointY = f23; Bodypiece[i3].rotationPointZ = f29; @@ -475,9 +446,8 @@ public class ModelPony extends ModelBase float f34 = 3.5F; float f37 = 6F; - for(int i4 = 0; i4 < LeftWingExt.length; i4++) - { - LeftWingExt[i4].rotateAngleX = (float)((double)f17 + 2.3561947345733643D); + for (int i4 = 0; i4 < LeftWingExt.length; i4++) { + LeftWingExt[i4].rotateAngleX = (float) ((double) f17 + 2.3561947345733643D); LeftWingExt[i4].rotationPointY = f23 + f34; LeftWingExt[i4].rotationPointZ = f29 + f37; LeftWingExt[i4].rotateAngleX = 2.5F; @@ -486,9 +456,8 @@ public class ModelPony extends ModelBase float f40 = 4.5F; float f43 = 6F; - for(int i5 = 0; i5 < LeftWingExt.length; i5++) - { - RightWingExt[i5].rotateAngleX = (float)((double)f17 + 2.3561947345733643D); + for (int i5 = 0; i5 < LeftWingExt.length; i5++) { + RightWingExt[i5].rotateAngleX = (float) ((double) f17 + 2.3561947345733643D); RightWingExt[i5].rotationPointY = f23 + f40; RightWingExt[i5].rotationPointZ = f29 + f43; RightWingExt[i5].rotateAngleX = 2.5F; @@ -507,13 +476,11 @@ public class ModelPony extends ModelBase float f46; float f48; float f50; - if(isSleeping) - { + if (isSleeping) { f46 = 2.0F; f48 = -1F; f50 = 1.0F; - } else - { + } else { f46 = 6F; f48 = -2F; f50 = 0.0F; @@ -540,63 +507,53 @@ public class ModelPony extends ModelBase float f60 = 9F - f54; float f62 = -4F - f56; float f63 = 0.0F; - for(int i6 = 0; i6 < Tail.length; i6++) - { + for (int i6 = 0; i6 < Tail.length; i6++) { Tail[i6].rotationPointX = f58; Tail[i6].rotationPointY = f60; Tail[i6].rotationPointZ = f62; Tail[i6].rotateAngleX = f63; } - } else - { + } else { float f18 = 0.0F; float f24 = 0.0F; float f30 = 0.0F; Body.rotateAngleX = f18; Body.rotationPointY = f24; Body.rotationPointZ = f30; - for(int j3 = 0; j3 < Bodypiece.length; j3++) - { + for (int j3 = 0; j3 < Bodypiece.length; j3++) { Bodypiece[j3].rotateAngleX = f18; Bodypiece[j3].rotationPointY = f24; Bodypiece[j3].rotationPointZ = f30; } - if(isPegasus) - { - if(!isFlying) - { - for(int k3 = 0; k3 < LeftWing.length; k3++) - { - LeftWing[k3].rotateAngleX = (float)((double)f18 + 1.5707964897155762D); + if (isPegasus) { + if (!isFlying) { + for (int k3 = 0; k3 < LeftWing.length; k3++) { + LeftWing[k3].rotateAngleX = (float) ((double) f18 + 1.5707964897155762D); LeftWing[k3].rotationPointY = f24 + 13F; LeftWing[k3].rotationPointZ = f30 - 3F; } - for(int l3 = 0; l3 < RightWing.length; l3++) - { - RightWing[l3].rotateAngleX = (float)((double)f18 + 1.5707964897155762D); + for (int l3 = 0; l3 < RightWing.length; l3++) { + RightWing[l3].rotateAngleX = (float) ((double) f18 + 1.5707964897155762D); RightWing[l3].rotationPointY = f24 + 13F; RightWing[l3].rotationPointZ = f30 - 3F; } - } else - { + } else { float f35 = 5.5F; float f38 = 3F; - for(int j4 = 0; j4 < LeftWingExt.length; j4++) - { - LeftWingExt[j4].rotateAngleX = (float)((double)f18 + 1.5707964897155762D); + for (int j4 = 0; j4 < LeftWingExt.length; j4++) { + LeftWingExt[j4].rotateAngleX = (float) ((double) f18 + 1.5707964897155762D); LeftWingExt[j4].rotationPointY = f24 + f35; LeftWingExt[j4].rotationPointZ = f30 + f38; } float f41 = 6.5F; float f44 = 3F; - for(int j5 = 0; j5 < RightWingExt.length; j5++) - { - RightWingExt[j5].rotateAngleX = (float)((double)f18 + 1.5707964897155762D); + for (int j5 = 0; j5 < RightWingExt.length; j5++) { + RightWingExt[j5].rotateAngleX = (float) ((double) f18 + 1.5707964897155762D); RightWingExt[j5].rotationPointY = f24 + f41; RightWingExt[j5].rotationPointZ = f30 + f44; } @@ -611,18 +568,15 @@ public class ModelPony extends ModelBase float f39 = MathHelper.sin(f2 * 0.067F) * 0.05F; unicornarm.rotateAngleZ += f36; unicornarm.rotateAngleX += f39; - if(isPegasus && isFlying) - { + if (isPegasus && isFlying) { WingRotateAngleY = MathHelper.sin(f2 * 0.067F * 8F) * 1.0F; WingRotateAngleZ = MathHelper.sin(f2 * 0.067F * 8F) * 1.0F; - for(int k4 = 0; k4 < LeftWingExt.length; k4++) - { + for (int k4 = 0; k4 < LeftWingExt.length; k4++) { LeftWingExt[k4].rotateAngleX = 2.5F; LeftWingExt[k4].rotateAngleZ = -WingRotateAngleZ - 4.712F - 0.4F; } - for(int l4 = 0; l4 < RightWingExt.length; l4++) - { + for (int l4 = 0; l4 < RightWingExt.length; l4++) { RightWingExt[l4].rotateAngleX = 2.5F; RightWingExt[l4].rotateAngleZ = WingRotateAngleZ + 4.712F + 0.4F; } @@ -631,13 +585,11 @@ public class ModelPony extends ModelBase float f42; float f45; float f47; - if(isSleeping) - { + if (isSleeping) { f42 = 2.0F; f45 = 1.0F; f47 = 1.0F; - } else - { + } else { f42 = 0.0F; f45 = 0.0F; f47 = 0.0F; @@ -664,24 +616,19 @@ public class ModelPony extends ModelBase float f57 = 9F - f51; float f59 = 0.0F - f53; float f61 = 0.5F * f1; - for(int k5 = 0; k5 < Tail.length; k5++) - { + for (int k5 = 0; k5 < Tail.length; k5++) { Tail[k5].rotationPointX = f55; Tail[k5].rotationPointY = f57; Tail[k5].rotationPointZ = f59; - if(rainboom) - { + if (rainboom) { Tail[k5].rotateAngleX = 1.571F + 0.1F * MathHelper.sin(f); - } else - { + } else { Tail[k5].rotateAngleX = f61; } } - for(int l5 = 0; l5 < Tail.length; l5++) - { - if(!rainboom) - { + for (int l5 = 0; l5 < Tail.length; l5++) { + if (!rainboom) { Tail[l5].rotateAngleX += f39; } } @@ -699,10 +646,8 @@ public class ModelPony extends ModelBase Bodypiece[10].rotateAngleX = Bodypiece[10].rotateAngleX + 0.5F; Bodypiece[11].rotateAngleX = Bodypiece[11].rotateAngleX + 0.5F; Bodypiece[12].rotateAngleX = Bodypiece[12].rotateAngleX + 0.5F; - if(rainboom) - { - for(int j1 = 0; j1 < Tail.length; j1++) - { + if (rainboom) { + for (int j1 = 0; j1 < Tail.length; j1++) { Tail[j1].rotationPointY = Tail[j1].rotationPointY + 6F; Tail[j1].rotationPointZ = Tail[j1].rotationPointZ + 1.0F; } @@ -769,8 +714,7 @@ public class ModelPony extends ModelBase // } // // } - if(isSleeping) - { + if (isSleeping) { RightArm.rotationPointZ = RightArm.rotationPointZ + 6F; LeftArm.rotationPointZ = LeftArm.rotationPointZ + 6F; RightLeg.rotationPointZ = RightLeg.rotationPointZ - 8F; @@ -780,10 +724,8 @@ public class ModelPony extends ModelBase RightLeg.rotationPointY = RightLeg.rotationPointY + 2.0F; LeftLeg.rotationPointY = LeftLeg.rotationPointY + 2.0F; } - if(aimedBow) - { - if(isUnicorn) - { + if (aimedBow) { + if (isUnicorn) { float f20 = 0.0F; float f26 = 0.0F; unicornarm.rotateAngleZ = 0.0F; @@ -793,8 +735,7 @@ public class ModelPony extends ModelBase float f31 = f2; unicornarm.rotateAngleZ += MathHelper.cos(f31 * 0.09F) * 0.05F + 0.05F; unicornarm.rotateAngleX += MathHelper.sin(f31 * 0.067F) * 0.05F; - } else - { + } else { float f21 = 0.0F; float f27 = 0.0F; RightArm.rotateAngleZ = 0.0F; @@ -810,66 +751,59 @@ public class ModelPony extends ModelBase } @Override - public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) - { - EntityNpcPony pony = (EntityNpcPony) entity; - if(pony.textureLocation != pony.checked && pony.textureLocation != null){ - try { - IResource resource = Minecraft.getMinecraft().getResourceManager().getResource(pony.textureLocation); - BufferedImage bufferedimage = ImageIO.read(resource.getInputStream()); + public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) { + EntityNpcPony pony = (EntityNpcPony) entity; + if (pony.textureLocation != pony.checked && pony.textureLocation != null) { + try { + IResource resource = Minecraft.getMinecraft().getResourceManager().getResource(pony.textureLocation); + BufferedImage bufferedimage = ImageIO.read(resource.getInputStream()); - pony.isPegasus = false; - pony.isUnicorn = false; - Color color = new Color(bufferedimage.getRGB(0, 0), true); - Color color1 = new Color(249, 177, 49, 255); - Color color2 = new Color(136, 202, 240, 255); - Color color3 = new Color(209, 159, 228, 255); - Color color4 = new Color(254, 249, 252, 255); - if(color.equals(color1)) - { - } - if(color.equals(color2)) - { - pony.isPegasus = true; - } - if(color.equals(color3)) - { - pony.isUnicorn = true; - } - if(color.equals(color4)) - { - pony.isPegasus = true; - pony.isUnicorn = true; - } - pony.checked = pony.textureLocation; - - } catch (IOException e) { - - } - } - isSleeping = pony.isPlayerSleeping(); + pony.isPegasus = false; + pony.isUnicorn = false; + Color color = new Color(bufferedimage.getRGB(0, 0), true); + Color color1 = new Color(249, 177, 49, 255); + Color color2 = new Color(136, 202, 240, 255); + Color color3 = new Color(209, 159, 228, 255); + Color color4 = new Color(254, 249, 252, 255); + if (color.equals(color1)) { + } + if (color.equals(color2)) { + pony.isPegasus = true; + } + if (color.equals(color3)) { + pony.isUnicorn = true; + } + if (color.equals(color4)) { + pony.isPegasus = true; + pony.isUnicorn = true; + } + pony.checked = pony.textureLocation; + + } catch (IOException e) { + + } + } + isSleeping = pony.isPlayerSleeping(); isUnicorn = pony.isUnicorn; isPegasus = pony.isPegasus; isSneak = pony.isSneaking(); heldItemRight = pony.getHeldItem() == null ? 0 : 1; setRotationAngles(f, f1, f2, f3, f4, f5, entity); GL11.glPushMatrix(); - if(isSleeping){ - GL11.glRotatef(90, 1, 0, 0); - GL11.glTranslatef(0f, -0.5f, -0.9f); + if (isSleeping) { + GL11.glRotatef(90, 1, 0, 0); + GL11.glTranslatef(0f, -0.5f, -0.9f); } - float scale = f5; + float scale = f5; Head.render(scale); Headpiece[0].render(scale); Headpiece[1].render(scale); - if(isUnicorn) - { + if (isUnicorn) { Headpiece[2].render(scale); } Helmet.render(scale); Body.render(scale); - for(int i = 0; i < Bodypiece.length; i++) - { + for (int i = 0; i < Bodypiece.length; i++) { Bodypiece[i].render(scale); } @@ -877,34 +811,26 @@ public class ModelPony extends ModelBase RightArm.render(scale); LeftLeg.render(scale); RightLeg.render(scale); - for(int j = 0; j < Tail.length; j++) - { + for (int j = 0; j < Tail.length; j++) { Tail[j].render(scale); } - if(isPegasus) - { - if(isFlying || isSneak) - { - for(int k = 0; k < LeftWingExt.length; k++) - { + if (isPegasus) { + if (isFlying || isSneak) { + for (int k = 0; k < LeftWingExt.length; k++) { LeftWingExt[k].render(scale); } - for(int l = 0; l < RightWingExt.length; l++) - { + for (int l = 0; l < RightWingExt.length; l++) { RightWingExt[l].render(scale); } - } else - { - for(int i1 = 0; i1 < LeftWing.length; i1++) - { + } else { + for (int i1 = 0; i1 < LeftWing.length; i1++) { LeftWing[i1].render(scale); } - for(int j1 = 0; j1 < RightWing.length; j1++) - { + for (int j1 = 0; j1 < RightWing.length; j1++) { RightWing[j1].render(scale); } @@ -913,20 +839,17 @@ public class ModelPony extends ModelBase GL11.glPopMatrix(); } - protected void renderGlow(RenderManager rendermanager, EntityPlayer entityplayer) - { + protected void renderGlow(RenderManager rendermanager, EntityPlayer entityplayer) { ItemStack itemstack = entityplayer.inventory.getCurrentItem(); - if(itemstack == null) - { + if (itemstack == null) { return; - } else - { + } else { GL11.glPushMatrix(); double d = entityplayer.posX; double d1 = entityplayer.posY; double d2 = entityplayer.posZ; GL11.glEnable(32826 /*GL_RESCALE_NORMAL_EXT*/); - GL11.glTranslatef((float)d + 0.0F, (float)d1 + 2.3F, (float)d2); + GL11.glTranslatef((float) d + 0.0F, (float) d1 + 2.3F, (float) d2); GL11.glScalef(5F, 5F, 5F); GL11.glRotatef(-rendermanager.playerViewY, 0.0F, 1.0F, 0.0F); GL11.glRotatef(rendermanager.playerViewX, 1.0F, 0.0F, 0.0F); diff --git a/src/main/java/noppes/npcs/client/model/ModelPonyArmor.java b/src/main/java/noppes/npcs/client/model/ModelPonyArmor.java index 33333e00f..cd7103e1a 100644 --- a/src/main/java/noppes/npcs/client/model/ModelPonyArmor.java +++ b/src/main/java/noppes/npcs/client/model/ModelPonyArmor.java @@ -7,8 +7,7 @@ import net.minecraft.util.MathHelper; import noppes.npcs.constants.EnumAnimation; import noppes.npcs.entity.EntityNPCInterface; -public class ModelPonyArmor extends ModelBase -{ +public class ModelPonyArmor extends ModelBase { private boolean rainboom; public ModelRenderer head; @@ -31,13 +30,11 @@ public class ModelPonyArmor extends ModelBase public boolean aimedBow; public int heldItemRight; - public ModelPonyArmor(float f) - { - init(f,0.0f); + public ModelPonyArmor(float f) { + init(f, 0.0f); } - public void init(float strech,float f) - { + public void init(float strech, float f) { float f2 = 0.0F; float f3 = 0.0F; float f4 = 0.0F; @@ -83,23 +80,20 @@ public class ModelPonyArmor extends ModelBase LeftLeg2.setRotationPoint(3F, 0.0F + f, 0.0F); } - public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5, Entity entity) - { - EntityNPCInterface npc = (EntityNPCInterface) entity; - if(!isRiding) - isRiding = npc.currentAnimation == EnumAnimation.SITTING; - - if(isSneak && (npc.currentAnimation == EnumAnimation.CRAWLING || npc.currentAnimation == EnumAnimation.LYING)) - isSneak = false; + public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5, Entity entity) { + EntityNPCInterface npc = (EntityNPCInterface) entity; + if (!isRiding) + isRiding = npc.currentAnimation == EnumAnimation.SITTING; + + if (isSneak && (npc.currentAnimation == EnumAnimation.CRAWLING || npc.currentAnimation == EnumAnimation.LYING)) + isSneak = false; rainboom = false; float f6; float f7; - if(isSleeping) - { + if (isSleeping) { f6 = 1.4F; f7 = 0.1F; - } else - { + } else { f6 = f3 / 57.29578F; f7 = f4 / 57.29578F; } @@ -109,8 +103,7 @@ public class ModelPonyArmor extends ModelBase float f9; float f10; float f11; - if(!isFlying || !isPegasus) - { + if (!isFlying || !isPegasus) { f8 = MathHelper.cos(f * 0.6662F + 3.141593F) * 0.6F * f1; f9 = MathHelper.cos(f * 0.6662F) * 0.6F * f1; f10 = MathHelper.cos(f * 0.6662F) * 0.3F * f1; @@ -123,17 +116,14 @@ public class ModelPonyArmor extends ModelBase LeftArm2.rotateAngleY = 0.0F; RightLeg2.rotateAngleY = 0.0F; LeftLeg2.rotateAngleY = 0.0F; - } else - { - if(f1 < 0.9999F) - { + } else { + if (f1 < 0.9999F) { rainboom = false; f8 = MathHelper.sin(0.0F - f1 * 0.5F); f9 = MathHelper.sin(0.0F - f1 * 0.5F); f10 = MathHelper.sin(f1 * 0.5F); f11 = MathHelper.sin(f1 * 0.5F); - } else - { + } else { rainboom = true; f8 = 4.712F; f9 = 4.712F; @@ -149,8 +139,7 @@ public class ModelPonyArmor extends ModelBase RightLeg2.rotateAngleY = -0.2F; LeftLeg2.rotateAngleY = 0.2F; } - if(isSleeping) - { + if (isSleeping) { f8 = 4.712F; f9 = 4.712F; f10 = 1.571F; @@ -168,37 +157,31 @@ public class ModelPonyArmor extends ModelBase LeftLeg2.rotateAngleX = f11; rightarm2.rotateAngleZ = 0.0F; LeftArm2.rotateAngleZ = 0.0F; - if(heldItemRight != 0 && !rainboom && !isUnicorn) - { + if (heldItemRight != 0 && !rainboom && !isUnicorn) { rightarm.rotateAngleX = rightarm.rotateAngleX * 0.5F - 0.3141593F; rightarm2.rotateAngleX = rightarm2.rotateAngleX * 0.5F - 0.3141593F; } float f12 = 0.0F; - if(f5 > -9990F && !isUnicorn) - { + if (f5 > -9990F && !isUnicorn) { f12 = MathHelper.sin(MathHelper.sqrt_float(f5) * 3.141593F * 2.0F) * 0.2F; } - Body.rotateAngleY = (float)((double)f12 * 0.20000000000000001D); - BodyBack.rotateAngleY = (float)((double)f12 * 0.20000000000000001D); + Body.rotateAngleY = (float) ((double) f12 * 0.20000000000000001D); + BodyBack.rotateAngleY = (float) ((double) f12 * 0.20000000000000001D); float f13 = MathHelper.sin(Body.rotateAngleY) * 5F; float f14 = MathHelper.cos(Body.rotateAngleY) * 5F; float f15 = 4F; - if(isSneak && !isFlying) - { + if (isSneak && !isFlying) { f15 = 0.0F; } - if(isSleeping) - { + if (isSleeping) { f15 = 2.6F; } - if(rainboom) - { + if (rainboom) { rightarm.rotationPointZ = f13 + 2.0F; rightarm2.rotationPointZ = f13 + 2.0F; LeftArm.rotationPointZ = (0.0F - f13) + 2.0F; LeftArm2.rotationPointZ = (0.0F - f13) + 2.0F; - } else - { + } else { rightarm.rotationPointZ = f13 + 1.0F; rightarm2.rotationPointZ = f13 + 1.0F; LeftArm.rotationPointZ = (0.0F - f13) + 1.0F; @@ -226,8 +209,7 @@ public class ModelPonyArmor extends ModelBase LeftArm2.rotationPointY = 8F; RightLeg2.rotationPointY = 4F; LeftLeg2.rotationPointY = 4F; - if(f5 > -9990F && !isUnicorn) - { + if (f5 > -9990F && !isUnicorn) { float f16 = f5; f16 = 1.0F - f5; f16 *= f16 * f16; @@ -242,8 +224,7 @@ public class ModelPonyArmor extends ModelBase // rightarm2.rotateAngleY += Body.rotateAngleY * 2.0F; // rightarm2.rotateAngleZ = f26 * -0.4F; } - if(isSneak && !isFlying) - { + if (isSneak && !isFlying) { float f17 = 0.4F; float f22 = 7F; float f27 = -4F; @@ -272,13 +253,11 @@ public class ModelPonyArmor extends ModelBase float f31; float f33; float f35; - if(isSleeping) - { + if (isSleeping) { f31 = 2.0F; f33 = -1F; f35 = 1.0F; - } else - { + } else { f31 = 6F; f33 = -2F; f35 = 0.0F; @@ -286,8 +265,7 @@ public class ModelPonyArmor extends ModelBase head.rotationPointY = f31; head.rotationPointZ = f33; head.rotationPointX = f35; - } else - { + } else { float f18 = 0.0F; float f23 = 0.0F; float f28 = 0.0F; @@ -339,8 +317,7 @@ public class ModelPonyArmor extends ModelBase // RightLeg2.rotationPointY = RightLeg2.rotationPointY + f19; // RightLeg2.rotationPointZ = RightLeg2.rotationPointZ + f24; // } - if(isSleeping) - { + if (isSleeping) { rightarm.rotationPointZ = rightarm.rotationPointZ + 6F; LeftArm.rotationPointZ = LeftArm.rotationPointZ + 6F; RightLeg.rotationPointZ = RightLeg.rotationPointZ - 8F; @@ -358,8 +335,7 @@ public class ModelPonyArmor extends ModelBase RightLeg2.rotationPointY = RightLeg2.rotationPointY + 2.0F; LeftLeg2.rotationPointY = LeftLeg2.rotationPointY + 2.0F; } - if(aimedBow && !isUnicorn) - { + if (aimedBow && !isUnicorn) { float f20 = 0.0F; float f25 = 0.0F; rightarm.rotateAngleZ = 0.0F; @@ -380,22 +356,21 @@ public class ModelPonyArmor extends ModelBase } } - public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) - { - float scale = f5; + public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) { + float scale = f5; setRotationAngles(f, f1, f2, f3, f4, f5, entity); - head.render(scale); - Body.render(scale); - BodyBack.render(scale); - LeftArm.render(scale); - rightarm.render(scale); - LeftLeg.render(scale); - RightLeg.render(scale); - LeftArm2.render(scale); - rightarm2.render(scale); - LeftLeg2.render(scale); - RightLeg2.render(scale); - + head.render(scale); + Body.render(scale); + BodyBack.render(scale); + LeftArm.render(scale); + rightarm.render(scale); + LeftLeg.render(scale); + RightLeg.render(scale); + LeftArm2.render(scale); + rightarm2.render(scale); + LeftLeg2.render(scale); + RightLeg2.render(scale); + } } diff --git a/src/main/java/noppes/npcs/client/model/ModelSkirtArmor.java b/src/main/java/noppes/npcs/client/model/ModelSkirtArmor.java index 39b9754ab..539dbc8a2 100644 --- a/src/main/java/noppes/npcs/client/model/ModelSkirtArmor.java +++ b/src/main/java/noppes/npcs/client/model/ModelSkirtArmor.java @@ -8,48 +8,48 @@ import noppes.npcs.client.model.util.ModelPlaneRenderer; import org.lwjgl.opengl.GL11; public class ModelSkirtArmor extends ModelBiped { - private ModelPlaneRenderer Shape1; - public ModelSkirtArmor() { - float pi = (float) (Math.PI / 5); + private ModelPlaneRenderer Shape1; - Shape1 = new ModelPlaneRenderer(this, 4, 20); - Shape1.addSidePlane(0, 0, 0, 9, 2); - - ModelPlaneRenderer part1 = new ModelPlaneRenderer(this, 6, 20); - part1.addSidePlane(2, 0, 0, 9, 2); - part1.rotateAngleY = -(float) (Math.PI/2); - Shape1.addChild(part1); + public ModelSkirtArmor() { + float pi = (float) (Math.PI / 5); - Shape1.setRotationPoint(2.4F, 8.8F, 0F); - setRotation(Shape1, 0.3F, -0.2f, -0.2F); - } + Shape1 = new ModelPlaneRenderer(this, 4, 20); + Shape1.addSidePlane(0, 0, 0, 9, 2); - public void setRotation(ModelRenderer model, float x, float y, float z) { - model.rotateAngleX = x; - model.rotateAngleY = y; - model.rotateAngleZ = z; - } + ModelPlaneRenderer part1 = new ModelPlaneRenderer(this, 6, 20); + part1.addSidePlane(2, 0, 0, 9, 2); + part1.rotateAngleY = -(float) (Math.PI / 2); + Shape1.addChild(part1); - public void render(Entity par1Entity, float par2, float par3, float par4, float par5, float par6, float par7) - { + Shape1.setRotationPoint(2.4F, 8.8F, 0F); + setRotation(Shape1, 0.3F, -0.2f, -0.2F); + } + + public void setRotation(ModelRenderer model, float x, float y, float z) { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } + + public void render(Entity par1Entity, float par2, float par3, float par4, float par5, float par6, float par7) { this.setRotationAngles(par2, par3, par4, par5, par6, par7, par1Entity); - GL11.glPushMatrix(); + GL11.glPushMatrix(); GL11.glTranslatef(0, 0, this.bipedRightLeg.rotationPointZ * par7); - GL11.glScalef(1.6f, 1.04f, 1.6f); - for(int i = 0; i < 10; i++){ - GL11.glRotatef(36, 0, 1, 0); - Shape1.render(par7); - } - GL11.glPopMatrix(); + GL11.glScalef(1.6f, 1.04f, 1.6f); + for (int i = 0; i < 10; i++) { + GL11.glRotatef(36, 0, 1, 0); + Shape1.render(par7); + } + GL11.glPopMatrix(); } - public void setRotationAngles(float par1, float par2, float par3, float par4, float par5, float par6, Entity par7Entity) - { - setRotation(Shape1, 0.3F, -0.2f, -0.2F); - isSneak = par7Entity.isSneaking(); - super.setRotationAngles(par1, par2, par3, par4, par5, par6, par7Entity); - Shape1.rotateAngleX += this.bipedLeftArm.rotateAngleX * 0.02f; - Shape1.rotateAngleZ += this.bipedLeftArm.rotateAngleX * 0.06f; + + public void setRotationAngles(float par1, float par2, float par3, float par4, float par5, float par6, Entity par7Entity) { + setRotation(Shape1, 0.3F, -0.2f, -0.2F); + isSneak = par7Entity.isSneaking(); + super.setRotationAngles(par1, par2, par3, par4, par5, par6, par7Entity); + Shape1.rotateAngleX += this.bipedLeftArm.rotateAngleX * 0.02f; + Shape1.rotateAngleZ += this.bipedLeftArm.rotateAngleX * 0.06f; //this.Shape1.rotateAngleX -= MathHelper.sin(par3 * 0.067F) * 0.05F; this.Shape1.rotateAngleZ -= MathHelper.cos(par3 * 0.09F) * 0.02F - 0.05F; } diff --git a/src/main/java/noppes/npcs/client/model/animation/AniCrawling.java b/src/main/java/noppes/npcs/client/model/animation/AniCrawling.java index 05c1ae3a0..ca75e8bae 100644 --- a/src/main/java/noppes/npcs/client/model/animation/AniCrawling.java +++ b/src/main/java/noppes/npcs/client/model/animation/AniCrawling.java @@ -6,26 +6,26 @@ import noppes.npcs.client.model.ModelMPM; public class AniCrawling { - public static void setRotationAngles(float par1, float par2, float par3, float par4, float par5, float par6, Entity entity, ModelMPM model){ + public static void setRotationAngles(float par1, float par2, float par3, float par4, float par5, float par6, Entity entity, ModelMPM model) { - model.bipedHead.rotateAngleZ = -par4 / (180F / (float)Math.PI); + model.bipedHead.rotateAngleZ = -par4 / (180F / (float) Math.PI); model.bipedHead.rotateAngleY = 0; - model.bipedHead.rotateAngleX = -55 / (180F / (float)Math.PI); + model.bipedHead.rotateAngleX = -55 / (180F / (float) Math.PI); model.bipedHeadwear.rotateAngleX = model.bipedHead.rotateAngleX; model.bipedHeadwear.rotateAngleY = model.bipedHead.rotateAngleY; model.bipedHeadwear.rotateAngleZ = model.bipedHead.rotateAngleZ; - - if(par2 > 0.25) - par2 = 0.25f; - float movement = MathHelper.cos(par1 * 0.8f + (float)Math.PI) * par2; - model.bipedLeftArm.rotateAngleX = 180 / (180F / (float)Math.PI) - movement * 0.25f; + if (par2 > 0.25) + par2 = 0.25f; + float movement = MathHelper.cos(par1 * 0.8f + (float) Math.PI) * par2; + + model.bipedLeftArm.rotateAngleX = 180 / (180F / (float) Math.PI) - movement * 0.25f; model.bipedLeftArm.rotateAngleY = movement * -0.46f; model.bipedLeftArm.rotateAngleZ = movement * -0.2f; model.bipedLeftArm.rotationPointY = 2 - movement * 9.0F; - - model.bipedRightArm.rotateAngleX = 180 / (180F / (float)Math.PI) + movement * 0.25f; + + model.bipedRightArm.rotateAngleX = 180 / (180F / (float) Math.PI) + movement * 0.25f; model.bipedRightArm.rotateAngleY = movement * -0.4f; model.bipedRightArm.rotateAngleZ = movement * -0.2f; model.bipedRightArm.rotationPointY = 2 + movement * 9.0F; @@ -33,17 +33,17 @@ public class AniCrawling { model.bipedBody.rotateAngleY = movement * 0.1f; model.bipedBody.rotateAngleX = 0; model.bipedBody.rotateAngleZ = movement * 0.1f; - + model.bipedLeftLeg.rotateAngleX = movement * 0.1f; model.bipedLeftLeg.rotateAngleY = movement * 0.1f; - model.bipedLeftLeg.rotateAngleZ = -7 / (180F / (float)Math.PI) - movement * 0.25f; + model.bipedLeftLeg.rotateAngleZ = -7 / (180F / (float) Math.PI) - movement * 0.25f; model.bipedLeftLeg.rotationPointY = 10.4f + movement * 9.0F; model.bipedLeftLeg.rotationPointZ = movement * 0.6f - 0.01f; model.bipedRightLeg.rotateAngleX = movement * -0.1f; model.bipedRightLeg.rotateAngleY = movement * 0.1f; - model.bipedRightLeg.rotateAngleZ = 7 / (180F / (float)Math.PI) - movement * 0.25f; + model.bipedRightLeg.rotateAngleZ = 7 / (180F / (float) Math.PI) - movement * 0.25f; model.bipedRightLeg.rotationPointY = 10.4f - movement * 9.0F; model.bipedRightLeg.rotationPointZ = movement * -0.6f - 0.01f; - } + } } diff --git a/src/main/java/noppes/npcs/client/model/animation/AniHug.java b/src/main/java/noppes/npcs/client/model/animation/AniHug.java index 0485f1f59..37a95f7d6 100644 --- a/src/main/java/noppes/npcs/client/model/animation/AniHug.java +++ b/src/main/java/noppes/npcs/client/model/animation/AniHug.java @@ -6,7 +6,7 @@ import noppes.npcs.client.model.ModelMPM; public class AniHug { - public static void setRotationAngles(float par1, float par2, float par3, float par4, float par5, float par6, Entity entity, ModelMPM base){ + public static void setRotationAngles(float par1, float par2, float par3, float par4, float par5, float par6, Entity entity, ModelMPM base) { float f6 = MathHelper.sin(base.onGround * 3.141593F); float f7 = MathHelper.sin((1.0F - (1.0F - base.onGround) * (1.0F - base.onGround)) * 3.141593F); @@ -22,5 +22,5 @@ public class AniHug { base.bipedLeftArm.rotateAngleZ -= MathHelper.cos(par3 * 0.09F) * 0.05F + 0.05F; base.bipedRightArm.rotateAngleX += MathHelper.sin(par3 * 0.067F) * 0.05F; base.bipedLeftArm.rotateAngleX -= MathHelper.sin(par3 * 0.067F) * 0.05F; - } + } } diff --git a/src/main/java/noppes/npcs/client/model/blocks/ModelAnvil.java b/src/main/java/noppes/npcs/client/model/blocks/ModelAnvil.java index 385e1839f..ba8c4a9c4 100644 --- a/src/main/java/noppes/npcs/client/model/blocks/ModelAnvil.java +++ b/src/main/java/noppes/npcs/client/model/blocks/ModelAnvil.java @@ -119,18 +119,18 @@ public class ModelAnvil extends ModelBase { cube_r8.cubeList.add(new ModelBox(cube_r8, 15, 60, -1.5F, -0.5F, -0.5F, 3, 1, 1, 0.0F)); } - @Override - public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) { - Anvil.render(f5); - Desk.render(f5); - Bucket.render(f5); - Hammer.render(f5); - Mold.render(f5); - } + @Override + public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) { + Anvil.render(f5); + Desk.render(f5); + Bucket.render(f5); + Hammer.render(f5); + Mold.render(f5); + } - public void setRotationAngle(ModelRenderer modelRenderer, float x, float y, float z) { - modelRenderer.rotateAngleX = x; - modelRenderer.rotateAngleY = y; - modelRenderer.rotateAngleZ = z; - } + public void setRotationAngle(ModelRenderer modelRenderer, float x, float y, float z) { + modelRenderer.rotateAngleX = x; + modelRenderer.rotateAngleY = y; + modelRenderer.rotateAngleZ = z; + } } diff --git a/src/main/java/noppes/npcs/client/model/blocks/ModelBeam.java b/src/main/java/noppes/npcs/client/model/blocks/ModelBeam.java index f9056e490..20258a210 100644 --- a/src/main/java/noppes/npcs/client/model/blocks/ModelBeam.java +++ b/src/main/java/noppes/npcs/client/model/blocks/ModelBeam.java @@ -5,27 +5,27 @@ import net.minecraft.client.model.ModelRenderer; import net.minecraft.entity.Entity; public class ModelBeam extends ModelBase { - ModelRenderer Bar; + ModelRenderer Bar; - public ModelBeam() { - Bar = new ModelRenderer(this, 6, 6); - Bar.addBox(0F, 0F, 0F, 5, 5, 12); - Bar.setRotationPoint(-2.5F, 13.5F, -4F); - Bar.setTextureSize(64, 32); - Bar.mirror = true; - setRotation(Bar, 0F, 0F, 0F); - } + public ModelBeam() { + Bar = new ModelRenderer(this, 6, 6); + Bar.addBox(0F, 0F, 0F, 5, 5, 12); + Bar.setRotationPoint(-2.5F, 13.5F, -4F); + Bar.setTextureSize(64, 32); + Bar.mirror = true; + setRotation(Bar, 0F, 0F, 0F); + } - public void render(Entity entity, float f, float f1, float f2, float f3, - float f4, float f5) { - super.render(entity, f, f1, f2, f3, f4, f5); - Bar.render(f5); - } + public void render(Entity entity, float f, float f1, float f2, float f3, + float f4, float f5) { + super.render(entity, f, f1, f2, f3, f4, f5); + Bar.render(f5); + } - private void setRotation(ModelRenderer model, float x, float y, float z) { - model.rotateAngleX = x; - model.rotateAngleY = y; - model.rotateAngleZ = z; - } + private void setRotation(ModelRenderer model, float x, float y, float z) { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } } diff --git a/src/main/java/noppes/npcs/client/model/blocks/ModelBigSign.java b/src/main/java/noppes/npcs/client/model/blocks/ModelBigSign.java index d265c2370..8cd21e8b0 100644 --- a/src/main/java/noppes/npcs/client/model/blocks/ModelBigSign.java +++ b/src/main/java/noppes/npcs/client/model/blocks/ModelBigSign.java @@ -3,19 +3,17 @@ package noppes.npcs.client.model.blocks; import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelRenderer; -public class ModelBigSign extends ModelBase{ +public class ModelBigSign extends ModelBase { public ModelRenderer signBoard = new ModelRenderer(this, 0, 0); - public ModelBigSign() - { + public ModelBigSign() { this.signBoard.addBox(-8.0F, -8F, -1.0F, 16, 16, 2, 0.0F); } /** * Renders the sign model through TileEntitySignRenderer */ - public void renderSign() - { + public void renderSign() { this.signBoard.render(0.0625F); } } diff --git a/src/main/java/noppes/npcs/client/model/blocks/ModelCampfire.java b/src/main/java/noppes/npcs/client/model/blocks/ModelCampfire.java index db434ec89..2859a413f 100644 --- a/src/main/java/noppes/npcs/client/model/blocks/ModelCampfire.java +++ b/src/main/java/noppes/npcs/client/model/blocks/ModelCampfire.java @@ -10,98 +10,99 @@ import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelRenderer; public class ModelCampfire extends ModelBase { - ModelRenderer Rock1; - ModelRenderer Rock2; - ModelRenderer Rock3; - ModelRenderer Rock4; - ModelRenderer Rock5; - ModelRenderer Rock6; - ModelRenderer Rock7; - ModelRenderer Rock8; - ModelRenderer Log3; - ModelRenderer Log1; - ModelRenderer Log4; - ModelRenderer Log2; + ModelRenderer Rock1; + ModelRenderer Rock2; + ModelRenderer Rock3; + ModelRenderer Rock4; + ModelRenderer Rock5; + ModelRenderer Rock6; + ModelRenderer Rock7; + ModelRenderer Rock8; + ModelRenderer Log3; + ModelRenderer Log1; + ModelRenderer Log4; + ModelRenderer Log2; - public ModelCampfire() { - Rock1 = new ModelRenderer(this, 0, 0); - Rock1.addBox(0F, 0F, 0F, 3, 2, 3); - Rock1.setRotationPoint(5F, 22F, 3F); - setRotation(Rock1, 0F, -0.7435722F, 0F); - - Rock2 = new ModelRenderer(this, 0, 0); - Rock2.addBox(0F, 0F, 0F, 3, 3, 6); - Rock2.setRotationPoint(5F, 21F, -3F); - - Rock3 = new ModelRenderer(this, 0, 0); - Rock3.addBox(0F, 0F, 0F, 5, 3, 3); - Rock3.setRotationPoint(2.5F, 21F, -8F); - setRotation(Rock3, 0F, -0.5576792F, 0F); - - Rock4 = new ModelRenderer(this, 0, 0); - Rock4.addBox(0F, 0F, 0F, 3, 2, 2); - Rock4.setRotationPoint(-2F, 22F, -7.5F); - - Rock5 = new ModelRenderer(this, 0, 0); - Rock5.addBox(0F, 0F, -2F, 7, 2, 2); - Rock5.setRotationPoint(-3.5F, 22F, 7.8F); - - Rock6 = new ModelRenderer(this, 0, 0); - Rock6.addBox(0F, 0F, 0F, 3, 3, 3); - Rock6.setRotationPoint(-5F, 21F, 3F); - setRotation(Rock6, 0F, -1.003822F, 0F); - - Rock7 = new ModelRenderer(this, 0, 0); - Rock7.addBox(0F, 0F, 0F, 4, 3, 3); - Rock7.setRotationPoint(-7F, 21F, -4.5F); - setRotation(Rock7, 0F, 0.8551081F, 0F); - - Rock8 = new ModelRenderer(this, 0, 0); - Rock8.addBox(0F, 0F, 0F, 3, 2, 6); - Rock8.setRotationPoint(-8F, 22F, -3F); - - Log3 = new ModelRenderer(this, 0, 16); - Log3.addBox(0F, 0F, 0F, 2, 9, 2); - Log3.setRotationPoint(0F, 16F, -1F); - setRotation(Log3, 0.3717861F, -1.487144F, -0.1487144F); - - Log1 = new ModelRenderer(this, 8, 21); - Log1.addBox(0F, 0F, 0F, 2, 9, 2); - Log1.setRotationPoint(0F, 16F, -1F); - setRotation(Log1, -0.1487144F, 0F, -0.3717861F); - - Log4 = new ModelRenderer(this, 0, 16); - Log4.addBox(0F, 0F, -2F, 2, 9, 2); - Log4.setRotationPoint(1F, 16F, 1F); - setRotation(Log4, -0.3346075F, 3.141593F, 0F); - - Log2 = new ModelRenderer(this, 0, 20); - Log2.addBox(0F, 0F, 0F, 2, 9, 2); - Log2.setRotationPoint(1F, 16F, -1F); - setRotation(Log2, 0.2974289F, 3.141593F, 0F); - } - public void renderRock(float f5){ - Rock1.render(f5); - Rock2.render(f5); - Rock3.render(f5); - Rock4.render(f5); - Rock5.render(f5); - Rock6.render(f5); - Rock7.render(f5); - Rock8.render(f5); - } + public ModelCampfire() { + Rock1 = new ModelRenderer(this, 0, 0); + Rock1.addBox(0F, 0F, 0F, 3, 2, 3); + Rock1.setRotationPoint(5F, 22F, 3F); + setRotation(Rock1, 0F, -0.7435722F, 0F); - public void renderLog(float f5){ - Log3.render(f5); - Log1.render(f5); - Log4.render(f5); - Log2.render(f5); - } + Rock2 = new ModelRenderer(this, 0, 0); + Rock2.addBox(0F, 0F, 0F, 3, 3, 6); + Rock2.setRotationPoint(5F, 21F, -3F); - private void setRotation(ModelRenderer model, float x, float y, float z) { - model.rotateAngleX = x; - model.rotateAngleY = y; - model.rotateAngleZ = z; - } + Rock3 = new ModelRenderer(this, 0, 0); + Rock3.addBox(0F, 0F, 0F, 5, 3, 3); + Rock3.setRotationPoint(2.5F, 21F, -8F); + setRotation(Rock3, 0F, -0.5576792F, 0F); + + Rock4 = new ModelRenderer(this, 0, 0); + Rock4.addBox(0F, 0F, 0F, 3, 2, 2); + Rock4.setRotationPoint(-2F, 22F, -7.5F); + + Rock5 = new ModelRenderer(this, 0, 0); + Rock5.addBox(0F, 0F, -2F, 7, 2, 2); + Rock5.setRotationPoint(-3.5F, 22F, 7.8F); + + Rock6 = new ModelRenderer(this, 0, 0); + Rock6.addBox(0F, 0F, 0F, 3, 3, 3); + Rock6.setRotationPoint(-5F, 21F, 3F); + setRotation(Rock6, 0F, -1.003822F, 0F); + + Rock7 = new ModelRenderer(this, 0, 0); + Rock7.addBox(0F, 0F, 0F, 4, 3, 3); + Rock7.setRotationPoint(-7F, 21F, -4.5F); + setRotation(Rock7, 0F, 0.8551081F, 0F); + + Rock8 = new ModelRenderer(this, 0, 0); + Rock8.addBox(0F, 0F, 0F, 3, 2, 6); + Rock8.setRotationPoint(-8F, 22F, -3F); + + Log3 = new ModelRenderer(this, 0, 16); + Log3.addBox(0F, 0F, 0F, 2, 9, 2); + Log3.setRotationPoint(0F, 16F, -1F); + setRotation(Log3, 0.3717861F, -1.487144F, -0.1487144F); + + Log1 = new ModelRenderer(this, 8, 21); + Log1.addBox(0F, 0F, 0F, 2, 9, 2); + Log1.setRotationPoint(0F, 16F, -1F); + setRotation(Log1, -0.1487144F, 0F, -0.3717861F); + + Log4 = new ModelRenderer(this, 0, 16); + Log4.addBox(0F, 0F, -2F, 2, 9, 2); + Log4.setRotationPoint(1F, 16F, 1F); + setRotation(Log4, -0.3346075F, 3.141593F, 0F); + + Log2 = new ModelRenderer(this, 0, 20); + Log2.addBox(0F, 0F, 0F, 2, 9, 2); + Log2.setRotationPoint(1F, 16F, -1F); + setRotation(Log2, 0.2974289F, 3.141593F, 0F); + } + + public void renderRock(float f5) { + Rock1.render(f5); + Rock2.render(f5); + Rock3.render(f5); + Rock4.render(f5); + Rock5.render(f5); + Rock6.render(f5); + Rock7.render(f5); + Rock8.render(f5); + } + + public void renderLog(float f5) { + Log3.render(f5); + Log1.render(f5); + Log4.render(f5); + Log2.render(f5); + } + + private void setRotation(ModelRenderer model, float x, float y, float z) { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } } diff --git a/src/main/java/noppes/npcs/client/model/blocks/ModelCarpentryBench.java b/src/main/java/noppes/npcs/client/model/blocks/ModelCarpentryBench.java index 6315018e2..a8f2fac47 100644 --- a/src/main/java/noppes/npcs/client/model/blocks/ModelCarpentryBench.java +++ b/src/main/java/noppes/npcs/client/model/blocks/ModelCarpentryBench.java @@ -9,90 +9,90 @@ public class ModelCarpentryBench extends ModelBase { private final ModelRenderer blueprint; private final ModelRenderer chissle; - private final ModelRenderer saw; - private final ModelRenderer bb_main; + private final ModelRenderer saw; + private final ModelRenderer bb_main; - public ModelCarpentryBench() { - textureWidth = 64; - textureHeight = 64; + public ModelCarpentryBench() { + textureWidth = 64; + textureHeight = 64; - blueprint = new ModelRenderer(this); - blueprint.setRotationPoint(-6.4564F, 9.3925F, -0.75F); - setRotationAngle(blueprint, 0.0F, -0.3054F, 0.0F); - blueprint.cubeList.add(new ModelBox(blueprint, 47, 27, -0.5436F, 0.5075F, -3.5F, 7, 0, 7, 0.0F)); + blueprint = new ModelRenderer(this); + blueprint.setRotationPoint(-6.4564F, 9.3925F, -0.75F); + setRotationAngle(blueprint, 0.0F, -0.3054F, 0.0F); + blueprint.cubeList.add(new ModelBox(blueprint, 47, 27, -0.5436F, 0.5075F, -3.5F, 7, 0, 7, 0.0F)); ModelRenderer blueprint_r1 = new ModelRenderer(this); - blueprint_r1.setRotationPoint(-0.5436F, 0.5075F, 0.0F); - blueprint.addChild(blueprint_r1); - setRotationAngle(blueprint_r1, 0.0F, 0.0F, 0.7854F); - blueprint_r1.cubeList.add(new ModelBox(blueprint_r1, 45, 27, -1.0F, 0.0F, -3.5F, 1, 0, 7, 0.0F)); + blueprint_r1.setRotationPoint(-0.5436F, 0.5075F, 0.0F); + blueprint.addChild(blueprint_r1); + setRotationAngle(blueprint_r1, 0.0F, 0.0F, 0.7854F); + blueprint_r1.cubeList.add(new ModelBox(blueprint_r1, 45, 27, -1.0F, 0.0F, -3.5F, 1, 0, 7, 0.0F)); ModelRenderer blueprint_r2 = new ModelRenderer(this); - blueprint_r2.setRotationPoint(-1.2507F, -0.1996F, 0.0F); - blueprint.addChild(blueprint_r2); - setRotationAngle(blueprint_r2, 0.0F, 0.0F, 1.9635F); - blueprint_r2.cubeList.add(new ModelBox(blueprint_r2, 43, 27, -1.0F, 0.0F, -3.5F, 1, 0, 7, 0.0F)); + blueprint_r2.setRotationPoint(-1.2507F, -0.1996F, 0.0F); + blueprint.addChild(blueprint_r2); + setRotationAngle(blueprint_r2, 0.0F, 0.0F, 1.9635F); + blueprint_r2.cubeList.add(new ModelBox(blueprint_r2, 43, 27, -1.0F, 0.0F, -3.5F, 1, 0, 7, 0.0F)); - chissle = new ModelRenderer(this); - chissle.setRotationPoint(1.356F, 18.6543F, -2.5F); - setRotationAngle(chissle, 0.0F, -0.7854F, 0.0F); - chissle.cubeList.add(new ModelBox(chissle, 17, 53, -0.356F, -0.6543F, -0.5F, 3, 1, 1, 0.0F)); + chissle = new ModelRenderer(this); + chissle.setRotationPoint(1.356F, 18.6543F, -2.5F); + setRotationAngle(chissle, 0.0F, -0.7854F, 0.0F); + chissle.cubeList.add(new ModelBox(chissle, 17, 53, -0.356F, -0.6543F, -0.5F, 3, 1, 1, 0.0F)); ModelRenderer cube_r1 = new ModelRenderer(this); - cube_r1.setRotationPoint(-1.606F, 0.3457F, 0.0F); - chissle.addChild(cube_r1); - setRotationAngle(cube_r1, 0.0F, 0.0F, -0.3927F); - cube_r1.cubeList.add(new ModelBox(cube_r1, 18, 52, -0.5F, 0.0F, -0.5F, 2, 0, 1, 0.0F)); + cube_r1.setRotationPoint(-1.606F, 0.3457F, 0.0F); + chissle.addChild(cube_r1); + setRotationAngle(cube_r1, 0.0F, 0.0F, -0.3927F); + cube_r1.cubeList.add(new ModelBox(cube_r1, 18, 52, -0.5F, 0.0F, -0.5F, 2, 0, 1, 0.0F)); - saw = new ModelRenderer(this); - saw.setRotationPoint(-2.65F, 18.5F, -2.7F); - setRotationAngle(saw, -3.096F, -0.3051F, 3.1241F); - saw.cubeList.add(new ModelBox(saw, 16, 46, -1.6F, -0.5F, 0.7F, 1, 1, 1, 0.0F)); - saw.cubeList.add(new ModelBox(saw, 16, 48, 0.4F, -0.5F, 0.7F, 1, 1, 1, 0.0F)); - saw.cubeList.add(new ModelBox(saw, 8, 36, -1.6F, 0.0F, -9.3F, 4, 0, 9, 0.0F)); - saw.cubeList.add(new ModelBox(saw, 20, 46, -1.6F, -0.5F, -0.3F, 3, 1, 1, 0.0F)); - saw.cubeList.add(new ModelBox(saw, 20, 48, -1.6F, -0.5F, 1.7F, 3, 1, 1, 0.0F)); + saw = new ModelRenderer(this); + saw.setRotationPoint(-2.65F, 18.5F, -2.7F); + setRotationAngle(saw, -3.096F, -0.3051F, 3.1241F); + saw.cubeList.add(new ModelBox(saw, 16, 46, -1.6F, -0.5F, 0.7F, 1, 1, 1, 0.0F)); + saw.cubeList.add(new ModelBox(saw, 16, 48, 0.4F, -0.5F, 0.7F, 1, 1, 1, 0.0F)); + saw.cubeList.add(new ModelBox(saw, 8, 36, -1.6F, 0.0F, -9.3F, 4, 0, 9, 0.0F)); + saw.cubeList.add(new ModelBox(saw, 20, 46, -1.6F, -0.5F, -0.3F, 3, 1, 1, 0.0F)); + saw.cubeList.add(new ModelBox(saw, 20, 48, -1.6F, -0.5F, 1.7F, 3, 1, 1, 0.0F)); - bb_main = new ModelRenderer(this); - bb_main.setRotationPoint(0.0F, 24.0F, 0.0F); - bb_main.cubeList.add(new ModelBox(bb_main, 8, 50, 3.0F, -12.0F, -6.0F, 2, 12, 2, 0.0F)); - bb_main.cubeList.add(new ModelBox(bb_main, 0, 50, -7.0F, -12.0F, -6.0F, 2, 12, 2, 0.0F)); - bb_main.cubeList.add(new ModelBox(bb_main, 0, 36, -7.0F, -12.0F, 4.0F, 2, 12, 2, 0.0F)); - bb_main.cubeList.add(new ModelBox(bb_main, 8, 36, 3.0F, -12.0F, 4.0F, 2, 12, 2, 0.0F)); - bb_main.cubeList.add(new ModelBox(bb_main, 0, 0, -9.0F, -14.0F, -7.0F, 16, 2, 14, 0.0F)); - bb_main.cubeList.add(new ModelBox(bb_main, 0, 16, -9.0F, -17.0F, 5.0F, 16, 3, 2, 0.0F)); - bb_main.cubeList.add(new ModelBox(bb_main, 0, 24, -6.0F, -5.0F, -5.0F, 10, 1, 10, 0.0F)); - bb_main.cubeList.add(new ModelBox(bb_main, 46, 17, 8.0F, -14.0F, -4.0F, 2, 3, 7, 0.0F)); - bb_main.cubeList.add(new ModelBox(bb_main, 29, 16, 6.0F, -12.0F, -4.0F, 2, 1, 7, 0.0F)); + bb_main = new ModelRenderer(this); + bb_main.setRotationPoint(0.0F, 24.0F, 0.0F); + bb_main.cubeList.add(new ModelBox(bb_main, 8, 50, 3.0F, -12.0F, -6.0F, 2, 12, 2, 0.0F)); + bb_main.cubeList.add(new ModelBox(bb_main, 0, 50, -7.0F, -12.0F, -6.0F, 2, 12, 2, 0.0F)); + bb_main.cubeList.add(new ModelBox(bb_main, 0, 36, -7.0F, -12.0F, 4.0F, 2, 12, 2, 0.0F)); + bb_main.cubeList.add(new ModelBox(bb_main, 8, 36, 3.0F, -12.0F, 4.0F, 2, 12, 2, 0.0F)); + bb_main.cubeList.add(new ModelBox(bb_main, 0, 0, -9.0F, -14.0F, -7.0F, 16, 2, 14, 0.0F)); + bb_main.cubeList.add(new ModelBox(bb_main, 0, 16, -9.0F, -17.0F, 5.0F, 16, 3, 2, 0.0F)); + bb_main.cubeList.add(new ModelBox(bb_main, 0, 24, -6.0F, -5.0F, -5.0F, 10, 1, 10, 0.0F)); + bb_main.cubeList.add(new ModelBox(bb_main, 46, 17, 8.0F, -14.0F, -4.0F, 2, 3, 7, 0.0F)); + bb_main.cubeList.add(new ModelBox(bb_main, 29, 16, 6.0F, -12.0F, -4.0F, 2, 1, 7, 0.0F)); ModelRenderer cube_r2 = new ModelRenderer(this); - cube_r2.setRotationPoint(10.5F, -12.5F, -0.5F); - bb_main.addChild(cube_r2); - setRotationAngle(cube_r2, 0.7854F, 0.0F, 0.0F); - cube_r2.cubeList.add(new ModelBox(cube_r2, 47, 17, -1.0F, -0.5F, -0.5F, 1, 1, 1, 0.0F)); - cube_r2.cubeList.add(new ModelBox(cube_r2, 41, 17, 0.0F, -0.5F, -1.5F, 1, 1, 3, 0.0F)); + cube_r2.setRotationPoint(10.5F, -12.5F, -0.5F); + bb_main.addChild(cube_r2); + setRotationAngle(cube_r2, 0.7854F, 0.0F, 0.0F); + cube_r2.cubeList.add(new ModelBox(cube_r2, 47, 17, -1.0F, -0.5F, -0.5F, 1, 1, 1, 0.0F)); + cube_r2.cubeList.add(new ModelBox(cube_r2, 41, 17, 0.0F, -0.5F, -1.5F, 1, 1, 3, 0.0F)); ModelRenderer hammer_r1 = new ModelRenderer(this); - hammer_r1.setRotationPoint(4.75F, -14.9F, 1.0F); - bb_main.addChild(hammer_r1); - setRotationAngle(hammer_r1, 2.9697F, -0.7703F, -2.8972F); - hammer_r1.cubeList.add(new ModelBox(hammer_r1, 44, 39, -2.75F, -0.5F, -0.5F, 3, 1, 1, 0.0F)); - hammer_r1.cubeList.add(new ModelBox(hammer_r1, 52, 35, 0.25F, -1.0F, -2.0F, 2, 2, 4, 0.0F)); - } + hammer_r1.setRotationPoint(4.75F, -14.9F, 1.0F); + bb_main.addChild(hammer_r1); + setRotationAngle(hammer_r1, 2.9697F, -0.7703F, -2.8972F); + hammer_r1.cubeList.add(new ModelBox(hammer_r1, 44, 39, -2.75F, -0.5F, -0.5F, 3, 1, 1, 0.0F)); + hammer_r1.cubeList.add(new ModelBox(hammer_r1, 52, 35, 0.25F, -1.0F, -2.0F, 2, 2, 4, 0.0F)); + } - @Override - public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) { + @Override + public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) { super.render(entity, f, f1, f2, f3, f4, f5); - setRotationAngles(f, f1, f2, f3, f4, f5,entity); - blueprint.render(f5); - chissle.render(f5); - saw.render(f5); - bb_main.render(f5); - } + setRotationAngles(f, f1, f2, f3, f4, f5, entity); + blueprint.render(f5); + chissle.render(f5); + saw.render(f5); + bb_main.render(f5); + } - public void setRotationAngle(ModelRenderer modelRenderer, float x, float y, float z) { - modelRenderer.rotateAngleX = x; - modelRenderer.rotateAngleY = y; - modelRenderer.rotateAngleZ = z; - } + public void setRotationAngle(ModelRenderer modelRenderer, float x, float y, float z) { + modelRenderer.rotateAngleX = x; + modelRenderer.rotateAngleY = y; + modelRenderer.rotateAngleZ = z; + } } diff --git a/src/main/java/noppes/npcs/client/model/blocks/ModelCrate.java b/src/main/java/noppes/npcs/client/model/blocks/ModelCrate.java index 9e179ca9b..fb6437f5f 100644 --- a/src/main/java/noppes/npcs/client/model/blocks/ModelCrate.java +++ b/src/main/java/noppes/npcs/client/model/blocks/ModelCrate.java @@ -5,139 +5,139 @@ import net.minecraft.client.model.ModelRenderer; import net.minecraft.entity.Entity; public class ModelCrate extends ModelBase { - ModelRenderer sticky1; - ModelRenderer sticky2; - ModelRenderer sticky3; - ModelRenderer sticky4; - ModelRenderer core; - ModelRenderer sticky1top; - ModelRenderer sticky2top; - ModelRenderer sticky3top; - ModelRenderer sticky4top; - ModelRenderer sidestick2; - ModelRenderer sidestick3; - ModelRenderer sidestick1; - ModelRenderer sidestick4; - ModelRenderer sidestuff2; - ModelRenderer sidestuff1; - ModelRenderer sidestuff3; - ModelRenderer sidestuff4; - ModelRenderer Shape1; - ModelRenderer Shape2; + ModelRenderer sticky1; + ModelRenderer sticky2; + ModelRenderer sticky3; + ModelRenderer sticky4; + ModelRenderer core; + ModelRenderer sticky1top; + ModelRenderer sticky2top; + ModelRenderer sticky3top; + ModelRenderer sticky4top; + ModelRenderer sidestick2; + ModelRenderer sidestick3; + ModelRenderer sidestick1; + ModelRenderer sidestick4; + ModelRenderer sidestuff2; + ModelRenderer sidestuff1; + ModelRenderer sidestuff3; + ModelRenderer sidestuff4; + ModelRenderer Shape1; + ModelRenderer Shape2; - public ModelCrate() { - sticky1 = new ModelRenderer(this, 0, 0); - sticky1.addBox(0F, 0F, 0F, 2, 2, 12); - sticky1.setRotationPoint(6F, 22F, -6F); - - sticky2 = new ModelRenderer(this, 0, 0); - sticky2.addBox(0F, 0F, 0F, 12, 2, 2); - sticky2.setRotationPoint(-6F, 22F, -8F); - - sticky3 = new ModelRenderer(this, 0, 0); - sticky3.addBox(0F, 0F, 0F, 2, 2, 12); - sticky3.setRotationPoint(-8F, 22F, -6F); - - sticky4 = new ModelRenderer(this, 32, 0); - sticky4.addBox(0F, 0F, 0F, 12, 2, 2); - sticky4.setRotationPoint(-6F, 22F, 6F); - - core = new ModelRenderer(this, 0, 0); - core.addBox(-8F, 0, -8F, 16, 16, 16, -1f); - core.setRotationPoint(0, 8F, 0); - - sticky1top = new ModelRenderer(this, 0, 0); - sticky1top.addBox(0F, 0F, 0F, 2, 2, 12); - sticky1top.setRotationPoint(6F, 8F, -6F); - - sticky2top = new ModelRenderer(this, 0, 0); - sticky2top.addBox(0F, 0F, 0F, 12, 2, 2); - sticky2top.setRotationPoint(-6F, 8F, 6F); - - sticky3top = new ModelRenderer(this, 0, 0); - sticky3top.addBox(0F, 0F, 0F, 2, 2, 12); - sticky3top.setRotationPoint(-8F, 8F, -6F); - - sticky4top = new ModelRenderer(this, 0, 0); - sticky4top.addBox(0F, 0F, 0F, 12, 2, 2); - sticky4top.setRotationPoint(-6F, 8F, -8F); - - sidestick1 = new ModelRenderer(this, 0, 0); - sidestick1.addBox(0F, 0F, 0F, 2, 16, 2); - sidestick1.setRotationPoint(-8F, 8F, 6F); - - sidestick2 = new ModelRenderer(this, 0, 0); - sidestick2.addBox(0F, 0F, 0F, 2, 16, 2); - sidestick2.setRotationPoint(6F, 8F, 6F); - - sidestick3 = new ModelRenderer(this, 0, 0); - sidestick3.addBox(0F, 0F, 0F, 2, 16, 2); - sidestick3.setRotationPoint(-8F, 8F, -8F); - - sidestick4 = new ModelRenderer(this, 0, 0); - sidestick4.addBox(0F, 0F, 0F, 2, 16, 2); - sidestick4.setRotationPoint(6F, 8F, -8F); - - sidestuff1 = new ModelRenderer(this, 0, 0); - sidestuff1.addBox(0F, 1F, 0F, 1, 18, 2); - sidestuff1.setRotationPoint(6F, 8.5F, -6.5F); - setRotation(sidestuff1, -0.7853982F, 1.570796F, 0F); - - sidestuff2 = new ModelRenderer(this, 0, 0); - sidestuff2.addBox(0F, -1F, 0F, 1, 18, 2); - sidestuff2.setRotationPoint(-7.5F, 9.5F, 5F); - setRotation(sidestuff2, -0.7853982F, 0F, 0F); - - sidestuff3 = new ModelRenderer(this, 0, 0); - sidestuff3.addBox(0F, 1F, 0F, 1, 18, 2); - sidestuff3.setRotationPoint(7.5F, 8.5F, -6F); - setRotation(sidestuff3, -0.7853982F, 3.141593F, 0F); - - sidestuff4 = new ModelRenderer(this, 0, 0); - sidestuff4.addBox(0F, 1F, 0F, 1, 18, 2); - sidestuff4.setRotationPoint(-6F, 8.5F, 6.5F); - setRotation(sidestuff4, -0.7853982F, -1.570796F, 0F); - - Shape1 = new ModelRenderer(this, 0, 0); - Shape1.addBox(0F, 0F, 0F, 18, 1, 2); - Shape1.setRotationPoint(-5.5F, 22.5F, -7F); - setRotation(Shape1, 0F, -0.7853982F, 0F); - - Shape2 = new ModelRenderer(this, 0, 0); - Shape2.addBox(0F, 0F, 0F, 18, 1, 2); - Shape2.setRotationPoint(-5.5F, 8.5F, -7F); - setRotation(Shape2, 0F, -0.7853982F, 0F); - } + public ModelCrate() { + sticky1 = new ModelRenderer(this, 0, 0); + sticky1.addBox(0F, 0F, 0F, 2, 2, 12); + sticky1.setRotationPoint(6F, 22F, -6F); - public void render(Entity entity, float f, float f1, float f2, float f3, - float f4, float f5) { - super.render(entity, f, f1, f2, f3, f4, f5); - sticky1.render(f5); - sticky2.render(f5); - sticky3.render(f5); - sticky4.render(f5); - core.render(f5); - sticky1top.render(f5); - sticky2top.render(f5); - sticky3top.render(f5); - sticky4top.render(f5); + sticky2 = new ModelRenderer(this, 0, 0); + sticky2.addBox(0F, 0F, 0F, 12, 2, 2); + sticky2.setRotationPoint(-6F, 22F, -8F); - sidestick1.render(f5); - sidestick2.render(f5); - sidestick3.render(f5); - sidestick4.render(f5); - sidestuff1.render(f5); - sidestuff2.render(f5); - sidestuff3.render(f5); - sidestuff4.render(f5); - Shape1.render(f5); - Shape2.render(f5); - } + sticky3 = new ModelRenderer(this, 0, 0); + sticky3.addBox(0F, 0F, 0F, 2, 2, 12); + sticky3.setRotationPoint(-8F, 22F, -6F); - private void setRotation(ModelRenderer model, float x, float y, float z) { - model.rotateAngleX = x; - model.rotateAngleY = y; - model.rotateAngleZ = z; - } + sticky4 = new ModelRenderer(this, 32, 0); + sticky4.addBox(0F, 0F, 0F, 12, 2, 2); + sticky4.setRotationPoint(-6F, 22F, 6F); + + core = new ModelRenderer(this, 0, 0); + core.addBox(-8F, 0, -8F, 16, 16, 16, -1f); + core.setRotationPoint(0, 8F, 0); + + sticky1top = new ModelRenderer(this, 0, 0); + sticky1top.addBox(0F, 0F, 0F, 2, 2, 12); + sticky1top.setRotationPoint(6F, 8F, -6F); + + sticky2top = new ModelRenderer(this, 0, 0); + sticky2top.addBox(0F, 0F, 0F, 12, 2, 2); + sticky2top.setRotationPoint(-6F, 8F, 6F); + + sticky3top = new ModelRenderer(this, 0, 0); + sticky3top.addBox(0F, 0F, 0F, 2, 2, 12); + sticky3top.setRotationPoint(-8F, 8F, -6F); + + sticky4top = new ModelRenderer(this, 0, 0); + sticky4top.addBox(0F, 0F, 0F, 12, 2, 2); + sticky4top.setRotationPoint(-6F, 8F, -8F); + + sidestick1 = new ModelRenderer(this, 0, 0); + sidestick1.addBox(0F, 0F, 0F, 2, 16, 2); + sidestick1.setRotationPoint(-8F, 8F, 6F); + + sidestick2 = new ModelRenderer(this, 0, 0); + sidestick2.addBox(0F, 0F, 0F, 2, 16, 2); + sidestick2.setRotationPoint(6F, 8F, 6F); + + sidestick3 = new ModelRenderer(this, 0, 0); + sidestick3.addBox(0F, 0F, 0F, 2, 16, 2); + sidestick3.setRotationPoint(-8F, 8F, -8F); + + sidestick4 = new ModelRenderer(this, 0, 0); + sidestick4.addBox(0F, 0F, 0F, 2, 16, 2); + sidestick4.setRotationPoint(6F, 8F, -8F); + + sidestuff1 = new ModelRenderer(this, 0, 0); + sidestuff1.addBox(0F, 1F, 0F, 1, 18, 2); + sidestuff1.setRotationPoint(6F, 8.5F, -6.5F); + setRotation(sidestuff1, -0.7853982F, 1.570796F, 0F); + + sidestuff2 = new ModelRenderer(this, 0, 0); + sidestuff2.addBox(0F, -1F, 0F, 1, 18, 2); + sidestuff2.setRotationPoint(-7.5F, 9.5F, 5F); + setRotation(sidestuff2, -0.7853982F, 0F, 0F); + + sidestuff3 = new ModelRenderer(this, 0, 0); + sidestuff3.addBox(0F, 1F, 0F, 1, 18, 2); + sidestuff3.setRotationPoint(7.5F, 8.5F, -6F); + setRotation(sidestuff3, -0.7853982F, 3.141593F, 0F); + + sidestuff4 = new ModelRenderer(this, 0, 0); + sidestuff4.addBox(0F, 1F, 0F, 1, 18, 2); + sidestuff4.setRotationPoint(-6F, 8.5F, 6.5F); + setRotation(sidestuff4, -0.7853982F, -1.570796F, 0F); + + Shape1 = new ModelRenderer(this, 0, 0); + Shape1.addBox(0F, 0F, 0F, 18, 1, 2); + Shape1.setRotationPoint(-5.5F, 22.5F, -7F); + setRotation(Shape1, 0F, -0.7853982F, 0F); + + Shape2 = new ModelRenderer(this, 0, 0); + Shape2.addBox(0F, 0F, 0F, 18, 1, 2); + Shape2.setRotationPoint(-5.5F, 8.5F, -7F); + setRotation(Shape2, 0F, -0.7853982F, 0F); + } + + public void render(Entity entity, float f, float f1, float f2, float f3, + float f4, float f5) { + super.render(entity, f, f1, f2, f3, f4, f5); + sticky1.render(f5); + sticky2.render(f5); + sticky3.render(f5); + sticky4.render(f5); + core.render(f5); + sticky1top.render(f5); + sticky2top.render(f5); + sticky3top.render(f5); + sticky4top.render(f5); + + sidestick1.render(f5); + sidestick2.render(f5); + sidestick3.render(f5); + sidestick4.render(f5); + sidestuff1.render(f5); + sidestuff2.render(f5); + sidestuff3.render(f5); + sidestuff4.render(f5); + Shape1.render(f5); + Shape2.render(f5); + } + + private void setRotation(ModelRenderer model, float x, float y, float z) { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } } diff --git a/src/main/java/noppes/npcs/client/model/blocks/ModelInk.java b/src/main/java/noppes/npcs/client/model/blocks/ModelInk.java index 83bdd4f63..45380956a 100644 --- a/src/main/java/noppes/npcs/client/model/blocks/ModelInk.java +++ b/src/main/java/noppes/npcs/client/model/blocks/ModelInk.java @@ -5,48 +5,48 @@ import net.minecraft.client.model.ModelRenderer; import net.minecraft.entity.Entity; public class ModelInk extends ModelBase { - ModelRenderer InkMid; - ModelRenderer InkTop; - ModelRenderer InkBottom; - ModelRenderer Shape1; - ModelRenderer InkBottom2; + ModelRenderer InkMid; + ModelRenderer InkTop; + ModelRenderer InkBottom; + ModelRenderer Shape1; + ModelRenderer InkBottom2; - public ModelInk() { - InkMid = new ModelRenderer(this, 0, 25); - InkMid.addBox(0F, 0F, 0F, 1, 1, 1); - InkMid.setRotationPoint(5F, 21F, 3.5F); - - InkTop = new ModelRenderer(this, 0, 22); - InkTop.addBox(0F, 0F, 0F, 2, 1, 2); - InkTop.setRotationPoint(4.5F, 20F, 3F); - - InkBottom = new ModelRenderer(this, 3, 16); - InkBottom.addBox(0F, 0F, 0F, 3, 1, 3); - InkBottom.setRotationPoint(4F, 22F, 2.5F); - - Shape1 = new ModelRenderer(this, 0, 0); - Shape1.addBox(0F, 0F, 0F, 0, 13, 3); - Shape1.setRotationPoint(5.5F, 10F, 2.5F); - - InkBottom2 = new ModelRenderer(this, 0, 27); - InkBottom2.addBox(0F, 0F, 0F, 3, 1, 3); - InkBottom2.setRotationPoint(4F, 23F, 2.5F); - } + public ModelInk() { + InkMid = new ModelRenderer(this, 0, 25); + InkMid.addBox(0F, 0F, 0F, 1, 1, 1); + InkMid.setRotationPoint(5F, 21F, 3.5F); - public void render(Entity entity, float f, float f1, float f2, float f3, - float f4, float f5) { - super.render(entity, f, f1, f2, f3, f4, f5); - Shape1.render(f5); - InkMid.render(f5); - InkTop.render(f5); - InkBottom2.render(f5); - InkBottom.render(f5); - } + InkTop = new ModelRenderer(this, 0, 22); + InkTop.addBox(0F, 0F, 0F, 2, 1, 2); + InkTop.setRotationPoint(4.5F, 20F, 3F); - private void setRotation(ModelRenderer model, float x, float y, float z) { - model.rotateAngleX = x; - model.rotateAngleY = y; - model.rotateAngleZ = z; - } + InkBottom = new ModelRenderer(this, 3, 16); + InkBottom.addBox(0F, 0F, 0F, 3, 1, 3); + InkBottom.setRotationPoint(4F, 22F, 2.5F); + + Shape1 = new ModelRenderer(this, 0, 0); + Shape1.addBox(0F, 0F, 0F, 0, 13, 3); + Shape1.setRotationPoint(5.5F, 10F, 2.5F); + + InkBottom2 = new ModelRenderer(this, 0, 27); + InkBottom2.addBox(0F, 0F, 0F, 3, 1, 3); + InkBottom2.setRotationPoint(4F, 23F, 2.5F); + } + + public void render(Entity entity, float f, float f1, float f2, float f3, + float f4, float f5) { + super.render(entity, f, f1, f2, f3, f4, f5); + Shape1.render(f5); + InkMid.render(f5); + InkTop.render(f5); + InkBottom2.render(f5); + InkBottom.render(f5); + } + + private void setRotation(ModelRenderer model, float x, float y, float z) { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } } diff --git a/src/main/java/noppes/npcs/client/model/blocks/ModelLongCrate.java b/src/main/java/noppes/npcs/client/model/blocks/ModelLongCrate.java index e7cfbdb52..106553401 100644 --- a/src/main/java/noppes/npcs/client/model/blocks/ModelLongCrate.java +++ b/src/main/java/noppes/npcs/client/model/blocks/ModelLongCrate.java @@ -5,64 +5,64 @@ import net.minecraft.client.model.ModelRenderer; import net.minecraft.entity.Entity; public class ModelLongCrate extends ModelBase { - // fields - ModelRenderer Vertical1; - ModelRenderer Horizontal1; - ModelRenderer Cratebody; - ModelRenderer Horizontal2; - ModelRenderer Vertical3; - ModelRenderer Vertical4; - ModelRenderer Vertical2; + // fields + ModelRenderer Vertical1; + ModelRenderer Horizontal1; + ModelRenderer Cratebody; + ModelRenderer Horizontal2; + ModelRenderer Vertical3; + ModelRenderer Vertical4; + ModelRenderer Vertical2; - public ModelLongCrate() { + public ModelLongCrate() { - Vertical1 = new ModelRenderer(this, 80, 0); - Vertical1.addBox(0F, 0F, 0F, 4, 13, 1); - Vertical1.setRotationPoint(-12F, 11F, 8F); - - Horizontal1 = new ModelRenderer(this, 0, 0); - Horizontal1.mirror = true; - Horizontal1.addBox(0F, 0F, 0F, 4, 1, 18); - Horizontal1.setRotationPoint(8F, 10F, -9F); - - Cratebody = new ModelRenderer(this, 8, 0); - Cratebody.addBox(-16F, 0F, -8F, 32, 13, 16); - Cratebody.setRotationPoint(0F, 11F, 0F); - - Horizontal2 = new ModelRenderer(this, 0, 0); - Horizontal2.addBox(0F, 0F, 0F, 4, 1, 18); - Horizontal2.setRotationPoint(-12F, 10F, -9F); - - Vertical3 = new ModelRenderer(this, 80, 0); - Vertical3.addBox(0F, 0F, 0F, 4, 13, 1); - Vertical3.setRotationPoint(-12F, 11F, -9F); - - Vertical4 = new ModelRenderer(this, 80, 0); - Vertical4.mirror = true; - Vertical4.addBox(0F, 0F, 0F, 4, 13, 1); - Vertical4.setRotationPoint(8F, 11F, -9F); - - Vertical2 = new ModelRenderer(this, 80, 0); - Vertical2.mirror = true; - Vertical2.addBox(0F, 0F, 0F, 4, 13, 1); - Vertical2.setRotationPoint(8F, 11F, 8F); - } + Vertical1 = new ModelRenderer(this, 80, 0); + Vertical1.addBox(0F, 0F, 0F, 4, 13, 1); + Vertical1.setRotationPoint(-12F, 11F, 8F); - public void render(Entity entity, float f, float f1, float f2, float f3, - float f4, float f5) { - super.render(entity, f, f1, f2, f3, f4, f5); - Vertical1.render(f5); - Horizontal1.render(f5); - Cratebody.render(f5); - Horizontal2.render(f5); - Vertical3.render(f5); - Vertical4.render(f5); - Vertical2.render(f5); - } + Horizontal1 = new ModelRenderer(this, 0, 0); + Horizontal1.mirror = true; + Horizontal1.addBox(0F, 0F, 0F, 4, 1, 18); + Horizontal1.setRotationPoint(8F, 10F, -9F); - private void setRotation(ModelRenderer model, float x, float y, float z) { - model.rotateAngleX = x; - model.rotateAngleY = y; - model.rotateAngleZ = z; - } + Cratebody = new ModelRenderer(this, 8, 0); + Cratebody.addBox(-16F, 0F, -8F, 32, 13, 16); + Cratebody.setRotationPoint(0F, 11F, 0F); + + Horizontal2 = new ModelRenderer(this, 0, 0); + Horizontal2.addBox(0F, 0F, 0F, 4, 1, 18); + Horizontal2.setRotationPoint(-12F, 10F, -9F); + + Vertical3 = new ModelRenderer(this, 80, 0); + Vertical3.addBox(0F, 0F, 0F, 4, 13, 1); + Vertical3.setRotationPoint(-12F, 11F, -9F); + + Vertical4 = new ModelRenderer(this, 80, 0); + Vertical4.mirror = true; + Vertical4.addBox(0F, 0F, 0F, 4, 13, 1); + Vertical4.setRotationPoint(8F, 11F, -9F); + + Vertical2 = new ModelRenderer(this, 80, 0); + Vertical2.mirror = true; + Vertical2.addBox(0F, 0F, 0F, 4, 13, 1); + Vertical2.setRotationPoint(8F, 11F, 8F); + } + + public void render(Entity entity, float f, float f1, float f2, float f3, + float f4, float f5) { + super.render(entity, f, f1, f2, f3, f4, f5); + Vertical1.render(f5); + Horizontal1.render(f5); + Cratebody.render(f5); + Horizontal2.render(f5); + Vertical3.render(f5); + Vertical4.render(f5); + Vertical2.render(f5); + } + + private void setRotation(ModelRenderer model, float x, float y, float z) { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } } diff --git a/src/main/java/noppes/npcs/client/model/blocks/ModelMailbox.java b/src/main/java/noppes/npcs/client/model/blocks/ModelMailbox.java index 7e0e0d27d..e05e47bf1 100644 --- a/src/main/java/noppes/npcs/client/model/blocks/ModelMailbox.java +++ b/src/main/java/noppes/npcs/client/model/blocks/ModelMailbox.java @@ -9,29 +9,29 @@ import net.minecraft.client.model.ModelRenderer; import net.minecraft.entity.Entity; public class ModelMailbox extends ModelBase { - private final ModelRenderer mailbox; + private final ModelRenderer mailbox; - public ModelMailbox() { - textureWidth = 64; - textureHeight = 64; + public ModelMailbox() { + textureWidth = 64; + textureHeight = 64; - mailbox = new ModelRenderer(this); - mailbox.setRotationPoint(0.0F, 24.0F, 0.0F); - mailbox.cubeList.add(new ModelBox(mailbox, 0, 0, -8.0F, -24.0F, -8.0F, 16, 20, 16, 0.0F)); - mailbox.cubeList.add(new ModelBox(mailbox, 0, 36, -8.0F, -4.0F, 6.0F, 2, 4, 2, 0.0F)); - mailbox.cubeList.add(new ModelBox(mailbox, 0, 36, 6.0F, -4.0F, 6.0F, 2, 4, 2, 0.0F)); - mailbox.cubeList.add(new ModelBox(mailbox, 0, 36, 6.0F, -4.0F, -8.0F, 2, 4, 2, 0.0F)); - mailbox.cubeList.add(new ModelBox(mailbox, 0, 36, -8.0F, -4.0F, -8.0F, 2, 4, 2, 0.0F)); - } + mailbox = new ModelRenderer(this); + mailbox.setRotationPoint(0.0F, 24.0F, 0.0F); + mailbox.cubeList.add(new ModelBox(mailbox, 0, 0, -8.0F, -24.0F, -8.0F, 16, 20, 16, 0.0F)); + mailbox.cubeList.add(new ModelBox(mailbox, 0, 36, -8.0F, -4.0F, 6.0F, 2, 4, 2, 0.0F)); + mailbox.cubeList.add(new ModelBox(mailbox, 0, 36, 6.0F, -4.0F, 6.0F, 2, 4, 2, 0.0F)); + mailbox.cubeList.add(new ModelBox(mailbox, 0, 36, 6.0F, -4.0F, -8.0F, 2, 4, 2, 0.0F)); + mailbox.cubeList.add(new ModelBox(mailbox, 0, 36, -8.0F, -4.0F, -8.0F, 2, 4, 2, 0.0F)); + } - @Override - public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) { - mailbox.render(f5); - } + @Override + public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) { + mailbox.render(f5); + } - public void setRotationAngle(ModelRenderer modelRenderer, float x, float y, float z) { - modelRenderer.rotateAngleX = x; - modelRenderer.rotateAngleY = y; - modelRenderer.rotateAngleZ = z; - } + public void setRotationAngle(ModelRenderer modelRenderer, float x, float y, float z) { + modelRenderer.rotateAngleX = x; + modelRenderer.rotateAngleY = y; + modelRenderer.rotateAngleZ = z; + } } diff --git a/src/main/java/noppes/npcs/client/model/blocks/ModelMailboxWow.java b/src/main/java/noppes/npcs/client/model/blocks/ModelMailboxWow.java index a3b048b3d..066f5ee98 100644 --- a/src/main/java/noppes/npcs/client/model/blocks/ModelMailboxWow.java +++ b/src/main/java/noppes/npcs/client/model/blocks/ModelMailboxWow.java @@ -5,39 +5,39 @@ import net.minecraft.client.model.ModelRenderer; import net.minecraft.entity.Entity; public class ModelMailboxWow extends ModelBase { - // fields - ModelRenderer Shape4; - ModelRenderer Shape1; - ModelRenderer Shape2; - ModelRenderer Shape3; + // fields + ModelRenderer Shape4; + ModelRenderer Shape1; + ModelRenderer Shape2; + ModelRenderer Shape3; - public ModelMailboxWow() { - textureWidth = 128; - textureHeight = 64; + public ModelMailboxWow() { + textureWidth = 128; + textureHeight = 64; - Shape4 = new ModelRenderer(this, 59, 0); - Shape4.addBox(0F, 0F, 0F, 8, 6, 0); - Shape4.setRotationPoint(-4F, -4F, 0F); - - Shape1 = new ModelRenderer(this, 0, 39); - Shape1.addBox(0F, 0F, 0F, 8, 5, 8); - Shape1.setRotationPoint(-4F, 19F, -4F); - - Shape2 = new ModelRenderer(this, 0, 21); - Shape2.addBox(0F, 0F, 0F, 6, 9, 6); - Shape2.setRotationPoint(-3F, 10F, -3F); - - Shape3 = new ModelRenderer(this, 0, 0); - Shape3.addBox(0F, 0F, 0F, 12, 8, 12); - Shape3.setRotationPoint(-6F, 2F, -6F); - } + Shape4 = new ModelRenderer(this, 59, 0); + Shape4.addBox(0F, 0F, 0F, 8, 6, 0); + Shape4.setRotationPoint(-4F, -4F, 0F); - public void render(Entity entity, float f, float f1, float f2, float f3, - float f4, float f5) { - super.render(entity, f, f1, f2, f3, f4, f5); - Shape4.render(f5); - Shape1.render(f5); - Shape2.render(f5); - Shape3.render(f5); - } + Shape1 = new ModelRenderer(this, 0, 39); + Shape1.addBox(0F, 0F, 0F, 8, 5, 8); + Shape1.setRotationPoint(-4F, 19F, -4F); + + Shape2 = new ModelRenderer(this, 0, 21); + Shape2.addBox(0F, 0F, 0F, 6, 9, 6); + Shape2.setRotationPoint(-3F, 10F, -3F); + + Shape3 = new ModelRenderer(this, 0, 0); + Shape3.addBox(0F, 0F, 0F, 12, 8, 12); + Shape3.setRotationPoint(-6F, 2F, -6F); + } + + public void render(Entity entity, float f, float f1, float f2, float f3, + float f4, float f5) { + super.render(entity, f, f1, f2, f3, f4, f5); + Shape4.render(f5); + Shape1.render(f5); + Shape2.render(f5); + Shape3.render(f5); + } } diff --git a/src/main/java/noppes/npcs/client/model/blocks/ModelPedestal.java b/src/main/java/noppes/npcs/client/model/blocks/ModelPedestal.java index 8431662e1..d652a341b 100644 --- a/src/main/java/noppes/npcs/client/model/blocks/ModelPedestal.java +++ b/src/main/java/noppes/npcs/client/model/blocks/ModelPedestal.java @@ -6,26 +6,26 @@ import net.minecraft.client.model.ModelRenderer; import net.minecraft.entity.Entity; public class ModelPedestal extends ModelBase { - private final ModelRenderer bb_main; + private final ModelRenderer bb_main; - public ModelPedestal() { - textureWidth = 64; - textureHeight = 64; + public ModelPedestal() { + textureWidth = 64; + textureHeight = 64; - bb_main = new ModelRenderer(this); - bb_main.setRotationPoint(0.0F, 24.0F, 0.0F); - bb_main.cubeList.add(new ModelBox(bb_main, 0, 0, -6.0F, -4.0F, -6.0F, 12, 4, 12, 0.0F)); - bb_main.cubeList.add(new ModelBox(bb_main, 0, 16, -5.0F, -5.0F, -4.0F, 10, 1, 8, 0.0F)); - } + bb_main = new ModelRenderer(this); + bb_main.setRotationPoint(0.0F, 24.0F, 0.0F); + bb_main.cubeList.add(new ModelBox(bb_main, 0, 0, -6.0F, -4.0F, -6.0F, 12, 4, 12, 0.0F)); + bb_main.cubeList.add(new ModelBox(bb_main, 0, 16, -5.0F, -5.0F, -4.0F, 10, 1, 8, 0.0F)); + } - @Override - public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) { - bb_main.render(f5); - } + @Override + public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) { + bb_main.render(f5); + } - public void setRotationAngle(ModelRenderer modelRenderer, float x, float y, float z) { - modelRenderer.rotateAngleX = x; - modelRenderer.rotateAngleY = y; - modelRenderer.rotateAngleZ = z; - } + public void setRotationAngle(ModelRenderer modelRenderer, float x, float y, float z) { + modelRenderer.rotateAngleX = x; + modelRenderer.rotateAngleY = y; + modelRenderer.rotateAngleZ = z; + } } diff --git a/src/main/java/noppes/npcs/client/model/blocks/ModelShelf.java b/src/main/java/noppes/npcs/client/model/blocks/ModelShelf.java index d0436d0bc..070fe788e 100644 --- a/src/main/java/noppes/npcs/client/model/blocks/ModelShelf.java +++ b/src/main/java/noppes/npcs/client/model/blocks/ModelShelf.java @@ -5,51 +5,51 @@ import net.minecraft.client.model.ModelRenderer; import net.minecraft.entity.Entity; public class ModelShelf extends ModelBase { - public ModelRenderer SupportLeft2; - ModelRenderer Top; - public ModelRenderer SupportLeft1; - public ModelRenderer SupportRight1; - public ModelRenderer SupportRight2; + public ModelRenderer SupportLeft2; + ModelRenderer Top; + public ModelRenderer SupportLeft1; + public ModelRenderer SupportRight1; + public ModelRenderer SupportRight2; - public ModelShelf() { - SupportLeft2 = new ModelRenderer(this, 0, 0); - SupportLeft2.mirror = true; - SupportLeft2.addBox(0F, 0F, 0F, 2, 10, 2); - SupportLeft2.setRotationPoint(-7.498F, 9.5F, -0.5F); - setRotation(SupportLeft2, 0.7853982F, 0F, 0F); - - Top = new ModelRenderer(this, 5, 0); - Top.addBox(0F, 0F, 0F, 16, 2, 11); - Top.setRotationPoint(-8F, 8F, -3F); - - SupportLeft1 = new ModelRenderer(this, 0, 0); - SupportLeft1.mirror = true; - SupportLeft1.addBox(0F, 0F, 0F, 2, 7, 2); - SupportLeft1.setRotationPoint(-7.5F, 10F, 6F); - - SupportRight1 = new ModelRenderer(this, 0, 0); - SupportRight1.addBox(0F, 0F, 0F, 2, 7, 2); - SupportRight1.setRotationPoint(5.5F, 10F, 6F); - - SupportRight2 = new ModelRenderer(this, 0, 0); - SupportRight2.addBox(0F, 0F, 0F, 2, 10, 2); - SupportRight2.setRotationPoint(5.498F, 9.5F, -0.5F); - setRotation(SupportRight2, 0.7853982F, 0F, 0F); - } + public ModelShelf() { + SupportLeft2 = new ModelRenderer(this, 0, 0); + SupportLeft2.mirror = true; + SupportLeft2.addBox(0F, 0F, 0F, 2, 10, 2); + SupportLeft2.setRotationPoint(-7.498F, 9.5F, -0.5F); + setRotation(SupportLeft2, 0.7853982F, 0F, 0F); - public void render(Entity entity, float f, float f1, float f2, float f3, - float f4, float f5) { - super.render(entity, f, f1, f2, f3, f4, f5); - SupportLeft2.render(f5); - Top.render(f5); - SupportLeft1.render(f5); - SupportRight1.render(f5); - SupportRight2.render(f5); - } + Top = new ModelRenderer(this, 5, 0); + Top.addBox(0F, 0F, 0F, 16, 2, 11); + Top.setRotationPoint(-8F, 8F, -3F); - private void setRotation(ModelRenderer model, float x, float y, float z) { - model.rotateAngleX = x; - model.rotateAngleY = y; - model.rotateAngleZ = z; - } + SupportLeft1 = new ModelRenderer(this, 0, 0); + SupportLeft1.mirror = true; + SupportLeft1.addBox(0F, 0F, 0F, 2, 7, 2); + SupportLeft1.setRotationPoint(-7.5F, 10F, 6F); + + SupportRight1 = new ModelRenderer(this, 0, 0); + SupportRight1.addBox(0F, 0F, 0F, 2, 7, 2); + SupportRight1.setRotationPoint(5.5F, 10F, 6F); + + SupportRight2 = new ModelRenderer(this, 0, 0); + SupportRight2.addBox(0F, 0F, 0F, 2, 10, 2); + SupportRight2.setRotationPoint(5.498F, 9.5F, -0.5F); + setRotation(SupportRight2, 0.7853982F, 0F, 0F); + } + + public void render(Entity entity, float f, float f1, float f2, float f3, + float f4, float f5) { + super.render(entity, f, f1, f2, f3, f4, f5); + SupportLeft2.render(f5); + Top.render(f5); + SupportLeft1.render(f5); + SupportRight1.render(f5); + SupportRight2.render(f5); + } + + private void setRotation(ModelRenderer model, float x, float y, float z) { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } } diff --git a/src/main/java/noppes/npcs/client/model/blocks/ModelSign.java b/src/main/java/noppes/npcs/client/model/blocks/ModelSign.java index 2fa43993c..0a13bb442 100644 --- a/src/main/java/noppes/npcs/client/model/blocks/ModelSign.java +++ b/src/main/java/noppes/npcs/client/model/blocks/ModelSign.java @@ -4,45 +4,42 @@ import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelRenderer; import net.minecraft.entity.Entity; -public class ModelSign extends ModelBase{ +public class ModelSign extends ModelBase { public ModelRenderer Sign; ModelRenderer Chain2; ModelRenderer Bar; ModelRenderer Chain1; - - public ModelSign() - { - Sign = new ModelRenderer(this, 0, 22); - Sign.addBox(0F, 0F, 0F, 14, 9, 1); - Sign.setRotationPoint(-7F, 12F, -0.5F); - setRotation(Sign, 0.0174533F, 0F, 0F); - - Chain2 = new ModelRenderer(this, 0, 0); - Chain2.addBox(0F, 0F, 0F, 1, 2, 2); - Chain2.setRotationPoint(5F, 11F, -1F); - - Bar = new ModelRenderer(this, 0, 0); - Bar.addBox(0F, 0F, 0F, 16, 1, 1); - Bar.setRotationPoint(-8F, 10F, -0.5F); - - Chain1 = new ModelRenderer(this, 0, 0); - Chain1.addBox(0F, 0F, 0F, 1, 2, 2); - Chain1.setRotationPoint(-6F, 11F, -1F); - } - - public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) - { - super.render(entity, f, f1, f2, f3, f4, f5); - Chain2.render(f5); - Bar.render(f5); - Chain1.render(f5); - } - - private void setRotation(ModelRenderer model, float x, float y, float z) - { - model.rotateAngleX = x; - model.rotateAngleY = y; - model.rotateAngleZ = z; - } + + public ModelSign() { + Sign = new ModelRenderer(this, 0, 22); + Sign.addBox(0F, 0F, 0F, 14, 9, 1); + Sign.setRotationPoint(-7F, 12F, -0.5F); + setRotation(Sign, 0.0174533F, 0F, 0F); + + Chain2 = new ModelRenderer(this, 0, 0); + Chain2.addBox(0F, 0F, 0F, 1, 2, 2); + Chain2.setRotationPoint(5F, 11F, -1F); + + Bar = new ModelRenderer(this, 0, 0); + Bar.addBox(0F, 0F, 0F, 16, 1, 1); + Bar.setRotationPoint(-8F, 10F, -0.5F); + + Chain1 = new ModelRenderer(this, 0, 0); + Chain1.addBox(0F, 0F, 0F, 1, 2, 2); + Chain1.setRotationPoint(-6F, 11F, -1F); + } + + public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) { + super.render(entity, f, f1, f2, f3, f4, f5); + Chain2.render(f5); + Bar.render(f5); + Chain1.render(f5); + } + + private void setRotation(ModelRenderer model, float x, float y, float z) { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } } diff --git a/src/main/java/noppes/npcs/client/model/blocks/ModelStool.java b/src/main/java/noppes/npcs/client/model/blocks/ModelStool.java index 429e5ea96..e9b7db175 100644 --- a/src/main/java/noppes/npcs/client/model/blocks/ModelStool.java +++ b/src/main/java/noppes/npcs/client/model/blocks/ModelStool.java @@ -6,9 +6,9 @@ import net.minecraft.client.model.ModelRenderer; import net.minecraft.entity.Entity; public class ModelStool extends ModelBase { - private final ModelRenderer stool; + private final ModelRenderer stool; - public ModelStool() { + public ModelStool() { textureWidth = 64; textureHeight = 32; @@ -22,16 +22,17 @@ public class ModelStool extends ModelBase { stool.cubeList.add(new ModelBox(stool, 0, 12, -4.0F, -7.0F, 2.0F, 2, 7, 2, 0.0F)); stool.cubeList.add(new ModelBox(stool, 8, 8, -3.0F, -5.0F, -2.0F, 0, 2, 4, 0.0F)); stool.cubeList.add(new ModelBox(stool, 0, 12, 2.0F, -7.0F, 2.0F, 2, 7, 2, 0.0F)); - stool.cubeList.add(new ModelBox(stool, 8, 12, -2.0F, -5.0F, 3.0F, 4, 2, 0, 0.0F)); } + stool.cubeList.add(new ModelBox(stool, 8, 12, -2.0F, -5.0F, 3.0F, 4, 2, 0, 0.0F)); + } - @Override - public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) { - stool.render(f5); - } + @Override + public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) { + stool.render(f5); + } - public void setRotationAngle(ModelRenderer modelRenderer, float x, float y, float z) { - modelRenderer.rotateAngleX = x; - modelRenderer.rotateAngleY = y; - modelRenderer.rotateAngleZ = z; - } + public void setRotationAngle(ModelRenderer modelRenderer, float x, float y, float z) { + modelRenderer.rotateAngleX = x; + modelRenderer.rotateAngleY = y; + modelRenderer.rotateAngleZ = z; + } } diff --git a/src/main/java/noppes/npcs/client/model/blocks/ModelTable.java b/src/main/java/noppes/npcs/client/model/blocks/ModelTable.java index f29345807..a0ad972f2 100644 --- a/src/main/java/noppes/npcs/client/model/blocks/ModelTable.java +++ b/src/main/java/noppes/npcs/client/model/blocks/ModelTable.java @@ -78,9 +78,9 @@ public class ModelTable extends ModelBase { Shape5.render(f5); } - public void setRotationAngle(ModelRenderer modelRenderer, float x, float y, float z) { - modelRenderer.rotateAngleX = x; - modelRenderer.rotateAngleY = y; - modelRenderer.rotateAngleZ = z; - } + public void setRotationAngle(ModelRenderer modelRenderer, float x, float y, float z) { + modelRenderer.rotateAngleX = x; + modelRenderer.rotateAngleY = y; + modelRenderer.rotateAngleZ = z; + } } diff --git a/src/main/java/noppes/npcs/client/model/blocks/ModelTombstone1.java b/src/main/java/noppes/npcs/client/model/blocks/ModelTombstone1.java index 789fa2275..50121b6e4 100644 --- a/src/main/java/noppes/npcs/client/model/blocks/ModelTombstone1.java +++ b/src/main/java/noppes/npcs/client/model/blocks/ModelTombstone1.java @@ -11,44 +11,44 @@ import net.minecraft.client.model.ModelRenderer; import net.minecraft.entity.Entity; public class ModelTombstone1 extends ModelBase { - // fields - ModelRenderer Mid; - ModelRenderer OuterEdge1; - ModelRenderer OuterEdge2; - ModelRenderer OuterEdgeTop; + // fields + ModelRenderer Mid; + ModelRenderer OuterEdge1; + ModelRenderer OuterEdge2; + ModelRenderer OuterEdgeTop; - public ModelTombstone1() { - Mid = new ModelRenderer(this, 36, 0); - Mid.addBox(0F, 0F, 0F, 10, 14, 3); - Mid.setRotationPoint(-5F, 10F, -1.5F); - - OuterEdge1 = new ModelRenderer(this, 0, 0); - OuterEdge1.addBox(0F, 0F, 0F, 2, 16, 4); - OuterEdge1.setRotationPoint(-7F, 8F, -2F); - - OuterEdge2 = new ModelRenderer(this, 0, 0); - OuterEdge2.mirror = true; - OuterEdge2.addBox(1F, 0F, 0F, 2, 16, 4); - OuterEdge2.setRotationPoint(4F, 8F, -2F); - - OuterEdgeTop = new ModelRenderer(this, 0, 22); - OuterEdgeTop.addBox(0F, 0F, 0F, 10, 2, 4); - OuterEdgeTop.setRotationPoint(-5F, 8F, -2F); - } + public ModelTombstone1() { + Mid = new ModelRenderer(this, 36, 0); + Mid.addBox(0F, 0F, 0F, 10, 14, 3); + Mid.setRotationPoint(-5F, 10F, -1.5F); - public void render(Entity entity, float f, float f1, float f2, float f3, - float f4, float f5) { - super.render(entity, f, f1, f2, f3, f4, f5); - Mid.render(f5); - OuterEdge1.render(f5); - OuterEdge2.render(f5); - OuterEdgeTop.render(f5); - } + OuterEdge1 = new ModelRenderer(this, 0, 0); + OuterEdge1.addBox(0F, 0F, 0F, 2, 16, 4); + OuterEdge1.setRotationPoint(-7F, 8F, -2F); - private void setRotation(ModelRenderer model, float x, float y, float z) { - model.rotateAngleX = x; - model.rotateAngleY = y; - model.rotateAngleZ = z; - } + OuterEdge2 = new ModelRenderer(this, 0, 0); + OuterEdge2.mirror = true; + OuterEdge2.addBox(1F, 0F, 0F, 2, 16, 4); + OuterEdge2.setRotationPoint(4F, 8F, -2F); + + OuterEdgeTop = new ModelRenderer(this, 0, 22); + OuterEdgeTop.addBox(0F, 0F, 0F, 10, 2, 4); + OuterEdgeTop.setRotationPoint(-5F, 8F, -2F); + } + + public void render(Entity entity, float f, float f1, float f2, float f3, + float f4, float f5) { + super.render(entity, f, f1, f2, f3, f4, f5); + Mid.render(f5); + OuterEdge1.render(f5); + OuterEdge2.render(f5); + OuterEdgeTop.render(f5); + } + + private void setRotation(ModelRenderer model, float x, float y, float z) { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } } diff --git a/src/main/java/noppes/npcs/client/model/blocks/ModelTombstone2.java b/src/main/java/noppes/npcs/client/model/blocks/ModelTombstone2.java index d3b71551d..4ce636e55 100644 --- a/src/main/java/noppes/npcs/client/model/blocks/ModelTombstone2.java +++ b/src/main/java/noppes/npcs/client/model/blocks/ModelTombstone2.java @@ -5,29 +5,29 @@ import net.minecraft.client.model.ModelRenderer; import net.minecraft.entity.Entity; public class ModelTombstone2 extends ModelBase { - ModelRenderer Top; - ModelRenderer mid; + ModelRenderer Top; + ModelRenderer mid; - public ModelTombstone2() { - Top = new ModelRenderer(this, 0, 0); - Top.addBox(0F, 0F, 0F, 10, 1, 4); - Top.setRotationPoint(-5F, 9F, -2F); + public ModelTombstone2() { + Top = new ModelRenderer(this, 0, 0); + Top.addBox(0F, 0F, 0F, 10, 1, 4); + Top.setRotationPoint(-5F, 9F, -2F); - mid = new ModelRenderer(this, 0, 0); - mid.addBox(0F, 0F, 0F, 12, 14, 4); - mid.setRotationPoint(-6F, 10F, -2F); - } + mid = new ModelRenderer(this, 0, 0); + mid.addBox(0F, 0F, 0F, 12, 14, 4); + mid.setRotationPoint(-6F, 10F, -2F); + } - public void render(Entity entity, float f, float f1, float f2, float f3, - float f4, float f5) { - super.render(entity, f, f1, f2, f3, f4, f5); - Top.render(f5); - mid.render(f5); - } + public void render(Entity entity, float f, float f1, float f2, float f3, + float f4, float f5) { + super.render(entity, f, f1, f2, f3, f4, f5); + Top.render(f5); + mid.render(f5); + } - private void setRotation(ModelRenderer model, float x, float y, float z) { - model.rotateAngleX = x; - model.rotateAngleY = y; - model.rotateAngleZ = z; - } + private void setRotation(ModelRenderer model, float x, float y, float z) { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } } diff --git a/src/main/java/noppes/npcs/client/model/blocks/ModelTombstone3.java b/src/main/java/noppes/npcs/client/model/blocks/ModelTombstone3.java index efb7f266f..3fa80c0f1 100644 --- a/src/main/java/noppes/npcs/client/model/blocks/ModelTombstone3.java +++ b/src/main/java/noppes/npcs/client/model/blocks/ModelTombstone3.java @@ -5,60 +5,60 @@ import net.minecraft.client.model.ModelRenderer; import net.minecraft.entity.Entity; public class ModelTombstone3 extends ModelBase { - ModelRenderer Bottom; - ModelRenderer Piece5; - ModelRenderer Piece2; - ModelRenderer Piece1; - ModelRenderer Piece4; - ModelRenderer Piece3; - ModelRenderer Piece7; + ModelRenderer Bottom; + ModelRenderer Piece5; + ModelRenderer Piece2; + ModelRenderer Piece1; + ModelRenderer Piece4; + ModelRenderer Piece3; + ModelRenderer Piece7; - public ModelTombstone3() { - Bottom = new ModelRenderer(this, 0, 0); - Bottom.addBox(0F, 0F, 0F, 12, 5, 4); - Bottom.setRotationPoint(-6F, 19F, -2F); - - Piece5 = new ModelRenderer(this, 0, 0); - Piece5.addBox(0F, 0F, 0F, 4, 1, 4); - Piece5.setRotationPoint(-4F, 16F, -2F); - - Piece2 = new ModelRenderer(this, 0, 0); - Piece2.addBox(0F, 0F, 0F, 4, 2, 4); - Piece2.setRotationPoint(2F, 17F, -2F); - - Piece1 = new ModelRenderer(this, 0, 0); - Piece1.addBox(0F, 0F, 0F, 6, 2, 4); - Piece1.setRotationPoint(-5F, 17F, -2F); - - Piece4 = new ModelRenderer(this, 0, 0); - Piece4.addBox(0F, 0F, 0F, 1, 3, 4); - Piece4.setRotationPoint(-5F, 14F, -2F); - - Piece3 = new ModelRenderer(this, 0, 0); - Piece3.addBox(0F, 0F, 0F, 3, 1, 4); - Piece3.setRotationPoint(3F, 16F, -2F); - - Piece7 = new ModelRenderer(this, 0, 0); - Piece7.addBox(0F, 0F, 0F, 1, 1, 4); - Piece7.setRotationPoint(-4F, 15F, -2F); - } + public ModelTombstone3() { + Bottom = new ModelRenderer(this, 0, 0); + Bottom.addBox(0F, 0F, 0F, 12, 5, 4); + Bottom.setRotationPoint(-6F, 19F, -2F); - public void render(Entity entity, float f, float f1, float f2, float f3, - float f4, float f5) { - super.render(entity, f, f1, f2, f3, f4, f5); - Bottom.render(f5); - Piece5.render(f5); - Piece2.render(f5); - Piece1.render(f5); - Piece4.render(f5); - Piece3.render(f5); - Piece7.render(f5); - } + Piece5 = new ModelRenderer(this, 0, 0); + Piece5.addBox(0F, 0F, 0F, 4, 1, 4); + Piece5.setRotationPoint(-4F, 16F, -2F); - private void setRotation(ModelRenderer model, float x, float y, float z) { - model.rotateAngleX = x; - model.rotateAngleY = y; - model.rotateAngleZ = z; - } + Piece2 = new ModelRenderer(this, 0, 0); + Piece2.addBox(0F, 0F, 0F, 4, 2, 4); + Piece2.setRotationPoint(2F, 17F, -2F); + + Piece1 = new ModelRenderer(this, 0, 0); + Piece1.addBox(0F, 0F, 0F, 6, 2, 4); + Piece1.setRotationPoint(-5F, 17F, -2F); + + Piece4 = new ModelRenderer(this, 0, 0); + Piece4.addBox(0F, 0F, 0F, 1, 3, 4); + Piece4.setRotationPoint(-5F, 14F, -2F); + + Piece3 = new ModelRenderer(this, 0, 0); + Piece3.addBox(0F, 0F, 0F, 3, 1, 4); + Piece3.setRotationPoint(3F, 16F, -2F); + + Piece7 = new ModelRenderer(this, 0, 0); + Piece7.addBox(0F, 0F, 0F, 1, 1, 4); + Piece7.setRotationPoint(-4F, 15F, -2F); + } + + public void render(Entity entity, float f, float f1, float f2, float f3, + float f4, float f5) { + super.render(entity, f, f1, f2, f3, f4, f5); + Bottom.render(f5); + Piece5.render(f5); + Piece2.render(f5); + Piece1.render(f5); + Piece4.render(f5); + Piece3.render(f5); + Piece7.render(f5); + } + + private void setRotation(ModelRenderer model, float x, float y, float z) { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } } diff --git a/src/main/java/noppes/npcs/client/model/blocks/ModelWeaponRack.java b/src/main/java/noppes/npcs/client/model/blocks/ModelWeaponRack.java index df87345ff..edc39deaa 100644 --- a/src/main/java/noppes/npcs/client/model/blocks/ModelWeaponRack.java +++ b/src/main/java/noppes/npcs/client/model/blocks/ModelWeaponRack.java @@ -5,143 +5,143 @@ import net.minecraft.client.model.ModelRenderer; import net.minecraft.entity.Entity; public class ModelWeaponRack extends ModelBase { - ModelRenderer Support_1; - ModelRenderer Support_2; - ModelRenderer Support_3; - ModelRenderer Support_4; - ModelRenderer Support_5; - ModelRenderer Support_6; - ModelRenderer Rung_1_A; - ModelRenderer Rung_1_B; - ModelRenderer Rung_1_C; - ModelRenderer Rung_2_A; - ModelRenderer Rung_2_B; - ModelRenderer Rung_2_C; - ModelRenderer Rung_3_A; - ModelRenderer Rung_3_B; - ModelRenderer Rung_3_C; - ModelRenderer Cross_Top_1; - ModelRenderer Cross_Top_2; - ModelRenderer Bottom_Support_1; - ModelRenderer Bottom_Support_2; - ModelRenderer Middle_Support_1; + ModelRenderer Support_1; + ModelRenderer Support_2; + ModelRenderer Support_3; + ModelRenderer Support_4; + ModelRenderer Support_5; + ModelRenderer Support_6; + ModelRenderer Rung_1_A; + ModelRenderer Rung_1_B; + ModelRenderer Rung_1_C; + ModelRenderer Rung_2_A; + ModelRenderer Rung_2_B; + ModelRenderer Rung_2_C; + ModelRenderer Rung_3_A; + ModelRenderer Rung_3_B; + ModelRenderer Rung_3_C; + ModelRenderer Cross_Top_1; + ModelRenderer Cross_Top_2; + ModelRenderer Bottom_Support_1; + ModelRenderer Bottom_Support_2; + ModelRenderer Middle_Support_1; - public ModelWeaponRack() { - Support_1 = new ModelRenderer(this, 0, 0); - Support_1.addBox(0F, 0F, 0F, 1, 30, 2); - Support_1.setRotationPoint(-5F, -6.9F, 5F); + public ModelWeaponRack() { + Support_1 = new ModelRenderer(this, 0, 0); + Support_1.addBox(0F, 0F, 0F, 1, 30, 2); + Support_1.setRotationPoint(-5F, -6.9F, 5F); - Support_2 = new ModelRenderer(this, 0, 0); - Support_2.addBox(0F, 0F, 0F, 1, 30, 2); - Support_2.setRotationPoint(-8.01F, -6.9F, 5F); + Support_2 = new ModelRenderer(this, 0, 0); + Support_2.addBox(0F, 0F, 0F, 1, 30, 2); + Support_2.setRotationPoint(-8.01F, -6.9F, 5F); - Support_3 = new ModelRenderer(this, 0, 0); - Support_3.addBox(0F, 0F, 0F, 1, 30, 2); - Support_3.setRotationPoint(-2F, -6.9F, 5F); + Support_3 = new ModelRenderer(this, 0, 0); + Support_3.addBox(0F, 0F, 0F, 1, 30, 2); + Support_3.setRotationPoint(-2F, -6.9F, 5F); - Support_4 = new ModelRenderer(this, 0, 0); - Support_4.addBox(0F, 0F, 0F, 1, 30, 2); - Support_4.setRotationPoint(1F, -6.9F, 5F); + Support_4 = new ModelRenderer(this, 0, 0); + Support_4.addBox(0F, 0F, 0F, 1, 30, 2); + Support_4.setRotationPoint(1F, -6.9F, 5F); - Support_5 = new ModelRenderer(this, 0, 0); - Support_5.addBox(0F, 0F, 0F, 1, 30, 2); - Support_5.setRotationPoint(4F, -6.9F, 5F); + Support_5 = new ModelRenderer(this, 0, 0); + Support_5.addBox(0F, 0F, 0F, 1, 30, 2); + Support_5.setRotationPoint(4F, -6.9F, 5F); - Support_6 = new ModelRenderer(this, 0, 0); - Support_6.addBox(0F, 0F, 0F, 1, 30, 2); - Support_6.setRotationPoint(7.01F, -6.9F, 5F); + Support_6 = new ModelRenderer(this, 0, 0); + Support_6.addBox(0F, 0F, 0F, 1, 30, 2); + Support_6.setRotationPoint(7.01F, -6.9F, 5F); - Rung_1_A = new ModelRenderer(this, 0, 22); - Rung_1_A.addBox(0F, 0F, 0F, 4, 1, 0); - Rung_1_A.setRotationPoint(-8F, 11F, 3.99F); + Rung_1_A = new ModelRenderer(this, 0, 22); + Rung_1_A.addBox(0F, 0F, 0F, 4, 1, 0); + Rung_1_A.setRotationPoint(-8F, 11F, 3.99F); - Rung_1_B = new ModelRenderer(this, 0, 24); - Rung_1_B.addBox(0F, 0F, 0F, 1, 1, 1); - Rung_1_B.setRotationPoint(-8F, 11F, 4F); + Rung_1_B = new ModelRenderer(this, 0, 24); + Rung_1_B.addBox(0F, 0F, 0F, 1, 1, 1); + Rung_1_B.setRotationPoint(-8F, 11F, 4F); - Rung_1_C = new ModelRenderer(this, 0, 24); - Rung_1_C.addBox(0F, 0F, 0F, 1, 1, 1); - Rung_1_C.setRotationPoint(-5F, 11F, 4F); + Rung_1_C = new ModelRenderer(this, 0, 24); + Rung_1_C.addBox(0F, 0F, 0F, 1, 1, 1); + Rung_1_C.setRotationPoint(-5F, 11F, 4F); - Rung_2_A = new ModelRenderer(this, 0, 22); - Rung_2_A.addBox(0F, 0F, 0F, 4, 1, 0); - Rung_2_A.setRotationPoint(-2F, 11F, 3.99F); + Rung_2_A = new ModelRenderer(this, 0, 22); + Rung_2_A.addBox(0F, 0F, 0F, 4, 1, 0); + Rung_2_A.setRotationPoint(-2F, 11F, 3.99F); - Rung_2_B = new ModelRenderer(this, 0, 24); - Rung_2_B.addBox(0F, 0F, 0F, 1, 1, 1); - Rung_2_B.setRotationPoint(-2F, 11F, 4F); + Rung_2_B = new ModelRenderer(this, 0, 24); + Rung_2_B.addBox(0F, 0F, 0F, 1, 1, 1); + Rung_2_B.setRotationPoint(-2F, 11F, 4F); - Rung_2_C = new ModelRenderer(this, 0, 24); - Rung_2_C.addBox(0F, 0F, 0F, 1, 1, 1); - Rung_2_C.setRotationPoint(1F, 11F, 4F); + Rung_2_C = new ModelRenderer(this, 0, 24); + Rung_2_C.addBox(0F, 0F, 0F, 1, 1, 1); + Rung_2_C.setRotationPoint(1F, 11F, 4F); - Rung_3_A = new ModelRenderer(this, 0, 22); - Rung_3_A.addBox(0F, 0F, 0F, 4, 1, 0); - Rung_3_A.setRotationPoint(4F, 11F, 3.99F); + Rung_3_A = new ModelRenderer(this, 0, 22); + Rung_3_A.addBox(0F, 0F, 0F, 4, 1, 0); + Rung_3_A.setRotationPoint(4F, 11F, 3.99F); - Rung_3_B = new ModelRenderer(this, 0, 24); - Rung_3_B.addBox(0F, 0F, 0F, 1, 1, 1); - Rung_3_B.setRotationPoint(4F, 11F, 4F); - - Rung_3_C = new ModelRenderer(this, 0, 24); - Rung_3_C.addBox(0F, 0F, 0F, 1, 1, 1); - Rung_3_C.setRotationPoint(7F, 11F, 4F); + Rung_3_B = new ModelRenderer(this, 0, 24); + Rung_3_B.addBox(0F, 0F, 0F, 1, 1, 1); + Rung_3_B.setRotationPoint(4F, 11F, 4F); - Cross_Top_1 = new ModelRenderer(this, 6, 0); - Cross_Top_1.addBox(0F, 0F, 0F, 16, 2, 1); - Cross_Top_1.setRotationPoint(-8F, -8.6F, 6F); - setRotation(Cross_Top_1, -0.5235988F, 0F, 0F); + Rung_3_C = new ModelRenderer(this, 0, 24); + Rung_3_C.addBox(0F, 0F, 0F, 1, 1, 1); + Rung_3_C.setRotationPoint(7F, 11F, 4F); - Cross_Top_2 = new ModelRenderer(this, 6, 0); - Cross_Top_2.addBox(0F, 0F, 0F, 16, 2, 1); - Cross_Top_2.setRotationPoint(-8F, -8.6F, 6.01F); + Cross_Top_1 = new ModelRenderer(this, 6, 0); + Cross_Top_1.addBox(0F, 0F, 0F, 16, 2, 1); + Cross_Top_1.setRotationPoint(-8F, -8.6F, 6F); + setRotation(Cross_Top_1, -0.5235988F, 0F, 0F); - Bottom_Support_1 = new ModelRenderer(this, 6, 0); - Bottom_Support_1.addBox(0F, 0F, 0F, 16, 2, 1); - Bottom_Support_1.setRotationPoint(-8F, 23F, 6F); - setRotation(Bottom_Support_1, -1.570796F, 0F, 0F); + Cross_Top_2 = new ModelRenderer(this, 6, 0); + Cross_Top_2.addBox(0F, 0F, 0F, 16, 2, 1); + Cross_Top_2.setRotationPoint(-8F, -8.6F, 6.01F); - Bottom_Support_2 = new ModelRenderer(this, 6, 0); - Bottom_Support_2.addBox(0F, 0F, 0F, 16, 2, 1); - Bottom_Support_2.setRotationPoint(-8F, 23F, 8F); - setRotation(Bottom_Support_2, -1.570796F, 0F, 0F); + Bottom_Support_1 = new ModelRenderer(this, 6, 0); + Bottom_Support_1.addBox(0F, 0F, 0F, 16, 2, 1); + Bottom_Support_1.setRotationPoint(-8F, 23F, 6F); + setRotation(Bottom_Support_1, -1.570796F, 0F, 0F); - Middle_Support_1 = new ModelRenderer(this, 6, 3); - Middle_Support_1.addBox(0F, 0F, 0F, 16, 1, 3); - Middle_Support_1.setRotationPoint(-8F, 10F, 7.01F); - setRotation(Middle_Support_1, -1.570796F, 0F, 0F); - } + Bottom_Support_2 = new ModelRenderer(this, 6, 0); + Bottom_Support_2.addBox(0F, 0F, 0F, 16, 2, 1); + Bottom_Support_2.setRotationPoint(-8F, 23F, 8F); + setRotation(Bottom_Support_2, -1.570796F, 0F, 0F); - public void render(Entity entity, float f, float f1, float f2, float f3, - float f4, float f5) { - super.render(entity, f, f1, f2, f3, f4, f5); - Support_1.render(f5); - Support_2.render(f5); - Support_3.render(f5); - Support_4.render(f5); - Support_5.render(f5); - Support_6.render(f5); - Rung_1_A.render(f5); - Rung_1_B.render(f5); - Rung_1_C.render(f5); - Rung_2_A.render(f5); - Rung_2_B.render(f5); - Rung_2_C.render(f5); - Rung_3_A.render(f5); - Rung_3_B.render(f5); - Rung_3_C.render(f5); - Cross_Top_1.render(f5); - Cross_Top_2.render(f5); - Bottom_Support_1.render(f5); - Bottom_Support_2.render(f5); - Middle_Support_1.render(f5); - } + Middle_Support_1 = new ModelRenderer(this, 6, 3); + Middle_Support_1.addBox(0F, 0F, 0F, 16, 1, 3); + Middle_Support_1.setRotationPoint(-8F, 10F, 7.01F); + setRotation(Middle_Support_1, -1.570796F, 0F, 0F); + } - private void setRotation(ModelRenderer model, float x, float y, float z) { - model.rotateAngleX = x; - model.rotateAngleY = y; - model.rotateAngleZ = z; - } + public void render(Entity entity, float f, float f1, float f2, float f3, + float f4, float f5) { + super.render(entity, f, f1, f2, f3, f4, f5); + Support_1.render(f5); + Support_2.render(f5); + Support_3.render(f5); + Support_4.render(f5); + Support_5.render(f5); + Support_6.render(f5); + Rung_1_A.render(f5); + Rung_1_B.render(f5); + Rung_1_C.render(f5); + Rung_2_A.render(f5); + Rung_2_B.render(f5); + Rung_2_C.render(f5); + Rung_3_A.render(f5); + Rung_3_B.render(f5); + Rung_3_C.render(f5); + Cross_Top_1.render(f5); + Cross_Top_2.render(f5); + Bottom_Support_1.render(f5); + Bottom_Support_2.render(f5); + Middle_Support_1.render(f5); + } + + private void setRotation(ModelRenderer model, float x, float y, float z) { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } } diff --git a/src/main/java/noppes/npcs/client/model/blocks/banner/ModelBannerFloor.java b/src/main/java/noppes/npcs/client/model/blocks/banner/ModelBannerFloor.java index b58c134a1..ab0ab286a 100644 --- a/src/main/java/noppes/npcs/client/model/blocks/banner/ModelBannerFloor.java +++ b/src/main/java/noppes/npcs/client/model/blocks/banner/ModelBannerFloor.java @@ -6,64 +6,64 @@ import net.minecraft.client.model.ModelRenderer; import net.minecraft.entity.Entity; public class ModelBannerFloor extends ModelBase { - private final ModelRenderer FloorBanner; - private final ModelRenderer Leg4_r1; - private final ModelRenderer Leg3_r1; - private final ModelRenderer Leg2_r1; - private final ModelRenderer Leg1_r1; - private final ModelRenderer Point1_r1; + private final ModelRenderer FloorBanner; + private final ModelRenderer Leg4_r1; + private final ModelRenderer Leg3_r1; + private final ModelRenderer Leg2_r1; + private final ModelRenderer Leg1_r1; + private final ModelRenderer Point1_r1; - public ModelBannerFloor() { - textureWidth = 64; - textureHeight = 64; + public ModelBannerFloor() { + textureWidth = 64; + textureHeight = 64; - FloorBanner = new ModelRenderer(this); - FloorBanner.setRotationPoint(0.0F, 24.0F, 0.0F); - FloorBanner.cubeList.add(new ModelBox(FloorBanner, 0, 0, -8.0F, -32.0F, -1.0F, 16, 3, 3, 0.0F)); - FloorBanner.cubeList.add(new ModelBox(FloorBanner, 0, 8, -6.0F, -36.0F, 0.5F, 4, 4, 0, 0.0F)); - FloorBanner.cubeList.add(new ModelBox(FloorBanner, 0, 13, -1.0F, -29.0F, -0.5F, 2, 26, 2, 0.0F)); - FloorBanner.cubeList.add(new ModelBox(FloorBanner, 18, 28, -6.0F, -2.0F, -5.0F, 12, 2, 11, 0.0F)); - FloorBanner.cubeList.add(new ModelBox(FloorBanner, 26, 19, -4.0F, -4.0F, -3.0F, 8, 2, 7, 0.0F)); + FloorBanner = new ModelRenderer(this); + FloorBanner.setRotationPoint(0.0F, 24.0F, 0.0F); + FloorBanner.cubeList.add(new ModelBox(FloorBanner, 0, 0, -8.0F, -32.0F, -1.0F, 16, 3, 3, 0.0F)); + FloorBanner.cubeList.add(new ModelBox(FloorBanner, 0, 8, -6.0F, -36.0F, 0.5F, 4, 4, 0, 0.0F)); + FloorBanner.cubeList.add(new ModelBox(FloorBanner, 0, 13, -1.0F, -29.0F, -0.5F, 2, 26, 2, 0.0F)); + FloorBanner.cubeList.add(new ModelBox(FloorBanner, 18, 28, -6.0F, -2.0F, -5.0F, 12, 2, 11, 0.0F)); + FloorBanner.cubeList.add(new ModelBox(FloorBanner, 26, 19, -4.0F, -4.0F, -3.0F, 8, 2, 7, 0.0F)); - Leg4_r1 = new ModelRenderer(this); - Leg4_r1.setRotationPoint(-3.5F, -2.1F, 0.5F); - FloorBanner.addChild(Leg4_r1); - setRotationAngle(Leg4_r1, 0.0F, 0.0F, 1.1781F); - Leg4_r1.cubeList.add(new ModelBox(Leg4_r1, 10, 29, -1.0F, -3.0F, -1.0F, 2, 6, 2, 0.0F)); + Leg4_r1 = new ModelRenderer(this); + Leg4_r1.setRotationPoint(-3.5F, -2.1F, 0.5F); + FloorBanner.addChild(Leg4_r1); + setRotationAngle(Leg4_r1, 0.0F, 0.0F, 1.1781F); + Leg4_r1.cubeList.add(new ModelBox(Leg4_r1, 10, 29, -1.0F, -3.0F, -1.0F, 2, 6, 2, 0.0F)); - Leg3_r1 = new ModelRenderer(this); - Leg3_r1.setRotationPoint(0.0F, -2.1F, 4.0F); - FloorBanner.addChild(Leg3_r1); - setRotationAngle(Leg3_r1, 1.1781F, 0.0F, 0.0F); - Leg3_r1.cubeList.add(new ModelBox(Leg3_r1, 10, 29, -1.0F, -3.0F, -1.0F, 2, 6, 2, 0.0F)); + Leg3_r1 = new ModelRenderer(this); + Leg3_r1.setRotationPoint(0.0F, -2.1F, 4.0F); + FloorBanner.addChild(Leg3_r1); + setRotationAngle(Leg3_r1, 1.1781F, 0.0F, 0.0F); + Leg3_r1.cubeList.add(new ModelBox(Leg3_r1, 10, 29, -1.0F, -3.0F, -1.0F, 2, 6, 2, 0.0F)); - Leg2_r1 = new ModelRenderer(this); - Leg2_r1.setRotationPoint(0.0F, -2.1F, -3.0F); - FloorBanner.addChild(Leg2_r1); - setRotationAngle(Leg2_r1, -1.1781F, 0.0F, 0.0F); - Leg2_r1.cubeList.add(new ModelBox(Leg2_r1, 10, 29, -1.0F, -3.0F, -1.0F, 2, 6, 2, 0.0F)); + Leg2_r1 = new ModelRenderer(this); + Leg2_r1.setRotationPoint(0.0F, -2.1F, -3.0F); + FloorBanner.addChild(Leg2_r1); + setRotationAngle(Leg2_r1, -1.1781F, 0.0F, 0.0F); + Leg2_r1.cubeList.add(new ModelBox(Leg2_r1, 10, 29, -1.0F, -3.0F, -1.0F, 2, 6, 2, 0.0F)); - Leg1_r1 = new ModelRenderer(this); - Leg1_r1.setRotationPoint(3.5F, -2.1F, 0.5F); - FloorBanner.addChild(Leg1_r1); - setRotationAngle(Leg1_r1, 0.0F, 0.0F, -1.1781F); - Leg1_r1.cubeList.add(new ModelBox(Leg1_r1, 10, 29, -1.0F, -3.0F, -1.0F, 2, 6, 2, 0.0F)); + Leg1_r1 = new ModelRenderer(this); + Leg1_r1.setRotationPoint(3.5F, -2.1F, 0.5F); + FloorBanner.addChild(Leg1_r1); + setRotationAngle(Leg1_r1, 0.0F, 0.0F, -1.1781F); + Leg1_r1.cubeList.add(new ModelBox(Leg1_r1, 10, 29, -1.0F, -3.0F, -1.0F, 2, 6, 2, 0.0F)); - Point1_r1 = new ModelRenderer(this); - Point1_r1.setRotationPoint(4.0F, -34.0F, 0.5F); - FloorBanner.addChild(Point1_r1); - setRotationAngle(Point1_r1, 0.0F, 3.1416F, 0.0F); - Point1_r1.cubeList.add(new ModelBox(Point1_r1, 0, 8, -2.0F, -2.0F, 0.0F, 4, 4, 0, 0.0F)); - } + Point1_r1 = new ModelRenderer(this); + Point1_r1.setRotationPoint(4.0F, -34.0F, 0.5F); + FloorBanner.addChild(Point1_r1); + setRotationAngle(Point1_r1, 0.0F, 3.1416F, 0.0F); + Point1_r1.cubeList.add(new ModelBox(Point1_r1, 0, 8, -2.0F, -2.0F, 0.0F, 4, 4, 0, 0.0F)); + } - @Override - public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) { - FloorBanner.render(f5); - } + @Override + public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) { + FloorBanner.render(f5); + } - public void setRotationAngle(ModelRenderer modelRenderer, float x, float y, float z) { - modelRenderer.rotateAngleX = x; - modelRenderer.rotateAngleY = y; - modelRenderer.rotateAngleZ = z; - } + public void setRotationAngle(ModelRenderer modelRenderer, float x, float y, float z) { + modelRenderer.rotateAngleX = x; + modelRenderer.rotateAngleY = y; + modelRenderer.rotateAngleZ = z; + } } diff --git a/src/main/java/noppes/npcs/client/model/blocks/banner/ModelBannerWall.java b/src/main/java/noppes/npcs/client/model/blocks/banner/ModelBannerWall.java index e3756d963..ed09dcf8d 100644 --- a/src/main/java/noppes/npcs/client/model/blocks/banner/ModelBannerWall.java +++ b/src/main/java/noppes/npcs/client/model/blocks/banner/ModelBannerWall.java @@ -9,7 +9,7 @@ public class ModelBannerWall extends ModelBase { private final ModelRenderer bb_main; private final ModelRenderer cube_r1; - public ModelBannerWall() { + public ModelBannerWall() { textureWidth = 64; textureHeight = 64; @@ -22,16 +22,17 @@ public class ModelBannerWall extends ModelBase { cube_r1.setRotationPoint(4.0F, -34.0F, 6.5F); bb_main.addChild(cube_r1); setRotationAngle(cube_r1, 0.0F, 3.1416F, 0.0F); - cube_r1.cubeList.add(new ModelBox(cube_r1, 0, 8, -2.0F, -2.0F, 0.0F, 4, 4, 0, 0.0F));} + cube_r1.cubeList.add(new ModelBox(cube_r1, 0, 8, -2.0F, -2.0F, 0.0F, 4, 4, 0, 0.0F)); + } - @Override - public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) { + @Override + public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) { bb_main.render(f5); - } + } - public void setRotationAngle(ModelRenderer modelRenderer, float x, float y, float z) { - modelRenderer.rotateAngleX = x; - modelRenderer.rotateAngleY = y; - modelRenderer.rotateAngleZ = z; - } + public void setRotationAngle(ModelRenderer modelRenderer, float x, float y, float z) { + modelRenderer.rotateAngleX = x; + modelRenderer.rotateAngleY = y; + modelRenderer.rotateAngleZ = z; + } } diff --git a/src/main/java/noppes/npcs/client/model/blocks/barrel/ModelBarrel.java b/src/main/java/noppes/npcs/client/model/blocks/barrel/ModelBarrel.java index c8506d465..99b8fe66c 100644 --- a/src/main/java/noppes/npcs/client/model/blocks/barrel/ModelBarrel.java +++ b/src/main/java/noppes/npcs/client/model/blocks/barrel/ModelBarrel.java @@ -5,75 +5,75 @@ import net.minecraft.client.model.ModelBox; import net.minecraft.client.model.ModelRenderer; public class ModelBarrel extends ModelBase { - private final ModelRenderer Wall; - private final ModelRenderer cube_r1; - private final ModelRenderer cube_r2; - private final ModelRenderer cube_r3; - private final ModelRenderer Trim; - private final ModelRenderer Base; + private final ModelRenderer Wall; + private final ModelRenderer cube_r1; + private final ModelRenderer cube_r2; + private final ModelRenderer cube_r3; + private final ModelRenderer Trim; + private final ModelRenderer Base; - public ModelBarrel() { - textureWidth = 64; - textureHeight = 32; + public ModelBarrel() { + textureWidth = 64; + textureHeight = 32; - Wall = new ModelRenderer(this); - Wall.setRotationPoint(0.0F, 24.0F, 0.0F); - Wall.cubeList.add(new ModelBox(Wall, 0, 0, 5.0F, -16.0F, 5.0F, 1, 16, 1, 0.0F)); - Wall.cubeList.add(new ModelBox(Wall, 0, 0, 5.0F, -16.0F, -6.0F, 1, 16, 1, 0.0F)); - Wall.cubeList.add(new ModelBox(Wall, 0, 0, -6.0F, -16.0F, -6.0F, 1, 16, 1, 0.0F)); - Wall.cubeList.add(new ModelBox(Wall, 0, 0, -6.0F, -16.0F, 5.0F, 1, 16, 1, 0.0F)); + Wall = new ModelRenderer(this); + Wall.setRotationPoint(0.0F, 24.0F, 0.0F); + Wall.cubeList.add(new ModelBox(Wall, 0, 0, 5.0F, -16.0F, 5.0F, 1, 16, 1, 0.0F)); + Wall.cubeList.add(new ModelBox(Wall, 0, 0, 5.0F, -16.0F, -6.0F, 1, 16, 1, 0.0F)); + Wall.cubeList.add(new ModelBox(Wall, 0, 0, -6.0F, -16.0F, -6.0F, 1, 16, 1, 0.0F)); + Wall.cubeList.add(new ModelBox(Wall, 0, 0, -6.0F, -16.0F, 5.0F, 1, 16, 1, 0.0F)); - cube_r1 = new ModelRenderer(this); - cube_r1.setRotationPoint(-6.5F, -8.0F, 0.0F); - Wall.addChild(cube_r1); - setRotationAngle(cube_r1, 1.5708F, 0.0F, 0.0F); - cube_r1.cubeList.add(new ModelBox(cube_r1, 0, 0, -0.5F, -6.0F, -8.0F, 1, 12, 16, 0.0F)); + cube_r1 = new ModelRenderer(this); + cube_r1.setRotationPoint(-6.5F, -8.0F, 0.0F); + Wall.addChild(cube_r1); + setRotationAngle(cube_r1, 1.5708F, 0.0F, 0.0F); + cube_r1.cubeList.add(new ModelBox(cube_r1, 0, 0, -0.5F, -6.0F, -8.0F, 1, 12, 16, 0.0F)); - cube_r2 = new ModelRenderer(this); - cube_r2.setRotationPoint(0.0F, -8.0F, 6.5F); - Wall.addChild(cube_r2); - setRotationAngle(cube_r2, 0.0F, 0.0F, 1.5708F); - cube_r2.cubeList.add(new ModelBox(cube_r2, 0, 14, -8.0F, -6.0F, -0.5F, 16, 12, 1, 0.0F)); - cube_r2.cubeList.add(new ModelBox(cube_r2, 0, 14, -8.0F, -6.0F, -13.5F, 16, 12, 1, 0.0F)); + cube_r2 = new ModelRenderer(this); + cube_r2.setRotationPoint(0.0F, -8.0F, 6.5F); + Wall.addChild(cube_r2); + setRotationAngle(cube_r2, 0.0F, 0.0F, 1.5708F); + cube_r2.cubeList.add(new ModelBox(cube_r2, 0, 14, -8.0F, -6.0F, -0.5F, 16, 12, 1, 0.0F)); + cube_r2.cubeList.add(new ModelBox(cube_r2, 0, 14, -8.0F, -6.0F, -13.5F, 16, 12, 1, 0.0F)); - cube_r3 = new ModelRenderer(this); - cube_r3.setRotationPoint(6.5F, -8.0F, 0.0F); - Wall.addChild(cube_r3); - setRotationAngle(cube_r3, -1.5708F, 0.0F, 0.0F); - cube_r3.cubeList.add(new ModelBox(cube_r3, 0, 0, -0.5F, -6.0F, -8.0F, 1, 12, 16, 0.0F)); + cube_r3 = new ModelRenderer(this); + cube_r3.setRotationPoint(6.5F, -8.0F, 0.0F); + Wall.addChild(cube_r3); + setRotationAngle(cube_r3, -1.5708F, 0.0F, 0.0F); + cube_r3.cubeList.add(new ModelBox(cube_r3, 0, 0, -0.5F, -6.0F, -8.0F, 1, 12, 16, 0.0F)); - Trim = new ModelRenderer(this); - Trim.setRotationPoint(0.0F, 24.0F, 0.0F); - Trim.cubeList.add(new ModelBox(Trim, 4, 28, -6.5F, -5.0F, 5.5F, 13, 2, 2, 0.0F)); - Trim.cubeList.add(new ModelBox(Trim, 34, 17, 5.5F, -5.0F, -6.5F, 2, 2, 13, 0.0F)); - Trim.cubeList.add(new ModelBox(Trim, 4, 28, -6.5F, -5.0F, -7.5F, 13, 2, 2, 0.0F)); - Trim.cubeList.add(new ModelBox(Trim, 34, 17, -7.5F, -5.0F, -6.5F, 2, 2, 13, 0.0F)); - Trim.cubeList.add(new ModelBox(Trim, 4, 28, -6.5F, -13.0F, -7.5F, 13, 2, 2, 0.0F)); - Trim.cubeList.add(new ModelBox(Trim, 4, 28, -6.5F, -13.0F, 5.5F, 13, 2, 2, 0.0F)); - Trim.cubeList.add(new ModelBox(Trim, 34, 17, -7.5F, -13.0F, -6.5F, 2, 2, 13, 0.0F)); - Trim.cubeList.add(new ModelBox(Trim, 34, 17, 5.5F, -13.0F, -6.5F, 2, 2, 13, 0.0F)); + Trim = new ModelRenderer(this); + Trim.setRotationPoint(0.0F, 24.0F, 0.0F); + Trim.cubeList.add(new ModelBox(Trim, 4, 28, -6.5F, -5.0F, 5.5F, 13, 2, 2, 0.0F)); + Trim.cubeList.add(new ModelBox(Trim, 34, 17, 5.5F, -5.0F, -6.5F, 2, 2, 13, 0.0F)); + Trim.cubeList.add(new ModelBox(Trim, 4, 28, -6.5F, -5.0F, -7.5F, 13, 2, 2, 0.0F)); + Trim.cubeList.add(new ModelBox(Trim, 34, 17, -7.5F, -5.0F, -6.5F, 2, 2, 13, 0.0F)); + Trim.cubeList.add(new ModelBox(Trim, 4, 28, -6.5F, -13.0F, -7.5F, 13, 2, 2, 0.0F)); + Trim.cubeList.add(new ModelBox(Trim, 4, 28, -6.5F, -13.0F, 5.5F, 13, 2, 2, 0.0F)); + Trim.cubeList.add(new ModelBox(Trim, 34, 17, -7.5F, -13.0F, -6.5F, 2, 2, 13, 0.0F)); + Trim.cubeList.add(new ModelBox(Trim, 34, 17, 5.5F, -13.0F, -6.5F, 2, 2, 13, 0.0F)); - Base = new ModelRenderer(this); - Base.setRotationPoint(0.0F, 24.0F, 0.0F); - Base.cubeList.add(new ModelBox(Base, 16, 2, -6.0F, -15.0F, -6.0F, 12, 1, 12, 0.0F)); - Base.cubeList.add(new ModelBox(Base, 16, 2, -6.0F, -2.0F, -6.0F, 12, 1, 12, 0.0F)); - } + Base = new ModelRenderer(this); + Base.setRotationPoint(0.0F, 24.0F, 0.0F); + Base.cubeList.add(new ModelBox(Base, 16, 2, -6.0F, -15.0F, -6.0F, 12, 1, 12, 0.0F)); + Base.cubeList.add(new ModelBox(Base, 16, 2, -6.0F, -2.0F, -6.0F, 12, 1, 12, 0.0F)); + } - public void renderBase(float f5){ + public void renderBase(float f5) { Base.render(f5); } - public void renderTrim(float f5){ + public void renderTrim(float f5) { Trim.render(f5); } - public void renderWall(float f5){ + public void renderWall(float f5) { Wall.render(f5); } - public void setRotationAngle(ModelRenderer modelRenderer, float x, float y, float z) { - modelRenderer.rotateAngleX = x; - modelRenderer.rotateAngleY = y; - modelRenderer.rotateAngleZ = z; - } + public void setRotationAngle(ModelRenderer modelRenderer, float x, float y, float z) { + modelRenderer.rotateAngleX = x; + modelRenderer.rotateAngleY = y; + modelRenderer.rotateAngleZ = z; + } } diff --git a/src/main/java/noppes/npcs/client/model/blocks/campfire/ModelCampfireCoals.java b/src/main/java/noppes/npcs/client/model/blocks/campfire/ModelCampfireCoals.java index 9f10ef8c9..179761dff 100644 --- a/src/main/java/noppes/npcs/client/model/blocks/campfire/ModelCampfireCoals.java +++ b/src/main/java/noppes/npcs/client/model/blocks/campfire/ModelCampfireCoals.java @@ -6,25 +6,25 @@ import net.minecraft.client.model.ModelRenderer; import net.minecraft.entity.Entity; public class ModelCampfireCoals extends ModelBase { - private final ModelRenderer bb_main; + private final ModelRenderer bb_main; - public ModelCampfireCoals() { - textureWidth = 64; - textureHeight = 64; + public ModelCampfireCoals() { + textureWidth = 64; + textureHeight = 64; - bb_main = new ModelRenderer(this); - bb_main.setRotationPoint(0.0F, 24.0F, 0.0F); - bb_main.cubeList.add(new ModelBox(bb_main, -10, 0, -5.0F, -0.02F, -5.0F, 10, 0, 10, 0.0F)); - } + bb_main = new ModelRenderer(this); + bb_main.setRotationPoint(0.0F, 24.0F, 0.0F); + bb_main.cubeList.add(new ModelBox(bb_main, -10, 0, -5.0F, -0.02F, -5.0F, 10, 0, 10, 0.0F)); + } - @Override - public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) { - bb_main.render(f5); - } + @Override + public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) { + bb_main.render(f5); + } - public void setRotationAngle(ModelRenderer modelRenderer, float x, float y, float z) { - modelRenderer.rotateAngleX = x; - modelRenderer.rotateAngleY = y; - modelRenderer.rotateAngleZ = z; - } + public void setRotationAngle(ModelRenderer modelRenderer, float x, float y, float z) { + modelRenderer.rotateAngleX = x; + modelRenderer.rotateAngleY = y; + modelRenderer.rotateAngleZ = z; + } } diff --git a/src/main/java/noppes/npcs/client/model/blocks/campfire/ModelCampfireStone.java b/src/main/java/noppes/npcs/client/model/blocks/campfire/ModelCampfireStone.java index feded698a..627790b1e 100644 --- a/src/main/java/noppes/npcs/client/model/blocks/campfire/ModelCampfireStone.java +++ b/src/main/java/noppes/npcs/client/model/blocks/campfire/ModelCampfireStone.java @@ -6,52 +6,52 @@ import net.minecraft.client.model.ModelRenderer; import net.minecraft.entity.Entity; public class ModelCampfireStone extends ModelBase { - private final ModelRenderer bb_main; - private final ModelRenderer cube_r1; - private final ModelRenderer cube_r2; - private final ModelRenderer cube_r3; + private final ModelRenderer bb_main; + private final ModelRenderer cube_r1; + private final ModelRenderer cube_r2; + private final ModelRenderer cube_r3; - public ModelCampfireStone() { - textureWidth = 16; - textureHeight = 16; + public ModelCampfireStone() { + textureWidth = 16; + textureHeight = 16; - bb_main = new ModelRenderer(this); - bb_main.setRotationPoint(0.0F, 24.0F, 0.0F); - bb_main.cubeList.add(new ModelBox(bb_main, 18, 5, 4.0F, -2.0F, 1.0F, 3, 2, 4, 0.0F)); - bb_main.cubeList.add(new ModelBox(bb_main, 18, 2, -4.0F, -3.0F, -7.0F, 4, 3, 3, 0.0F)); - bb_main.cubeList.add(new ModelBox(bb_main, 17, 0, -3.0F, -3.0F, 5.0F, 4, 3, 3, 0.0F)); - bb_main.cubeList.add(new ModelBox(bb_main, 18, 2, -8.0F, -3.0F, -1.0F, 3, 3, 4, 0.0F)); - bb_main.cubeList.add(new ModelBox(bb_main, 18, 11, -6.0F, -2.0F, 3.0F, 3, 2, 3, 0.0F)); - bb_main.cubeList.add(new ModelBox(bb_main, 16, 0, -7.0F, -2.0F, -5.0F, 3, 2, 4, 0.0F)); - bb_main.cubeList.add(new ModelBox(bb_main, 18, 11, 4.0F, -2.0F, -6.0F, 3, 2, 3, 0.0F)); + bb_main = new ModelRenderer(this); + bb_main.setRotationPoint(0.0F, 24.0F, 0.0F); + bb_main.cubeList.add(new ModelBox(bb_main, 18, 5, 4.0F, -2.0F, 1.0F, 3, 2, 4, 0.0F)); + bb_main.cubeList.add(new ModelBox(bb_main, 18, 2, -4.0F, -3.0F, -7.0F, 4, 3, 3, 0.0F)); + bb_main.cubeList.add(new ModelBox(bb_main, 17, 0, -3.0F, -3.0F, 5.0F, 4, 3, 3, 0.0F)); + bb_main.cubeList.add(new ModelBox(bb_main, 18, 2, -8.0F, -3.0F, -1.0F, 3, 3, 4, 0.0F)); + bb_main.cubeList.add(new ModelBox(bb_main, 18, 11, -6.0F, -2.0F, 3.0F, 3, 2, 3, 0.0F)); + bb_main.cubeList.add(new ModelBox(bb_main, 16, 0, -7.0F, -2.0F, -5.0F, 3, 2, 4, 0.0F)); + bb_main.cubeList.add(new ModelBox(bb_main, 18, 11, 4.0F, -2.0F, -6.0F, 3, 2, 3, 0.0F)); - cube_r1 = new ModelRenderer(this); - cube_r1.setRotationPoint(6.5F, -1.5F, -1.0F); - bb_main.addChild(cube_r1); - setRotationAngle(cube_r1, 0.0F, -1.5708F, 0.0F); - cube_r1.cubeList.add(new ModelBox(cube_r1, 18, 2, -2.0F, -1.5F, -1.5F, 4, 3, 3, 0.0F)); + cube_r1 = new ModelRenderer(this); + cube_r1.setRotationPoint(6.5F, -1.5F, -1.0F); + bb_main.addChild(cube_r1); + setRotationAngle(cube_r1, 0.0F, -1.5708F, 0.0F); + cube_r1.cubeList.add(new ModelBox(cube_r1, 18, 2, -2.0F, -1.5F, -1.5F, 4, 3, 3, 0.0F)); - cube_r2 = new ModelRenderer(this); - cube_r2.setRotationPoint(2.5F, -1.5F, -6.0F); - bb_main.addChild(cube_r2); - setRotationAngle(cube_r2, 0.0F, 1.5708F, 0.0F); - cube_r2.cubeList.add(new ModelBox(cube_r2, 18, 5, -1.0F, -0.5F, -2.5F, 3, 2, 4, 0.0F)); + cube_r2 = new ModelRenderer(this); + cube_r2.setRotationPoint(2.5F, -1.5F, -6.0F); + bb_main.addChild(cube_r2); + setRotationAngle(cube_r2, 0.0F, 1.5708F, 0.0F); + cube_r2.cubeList.add(new ModelBox(cube_r2, 18, 5, -1.0F, -0.5F, -2.5F, 3, 2, 4, 0.0F)); - cube_r3 = new ModelRenderer(this); - cube_r3.setRotationPoint(3.5F, -1.5F, 5.5F); - bb_main.addChild(cube_r3); - setRotationAngle(cube_r3, 0.0F, -1.5708F, 0.0F); - cube_r3.cubeList.add(new ModelBox(cube_r3, 20, 1, -0.5F, -0.5F, -1.5F, 2, 2, 4, 0.0F)); - } + cube_r3 = new ModelRenderer(this); + cube_r3.setRotationPoint(3.5F, -1.5F, 5.5F); + bb_main.addChild(cube_r3); + setRotationAngle(cube_r3, 0.0F, -1.5708F, 0.0F); + cube_r3.cubeList.add(new ModelBox(cube_r3, 20, 1, -0.5F, -0.5F, -1.5F, 2, 2, 4, 0.0F)); + } - @Override - public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) { - bb_main.render(f5); - } + @Override + public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) { + bb_main.render(f5); + } - public void setRotationAngle(ModelRenderer modelRenderer, float x, float y, float z) { - modelRenderer.rotateAngleX = x; - modelRenderer.rotateAngleY = y; - modelRenderer.rotateAngleZ = z; - } + public void setRotationAngle(ModelRenderer modelRenderer, float x, float y, float z) { + modelRenderer.rotateAngleX = x; + modelRenderer.rotateAngleY = y; + modelRenderer.rotateAngleZ = z; + } } diff --git a/src/main/java/noppes/npcs/client/model/blocks/candle/ModelCandle.java b/src/main/java/noppes/npcs/client/model/blocks/candle/ModelCandle.java index 6f09f0cfb..4627f8ce6 100644 --- a/src/main/java/noppes/npcs/client/model/blocks/candle/ModelCandle.java +++ b/src/main/java/noppes/npcs/client/model/blocks/candle/ModelCandle.java @@ -6,50 +6,50 @@ import net.minecraft.client.model.ModelRenderer; import net.minecraft.entity.Entity; public class ModelCandle extends ModelBase { - public final ModelRenderer Candle; - private final ModelRenderer cube_r1; - private final ModelRenderer cube_r2; + public final ModelRenderer Candle; + private final ModelRenderer cube_r1; + private final ModelRenderer cube_r2; public final ModelRenderer Holder; - public ModelCandle() { - textureWidth = 64; - textureHeight = 32; + public ModelCandle() { + textureWidth = 64; + textureHeight = 32; - Candle = new ModelRenderer(this); - Candle.setRotationPoint(0.0F, 23.0F, 0.0F); - Candle.cubeList.add(new ModelBox(Candle, 28, 1, -1.0F, -5.0F, -1.0F, 2, 5, 2, 0.0F)); + Candle = new ModelRenderer(this); + Candle.setRotationPoint(0.0F, 23.0F, 0.0F); + Candle.cubeList.add(new ModelBox(Candle, 28, 1, -1.0F, -5.0F, -1.0F, 2, 5, 2, 0.0F)); - cube_r1 = new ModelRenderer(this); - cube_r1.setRotationPoint(0.0F, -5.5F, 0.0F); - Candle.addChild(cube_r1); - setRotationAngle(cube_r1, 0.0F, 2.3562F, 0.0F); - cube_r1.cubeList.add(new ModelBox(cube_r1, 31, -1, 0.0F, -0.5F, -0.5F, 0, 1, 1, 0.0F)); + cube_r1 = new ModelRenderer(this); + cube_r1.setRotationPoint(0.0F, -5.5F, 0.0F); + Candle.addChild(cube_r1); + setRotationAngle(cube_r1, 0.0F, 2.3562F, 0.0F); + cube_r1.cubeList.add(new ModelBox(cube_r1, 31, -1, 0.0F, -0.5F, -0.5F, 0, 1, 1, 0.0F)); - cube_r2 = new ModelRenderer(this); - cube_r2.setRotationPoint(0.0F, -5.5F, 0.0F); - Candle.addChild(cube_r2); - setRotationAngle(cube_r2, 0.0F, 0.7854F, 0.0F); - cube_r2.cubeList.add(new ModelBox(cube_r2, 31, -1, 0.0F, -0.5F, -0.5F, 0, 1, 1, 0.0F)); + cube_r2 = new ModelRenderer(this); + cube_r2.setRotationPoint(0.0F, -5.5F, 0.0F); + Candle.addChild(cube_r2); + setRotationAngle(cube_r2, 0.0F, 0.7854F, 0.0F); + cube_r2.cubeList.add(new ModelBox(cube_r2, 31, -1, 0.0F, -0.5F, -0.5F, 0, 1, 1, 0.0F)); - Holder = new ModelRenderer(this); - Holder.setRotationPoint(0.0F, 24.0F, 0.0F); - Holder.cubeList.add(new ModelBox(Holder, 12, 0, -2.0F, -1.0F, -2.0F, 4, 1, 4, 0.0F)); - Holder.cubeList.add(new ModelBox(Holder, 36, 0, 2.0F, -2.0F, -3.0F, 1, 1, 6, 0.0F)); - Holder.cubeList.add(new ModelBox(Holder, 36, 0, -3.0F, -2.0F, -3.0F, 1, 1, 6, 0.0F)); - Holder.cubeList.add(new ModelBox(Holder, 36, 7, -2.0F, -2.0F, -3.0F, 4, 1, 1, 0.0F)); - Holder.cubeList.add(new ModelBox(Holder, 36, 7, -2.0F, -2.0F, 2.0F, 4, 1, 1, 0.0F)); - Holder.cubeList.add(new ModelBox(Holder, 12, 11, 2.0F, -4.0F, 0.0F, 3, 3, 0, 0.0F)); - } + Holder = new ModelRenderer(this); + Holder.setRotationPoint(0.0F, 24.0F, 0.0F); + Holder.cubeList.add(new ModelBox(Holder, 12, 0, -2.0F, -1.0F, -2.0F, 4, 1, 4, 0.0F)); + Holder.cubeList.add(new ModelBox(Holder, 36, 0, 2.0F, -2.0F, -3.0F, 1, 1, 6, 0.0F)); + Holder.cubeList.add(new ModelBox(Holder, 36, 0, -3.0F, -2.0F, -3.0F, 1, 1, 6, 0.0F)); + Holder.cubeList.add(new ModelBox(Holder, 36, 7, -2.0F, -2.0F, -3.0F, 4, 1, 1, 0.0F)); + Holder.cubeList.add(new ModelBox(Holder, 36, 7, -2.0F, -2.0F, 2.0F, 4, 1, 1, 0.0F)); + Holder.cubeList.add(new ModelBox(Holder, 12, 11, 2.0F, -4.0F, 0.0F, 3, 3, 0, 0.0F)); + } - @Override - public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) { - Candle.render(f5); - Holder.render(f5); - } + @Override + public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) { + Candle.render(f5); + Holder.render(f5); + } - public void setRotationAngle(ModelRenderer modelRenderer, float x, float y, float z) { - modelRenderer.rotateAngleX = x; - modelRenderer.rotateAngleY = y; - modelRenderer.rotateAngleZ = z; - } + public void setRotationAngle(ModelRenderer modelRenderer, float x, float y, float z) { + modelRenderer.rotateAngleX = x; + modelRenderer.rotateAngleY = y; + modelRenderer.rotateAngleZ = z; + } } diff --git a/src/main/java/noppes/npcs/client/model/blocks/candle/ModelCandleCeiling.java b/src/main/java/noppes/npcs/client/model/blocks/candle/ModelCandleCeiling.java index 9c7de379c..3554e2d17 100644 --- a/src/main/java/noppes/npcs/client/model/blocks/candle/ModelCandleCeiling.java +++ b/src/main/java/noppes/npcs/client/model/blocks/candle/ModelCandleCeiling.java @@ -6,140 +6,140 @@ import net.minecraft.client.model.ModelRenderer; import net.minecraft.entity.Entity; public class ModelCandleCeiling extends ModelBase { - public final ModelRenderer Candle; - private final ModelRenderer cube_r1; - private final ModelRenderer cube_r2; - private final ModelRenderer cube_r3; - private final ModelRenderer cube_r4; - private final ModelRenderer cube_r5; - private final ModelRenderer cube_r6; - private final ModelRenderer cube_r7; - private final ModelRenderer cube_r8; + public final ModelRenderer Candle; + private final ModelRenderer cube_r1; + private final ModelRenderer cube_r2; + private final ModelRenderer cube_r3; + private final ModelRenderer cube_r4; + private final ModelRenderer cube_r5; + private final ModelRenderer cube_r6; + private final ModelRenderer cube_r7; + private final ModelRenderer cube_r8; public final ModelRenderer Holder; public final ModelRenderer Base; - private final ModelRenderer cube_r9; - private final ModelRenderer cube_r10; - private final ModelRenderer cube_r11; + private final ModelRenderer cube_r9; + private final ModelRenderer cube_r10; + private final ModelRenderer cube_r11; public final ModelRenderer Chain; - private final ModelRenderer cube_r12; - private final ModelRenderer cube_r13; + private final ModelRenderer cube_r12; + private final ModelRenderer cube_r13; - public ModelCandleCeiling() { - textureWidth = 64; - textureHeight = 32; + public ModelCandleCeiling() { + textureWidth = 64; + textureHeight = 32; - Candle = new ModelRenderer(this); - Candle.setRotationPoint(0.0F, 23.0F, 0.0F); - Candle.cubeList.add(new ModelBox(Candle, 28, 1, -1.0F, -9.0F, 5.0F, 2, 5, 2, 0.0F)); - Candle.cubeList.add(new ModelBox(Candle, 28, 1, -7.0F, -9.0F, -1.0F, 2, 5, 2, 0.0F)); - Candle.cubeList.add(new ModelBox(Candle, 28, 1, 5.0F, -9.0F, -1.0F, 2, 5, 2, 0.0F)); - Candle.cubeList.add(new ModelBox(Candle, 28, 1, -1.0F, -9.0F, -7.0F, 2, 5, 2, 0.0F)); + Candle = new ModelRenderer(this); + Candle.setRotationPoint(0.0F, 23.0F, 0.0F); + Candle.cubeList.add(new ModelBox(Candle, 28, 1, -1.0F, -9.0F, 5.0F, 2, 5, 2, 0.0F)); + Candle.cubeList.add(new ModelBox(Candle, 28, 1, -7.0F, -9.0F, -1.0F, 2, 5, 2, 0.0F)); + Candle.cubeList.add(new ModelBox(Candle, 28, 1, 5.0F, -9.0F, -1.0F, 2, 5, 2, 0.0F)); + Candle.cubeList.add(new ModelBox(Candle, 28, 1, -1.0F, -9.0F, -7.0F, 2, 5, 2, 0.0F)); - cube_r1 = new ModelRenderer(this); - cube_r1.setRotationPoint(0.0F, -9.5F, -6.0F); - Candle.addChild(cube_r1); - setRotationAngle(cube_r1, 0.0F, 2.3562F, 0.0F); - cube_r1.cubeList.add(new ModelBox(cube_r1, 31, -1, 0.0F, -0.5F, -0.5F, 0, 1, 1, 0.0F)); + cube_r1 = new ModelRenderer(this); + cube_r1.setRotationPoint(0.0F, -9.5F, -6.0F); + Candle.addChild(cube_r1); + setRotationAngle(cube_r1, 0.0F, 2.3562F, 0.0F); + cube_r1.cubeList.add(new ModelBox(cube_r1, 31, -1, 0.0F, -0.5F, -0.5F, 0, 1, 1, 0.0F)); - cube_r2 = new ModelRenderer(this); - cube_r2.setRotationPoint(0.0F, -9.5F, -6.0F); - Candle.addChild(cube_r2); - setRotationAngle(cube_r2, 0.0F, 0.7854F, 0.0F); - cube_r2.cubeList.add(new ModelBox(cube_r2, 31, -1, 0.0F, -0.5F, -0.5F, 0, 1, 1, 0.0F)); + cube_r2 = new ModelRenderer(this); + cube_r2.setRotationPoint(0.0F, -9.5F, -6.0F); + Candle.addChild(cube_r2); + setRotationAngle(cube_r2, 0.0F, 0.7854F, 0.0F); + cube_r2.cubeList.add(new ModelBox(cube_r2, 31, -1, 0.0F, -0.5F, -0.5F, 0, 1, 1, 0.0F)); - cube_r3 = new ModelRenderer(this); - cube_r3.setRotationPoint(6.0F, -9.5F, 0.0F); - Candle.addChild(cube_r3); - setRotationAngle(cube_r3, 0.0F, 2.3562F, 0.0F); - cube_r3.cubeList.add(new ModelBox(cube_r3, 31, -1, 0.0F, -0.5F, -0.5F, 0, 1, 1, 0.0F)); + cube_r3 = new ModelRenderer(this); + cube_r3.setRotationPoint(6.0F, -9.5F, 0.0F); + Candle.addChild(cube_r3); + setRotationAngle(cube_r3, 0.0F, 2.3562F, 0.0F); + cube_r3.cubeList.add(new ModelBox(cube_r3, 31, -1, 0.0F, -0.5F, -0.5F, 0, 1, 1, 0.0F)); - cube_r4 = new ModelRenderer(this); - cube_r4.setRotationPoint(6.0F, -9.5F, 0.0F); - Candle.addChild(cube_r4); - setRotationAngle(cube_r4, 0.0F, 0.7854F, 0.0F); - cube_r4.cubeList.add(new ModelBox(cube_r4, 31, -1, 0.0F, -0.5F, -0.5F, 0, 1, 1, 0.0F)); + cube_r4 = new ModelRenderer(this); + cube_r4.setRotationPoint(6.0F, -9.5F, 0.0F); + Candle.addChild(cube_r4); + setRotationAngle(cube_r4, 0.0F, 0.7854F, 0.0F); + cube_r4.cubeList.add(new ModelBox(cube_r4, 31, -1, 0.0F, -0.5F, -0.5F, 0, 1, 1, 0.0F)); - cube_r5 = new ModelRenderer(this); - cube_r5.setRotationPoint(-6.0F, -9.5F, 0.0F); - Candle.addChild(cube_r5); - setRotationAngle(cube_r5, 0.0F, 2.3562F, 0.0F); - cube_r5.cubeList.add(new ModelBox(cube_r5, 31, -1, 0.0F, -0.5F, -0.5F, 0, 1, 1, 0.0F)); + cube_r5 = new ModelRenderer(this); + cube_r5.setRotationPoint(-6.0F, -9.5F, 0.0F); + Candle.addChild(cube_r5); + setRotationAngle(cube_r5, 0.0F, 2.3562F, 0.0F); + cube_r5.cubeList.add(new ModelBox(cube_r5, 31, -1, 0.0F, -0.5F, -0.5F, 0, 1, 1, 0.0F)); - cube_r6 = new ModelRenderer(this); - cube_r6.setRotationPoint(-6.0F, -9.5F, 0.0F); - Candle.addChild(cube_r6); - setRotationAngle(cube_r6, 0.0F, 0.7854F, 0.0F); - cube_r6.cubeList.add(new ModelBox(cube_r6, 31, -1, 0.0F, -0.5F, -0.5F, 0, 1, 1, 0.0F)); + cube_r6 = new ModelRenderer(this); + cube_r6.setRotationPoint(-6.0F, -9.5F, 0.0F); + Candle.addChild(cube_r6); + setRotationAngle(cube_r6, 0.0F, 0.7854F, 0.0F); + cube_r6.cubeList.add(new ModelBox(cube_r6, 31, -1, 0.0F, -0.5F, -0.5F, 0, 1, 1, 0.0F)); - cube_r7 = new ModelRenderer(this); - cube_r7.setRotationPoint(0.0F, -9.5F, 6.0F); - Candle.addChild(cube_r7); - setRotationAngle(cube_r7, 0.0F, 2.3562F, 0.0F); - cube_r7.cubeList.add(new ModelBox(cube_r7, 31, -1, 0.0F, -0.5F, -0.5F, 0, 1, 1, 0.0F)); + cube_r7 = new ModelRenderer(this); + cube_r7.setRotationPoint(0.0F, -9.5F, 6.0F); + Candle.addChild(cube_r7); + setRotationAngle(cube_r7, 0.0F, 2.3562F, 0.0F); + cube_r7.cubeList.add(new ModelBox(cube_r7, 31, -1, 0.0F, -0.5F, -0.5F, 0, 1, 1, 0.0F)); - cube_r8 = new ModelRenderer(this); - cube_r8.setRotationPoint(0.0F, -9.5F, 6.0F); - Candle.addChild(cube_r8); - setRotationAngle(cube_r8, 0.0F, 0.7854F, 0.0F); - cube_r8.cubeList.add(new ModelBox(cube_r8, 31, -1, 0.0F, -0.5F, -0.5F, 0, 1, 1, 0.0F)); + cube_r8 = new ModelRenderer(this); + cube_r8.setRotationPoint(0.0F, -9.5F, 6.0F); + Candle.addChild(cube_r8); + setRotationAngle(cube_r8, 0.0F, 0.7854F, 0.0F); + cube_r8.cubeList.add(new ModelBox(cube_r8, 31, -1, 0.0F, -0.5F, -0.5F, 0, 1, 1, 0.0F)); - Holder = new ModelRenderer(this); - Holder.setRotationPoint(0.0F, 24.0F, 0.0F); - Holder.cubeList.add(new ModelBox(Holder, 12, 0, -2.0F, -5.0F, 4.0F, 4, 1, 4, 0.0F)); - Holder.cubeList.add(new ModelBox(Holder, 12, 0, -8.0F, -5.0F, -2.0F, 4, 1, 4, 0.0F)); - Holder.cubeList.add(new ModelBox(Holder, 12, 0, 4.0F, -5.0F, -2.0F, 4, 1, 4, 0.0F)); - Holder.cubeList.add(new ModelBox(Holder, 12, 0, -2.0F, -5.0F, -8.0F, 4, 1, 4, 0.0F)); + Holder = new ModelRenderer(this); + Holder.setRotationPoint(0.0F, 24.0F, 0.0F); + Holder.cubeList.add(new ModelBox(Holder, 12, 0, -2.0F, -5.0F, 4.0F, 4, 1, 4, 0.0F)); + Holder.cubeList.add(new ModelBox(Holder, 12, 0, -8.0F, -5.0F, -2.0F, 4, 1, 4, 0.0F)); + Holder.cubeList.add(new ModelBox(Holder, 12, 0, 4.0F, -5.0F, -2.0F, 4, 1, 4, 0.0F)); + Holder.cubeList.add(new ModelBox(Holder, 12, 0, -2.0F, -5.0F, -8.0F, 4, 1, 4, 0.0F)); - Base = new ModelRenderer(this); - Base.setRotationPoint(0.0F, 24.0F, 0.0F); - Base.cubeList.add(new ModelBox(Base, 12, 0, -2.0F, -2.0F, -2.0F, 4, 1, 4, 0.0F)); - Base.cubeList.add(new ModelBox(Base, 12, 0, 0.0F, -4.0F, 2.0F, 0, 3, 5, 0.0F)); + Base = new ModelRenderer(this); + Base.setRotationPoint(0.0F, 24.0F, 0.0F); + Base.cubeList.add(new ModelBox(Base, 12, 0, -2.0F, -2.0F, -2.0F, 4, 1, 4, 0.0F)); + Base.cubeList.add(new ModelBox(Base, 12, 0, 0.0F, -4.0F, 2.0F, 0, 3, 5, 0.0F)); - cube_r9 = new ModelRenderer(this); - cube_r9.setRotationPoint(4.5F, -2.5F, 0.0F); - Base.addChild(cube_r9); - setRotationAngle(cube_r9, 0.0F, 1.5708F, 0.0F); - cube_r9.cubeList.add(new ModelBox(cube_r9, 12, 0, 0.0F, -1.5F, -2.5F, 0, 3, 5, 0.0F)); + cube_r9 = new ModelRenderer(this); + cube_r9.setRotationPoint(4.5F, -2.5F, 0.0F); + Base.addChild(cube_r9); + setRotationAngle(cube_r9, 0.0F, 1.5708F, 0.0F); + cube_r9.cubeList.add(new ModelBox(cube_r9, 12, 0, 0.0F, -1.5F, -2.5F, 0, 3, 5, 0.0F)); - cube_r10 = new ModelRenderer(this); - cube_r10.setRotationPoint(-7.0F, -2.5F, 0.0F); - Base.addChild(cube_r10); - setRotationAngle(cube_r10, 0.0F, -1.5708F, 0.0F); - cube_r10.cubeList.add(new ModelBox(cube_r10, 12, 0, 0.0F, -1.5F, -5.0F, 0, 3, 5, 0.0F)); + cube_r10 = new ModelRenderer(this); + cube_r10.setRotationPoint(-7.0F, -2.5F, 0.0F); + Base.addChild(cube_r10); + setRotationAngle(cube_r10, 0.0F, -1.5708F, 0.0F); + cube_r10.cubeList.add(new ModelBox(cube_r10, 12, 0, 0.0F, -1.5F, -5.0F, 0, 3, 5, 0.0F)); - cube_r11 = new ModelRenderer(this); - cube_r11.setRotationPoint(0.0F, -2.5F, -4.5F); - Base.addChild(cube_r11); - setRotationAngle(cube_r11, 0.0F, 3.1416F, 0.0F); - cube_r11.cubeList.add(new ModelBox(cube_r11, 12, 0, 0.0F, -1.5F, -2.5F, 0, 3, 5, 0.0F)); + cube_r11 = new ModelRenderer(this); + cube_r11.setRotationPoint(0.0F, -2.5F, -4.5F); + Base.addChild(cube_r11); + setRotationAngle(cube_r11, 0.0F, 3.1416F, 0.0F); + cube_r11.cubeList.add(new ModelBox(cube_r11, 12, 0, 0.0F, -1.5F, -2.5F, 0, 3, 5, 0.0F)); - Chain = new ModelRenderer(this); - Chain.setRotationPoint(0.0F, 18.0F, 0.0F); + Chain = new ModelRenderer(this); + Chain.setRotationPoint(0.0F, 18.0F, 0.0F); - cube_r12 = new ModelRenderer(this); - cube_r12.setRotationPoint(0.0F, -3.0F, 0.0F); - Chain.addChild(cube_r12); - setRotationAngle(cube_r12, 0.0F, 0.7854F, 0.0F); - cube_r12.cubeList.add(new ModelBox(cube_r12, 6, -1, 0.0F, -7.0F, -1.5F, 0, 14, 3, 0.0F)); + cube_r12 = new ModelRenderer(this); + cube_r12.setRotationPoint(0.0F, -3.0F, 0.0F); + Chain.addChild(cube_r12); + setRotationAngle(cube_r12, 0.0F, 0.7854F, 0.0F); + cube_r12.cubeList.add(new ModelBox(cube_r12, 6, -1, 0.0F, -7.0F, -1.5F, 0, 14, 3, 0.0F)); - cube_r13 = new ModelRenderer(this); - cube_r13.setRotationPoint(0.0F, -3.0F, 0.0F); - Chain.addChild(cube_r13); - setRotationAngle(cube_r13, 0.0F, -0.7854F, 0.0F); - cube_r13.cubeList.add(new ModelBox(cube_r13, 0, -1, 0.0F, -7.0F, -1.5F, 0, 14, 3, 0.0F)); - } + cube_r13 = new ModelRenderer(this); + cube_r13.setRotationPoint(0.0F, -3.0F, 0.0F); + Chain.addChild(cube_r13); + setRotationAngle(cube_r13, 0.0F, -0.7854F, 0.0F); + cube_r13.cubeList.add(new ModelBox(cube_r13, 0, -1, 0.0F, -7.0F, -1.5F, 0, 14, 3, 0.0F)); + } - @Override - public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) { - Candle.render(f5); - Holder.render(f5); - Base.render(f5); - } + @Override + public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) { + Candle.render(f5); + Holder.render(f5); + Base.render(f5); + } - public void setRotationAngle(ModelRenderer modelRenderer, float x, float y, float z) { - modelRenderer.rotateAngleX = x; - modelRenderer.rotateAngleY = y; - modelRenderer.rotateAngleZ = z; - } + public void setRotationAngle(ModelRenderer modelRenderer, float x, float y, float z) { + modelRenderer.rotateAngleX = x; + modelRenderer.rotateAngleY = y; + modelRenderer.rotateAngleZ = z; + } } diff --git a/src/main/java/noppes/npcs/client/model/blocks/candle/ModelCandleWall.java b/src/main/java/noppes/npcs/client/model/blocks/candle/ModelCandleWall.java index 850674143..78ad90426 100644 --- a/src/main/java/noppes/npcs/client/model/blocks/candle/ModelCandleWall.java +++ b/src/main/java/noppes/npcs/client/model/blocks/candle/ModelCandleWall.java @@ -6,65 +6,65 @@ import net.minecraft.client.model.ModelRenderer; import net.minecraft.entity.Entity; public class ModelCandleWall extends ModelBase { - private final ModelRenderer Candle; - private final ModelRenderer cube_r1; - private final ModelRenderer cube_r2; - private final ModelRenderer Holder; - private final ModelRenderer bb_main; - private final ModelRenderer cube_r3; - private final ModelRenderer cube_r4; + private final ModelRenderer Candle; + private final ModelRenderer cube_r1; + private final ModelRenderer cube_r2; + private final ModelRenderer Holder; + private final ModelRenderer bb_main; + private final ModelRenderer cube_r3; + private final ModelRenderer cube_r4; - public ModelCandleWall() { - textureWidth = 64; - textureHeight = 32; + public ModelCandleWall() { + textureWidth = 64; + textureHeight = 32; - Candle = new ModelRenderer(this); - Candle.setRotationPoint(0.0F, 23.0F, 0.0F); - Candle.cubeList.add(new ModelBox(Candle, 28, 1, -1.0F, -12.0F, 2.0F, 2, 5, 2, 0.0F)); + Candle = new ModelRenderer(this); + Candle.setRotationPoint(0.0F, 23.0F, 0.0F); + Candle.cubeList.add(new ModelBox(Candle, 28, 1, -1.0F, -12.0F, 2.0F, 2, 5, 2, 0.0F)); - cube_r1 = new ModelRenderer(this); - cube_r1.setRotationPoint(0.0F, -12.5F, 3.0F); - Candle.addChild(cube_r1); - setRotationAngle(cube_r1, 0.0F, 2.3562F, 0.0F); - cube_r1.cubeList.add(new ModelBox(cube_r1, 31, -1, 0.0F, -0.5F, -0.5F, 0, 1, 1, 0.0F)); + cube_r1 = new ModelRenderer(this); + cube_r1.setRotationPoint(0.0F, -12.5F, 3.0F); + Candle.addChild(cube_r1); + setRotationAngle(cube_r1, 0.0F, 2.3562F, 0.0F); + cube_r1.cubeList.add(new ModelBox(cube_r1, 31, -1, 0.0F, -0.5F, -0.5F, 0, 1, 1, 0.0F)); - cube_r2 = new ModelRenderer(this); - cube_r2.setRotationPoint(0.0F, -12.5F, 3.0F); - Candle.addChild(cube_r2); - setRotationAngle(cube_r2, 0.0F, 0.7854F, 0.0F); - cube_r2.cubeList.add(new ModelBox(cube_r2, 31, -1, 0.0F, -0.5F, -0.5F, 0, 1, 1, 0.0F)); + cube_r2 = new ModelRenderer(this); + cube_r2.setRotationPoint(0.0F, -12.5F, 3.0F); + Candle.addChild(cube_r2); + setRotationAngle(cube_r2, 0.0F, 0.7854F, 0.0F); + cube_r2.cubeList.add(new ModelBox(cube_r2, 31, -1, 0.0F, -0.5F, -0.5F, 0, 1, 1, 0.0F)); - Holder = new ModelRenderer(this); - Holder.setRotationPoint(0.0F, 24.0F, 0.0F); - Holder.cubeList.add(new ModelBox(Holder, 12, 0, -2.0F, -8.0F, 1.0F, 4, 1, 4, 0.0F)); + Holder = new ModelRenderer(this); + Holder.setRotationPoint(0.0F, 24.0F, 0.0F); + Holder.cubeList.add(new ModelBox(Holder, 12, 0, -2.0F, -8.0F, 1.0F, 4, 1, 4, 0.0F)); - bb_main = new ModelRenderer(this); - bb_main.setRotationPoint(0.0F, 24.0F, 0.0F); + bb_main = new ModelRenderer(this); + bb_main.setRotationPoint(0.0F, 24.0F, 0.0F); - cube_r3 = new ModelRenderer(this); - cube_r3.setRotationPoint(0.0F, -5.5F, 4.5F); - bb_main.addChild(cube_r3); - setRotationAngle(cube_r3, 0.0F, 3.1416F, 0.0F); - cube_r3.cubeList.add(new ModelBox(cube_r3, 12, 3, 0.0F, -1.5F, -2.5F, 0, 3, 5, 0.0F)); + cube_r3 = new ModelRenderer(this); + cube_r3.setRotationPoint(0.0F, -5.5F, 4.5F); + bb_main.addChild(cube_r3); + setRotationAngle(cube_r3, 0.0F, 3.1416F, 0.0F); + cube_r3.cubeList.add(new ModelBox(cube_r3, 12, 3, 0.0F, -1.5F, -2.5F, 0, 3, 5, 0.0F)); - cube_r4 = new ModelRenderer(this); - cube_r4.setRotationPoint(0.0F, -4.5F, 9.0F); - bb_main.addChild(cube_r4); - setRotationAngle(cube_r4, 1.5708F, 0.0F, 0.0F); - cube_r4.cubeList.add(new ModelBox(cube_r4, 12, 0, -2.0F, -2.0F, -1.5F, 4, 1, 4, 0.0F)); - } + cube_r4 = new ModelRenderer(this); + cube_r4.setRotationPoint(0.0F, -4.5F, 9.0F); + bb_main.addChild(cube_r4); + setRotationAngle(cube_r4, 1.5708F, 0.0F, 0.0F); + cube_r4.cubeList.add(new ModelBox(cube_r4, 12, 0, -2.0F, -2.0F, -1.5F, 4, 1, 4, 0.0F)); + } - @Override - public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) { - Candle.render(f5); - Holder.render(f5); - bb_main.render(f5); - } + @Override + public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) { + Candle.render(f5); + Holder.render(f5); + bb_main.render(f5); + } - public void setRotationAngle(ModelRenderer modelRenderer, float x, float y, float z) { - modelRenderer.rotateAngleX = x; - modelRenderer.rotateAngleY = y; - modelRenderer.rotateAngleZ = z; - } + public void setRotationAngle(ModelRenderer modelRenderer, float x, float y, float z) { + modelRenderer.rotateAngleX = x; + modelRenderer.rotateAngleY = y; + modelRenderer.rotateAngleZ = z; + } } diff --git a/src/main/java/noppes/npcs/client/model/blocks/chair/ModelChair.java b/src/main/java/noppes/npcs/client/model/blocks/chair/ModelChair.java index 84bff4eac..01913eb40 100644 --- a/src/main/java/noppes/npcs/client/model/blocks/chair/ModelChair.java +++ b/src/main/java/noppes/npcs/client/model/blocks/chair/ModelChair.java @@ -6,36 +6,36 @@ import net.minecraft.client.model.ModelRenderer; import net.minecraft.entity.Entity; public class ModelChair extends ModelBase { - private final ModelRenderer bb_main; + private final ModelRenderer bb_main; - public ModelChair(){ - textureWidth = 64; - textureHeight = 32; + public ModelChair() { + textureWidth = 64; + textureHeight = 32; - bb_main = new ModelRenderer(this); - bb_main.setRotationPoint(0.0F, 24.0F, 0.0F); - bb_main.cubeList.add(new ModelBox(bb_main, 0, 17, 4.0F, -6.0F, 4.0F, 2, 6, 2, 0.0F)); - bb_main.cubeList.add(new ModelBox(bb_main, 0, 17, -6.0F, -6.0F, 4.0F, 2, 6, 2, 0.0F)); - bb_main.cubeList.add(new ModelBox(bb_main, 0, 17, -6.0F, -6.0F, -6.0F, 2, 6, 2, 0.0F)); - bb_main.cubeList.add(new ModelBox(bb_main, 0, 17, 4.0F, -6.0F, -6.0F, 2, 6, 2, 0.0F)); - bb_main.cubeList.add(new ModelBox(bb_main, 0, 0, -6.0F, -8.0F, -6.0F, 12, 2, 12, 0.0F)); - bb_main.cubeList.add(new ModelBox(bb_main, 8, 17, 4.0F, -20.0F, 4.0F, 2, 12, 2, 0.0F)); - bb_main.cubeList.add(new ModelBox(bb_main, 8, 17, -6.0F, -20.0F, 4.0F, 2, 12, 2, 0.0F)); - bb_main.cubeList.add(new ModelBox(bb_main, 16, 18, -4.0F, -19.0F, 5.0F, 8, 11, 0, 0.0F)); - bb_main.cubeList.add(new ModelBox(bb_main, 16, 8, 5.0F, -4.0F, -4.0F, 0, 2, 8, 0.0F)); - bb_main.cubeList.add(new ModelBox(bb_main, 16, 16, -4.0F, -4.0F, -5.0F, 8, 2, 0, 0.0F)); - bb_main.cubeList.add(new ModelBox(bb_main, 16, 8, -5.0F, -4.0F, -4.0F, 0, 2, 8, 0.0F)); - bb_main.cubeList.add(new ModelBox(bb_main, 16, 16, -4.0F, -4.0F, 5.0F, 8, 2, 0, 0.0F)); - } + bb_main = new ModelRenderer(this); + bb_main.setRotationPoint(0.0F, 24.0F, 0.0F); + bb_main.cubeList.add(new ModelBox(bb_main, 0, 17, 4.0F, -6.0F, 4.0F, 2, 6, 2, 0.0F)); + bb_main.cubeList.add(new ModelBox(bb_main, 0, 17, -6.0F, -6.0F, 4.0F, 2, 6, 2, 0.0F)); + bb_main.cubeList.add(new ModelBox(bb_main, 0, 17, -6.0F, -6.0F, -6.0F, 2, 6, 2, 0.0F)); + bb_main.cubeList.add(new ModelBox(bb_main, 0, 17, 4.0F, -6.0F, -6.0F, 2, 6, 2, 0.0F)); + bb_main.cubeList.add(new ModelBox(bb_main, 0, 0, -6.0F, -8.0F, -6.0F, 12, 2, 12, 0.0F)); + bb_main.cubeList.add(new ModelBox(bb_main, 8, 17, 4.0F, -20.0F, 4.0F, 2, 12, 2, 0.0F)); + bb_main.cubeList.add(new ModelBox(bb_main, 8, 17, -6.0F, -20.0F, 4.0F, 2, 12, 2, 0.0F)); + bb_main.cubeList.add(new ModelBox(bb_main, 16, 18, -4.0F, -19.0F, 5.0F, 8, 11, 0, 0.0F)); + bb_main.cubeList.add(new ModelBox(bb_main, 16, 8, 5.0F, -4.0F, -4.0F, 0, 2, 8, 0.0F)); + bb_main.cubeList.add(new ModelBox(bb_main, 16, 16, -4.0F, -4.0F, -5.0F, 8, 2, 0, 0.0F)); + bb_main.cubeList.add(new ModelBox(bb_main, 16, 8, -5.0F, -4.0F, -4.0F, 0, 2, 8, 0.0F)); + bb_main.cubeList.add(new ModelBox(bb_main, 16, 16, -4.0F, -4.0F, 5.0F, 8, 2, 0, 0.0F)); + } - @Override - public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) { - bb_main.render(f5); - } + @Override + public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) { + bb_main.render(f5); + } - public void setRotationAngle(ModelRenderer modelRenderer, float x, float y, float z) { - modelRenderer.rotateAngleX = x; - modelRenderer.rotateAngleY = y; - modelRenderer.rotateAngleZ = z; - } + public void setRotationAngle(ModelRenderer modelRenderer, float x, float y, float z) { + modelRenderer.rotateAngleX = x; + modelRenderer.rotateAngleY = y; + modelRenderer.rotateAngleZ = z; + } } diff --git a/src/main/java/noppes/npcs/client/model/blocks/chair/ModelChairSpoof.java b/src/main/java/noppes/npcs/client/model/blocks/chair/ModelChairSpoof.java index eccad5767..258190e06 100644 --- a/src/main/java/noppes/npcs/client/model/blocks/chair/ModelChairSpoof.java +++ b/src/main/java/noppes/npcs/client/model/blocks/chair/ModelChairSpoof.java @@ -10,35 +10,35 @@ public class ModelChairSpoof extends ModelBase { private final ModelRenderer chairBase; - public ModelChairSpoof() { - textureWidth = 64; - textureHeight = 32; + public ModelChairSpoof() { + textureWidth = 64; + textureHeight = 32; - chairBase = new ModelRenderer(this); - chairBase.setRotationPoint(0.0F, 24.0F, 0.0F); - chairBase.cubeList.add(new ModelBox(chairBase, 0, 0, 4.0F, -6.0F, 4.0F, 2, 6, 2, 0.0F)); - chairBase.cubeList.add(new ModelBox(chairBase, 0, 0, -6.0F, -6.0F, 4.0F, 2, 6, 2, 0.0F)); - chairBase.cubeList.add(new ModelBox(chairBase, 0, 0, -6.0F, -6.0F, -6.0F, 2, 6, 2, 0.0F)); - chairBase.cubeList.add(new ModelBox(chairBase, 0, 0, 4.0F, -6.0F, -6.0F, 2, 6, 2, 0.0F)); - chairBase.cubeList.add(new ModelBox(chairBase, 0, 0, -6.0F, -8.0F, -6.0F, 12, 2, 12, 0.0F)); - chairBase.cubeList.add(new ModelBox(chairBase, 12, 0, 4.0F, -20.0F, 4.0F, 2, 12, 2, 0.0F)); - chairBase.cubeList.add(new ModelBox(chairBase, 30, 0, -6.0F, -20.0F, 4.0F, 2, 12, 2, 0.0F)); - chairBase.cubeList.add(new ModelBox(chairBase, 0, 2, -4.0F, -19.0F, 5.0F, 8, 3, 0, 0.0F)); - chairBase.cubeList.add(new ModelBox(chairBase, -5, -6, 5.0F, -4.0F, -4.0F, 0, 2, 8, 0.0F)); - chairBase.cubeList.add(new ModelBox(chairBase, 1, 2, -4.0F, -4.0F, -5.0F, 8, 2, 0, 0.0F)); - chairBase.cubeList.add(new ModelBox(chairBase, -5, -6, -5.0F, -4.0F, -4.0F, 0, 2, 8, 0.0F)); - chairBase.cubeList.add(new ModelBox(chairBase, -3, 2, -4.0F, -4.0F, 5.0F, 8, 2, 0, 0.0F)); - chairBase.cubeList.add(new ModelBox(chairBase, 0, 2, -4.0F, -13.0F, 5.0F, 8, 3, 0, 0.0F)); - } + chairBase = new ModelRenderer(this); + chairBase.setRotationPoint(0.0F, 24.0F, 0.0F); + chairBase.cubeList.add(new ModelBox(chairBase, 0, 0, 4.0F, -6.0F, 4.0F, 2, 6, 2, 0.0F)); + chairBase.cubeList.add(new ModelBox(chairBase, 0, 0, -6.0F, -6.0F, 4.0F, 2, 6, 2, 0.0F)); + chairBase.cubeList.add(new ModelBox(chairBase, 0, 0, -6.0F, -6.0F, -6.0F, 2, 6, 2, 0.0F)); + chairBase.cubeList.add(new ModelBox(chairBase, 0, 0, 4.0F, -6.0F, -6.0F, 2, 6, 2, 0.0F)); + chairBase.cubeList.add(new ModelBox(chairBase, 0, 0, -6.0F, -8.0F, -6.0F, 12, 2, 12, 0.0F)); + chairBase.cubeList.add(new ModelBox(chairBase, 12, 0, 4.0F, -20.0F, 4.0F, 2, 12, 2, 0.0F)); + chairBase.cubeList.add(new ModelBox(chairBase, 30, 0, -6.0F, -20.0F, 4.0F, 2, 12, 2, 0.0F)); + chairBase.cubeList.add(new ModelBox(chairBase, 0, 2, -4.0F, -19.0F, 5.0F, 8, 3, 0, 0.0F)); + chairBase.cubeList.add(new ModelBox(chairBase, -5, -6, 5.0F, -4.0F, -4.0F, 0, 2, 8, 0.0F)); + chairBase.cubeList.add(new ModelBox(chairBase, 1, 2, -4.0F, -4.0F, -5.0F, 8, 2, 0, 0.0F)); + chairBase.cubeList.add(new ModelBox(chairBase, -5, -6, -5.0F, -4.0F, -4.0F, 0, 2, 8, 0.0F)); + chairBase.cubeList.add(new ModelBox(chairBase, -3, 2, -4.0F, -4.0F, 5.0F, 8, 2, 0, 0.0F)); + chairBase.cubeList.add(new ModelBox(chairBase, 0, 2, -4.0F, -13.0F, 5.0F, 8, 3, 0, 0.0F)); + } - @Override - public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) { - chairBase.render(f5); - } + @Override + public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) { + chairBase.render(f5); + } - public void setRotationAngle(ModelRenderer modelRenderer, float x, float y, float z) { - modelRenderer.rotateAngleX = x; - modelRenderer.rotateAngleY = y; - modelRenderer.rotateAngleZ = z; - } + public void setRotationAngle(ModelRenderer modelRenderer, float x, float y, float z) { + modelRenderer.rotateAngleX = x; + modelRenderer.rotateAngleY = y; + modelRenderer.rotateAngleZ = z; + } } diff --git a/src/main/java/noppes/npcs/client/model/blocks/couch/ModelCouchCorner.java b/src/main/java/noppes/npcs/client/model/blocks/couch/ModelCouchCorner.java index 71520c74f..37a743e3b 100644 --- a/src/main/java/noppes/npcs/client/model/blocks/couch/ModelCouchCorner.java +++ b/src/main/java/noppes/npcs/client/model/blocks/couch/ModelCouchCorner.java @@ -51,7 +51,8 @@ public class ModelCouchCorner extends ModelBase { } @Override - public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) {} + public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) { + } public void setRotationAngle(ModelRenderer modelRenderer, float x, float y, float z) { modelRenderer.rotateAngleX = x; diff --git a/src/main/java/noppes/npcs/client/model/blocks/couch/ModelCouchMiddle.java b/src/main/java/noppes/npcs/client/model/blocks/couch/ModelCouchMiddle.java index b7fc591b3..9b43dd403 100644 --- a/src/main/java/noppes/npcs/client/model/blocks/couch/ModelCouchMiddle.java +++ b/src/main/java/noppes/npcs/client/model/blocks/couch/ModelCouchMiddle.java @@ -30,7 +30,8 @@ public class ModelCouchMiddle extends ModelBase { } @Override - public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) {} + public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) { + } public void setRotationAngle(ModelRenderer modelRenderer, float x, float y, float z) { modelRenderer.rotateAngleX = x; diff --git a/src/main/java/noppes/npcs/client/model/blocks/couch/ModelCouchSingle.java b/src/main/java/noppes/npcs/client/model/blocks/couch/ModelCouchSingle.java index 32b56f527..6b0512fdc 100644 --- a/src/main/java/noppes/npcs/client/model/blocks/couch/ModelCouchSingle.java +++ b/src/main/java/noppes/npcs/client/model/blocks/couch/ModelCouchSingle.java @@ -52,7 +52,8 @@ public class ModelCouchSingle extends ModelBase { } @Override - public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) {} + public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) { + } public void setRotationAngle(ModelRenderer modelRenderer, float x, float y, float z) { modelRenderer.rotateAngleX = x; diff --git a/src/main/java/noppes/npcs/client/model/blocks/lamp/ModelShortLamp.java b/src/main/java/noppes/npcs/client/model/blocks/lamp/ModelShortLamp.java index 440faa0f3..1cfe2d712 100644 --- a/src/main/java/noppes/npcs/client/model/blocks/lamp/ModelShortLamp.java +++ b/src/main/java/noppes/npcs/client/model/blocks/lamp/ModelShortLamp.java @@ -6,73 +6,74 @@ import net.minecraft.client.model.ModelRenderer; import net.minecraft.entity.Entity; public class ModelShortLamp extends ModelBase { - public final ModelRenderer Shade; - private final ModelRenderer cube_r1; - private final ModelRenderer cube_r2; + public final ModelRenderer Shade; + private final ModelRenderer cube_r1; + private final ModelRenderer cube_r2; public final ModelRenderer Lamp; - private final ModelRenderer cube_r3; - private final ModelRenderer cube_r4; - private final ModelRenderer cube_r5; + private final ModelRenderer cube_r3; + private final ModelRenderer cube_r4; + private final ModelRenderer cube_r5; public final ModelRenderer Light; - public ModelShortLamp() { - textureWidth = 64; - textureHeight = 64; + public ModelShortLamp() { + textureWidth = 64; + textureHeight = 64; - Shade = new ModelRenderer(this); - Shade.setRotationPoint(-4.0F, 12.0F, 0.0F); - Shade.cubeList.add(new ModelBox(Shade, 0, 8, 0.0F, -4.0F, -4.0F, 8, 8, 0, 0.0F)); - Shade.cubeList.add(new ModelBox(Shade, -8, 0, 0.0F, -4.0F, -4.0F, 8, 0, 8, 0.0F)); - Shade.cubeList.add(new ModelBox(Shade, 0, 8, 0.0F, -4.0F, 4.0F, 8, 8, 0, 0.0F)); + Shade = new ModelRenderer(this); + Shade.setRotationPoint(-4.0F, 12.0F, 0.0F); + Shade.cubeList.add(new ModelBox(Shade, 0, 8, 0.0F, -4.0F, -4.0F, 8, 8, 0, 0.0F)); + Shade.cubeList.add(new ModelBox(Shade, -8, 0, 0.0F, -4.0F, -4.0F, 8, 0, 8, 0.0F)); + Shade.cubeList.add(new ModelBox(Shade, 0, 8, 0.0F, -4.0F, 4.0F, 8, 8, 0, 0.0F)); - cube_r1 = new ModelRenderer(this); - cube_r1.setRotationPoint(0.0F, 0.0F, 0.0F); - Shade.addChild(cube_r1); - setRotationAngle(cube_r1, 0.0F, 1.5708F, 0.0F); - cube_r1.cubeList.add(new ModelBox(cube_r1, 0, 8, -4.0F, -4.0F, 0.0F, 8, 8, 0, 0.0F)); + cube_r1 = new ModelRenderer(this); + cube_r1.setRotationPoint(0.0F, 0.0F, 0.0F); + Shade.addChild(cube_r1); + setRotationAngle(cube_r1, 0.0F, 1.5708F, 0.0F); + cube_r1.cubeList.add(new ModelBox(cube_r1, 0, 8, -4.0F, -4.0F, 0.0F, 8, 8, 0, 0.0F)); - cube_r2 = new ModelRenderer(this); - cube_r2.setRotationPoint(8.0F, 0.0F, 0.0F); - Shade.addChild(cube_r2); - setRotationAngle(cube_r2, 0.0F, 1.5708F, 0.0F); - cube_r2.cubeList.add(new ModelBox(cube_r2, 0, 8, -4.0F, -4.0F, 0.0F, 8, 8, 0, 0.0F)); + cube_r2 = new ModelRenderer(this); + cube_r2.setRotationPoint(8.0F, 0.0F, 0.0F); + Shade.addChild(cube_r2); + setRotationAngle(cube_r2, 0.0F, 1.5708F, 0.0F); + cube_r2.cubeList.add(new ModelBox(cube_r2, 0, 8, -4.0F, -4.0F, 0.0F, 8, 8, 0, 0.0F)); - Lamp = new ModelRenderer(this); - Lamp.setRotationPoint(0.0F, 24.0F, 0.0F); - Lamp.cubeList.add(new ModelBox(Lamp, 28, 8, -3.0F, -6.0F, -3.0F, 6, 6, 6, 0.0F)); - Lamp.cubeList.add(new ModelBox(Lamp, 20, 5, -1.0F, -9.0F, -1.0F, 2, 3, 2, 0.0F)); - Lamp.cubeList.add(new ModelBox(Lamp, 20, 0, -1.0F, -16.0F, -1.0F, 2, 3, 2, 0.0F)); - Lamp.cubeList.add(new ModelBox(Lamp, 14, 0, -3.0F, -16.0F, -1.0F, 2, 0, 2, 0.0F)); + Lamp = new ModelRenderer(this); + Lamp.setRotationPoint(0.0F, 24.0F, 0.0F); + Lamp.cubeList.add(new ModelBox(Lamp, 28, 8, -3.0F, -6.0F, -3.0F, 6, 6, 6, 0.0F)); + Lamp.cubeList.add(new ModelBox(Lamp, 20, 5, -1.0F, -9.0F, -1.0F, 2, 3, 2, 0.0F)); + Lamp.cubeList.add(new ModelBox(Lamp, 20, 0, -1.0F, -16.0F, -1.0F, 2, 3, 2, 0.0F)); + Lamp.cubeList.add(new ModelBox(Lamp, 14, 0, -3.0F, -16.0F, -1.0F, 2, 0, 2, 0.0F)); - cube_r3 = new ModelRenderer(this); - cube_r3.setRotationPoint(0.0F, -16.0F, -2.5F); - Lamp.addChild(cube_r3); - setRotationAngle(cube_r3, 0.0F, -1.5708F, 0.0F); - cube_r3.cubeList.add(new ModelBox(cube_r3, 14, 0, -0.5F, 0.0F, -1.0F, 2, 0, 2, 0.0F)); + cube_r3 = new ModelRenderer(this); + cube_r3.setRotationPoint(0.0F, -16.0F, -2.5F); + Lamp.addChild(cube_r3); + setRotationAngle(cube_r3, 0.0F, -1.5708F, 0.0F); + cube_r3.cubeList.add(new ModelBox(cube_r3, 14, 0, -0.5F, 0.0F, -1.0F, 2, 0, 2, 0.0F)); - cube_r4 = new ModelRenderer(this); - cube_r4.setRotationPoint(0.0F, -16.0F, 2.5F); - Lamp.addChild(cube_r4); - setRotationAngle(cube_r4, 0.0F, 1.5708F, 0.0F); - cube_r4.cubeList.add(new ModelBox(cube_r4, 14, 0, -0.5F, 0.0F, -1.0F, 2, 0, 2, 0.0F)); + cube_r4 = new ModelRenderer(this); + cube_r4.setRotationPoint(0.0F, -16.0F, 2.5F); + Lamp.addChild(cube_r4); + setRotationAngle(cube_r4, 0.0F, 1.5708F, 0.0F); + cube_r4.cubeList.add(new ModelBox(cube_r4, 14, 0, -0.5F, 0.0F, -1.0F, 2, 0, 2, 0.0F)); - cube_r5 = new ModelRenderer(this); - cube_r5.setRotationPoint(2.5F, -16.0F, 0.0F); - Lamp.addChild(cube_r5); - setRotationAngle(cube_r5, -3.1416F, 0.0F, 0.0F); - cube_r5.cubeList.add(new ModelBox(cube_r5, 14, 0, -1.5F, 0.0F, -1.0F, 2, 0, 2, 0.0F)); + cube_r5 = new ModelRenderer(this); + cube_r5.setRotationPoint(2.5F, -16.0F, 0.0F); + Lamp.addChild(cube_r5); + setRotationAngle(cube_r5, -3.1416F, 0.0F, 0.0F); + cube_r5.cubeList.add(new ModelBox(cube_r5, 14, 0, -1.5F, 0.0F, -1.0F, 2, 0, 2, 0.0F)); - Light = new ModelRenderer(this); - Light.setRotationPoint(0.0F, 24.0F, 0.0F); - Light.cubeList.add(new ModelBox(Light, 28, 0, -2.0F, -13.0F, -2.0F, 4, 4, 4, 0.0F)); - } + Light = new ModelRenderer(this); + Light.setRotationPoint(0.0F, 24.0F, 0.0F); + Light.cubeList.add(new ModelBox(Light, 28, 0, -2.0F, -13.0F, -2.0F, 4, 4, 4, 0.0F)); + } - @Override - public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) {} + @Override + public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) { + } - public void setRotationAngle(ModelRenderer modelRenderer, float x, float y, float z) { - modelRenderer.rotateAngleX = x; - modelRenderer.rotateAngleY = y; - modelRenderer.rotateAngleZ = z; - } + public void setRotationAngle(ModelRenderer modelRenderer, float x, float y, float z) { + modelRenderer.rotateAngleX = x; + modelRenderer.rotateAngleY = y; + modelRenderer.rotateAngleZ = z; + } } diff --git a/src/main/java/noppes/npcs/client/model/blocks/lamp/ModelTallLamp.java b/src/main/java/noppes/npcs/client/model/blocks/lamp/ModelTallLamp.java index 41ebee6dd..fb7cb66a3 100644 --- a/src/main/java/noppes/npcs/client/model/blocks/lamp/ModelTallLamp.java +++ b/src/main/java/noppes/npcs/client/model/blocks/lamp/ModelTallLamp.java @@ -6,73 +6,74 @@ import net.minecraft.client.model.ModelRenderer; import net.minecraft.entity.Entity; public class ModelTallLamp extends ModelBase { - public final ModelRenderer Shade; - private final ModelRenderer cube_r1; - private final ModelRenderer cube_r2; + public final ModelRenderer Shade; + private final ModelRenderer cube_r1; + private final ModelRenderer cube_r2; public final ModelRenderer Lamp; - private final ModelRenderer cube_r3; - private final ModelRenderer cube_r4; - private final ModelRenderer cube_r5; + private final ModelRenderer cube_r3; + private final ModelRenderer cube_r4; + private final ModelRenderer cube_r5; public final ModelRenderer Light; - public ModelTallLamp() { - textureWidth = 64; - textureHeight = 64; + public ModelTallLamp() { + textureWidth = 64; + textureHeight = 64; - Shade = new ModelRenderer(this); - Shade.setRotationPoint(0.0F, -6.0F, 7.0F); - Shade.cubeList.add(new ModelBox(Shade, 0, 12, -6.0F, -2.0F, -13.0F, 12, 12, 0, 0.0F)); - Shade.cubeList.add(new ModelBox(Shade, -12, 0, -6.0F, -2.0F, -13.0F, 12, 0, 12, 0.0F)); - Shade.cubeList.add(new ModelBox(Shade, 0, 12, -6.0F, -2.0F, -1.0F, 12, 12, 0, 0.0F)); + Shade = new ModelRenderer(this); + Shade.setRotationPoint(0.0F, -6.0F, 7.0F); + Shade.cubeList.add(new ModelBox(Shade, 0, 12, -6.0F, -2.0F, -13.0F, 12, 12, 0, 0.0F)); + Shade.cubeList.add(new ModelBox(Shade, -12, 0, -6.0F, -2.0F, -13.0F, 12, 0, 12, 0.0F)); + Shade.cubeList.add(new ModelBox(Shade, 0, 12, -6.0F, -2.0F, -1.0F, 12, 12, 0, 0.0F)); - cube_r1 = new ModelRenderer(this); - cube_r1.setRotationPoint(6.0F, 4.0F, -7.0F); - Shade.addChild(cube_r1); - setRotationAngle(cube_r1, 0.0F, 1.5708F, 0.0F); - cube_r1.cubeList.add(new ModelBox(cube_r1, 0, 12, -6.0F, -6.0F, 0.0F, 12, 12, 0, 0.0F)); + cube_r1 = new ModelRenderer(this); + cube_r1.setRotationPoint(6.0F, 4.0F, -7.0F); + Shade.addChild(cube_r1); + setRotationAngle(cube_r1, 0.0F, 1.5708F, 0.0F); + cube_r1.cubeList.add(new ModelBox(cube_r1, 0, 12, -6.0F, -6.0F, 0.0F, 12, 12, 0, 0.0F)); - cube_r2 = new ModelRenderer(this); - cube_r2.setRotationPoint(-6.0F, 4.0F, -7.0F); - Shade.addChild(cube_r2); - setRotationAngle(cube_r2, 0.0F, 1.5708F, 0.0F); - cube_r2.cubeList.add(new ModelBox(cube_r2, 0, 12, -6.0F, -6.0F, 0.0F, 12, 12, 0, 0.0F)); + cube_r2 = new ModelRenderer(this); + cube_r2.setRotationPoint(-6.0F, 4.0F, -7.0F); + Shade.addChild(cube_r2); + setRotationAngle(cube_r2, 0.0F, 1.5708F, 0.0F); + cube_r2.cubeList.add(new ModelBox(cube_r2, 0, 12, -6.0F, -6.0F, 0.0F, 12, 12, 0, 0.0F)); - Lamp = new ModelRenderer(this); - Lamp.setRotationPoint(0.0F, 24.0F, 0.0F); - Lamp.cubeList.add(new ModelBox(Lamp, 40, 22, -3.0F, -2.0F, -3.0F, 6, 2, 6, 0.0F)); - Lamp.cubeList.add(new ModelBox(Lamp, 32, 5, -1.0F, -25.0F, -1.0F, 2, 23, 2, 0.0F)); - Lamp.cubeList.add(new ModelBox(Lamp, 32, 0, -1.0F, -32.0F, -1.0F, 2, 3, 2, 0.0F)); - Lamp.cubeList.add(new ModelBox(Lamp, 22, 0, -4.0F, -32.0F, -1.0F, 3, 0, 2, 0.0F)); + Lamp = new ModelRenderer(this); + Lamp.setRotationPoint(0.0F, 24.0F, 0.0F); + Lamp.cubeList.add(new ModelBox(Lamp, 40, 22, -3.0F, -2.0F, -3.0F, 6, 2, 6, 0.0F)); + Lamp.cubeList.add(new ModelBox(Lamp, 32, 5, -1.0F, -25.0F, -1.0F, 2, 23, 2, 0.0F)); + Lamp.cubeList.add(new ModelBox(Lamp, 32, 0, -1.0F, -32.0F, -1.0F, 2, 3, 2, 0.0F)); + Lamp.cubeList.add(new ModelBox(Lamp, 22, 0, -4.0F, -32.0F, -1.0F, 3, 0, 2, 0.0F)); - cube_r3 = new ModelRenderer(this); - cube_r3.setRotationPoint(0.0F, -32.0F, -2.5F); - Lamp.addChild(cube_r3); - setRotationAngle(cube_r3, 0.0F, -1.5708F, 0.0F); - cube_r3.cubeList.add(new ModelBox(cube_r3, 22, 0, -1.5F, 0.0F, -1.0F, 3, 0, 2, 0.0F)); + cube_r3 = new ModelRenderer(this); + cube_r3.setRotationPoint(0.0F, -32.0F, -2.5F); + Lamp.addChild(cube_r3); + setRotationAngle(cube_r3, 0.0F, -1.5708F, 0.0F); + cube_r3.cubeList.add(new ModelBox(cube_r3, 22, 0, -1.5F, 0.0F, -1.0F, 3, 0, 2, 0.0F)); - cube_r4 = new ModelRenderer(this); - cube_r4.setRotationPoint(0.0F, -32.0F, 2.5F); - Lamp.addChild(cube_r4); - setRotationAngle(cube_r4, 0.0F, 1.5708F, 0.0F); - cube_r4.cubeList.add(new ModelBox(cube_r4, 22, 0, -1.5F, 0.0F, -1.0F, 3, 0, 2, 0.0F)); + cube_r4 = new ModelRenderer(this); + cube_r4.setRotationPoint(0.0F, -32.0F, 2.5F); + Lamp.addChild(cube_r4); + setRotationAngle(cube_r4, 0.0F, 1.5708F, 0.0F); + cube_r4.cubeList.add(new ModelBox(cube_r4, 22, 0, -1.5F, 0.0F, -1.0F, 3, 0, 2, 0.0F)); - cube_r5 = new ModelRenderer(this); - cube_r5.setRotationPoint(2.5F, -32.0F, 0.0F); - Lamp.addChild(cube_r5); - setRotationAngle(cube_r5, -3.1416F, 0.0F, 0.0F); - cube_r5.cubeList.add(new ModelBox(cube_r5, 22, 0, -1.5F, 0.0F, -1.0F, 3, 0, 2, 0.0F)); + cube_r5 = new ModelRenderer(this); + cube_r5.setRotationPoint(2.5F, -32.0F, 0.0F); + Lamp.addChild(cube_r5); + setRotationAngle(cube_r5, -3.1416F, 0.0F, 0.0F); + cube_r5.cubeList.add(new ModelBox(cube_r5, 22, 0, -1.5F, 0.0F, -1.0F, 3, 0, 2, 0.0F)); - Light = new ModelRenderer(this); - Light.setRotationPoint(0.0F, 24.0F, 0.0F); - Light.cubeList.add(new ModelBox(Light, 40, 14, -2.0F, -29.0F, -2.0F, 4, 4, 4, 0.0F)); - } + Light = new ModelRenderer(this); + Light.setRotationPoint(0.0F, 24.0F, 0.0F); + Light.cubeList.add(new ModelBox(Light, 40, 14, -2.0F, -29.0F, -2.0F, 4, 4, 4, 0.0F)); + } - @Override - public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) {} + @Override + public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) { + } - public void setRotationAngle(ModelRenderer modelRenderer, float x, float y, float z) { - modelRenderer.rotateAngleX = x; - modelRenderer.rotateAngleY = y; - modelRenderer.rotateAngleZ = z; - } + public void setRotationAngle(ModelRenderer modelRenderer, float x, float y, float z) { + modelRenderer.rotateAngleX = x; + modelRenderer.rotateAngleY = y; + modelRenderer.rotateAngleZ = z; + } } diff --git a/src/main/java/noppes/npcs/client/model/blocks/lantern/LanternCeiling.java b/src/main/java/noppes/npcs/client/model/blocks/lantern/LanternCeiling.java index fbb74ee84..a8315cf09 100644 --- a/src/main/java/noppes/npcs/client/model/blocks/lantern/LanternCeiling.java +++ b/src/main/java/noppes/npcs/client/model/blocks/lantern/LanternCeiling.java @@ -12,49 +12,49 @@ public class LanternCeiling extends ModelBase { private final ModelRenderer cube_r1; private final ModelRenderer cube_r2; - public LanternCeiling() { - textureWidth = 64; - textureHeight = 32; + public LanternCeiling() { + textureWidth = 64; + textureHeight = 32; - Light = new ModelRenderer(this); - Light.setRotationPoint(0.0F, 24.0F, 0.0F); - Light.cubeList.add(new ModelBox(Light, 28, 8, -3.0F, -9.0F, -3.0F, 6, 7, 6, 0.0F)); + Light = new ModelRenderer(this); + Light.setRotationPoint(0.0F, 24.0F, 0.0F); + Light.cubeList.add(new ModelBox(Light, 28, 8, -3.0F, -9.0F, -3.0F, 6, 7, 6, 0.0F)); - Lantern = new ModelRenderer(this); - Lantern.setRotationPoint(0.0F, 24.0F, 0.0F); - Lantern.cubeList.add(new ModelBox(Lantern, 28, 0, -3.0F, -2.0F, -3.0F, 6, 2, 6, 0.0F)); - Lantern.cubeList.add(new ModelBox(Lantern, 28, 21, -2.0F, -11.0F, -2.0F, 4, 2, 4, 0.0F)); + Lantern = new ModelRenderer(this); + Lantern.setRotationPoint(0.0F, 24.0F, 0.0F); + Lantern.cubeList.add(new ModelBox(Lantern, 28, 0, -3.0F, -2.0F, -3.0F, 6, 2, 6, 0.0F)); + Lantern.cubeList.add(new ModelBox(Lantern, 28, 21, -2.0F, -11.0F, -2.0F, 4, 2, 4, 0.0F)); Lantern.cubeList.add(new ModelBox(Lantern, 46, 21, -5.0F, -11.0F, 0.0F, 3, 11, 0, 0.0F)); Lantern.mirror = true; Lantern.cubeList.add(new ModelBox(Lantern, 46, 21, 2.0F, -11.0F, 0.0F, 3, 11, 0, 0.0F)); Lantern.mirror = false; - Chain = new ModelRenderer(this); - Chain.setRotationPoint(0.0F, 24.0F, 0.0F); + Chain = new ModelRenderer(this); + Chain.setRotationPoint(0.0F, 24.0F, 0.0F); - cube_r1 = new ModelRenderer(this); - cube_r1.setRotationPoint(0.0F, -18.0F, 0.0F); - Chain.addChild(cube_r1); - setRotationAngle(cube_r1, 0.0F, -0.7854F, 0.0F); - cube_r1.cubeList.add(new ModelBox(cube_r1, 0, -1, 0.0F, 2.0F, -1.5F, 0, 5, 3, 0.0F)); + cube_r1 = new ModelRenderer(this); + cube_r1.setRotationPoint(0.0F, -18.0F, 0.0F); + Chain.addChild(cube_r1); + setRotationAngle(cube_r1, 0.0F, -0.7854F, 0.0F); + cube_r1.cubeList.add(new ModelBox(cube_r1, 0, -1, 0.0F, 2.0F, -1.5F, 0, 5, 3, 0.0F)); - cube_r2 = new ModelRenderer(this); - cube_r2.setRotationPoint(0.0F, -18.0F, 0.0F); - Chain.addChild(cube_r2); - setRotationAngle(cube_r2, 0.0F, 0.7854F, 0.0F); - cube_r2.cubeList.add(new ModelBox(cube_r2, 6, -1, 0.0F, 2.0F, -1.5F, 0, 5, 3, 0.0F)); - } + cube_r2 = new ModelRenderer(this); + cube_r2.setRotationPoint(0.0F, -18.0F, 0.0F); + Chain.addChild(cube_r2); + setRotationAngle(cube_r2, 0.0F, 0.7854F, 0.0F); + cube_r2.cubeList.add(new ModelBox(cube_r2, 6, -1, 0.0F, 2.0F, -1.5F, 0, 5, 3, 0.0F)); + } - @Override - public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) { - Light.render(f5); - Lantern.render(f5); - Chain.render(f5); - } + @Override + public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) { + Light.render(f5); + Lantern.render(f5); + Chain.render(f5); + } - public void setRotationAngle(ModelRenderer modelRenderer, float x, float y, float z) { - modelRenderer.rotateAngleX = x; - modelRenderer.rotateAngleY = y; - modelRenderer.rotateAngleZ = z; - } + public void setRotationAngle(ModelRenderer modelRenderer, float x, float y, float z) { + modelRenderer.rotateAngleX = x; + modelRenderer.rotateAngleY = y; + modelRenderer.rotateAngleZ = z; + } } diff --git a/src/main/java/noppes/npcs/client/model/blocks/lantern/LanternFloor.java b/src/main/java/noppes/npcs/client/model/blocks/lantern/LanternFloor.java index d0e368d62..50ccb46c6 100644 --- a/src/main/java/noppes/npcs/client/model/blocks/lantern/LanternFloor.java +++ b/src/main/java/noppes/npcs/client/model/blocks/lantern/LanternFloor.java @@ -6,37 +6,37 @@ import net.minecraft.client.model.ModelRenderer; import net.minecraft.entity.Entity; public class LanternFloor extends ModelBase { - public final ModelRenderer Light; + public final ModelRenderer Light; public final ModelRenderer Lantern; - public LanternFloor() { - textureWidth = 64; - textureHeight = 32; + public LanternFloor() { + textureWidth = 64; + textureHeight = 32; - Light = new ModelRenderer(this); - Light.setRotationPoint(0.0F, 24.0F, 0.0F); - Light.cubeList.add(new ModelBox(Light, 28, 8, -3.0F, -9.0F, -3.0F, 6, 7, 6, 0.0F)); + Light = new ModelRenderer(this); + Light.setRotationPoint(0.0F, 24.0F, 0.0F); + Light.cubeList.add(new ModelBox(Light, 28, 8, -3.0F, -9.0F, -3.0F, 6, 7, 6, 0.0F)); - Lantern = new ModelRenderer(this); - Lantern.setRotationPoint(0.0F, 24.0F, 0.0F); - Lantern.cubeList.add(new ModelBox(Lantern, 28, 0, -3.0F, -2.0F, -3.0F, 6, 2, 6, 0.0F)); - Lantern.cubeList.add(new ModelBox(Lantern, 28, 21, -2.0F, -11.0F, -2.0F, 4, 2, 4, 0.0F)); - Lantern.cubeList.add(new ModelBox(Lantern, 46, 21, -5.0F, -11.0F, 0.0F, 3, 11, 0, 0.0F)); - Lantern.mirror = true; + Lantern = new ModelRenderer(this); + Lantern.setRotationPoint(0.0F, 24.0F, 0.0F); + Lantern.cubeList.add(new ModelBox(Lantern, 28, 0, -3.0F, -2.0F, -3.0F, 6, 2, 6, 0.0F)); + Lantern.cubeList.add(new ModelBox(Lantern, 28, 21, -2.0F, -11.0F, -2.0F, 4, 2, 4, 0.0F)); + Lantern.cubeList.add(new ModelBox(Lantern, 46, 21, -5.0F, -11.0F, 0.0F, 3, 11, 0, 0.0F)); + Lantern.mirror = true; Lantern.cubeList.add(new ModelBox(Lantern, 46, 21, 2.0F, -11.0F, 0.0F, 3, 11, 0, 0.0F)); - Lantern.mirror = false; + Lantern.mirror = false; Lantern.cubeList.add(new ModelBox(Lantern, 28, 27, -3.0F, -13.0F, 0.0F, 6, 2, 0, 0.0F)); - } + } - @Override - public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) { - Light.render(f5); - Lantern.render(f5); - } + @Override + public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) { + Light.render(f5); + Lantern.render(f5); + } - public void setRotationAngle(ModelRenderer modelRenderer, float x, float y, float z) { - modelRenderer.rotateAngleX = x; - modelRenderer.rotateAngleY = y; - modelRenderer.rotateAngleZ = z; - } + public void setRotationAngle(ModelRenderer modelRenderer, float x, float y, float z) { + modelRenderer.rotateAngleX = x; + modelRenderer.rotateAngleY = y; + modelRenderer.rotateAngleZ = z; + } } diff --git a/src/main/java/noppes/npcs/client/model/blocks/lantern/LanternWall.java b/src/main/java/noppes/npcs/client/model/blocks/lantern/LanternWall.java index d330885a3..10b4d4f80 100644 --- a/src/main/java/noppes/npcs/client/model/blocks/lantern/LanternWall.java +++ b/src/main/java/noppes/npcs/client/model/blocks/lantern/LanternWall.java @@ -9,54 +9,54 @@ public class LanternWall extends ModelBase { public final ModelRenderer Light; public final ModelRenderer Lantern; public final ModelRenderer Holder; - private final ModelRenderer cube_r1; - private final ModelRenderer cube_r2; + private final ModelRenderer cube_r1; + private final ModelRenderer cube_r2; - public LanternWall() { - textureWidth = 64; - textureHeight = 32; + public LanternWall() { + textureWidth = 64; + textureHeight = 32; - Light = new ModelRenderer(this); - Light.setRotationPoint(0.0F, 24.0F, 0.0F); - Light.cubeList.add(new ModelBox(Light, 28, 8, -3.0F, -12.0F, -1.0F, 6, 7, 6, 0.0F)); + Light = new ModelRenderer(this); + Light.setRotationPoint(0.0F, 24.0F, 0.0F); + Light.cubeList.add(new ModelBox(Light, 28, 8, -3.0F, -12.0F, -1.0F, 6, 7, 6, 0.0F)); - Lantern = new ModelRenderer(this); - Lantern.setRotationPoint(0.0F, 24.0F, 0.0F); - Lantern.cubeList.add(new ModelBox(Lantern, 28, 0, -3.0F, -5.0F, -1.0F, 6, 2, 6, 0.0F)); - Lantern.cubeList.add(new ModelBox(Lantern, 28, 21, -2.0F, -14.0F, 0.0F, 4, 2, 4, 0.0F)); - Lantern.cubeList.add(new ModelBox(Lantern, 46, 21, -5.0F, -14.0F, 2.0F, 3, 11, 0, 0.0F)); - Lantern.mirror = true; + Lantern = new ModelRenderer(this); + Lantern.setRotationPoint(0.0F, 24.0F, 0.0F); + Lantern.cubeList.add(new ModelBox(Lantern, 28, 0, -3.0F, -5.0F, -1.0F, 6, 2, 6, 0.0F)); + Lantern.cubeList.add(new ModelBox(Lantern, 28, 21, -2.0F, -14.0F, 0.0F, 4, 2, 4, 0.0F)); + Lantern.cubeList.add(new ModelBox(Lantern, 46, 21, -5.0F, -14.0F, 2.0F, 3, 11, 0, 0.0F)); + Lantern.mirror = true; Lantern.cubeList.add(new ModelBox(Lantern, 46, 21, 2.0F, -14.0F, 2.0F, 3, 11, 0, 0.0F)); - Lantern.mirror = false; + Lantern.mirror = false; Lantern.cubeList.add(new ModelBox(Lantern, 28, 27, -3.0F, -16.0F, 2.0F, 6, 2, 0, 0.0F)); - Holder = new ModelRenderer(this); - Holder.setRotationPoint(0.0F, 24.0F, 0.0F); + Holder = new ModelRenderer(this); + Holder.setRotationPoint(0.0F, 24.0F, 0.0F); - cube_r1 = new ModelRenderer(this); - cube_r1.setRotationPoint(0.0F, -14.5F, 4.5F); - Holder.addChild(cube_r1); - setRotationAngle(cube_r1, 0.0F, 3.1416F, 0.0F); - cube_r1.cubeList.add(new ModelBox(cube_r1, 12, 0, 0.0F, -1.5F, -2.5F, 0, 3, 5, 0.0F)); + cube_r1 = new ModelRenderer(this); + cube_r1.setRotationPoint(0.0F, -14.5F, 4.5F); + Holder.addChild(cube_r1); + setRotationAngle(cube_r1, 0.0F, 3.1416F, 0.0F); + cube_r1.cubeList.add(new ModelBox(cube_r1, 12, 0, 0.0F, -1.5F, -2.5F, 0, 3, 5, 0.0F)); - cube_r2 = new ModelRenderer(this); - cube_r2.setRotationPoint(0.0F, -14.0F, 6.5F); - Holder.addChild(cube_r2); - setRotationAngle(cube_r2, -1.5708F, 0.0F, 0.0F); - cube_r2.cubeList.add(new ModelBox(cube_r2, 12, 0, -2.0F, -1.5F, -2.0F, 4, 1, 4, 0.0F)); - } + cube_r2 = new ModelRenderer(this); + cube_r2.setRotationPoint(0.0F, -14.0F, 6.5F); + Holder.addChild(cube_r2); + setRotationAngle(cube_r2, -1.5708F, 0.0F, 0.0F); + cube_r2.cubeList.add(new ModelBox(cube_r2, 12, 0, -2.0F, -1.5F, -2.0F, 4, 1, 4, 0.0F)); + } - @Override - public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) { - Light.render(f5); - Lantern.render(f5); - Holder.render(f5); - } + @Override + public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) { + Light.render(f5); + Lantern.render(f5); + Holder.render(f5); + } - public void setRotationAngle(ModelRenderer modelRenderer, float x, float y, float z) { - modelRenderer.rotateAngleX = x; - modelRenderer.rotateAngleY = y; - modelRenderer.rotateAngleZ = z; - } + public void setRotationAngle(ModelRenderer modelRenderer, float x, float y, float z) { + modelRenderer.rotateAngleX = x; + modelRenderer.rotateAngleY = y; + modelRenderer.rotateAngleZ = z; + } } diff --git a/src/main/java/noppes/npcs/client/model/blocks/legacy/ModelLegacyAnvil.java b/src/main/java/noppes/npcs/client/model/blocks/legacy/ModelLegacyAnvil.java index 6eb1360b7..96a18e4e1 100644 --- a/src/main/java/noppes/npcs/client/model/blocks/legacy/ModelLegacyAnvil.java +++ b/src/main/java/noppes/npcs/client/model/blocks/legacy/ModelLegacyAnvil.java @@ -11,80 +11,80 @@ import net.minecraft.client.model.ModelRenderer; import net.minecraft.entity.Entity; public class ModelLegacyAnvil extends ModelBase { - ModelRenderer Tail; - ModelRenderer Nose1; - ModelRenderer Nose2; - ModelRenderer Nose3; - ModelRenderer Nose4; - ModelRenderer Head1; - ModelRenderer Head2; - ModelRenderer Neck2; - ModelRenderer Bottom2; - ModelRenderer Bottom3; - ModelRenderer Foot4; + ModelRenderer Tail; + ModelRenderer Nose1; + ModelRenderer Nose2; + ModelRenderer Nose3; + ModelRenderer Nose4; + ModelRenderer Head1; + ModelRenderer Head2; + ModelRenderer Neck2; + ModelRenderer Bottom2; + ModelRenderer Bottom3; + ModelRenderer Foot4; - public ModelLegacyAnvil() { - textureWidth = 64; - textureHeight = 32; + public ModelLegacyAnvil() { + textureWidth = 64; + textureHeight = 32; - Tail = new ModelRenderer(this, 0, 0); - Tail.addBox(0F, 0F, 0F, 1, 2, 4); - Tail.setRotationPoint(-7F, 12F, -2F); + Tail = new ModelRenderer(this, 0, 0); + Tail.addBox(0F, 0F, 0F, 1, 2, 4); + Tail.setRotationPoint(-7F, 12F, -2F); - Nose1 = new ModelRenderer(this, 0, 0); - Nose1.addBox(0F, 0F, 0F, 1, 5, 6); - Nose1.setRotationPoint(6F, 10F, -3F); + Nose1 = new ModelRenderer(this, 0, 0); + Nose1.addBox(0F, 0F, 0F, 1, 5, 6); + Nose1.setRotationPoint(6F, 10F, -3F); - Nose2 = new ModelRenderer(this, 0, 0); - Nose2.addBox(0F, 0F, 0F, 1, 4, 5); - Nose2.setRotationPoint(7F, 10F, -2.5F); + Nose2 = new ModelRenderer(this, 0, 0); + Nose2.addBox(0F, 0F, 0F, 1, 4, 5); + Nose2.setRotationPoint(7F, 10F, -2.5F); - Nose3 = new ModelRenderer(this, 0, 0); - Nose3.addBox(0F, 0F, 0F, 1, 3, 4); - Nose3.setRotationPoint(8F, 10F, -2F); + Nose3 = new ModelRenderer(this, 0, 0); + Nose3.addBox(0F, 0F, 0F, 1, 3, 4); + Nose3.setRotationPoint(8F, 10F, -2F); - Nose4 = new ModelRenderer(this, 0, 0); - Nose4.addBox(0F, 0F, 0F, 1, 2, 2); - Nose4.setRotationPoint(9F, 10F, -1F); + Nose4 = new ModelRenderer(this, 0, 0); + Nose4.addBox(0F, 0F, 0F, 1, 2, 2); + Nose4.setRotationPoint(9F, 10F, -1F); - Head1 = new ModelRenderer(this, 0, 0); - Head1.addBox(0F, 0F, 0F, 12, 4, 7); - Head1.setRotationPoint(-6F, 12F, -3.5F); + Head1 = new ModelRenderer(this, 0, 0); + Head1.addBox(0F, 0F, 0F, 12, 4, 7); + Head1.setRotationPoint(-6F, 12F, -3.5F); - Head2 = new ModelRenderer(this, 0, 0); - Head2.addBox(0F, 0F, 0F, 14, 2, 9); - Head2.setRotationPoint(-8F, 10F, -4.5F); + Head2 = new ModelRenderer(this, 0, 0); + Head2.addBox(0F, 0F, 0F, 14, 2, 9); + Head2.setRotationPoint(-8F, 10F, -4.5F); - Neck2 = new ModelRenderer(this, 0, 0); - Neck2.addBox(0F, 0F, 0F, 10, 1, 6); - Neck2.setRotationPoint(-5F, 16F, -3F); + Neck2 = new ModelRenderer(this, 0, 0); + Neck2.addBox(0F, 0F, 0F, 10, 1, 6); + Neck2.setRotationPoint(-5F, 16F, -3F); - Bottom2 = new ModelRenderer(this, 0, 0); - Bottom2.addBox(0F, 0F, 0F, 10, 2, 7); - Bottom2.setRotationPoint(-5F, 20F, -3.5F); + Bottom2 = new ModelRenderer(this, 0, 0); + Bottom2.addBox(0F, 0F, 0F, 10, 2, 7); + Bottom2.setRotationPoint(-5F, 20F, -3.5F); - Bottom3 = new ModelRenderer(this, 0, 0); - Bottom3.addBox(0F, 0F, 0F, 8, 3, 4); - Bottom3.setRotationPoint(-4F, 17F, -2F); + Bottom3 = new ModelRenderer(this, 0, 0); + Bottom3.addBox(0F, 0F, 0F, 8, 3, 4); + Bottom3.setRotationPoint(-4F, 17F, -2F); - Foot4 = new ModelRenderer(this, 0, 0); - Foot4.addBox(0F, 0F, 0F, 14, 2, 10); - Foot4.setRotationPoint(-7F, 22F, -5F); - } + Foot4 = new ModelRenderer(this, 0, 0); + Foot4.addBox(0F, 0F, 0F, 14, 2, 10); + Foot4.setRotationPoint(-7F, 22F, -5F); + } - public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) { - super.render(entity, f, f1, f2, f3, f4, f5); - setRotationAngles(f, f1, f2, f3, f4, f5,entity); - Tail.render(f5); - Nose1.render(f5); - Nose2.render(f5); - Nose3.render(f5); - Nose4.render(f5); - Head1.render(f5); - Head2.render(f5); - Neck2.render(f5); - Bottom2.render(f5); - Bottom3.render(f5); - Foot4.render(f5); - } + public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) { + super.render(entity, f, f1, f2, f3, f4, f5); + setRotationAngles(f, f1, f2, f3, f4, f5, entity); + Tail.render(f5); + Nose1.render(f5); + Nose2.render(f5); + Nose3.render(f5); + Nose4.render(f5); + Head1.render(f5); + Head2.render(f5); + Neck2.render(f5); + Bottom2.render(f5); + Bottom3.render(f5); + Foot4.render(f5); + } } diff --git a/src/main/java/noppes/npcs/client/model/blocks/legacy/ModelLegacyBanner.java b/src/main/java/noppes/npcs/client/model/blocks/legacy/ModelLegacyBanner.java index 086e27b65..467668898 100644 --- a/src/main/java/noppes/npcs/client/model/blocks/legacy/ModelLegacyBanner.java +++ b/src/main/java/noppes/npcs/client/model/blocks/legacy/ModelLegacyBanner.java @@ -1,13 +1,11 @@ - package noppes.npcs.client.model.blocks.legacy; import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelRenderer; import net.minecraft.entity.Entity; -public class ModelLegacyBanner extends ModelBase -{ - //fields +public class ModelLegacyBanner extends ModelBase { + //fields ModelRenderer Base; ModelRenderer MiddleStick; ModelRenderer StickDecoration; @@ -19,69 +17,66 @@ public class ModelLegacyBanner extends ModelBase ModelRenderer BaseDeco3; ModelRenderer BaseDeco4; - public ModelLegacyBanner() - { - Base = new ModelRenderer(this, 3, 1); - Base.addBox(-7F, 0F, -7F, 14, 1, 14); - Base.setRotationPoint(0F, 23F, 0F); + public ModelLegacyBanner() { + Base = new ModelRenderer(this, 3, 1); + Base.addBox(-7F, 0F, -7F, 14, 1, 14); + Base.setRotationPoint(0F, 23F, 0F); - MiddleStick = new ModelRenderer(this, 12, 2); - MiddleStick.addBox(-1F, 0F, -1F, 2, 32, 2); - MiddleStick.setRotationPoint(0F, -9F, 0F); + MiddleStick = new ModelRenderer(this, 12, 2); + MiddleStick.addBox(-1F, 0F, -1F, 2, 32, 2); + MiddleStick.setRotationPoint(0F, -9F, 0F); - StickDecoration = new ModelRenderer(this, 11, 12); - StickDecoration.addBox(0F, 0F, 0F, 16, 3, 3); - StickDecoration.setRotationPoint(-8F, -7.5F, -1.5F); + StickDecoration = new ModelRenderer(this, 11, 12); + StickDecoration.addBox(0F, 0F, 0F, 16, 3, 3); + StickDecoration.setRotationPoint(-8F, -7.5F, -1.5F); - TopDecoration = new ModelRenderer(this, 45, 19); - TopDecoration.addBox(0F, 0F, 0F, 1, 1, 1); - TopDecoration.setRotationPoint(-0.5F, -10F, -0.5F); + TopDecoration = new ModelRenderer(this, 45, 19); + TopDecoration.addBox(0F, 0F, 0F, 1, 1, 1); + TopDecoration.setRotationPoint(-0.5F, -10F, -0.5F); - FlagPole1 = new ModelRenderer(this, 45, 19); - FlagPole1.addBox(0F, 0F, 0F, 1, 1, 1); - FlagPole1.setRotationPoint(-7F, -6.5F, -2.5F); + FlagPole1 = new ModelRenderer(this, 45, 19); + FlagPole1.addBox(0F, 0F, 0F, 1, 1, 1); + FlagPole1.setRotationPoint(-7F, -6.5F, -2.5F); - FlagPole2 = new ModelRenderer(this, 45, 19); - FlagPole2.addBox(0F, 0F, 0F, 1, 1, 1); - FlagPole2.setRotationPoint(6F, -6.5F, -2.5F); + FlagPole2 = new ModelRenderer(this, 45, 19); + FlagPole2.addBox(0F, 0F, 0F, 1, 1, 1); + FlagPole2.setRotationPoint(6F, -6.5F, -2.5F); - BaseDeco1 = new ModelRenderer(this, 1, 14); - BaseDeco1.addBox(0F, 0F, 0F, 12, 1, 1); - BaseDeco1.setRotationPoint(-6F, 23F, -8F); + BaseDeco1 = new ModelRenderer(this, 1, 14); + BaseDeco1.addBox(0F, 0F, 0F, 12, 1, 1); + BaseDeco1.setRotationPoint(-6F, 23F, -8F); - BaseDeco2 = new ModelRenderer(this, 1, 14); - BaseDeco2.addBox(0F, 0F, 0F, 12, 1, 1); - BaseDeco2.setRotationPoint(-6F, 23F, 7F); + BaseDeco2 = new ModelRenderer(this, 1, 14); + BaseDeco2.addBox(0F, 0F, 0F, 12, 1, 1); + BaseDeco2.setRotationPoint(-6F, 23F, 7F); - BaseDeco3 = new ModelRenderer(this, 2, 2); - BaseDeco3.addBox(0F, 0F, 0F, 1, 1, 12); - BaseDeco3.setRotationPoint(-8F, 23F, -6F); + BaseDeco3 = new ModelRenderer(this, 2, 2); + BaseDeco3.addBox(0F, 0F, 0F, 1, 1, 12); + BaseDeco3.setRotationPoint(-8F, 23F, -6F); - BaseDeco4 = new ModelRenderer(this, 2, 2); - BaseDeco4.addBox(0F, 0F, 0F, 1, 1, 12); - BaseDeco4.setRotationPoint(7F, 23F, -6F); - } + BaseDeco4 = new ModelRenderer(this, 2, 2); + BaseDeco4.addBox(0F, 0F, 0F, 1, 1, 12); + BaseDeco4.setRotationPoint(7F, 23F, -6F); + } - public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) - { - super.render(entity, f, f1, f2, f3, f4, f5); - Base.render(f5); - MiddleStick.render(f5); - StickDecoration.render(f5); - TopDecoration.render(f5); - FlagPole1.render(f5); - FlagPole2.render(f5); - BaseDeco1.render(f5); - BaseDeco2.render(f5); - BaseDeco3.render(f5); - BaseDeco4.render(f5); - } + public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) { + super.render(entity, f, f1, f2, f3, f4, f5); + Base.render(f5); + MiddleStick.render(f5); + StickDecoration.render(f5); + TopDecoration.render(f5); + FlagPole1.render(f5); + FlagPole2.render(f5); + BaseDeco1.render(f5); + BaseDeco2.render(f5); + BaseDeco3.render(f5); + BaseDeco4.render(f5); + } - private void setRotation(ModelRenderer model, float x, float y, float z) - { - model.rotateAngleX = x; - model.rotateAngleY = y; - model.rotateAngleZ = z; - } + private void setRotation(ModelRenderer model, float x, float y, float z) { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } } diff --git a/src/main/java/noppes/npcs/client/model/blocks/legacy/ModelLegacyBannerFlag.java b/src/main/java/noppes/npcs/client/model/blocks/legacy/ModelLegacyBannerFlag.java index b6830ad7a..3e1379f0b 100644 --- a/src/main/java/noppes/npcs/client/model/blocks/legacy/ModelLegacyBannerFlag.java +++ b/src/main/java/noppes/npcs/client/model/blocks/legacy/ModelLegacyBannerFlag.java @@ -1,36 +1,31 @@ - package noppes.npcs.client.model.blocks.legacy; import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelRenderer; import net.minecraft.entity.Entity; -public class ModelLegacyBannerFlag extends ModelBase -{ +public class ModelLegacyBannerFlag extends ModelBase { ModelRenderer Flag; - public ModelLegacyBannerFlag() - { - textureWidth = 32; - textureHeight = 32; + public ModelLegacyBannerFlag() { + textureWidth = 32; + textureHeight = 32; - Flag = new ModelRenderer(this, 0, 0); - Flag.addBox(0F, 0F, 0F, 15, 27, 0); - Flag.setRotationPoint(-7.5F, -7F, -2F); - Flag.setTextureSize(32, 32); - } + Flag = new ModelRenderer(this, 0, 0); + Flag.addBox(0F, 0F, 0F, 15, 27, 0); + Flag.setRotationPoint(-7.5F, -7F, -2F); + Flag.setTextureSize(32, 32); + } - public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) - { - super.render(entity, f, f1, f2, f3, f4, f5); - Flag.render(f5); - } + public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) { + super.render(entity, f, f1, f2, f3, f4, f5); + Flag.render(f5); + } - private void setRotation(ModelRenderer model, float x, float y, float z) - { - model.rotateAngleX = x; - model.rotateAngleY = y; - model.rotateAngleZ = z; - } + private void setRotation(ModelRenderer model, float x, float y, float z) { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } } diff --git a/src/main/java/noppes/npcs/client/model/blocks/legacy/ModelLegacyBarrel.java b/src/main/java/noppes/npcs/client/model/blocks/legacy/ModelLegacyBarrel.java index 19ca1d92c..0951ca32b 100644 --- a/src/main/java/noppes/npcs/client/model/blocks/legacy/ModelLegacyBarrel.java +++ b/src/main/java/noppes/npcs/client/model/blocks/legacy/ModelLegacyBarrel.java @@ -4,8 +4,7 @@ import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelRenderer; import net.minecraft.entity.Entity; -public class ModelLegacyBarrel extends ModelBase -{ +public class ModelLegacyBarrel extends ModelBase { ModelRenderer Plank1; ModelRenderer Plank2; ModelRenderer Plank3; @@ -19,92 +18,89 @@ public class ModelLegacyBarrel extends ModelBase ModelRenderer Plank11; ModelRenderer Plank12; - public ModelLegacyBarrel() - { - Plank1 = new ModelRenderer(this, 10, 0); - Plank1.addBox(0F, 6.5F, -2F, 17, 1, 4); - Plank1.setRotationPoint(0F, 7.01F, 0F); - setRotation(Plank1, 0F, 0F, 1.570796F); + public ModelLegacyBarrel() { + Plank1 = new ModelRenderer(this, 10, 0); + Plank1.addBox(0F, 6.5F, -2F, 17, 1, 4); + Plank1.setRotationPoint(0F, 7.01F, 0F); + setRotation(Plank1, 0F, 0F, 1.570796F); - Plank2 = new ModelRenderer(this, 10, 8); - Plank2.addBox(0F, 6.5F, -2F, 17, 1, 4); - Plank2.setRotationPoint(0F, 7F, 0F); - setRotation(Plank2, 0F, 0.5235988F, 1.570796F); + Plank2 = new ModelRenderer(this, 10, 8); + Plank2.addBox(0F, 6.5F, -2F, 17, 1, 4); + Plank2.setRotationPoint(0F, 7F, 0F); + setRotation(Plank2, 0F, 0.5235988F, 1.570796F); - Plank3 = new ModelRenderer(this, 10, 0); - Plank3.addBox(0F, 6.5F, -2F, 17, 1, 4); - Plank3.setRotationPoint(0F, 7.01F, 0F); - setRotation(Plank3, 0F, 1.047198F, 1.570796F); + Plank3 = new ModelRenderer(this, 10, 0); + Plank3.addBox(0F, 6.5F, -2F, 17, 1, 4); + Plank3.setRotationPoint(0F, 7.01F, 0F); + setRotation(Plank3, 0F, 1.047198F, 1.570796F); - Plank4 = new ModelRenderer(this, 10, 8); - Plank4.addBox(0F, 6.5F, -2F, 17, 1, 4); - Plank4.setRotationPoint(0F, 7F, 0F); - setRotation(Plank4, 0F, 1.570796F, 1.570796F); + Plank4 = new ModelRenderer(this, 10, 8); + Plank4.addBox(0F, 6.5F, -2F, 17, 1, 4); + Plank4.setRotationPoint(0F, 7F, 0F); + setRotation(Plank4, 0F, 1.570796F, 1.570796F); - Plank5 = new ModelRenderer(this, 10, 0); - Plank5.addBox(0F, 6.5F, -2F, 17, 1, 4); - Plank5.setRotationPoint(0F, 7.01F, 0F); - setRotation(Plank5, 0F, 2.094395F, 1.570796F); + Plank5 = new ModelRenderer(this, 10, 0); + Plank5.addBox(0F, 6.5F, -2F, 17, 1, 4); + Plank5.setRotationPoint(0F, 7.01F, 0F); + setRotation(Plank5, 0F, 2.094395F, 1.570796F); - Plank6 = new ModelRenderer(this, 10, 8); - Plank6.addBox(0F, 6.5F, -2F, 17, 1, 4); - Plank6.setRotationPoint(0F, 7F, 0F); - setRotation(Plank6, 0F, 2.617994F, 1.570796F); + Plank6 = new ModelRenderer(this, 10, 8); + Plank6.addBox(0F, 6.5F, -2F, 17, 1, 4); + Plank6.setRotationPoint(0F, 7F, 0F); + setRotation(Plank6, 0F, 2.617994F, 1.570796F); - Plank7 = new ModelRenderer(this, 10, 0); - Plank7.addBox(0F, 6.5F, -2F, 17, 1, 4); - Plank7.setRotationPoint(0F, 7.01F, 0F); - setRotation(Plank7, 0F, 3.150901F, 1.570796F); + Plank7 = new ModelRenderer(this, 10, 0); + Plank7.addBox(0F, 6.5F, -2F, 17, 1, 4); + Plank7.setRotationPoint(0F, 7.01F, 0F); + setRotation(Plank7, 0F, 3.150901F, 1.570796F); - Plank8 = new ModelRenderer(this, 10, 8); - Plank8.addBox(0F, 6.5F, -2F, 17, 1, 4); - Plank8.setRotationPoint(0F, 7F, 0F); - setRotation(Plank8, 0F, -2.617994F, 1.570796F); + Plank8 = new ModelRenderer(this, 10, 8); + Plank8.addBox(0F, 6.5F, -2F, 17, 1, 4); + Plank8.setRotationPoint(0F, 7F, 0F); + setRotation(Plank8, 0F, -2.617994F, 1.570796F); - Plank9 = new ModelRenderer(this, 10, 0); - Plank9.addBox(0F, 6.5F, -2F, 17, 1, 4); - Plank9.setRotationPoint(0F, 7.01F, 0F); - setRotation(Plank9, 0F, -2.094395F, 1.570796F); + Plank9 = new ModelRenderer(this, 10, 0); + Plank9.addBox(0F, 6.5F, -2F, 17, 1, 4); + Plank9.setRotationPoint(0F, 7.01F, 0F); + setRotation(Plank9, 0F, -2.094395F, 1.570796F); - Plank10 = new ModelRenderer(this, 10, 8); - Plank10.addBox(0F, 6.5F, -2F, 17, 1, 4); - Plank10.setRotationPoint(0F, 7F, 0F); - setRotation(Plank10, 0F, -1.570796F, 1.570796F); + Plank10 = new ModelRenderer(this, 10, 8); + Plank10.addBox(0F, 6.5F, -2F, 17, 1, 4); + Plank10.setRotationPoint(0F, 7F, 0F); + setRotation(Plank10, 0F, -1.570796F, 1.570796F); - Plank11 = new ModelRenderer(this, 10, 0); - Plank11.addBox(0F, 6.5F, -2F, 17, 1, 4); - Plank11.setRotationPoint(0F, 7.01F, 0F); - setRotation(Plank11, 0F, -1.047198F, 1.570796F); + Plank11 = new ModelRenderer(this, 10, 0); + Plank11.addBox(0F, 6.5F, -2F, 17, 1, 4); + Plank11.setRotationPoint(0F, 7.01F, 0F); + setRotation(Plank11, 0F, -1.047198F, 1.570796F); - Plank12 = new ModelRenderer(this, 10, 0); - Plank12.addBox(0F, 6.5F, -2F, 17, 1, 4); - Plank12.setRotationPoint(0F, 7F, 0F); - setRotation(Plank12, 0F, -0.5235988F, 1.570796F); - } + Plank12 = new ModelRenderer(this, 10, 0); + Plank12.addBox(0F, 6.5F, -2F, 17, 1, 4); + Plank12.setRotationPoint(0F, 7F, 0F); + setRotation(Plank12, 0F, -0.5235988F, 1.570796F); + } - public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) - { - super.render(entity, f, f1, f2, f3, f4, f5); - Plank1.render(f5); - Plank2.render(f5); - Plank3.render(f5); - Plank4.render(f5); - Plank5.render(f5); - Plank6.render(f5); - Plank7.render(f5); - Plank8.render(f5); - Plank9.render(f5); - Plank10.render(f5); - Plank11.render(f5); - Plank12.render(f5); - } + public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) { + super.render(entity, f, f1, f2, f3, f4, f5); + Plank1.render(f5); + Plank2.render(f5); + Plank3.render(f5); + Plank4.render(f5); + Plank5.render(f5); + Plank6.render(f5); + Plank7.render(f5); + Plank8.render(f5); + Plank9.render(f5); + Plank10.render(f5); + Plank11.render(f5); + Plank12.render(f5); + } - private void setRotation(ModelRenderer model, float x, float y, float z) - { - model.rotateAngleX = y; - model.rotateAngleY = x; - model.rotateAngleZ = z; - } + private void setRotation(ModelRenderer model, float x, float y, float z) { + model.rotateAngleX = y; + model.rotateAngleY = x; + model.rotateAngleZ = z; + } } diff --git a/src/main/java/noppes/npcs/client/model/blocks/legacy/ModelLegacyBarrelLid.java b/src/main/java/noppes/npcs/client/model/blocks/legacy/ModelLegacyBarrelLid.java index b8efe0a8f..9735bee3f 100644 --- a/src/main/java/noppes/npcs/client/model/blocks/legacy/ModelLegacyBarrelLid.java +++ b/src/main/java/noppes/npcs/client/model/blocks/legacy/ModelLegacyBarrelLid.java @@ -4,35 +4,31 @@ import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelRenderer; import net.minecraft.entity.Entity; -public class ModelLegacyBarrelLid extends ModelBase -{ - ModelRenderer Top; +public class ModelLegacyBarrelLid extends ModelBase { + ModelRenderer Top; ModelRenderer Bottom; - public ModelLegacyBarrelLid() - { - Top = new ModelRenderer(this, 0, 0); - Top.addBox(0F, 0F, 0F, 16, 0, 16); - Top.setRotationPoint(-8F, 9F, -8F); + public ModelLegacyBarrelLid() { + Top = new ModelRenderer(this, 0, 0); + Top.addBox(0F, 0F, 0F, 16, 0, 16); + Top.setRotationPoint(-8F, 9F, -8F); - Bottom = new ModelRenderer(this, 0, 0); - Bottom.addBox(0F, 0F, 0F, 16, 0, 16); - Bottom.setRotationPoint(-8F, 23F, -8F); - } + Bottom = new ModelRenderer(this, 0, 0); + Bottom.addBox(0F, 0F, 0F, 16, 0, 16); + Bottom.setRotationPoint(-8F, 23F, -8F); + } - public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) - { - super.render(entity, f, f1, f2, f3, f4, f5); - Bottom.render(f5); - Top.render(f5); - } + public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) { + super.render(entity, f, f1, f2, f3, f4, f5); + Bottom.render(f5); + Top.render(f5); + } - private void setRotation(ModelRenderer model, float x, float y, float z) - { - model.rotateAngleX = y; - model.rotateAngleY = x; - model.rotateAngleZ = z; - } + private void setRotation(ModelRenderer model, float x, float y, float z) { + model.rotateAngleX = y; + model.rotateAngleY = x; + model.rotateAngleZ = z; + } } diff --git a/src/main/java/noppes/npcs/client/model/blocks/legacy/ModelLegacyCandle.java b/src/main/java/noppes/npcs/client/model/blocks/legacy/ModelLegacyCandle.java index a92f5db62..81fcafd75 100644 --- a/src/main/java/noppes/npcs/client/model/blocks/legacy/ModelLegacyCandle.java +++ b/src/main/java/noppes/npcs/client/model/blocks/legacy/ModelLegacyCandle.java @@ -5,55 +5,55 @@ import net.minecraft.client.model.ModelRenderer; import net.minecraft.entity.Entity; public class ModelLegacyCandle extends ModelBase { - // fields - ModelRenderer Base; - ModelRenderer Bar1; - ModelRenderer Bar2; - ModelRenderer Bar3; - ModelRenderer Bar4; - ModelRenderer Wax; + // fields + ModelRenderer Base; + ModelRenderer Bar1; + ModelRenderer Bar2; + ModelRenderer Bar3; + ModelRenderer Bar4; + ModelRenderer Wax; - public ModelLegacyCandle() { - Base = new ModelRenderer(this, 0, 0); - Base.addBox(0F, 0F, 0F, 4, 1, 4); - Base.setRotationPoint(-2F, 23F, -2F); + public ModelLegacyCandle() { + Base = new ModelRenderer(this, 0, 0); + Base.addBox(0F, 0F, 0F, 4, 1, 4); + Base.setRotationPoint(-2F, 23F, -2F); - Bar1 = new ModelRenderer(this, 0, 0); - Bar1.addBox(0F, 0F, 0F, 1, 1, 6); - Bar1.setRotationPoint(-3F, 22F, -3F); + Bar1 = new ModelRenderer(this, 0, 0); + Bar1.addBox(0F, 0F, 0F, 1, 1, 6); + Bar1.setRotationPoint(-3F, 22F, -3F); - Bar2 = new ModelRenderer(this, 0, 0); - Bar2.addBox(0F, 0F, 0F, 1, 1, 6); - Bar2.setRotationPoint(2F, 22F, -3F); + Bar2 = new ModelRenderer(this, 0, 0); + Bar2.addBox(0F, 0F, 0F, 1, 1, 6); + Bar2.setRotationPoint(2F, 22F, -3F); - Bar3 = new ModelRenderer(this, 0, 0); - Bar3.addBox(0F, 0F, 0F, 4, 1, 1); - Bar3.setRotationPoint(-2F, 22F, -3F); + Bar3 = new ModelRenderer(this, 0, 0); + Bar3.addBox(0F, 0F, 0F, 4, 1, 1); + Bar3.setRotationPoint(-2F, 22F, -3F); - Bar4 = new ModelRenderer(this, 0, 0); - Bar4.addBox(0F, 0F, 0F, 4, 1, 1); - Bar4.setRotationPoint(-2F, 22F, 2F); + Bar4 = new ModelRenderer(this, 0, 0); + Bar4.addBox(0F, 0F, 0F, 4, 1, 1); + Bar4.setRotationPoint(-2F, 22F, 2F); - Wax = new ModelRenderer(this, 16, 0); - Wax.addBox(0F, 0F, 0F, 2, 4, 2); - Wax.setRotationPoint(-1F, 19F, -1F); - } + Wax = new ModelRenderer(this, 16, 0); + Wax.addBox(0F, 0F, 0F, 2, 4, 2); + Wax.setRotationPoint(-1F, 19F, -1F); + } - public void render(Entity entity, float f, float f1, float f2, float f3, - float f4, float f5) { - super.render(entity, f, f1, f2, f3, f4, f5); - Base.render(f5); - Bar1.render(f5); - Bar2.render(f5); - Bar3.render(f5); - Bar4.render(f5); - Wax.render(f5); - } + public void render(Entity entity, float f, float f1, float f2, float f3, + float f4, float f5) { + super.render(entity, f, f1, f2, f3, f4, f5); + Base.render(f5); + Bar1.render(f5); + Bar2.render(f5); + Bar3.render(f5); + Bar4.render(f5); + Wax.render(f5); + } - private void setRotation(ModelRenderer model, float x, float y, float z) { - model.rotateAngleX = x; - model.rotateAngleY = y; - model.rotateAngleZ = z; - } + private void setRotation(ModelRenderer model, float x, float y, float z) { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } } diff --git a/src/main/java/noppes/npcs/client/model/blocks/legacy/ModelLegacyCandleCeiling.java b/src/main/java/noppes/npcs/client/model/blocks/legacy/ModelLegacyCandleCeiling.java index 2dff35173..56ba05b71 100644 --- a/src/main/java/noppes/npcs/client/model/blocks/legacy/ModelLegacyCandleCeiling.java +++ b/src/main/java/noppes/npcs/client/model/blocks/legacy/ModelLegacyCandleCeiling.java @@ -5,139 +5,139 @@ import net.minecraft.client.model.ModelRenderer; import net.minecraft.entity.Entity; public class ModelLegacyCandleCeiling extends ModelBase { - ModelRenderer Wax1; - ModelRenderer Wax2; - ModelRenderer Wax3; - ModelRenderer Wax4; - ModelRenderer TippyTop1; - ModelRenderer TippyTop2; - ModelRenderer Middle; - ModelRenderer BottomBar1; - ModelRenderer Rod1; - ModelRenderer Rod2; - ModelRenderer Rod3; - ModelRenderer Rod4; - ModelRenderer Base1; - ModelRenderer Base2; - ModelRenderer Base3; - ModelRenderer Base4; - ModelRenderer BottomBar3; - ModelRenderer BottomBar2; - ModelRenderer BottomBar4; + ModelRenderer Wax1; + ModelRenderer Wax2; + ModelRenderer Wax3; + ModelRenderer Wax4; + ModelRenderer TippyTop1; + ModelRenderer TippyTop2; + ModelRenderer Middle; + ModelRenderer BottomBar1; + ModelRenderer Rod1; + ModelRenderer Rod2; + ModelRenderer Rod3; + ModelRenderer Rod4; + ModelRenderer Base1; + ModelRenderer Base2; + ModelRenderer Base3; + ModelRenderer Base4; + ModelRenderer BottomBar3; + ModelRenderer BottomBar2; + ModelRenderer BottomBar4; - public ModelLegacyCandleCeiling() { - Wax1 = new ModelRenderer(this, 16, 0); - Wax1.addBox(0F, 0F, 0F, 2, 4, 2); - Wax1.setRotationPoint(-1F, 15.5F, 5F); + public ModelLegacyCandleCeiling() { + Wax1 = new ModelRenderer(this, 16, 0); + Wax1.addBox(0F, 0F, 0F, 2, 4, 2); + Wax1.setRotationPoint(-1F, 15.5F, 5F); - Wax2 = new ModelRenderer(this, 16, 0); - Wax2.addBox(0F, 0F, 0F, 2, 4, 2); - Wax2.setRotationPoint(7F, 15.5F, 1F); - setRotation(Wax2, 0F, 3.141593F, 0F); + Wax2 = new ModelRenderer(this, 16, 0); + Wax2.addBox(0F, 0F, 0F, 2, 4, 2); + Wax2.setRotationPoint(7F, 15.5F, 1F); + setRotation(Wax2, 0F, 3.141593F, 0F); - Wax3 = new ModelRenderer(this, 16, 0); - Wax3.addBox(0F, 0F, 0F, 2, 4, 2); - Wax3.setRotationPoint(-7F, 15.5F, -1F); + Wax3 = new ModelRenderer(this, 16, 0); + Wax3.addBox(0F, 0F, 0F, 2, 4, 2); + Wax3.setRotationPoint(-7F, 15.5F, -1F); - Wax4 = new ModelRenderer(this, 16, 0); - Wax4.addBox(0F, 0F, 0F, 2, 4, 2); - Wax4.setRotationPoint(1F, 15.5F, -5F); - setRotation(Wax4, 0F, 3.141593F, 0F); + Wax4 = new ModelRenderer(this, 16, 0); + Wax4.addBox(0F, 0F, 0F, 2, 4, 2); + Wax4.setRotationPoint(1F, 15.5F, -5F); + setRotation(Wax4, 0F, 3.141593F, 0F); - TippyTop1 = new ModelRenderer(this, 0, 0); - TippyTop1.addBox(0F, 0F, 0F, 4, 1, 4); - TippyTop1.setRotationPoint(-2.8F, 7.5F, 0F); - setRotation(TippyTop1, 0F, 0.7853982F, 0F); + TippyTop1 = new ModelRenderer(this, 0, 0); + TippyTop1.addBox(0F, 0F, 0F, 4, 1, 4); + TippyTop1.setRotationPoint(-2.8F, 7.5F, 0F); + setRotation(TippyTop1, 0F, 0.7853982F, 0F); - TippyTop2 = new ModelRenderer(this, 0, 0); - TippyTop2.addBox(0F, 0F, 0F, 3, 1, 3); - TippyTop2.setRotationPoint(-2.1F, 8F, 0F); - setRotation(TippyTop2, 0F, 0.7853982F, 0F); + TippyTop2 = new ModelRenderer(this, 0, 0); + TippyTop2.addBox(0F, 0F, 0F, 3, 1, 3); + TippyTop2.setRotationPoint(-2.1F, 8F, 0F); + setRotation(TippyTop2, 0F, 0.7853982F, 0F); - Middle = new ModelRenderer(this, 0, 0); - Middle.addBox(0F, 0F, 0F, 1, 13, 1); - Middle.setRotationPoint(-0.5F, 9F, -0.5F); + Middle = new ModelRenderer(this, 0, 0); + Middle.addBox(0F, 0F, 0F, 1, 13, 1); + Middle.setRotationPoint(-0.5F, 9F, -0.5F); - BottomBar1 = new ModelRenderer(this, 0, 4); - BottomBar1.addBox(0F, 0F, 0F, 1, 1, 5); - BottomBar1.setRotationPoint(-0.5F, 21F, 0.5F); + BottomBar1 = new ModelRenderer(this, 0, 4); + BottomBar1.addBox(0F, 0F, 0F, 1, 1, 5); + BottomBar1.setRotationPoint(-0.5F, 21F, 0.5F); - Rod1 = new ModelRenderer(this, 0, 0); - Rod1.addBox(0F, 0F, 0F, 1, 2, 1); - Rod1.setRotationPoint(-0.5F, 20F, 5.5F); + Rod1 = new ModelRenderer(this, 0, 0); + Rod1.addBox(0F, 0F, 0F, 1, 2, 1); + Rod1.setRotationPoint(-0.5F, 20F, 5.5F); - Rod2 = new ModelRenderer(this, 0, 0); - Rod2.addBox(0F, 0F, 0F, 1, 2, 1); - Rod2.setRotationPoint(5.5F, 20F, -0.5F); + Rod2 = new ModelRenderer(this, 0, 0); + Rod2.addBox(0F, 0F, 0F, 1, 2, 1); + Rod2.setRotationPoint(5.5F, 20F, -0.5F); - Rod3 = new ModelRenderer(this, 0, 0); - Rod3.addBox(0F, 0F, 0F, 1, 2, 1); - Rod3.setRotationPoint(-6.5F, 20F, -0.5F); + Rod3 = new ModelRenderer(this, 0, 0); + Rod3.addBox(0F, 0F, 0F, 1, 2, 1); + Rod3.setRotationPoint(-6.5F, 20F, -0.5F); - Rod4 = new ModelRenderer(this, 0, 0); - Rod4.addBox(0F, 0F, 0F, 1, 2, 1); - Rod4.setRotationPoint(-0.5F, 20F, -6.5F); + Rod4 = new ModelRenderer(this, 0, 0); + Rod4.addBox(0F, 0F, 0F, 1, 2, 1); + Rod4.setRotationPoint(-0.5F, 20F, -6.5F); - Base1 = new ModelRenderer(this, 0, 0); - Base1.addBox(0F, 0F, 0F, 4, 1, 4); - Base1.setRotationPoint(-2F, 19F, 4F); + Base1 = new ModelRenderer(this, 0, 0); + Base1.addBox(0F, 0F, 0F, 4, 1, 4); + Base1.setRotationPoint(-2F, 19F, 4F); - Base2 = new ModelRenderer(this, 0, 0); - Base2.addBox(0F, 0F, 0F, 4, 1, 4); - Base2.setRotationPoint(4F, 19F, -2F); + Base2 = new ModelRenderer(this, 0, 0); + Base2.addBox(0F, 0F, 0F, 4, 1, 4); + Base2.setRotationPoint(4F, 19F, -2F); - Base3 = new ModelRenderer(this, 0, 0); - Base3.addBox(0F, 0F, 0F, 4, 1, 4); - Base3.setRotationPoint(-8F, 19F, -2F); + Base3 = new ModelRenderer(this, 0, 0); + Base3.addBox(0F, 0F, 0F, 4, 1, 4); + Base3.setRotationPoint(-8F, 19F, -2F); - Base4 = new ModelRenderer(this, 0, 0); - Base4.addBox(0F, 0F, 0F, 4, 1, 4); - Base4.setRotationPoint(-2F, 19F, -8F); + Base4 = new ModelRenderer(this, 0, 0); + Base4.addBox(0F, 0F, 0F, 4, 1, 4); + Base4.setRotationPoint(-2F, 19F, -8F); - BottomBar3 = new ModelRenderer(this, 0, 4); - BottomBar3.addBox(0F, 0F, 0F, 1, 1, 5); - BottomBar3.setRotationPoint(-0.5F, 21F, -0.5F); - setRotation(BottomBar3, 0F, -1.570796F, 0F); + BottomBar3 = new ModelRenderer(this, 0, 4); + BottomBar3.addBox(0F, 0F, 0F, 1, 1, 5); + BottomBar3.setRotationPoint(-0.5F, 21F, -0.5F); + setRotation(BottomBar3, 0F, -1.570796F, 0F); - BottomBar2 = new ModelRenderer(this, 0, 4); - BottomBar2.addBox(0F, 0F, 0F, 1, 1, 5); - BottomBar2.setRotationPoint(0.5F, 21F, 0.5F); - setRotation(BottomBar2, 0F, 1.570796F, 0F); + BottomBar2 = new ModelRenderer(this, 0, 4); + BottomBar2.addBox(0F, 0F, 0F, 1, 1, 5); + BottomBar2.setRotationPoint(0.5F, 21F, 0.5F); + setRotation(BottomBar2, 0F, 1.570796F, 0F); - BottomBar4 = new ModelRenderer(this, 0, 4); - BottomBar4.addBox(0F, 0F, 0F, 1, 1, 5); - BottomBar4.setRotationPoint(0.4F, 21F, -0.5F); - setRotation(BottomBar4, 0F, 3.141593F, 0F); - } + BottomBar4 = new ModelRenderer(this, 0, 4); + BottomBar4.addBox(0F, 0F, 0F, 1, 1, 5); + BottomBar4.setRotationPoint(0.4F, 21F, -0.5F); + setRotation(BottomBar4, 0F, 3.141593F, 0F); + } - public void render(Entity entity, float f, float f1, float f2, float f3, - float f4, float f5) { - super.render(entity, f, f1, f2, f3, f4, f5); - Wax1.render(f5); - Wax2.render(f5); - Wax3.render(f5); - Wax4.render(f5); - TippyTop1.render(f5); - TippyTop2.render(f5); - Middle.render(f5); - BottomBar1.render(f5); - Rod1.render(f5); - Rod2.render(f5); - Rod3.render(f5); - Rod4.render(f5); - Base1.render(f5); - Base2.render(f5); - Base3.render(f5); - Base4.render(f5); - BottomBar3.render(f5); - BottomBar2.render(f5); - BottomBar4.render(f5); - } + public void render(Entity entity, float f, float f1, float f2, float f3, + float f4, float f5) { + super.render(entity, f, f1, f2, f3, f4, f5); + Wax1.render(f5); + Wax2.render(f5); + Wax3.render(f5); + Wax4.render(f5); + TippyTop1.render(f5); + TippyTop2.render(f5); + Middle.render(f5); + BottomBar1.render(f5); + Rod1.render(f5); + Rod2.render(f5); + Rod3.render(f5); + Rod4.render(f5); + Base1.render(f5); + Base2.render(f5); + Base3.render(f5); + Base4.render(f5); + BottomBar3.render(f5); + BottomBar2.render(f5); + BottomBar4.render(f5); + } - private void setRotation(ModelRenderer model, float x, float y, float z) { - model.rotateAngleX = x; - model.rotateAngleY = y; - model.rotateAngleZ = z; - } + private void setRotation(ModelRenderer model, float x, float y, float z) { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } } diff --git a/src/main/java/noppes/npcs/client/model/blocks/legacy/ModelLegacyCandleWall.java b/src/main/java/noppes/npcs/client/model/blocks/legacy/ModelLegacyCandleWall.java index d71a31875..ed3641a04 100644 --- a/src/main/java/noppes/npcs/client/model/blocks/legacy/ModelLegacyCandleWall.java +++ b/src/main/java/noppes/npcs/client/model/blocks/legacy/ModelLegacyCandleWall.java @@ -5,80 +5,80 @@ import net.minecraft.client.model.ModelRenderer; import net.minecraft.entity.Entity; public class ModelLegacyCandleWall extends ModelBase { - ModelRenderer Base; - ModelRenderer Bar1; - ModelRenderer Bar2; - ModelRenderer Bar3; - ModelRenderer Bar4; - ModelRenderer Wax; - ModelRenderer Wall2; - ModelRenderer Wall1; - ModelRenderer Bar5; - ModelRenderer Bar6; + ModelRenderer Base; + ModelRenderer Bar1; + ModelRenderer Bar2; + ModelRenderer Bar3; + ModelRenderer Bar4; + ModelRenderer Wax; + ModelRenderer Wall2; + ModelRenderer Wall1; + ModelRenderer Bar5; + ModelRenderer Bar6; - public ModelLegacyCandleWall() { - Base = new ModelRenderer(this, 0, 0); - Base.addBox(0F, 0F, 0F, 4, 1, 4); - Base.setRotationPoint(-2F, 13F, -4F); + public ModelLegacyCandleWall() { + Base = new ModelRenderer(this, 0, 0); + Base.addBox(0F, 0F, 0F, 4, 1, 4); + Base.setRotationPoint(-2F, 13F, -4F); - Bar1 = new ModelRenderer(this, 0, 0); - Bar1.addBox(0F, 0F, 0F, 1, 1, 6); - Bar1.setRotationPoint(-3F, 12F, -5F); + Bar1 = new ModelRenderer(this, 0, 0); + Bar1.addBox(0F, 0F, 0F, 1, 1, 6); + Bar1.setRotationPoint(-3F, 12F, -5F); - Bar2 = new ModelRenderer(this, 0, 0); - Bar2.addBox(0F, 0F, 0F, 1, 1, 6); - Bar2.setRotationPoint(2F, 12F, -5F); + Bar2 = new ModelRenderer(this, 0, 0); + Bar2.addBox(0F, 0F, 0F, 1, 1, 6); + Bar2.setRotationPoint(2F, 12F, -5F); - Bar3 = new ModelRenderer(this, 0, 0); - Bar3.addBox(0F, 0F, 0F, 4, 1, 1); - Bar3.setRotationPoint(-2F, 12F, -5F); + Bar3 = new ModelRenderer(this, 0, 0); + Bar3.addBox(0F, 0F, 0F, 4, 1, 1); + Bar3.setRotationPoint(-2F, 12F, -5F); - Bar4 = new ModelRenderer(this, 0, 0); - Bar4.addBox(0F, 0F, 0F, 4, 1, 1); - Bar4.setRotationPoint(-2F, 12F, 0F); + Bar4 = new ModelRenderer(this, 0, 0); + Bar4.addBox(0F, 0F, 0F, 4, 1, 1); + Bar4.setRotationPoint(-2F, 12F, 0F); - Wax = new ModelRenderer(this, 16, 0); - Wax.addBox(0F, 0F, 0F, 2, 4, 2); - Wax.setRotationPoint(-1F, 9F, -3F); + Wax = new ModelRenderer(this, 16, 0); + Wax.addBox(0F, 0F, 0F, 2, 4, 2); + Wax.setRotationPoint(-1F, 9F, -3F); - Wall2 = new ModelRenderer(this, 0, 0); - Wall2.addBox(0F, 0F, 0F, 3, 3, 1); - Wall2.setRotationPoint(0F, 13.7F, -7.5F); - setRotation(Wall2, 0F, 0F, 0.7853982F); + Wall2 = new ModelRenderer(this, 0, 0); + Wall2.addBox(0F, 0F, 0F, 3, 3, 1); + Wall2.setRotationPoint(0F, 13.7F, -7.5F); + setRotation(Wall2, 0F, 0F, 0.7853982F); - Wall1 = new ModelRenderer(this, 0, 0); - Wall1.addBox(0F, 0F, 0F, 4, 4, 1); - Wall1.setRotationPoint(0F, 13F, -8F); - setRotation(Wall1, 0F, 0F, 0.7853982F); + Wall1 = new ModelRenderer(this, 0, 0); + Wall1.addBox(0F, 0F, 0F, 4, 4, 1); + Wall1.setRotationPoint(0F, 13F, -8F); + setRotation(Wall1, 0F, 0F, 0.7853982F); - Bar5 = new ModelRenderer(this, 0, 0); - Bar5.addBox(0F, 0F, 0F, 1, 2, 1); - Bar5.setRotationPoint(-0.5F, 13.5F, -2.5F); + Bar5 = new ModelRenderer(this, 0, 0); + Bar5.addBox(0F, 0F, 0F, 1, 2, 1); + Bar5.setRotationPoint(-0.5F, 13.5F, -2.5F); - Bar6 = new ModelRenderer(this, 0, 0); - Bar6.addBox(0F, 0F, 0F, 1, 1, 5); - Bar6.setRotationPoint(-0.5F, 15.5F, -6.5F); - } + Bar6 = new ModelRenderer(this, 0, 0); + Bar6.addBox(0F, 0F, 0F, 1, 1, 5); + Bar6.setRotationPoint(-0.5F, 15.5F, -6.5F); + } - public void render(Entity entity, float f, float f1, float f2, float f3, - float f4, float f5) { - super.render(entity, f, f1, f2, f3, f4, f5); - Base.render(f5); - Bar1.render(f5); - Bar2.render(f5); - Bar3.render(f5); - Bar4.render(f5); - Wax.render(f5); - Wall2.render(f5); - Wall1.render(f5); - Bar5.render(f5); - Bar6.render(f5); - } + public void render(Entity entity, float f, float f1, float f2, float f3, + float f4, float f5) { + super.render(entity, f, f1, f2, f3, f4, f5); + Base.render(f5); + Bar1.render(f5); + Bar2.render(f5); + Bar3.render(f5); + Bar4.render(f5); + Wax.render(f5); + Wall2.render(f5); + Wall1.render(f5); + Bar5.render(f5); + Bar6.render(f5); + } - private void setRotation(ModelRenderer model, float x, float y, float z) { - model.rotateAngleX = x; - model.rotateAngleY = y; - model.rotateAngleZ = z; - } + private void setRotation(ModelRenderer model, float x, float y, float z) { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } } diff --git a/src/main/java/noppes/npcs/client/model/blocks/legacy/ModelLegacyCarpentryBench.java b/src/main/java/noppes/npcs/client/model/blocks/legacy/ModelLegacyCarpentryBench.java index 9ccbd93e2..f105b6fb3 100644 --- a/src/main/java/noppes/npcs/client/model/blocks/legacy/ModelLegacyCarpentryBench.java +++ b/src/main/java/noppes/npcs/client/model/blocks/legacy/ModelLegacyCarpentryBench.java @@ -5,109 +5,109 @@ import net.minecraft.client.model.ModelRenderer; import net.minecraft.entity.Entity; public class ModelLegacyCarpentryBench extends ModelBase { - // fields - ModelRenderer Leg1; - ModelRenderer Leg2; - ModelRenderer Leg3; - ModelRenderer Leg4; - ModelRenderer Bottom_plate; - ModelRenderer Desktop; - ModelRenderer Backboard; - ModelRenderer Vice_Jaw1; - ModelRenderer Vice_Jaw2; - ModelRenderer Vice_Base1; - ModelRenderer Vice_Base2; - ModelRenderer Vice_Crank; - ModelRenderer Vice_Screw; - ModelRenderer Blueprint; + // fields + ModelRenderer Leg1; + ModelRenderer Leg2; + ModelRenderer Leg3; + ModelRenderer Leg4; + ModelRenderer Bottom_plate; + ModelRenderer Desktop; + ModelRenderer Backboard; + ModelRenderer Vice_Jaw1; + ModelRenderer Vice_Jaw2; + ModelRenderer Vice_Base1; + ModelRenderer Vice_Base2; + ModelRenderer Vice_Crank; + ModelRenderer Vice_Screw; + ModelRenderer Blueprint; - public ModelLegacyCarpentryBench() { - this.textureWidth = 128; - this.textureHeight = 64; + public ModelLegacyCarpentryBench() { + this.textureWidth = 128; + this.textureHeight = 64; - Leg1 = new ModelRenderer(this, 0, 0); - Leg1.addBox(0F, 0F, 0F, 2, 14, 2); - Leg1.setRotationPoint(6F, 10F, 5F); + Leg1 = new ModelRenderer(this, 0, 0); + Leg1.addBox(0F, 0F, 0F, 2, 14, 2); + Leg1.setRotationPoint(6F, 10F, 5F); - Leg2 = new ModelRenderer(this, 0, 0); - Leg2.addBox(0F, 0F, 0F, 2, 14, 2); - Leg2.setRotationPoint(6F, 10F, -5F); + Leg2 = new ModelRenderer(this, 0, 0); + Leg2.addBox(0F, 0F, 0F, 2, 14, 2); + Leg2.setRotationPoint(6F, 10F, -5F); - Leg3 = new ModelRenderer(this, 0, 0); - Leg3.addBox(0F, 0F, 0F, 2, 14, 2); - Leg3.setRotationPoint(-8F, 10F, 5F); + Leg3 = new ModelRenderer(this, 0, 0); + Leg3.addBox(0F, 0F, 0F, 2, 14, 2); + Leg3.setRotationPoint(-8F, 10F, 5F); - Leg4 = new ModelRenderer(this, 0, 0); - Leg4.addBox(0F, 0F, 0F, 2, 14, 2); - Leg4.setRotationPoint(-8F, 10F, -5F); + Leg4 = new ModelRenderer(this, 0, 0); + Leg4.addBox(0F, 0F, 0F, 2, 14, 2); + Leg4.setRotationPoint(-8F, 10F, -5F); - Bottom_plate = new ModelRenderer(this, 0, 24); - Bottom_plate.addBox(0F, 0F, 0F, 14, 1, 10); - Bottom_plate.setRotationPoint(-7F, 21F, -4F); - Bottom_plate.setTextureSize(130, 64); + Bottom_plate = new ModelRenderer(this, 0, 24); + Bottom_plate.addBox(0F, 0F, 0F, 14, 1, 10); + Bottom_plate.setRotationPoint(-7F, 21F, -4F); + Bottom_plate.setTextureSize(130, 64); - Desktop = new ModelRenderer(this, 0, 3); - Desktop.addBox(0F, 0F, 0F, 18, 2, 13); - Desktop.setRotationPoint(-9F, 9F, -6F); + Desktop = new ModelRenderer(this, 0, 3); + Desktop.addBox(0F, 0F, 0F, 18, 2, 13); + Desktop.setRotationPoint(-9F, 9F, -6F); - Backboard = new ModelRenderer(this, 0, 18); - Backboard.addBox(-1F, 0F, 0F, 18, 5, 1); - Backboard.setRotationPoint(-8F, 7F, 7F); + Backboard = new ModelRenderer(this, 0, 18); + Backboard.addBox(-1F, 0F, 0F, 18, 5, 1); + Backboard.setRotationPoint(-8F, 7F, 7F); - Vice_Jaw1 = new ModelRenderer(this, 54, 18); - Vice_Jaw1.addBox(0F, 0F, 0F, 3, 2, 1); - Vice_Jaw1.setRotationPoint(3F, 6F, -8F); + Vice_Jaw1 = new ModelRenderer(this, 54, 18); + Vice_Jaw1.addBox(0F, 0F, 0F, 3, 2, 1); + Vice_Jaw1.setRotationPoint(3F, 6F, -8F); - Vice_Jaw2 = new ModelRenderer(this, 54, 21); - Vice_Jaw2.addBox(0F, 0F, 0F, 3, 2, 1); - Vice_Jaw2.setRotationPoint(3F, 6F, -6F); + Vice_Jaw2 = new ModelRenderer(this, 54, 21); + Vice_Jaw2.addBox(0F, 0F, 0F, 3, 2, 1); + Vice_Jaw2.setRotationPoint(3F, 6F, -6F); - Vice_Base1 = new ModelRenderer(this, 38, 30); - Vice_Base1.addBox(0F, 0F, 0F, 3, 1, 3); - Vice_Base1.setRotationPoint(3F, 8F, -5F); + Vice_Base1 = new ModelRenderer(this, 38, 30); + Vice_Base1.addBox(0F, 0F, 0F, 3, 1, 3); + Vice_Base1.setRotationPoint(3F, 8F, -5F); - Vice_Base2 = new ModelRenderer(this, 38, 25); - Vice_Base2.addBox(0F, 0F, 0F, 1, 2, 2); - Vice_Base2.setRotationPoint(4F, 7F, -5F); + Vice_Base2 = new ModelRenderer(this, 38, 25); + Vice_Base2.addBox(0F, 0F, 0F, 1, 2, 2); + Vice_Base2.setRotationPoint(4F, 7F, -5F); - Vice_Crank = new ModelRenderer(this, 54, 24); - Vice_Crank.addBox(0F, 0F, 0F, 1, 5, 1); - Vice_Crank.setRotationPoint(6F, 6F, -9F); + Vice_Crank = new ModelRenderer(this, 54, 24); + Vice_Crank.addBox(0F, 0F, 0F, 1, 5, 1); + Vice_Crank.setRotationPoint(6F, 6F, -9F); - Vice_Screw = new ModelRenderer(this, 44, 25); - Vice_Screw.addBox(0F, 0F, 0F, 1, 1, 4); - Vice_Screw.setRotationPoint(4F, 8F, -8F); + Vice_Screw = new ModelRenderer(this, 44, 25); + Vice_Screw.addBox(0F, 0F, 0F, 1, 1, 4); + Vice_Screw.setRotationPoint(4F, 8F, -8F); - Blueprint = new ModelRenderer(this, 31, 18); - Blueprint.addBox(0F, 0F, 0F, 8, 0, 7); - Blueprint.setRotationPoint(0F, 9F, 1F); - setRotation(Blueprint, 0.3271718F, 0.1487144F, 0F); - } + Blueprint = new ModelRenderer(this, 31, 18); + Blueprint.addBox(0F, 0F, 0F, 8, 0, 7); + Blueprint.setRotationPoint(0F, 9F, 1F); + setRotation(Blueprint, 0.3271718F, 0.1487144F, 0F); + } - public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) { - super.render(entity, f, f1, f2, f3, f4, f5); - setRotationAngles(f, f1, f2, f3, f4, f5,entity); - Leg1.render(f5); - Leg2.render(f5); - Leg3.render(f5); - Leg4.render(f5); - Bottom_plate.render(f5); - Desktop.render(f5); - Backboard.render(f5); - Vice_Jaw1.render(f5); - Vice_Jaw2.render(f5); - Vice_Base1.render(f5); - Vice_Base2.render(f5); - Vice_Crank.render(f5); - Vice_Screw.render(f5); - Blueprint.render(f5); - } + public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) { + super.render(entity, f, f1, f2, f3, f4, f5); + setRotationAngles(f, f1, f2, f3, f4, f5, entity); + Leg1.render(f5); + Leg2.render(f5); + Leg3.render(f5); + Leg4.render(f5); + Bottom_plate.render(f5); + Desktop.render(f5); + Backboard.render(f5); + Vice_Jaw1.render(f5); + Vice_Jaw2.render(f5); + Vice_Base1.render(f5); + Vice_Base2.render(f5); + Vice_Crank.render(f5); + Vice_Screw.render(f5); + Blueprint.render(f5); + } - private void setRotation(ModelRenderer model, float x, float y, float z) { - model.rotateAngleX = x; - model.rotateAngleY = y; - model.rotateAngleZ = z; - } + private void setRotation(ModelRenderer model, float x, float y, float z) { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } } diff --git a/src/main/java/noppes/npcs/client/model/blocks/legacy/ModelLegacyCeiling.java b/src/main/java/noppes/npcs/client/model/blocks/legacy/ModelLegacyCeiling.java index ee245a531..2a37276fb 100644 --- a/src/main/java/noppes/npcs/client/model/blocks/legacy/ModelLegacyCeiling.java +++ b/src/main/java/noppes/npcs/client/model/blocks/legacy/ModelLegacyCeiling.java @@ -5,122 +5,122 @@ import net.minecraft.client.model.ModelRenderer; import net.minecraft.entity.Entity; public class ModelLegacyCeiling extends ModelBase { - ModelRenderer Base; - ModelRenderer Top1; - ModelRenderer Top2; - ModelRenderer Top3; - ModelRenderer Chain8; - ModelRenderer Chain1; - ModelRenderer Chain2; - ModelRenderer Chain3; - ModelRenderer Chain4; - ModelRenderer Chain5; - ModelRenderer Chain6; - ModelRenderer Chain7; - ModelRenderer TippyTop1; - ModelRenderer TippyTop2; - ModelRenderer Shape3; - ModelRenderer Shape1; - ModelRenderer Shape2; + ModelRenderer Base; + ModelRenderer Top1; + ModelRenderer Top2; + ModelRenderer Top3; + ModelRenderer Chain8; + ModelRenderer Chain1; + ModelRenderer Chain2; + ModelRenderer Chain3; + ModelRenderer Chain4; + ModelRenderer Chain5; + ModelRenderer Chain6; + ModelRenderer Chain7; + ModelRenderer TippyTop1; + ModelRenderer TippyTop2; + ModelRenderer Shape3; + ModelRenderer Shape1; + ModelRenderer Shape2; - public ModelLegacyCeiling() { - Base = new ModelRenderer(this, 0, 6); - Base.addBox(0F, 0F, 0F, 4, 7, 4); - Base.setRotationPoint(-2F, 17F, -2F); + public ModelLegacyCeiling() { + Base = new ModelRenderer(this, 0, 6); + Base.addBox(0F, 0F, 0F, 4, 7, 4); + Base.setRotationPoint(-2F, 17F, -2F); - Top1 = new ModelRenderer(this, 0, 0); - Top1.addBox(0F, 0F, 0F, 5, 1, 5); - Top1.setRotationPoint(-2.5F, 17F, -2.5F); + Top1 = new ModelRenderer(this, 0, 0); + Top1.addBox(0F, 0F, 0F, 5, 1, 5); + Top1.setRotationPoint(-2.5F, 17F, -2.5F); - Top2 = new ModelRenderer(this, 0, 0); - Top2.addBox(0F, 0F, 0F, 4, 1, 4); - Top2.setRotationPoint(-2F, 16.5F, -2F); + Top2 = new ModelRenderer(this, 0, 0); + Top2.addBox(0F, 0F, 0F, 4, 1, 4); + Top2.setRotationPoint(-2F, 16.5F, -2F); - Top3 = new ModelRenderer(this, 0, 0); - Top3.addBox(0F, 0F, 0F, 3, 1, 3); - Top3.setRotationPoint(-1.5F, 16F, -1.5F); + Top3 = new ModelRenderer(this, 0, 0); + Top3.addBox(0F, 0F, 0F, 3, 1, 3); + Top3.setRotationPoint(-1.5F, 16F, -1.5F); - Chain8 = new ModelRenderer(this, 0, 0); - Chain8.addBox(0F, 0F, 0F, 1, 2, 1); - Chain8.setRotationPoint(-0.5F, 14F, -1.5F); + Chain8 = new ModelRenderer(this, 0, 0); + Chain8.addBox(0F, 0F, 0F, 1, 2, 1); + Chain8.setRotationPoint(-0.5F, 14F, -1.5F); - Chain1 = new ModelRenderer(this, 0, 0); - Chain1.addBox(0F, 0F, 0F, 1, 3, 1); - Chain1.setRotationPoint(0.5F, 8F, -0.5F); + Chain1 = new ModelRenderer(this, 0, 0); + Chain1.addBox(0F, 0F, 0F, 1, 3, 1); + Chain1.setRotationPoint(0.5F, 8F, -0.5F); - Chain2 = new ModelRenderer(this, 0, 0); - Chain2.addBox(0F, 0F, 0F, 1, 3, 1); - Chain2.setRotationPoint(-1.5F, 8F, -0.5F); + Chain2 = new ModelRenderer(this, 0, 0); + Chain2.addBox(0F, 0F, 0F, 1, 3, 1); + Chain2.setRotationPoint(-1.5F, 8F, -0.5F); - Chain3 = new ModelRenderer(this, 0, 0); - Chain3.addBox(0F, 0F, 0F, 1, 3, 1); - Chain3.setRotationPoint(-0.5F, 10F, 0.5F); + Chain3 = new ModelRenderer(this, 0, 0); + Chain3.addBox(0F, 0F, 0F, 1, 3, 1); + Chain3.setRotationPoint(-0.5F, 10F, 0.5F); - Chain4 = new ModelRenderer(this, 0, 0); - Chain4.addBox(0F, 0F, 0F, 1, 3, 1); - Chain4.setRotationPoint(-0.5F, 10F, -1.5F); + Chain4 = new ModelRenderer(this, 0, 0); + Chain4.addBox(0F, 0F, 0F, 1, 3, 1); + Chain4.setRotationPoint(-0.5F, 10F, -1.5F); - Chain5 = new ModelRenderer(this, 0, 0); - Chain5.addBox(0F, 0F, 0F, 1, 3, 1); - Chain5.setRotationPoint(-1.5F, 12F, -0.5F); + Chain5 = new ModelRenderer(this, 0, 0); + Chain5.addBox(0F, 0F, 0F, 1, 3, 1); + Chain5.setRotationPoint(-1.5F, 12F, -0.5F); - Chain6 = new ModelRenderer(this, 0, 0); - Chain6.addBox(0F, 0F, 0F, 1, 3, 1); - Chain6.setRotationPoint(0.5F, 12F, -0.5F); + Chain6 = new ModelRenderer(this, 0, 0); + Chain6.addBox(0F, 0F, 0F, 1, 3, 1); + Chain6.setRotationPoint(0.5F, 12F, -0.5F); - Chain7 = new ModelRenderer(this, 0, 0); - Chain7.addBox(0F, 0F, 0F, 1, 2, 1); - Chain7.setRotationPoint(-0.5F, 14F, 0.5F); + Chain7 = new ModelRenderer(this, 0, 0); + Chain7.addBox(0F, 0F, 0F, 1, 2, 1); + Chain7.setRotationPoint(-0.5F, 14F, 0.5F); - TippyTop1 = new ModelRenderer(this, 0, 0); - TippyTop1.addBox(0F, 0F, 0F, 4, 1, 4); - TippyTop1.setRotationPoint(-2.8F, 8F, 0F); - setRotation(TippyTop1, 0F, 0.7853982F, 0F); + TippyTop1 = new ModelRenderer(this, 0, 0); + TippyTop1.addBox(0F, 0F, 0F, 4, 1, 4); + TippyTop1.setRotationPoint(-2.8F, 8F, 0F); + setRotation(TippyTop1, 0F, 0.7853982F, 0F); - TippyTop2 = new ModelRenderer(this, 0, 0); - TippyTop2.addBox(0F, 0F, 0F, 3, 1, 3); - TippyTop2.setRotationPoint(-2.1F, 8.5F, 0F); - setRotation(TippyTop2, 0F, 0.7853982F, 0F); + TippyTop2 = new ModelRenderer(this, 0, 0); + TippyTop2.addBox(0F, 0F, 0F, 3, 1, 3); + TippyTop2.setRotationPoint(-2.1F, 8.5F, 0F); + setRotation(TippyTop2, 0F, 0.7853982F, 0F); - Shape3 = new ModelRenderer(this, 0, 0); - Shape3.addBox(0F, 0F, 0F, 1, 1, 1); - Shape3.setRotationPoint(-0.5F, 14F, -0.5F); + Shape3 = new ModelRenderer(this, 0, 0); + Shape3.addBox(0F, 0F, 0F, 1, 1, 1); + Shape3.setRotationPoint(-0.5F, 14F, -0.5F); - Shape1 = new ModelRenderer(this, 0, 0); - Shape1.addBox(0F, 0F, 0F, 1, 1, 1); - Shape1.setRotationPoint(-0.5F, 10F, -0.5F); + Shape1 = new ModelRenderer(this, 0, 0); + Shape1.addBox(0F, 0F, 0F, 1, 1, 1); + Shape1.setRotationPoint(-0.5F, 10F, -0.5F); - Shape2 = new ModelRenderer(this, 0, 0); - Shape2.addBox(0F, 0F, 0F, 1, 1, 1); - Shape2.setRotationPoint(-0.5F, 12F, -0.5F); - } + Shape2 = new ModelRenderer(this, 0, 0); + Shape2.addBox(0F, 0F, 0F, 1, 1, 1); + Shape2.setRotationPoint(-0.5F, 12F, -0.5F); + } - public void render(Entity entity, float f, float f1, float f2, float f3, - float f4, float f5) { - super.render(entity, f, f1, f2, f3, f4, f5); - Base.render(f5); - Top1.render(f5); - Top2.render(f5); - Top3.render(f5); - Chain8.render(f5); - Chain1.render(f5); - Chain2.render(f5); - Chain3.render(f5); - Chain4.render(f5); - Chain5.render(f5); - Chain6.render(f5); - Chain7.render(f5); - TippyTop1.render(f5); - TippyTop2.render(f5); - Shape3.render(f5); - Shape1.render(f5); - Shape2.render(f5); - } + public void render(Entity entity, float f, float f1, float f2, float f3, + float f4, float f5) { + super.render(entity, f, f1, f2, f3, f4, f5); + Base.render(f5); + Top1.render(f5); + Top2.render(f5); + Top3.render(f5); + Chain8.render(f5); + Chain1.render(f5); + Chain2.render(f5); + Chain3.render(f5); + Chain4.render(f5); + Chain5.render(f5); + Chain6.render(f5); + Chain7.render(f5); + TippyTop1.render(f5); + TippyTop2.render(f5); + Shape3.render(f5); + Shape1.render(f5); + Shape2.render(f5); + } - private void setRotation(ModelRenderer model, float x, float y, float z) { - model.rotateAngleX = x; - model.rotateAngleY = y; - model.rotateAngleZ = z; - } + private void setRotation(ModelRenderer model, float x, float y, float z) { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } } diff --git a/src/main/java/noppes/npcs/client/model/blocks/legacy/ModelLegacyChair.java b/src/main/java/noppes/npcs/client/model/blocks/legacy/ModelLegacyChair.java index 4b6cfcfe4..c82317759 100644 --- a/src/main/java/noppes/npcs/client/model/blocks/legacy/ModelLegacyChair.java +++ b/src/main/java/noppes/npcs/client/model/blocks/legacy/ModelLegacyChair.java @@ -4,9 +4,8 @@ import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelRenderer; import net.minecraft.entity.Entity; -public class ModelLegacyChair extends ModelBase -{ - //fields +public class ModelLegacyChair extends ModelBase { + //fields ModelRenderer Leg1; ModelRenderer Leg2; ModelRenderer Leg3; @@ -23,104 +22,101 @@ public class ModelLegacyChair extends ModelBase ModelRenderer Shape10; ModelRenderer Shape11; - public ModelLegacyChair() - { - Leg1 = new ModelRenderer(this, 0, 0); - Leg1.mirror = true; - Leg1.addBox(0F, 0F, 0F, 1, 18, 1); - Leg1.setRotationPoint(4.01F, 6F, 5.01F); + public ModelLegacyChair() { + Leg1 = new ModelRenderer(this, 0, 0); + Leg1.mirror = true; + Leg1.addBox(0F, 0F, 0F, 1, 18, 1); + Leg1.setRotationPoint(4.01F, 6F, 5.01F); - Leg2 = new ModelRenderer(this, 0, 0); - Leg2.mirror = true; - Leg2.addBox(0F, 0F, 0F, 1, 9, 1); - Leg2.setRotationPoint(4.01F, 15.5F, -5.01F); + Leg2 = new ModelRenderer(this, 0, 0); + Leg2.mirror = true; + Leg2.addBox(0F, 0F, 0F, 1, 9, 1); + Leg2.setRotationPoint(4.01F, 15.5F, -5.01F); - Leg3 = new ModelRenderer(this, 0, 0); - Leg3.addBox(0F, 0F, 0F, 1, 18, 1); - Leg3.setRotationPoint(-5.01F, 6F, 5.01F); + Leg3 = new ModelRenderer(this, 0, 0); + Leg3.addBox(0F, 0F, 0F, 1, 18, 1); + Leg3.setRotationPoint(-5.01F, 6F, 5.01F); - Leg4 = new ModelRenderer(this, 0, 0); - Leg4.addBox(0F, 0F, 0F, 1, 9, 1); - Leg4.setRotationPoint(-5.01F, 15.5F, -5.01F); + Leg4 = new ModelRenderer(this, 0, 0); + Leg4.addBox(0F, 0F, 0F, 1, 9, 1); + Leg4.setRotationPoint(-5.01F, 15.5F, -5.01F); - Shape1 = new ModelRenderer(this, 8, 2); - Shape1.addBox(0F, 0F, 0F, 10, 1, 11); - Shape1.setRotationPoint(-5F, 16F, -5F); + Shape1 = new ModelRenderer(this, 8, 2); + Shape1.addBox(0F, 0F, 0F, 10, 1, 11); + Shape1.setRotationPoint(-5F, 16F, -5F); - Shape2 = new ModelRenderer(this, 4, 4); - Shape2.addBox(0F, 0F, 0F, 3, 2, 1); - Shape2.setRotationPoint(-1.5F, 6.51F, 5.5F); + Shape2 = new ModelRenderer(this, 4, 4); + Shape2.addBox(0F, 0F, 0F, 3, 2, 1); + Shape2.setRotationPoint(-1.5F, 6.51F, 5.5F); - Shape3 = new ModelRenderer(this, 4, 4); - Shape3.mirror = true; - Shape3.addBox(-3F, 0F, 0F, 3, 2, 1); - Shape3.setRotationPoint(4F, 6.5F, 5F); - setRotation(Shape3, 0F, 0.2094395F, 0F); + Shape3 = new ModelRenderer(this, 4, 4); + Shape3.mirror = true; + Shape3.addBox(-3F, 0F, 0F, 3, 2, 1); + Shape3.setRotationPoint(4F, 6.5F, 5F); + setRotation(Shape3, 0F, 0.2094395F, 0F); - Shape4 = new ModelRenderer(this, 4, 4); - Shape4.addBox(0F, 0F, 0F, 3, 2, 1); - Shape4.setRotationPoint(-4F, 6.5F, 5F); - setRotation(Shape4, 0F, -0.2094395F, 0F); + Shape4 = new ModelRenderer(this, 4, 4); + Shape4.addBox(0F, 0F, 0F, 3, 2, 1); + Shape4.setRotationPoint(-4F, 6.5F, 5F); + setRotation(Shape4, 0F, -0.2094395F, 0F); - Shape5 = new ModelRenderer(this, 46, 0); - Shape5.addBox(0F, 0F, 0F, 9, 1, 1); - Shape5.setRotationPoint(-4F, 19F, 5F); + Shape5 = new ModelRenderer(this, 46, 0); + Shape5.addBox(0F, 0F, 0F, 9, 1, 1); + Shape5.setRotationPoint(-4F, 19F, 5F); - Shape6 = new ModelRenderer(this, 46, 0); - Shape6.addBox(0F, 0F, 0F, 8, 1, 1); - Shape6.setRotationPoint(-4F, 19F, -5F); + Shape6 = new ModelRenderer(this, 46, 0); + Shape6.addBox(0F, 0F, 0F, 8, 1, 1); + Shape6.setRotationPoint(-4F, 19F, -5F); - Shape7 = new ModelRenderer(this, 11, 13); - Shape7.addBox(0F, 0F, 0F, 1, 1, 9); - Shape7.setRotationPoint(-5F, 20F, -4F); + Shape7 = new ModelRenderer(this, 11, 13); + Shape7.addBox(0F, 0F, 0F, 1, 1, 9); + Shape7.setRotationPoint(-5F, 20F, -4F); - Shape8 = new ModelRenderer(this, 11, 13); - Shape8.mirror = true; - Shape8.addBox(0F, 0F, 0F, 1, 1, 9); - Shape8.setRotationPoint(4F, 20F, -4F); + Shape8 = new ModelRenderer(this, 11, 13); + Shape8.mirror = true; + Shape8.addBox(0F, 0F, 0F, 1, 1, 9); + Shape8.setRotationPoint(4F, 20F, -4F); - Shape9 = new ModelRenderer(this, 0, 0); - Shape9.mirror = true; - Shape9.addBox(0F, 0F, 0F, 1, 8, 1); - Shape9.setRotationPoint(2F, 8F, 5.5F); - setRotation(Shape9, -0.0523599F, 0F, 0F); + Shape9 = new ModelRenderer(this, 0, 0); + Shape9.mirror = true; + Shape9.addBox(0F, 0F, 0F, 1, 8, 1); + Shape9.setRotationPoint(2F, 8F, 5.5F); + setRotation(Shape9, -0.0523599F, 0F, 0F); - Shape10 = new ModelRenderer(this, 0, 0); - Shape10.addBox(0F, 0F, 0F, 1, 8, 1); - Shape10.setRotationPoint(-3F, 8F, 5.5F); - setRotation(Shape10, -0.0523599F, 0F, 0F); + Shape10 = new ModelRenderer(this, 0, 0); + Shape10.addBox(0F, 0F, 0F, 1, 8, 1); + Shape10.setRotationPoint(-3F, 8F, 5.5F); + setRotation(Shape10, -0.0523599F, 0F, 0F); - Shape11 = new ModelRenderer(this, 0, 0); - Shape11.addBox(0F, 0F, 0F, 1, 8, 1); - Shape11.setRotationPoint(-0.5F, 8F, 5.6F); - setRotation(Shape11, -0.0698132F, 0F, 0F); - } + Shape11 = new ModelRenderer(this, 0, 0); + Shape11.addBox(0F, 0F, 0F, 1, 8, 1); + Shape11.setRotationPoint(-0.5F, 8F, 5.6F); + setRotation(Shape11, -0.0698132F, 0F, 0F); + } - public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) - { - super.render(entity, f, f1, f2, f3, f4, f5); - Leg1.render(f5); - Leg2.render(f5); - Leg3.render(f5); - Leg4.render(f5); - Shape1.render(f5); - Shape2.render(f5); - Shape3.render(f5); - Shape4.render(f5); - Shape5.render(f5); - Shape6.render(f5); - Shape7.render(f5); - Shape8.render(f5); - Shape9.render(f5); - Shape10.render(f5); - Shape11.render(f5); - } + public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) { + super.render(entity, f, f1, f2, f3, f4, f5); + Leg1.render(f5); + Leg2.render(f5); + Leg3.render(f5); + Leg4.render(f5); + Shape1.render(f5); + Shape2.render(f5); + Shape3.render(f5); + Shape4.render(f5); + Shape5.render(f5); + Shape6.render(f5); + Shape7.render(f5); + Shape8.render(f5); + Shape9.render(f5); + Shape10.render(f5); + Shape11.render(f5); + } - private void setRotation(ModelRenderer model, float x, float y, float z) - { - model.rotateAngleX = x; - model.rotateAngleY = y; - model.rotateAngleZ = z; - } + private void setRotation(ModelRenderer model, float x, float y, float z) { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } } diff --git a/src/main/java/noppes/npcs/client/model/blocks/legacy/ModelLegacyLantern.java b/src/main/java/noppes/npcs/client/model/blocks/legacy/ModelLegacyLantern.java index c20bd7f6d..6bae02671 100644 --- a/src/main/java/noppes/npcs/client/model/blocks/legacy/ModelLegacyLantern.java +++ b/src/main/java/noppes/npcs/client/model/blocks/legacy/ModelLegacyLantern.java @@ -11,55 +11,55 @@ import net.minecraft.client.model.ModelRenderer; import net.minecraft.entity.Entity; public class ModelLegacyLantern extends ModelBase { - ModelRenderer Base; - ModelRenderer Top1; - ModelRenderer Top2; - ModelRenderer Top3; - ModelRenderer Handle; - ModelRenderer Shape1; + ModelRenderer Base; + ModelRenderer Top1; + ModelRenderer Top2; + ModelRenderer Top3; + ModelRenderer Handle; + ModelRenderer Shape1; - public ModelLegacyLantern() { - Base = new ModelRenderer(this, 0, 6); - Base.addBox(0F, 0F, 0F, 4, 7, 4); - Base.setRotationPoint(-2F, 16F, -2F); + public ModelLegacyLantern() { + Base = new ModelRenderer(this, 0, 6); + Base.addBox(0F, 0F, 0F, 4, 7, 4); + Base.setRotationPoint(-2F, 16F, -2F); - Top1 = new ModelRenderer(this, 0, 0); - Top1.addBox(0F, 0F, 0F, 5, 1, 5); - Top1.setRotationPoint(-2.5F, 16F, -2.5F); + Top1 = new ModelRenderer(this, 0, 0); + Top1.addBox(0F, 0F, 0F, 5, 1, 5); + Top1.setRotationPoint(-2.5F, 16F, -2.5F); - Top2 = new ModelRenderer(this, 0, 0); - Top2.addBox(0F, 0F, 0F, 4, 1, 4); - Top2.setRotationPoint(-2F, 15.5F, -2F); + Top2 = new ModelRenderer(this, 0, 0); + Top2.addBox(0F, 0F, 0F, 4, 1, 4); + Top2.setRotationPoint(-2F, 15.5F, -2F); - Top3 = new ModelRenderer(this, 0, 0); - Top3.addBox(0F, 0F, 0F, 3, 1, 3); - Top3.setRotationPoint(-1.5F, 15F, -1.5F); + Top3 = new ModelRenderer(this, 0, 0); + Top3.addBox(0F, 0F, 0F, 3, 1, 3); + Top3.setRotationPoint(-1.5F, 15F, -1.5F); - Handle = new ModelRenderer(this, 24, 0); - Handle.addBox(0F, 0F, 0F, 3, 0, 3); - Handle.setRotationPoint(0F, 15F, 0F); - setRotation(Handle, 0.296706F, 0.1745329F, 0F); + Handle = new ModelRenderer(this, 24, 0); + Handle.addBox(0F, 0F, 0F, 3, 0, 3); + Handle.setRotationPoint(0F, 15F, 0F); + setRotation(Handle, 0.296706F, 0.1745329F, 0F); - Shape1 = new ModelRenderer(this, 0, 17); - Shape1.addBox(-2F, 0F, -2F, 4, 1, 4); - Shape1.setRotationPoint(0F, 23F, 0F); - } + Shape1 = new ModelRenderer(this, 0, 17); + Shape1.addBox(-2F, 0F, -2F, 4, 1, 4); + Shape1.setRotationPoint(0F, 23F, 0F); + } - public void render(Entity entity, float f, float f1, float f2, float f3, - float f4, float f5) { - super.render(entity, f, f1, f2, f3, f4, f5); - Base.render(f5); - Top1.render(f5); - Top2.render(f5); - Top3.render(f5); - Handle.render(f5); - Shape1.render(f5); - } + public void render(Entity entity, float f, float f1, float f2, float f3, + float f4, float f5) { + super.render(entity, f, f1, f2, f3, f4, f5); + Base.render(f5); + Top1.render(f5); + Top2.render(f5); + Top3.render(f5); + Handle.render(f5); + Shape1.render(f5); + } - private void setRotation(ModelRenderer model, float x, float y, float z) { - model.rotateAngleX = x; - model.rotateAngleY = y; - model.rotateAngleZ = z; - } + private void setRotation(ModelRenderer model, float x, float y, float z) { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } } diff --git a/src/main/java/noppes/npcs/client/model/blocks/legacy/ModelLegacyMailboxUS.java b/src/main/java/noppes/npcs/client/model/blocks/legacy/ModelLegacyMailboxUS.java index ebe986822..2a72b124a 100644 --- a/src/main/java/noppes/npcs/client/model/blocks/legacy/ModelLegacyMailboxUS.java +++ b/src/main/java/noppes/npcs/client/model/blocks/legacy/ModelLegacyMailboxUS.java @@ -5,94 +5,94 @@ import net.minecraft.client.model.ModelRenderer; import net.minecraft.entity.Entity; public class ModelLegacyMailboxUS extends ModelBase { - // fields - ModelRenderer Shape1; - ModelRenderer Shape2; - ModelRenderer Shape3; - ModelRenderer Shape4; - ModelRenderer Shape5; - ModelRenderer Shape6; - ModelRenderer Shape7; - ModelRenderer Shape8; - ModelRenderer Shape9; - ModelRenderer Shape10; - ModelRenderer Shape11; - ModelRenderer Shape12; - ModelRenderer Shape13; + // fields + ModelRenderer Shape1; + ModelRenderer Shape2; + ModelRenderer Shape3; + ModelRenderer Shape4; + ModelRenderer Shape5; + ModelRenderer Shape6; + ModelRenderer Shape7; + ModelRenderer Shape8; + ModelRenderer Shape9; + ModelRenderer Shape10; + ModelRenderer Shape11; + ModelRenderer Shape12; + ModelRenderer Shape13; - public ModelLegacyMailboxUS() { - textureWidth = 64; - textureHeight = 128; + public ModelLegacyMailboxUS() { + textureWidth = 64; + textureHeight = 128; - Shape1 = new ModelRenderer(this, 0, 48); - Shape1.addBox(0F, 0F, 0F, 16, 14, 16); - Shape1.setRotationPoint(-8F, 8F, -8F); + Shape1 = new ModelRenderer(this, 0, 48); + Shape1.addBox(0F, 0F, 0F, 16, 14, 16); + Shape1.setRotationPoint(-8F, 8F, -8F); - Shape2 = new ModelRenderer(this, 0, 79); - Shape2.addBox(0F, 0F, 0F, 1, 2, 1); - Shape2.setRotationPoint(-8F, 22F, -8F); + Shape2 = new ModelRenderer(this, 0, 79); + Shape2.addBox(0F, 0F, 0F, 1, 2, 1); + Shape2.setRotationPoint(-8F, 22F, -8F); - Shape3 = new ModelRenderer(this, 5, 79); - Shape3.addBox(0F, 0F, 0F, 1, 2, 1); - Shape3.setRotationPoint(-8F, 22F, 7F); + Shape3 = new ModelRenderer(this, 5, 79); + Shape3.addBox(0F, 0F, 0F, 1, 2, 1); + Shape3.setRotationPoint(-8F, 22F, 7F); - Shape4 = new ModelRenderer(this, 10, 79); - Shape4.addBox(0F, 0F, 0F, 1, 2, 1); - Shape4.setRotationPoint(7F, 22F, -8F); + Shape4 = new ModelRenderer(this, 10, 79); + Shape4.addBox(0F, 0F, 0F, 1, 2, 1); + Shape4.setRotationPoint(7F, 22F, -8F); - Shape5 = new ModelRenderer(this, 15, 79); - Shape5.addBox(0F, 0F, 0F, 1, 2, 1); - Shape5.setRotationPoint(7F, 22F, 7F); + Shape5 = new ModelRenderer(this, 15, 79); + Shape5.addBox(0F, 0F, 0F, 1, 2, 1); + Shape5.setRotationPoint(7F, 22F, 7F); - Shape6 = new ModelRenderer(this, 0, 14); - Shape6.addBox(0F, 0F, 0F, 16, 3, 7); - Shape6.setRotationPoint(-8F, 5F, 0F); + Shape6 = new ModelRenderer(this, 0, 14); + Shape6.addBox(0F, 0F, 0F, 16, 3, 7); + Shape6.setRotationPoint(-8F, 5F, 0F); - Shape7 = new ModelRenderer(this, 0, 6); - Shape7.addBox(0F, 0F, 0F, 16, 2, 6); - Shape7.setRotationPoint(-8F, 3F, 0F); + Shape7 = new ModelRenderer(this, 0, 6); + Shape7.addBox(0F, 0F, 0F, 16, 2, 6); + Shape7.setRotationPoint(-8F, 3F, 0F); - Shape8 = new ModelRenderer(this, 0, 0); - Shape8.addBox(0F, 0F, 0F, 16, 1, 5); - Shape8.setRotationPoint(-8F, 2F, 0F); + Shape8 = new ModelRenderer(this, 0, 0); + Shape8.addBox(0F, 0F, 0F, 16, 1, 5); + Shape8.setRotationPoint(-8F, 2F, 0F); - Shape9 = new ModelRenderer(this, 0, 37); - Shape9.addBox(0F, 0F, 0F, 1, 3, 7); - Shape9.setRotationPoint(-8F, 5F, -7F); + Shape9 = new ModelRenderer(this, 0, 37); + Shape9.addBox(0F, 0F, 0F, 1, 3, 7); + Shape9.setRotationPoint(-8F, 5F, -7F); - Shape10 = new ModelRenderer(this, 16, 37); - Shape10.addBox(0F, 0F, 0F, 1, 3, 7); - Shape10.setRotationPoint(7F, 5F, -7F); + Shape10 = new ModelRenderer(this, 16, 37); + Shape10.addBox(0F, 0F, 0F, 1, 3, 7); + Shape10.setRotationPoint(7F, 5F, -7F); - Shape11 = new ModelRenderer(this, 0, 29); - Shape11.addBox(0F, 0F, 0F, 1, 2, 6); - Shape11.setRotationPoint(-8F, 3F, -6F); + Shape11 = new ModelRenderer(this, 0, 29); + Shape11.addBox(0F, 0F, 0F, 1, 2, 6); + Shape11.setRotationPoint(-8F, 3F, -6F); - Shape12 = new ModelRenderer(this, 14, 29); - Shape12.addBox(0F, 0F, 0F, 1, 2, 6); - Shape12.setRotationPoint(7F, 3F, -6F); + Shape12 = new ModelRenderer(this, 14, 29); + Shape12.addBox(0F, 0F, 0F, 1, 2, 6); + Shape12.setRotationPoint(7F, 3F, -6F); - Shape13 = new ModelRenderer(this, 0, 25); - Shape13.addBox(0F, 0F, 0F, 16, 1, 3); - Shape13.setRotationPoint(-8F, 2F, -3F); - } + Shape13 = new ModelRenderer(this, 0, 25); + Shape13.addBox(0F, 0F, 0F, 16, 1, 3); + Shape13.setRotationPoint(-8F, 2F, -3F); + } - public void render(Entity entity, float f, float f1, float f2, float f3, - float f4, float f5) { - super.render(entity, f, f1, f2, f3, f4, f5); - Shape1.render(f5); - Shape2.render(f5); - Shape3.render(f5); - Shape4.render(f5); - Shape5.render(f5); - Shape6.render(f5); - Shape7.render(f5); - Shape8.render(f5); - Shape9.render(f5); - Shape10.render(f5); - Shape11.render(f5); - Shape12.render(f5); - Shape13.render(f5); - } + public void render(Entity entity, float f, float f1, float f2, float f3, + float f4, float f5) { + super.render(entity, f, f1, f2, f3, f4, f5); + Shape1.render(f5); + Shape2.render(f5); + Shape3.render(f5); + Shape4.render(f5); + Shape5.render(f5); + Shape6.render(f5); + Shape7.render(f5); + Shape8.render(f5); + Shape9.render(f5); + Shape10.render(f5); + Shape11.render(f5); + Shape12.render(f5); + Shape13.render(f5); + } } diff --git a/src/main/java/noppes/npcs/client/model/blocks/legacy/ModelLegacyPedestal.java b/src/main/java/noppes/npcs/client/model/blocks/legacy/ModelLegacyPedestal.java index 18fd108ce..a97d6fdee 100644 --- a/src/main/java/noppes/npcs/client/model/blocks/legacy/ModelLegacyPedestal.java +++ b/src/main/java/noppes/npcs/client/model/blocks/legacy/ModelLegacyPedestal.java @@ -6,35 +6,35 @@ import net.minecraft.entity.Entity; import org.lwjgl.opengl.GL11; public class ModelLegacyPedestal extends ModelBase { - ModelRenderer Main_Block; - ModelRenderer Front; + ModelRenderer Main_Block; + ModelRenderer Front; - public ModelLegacyPedestal() { - Main_Block = new ModelRenderer(this, 1, 0); - Main_Block.addBox(-7F, 0F, -8F, 14, 3, 16); - Main_Block.setRotationPoint(0, 16F, 0F); + public ModelLegacyPedestal() { + Main_Block = new ModelRenderer(this, 1, 0); + Main_Block.addBox(-7F, 0F, -8F, 14, 3, 16); + Main_Block.setRotationPoint(0, 16F, 0F); - Front = new ModelRenderer(this, 16, 8); - Front.addBox(-8F, 0F, -8F, 16, 5, 16); - Front.setRotationPoint(0F, 19F, 0F); - } + Front = new ModelRenderer(this, 16, 8); + Front.addBox(-8F, 0F, -8F, 16, 5, 16); + Front.setRotationPoint(0F, 19F, 0F); + } - public void render(Entity entity, float f, float f1, float f2, float f3, - float f4, float f5) { - super.render(entity, f, f1, f2, f3, f4, f5); - GL11.glPushMatrix(); - GL11.glScalef(1, 1, 0.5f); - Main_Block.render(f5); - GL11.glScalef(1, 1, 1.25f); - Front.render(f5); - GL11.glPopMatrix(); - } + public void render(Entity entity, float f, float f1, float f2, float f3, + float f4, float f5) { + super.render(entity, f, f1, f2, f3, f4, f5); + GL11.glPushMatrix(); + GL11.glScalef(1, 1, 0.5f); + Main_Block.render(f5); + GL11.glScalef(1, 1, 1.25f); + Front.render(f5); + GL11.glPopMatrix(); + } - private void setRotation(ModelRenderer model, float x, float y, float z) { - model.rotateAngleX = x; - model.rotateAngleY = y; - model.rotateAngleZ = z; - } + private void setRotation(ModelRenderer model, float x, float y, float z) { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } } diff --git a/src/main/java/noppes/npcs/client/model/blocks/legacy/ModelLegacyStool.java b/src/main/java/noppes/npcs/client/model/blocks/legacy/ModelLegacyStool.java index 0c964f5ec..79e3bc619 100644 --- a/src/main/java/noppes/npcs/client/model/blocks/legacy/ModelLegacyStool.java +++ b/src/main/java/noppes/npcs/client/model/blocks/legacy/ModelLegacyStool.java @@ -5,79 +5,79 @@ import net.minecraft.client.model.ModelRenderer; import net.minecraft.entity.Entity; public class ModelLegacyStool extends ModelBase { - ModelRenderer Base; - ModelRenderer Leg1; - ModelRenderer Leg2; - ModelRenderer Leg3; - ModelRenderer Leg4; - ModelRenderer Shape1; - ModelRenderer Shape2; - ModelRenderer Shape3; - ModelRenderer Shape4; + ModelRenderer Base; + ModelRenderer Leg1; + ModelRenderer Leg2; + ModelRenderer Leg3; + ModelRenderer Leg4; + ModelRenderer Shape1; + ModelRenderer Shape2; + ModelRenderer Shape3; + ModelRenderer Shape4; - public ModelLegacyStool() { - Base = new ModelRenderer(this, 9, 3); - Base.addBox(-5F, 0F, -5F, 10, 1, 10); - Base.setRotationPoint(0F, 16F, 0F); + public ModelLegacyStool() { + Base = new ModelRenderer(this, 9, 3); + Base.addBox(-5F, 0F, -5F, 10, 1, 10); + Base.setRotationPoint(0F, 16F, 0F); - Leg1 = new ModelRenderer(this, 0, 12); - Leg1.addBox(-1F, 0F, 0F, 2, 8, 1); - Leg1.setRotationPoint(2F, 17F, 2F); - setRotation(Leg1, 0.3316126F, 0.7853982F, 0F); + Leg1 = new ModelRenderer(this, 0, 12); + Leg1.addBox(-1F, 0F, 0F, 2, 8, 1); + Leg1.setRotationPoint(2F, 17F, 2F); + setRotation(Leg1, 0.3316126F, 0.7853982F, 0F); - Leg2 = new ModelRenderer(this, 0, 12); - Leg2.addBox(-1F, 0F, 0F, 2, 8, 1); - Leg2.setRotationPoint(2F, 17F, -2F); - setRotation(Leg2, 0.3316126F, 2.356194F, -0.0081449F); + Leg2 = new ModelRenderer(this, 0, 12); + Leg2.addBox(-1F, 0F, 0F, 2, 8, 1); + Leg2.setRotationPoint(2F, 17F, -2F); + setRotation(Leg2, 0.3316126F, 2.356194F, -0.0081449F); - Leg3 = new ModelRenderer(this, 0, 12); - Leg3.addBox(-1F, 0F, 0F, 2, 8, 1); - Leg3.setRotationPoint(-2F, 17F, 2F); - setRotation(Leg3, 0.3316126F, -0.7853982F, 0F); + Leg3 = new ModelRenderer(this, 0, 12); + Leg3.addBox(-1F, 0F, 0F, 2, 8, 1); + Leg3.setRotationPoint(-2F, 17F, 2F); + setRotation(Leg3, 0.3316126F, -0.7853982F, 0F); - Leg4 = new ModelRenderer(this, 0, 12); - Leg4.addBox(-1F, 0F, 0F, 2, 8, 1); - Leg4.setRotationPoint(-2F, 17F, -2F); - setRotation(Leg4, 0.3316126F, -2.356194F, 0F); + Leg4 = new ModelRenderer(this, 0, 12); + Leg4.addBox(-1F, 0F, 0F, 2, 8, 1); + Leg4.setRotationPoint(-2F, 17F, -2F); + setRotation(Leg4, 0.3316126F, -2.356194F, 0F); - Shape1 = new ModelRenderer(this, 0, 11); - Shape1.addBox(-3F, 0F, 0F, 6, 1, 1); - Shape1.setRotationPoint(2.4F, 19F, 0F); - setRotation(Shape1, 0F, 1.570796F, 0F); + Shape1 = new ModelRenderer(this, 0, 11); + Shape1.addBox(-3F, 0F, 0F, 6, 1, 1); + Shape1.setRotationPoint(2.4F, 19F, 0F); + setRotation(Shape1, 0F, 1.570796F, 0F); - Shape2 = new ModelRenderer(this, 0, 11); - Shape2.addBox(-3F, 0F, 0F, 6, 1, 1); - Shape2.setRotationPoint(0F, 19F, 2.4F); + Shape2 = new ModelRenderer(this, 0, 11); + Shape2.addBox(-3F, 0F, 0F, 6, 1, 1); + Shape2.setRotationPoint(0F, 19F, 2.4F); - Shape3 = new ModelRenderer(this, 0, 11); - Shape3.addBox(-3F, 0F, 0F, 6, 1, 1); - Shape3.setRotationPoint(0F, 19F, -3.4F); + Shape3 = new ModelRenderer(this, 0, 11); + Shape3.addBox(-3F, 0F, 0F, 6, 1, 1); + Shape3.setRotationPoint(0F, 19F, -3.4F); - Shape4 = new ModelRenderer(this, 0, 11); - Shape4.addBox(-3F, 0F, 0F, 6, 1, 1); - Shape4.setRotationPoint(-3.4F, 19F, 0F); - setRotation(Shape4, 0F, 1.570796F, 0F); - } + Shape4 = new ModelRenderer(this, 0, 11); + Shape4.addBox(-3F, 0F, 0F, 6, 1, 1); + Shape4.setRotationPoint(-3.4F, 19F, 0F); + setRotation(Shape4, 0F, 1.570796F, 0F); + } - public void render(Entity entity, float f, float f1, float f2, float f3, - float f4, float f5) { - super.render(entity, f, f1, f2, f3, f4, f5); - Base.render(f5); - Leg1.render(f5); - Leg2.render(f5); - Leg3.render(f5); - Leg4.render(f5); - Shape1.render(f5); - Shape2.render(f5); - Shape3.render(f5); - Shape4.render(f5); - } + public void render(Entity entity, float f, float f1, float f2, float f3, + float f4, float f5) { + super.render(entity, f, f1, f2, f3, f4, f5); + Base.render(f5); + Leg1.render(f5); + Leg2.render(f5); + Leg3.render(f5); + Leg4.render(f5); + Shape1.render(f5); + Shape2.render(f5); + Shape3.render(f5); + Shape4.render(f5); + } - private void setRotation(ModelRenderer model, float x, float y, float z) { - model.rotateAngleX = x; - model.rotateAngleY = y; - model.rotateAngleZ = z; - } + private void setRotation(ModelRenderer model, float x, float y, float z) { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } } diff --git a/src/main/java/noppes/npcs/client/model/blocks/legacy/ModelLegacyTable.java b/src/main/java/noppes/npcs/client/model/blocks/legacy/ModelLegacyTable.java index 2bd7aa165..dbc87ddc8 100644 --- a/src/main/java/noppes/npcs/client/model/blocks/legacy/ModelLegacyTable.java +++ b/src/main/java/noppes/npcs/client/model/blocks/legacy/ModelLegacyTable.java @@ -5,49 +5,49 @@ import net.minecraft.client.model.ModelRenderer; import net.minecraft.entity.Entity; public class ModelLegacyTable extends ModelBase { - public ModelRenderer Shape1; - public ModelRenderer Table; - public ModelRenderer Shape3; - public ModelRenderer Shape4; - public ModelRenderer Shape5; + public ModelRenderer Shape1; + public ModelRenderer Table; + public ModelRenderer Shape3; + public ModelRenderer Shape4; + public ModelRenderer Shape5; - public ModelLegacyTable() { - Shape1 = new ModelRenderer(this, 0, 0); - Shape1.mirror = true; - Shape1.addBox(-1F, 0F, -1F, 2, 14, 2); - Shape1.setRotationPoint(-6F, 10F, 6F); + public ModelLegacyTable() { + Shape1 = new ModelRenderer(this, 0, 0); + Shape1.mirror = true; + Shape1.addBox(-1F, 0F, -1F, 2, 14, 2); + Shape1.setRotationPoint(-6F, 10F, 6F); - Table = new ModelRenderer(this, 0, 0); - Table.addBox(0F, -2F, 0F, 16, 2, 16); - Table.setRotationPoint(-8F, 10F, -8F); + Table = new ModelRenderer(this, 0, 0); + Table.addBox(0F, -2F, 0F, 16, 2, 16); + Table.setRotationPoint(-8F, 10F, -8F); - Shape3 = new ModelRenderer(this, 0, 0); - Shape3.addBox(-1F, 0F, -1F, 2, 14, 2); - Shape3.setRotationPoint(6F, 10F, -6F); + Shape3 = new ModelRenderer(this, 0, 0); + Shape3.addBox(-1F, 0F, -1F, 2, 14, 2); + Shape3.setRotationPoint(6F, 10F, -6F); - Shape4 = new ModelRenderer(this, 0, 0); - Shape4.addBox(-1F, 0F, -1F, 2, 14, 2); - Shape4.setRotationPoint(6F, 10F, 6F); + Shape4 = new ModelRenderer(this, 0, 0); + Shape4.addBox(-1F, 0F, -1F, 2, 14, 2); + Shape4.setRotationPoint(6F, 10F, 6F); - Shape5 = new ModelRenderer(this, 0, 0); - Shape5.mirror = true; - Shape5.addBox(-1F, 0F, -1F, 2, 14, 2); - Shape5.setRotationPoint(-6F, 10F, -6F); - } + Shape5 = new ModelRenderer(this, 0, 0); + Shape5.mirror = true; + Shape5.addBox(-1F, 0F, -1F, 2, 14, 2); + Shape5.setRotationPoint(-6F, 10F, -6F); + } - public void render(Entity entity, float f, float f1, float f2, float f3, - float f4, float f5) { - super.render(entity, f, f1, f2, f3, f4, f5); - Shape1.render(f5); - Shape3.render(f5); - Shape4.render(f5); - Shape5.render(f5); - } + public void render(Entity entity, float f, float f1, float f2, float f3, + float f4, float f5) { + super.render(entity, f, f1, f2, f3, f4, f5); + Shape1.render(f5); + Shape3.render(f5); + Shape4.render(f5); + Shape5.render(f5); + } - private void setRotation(ModelRenderer model, float x, float y, float z) { - model.rotateAngleX = x; - model.rotateAngleY = y; - model.rotateAngleZ = z; - } + private void setRotation(ModelRenderer model, float x, float y, float z) { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } } diff --git a/src/main/java/noppes/npcs/client/model/blocks/legacy/ModelLegacyTallLamp.java b/src/main/java/noppes/npcs/client/model/blocks/legacy/ModelLegacyTallLamp.java index 3cbeb2977..e79ae72df 100644 --- a/src/main/java/noppes/npcs/client/model/blocks/legacy/ModelLegacyTallLamp.java +++ b/src/main/java/noppes/npcs/client/model/blocks/legacy/ModelLegacyTallLamp.java @@ -4,9 +4,8 @@ import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelRenderer; import net.minecraft.entity.Entity; -public class ModelLegacyTallLamp extends ModelBase -{ - //fields +public class ModelLegacyTallLamp extends ModelBase { + //fields ModelRenderer Base; ModelRenderer MiddleStick; ModelRenderer LampShadeStick1; @@ -14,53 +13,50 @@ public class ModelLegacyTallLamp extends ModelBase ModelRenderer LampShadeStick3; ModelRenderer LampShadeStick4; - public ModelLegacyTallLamp() - { - Base = new ModelRenderer(this, 6, 2); - Base.addBox(-6F, 0F, -6F, 12, 1, 12); - Base.setRotationPoint(0F, 23F, 0F); + public ModelLegacyTallLamp() { + Base = new ModelRenderer(this, 6, 2); + Base.addBox(-6F, 0F, -6F, 12, 1, 12); + Base.setRotationPoint(0F, 23F, 0F); - MiddleStick = new ModelRenderer(this, 12, 2); - MiddleStick.addBox(-1F, 0F, -1F, 2, 28, 2); - MiddleStick.setRotationPoint(0F, -5F, 0F); + MiddleStick = new ModelRenderer(this, 12, 2); + MiddleStick.addBox(-1F, 0F, -1F, 2, 28, 2); + MiddleStick.setRotationPoint(0F, -5F, 0F); - LampShadeStick1 = new ModelRenderer(this, 0, 30); - LampShadeStick1.addBox(0F, 0F, 0F, 5, 1, 1); - LampShadeStick1.setRotationPoint(1F, -1F, -0.5F); + LampShadeStick1 = new ModelRenderer(this, 0, 30); + LampShadeStick1.addBox(0F, 0F, 0F, 5, 1, 1); + LampShadeStick1.setRotationPoint(1F, -1F, -0.5F); - LampShadeStick2 = new ModelRenderer(this, 0, 30); - LampShadeStick2.addBox(0F, 0F, 0F, 5, 1, 1); - LampShadeStick2.setRotationPoint(-0.5F, -1F, -1F); - setRotation(LampShadeStick2, 0F, 1.570796F, 0F); + LampShadeStick2 = new ModelRenderer(this, 0, 30); + LampShadeStick2.addBox(0F, 0F, 0F, 5, 1, 1); + LampShadeStick2.setRotationPoint(-0.5F, -1F, -1F); + setRotation(LampShadeStick2, 0F, 1.570796F, 0F); - LampShadeStick3 = new ModelRenderer(this, 0, 30); - LampShadeStick3.addBox(0F, 0F, 0F, 5, 1, 1); - LampShadeStick3.setRotationPoint(-1F, -1F, 0.5F); - setRotation(LampShadeStick3, 0F, 3.141593F, 0F); + LampShadeStick3 = new ModelRenderer(this, 0, 30); + LampShadeStick3.addBox(0F, 0F, 0F, 5, 1, 1); + LampShadeStick3.setRotationPoint(-1F, -1F, 0.5F); + setRotation(LampShadeStick3, 0F, 3.141593F, 0F); - LampShadeStick4 = new ModelRenderer(this, 0, 30); - LampShadeStick4.addBox(0F, 0F, 0F, 5, 1, 1); - LampShadeStick4.setRotationPoint(0.5F, -1F, 1F); - setRotation(LampShadeStick4, 0F, -1.570796F, 0F); - } + LampShadeStick4 = new ModelRenderer(this, 0, 30); + LampShadeStick4.addBox(0F, 0F, 0F, 5, 1, 1); + LampShadeStick4.setRotationPoint(0.5F, -1F, 1F); + setRotation(LampShadeStick4, 0F, -1.570796F, 0F); + } - @Override - public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) - { - super.render(entity, f, f1, f2, f3, f4, f5); - Base.render(f5); - MiddleStick.render(f5); - LampShadeStick1.render(f5); - LampShadeStick2.render(f5); - LampShadeStick3.render(f5); - LampShadeStick4.render(f5); - } + @Override + public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) { + super.render(entity, f, f1, f2, f3, f4, f5); + Base.render(f5); + MiddleStick.render(f5); + LampShadeStick1.render(f5); + LampShadeStick2.render(f5); + LampShadeStick3.render(f5); + LampShadeStick4.render(f5); + } - private void setRotation(ModelRenderer model, float x, float y, float z) - { - model.rotateAngleX = x; - model.rotateAngleY = y; - model.rotateAngleZ = z; - } + private void setRotation(ModelRenderer model, float x, float y, float z) { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } } diff --git a/src/main/java/noppes/npcs/client/model/blocks/legacy/ModelLegacyTallLampTop.java b/src/main/java/noppes/npcs/client/model/blocks/legacy/ModelLegacyTallLampTop.java index f1c63db60..698f49ad6 100644 --- a/src/main/java/noppes/npcs/client/model/blocks/legacy/ModelLegacyTallLampTop.java +++ b/src/main/java/noppes/npcs/client/model/blocks/legacy/ModelLegacyTallLampTop.java @@ -4,47 +4,43 @@ import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelRenderer; import net.minecraft.entity.Entity; -public class ModelLegacyTallLampTop extends ModelBase -{ +public class ModelLegacyTallLampTop extends ModelBase { ModelRenderer LampShade1; ModelRenderer LampShade3; ModelRenderer LampShade2; ModelRenderer LampShade4; - public ModelLegacyTallLampTop() - { - LampShade1 = new ModelRenderer(this, 0, 0); - LampShade1.addBox(-.5F, -6F, -6F, 1, 12, 12); - LampShade1.setRotationPoint(6F, -1F, 0F); + public ModelLegacyTallLampTop() { + LampShade1 = new ModelRenderer(this, 0, 0); + LampShade1.addBox(-.5F, -6F, -6F, 1, 12, 12); + LampShade1.setRotationPoint(6F, -1F, 0F); - LampShade3 = new ModelRenderer(this, 0, 0); - LampShade3.addBox(-6F, -6F, -.5F, 12, 12, 1); - LampShade3.setRotationPoint(0F, -1F, -6F); + LampShade3 = new ModelRenderer(this, 0, 0); + LampShade3.addBox(-6F, -6F, -.5F, 12, 12, 1); + LampShade3.setRotationPoint(0F, -1F, -6F); - LampShade2 = new ModelRenderer(this, 0, 0); - LampShade2.addBox(-.5F, -6F, -6F, 1, 12, 12); - LampShade2.setRotationPoint(-6F, -1F, 0F); + LampShade2 = new ModelRenderer(this, 0, 0); + LampShade2.addBox(-.5F, -6F, -6F, 1, 12, 12); + LampShade2.setRotationPoint(-6F, -1F, 0F); - LampShade4 = new ModelRenderer(this, 0, 0); - LampShade4.addBox(-6F, -6F, -.5F, 12, 12, 1); - LampShade4.setRotationPoint(0F, -1F, 6F); - } + LampShade4 = new ModelRenderer(this, 0, 0); + LampShade4.addBox(-6F, -6F, -.5F, 12, 12, 1); + LampShade4.setRotationPoint(0F, -1F, 6F); + } - @Override - public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) - { - super.render(entity, f, f1, f2, f3, f4, f5); - LampShade1.render(f5); - LampShade3.render(f5); - LampShade2.render(f5); - LampShade4.render(f5); - } + @Override + public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) { + super.render(entity, f, f1, f2, f3, f4, f5); + LampShade1.render(f5); + LampShade3.render(f5); + LampShade2.render(f5); + LampShade4.render(f5); + } - private void setRotation(ModelRenderer model, float x, float y, float z) - { - model.rotateAngleX = x; - model.rotateAngleY = y; - model.rotateAngleZ = z; - } + private void setRotation(ModelRenderer model, float x, float y, float z) { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } } diff --git a/src/main/java/noppes/npcs/client/model/blocks/legacy/ModelLegacyWall.java b/src/main/java/noppes/npcs/client/model/blocks/legacy/ModelLegacyWall.java index 7d75b60b9..7f3bce3e5 100644 --- a/src/main/java/noppes/npcs/client/model/blocks/legacy/ModelLegacyWall.java +++ b/src/main/java/noppes/npcs/client/model/blocks/legacy/ModelLegacyWall.java @@ -5,69 +5,69 @@ import net.minecraft.client.model.ModelRenderer; import net.minecraft.entity.Entity; public class ModelLegacyWall extends ModelBase { - ModelRenderer Base; - ModelRenderer Top1; - ModelRenderer Top2; - ModelRenderer Top3; - ModelRenderer Shape2; - ModelRenderer Shape3; - ModelRenderer Shape4; - ModelRenderer Shape5; + ModelRenderer Base; + ModelRenderer Top1; + ModelRenderer Top2; + ModelRenderer Top3; + ModelRenderer Shape2; + ModelRenderer Shape3; + ModelRenderer Shape4; + ModelRenderer Shape5; - public ModelLegacyWall() { - Base = new ModelRenderer(this, 0, 6); - Base.addBox(0F, 0F, 0F, 4, 7, 4); - Base.setRotationPoint(-2F, 14F, 1F); + public ModelLegacyWall() { + Base = new ModelRenderer(this, 0, 6); + Base.addBox(0F, 0F, 0F, 4, 7, 4); + Base.setRotationPoint(-2F, 14F, 1F); - Top1 = new ModelRenderer(this, 0, 0); - Top1.addBox(0F, 0F, 0F, 5, 1, 5); - Top1.setRotationPoint(-2.5F, 14F, 0.5F); + Top1 = new ModelRenderer(this, 0, 0); + Top1.addBox(0F, 0F, 0F, 5, 1, 5); + Top1.setRotationPoint(-2.5F, 14F, 0.5F); - Top2 = new ModelRenderer(this, 0, 0); - Top2.addBox(0F, 0F, 0F, 4, 1, 4); - Top2.setRotationPoint(-2F, 13.5F, 1F); + Top2 = new ModelRenderer(this, 0, 0); + Top2.addBox(0F, 0F, 0F, 4, 1, 4); + Top2.setRotationPoint(-2F, 13.5F, 1F); - Top3 = new ModelRenderer(this, 0, 0); - Top3.addBox(0F, 0F, 0F, 3, 1, 3); - Top3.setRotationPoint(-1.5F, 13F, 1.5F); + Top3 = new ModelRenderer(this, 0, 0); + Top3.addBox(0F, 0F, 0F, 3, 1, 3); + Top3.setRotationPoint(-1.5F, 13F, 1.5F); - Shape2 = new ModelRenderer(this, 0, 0); - Shape2.addBox(0F, 0F, 0F, 1, 1, 3); - Shape2.setRotationPoint(-0.5F, 11F, 3.5F); + Shape2 = new ModelRenderer(this, 0, 0); + Shape2.addBox(0F, 0F, 0F, 1, 1, 3); + Shape2.setRotationPoint(-0.5F, 11F, 3.5F); - Shape3 = new ModelRenderer(this, 0, 0); - Shape3.addBox(0F, 0F, 0F, 3, 3, 1); - Shape3.setRotationPoint(0F, 9.5F, 6.5F); - setRotation(Shape3, 0F, 0F, 0.7853982F); + Shape3 = new ModelRenderer(this, 0, 0); + Shape3.addBox(0F, 0F, 0F, 3, 3, 1); + Shape3.setRotationPoint(0F, 9.5F, 6.5F); + setRotation(Shape3, 0F, 0F, 0.7853982F); - Shape4 = new ModelRenderer(this, 0, 0); - Shape4.addBox(0F, 0F, 0F, 1, 3, 1); - Shape4.setRotationPoint(-0.5F, 10.5F, 2.5F); + Shape4 = new ModelRenderer(this, 0, 0); + Shape4.addBox(0F, 0F, 0F, 1, 3, 1); + Shape4.setRotationPoint(-0.5F, 10.5F, 2.5F); - Shape5 = new ModelRenderer(this, 0, 0); - Shape5.addBox(0F, 0F, 0F, 4, 4, 1); - Shape5.setRotationPoint(0F, 8.7F, 7F); - setRotation(Shape5, 0F, 0F, 0.7853982F); - } + Shape5 = new ModelRenderer(this, 0, 0); + Shape5.addBox(0F, 0F, 0F, 4, 4, 1); + Shape5.setRotationPoint(0F, 8.7F, 7F); + setRotation(Shape5, 0F, 0F, 0.7853982F); + } - public void render(Entity entity, float f, float f1, float f2, float f3, - float f4, float f5) { - super.render(entity, f, f1, f2, f3, f4, f5); - Base.render(f5); - Top1.render(f5); - Top2.render(f5); - Top3.render(f5); - Shape2.render(f5); - Shape3.render(f5); - Shape4.render(f5); - Shape5.render(f5); - } + public void render(Entity entity, float f, float f1, float f2, float f3, + float f4, float f5) { + super.render(entity, f, f1, f2, f3, f4, f5); + Base.render(f5); + Top1.render(f5); + Top2.render(f5); + Top3.render(f5); + Shape2.render(f5); + Shape3.render(f5); + Shape4.render(f5); + Shape5.render(f5); + } - private void setRotation(ModelRenderer model, float x, float y, float z) { - model.rotateAngleX = x; - model.rotateAngleY = y; - model.rotateAngleZ = z; - } + private void setRotation(ModelRenderer model, float x, float y, float z) { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } } diff --git a/src/main/java/noppes/npcs/client/model/blocks/legacy/ModelLegacyWallBanner.java b/src/main/java/noppes/npcs/client/model/blocks/legacy/ModelLegacyWallBanner.java index 8c3a6dd8a..712c729f9 100644 --- a/src/main/java/noppes/npcs/client/model/blocks/legacy/ModelLegacyWallBanner.java +++ b/src/main/java/noppes/npcs/client/model/blocks/legacy/ModelLegacyWallBanner.java @@ -5,50 +5,50 @@ import net.minecraft.client.model.ModelRenderer; import net.minecraft.entity.Entity; public class ModelLegacyWallBanner extends ModelBase { - // fields - ModelRenderer MiddleStick; - ModelRenderer StickDecoration; - ModelRenderer TopDecoration; - ModelRenderer FlagPole1; - ModelRenderer FlagPole2; + // fields + ModelRenderer MiddleStick; + ModelRenderer StickDecoration; + ModelRenderer TopDecoration; + ModelRenderer FlagPole1; + ModelRenderer FlagPole2; - public ModelLegacyWallBanner() { + public ModelLegacyWallBanner() { - MiddleStick = new ModelRenderer(this, 56, 0); - MiddleStick.addBox(-1F, 0F, -1F, 2, 3, 2); - MiddleStick.setRotationPoint(0F, -9F, 6.5F); + MiddleStick = new ModelRenderer(this, 56, 0); + MiddleStick.addBox(-1F, 0F, -1F, 2, 3, 2); + MiddleStick.setRotationPoint(0F, -9F, 6.5F); - StickDecoration = new ModelRenderer(this, 11, 12); - StickDecoration.addBox(0F, 0F, 0F, 16, 3, 3); - StickDecoration.setRotationPoint(-8F, -7.5F, 5F); + StickDecoration = new ModelRenderer(this, 11, 12); + StickDecoration.addBox(0F, 0F, 0F, 16, 3, 3); + StickDecoration.setRotationPoint(-8F, -7.5F, 5F); - TopDecoration = new ModelRenderer(this, 45, 19); - TopDecoration.addBox(0F, 0F, 0F, 1, 1, 1); - TopDecoration.setRotationPoint(-0.5F, -10F, 6F); + TopDecoration = new ModelRenderer(this, 45, 19); + TopDecoration.addBox(0F, 0F, 0F, 1, 1, 1); + TopDecoration.setRotationPoint(-0.5F, -10F, 6F); - FlagPole1 = new ModelRenderer(this, 45, 19); - FlagPole1.addBox(0F, 0F, 0F, 1, 1, 1); - FlagPole1.setRotationPoint(-7F, -6.5F, 4F); + FlagPole1 = new ModelRenderer(this, 45, 19); + FlagPole1.addBox(0F, 0F, 0F, 1, 1, 1); + FlagPole1.setRotationPoint(-7F, -6.5F, 4F); - FlagPole2 = new ModelRenderer(this, 45, 19); - FlagPole2.addBox(0F, 0F, 0F, 1, 1, 1); - FlagPole2.setRotationPoint(6F, -6.5F, 4F); - } + FlagPole2 = new ModelRenderer(this, 45, 19); + FlagPole2.addBox(0F, 0F, 0F, 1, 1, 1); + FlagPole2.setRotationPoint(6F, -6.5F, 4F); + } - public void render(Entity entity, float f, float f1, float f2, float f3, - float f4, float f5) { - super.render(entity, f, f1, f2, f3, f4, f5); - MiddleStick.render(f5); - StickDecoration.render(f5); - TopDecoration.render(f5); - FlagPole1.render(f5); - FlagPole2.render(f5); - } + public void render(Entity entity, float f, float f1, float f2, float f3, + float f4, float f5) { + super.render(entity, f, f1, f2, f3, f4, f5); + MiddleStick.render(f5); + StickDecoration.render(f5); + TopDecoration.render(f5); + FlagPole1.render(f5); + FlagPole2.render(f5); + } - private void setRotation(ModelRenderer model, float x, float y, float z) { - model.rotateAngleX = x; - model.rotateAngleY = y; - model.rotateAngleZ = z; - } + private void setRotation(ModelRenderer model, float x, float y, float z) { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } } diff --git a/src/main/java/noppes/npcs/client/model/blocks/legacy/ModelLegacyWallBannerFlag.java b/src/main/java/noppes/npcs/client/model/blocks/legacy/ModelLegacyWallBannerFlag.java index 17e152f3a..f35e7e06e 100644 --- a/src/main/java/noppes/npcs/client/model/blocks/legacy/ModelLegacyWallBannerFlag.java +++ b/src/main/java/noppes/npcs/client/model/blocks/legacy/ModelLegacyWallBannerFlag.java @@ -5,21 +5,21 @@ import net.minecraft.client.model.ModelRenderer; import net.minecraft.entity.Entity; public class ModelLegacyWallBannerFlag extends ModelBase { - ModelRenderer Flag; + ModelRenderer Flag; - public ModelLegacyWallBannerFlag() { - textureWidth = 32; - textureHeight = 32; - Flag = new ModelRenderer(this, 0, 0); - Flag.addBox(0F, 0F, 0F, 15, 27, 0); - Flag.setRotationPoint(-7.5F, -7F, 4.5F); - Flag.setTextureSize(32, 32); - } + public ModelLegacyWallBannerFlag() { + textureWidth = 32; + textureHeight = 32; + Flag = new ModelRenderer(this, 0, 0); + Flag.addBox(0F, 0F, 0F, 15, 27, 0); + Flag.setRotationPoint(-7.5F, -7F, 4.5F); + Flag.setTextureSize(32, 32); + } - public void render(Entity entity, float f, float f1, float f2, float f3, - float f4, float f5) { - super.render(entity, f, f1, f2, f3, f4, f5); - Flag.render(f5); - } + public void render(Entity entity, float f, float f1, float f2, float f3, + float f4, float f5) { + super.render(entity, f, f1, f2, f3, f4, f5); + Flag.render(f5); + } } diff --git a/src/main/java/noppes/npcs/client/model/blocks/legacy/couch/ModelCouchWoodLeft.java b/src/main/java/noppes/npcs/client/model/blocks/legacy/couch/ModelCouchWoodLeft.java index 5d889b3b3..ceb80ddff 100644 --- a/src/main/java/noppes/npcs/client/model/blocks/legacy/couch/ModelCouchWoodLeft.java +++ b/src/main/java/noppes/npcs/client/model/blocks/legacy/couch/ModelCouchWoodLeft.java @@ -5,134 +5,134 @@ import net.minecraft.client.model.ModelRenderer; import net.minecraft.entity.Entity; public class ModelCouchWoodLeft extends ModelBase { - ModelRenderer Shape1; - ModelRenderer Shape2; - ModelRenderer Shape3; - ModelRenderer Shape4; - ModelRenderer Shape5; - ModelRenderer Shape6; - ModelRenderer Shape7; - ModelRenderer Shape8; - ModelRenderer Shape9; - ModelRenderer Shape10; - ModelRenderer Shape11; - ModelRenderer Shape12; - ModelRenderer Shape13; - ModelRenderer Shape14; - ModelRenderer Shape15; - ModelRenderer Shape16; - ModelRenderer Shape17; - ModelRenderer Shape18; + ModelRenderer Shape1; + ModelRenderer Shape2; + ModelRenderer Shape3; + ModelRenderer Shape4; + ModelRenderer Shape5; + ModelRenderer Shape6; + ModelRenderer Shape7; + ModelRenderer Shape8; + ModelRenderer Shape9; + ModelRenderer Shape10; + ModelRenderer Shape11; + ModelRenderer Shape12; + ModelRenderer Shape13; + ModelRenderer Shape14; + ModelRenderer Shape15; + ModelRenderer Shape16; + ModelRenderer Shape17; + ModelRenderer Shape18; - public ModelCouchWoodLeft() { - Shape1 = new ModelRenderer(this, 0, 0); - Shape1.mirror = true; - Shape1.addBox(0F, 0F, 0F, 2, 3, 10); - Shape1.setRotationPoint(-8F, 18F, -4F); + public ModelCouchWoodLeft() { + Shape1 = new ModelRenderer(this, 0, 0); + Shape1.mirror = true; + Shape1.addBox(0F, 0F, 0F, 2, 3, 10); + Shape1.setRotationPoint(-8F, 18F, -4F); - Shape2 = new ModelRenderer(this, 0, 0); - Shape2.addBox(0F, 0F, 0F, 1, 3, 2); - Shape2.setRotationPoint(7F, 21F, -6F); + Shape2 = new ModelRenderer(this, 0, 0); + Shape2.addBox(0F, 0F, 0F, 1, 3, 2); + Shape2.setRotationPoint(7F, 21F, -6F); - Shape3 = new ModelRenderer(this, 0, 0); - Shape3.mirror = true; - Shape3.addBox(0F, 0F, 0F, 2, 4, 1); - Shape3.setRotationPoint(-8F, 14F, 0.5F); + Shape3 = new ModelRenderer(this, 0, 0); + Shape3.mirror = true; + Shape3.addBox(0F, 0F, 0F, 2, 4, 1); + Shape3.setRotationPoint(-8F, 14F, 0.5F); - Shape4 = new ModelRenderer(this, 0, 0); - Shape4.mirror = true; - Shape4.addBox(0F, 0F, 0F, 14, 2, 1); - Shape4.setRotationPoint(-6F, 7F, 7F); + Shape4 = new ModelRenderer(this, 0, 0); + Shape4.mirror = true; + Shape4.addBox(0F, 0F, 0F, 14, 2, 1); + Shape4.setRotationPoint(-6F, 7F, 7F); - Shape5 = new ModelRenderer(this, 0, 0); - Shape5.mirror = true; - Shape5.addBox(0F, 0F, 0F, 14, 2, 2); - Shape5.setRotationPoint(-6F, 19F, 6F); + Shape5 = new ModelRenderer(this, 0, 0); + Shape5.mirror = true; + Shape5.addBox(0F, 0F, 0F, 14, 2, 2); + Shape5.setRotationPoint(-6F, 19F, 6F); - Shape6 = new ModelRenderer(this, 0, 0); - Shape6.mirror = true; - Shape6.addBox(0F, 0F, 0F, 2, 1, 13); - Shape6.setRotationPoint(-8F, 13F, -7F); + Shape6 = new ModelRenderer(this, 0, 0); + Shape6.mirror = true; + Shape6.addBox(0F, 0F, 0F, 2, 1, 13); + Shape6.setRotationPoint(-8F, 13F, -7F); - Shape7 = new ModelRenderer(this, 0, 0); - Shape7.addBox(0F, 0F, 0F, 1, 1, 10); - Shape7.setRotationPoint(-6F, 19F, -4F); + Shape7 = new ModelRenderer(this, 0, 0); + Shape7.addBox(0F, 0F, 0F, 1, 1, 10); + Shape7.setRotationPoint(-6F, 19F, -4F); - Shape8 = new ModelRenderer(this, 0, 0); - Shape8.addBox(0F, 0F, 0F, 1, 3, 2); - Shape8.setRotationPoint(7F, 21F, 6F); + Shape8 = new ModelRenderer(this, 0, 0); + Shape8.addBox(0F, 0F, 0F, 1, 3, 2); + Shape8.setRotationPoint(7F, 21F, 6F); - Shape9 = new ModelRenderer(this, 0, 0); - Shape9.addBox(0F, 0F, 0F, 2, 1, 10); - Shape9.setRotationPoint(5F, 19F, -4F); + Shape9 = new ModelRenderer(this, 0, 0); + Shape9.addBox(0F, 0F, 0F, 2, 1, 10); + Shape9.setRotationPoint(5F, 19F, -4F); - Shape10 = new ModelRenderer(this, 0, 0); - Shape10.addBox(0F, 0F, 0F, 1, 10, 1); - Shape10.setRotationPoint(-6F, 9F, 7F); + Shape10 = new ModelRenderer(this, 0, 0); + Shape10.addBox(0F, 0F, 0F, 1, 10, 1); + Shape10.setRotationPoint(-6F, 9F, 7F); - Shape11 = new ModelRenderer(this, 0, 0); - Shape11.mirror = true; - Shape11.addBox(0F, 0F, 0F, 14, 2, 2); - Shape11.setRotationPoint(-6F, 19F, -6F); + Shape11 = new ModelRenderer(this, 0, 0); + Shape11.mirror = true; + Shape11.addBox(0F, 0F, 0F, 14, 2, 2); + Shape11.setRotationPoint(-6F, 19F, -6F); - Shape12 = new ModelRenderer(this, 0, 0); - Shape12.addBox(0F, 0F, 0F, 2, 1, 10); - Shape12.setRotationPoint(-3F, 19F, -4F); + Shape12 = new ModelRenderer(this, 0, 0); + Shape12.addBox(0F, 0F, 0F, 2, 1, 10); + Shape12.setRotationPoint(-3F, 19F, -4F); - Shape13 = new ModelRenderer(this, 0, 0); - Shape13.addBox(0F, 0F, 0F, 2, 1, 10); - Shape13.setRotationPoint(1F, 19F, -4F); + Shape13 = new ModelRenderer(this, 0, 0); + Shape13.addBox(0F, 0F, 0F, 2, 1, 10); + Shape13.setRotationPoint(1F, 19F, -4F); - Shape14 = new ModelRenderer(this, 0, 0); - Shape14.addBox(0F, 0F, 0F, 2, 10, 1); - Shape14.setRotationPoint(-3F, 9F, 7F); + Shape14 = new ModelRenderer(this, 0, 0); + Shape14.addBox(0F, 0F, 0F, 2, 10, 1); + Shape14.setRotationPoint(-3F, 9F, 7F); - Shape15 = new ModelRenderer(this, 0, 0); - Shape15.addBox(0F, 0F, 0F, 2, 10, 1); - Shape15.setRotationPoint(1F, 9F, 7F); + Shape15 = new ModelRenderer(this, 0, 0); + Shape15.addBox(0F, 0F, 0F, 2, 10, 1); + Shape15.setRotationPoint(1F, 9F, 7F); - Shape16 = new ModelRenderer(this, 0, 0); - Shape16.addBox(0F, 0F, 0F, 2, 10, 1); - Shape16.setRotationPoint(5F, 9F, 7F); + Shape16 = new ModelRenderer(this, 0, 0); + Shape16.addBox(0F, 0F, 0F, 2, 10, 1); + Shape16.setRotationPoint(5F, 9F, 7F); - Shape17 = new ModelRenderer(this, 0, 0); - Shape17.mirror = true; - Shape17.addBox(0F, 0F, 0F, 2, 10, 2); - Shape17.setRotationPoint(-8F, 14F, -6F); + Shape17 = new ModelRenderer(this, 0, 0); + Shape17.mirror = true; + Shape17.addBox(0F, 0F, 0F, 2, 10, 2); + Shape17.setRotationPoint(-8F, 14F, -6F); - Shape18 = new ModelRenderer(this, 0, 0); - Shape18.mirror = true; - Shape18.addBox(0F, 0F, 0F, 2, 18, 2); - Shape18.setRotationPoint(-8F, 6F, 6F); - } + Shape18 = new ModelRenderer(this, 0, 0); + Shape18.mirror = true; + Shape18.addBox(0F, 0F, 0F, 2, 18, 2); + Shape18.setRotationPoint(-8F, 6F, 6F); + } - public void render(Entity entity, float f, float f1, float f2, float f3, - float f4, float f5) { - super.render(entity, f, f1, f2, f3, f4, f5); - Shape1.render(f5); - Shape2.render(f5); - Shape3.render(f5); - Shape4.render(f5); - Shape5.render(f5); - Shape6.render(f5); - Shape7.render(f5); - Shape8.render(f5); - Shape9.render(f5); - Shape10.render(f5); - Shape11.render(f5); - Shape12.render(f5); - Shape13.render(f5); - Shape14.render(f5); - Shape15.render(f5); - Shape16.render(f5); - Shape17.render(f5); - Shape18.render(f5); - } + public void render(Entity entity, float f, float f1, float f2, float f3, + float f4, float f5) { + super.render(entity, f, f1, f2, f3, f4, f5); + Shape1.render(f5); + Shape2.render(f5); + Shape3.render(f5); + Shape4.render(f5); + Shape5.render(f5); + Shape6.render(f5); + Shape7.render(f5); + Shape8.render(f5); + Shape9.render(f5); + Shape10.render(f5); + Shape11.render(f5); + Shape12.render(f5); + Shape13.render(f5); + Shape14.render(f5); + Shape15.render(f5); + Shape16.render(f5); + Shape17.render(f5); + Shape18.render(f5); + } - private void setRotation(ModelRenderer model, float x, float y, float z) { - model.rotateAngleX = x; - model.rotateAngleY = y; - model.rotateAngleZ = z; - } + private void setRotation(ModelRenderer model, float x, float y, float z) { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } } diff --git a/src/main/java/noppes/npcs/client/model/blocks/legacy/couch/ModelCouchWoodMiddle.java b/src/main/java/noppes/npcs/client/model/blocks/legacy/couch/ModelCouchWoodMiddle.java index f59932b83..aaa5e4165 100644 --- a/src/main/java/noppes/npcs/client/model/blocks/legacy/couch/ModelCouchWoodMiddle.java +++ b/src/main/java/noppes/npcs/client/model/blocks/legacy/couch/ModelCouchWoodMiddle.java @@ -5,109 +5,109 @@ import net.minecraft.client.model.ModelRenderer; import net.minecraft.entity.Entity; public class ModelCouchWoodMiddle extends ModelBase { - // fields - ModelRenderer Shape2; - ModelRenderer Shape4; - ModelRenderer Shape5; - ModelRenderer Shape7; - ModelRenderer Shape8; - ModelRenderer Shape9; - ModelRenderer Shape10; - ModelRenderer Shape11; - ModelRenderer Shape12; - ModelRenderer Shape13; - ModelRenderer Shape14; - ModelRenderer Shape15; - ModelRenderer Shape16; - ModelRenderer Shape17; - ModelRenderer Shape19; + // fields + ModelRenderer Shape2; + ModelRenderer Shape4; + ModelRenderer Shape5; + ModelRenderer Shape7; + ModelRenderer Shape8; + ModelRenderer Shape9; + ModelRenderer Shape10; + ModelRenderer Shape11; + ModelRenderer Shape12; + ModelRenderer Shape13; + ModelRenderer Shape14; + ModelRenderer Shape15; + ModelRenderer Shape16; + ModelRenderer Shape17; + ModelRenderer Shape19; - public ModelCouchWoodMiddle() { - Shape2 = new ModelRenderer(this, 0, 0); - Shape2.addBox(0F, 0F, 0F, 1, 3, 2); - Shape2.setRotationPoint(-8F, 21F, -6F); + public ModelCouchWoodMiddle() { + Shape2 = new ModelRenderer(this, 0, 0); + Shape2.addBox(0F, 0F, 0F, 1, 3, 2); + Shape2.setRotationPoint(-8F, 21F, -6F); - Shape4 = new ModelRenderer(this, 0, 0); - Shape4.addBox(0F, 0F, 0F, 16, 2, 1); - Shape4.setRotationPoint(-8F, 7F, 7F); + Shape4 = new ModelRenderer(this, 0, 0); + Shape4.addBox(0F, 0F, 0F, 16, 2, 1); + Shape4.setRotationPoint(-8F, 7F, 7F); - Shape5 = new ModelRenderer(this, 0, 0); - Shape5.addBox(0F, 0F, 0F, 16, 2, 2); - Shape5.setRotationPoint(-8F, 19F, 6F); + Shape5 = new ModelRenderer(this, 0, 0); + Shape5.addBox(0F, 0F, 0F, 16, 2, 2); + Shape5.setRotationPoint(-8F, 19F, 6F); - Shape7 = new ModelRenderer(this, 0, 0); - Shape7.addBox(0F, 0F, 0F, 2, 1, 10); - Shape7.setRotationPoint(-7F, 19F, -4F); + Shape7 = new ModelRenderer(this, 0, 0); + Shape7.addBox(0F, 0F, 0F, 2, 1, 10); + Shape7.setRotationPoint(-7F, 19F, -4F); - Shape8 = new ModelRenderer(this, 0, 0); - Shape8.addBox(0F, 0F, 0F, 1, 3, 2); - Shape8.setRotationPoint(-8F, 21F, 6F); + Shape8 = new ModelRenderer(this, 0, 0); + Shape8.addBox(0F, 0F, 0F, 1, 3, 2); + Shape8.setRotationPoint(-8F, 21F, 6F); - Shape9 = new ModelRenderer(this, 0, 0); - Shape9.addBox(0F, 0F, 0F, 2, 1, 10); - Shape9.setRotationPoint(5F, 19F, -4F); + Shape9 = new ModelRenderer(this, 0, 0); + Shape9.addBox(0F, 0F, 0F, 2, 1, 10); + Shape9.setRotationPoint(5F, 19F, -4F); - Shape10 = new ModelRenderer(this, 0, 0); - Shape10.addBox(0F, 0F, 0F, 2, 10, 1); - Shape10.setRotationPoint(-7F, 9F, 7F); + Shape10 = new ModelRenderer(this, 0, 0); + Shape10.addBox(0F, 0F, 0F, 2, 10, 1); + Shape10.setRotationPoint(-7F, 9F, 7F); - Shape11 = new ModelRenderer(this, 0, 0); - Shape11.addBox(0F, 0F, 0F, 16, 2, 2); - Shape11.setRotationPoint(-8F, 19F, -6F); + Shape11 = new ModelRenderer(this, 0, 0); + Shape11.addBox(0F, 0F, 0F, 16, 2, 2); + Shape11.setRotationPoint(-8F, 19F, -6F); - Shape12 = new ModelRenderer(this, 0, 0); - Shape12.addBox(0F, 0F, 0F, 2, 1, 10); - Shape12.setRotationPoint(-3F, 19F, -4F); + Shape12 = new ModelRenderer(this, 0, 0); + Shape12.addBox(0F, 0F, 0F, 2, 1, 10); + Shape12.setRotationPoint(-3F, 19F, -4F); - Shape13 = new ModelRenderer(this, 0, 0); - Shape13.addBox(0F, 0F, 0F, 2, 1, 10); - Shape13.setRotationPoint(1F, 19F, -4F); + Shape13 = new ModelRenderer(this, 0, 0); + Shape13.addBox(0F, 0F, 0F, 2, 1, 10); + Shape13.setRotationPoint(1F, 19F, -4F); - Shape14 = new ModelRenderer(this, 0, 0); - Shape14.addBox(0F, 0F, 0F, 2, 10, 1); - Shape14.setRotationPoint(-3F, 9F, 7F); + Shape14 = new ModelRenderer(this, 0, 0); + Shape14.addBox(0F, 0F, 0F, 2, 10, 1); + Shape14.setRotationPoint(-3F, 9F, 7F); - Shape15 = new ModelRenderer(this, 0, 0); - Shape15.addBox(0F, 0F, 0F, 2, 10, 1); - Shape15.setRotationPoint(1F, 9F, 7F); + Shape15 = new ModelRenderer(this, 0, 0); + Shape15.addBox(0F, 0F, 0F, 2, 10, 1); + Shape15.setRotationPoint(1F, 9F, 7F); - Shape16 = new ModelRenderer(this, 0, 0); - Shape16.addBox(0F, 0F, 0F, 2, 10, 1); - Shape16.setRotationPoint(5F, 9F, 7F); + Shape16 = new ModelRenderer(this, 0, 0); + Shape16.addBox(0F, 0F, 0F, 2, 10, 1); + Shape16.setRotationPoint(5F, 9F, 7F); - Shape17 = new ModelRenderer(this, 0, 0); - Shape17.addBox(0F, 0F, 0F, 1, 3, 2); - Shape17.setRotationPoint(7F, 21F, 6F); + Shape17 = new ModelRenderer(this, 0, 0); + Shape17.addBox(0F, 0F, 0F, 1, 3, 2); + Shape17.setRotationPoint(7F, 21F, 6F); - Shape19 = new ModelRenderer(this, 0, 0); - Shape19.addBox(0F, 0F, 0F, 1, 3, 2); - Shape19.setRotationPoint(7F, 21F, -6F); - } + Shape19 = new ModelRenderer(this, 0, 0); + Shape19.addBox(0F, 0F, 0F, 1, 3, 2); + Shape19.setRotationPoint(7F, 21F, -6F); + } - public void render(Entity entity, float f, float f1, float f2, float f3, - float f4, float f5) { - super.render(entity, f, f1, f2, f3, f4, f5); - Shape2.render(f5); - Shape4.render(f5); - Shape5.render(f5); - Shape7.render(f5); - Shape8.render(f5); - Shape9.render(f5); - Shape10.render(f5); - Shape11.render(f5); - Shape12.render(f5); - Shape13.render(f5); - Shape14.render(f5); - Shape15.render(f5); - Shape16.render(f5); - Shape17.render(f5); - Shape19.render(f5); - } + public void render(Entity entity, float f, float f1, float f2, float f3, + float f4, float f5) { + super.render(entity, f, f1, f2, f3, f4, f5); + Shape2.render(f5); + Shape4.render(f5); + Shape5.render(f5); + Shape7.render(f5); + Shape8.render(f5); + Shape9.render(f5); + Shape10.render(f5); + Shape11.render(f5); + Shape12.render(f5); + Shape13.render(f5); + Shape14.render(f5); + Shape15.render(f5); + Shape16.render(f5); + Shape17.render(f5); + Shape19.render(f5); + } - private void setRotation(ModelRenderer model, float x, float y, float z) { - model.rotateAngleX = x; - model.rotateAngleY = y; - model.rotateAngleZ = z; - } + private void setRotation(ModelRenderer model, float x, float y, float z) { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } } diff --git a/src/main/java/noppes/npcs/client/model/blocks/legacy/couch/ModelCouchWoodRight.java b/src/main/java/noppes/npcs/client/model/blocks/legacy/couch/ModelCouchWoodRight.java index 951af09c2..2c4245eeb 100644 --- a/src/main/java/noppes/npcs/client/model/blocks/legacy/couch/ModelCouchWoodRight.java +++ b/src/main/java/noppes/npcs/client/model/blocks/legacy/couch/ModelCouchWoodRight.java @@ -5,127 +5,127 @@ import net.minecraft.client.model.ModelRenderer; import net.minecraft.entity.Entity; public class ModelCouchWoodRight extends ModelBase { - // fields - ModelRenderer Shape1; - ModelRenderer Shape2; - ModelRenderer Shape3; - ModelRenderer Shape4; - ModelRenderer Shape5; - ModelRenderer Shape6; - ModelRenderer Shape7; - ModelRenderer Shape8; - ModelRenderer Shape9; - ModelRenderer Shape10; - ModelRenderer Shape11; - ModelRenderer Shape12; - ModelRenderer Shape13; - ModelRenderer Shape14; - ModelRenderer Shape15; - ModelRenderer Shape16; - ModelRenderer Shape17; - ModelRenderer Shape18; + // fields + ModelRenderer Shape1; + ModelRenderer Shape2; + ModelRenderer Shape3; + ModelRenderer Shape4; + ModelRenderer Shape5; + ModelRenderer Shape6; + ModelRenderer Shape7; + ModelRenderer Shape8; + ModelRenderer Shape9; + ModelRenderer Shape10; + ModelRenderer Shape11; + ModelRenderer Shape12; + ModelRenderer Shape13; + ModelRenderer Shape14; + ModelRenderer Shape15; + ModelRenderer Shape16; + ModelRenderer Shape17; + ModelRenderer Shape18; - public ModelCouchWoodRight() { - Shape1 = new ModelRenderer(this, 0, 0); - Shape1.addBox(0F, 0F, 0F, 2, 3, 10); - Shape1.setRotationPoint(6F, 18F, -4F); + public ModelCouchWoodRight() { + Shape1 = new ModelRenderer(this, 0, 0); + Shape1.addBox(0F, 0F, 0F, 2, 3, 10); + Shape1.setRotationPoint(6F, 18F, -4F); - Shape2 = new ModelRenderer(this, 0, 0); - Shape2.addBox(0F, 0F, 0F, 1, 3, 2); - Shape2.setRotationPoint(-8F, 21F, -6F); + Shape2 = new ModelRenderer(this, 0, 0); + Shape2.addBox(0F, 0F, 0F, 1, 3, 2); + Shape2.setRotationPoint(-8F, 21F, -6F); - Shape3 = new ModelRenderer(this, 0, 0); - Shape3.addBox(0F, 0F, 0F, 2, 4, 1); - Shape3.setRotationPoint(6F, 14F, 0.5F); + Shape3 = new ModelRenderer(this, 0, 0); + Shape3.addBox(0F, 0F, 0F, 2, 4, 1); + Shape3.setRotationPoint(6F, 14F, 0.5F); - Shape4 = new ModelRenderer(this, 0, 0); - Shape4.addBox(0F, 0F, 0F, 14, 2, 1); - Shape4.setRotationPoint(-8F, 7F, 7F); + Shape4 = new ModelRenderer(this, 0, 0); + Shape4.addBox(0F, 0F, 0F, 14, 2, 1); + Shape4.setRotationPoint(-8F, 7F, 7F); - Shape5 = new ModelRenderer(this, 0, 0); - Shape5.addBox(0F, 0F, 0F, 14, 2, 2); - Shape5.setRotationPoint(-8F, 19F, 6F); + Shape5 = new ModelRenderer(this, 0, 0); + Shape5.addBox(0F, 0F, 0F, 14, 2, 2); + Shape5.setRotationPoint(-8F, 19F, 6F); - Shape6 = new ModelRenderer(this, 0, 0); - Shape6.addBox(0F, 0F, 0F, 2, 1, 13); - Shape6.setRotationPoint(6F, 13F, -7F); + Shape6 = new ModelRenderer(this, 0, 0); + Shape6.addBox(0F, 0F, 0F, 2, 1, 13); + Shape6.setRotationPoint(6F, 13F, -7F); - Shape7 = new ModelRenderer(this, 0, 0); - Shape7.addBox(0F, 0F, 0F, 2, 1, 10); - Shape7.setRotationPoint(-7F, 19F, -4F); + Shape7 = new ModelRenderer(this, 0, 0); + Shape7.addBox(0F, 0F, 0F, 2, 1, 10); + Shape7.setRotationPoint(-7F, 19F, -4F); - Shape8 = new ModelRenderer(this, 0, 0); - Shape8.addBox(0F, 0F, 0F, 1, 3, 2); - Shape8.setRotationPoint(-8F, 21F, 6F); + Shape8 = new ModelRenderer(this, 0, 0); + Shape8.addBox(0F, 0F, 0F, 1, 3, 2); + Shape8.setRotationPoint(-8F, 21F, 6F); - Shape9 = new ModelRenderer(this, 0, 0); - Shape9.addBox(0F, 0F, 0F, 1, 1, 10); - Shape9.setRotationPoint(5F, 19F, -4F); + Shape9 = new ModelRenderer(this, 0, 0); + Shape9.addBox(0F, 0F, 0F, 1, 1, 10); + Shape9.setRotationPoint(5F, 19F, -4F); - Shape10 = new ModelRenderer(this, 0, 0); - Shape10.addBox(0F, 0F, 0F, 2, 10, 1); - Shape10.setRotationPoint(-7F, 9F, 7F); + Shape10 = new ModelRenderer(this, 0, 0); + Shape10.addBox(0F, 0F, 0F, 2, 10, 1); + Shape10.setRotationPoint(-7F, 9F, 7F); - Shape11 = new ModelRenderer(this, 0, 0); - Shape11.addBox(0F, 0F, 0F, 14, 2, 2); - Shape11.setRotationPoint(-8F, 19F, -6F); + Shape11 = new ModelRenderer(this, 0, 0); + Shape11.addBox(0F, 0F, 0F, 14, 2, 2); + Shape11.setRotationPoint(-8F, 19F, -6F); - Shape12 = new ModelRenderer(this, 0, 0); - Shape12.addBox(0F, 0F, 0F, 2, 1, 10); - Shape12.setRotationPoint(-3F, 19F, -4F); + Shape12 = new ModelRenderer(this, 0, 0); + Shape12.addBox(0F, 0F, 0F, 2, 1, 10); + Shape12.setRotationPoint(-3F, 19F, -4F); - Shape13 = new ModelRenderer(this, 0, 0); - Shape13.addBox(0F, 0F, 0F, 2, 1, 10); - Shape13.setRotationPoint(1F, 19F, -4F); + Shape13 = new ModelRenderer(this, 0, 0); + Shape13.addBox(0F, 0F, 0F, 2, 1, 10); + Shape13.setRotationPoint(1F, 19F, -4F); - Shape14 = new ModelRenderer(this, 0, 0); - Shape14.addBox(0F, 0F, 0F, 2, 10, 1); - Shape14.setRotationPoint(-3F, 9F, 7F); + Shape14 = new ModelRenderer(this, 0, 0); + Shape14.addBox(0F, 0F, 0F, 2, 10, 1); + Shape14.setRotationPoint(-3F, 9F, 7F); - Shape15 = new ModelRenderer(this, 0, 0); - Shape15.addBox(0F, 0F, 0F, 2, 10, 1); - Shape15.setRotationPoint(1F, 9F, 7F); + Shape15 = new ModelRenderer(this, 0, 0); + Shape15.addBox(0F, 0F, 0F, 2, 10, 1); + Shape15.setRotationPoint(1F, 9F, 7F); - Shape16 = new ModelRenderer(this, 0, 0); - Shape16.addBox(0F, 0F, 0F, 1, 10, 1); - Shape16.setRotationPoint(5F, 9F, 7F); + Shape16 = new ModelRenderer(this, 0, 0); + Shape16.addBox(0F, 0F, 0F, 1, 10, 1); + Shape16.setRotationPoint(5F, 9F, 7F); - Shape17 = new ModelRenderer(this, 0, 0); - Shape17.addBox(0F, 0F, 0F, 2, 10, 2); - Shape17.setRotationPoint(6F, 14F, -6F); + Shape17 = new ModelRenderer(this, 0, 0); + Shape17.addBox(0F, 0F, 0F, 2, 10, 2); + Shape17.setRotationPoint(6F, 14F, -6F); - Shape18 = new ModelRenderer(this, 0, 0); - Shape18.addBox(0F, 0F, 0F, 2, 18, 2); - Shape18.setRotationPoint(6F, 6F, 6F); - } + Shape18 = new ModelRenderer(this, 0, 0); + Shape18.addBox(0F, 0F, 0F, 2, 18, 2); + Shape18.setRotationPoint(6F, 6F, 6F); + } - public void render(Entity entity, float f, float f1, float f2, float f3, - float f4, float f5) { - super.render(entity, f, f1, f2, f3, f4, f5); - Shape1.render(f5); - Shape2.render(f5); - Shape3.render(f5); - Shape4.render(f5); - Shape5.render(f5); - Shape6.render(f5); - Shape7.render(f5); - Shape8.render(f5); - Shape9.render(f5); - Shape10.render(f5); - Shape11.render(f5); - Shape12.render(f5); - Shape13.render(f5); - Shape14.render(f5); - Shape15.render(f5); - Shape16.render(f5); - Shape17.render(f5); - Shape18.render(f5); - } + public void render(Entity entity, float f, float f1, float f2, float f3, + float f4, float f5) { + super.render(entity, f, f1, f2, f3, f4, f5); + Shape1.render(f5); + Shape2.render(f5); + Shape3.render(f5); + Shape4.render(f5); + Shape5.render(f5); + Shape6.render(f5); + Shape7.render(f5); + Shape8.render(f5); + Shape9.render(f5); + Shape10.render(f5); + Shape11.render(f5); + Shape12.render(f5); + Shape13.render(f5); + Shape14.render(f5); + Shape15.render(f5); + Shape16.render(f5); + Shape17.render(f5); + Shape18.render(f5); + } - private void setRotation(ModelRenderer model, float x, float y, float z) { - model.rotateAngleX = x; - model.rotateAngleY = y; - model.rotateAngleZ = z; - } + private void setRotation(ModelRenderer model, float x, float y, float z) { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } } diff --git a/src/main/java/noppes/npcs/client/model/blocks/legacy/couch/ModelCouchWoodSingle.java b/src/main/java/noppes/npcs/client/model/blocks/legacy/couch/ModelCouchWoodSingle.java index f43549102..924727ddd 100644 --- a/src/main/java/noppes/npcs/client/model/blocks/legacy/couch/ModelCouchWoodSingle.java +++ b/src/main/java/noppes/npcs/client/model/blocks/legacy/couch/ModelCouchWoodSingle.java @@ -5,150 +5,150 @@ import net.minecraft.client.model.ModelRenderer; import net.minecraft.entity.Entity; public class ModelCouchWoodSingle extends ModelBase { - // fields - ModelRenderer Shape1; - ModelRenderer Shape2; - ModelRenderer Shape3; - ModelRenderer Shape4; - ModelRenderer Shape5; - ModelRenderer Shape6; - ModelRenderer Shape7; - ModelRenderer Shape8; - ModelRenderer Shape9; - ModelRenderer Shape10; - ModelRenderer Shape11; - ModelRenderer Shape12; - ModelRenderer Shape13; - ModelRenderer Shape14; - ModelRenderer Shape15; - ModelRenderer Shape16; - ModelRenderer Shape17; - ModelRenderer Shape18; - ModelRenderer Shape19; - ModelRenderer Shape20; - ModelRenderer Shape21; + // fields + ModelRenderer Shape1; + ModelRenderer Shape2; + ModelRenderer Shape3; + ModelRenderer Shape4; + ModelRenderer Shape5; + ModelRenderer Shape6; + ModelRenderer Shape7; + ModelRenderer Shape8; + ModelRenderer Shape9; + ModelRenderer Shape10; + ModelRenderer Shape11; + ModelRenderer Shape12; + ModelRenderer Shape13; + ModelRenderer Shape14; + ModelRenderer Shape15; + ModelRenderer Shape16; + ModelRenderer Shape17; + ModelRenderer Shape18; + ModelRenderer Shape19; + ModelRenderer Shape20; + ModelRenderer Shape21; - public ModelCouchWoodSingle() { - Shape1 = new ModelRenderer(this, 0, 0); - Shape1.mirror = true; - Shape1.addBox(0F, 0F, 0F, 2, 3, 10); - Shape1.setRotationPoint(-8F, 18F, -4F); + public ModelCouchWoodSingle() { + Shape1 = new ModelRenderer(this, 0, 0); + Shape1.mirror = true; + Shape1.addBox(0F, 0F, 0F, 2, 3, 10); + Shape1.setRotationPoint(-8F, 18F, -4F); - Shape2 = new ModelRenderer(this, 0, 0); - Shape2.mirror = true; - Shape2.addBox(0F, 0F, 0F, 2, 10, 2); - Shape2.setRotationPoint(-8F, 14F, -6F); + Shape2 = new ModelRenderer(this, 0, 0); + Shape2.mirror = true; + Shape2.addBox(0F, 0F, 0F, 2, 10, 2); + Shape2.setRotationPoint(-8F, 14F, -6F); - Shape3 = new ModelRenderer(this, 0, 0); - Shape3.mirror = true; - Shape3.addBox(0F, 0F, 0F, 2, 4, 1); - Shape3.setRotationPoint(-8F, 14F, 0.5F); + Shape3 = new ModelRenderer(this, 0, 0); + Shape3.mirror = true; + Shape3.addBox(0F, 0F, 0F, 2, 4, 1); + Shape3.setRotationPoint(-8F, 14F, 0.5F); - Shape4 = new ModelRenderer(this, 0, 0); - Shape4.addBox(0F, 0F, 0F, 12, 2, 1); - Shape4.setRotationPoint(-6F, 7F, 7F); + Shape4 = new ModelRenderer(this, 0, 0); + Shape4.addBox(0F, 0F, 0F, 12, 2, 1); + Shape4.setRotationPoint(-6F, 7F, 7F); - Shape5 = new ModelRenderer(this, 0, 0); - Shape5.addBox(0F, 0F, 0F, 12, 2, 2); - Shape5.setRotationPoint(-6F, 19F, 6F); + Shape5 = new ModelRenderer(this, 0, 0); + Shape5.addBox(0F, 0F, 0F, 12, 2, 2); + Shape5.setRotationPoint(-6F, 19F, 6F); - Shape6 = new ModelRenderer(this, 0, 0); - Shape6.mirror = true; - Shape6.addBox(0F, 0F, 0F, 2, 1, 13); - Shape6.setRotationPoint(-8F, 13F, -7F); + Shape6 = new ModelRenderer(this, 0, 0); + Shape6.mirror = true; + Shape6.addBox(0F, 0F, 0F, 2, 1, 13); + Shape6.setRotationPoint(-8F, 13F, -7F); - Shape7 = new ModelRenderer(this, 0, 0); - Shape7.addBox(0F, 0F, 0F, 1, 1, 10); - Shape7.setRotationPoint(-6F, 19F, -4F); + Shape7 = new ModelRenderer(this, 0, 0); + Shape7.addBox(0F, 0F, 0F, 1, 1, 10); + Shape7.setRotationPoint(-6F, 19F, -4F); - Shape8 = new ModelRenderer(this, 0, 0); - Shape8.mirror = true; - Shape8.addBox(0F, 0F, 0F, 2, 18, 2); - Shape8.setRotationPoint(-8F, 6F, 6F); + Shape8 = new ModelRenderer(this, 0, 0); + Shape8.mirror = true; + Shape8.addBox(0F, 0F, 0F, 2, 18, 2); + Shape8.setRotationPoint(-8F, 6F, 6F); - Shape9 = new ModelRenderer(this, 0, 0); - Shape9.addBox(0F, 0F, 0F, 1, 1, 10); - Shape9.setRotationPoint(5F, 19F, -4F); + Shape9 = new ModelRenderer(this, 0, 0); + Shape9.addBox(0F, 0F, 0F, 1, 1, 10); + Shape9.setRotationPoint(5F, 19F, -4F); - Shape10 = new ModelRenderer(this, 0, 0); - Shape10.addBox(0F, 0F, 0F, 1, 10, 1); - Shape10.setRotationPoint(-6F, 9F, 7F); + Shape10 = new ModelRenderer(this, 0, 0); + Shape10.addBox(0F, 0F, 0F, 1, 10, 1); + Shape10.setRotationPoint(-6F, 9F, 7F); - Shape11 = new ModelRenderer(this, 0, 0); - Shape11.addBox(0F, 0F, 0F, 12, 2, 2); - Shape11.setRotationPoint(-6F, 19F, -6F); + Shape11 = new ModelRenderer(this, 0, 0); + Shape11.addBox(0F, 0F, 0F, 12, 2, 2); + Shape11.setRotationPoint(-6F, 19F, -6F); - Shape12 = new ModelRenderer(this, 0, 0); - Shape12.addBox(0F, 0F, 0F, 2, 1, 10); - Shape12.setRotationPoint(-3F, 19F, -4F); + Shape12 = new ModelRenderer(this, 0, 0); + Shape12.addBox(0F, 0F, 0F, 2, 1, 10); + Shape12.setRotationPoint(-3F, 19F, -4F); - Shape13 = new ModelRenderer(this, 0, 0); - Shape13.addBox(0F, 0F, 0F, 2, 1, 10); - Shape13.setRotationPoint(1F, 19F, -4F); + Shape13 = new ModelRenderer(this, 0, 0); + Shape13.addBox(0F, 0F, 0F, 2, 1, 10); + Shape13.setRotationPoint(1F, 19F, -4F); - Shape14 = new ModelRenderer(this, 0, 0); - Shape14.addBox(0F, 0F, 0F, 2, 10, 1); - Shape14.setRotationPoint(-3F, 9F, 7F); + Shape14 = new ModelRenderer(this, 0, 0); + Shape14.addBox(0F, 0F, 0F, 2, 10, 1); + Shape14.setRotationPoint(-3F, 9F, 7F); - Shape15 = new ModelRenderer(this, 0, 0); - Shape15.addBox(0F, 0F, 0F, 2, 10, 1); - Shape15.setRotationPoint(1F, 9F, 7F); + Shape15 = new ModelRenderer(this, 0, 0); + Shape15.addBox(0F, 0F, 0F, 2, 10, 1); + Shape15.setRotationPoint(1F, 9F, 7F); - Shape16 = new ModelRenderer(this, 0, 0); - Shape16.addBox(0F, 0F, 0F, 1, 10, 1); - Shape16.setRotationPoint(5F, 9F, 7F); + Shape16 = new ModelRenderer(this, 0, 0); + Shape16.addBox(0F, 0F, 0F, 1, 10, 1); + Shape16.setRotationPoint(5F, 9F, 7F); - Shape17 = new ModelRenderer(this, 0, 0); - Shape17.addBox(0F, 0F, 0F, 2, 18, 2); - Shape17.setRotationPoint(6F, 6F, 6F); + Shape17 = new ModelRenderer(this, 0, 0); + Shape17.addBox(0F, 0F, 0F, 2, 18, 2); + Shape17.setRotationPoint(6F, 6F, 6F); - Shape18 = new ModelRenderer(this, 0, 0); - Shape18.addBox(0F, 0F, 0F, 2, 1, 13); - Shape18.setRotationPoint(6F, 13F, -7F); + Shape18 = new ModelRenderer(this, 0, 0); + Shape18.addBox(0F, 0F, 0F, 2, 1, 13); + Shape18.setRotationPoint(6F, 13F, -7F); - Shape19 = new ModelRenderer(this, 0, 0); - Shape19.addBox(0F, 0F, 0F, 2, 10, 2); - Shape19.setRotationPoint(6F, 14F, -6F); + Shape19 = new ModelRenderer(this, 0, 0); + Shape19.addBox(0F, 0F, 0F, 2, 10, 2); + Shape19.setRotationPoint(6F, 14F, -6F); - Shape20 = new ModelRenderer(this, 0, 0); - Shape20.addBox(0F, 0F, 0F, 2, 3, 10); - Shape20.setRotationPoint(6F, 18F, -4F); + Shape20 = new ModelRenderer(this, 0, 0); + Shape20.addBox(0F, 0F, 0F, 2, 3, 10); + Shape20.setRotationPoint(6F, 18F, -4F); - Shape21 = new ModelRenderer(this, 0, 0); - Shape21.addBox(0F, 0F, 0F, 2, 4, 1); - Shape21.setRotationPoint(6F, 14F, 0.5F); - } + Shape21 = new ModelRenderer(this, 0, 0); + Shape21.addBox(0F, 0F, 0F, 2, 4, 1); + Shape21.setRotationPoint(6F, 14F, 0.5F); + } - public void render(Entity entity, float f, float f1, float f2, float f3, - float f4, float f5) { - super.render(entity, f, f1, f2, f3, f4, f5); - Shape1.render(f5); - Shape2.render(f5); - Shape3.render(f5); - Shape4.render(f5); - Shape5.render(f5); - Shape6.render(f5); - Shape7.render(f5); - Shape8.render(f5); - Shape9.render(f5); - Shape10.render(f5); - Shape11.render(f5); - Shape12.render(f5); - Shape13.render(f5); - Shape14.render(f5); - Shape15.render(f5); - Shape16.render(f5); - Shape17.render(f5); - Shape18.render(f5); - Shape19.render(f5); - Shape20.render(f5); - Shape21.render(f5); - } + public void render(Entity entity, float f, float f1, float f2, float f3, + float f4, float f5) { + super.render(entity, f, f1, f2, f3, f4, f5); + Shape1.render(f5); + Shape2.render(f5); + Shape3.render(f5); + Shape4.render(f5); + Shape5.render(f5); + Shape6.render(f5); + Shape7.render(f5); + Shape8.render(f5); + Shape9.render(f5); + Shape10.render(f5); + Shape11.render(f5); + Shape12.render(f5); + Shape13.render(f5); + Shape14.render(f5); + Shape15.render(f5); + Shape16.render(f5); + Shape17.render(f5); + Shape18.render(f5); + Shape19.render(f5); + Shape20.render(f5); + Shape21.render(f5); + } - private void setRotation(ModelRenderer model, float x, float y, float z) { - model.rotateAngleX = x; - model.rotateAngleY = y; - model.rotateAngleZ = z; - } + private void setRotation(ModelRenderer model, float x, float y, float z) { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } } diff --git a/src/main/java/noppes/npcs/client/model/blocks/legacy/couch/ModelLegacyCouchCorner.java b/src/main/java/noppes/npcs/client/model/blocks/legacy/couch/ModelLegacyCouchCorner.java index 990c7c56c..dc0fd44d8 100644 --- a/src/main/java/noppes/npcs/client/model/blocks/legacy/couch/ModelLegacyCouchCorner.java +++ b/src/main/java/noppes/npcs/client/model/blocks/legacy/couch/ModelLegacyCouchCorner.java @@ -5,72 +5,72 @@ import net.minecraft.client.model.ModelRenderer; import net.minecraft.entity.Entity; public class ModelLegacyCouchCorner extends ModelBase { - ModelRenderer Leg1; - ModelRenderer Leg2; - ModelRenderer Leg3; - ModelRenderer Leg4; - ModelRenderer Leg5; - ModelRenderer Back; - ModelRenderer Back2; - ModelRenderer Bottom; - ModelRenderer Bottom2; + ModelRenderer Leg1; + ModelRenderer Leg2; + ModelRenderer Leg3; + ModelRenderer Leg4; + ModelRenderer Leg5; + ModelRenderer Back; + ModelRenderer Back2; + ModelRenderer Bottom; + ModelRenderer Bottom2; - public ModelLegacyCouchCorner() { - Leg1 = new ModelRenderer(this, 0, 0); - Leg1.addBox(0F, 0F, 0F, 1, 1, 2); - Leg1.setRotationPoint(7F, 23F, 6F); + public ModelLegacyCouchCorner() { + Leg1 = new ModelRenderer(this, 0, 0); + Leg1.addBox(0F, 0F, 0F, 1, 1, 2); + Leg1.setRotationPoint(7F, 23F, 6F); - Leg2 = new ModelRenderer(this, 0, 0); - Leg2.addBox(0F, 0F, 0F, 2, 1, 1); - Leg2.setRotationPoint(4F, 23F, -8F); + Leg2 = new ModelRenderer(this, 0, 0); + Leg2.addBox(0F, 0F, 0F, 2, 1, 1); + Leg2.setRotationPoint(4F, 23F, -8F); - Leg3 = new ModelRenderer(this, 0, 0); - Leg3.addBox(0F, 0F, 0F, 2, 1, 1); - Leg3.setRotationPoint(-8F, 23F, -8F); + Leg3 = new ModelRenderer(this, 0, 0); + Leg3.addBox(0F, 0F, 0F, 2, 1, 1); + Leg3.setRotationPoint(-8F, 23F, -8F); - Leg4 = new ModelRenderer(this, 0, 0); - Leg4.addBox(0F, 0F, 0F, 2, 1, 2); - Leg4.setRotationPoint(-8F, 23F, 6F); + Leg4 = new ModelRenderer(this, 0, 0); + Leg4.addBox(0F, 0F, 0F, 2, 1, 2); + Leg4.setRotationPoint(-8F, 23F, 6F); - Leg5 = new ModelRenderer(this, 0, 0); - Leg5.addBox(0F, 0F, 0F, 1, 1, 2); - Leg5.setRotationPoint(7F, 23F, -6F); + Leg5 = new ModelRenderer(this, 0, 0); + Leg5.addBox(0F, 0F, 0F, 1, 1, 2); + Leg5.setRotationPoint(7F, 23F, -6F); - Back = new ModelRenderer(this, 1, 1); - Back.addBox(0F, 0F, 0F, 1, 15, 15); - Back.setRotationPoint(-8F, 6F, -8F); + Back = new ModelRenderer(this, 1, 1); + Back.addBox(0F, 0F, 0F, 1, 15, 15); + Back.setRotationPoint(-8F, 6F, -8F); - Back2 = new ModelRenderer(this, 14, 15); - Back2.addBox(0F, 0F, 0F, 16, 15, 1); - Back2.setRotationPoint(-8F, 6F, 7F); + Back2 = new ModelRenderer(this, 14, 15); + Back2.addBox(0F, 0F, 0F, 16, 15, 1); + Back2.setRotationPoint(-8F, 6F, 7F); - Bottom = new ModelRenderer(this, 4, 0); - Bottom.addBox(0F, 0F, 0F, 16, 2, 14); - Bottom.setRotationPoint(-8F, 21F, -6F); + Bottom = new ModelRenderer(this, 4, 0); + Bottom.addBox(0F, 0F, 0F, 16, 2, 14); + Bottom.setRotationPoint(-8F, 21F, -6F); - Bottom2 = new ModelRenderer(this, 0, 0); - Bottom2.addBox(0F, 0F, 0F, 14, 2, 2); - Bottom2.setRotationPoint(-8F, 21F, -8F); - } + Bottom2 = new ModelRenderer(this, 0, 0); + Bottom2.addBox(0F, 0F, 0F, 14, 2, 2); + Bottom2.setRotationPoint(-8F, 21F, -8F); + } - public void render(Entity entity, float f, float f1, float f2, float f3, - float f4, float f5) { - super.render(entity, f, f1, f2, f3, f4, f5); - Leg1.render(f5); - Leg2.render(f5); - Leg3.render(f5); - Leg4.render(f5); - Leg5.render(f5); - Back.render(f5); - Back2.render(f5); - Bottom.render(f5); - Bottom2.render(f5); - } + public void render(Entity entity, float f, float f1, float f2, float f3, + float f4, float f5) { + super.render(entity, f, f1, f2, f3, f4, f5); + Leg1.render(f5); + Leg2.render(f5); + Leg3.render(f5); + Leg4.render(f5); + Leg5.render(f5); + Back.render(f5); + Back2.render(f5); + Bottom.render(f5); + Bottom2.render(f5); + } - private void setRotation(ModelRenderer model, float x, float y, float z) { - model.rotateAngleX = x; - model.rotateAngleY = y; - model.rotateAngleZ = z; - } + private void setRotation(ModelRenderer model, float x, float y, float z) { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } } diff --git a/src/main/java/noppes/npcs/client/model/blocks/legacy/couch/ModelLegacyCouchCornerWool.java b/src/main/java/noppes/npcs/client/model/blocks/legacy/couch/ModelLegacyCouchCornerWool.java index ec6f9e12d..df2d41448 100644 --- a/src/main/java/noppes/npcs/client/model/blocks/legacy/couch/ModelLegacyCouchCornerWool.java +++ b/src/main/java/noppes/npcs/client/model/blocks/legacy/couch/ModelLegacyCouchCornerWool.java @@ -5,42 +5,42 @@ import net.minecraft.client.model.ModelRenderer; import net.minecraft.entity.Entity; public class ModelLegacyCouchCornerWool extends ModelBase { - ModelRenderer Wool1; - ModelRenderer Wool2; - ModelRenderer Wool3; - ModelRenderer Wool4; + ModelRenderer Wool1; + ModelRenderer Wool2; + ModelRenderer Wool3; + ModelRenderer Wool4; - public ModelLegacyCouchCornerWool() { - Wool1 = new ModelRenderer(this, 11, 3); - Wool1.addBox(0F, 0F, 0F, 13, 5, 2); - Wool1.setRotationPoint(-7F, 16F, -8F); + public ModelLegacyCouchCornerWool() { + Wool1 = new ModelRenderer(this, 11, 3); + Wool1.addBox(0F, 0F, 0F, 13, 5, 2); + Wool1.setRotationPoint(-7F, 16F, -8F); - Wool2 = new ModelRenderer(this, 2, 4); - Wool2.addBox(0F, 0F, 0F, 2, 10, 13); - Wool2.setRotationPoint(-7F, 6F, -8F); + Wool2 = new ModelRenderer(this, 2, 4); + Wool2.addBox(0F, 0F, 0F, 2, 10, 13); + Wool2.setRotationPoint(-7F, 6F, -8F); - Wool3 = new ModelRenderer(this, 14, 15); - Wool3.addBox(0F, 0F, 0F, 15, 10, 2); - Wool3.setRotationPoint(-7F, 6F, 5F); + Wool3 = new ModelRenderer(this, 14, 15); + Wool3.addBox(0F, 0F, 0F, 15, 10, 2); + Wool3.setRotationPoint(-7F, 6F, 5F); - Wool4 = new ModelRenderer(this, 0, 45); - Wool4.addBox(0F, 0F, 0F, 15, 5, 13); - Wool4.setRotationPoint(-7F, 16F, -6F); - } + Wool4 = new ModelRenderer(this, 0, 45); + Wool4.addBox(0F, 0F, 0F, 15, 5, 13); + Wool4.setRotationPoint(-7F, 16F, -6F); + } - public void render(Entity entity, float f, float f1, float f2, float f3, - float f4, float f5) { - super.render(entity, f, f1, f2, f3, f4, f5); - Wool1.render(f5); - Wool2.render(f5); - Wool3.render(f5); - Wool4.render(f5); - } + public void render(Entity entity, float f, float f1, float f2, float f3, + float f4, float f5) { + super.render(entity, f, f1, f2, f3, f4, f5); + Wool1.render(f5); + Wool2.render(f5); + Wool3.render(f5); + Wool4.render(f5); + } - private void setRotation(ModelRenderer model, float x, float y, float z) { - model.rotateAngleX = x; - model.rotateAngleY = y; - model.rotateAngleZ = z; - } + private void setRotation(ModelRenderer model, float x, float y, float z) { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } } diff --git a/src/main/java/noppes/npcs/client/model/blocks/legacy/couch/ModelLegacyCouchLeft.java b/src/main/java/noppes/npcs/client/model/blocks/legacy/couch/ModelLegacyCouchLeft.java index b51488dd8..e45311e92 100644 --- a/src/main/java/noppes/npcs/client/model/blocks/legacy/couch/ModelLegacyCouchLeft.java +++ b/src/main/java/noppes/npcs/client/model/blocks/legacy/couch/ModelLegacyCouchLeft.java @@ -5,60 +5,60 @@ import net.minecraft.client.model.ModelRenderer; import net.minecraft.entity.Entity; public class ModelLegacyCouchLeft extends ModelBase { - ModelRenderer Leg1; - ModelRenderer Leg2; - ModelRenderer Leg3; - ModelRenderer Leg4; - ModelRenderer Back; - ModelRenderer Side; - ModelRenderer Bottom; + ModelRenderer Leg1; + ModelRenderer Leg2; + ModelRenderer Leg3; + ModelRenderer Leg4; + ModelRenderer Back; + ModelRenderer Side; + ModelRenderer Bottom; - public ModelLegacyCouchLeft() { - Leg1 = new ModelRenderer(this, 0, 0); - Leg1.addBox(0F, 0F, 0F, 2, 1, 2); - Leg1.setRotationPoint(-8F, 23F, 6F); + public ModelLegacyCouchLeft() { + Leg1 = new ModelRenderer(this, 0, 0); + Leg1.addBox(0F, 0F, 0F, 2, 1, 2); + Leg1.setRotationPoint(-8F, 23F, 6F); - Leg2 = new ModelRenderer(this, 0, 0); - Leg2.addBox(0F, 0F, 0F, 1, 1, 2); - Leg2.setRotationPoint(7F, 23F, -6F); + Leg2 = new ModelRenderer(this, 0, 0); + Leg2.addBox(0F, 0F, 0F, 1, 1, 2); + Leg2.setRotationPoint(7F, 23F, -6F); - Leg3 = new ModelRenderer(this, 0, 0); - Leg3.addBox(0F, 0F, 0F, 2, 1, 2); - Leg3.setRotationPoint(-8F, 23F, -6F); + Leg3 = new ModelRenderer(this, 0, 0); + Leg3.addBox(0F, 0F, 0F, 2, 1, 2); + Leg3.setRotationPoint(-8F, 23F, -6F); - Leg4 = new ModelRenderer(this, 0, 0); - Leg4.addBox(0F, 0F, 0F, 1, 1, 2); - Leg4.setRotationPoint(7F, 23F, 6F); + Leg4 = new ModelRenderer(this, 0, 0); + Leg4.addBox(0F, 0F, 0F, 1, 1, 2); + Leg4.setRotationPoint(7F, 23F, 6F); - Back = new ModelRenderer(this, 1, 15); - Back.addBox(0F, 0F, 0F, 14, 15, 1); - Back.setRotationPoint(-6F, 6F, 7F); + Back = new ModelRenderer(this, 1, 15); + Back.addBox(0F, 0F, 0F, 14, 15, 1); + Back.setRotationPoint(-6F, 6F, 7F); - Side = new ModelRenderer(this, 1, 28); - Side.addBox(0F, 0F, 0F, 2, 11, 14); - Side.setRotationPoint(-8F, 12F, -6F); + Side = new ModelRenderer(this, 1, 28); + Side.addBox(0F, 0F, 0F, 2, 11, 14); + Side.setRotationPoint(-8F, 12F, -6F); - Bottom = new ModelRenderer(this, 3, 1); - Bottom.addBox(0F, 0F, 0F, 14, 2, 14); - Bottom.setRotationPoint(-6F, 21F, -6F); - } + Bottom = new ModelRenderer(this, 3, 1); + Bottom.addBox(0F, 0F, 0F, 14, 2, 14); + Bottom.setRotationPoint(-6F, 21F, -6F); + } - public void render(Entity entity, float f, float f1, float f2, float f3, - float f4, float f5) { - super.render(entity, f, f1, f2, f3, f4, f5); - Leg1.render(f5); - Leg2.render(f5); - Leg3.render(f5); - Leg4.render(f5); - Back.render(f5); - Side.render(f5); - Bottom.render(f5); - } + public void render(Entity entity, float f, float f1, float f2, float f3, + float f4, float f5) { + super.render(entity, f, f1, f2, f3, f4, f5); + Leg1.render(f5); + Leg2.render(f5); + Leg3.render(f5); + Leg4.render(f5); + Back.render(f5); + Side.render(f5); + Bottom.render(f5); + } - private void setRotation(ModelRenderer model, float x, float y, float z) { - model.rotateAngleX = x; - model.rotateAngleY = y; - model.rotateAngleZ = z; - } + private void setRotation(ModelRenderer model, float x, float y, float z) { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } } diff --git a/src/main/java/noppes/npcs/client/model/blocks/legacy/couch/ModelLegacyCouchLeftWool.java b/src/main/java/noppes/npcs/client/model/blocks/legacy/couch/ModelLegacyCouchLeftWool.java index 3e3ab99bf..0ebd3495a 100644 --- a/src/main/java/noppes/npcs/client/model/blocks/legacy/couch/ModelLegacyCouchLeftWool.java +++ b/src/main/java/noppes/npcs/client/model/blocks/legacy/couch/ModelLegacyCouchLeftWool.java @@ -5,30 +5,30 @@ import net.minecraft.client.model.ModelRenderer; import net.minecraft.entity.Entity; public class ModelLegacyCouchLeftWool extends ModelBase { - ModelRenderer Wool1; - ModelRenderer Wool2; + ModelRenderer Wool1; + ModelRenderer Wool2; - public ModelLegacyCouchLeftWool() { - Wool1 = new ModelRenderer(this, 3, 0); - Wool1.addBox(0F, 0F, 0F, 14, 5, 13); - Wool1.setRotationPoint(-6F, 16F, -6F); + public ModelLegacyCouchLeftWool() { + Wool1 = new ModelRenderer(this, 3, 0); + Wool1.addBox(0F, 0F, 0F, 14, 5, 13); + Wool1.setRotationPoint(-6F, 16F, -6F); - Wool2 = new ModelRenderer(this, 14, 0); - Wool2.addBox(0F, 0F, 0F, 14, 10, 2); - Wool2.setRotationPoint(-6F, 6F, 5F); - } + Wool2 = new ModelRenderer(this, 14, 0); + Wool2.addBox(0F, 0F, 0F, 14, 10, 2); + Wool2.setRotationPoint(-6F, 6F, 5F); + } - public void render(Entity entity, float f, float f1, float f2, float f3, - float f4, float f5) { - super.render(entity, f, f1, f2, f3, f4, f5); - Wool1.render(f5); - Wool2.render(f5); - } + public void render(Entity entity, float f, float f1, float f2, float f3, + float f4, float f5) { + super.render(entity, f, f1, f2, f3, f4, f5); + Wool1.render(f5); + Wool2.render(f5); + } - private void setRotation(ModelRenderer model, float x, float y, float z) { - model.rotateAngleX = x; - model.rotateAngleY = y; - model.rotateAngleZ = z; - } + private void setRotation(ModelRenderer model, float x, float y, float z) { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } } diff --git a/src/main/java/noppes/npcs/client/model/blocks/legacy/couch/ModelLegacyCouchMiddle.java b/src/main/java/noppes/npcs/client/model/blocks/legacy/couch/ModelLegacyCouchMiddle.java index 61d9554e8..5f231a415 100644 --- a/src/main/java/noppes/npcs/client/model/blocks/legacy/couch/ModelLegacyCouchMiddle.java +++ b/src/main/java/noppes/npcs/client/model/blocks/legacy/couch/ModelLegacyCouchMiddle.java @@ -4,9 +4,8 @@ import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelRenderer; import net.minecraft.entity.Entity; -public class ModelLegacyCouchMiddle extends ModelBase -{ - //fields +public class ModelLegacyCouchMiddle extends ModelBase { + //fields ModelRenderer Leg1; ModelRenderer Leg2; ModelRenderer Leg3; @@ -14,48 +13,46 @@ public class ModelLegacyCouchMiddle extends ModelBase ModelRenderer Bottom; ModelRenderer Back; - public ModelLegacyCouchMiddle(){ - Leg1 = new ModelRenderer(this, 0, 0); - Leg1.addBox(0F, 0F, 0F, 1, 1, 2); - Leg1.setRotationPoint(7F, 23F, 6F); + public ModelLegacyCouchMiddle() { + Leg1 = new ModelRenderer(this, 0, 0); + Leg1.addBox(0F, 0F, 0F, 1, 1, 2); + Leg1.setRotationPoint(7F, 23F, 6F); - Leg2 = new ModelRenderer(this, 0, 0); - Leg2.addBox(0F, 0F, 0F, 1, 1, 2); - Leg2.setRotationPoint(7F, 23F, -6F); + Leg2 = new ModelRenderer(this, 0, 0); + Leg2.addBox(0F, 0F, 0F, 1, 1, 2); + Leg2.setRotationPoint(7F, 23F, -6F); - Leg3 = new ModelRenderer(this, 0, 0); - Leg3.addBox(0F, 0F, 0F, 1, 1, 2); - Leg3.setRotationPoint(-8F, 23F, -6F); + Leg3 = new ModelRenderer(this, 0, 0); + Leg3.addBox(0F, 0F, 0F, 1, 1, 2); + Leg3.setRotationPoint(-8F, 23F, -6F); - Leg4 = new ModelRenderer(this, 0, 0); - Leg4.addBox(0F, 0F, 0F, 1, 1, 2); - Leg4.setRotationPoint(-8F, 23F, 6F); + Leg4 = new ModelRenderer(this, 0, 0); + Leg4.addBox(0F, 0F, 0F, 1, 1, 2); + Leg4.setRotationPoint(-8F, 23F, 6F); - Bottom = new ModelRenderer(this, 2, 0); - Bottom.addBox(0F, 0F, 0F, 16, 2, 14); - Bottom.setRotationPoint(-8F, 21F, -6F); + Bottom = new ModelRenderer(this, 2, 0); + Bottom.addBox(0F, 0F, 0F, 16, 2, 14); + Bottom.setRotationPoint(-8F, 21F, -6F); - Back = new ModelRenderer(this, 14, 15); - Back.addBox(0F, 0F, 0F, 16, 15, 1); - Back.setRotationPoint(-8F, 6F, 7F); - } + Back = new ModelRenderer(this, 14, 15); + Back.addBox(0F, 0F, 0F, 16, 15, 1); + Back.setRotationPoint(-8F, 6F, 7F); + } - public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) - { - super.render(entity, f, f1, f2, f3, f4, f5); - Leg1.render(f5); - Leg2.render(f5); - Leg3.render(f5); - Leg4.render(f5); - Bottom.render(f5); - Back.render(f5); - } + public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) { + super.render(entity, f, f1, f2, f3, f4, f5); + Leg1.render(f5); + Leg2.render(f5); + Leg3.render(f5); + Leg4.render(f5); + Bottom.render(f5); + Back.render(f5); + } - private void setRotation(ModelRenderer model, float x, float y, float z) - { - model.rotateAngleX = x; - model.rotateAngleY = y; - model.rotateAngleZ = z; - } + private void setRotation(ModelRenderer model, float x, float y, float z) { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } } diff --git a/src/main/java/noppes/npcs/client/model/blocks/legacy/couch/ModelLegacyCouchMiddleWool.java b/src/main/java/noppes/npcs/client/model/blocks/legacy/couch/ModelLegacyCouchMiddleWool.java index 654298906..21216db39 100644 --- a/src/main/java/noppes/npcs/client/model/blocks/legacy/couch/ModelLegacyCouchMiddleWool.java +++ b/src/main/java/noppes/npcs/client/model/blocks/legacy/couch/ModelLegacyCouchMiddleWool.java @@ -4,33 +4,30 @@ import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelRenderer; import net.minecraft.entity.Entity; -public class ModelLegacyCouchMiddleWool extends ModelBase -{ +public class ModelLegacyCouchMiddleWool extends ModelBase { ModelRenderer Wool1; ModelRenderer Wool2; - public ModelLegacyCouchMiddleWool(){ - Wool1 = new ModelRenderer(this, 3, 0); - Wool1.addBox(0F, 0F, 0F, 16, 5, 13); - Wool1.setRotationPoint(-8F, 16F, -6F); + public ModelLegacyCouchMiddleWool() { + Wool1 = new ModelRenderer(this, 3, 0); + Wool1.addBox(0F, 0F, 0F, 16, 5, 13); + Wool1.setRotationPoint(-8F, 16F, -6F); - Wool2 = new ModelRenderer(this, 14, 0); - Wool2.addBox(0F, 0F, 0F, 16, 10, 2); - Wool2.setRotationPoint(-8F, 6F, 5F); - } + Wool2 = new ModelRenderer(this, 14, 0); + Wool2.addBox(0F, 0F, 0F, 16, 10, 2); + Wool2.setRotationPoint(-8F, 6F, 5F); + } - public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) - { - super.render(entity, f, f1, f2, f3, f4, f5); - Wool1.render(f5); - Wool2.render(f5); - } + public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) { + super.render(entity, f, f1, f2, f3, f4, f5); + Wool1.render(f5); + Wool2.render(f5); + } - private void setRotation(ModelRenderer model, float x, float y, float z) - { - model.rotateAngleX = x; - model.rotateAngleY = y; - model.rotateAngleZ = z; - } + private void setRotation(ModelRenderer model, float x, float y, float z) { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } } diff --git a/src/main/java/noppes/npcs/client/model/blocks/legacy/couch/ModelLegacyCouchRight.java b/src/main/java/noppes/npcs/client/model/blocks/legacy/couch/ModelLegacyCouchRight.java index e3867a270..1de74f93b 100644 --- a/src/main/java/noppes/npcs/client/model/blocks/legacy/couch/ModelLegacyCouchRight.java +++ b/src/main/java/noppes/npcs/client/model/blocks/legacy/couch/ModelLegacyCouchRight.java @@ -5,64 +5,64 @@ import net.minecraft.client.model.ModelRenderer; import net.minecraft.entity.Entity; public class ModelLegacyCouchRight extends ModelBase { - // fields - ModelRenderer Leg1; - ModelRenderer Leg2; - ModelRenderer Leg3; - ModelRenderer Leg4; - ModelRenderer Back; - ModelRenderer Bottom; - ModelRenderer Side; + // fields + ModelRenderer Leg1; + ModelRenderer Leg2; + ModelRenderer Leg3; + ModelRenderer Leg4; + ModelRenderer Back; + ModelRenderer Bottom; + ModelRenderer Side; - public ModelLegacyCouchRight() { - Leg1 = new ModelRenderer(this, 0, 0); - Leg1.addBox(0F, 0F, 0F, 2, 1, 2); - Leg1.setRotationPoint(6F, 23F, 6F); + public ModelLegacyCouchRight() { + Leg1 = new ModelRenderer(this, 0, 0); + Leg1.addBox(0F, 0F, 0F, 2, 1, 2); + Leg1.setRotationPoint(6F, 23F, 6F); - Leg2 = new ModelRenderer(this, 0, 0); - Leg2.addBox(0F, 0F, 0F, 1, 1, 2); - Leg2.setRotationPoint(-8F, 23F, -6F); + Leg2 = new ModelRenderer(this, 0, 0); + Leg2.addBox(0F, 0F, 0F, 1, 1, 2); + Leg2.setRotationPoint(-8F, 23F, -6F); - Leg3 = new ModelRenderer(this, 0, 0); - Leg3.addBox(0F, 0F, 0F, 2, 1, 2); - Leg3.setRotationPoint(6F, 23F, -6F); + Leg3 = new ModelRenderer(this, 0, 0); + Leg3.addBox(0F, 0F, 0F, 2, 1, 2); + Leg3.setRotationPoint(6F, 23F, -6F); - Leg4 = new ModelRenderer(this, 0, 0); - Leg4.addBox(0F, 0F, 0F, 1, 1, 2); - Leg4.setRotationPoint(-8F, 23F, 6F); + Leg4 = new ModelRenderer(this, 0, 0); + Leg4.addBox(0F, 0F, 0F, 1, 1, 2); + Leg4.setRotationPoint(-8F, 23F, 6F); - Back = new ModelRenderer(this, 1, 15); - Back.mirror = true; - Back.addBox(0F, 0F, 0F, 14, 15, 1); - Back.setRotationPoint(-8F, 6F, 7F); + Back = new ModelRenderer(this, 1, 15); + Back.mirror = true; + Back.addBox(0F, 0F, 0F, 14, 15, 1); + Back.setRotationPoint(-8F, 6F, 7F); - Bottom = new ModelRenderer(this, 3, 1); - Bottom.mirror = true; - Bottom.addBox(0F, 0F, 0F, 14, 2, 14); - Bottom.setRotationPoint(-8F, 21F, -6F); + Bottom = new ModelRenderer(this, 3, 1); + Bottom.mirror = true; + Bottom.addBox(0F, 0F, 0F, 14, 2, 14); + Bottom.setRotationPoint(-8F, 21F, -6F); - Side = new ModelRenderer(this, 1, 28); - Side.mirror = true; - Side.addBox(0F, 0F, 0F, 2, 11, 14); - Side.setRotationPoint(6F, 12F, -6F); - } + Side = new ModelRenderer(this, 1, 28); + Side.mirror = true; + Side.addBox(0F, 0F, 0F, 2, 11, 14); + Side.setRotationPoint(6F, 12F, -6F); + } - public void render(Entity entity, float f, float f1, float f2, float f3, - float f4, float f5) { - super.render(entity, f, f1, f2, f3, f4, f5); - Leg1.render(f5); - Leg2.render(f5); - Leg3.render(f5); - Leg4.render(f5); - Back.render(f5); - Bottom.render(f5); - Side.render(f5); - } + public void render(Entity entity, float f, float f1, float f2, float f3, + float f4, float f5) { + super.render(entity, f, f1, f2, f3, f4, f5); + Leg1.render(f5); + Leg2.render(f5); + Leg3.render(f5); + Leg4.render(f5); + Back.render(f5); + Bottom.render(f5); + Side.render(f5); + } - private void setRotation(ModelRenderer model, float x, float y, float z) { - model.rotateAngleX = x; - model.rotateAngleY = y; - model.rotateAngleZ = z; - } + private void setRotation(ModelRenderer model, float x, float y, float z) { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } } diff --git a/src/main/java/noppes/npcs/client/model/blocks/legacy/couch/ModelLegacyCouchRightWool.java b/src/main/java/noppes/npcs/client/model/blocks/legacy/couch/ModelLegacyCouchRightWool.java index 6a92b3855..5d9b345d8 100644 --- a/src/main/java/noppes/npcs/client/model/blocks/legacy/couch/ModelLegacyCouchRightWool.java +++ b/src/main/java/noppes/npcs/client/model/blocks/legacy/couch/ModelLegacyCouchRightWool.java @@ -5,32 +5,32 @@ import net.minecraft.client.model.ModelRenderer; import net.minecraft.entity.Entity; public class ModelLegacyCouchRightWool extends ModelBase { - ModelRenderer Wool1; - ModelRenderer Wool2; + ModelRenderer Wool1; + ModelRenderer Wool2; - public ModelLegacyCouchRightWool() { - Wool1 = new ModelRenderer(this, 3, 0); - Wool1.mirror = true; - Wool1.addBox(0F, 0F, 0F, 14, 5, 13); - Wool1.setRotationPoint(-8F, 16F, -6F); + public ModelLegacyCouchRightWool() { + Wool1 = new ModelRenderer(this, 3, 0); + Wool1.mirror = true; + Wool1.addBox(0F, 0F, 0F, 14, 5, 13); + Wool1.setRotationPoint(-8F, 16F, -6F); - Wool2 = new ModelRenderer(this, 14, 0); - Wool2.mirror = true; - Wool2.addBox(0F, 0F, 0F, 14, 10, 2); - Wool2.setRotationPoint(-8F, 6F, 5F); - } + Wool2 = new ModelRenderer(this, 14, 0); + Wool2.mirror = true; + Wool2.addBox(0F, 0F, 0F, 14, 10, 2); + Wool2.setRotationPoint(-8F, 6F, 5F); + } - public void render(Entity entity, float f, float f1, float f2, float f3, - float f4, float f5) { - super.render(entity, f, f1, f2, f3, f4, f5); - Wool1.render(f5); - Wool2.render(f5); - } + public void render(Entity entity, float f, float f1, float f2, float f3, + float f4, float f5) { + super.render(entity, f, f1, f2, f3, f4, f5); + Wool1.render(f5); + Wool2.render(f5); + } - private void setRotation(ModelRenderer model, float x, float y, float z) { - model.rotateAngleX = x; - model.rotateAngleY = y; - model.rotateAngleZ = z; - } + private void setRotation(ModelRenderer model, float x, float y, float z) { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } } diff --git a/src/main/java/noppes/npcs/client/model/part/ModelBeard.java b/src/main/java/noppes/npcs/client/model/part/ModelBeard.java index eb9489fba..190a308b3 100644 --- a/src/main/java/noppes/npcs/client/model/part/ModelBeard.java +++ b/src/main/java/noppes/npcs/client/model/part/ModelBeard.java @@ -9,41 +9,39 @@ import noppes.npcs.entity.data.ModelPartData; public class ModelBeard extends ModelPartInterface { - private Model2DRenderer model; + private Model2DRenderer model; - public ModelBeard(ModelMPM base) { - super(base); - model = new Model2DRenderer(base, 56, 20, 8, 12, 64, 32); - model.setRotationPoint(-3.99F, 11.9f, -4); - model.setScale(0.74f); - this.addChild(model); - } + public ModelBeard(ModelMPM base) { + super(base); + model = new Model2DRenderer(base, 56, 20, 8, 12, 64, 32); + model.setRotationPoint(-3.99F, 11.9f, -4); + model.setScale(0.74f); + this.addChild(model); + } - @Override - public void setRotationAngles(float par1, float par2, float par3, - float par4, float par5, float par6, Entity entity) { - if(this.base.bipedHead.rotateAngleX > 0) - rotateAngleX = -base.bipedHead.rotateAngleX; - else - rotateAngleX = 0; - } + @Override + public void setRotationAngles(float par1, float par2, float par3, + float par4, float par5, float par6, Entity entity) { + if (this.base.bipedHead.rotateAngleX > 0) + rotateAngleX = -base.bipedHead.rotateAngleX; + else + rotateAngleX = 0; + } - @Override - public void initData(ModelData data) { - ModelPartData config = data.getPartData("beard"); - if(config == null) - { - isHidden = true; - return; - } - color = config.color; - isHidden = false; + @Override + public void initData(ModelData data) { + ModelPartData config = data.getPartData("beard"); + if (config == null) { + isHidden = true; + return; + } + color = config.color; + isHidden = false; - if(!config.playerTexture){ - location = config.getResource(); - } - else - location = null; - } + if (!config.playerTexture) { + location = config.getResource(); + } else + location = null; + } } diff --git a/src/main/java/noppes/npcs/client/model/part/ModelBodywear.java b/src/main/java/noppes/npcs/client/model/part/ModelBodywear.java index cef8a1f36..fe88a452a 100644 --- a/src/main/java/noppes/npcs/client/model/part/ModelBodywear.java +++ b/src/main/java/noppes/npcs/client/model/part/ModelBodywear.java @@ -7,59 +7,59 @@ import noppes.npcs.client.model.util.ModelScaleRenderer; public class ModelBodywear extends ModelScaleRenderer { - public ModelBodywear(ModelBase base, int height, int width) { - super(base); + public ModelBodywear(ModelBase base, int height, int width) { + super(base); - float thick = 0.50f; + float thick = 0.50f; - Model2DRenderer front = new Model2DRenderer(base, 20, 36, 8, 12, width, height); - front.setRotationPoint(-4.53f, 12.535f, -2.52f); - front.setScale(0.85f,0.8175f); - front.setThickness(thick); - setRotation(front, 0, 0, 0); - this.addChild(front); + Model2DRenderer front = new Model2DRenderer(base, 20, 36, 8, 12, width, height); + front.setRotationPoint(-4.53f, 12.535f, -2.52f); + front.setScale(0.85f, 0.8175f); + front.setThickness(thick); + setRotation(front, 0, 0, 0); + this.addChild(front); - Model2DRenderer back = new Model2DRenderer(base, 32, 36, 8, 12, width, height); - back.setRotationPoint(4.53f, 12.535f, 2.52f); - back.setScale(0.85f,0.8175f); - back.setThickness(thick); - setRotation(back, 0, (float)(Math.PI), 0); - this.addChild(back); + Model2DRenderer back = new Model2DRenderer(base, 32, 36, 8, 12, width, height); + back.setRotationPoint(4.53f, 12.535f, 2.52f); + back.setScale(0.85f, 0.8175f); + back.setThickness(thick); + setRotation(back, 0, (float) (Math.PI), 0); + this.addChild(back); - Model2DRenderer right = new Model2DRenderer(base, 28, 36, 4, 12, width, height); - right.setRotationPoint(4.03f, 12.55f, 2.55f); - right.setScale(0.96f,0.82f); - right.setThickness(thick); - setRotation(right, 0, (float)(Math.PI/2f), 0); - this.addChild(right); + Model2DRenderer right = new Model2DRenderer(base, 28, 36, 4, 12, width, height); + right.setRotationPoint(4.03f, 12.55f, 2.55f); + right.setScale(0.96f, 0.82f); + right.setThickness(thick); + setRotation(right, 0, (float) (Math.PI / 2f), 0); + this.addChild(right); - Model2DRenderer left = new Model2DRenderer(base, 16, 36, 4, 12, width, height); - left.setRotationPoint(-4.03f, 12.55f, -2.55f); - left.setScale(0.96f,0.82f); - left.setThickness(thick); - setRotation(left, 0, (float)(Math.PI/-2f), 0); - this.addChild(left); + Model2DRenderer left = new Model2DRenderer(base, 16, 36, 4, 12, width, height); + left.setRotationPoint(-4.03f, 12.55f, -2.55f); + left.setScale(0.96f, 0.82f); + left.setThickness(thick); + setRotation(left, 0, (float) (Math.PI / -2f), 0); + this.addChild(left); - Model2DRenderer top = new Model2DRenderer(base, 20, 32, 8, 4, width, height); - top.setRotationPoint(-4.5f, -0.6f, -2.525f); - top.setScale(0.2815f,0.315f); - top.setThickness(thick); - setRotation(top, (float)(Math.PI / -2), 0, 0); - this.addChild(top); + Model2DRenderer top = new Model2DRenderer(base, 20, 32, 8, 4, width, height); + top.setRotationPoint(-4.5f, -0.6f, -2.525f); + top.setScale(0.2815f, 0.315f); + top.setThickness(thick); + setRotation(top, (float) (Math.PI / -2), 0, 0); + this.addChild(top); - Model2DRenderer bottom = new Model2DRenderer(base, 28, 32, 8, 4, width, height); - bottom.setRotationPoint(-4.5f, 12.11f, -2.525f); - bottom.setScale(0.2815f,0.315f); - bottom.setThickness(thick); - setRotation(bottom, (float)(Math.PI / -2), 0, 0); - this.addChild(bottom); - } + Model2DRenderer bottom = new Model2DRenderer(base, 28, 32, 8, 4, width, height); + bottom.setRotationPoint(-4.5f, 12.11f, -2.525f); + bottom.setScale(0.2815f, 0.315f); + bottom.setThickness(thick); + setRotation(bottom, (float) (Math.PI / -2), 0, 0); + this.addChild(bottom); + } - public void setRotation(ModelRenderer model, float x, float y, float z) { - model.rotateAngleX = x; - model.rotateAngleY = y; - model.rotateAngleZ = z; - } + public void setRotation(ModelRenderer model, float x, float y, float z) { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } } diff --git a/src/main/java/noppes/npcs/client/model/part/ModelBreasts.java b/src/main/java/noppes/npcs/client/model/part/ModelBreasts.java index 459de00b8..1cd400ca0 100644 --- a/src/main/java/noppes/npcs/client/model/part/ModelBreasts.java +++ b/src/main/java/noppes/npcs/client/model/part/ModelBreasts.java @@ -8,111 +8,111 @@ import noppes.npcs.client.model.util.ModelPartInterface; import noppes.npcs.entity.data.ModelData; public class ModelBreasts extends ModelPartInterface { - private Model2DRenderer breasts; - private ModelRenderer breasts2; - private ModelRenderer breasts3; + private Model2DRenderer breasts; + private ModelRenderer breasts2; + private ModelRenderer breasts3; - public ModelBreasts(ModelMPM base, int width, int height) { - super(base); + public ModelBreasts(ModelMPM base, int width, int height) { + super(base); - breasts = new Model2DRenderer(base, 20f, 22, 8, 3, width, height); - breasts.setTextureSize(width, height); - breasts.setRotationPoint(-3.6F, 5.2f, -3f); - breasts.setScale(0.17f, 0.19f); - breasts.setThickness(1); - this.addChild(breasts); + breasts = new Model2DRenderer(base, 20f, 22, 8, 3, width, height); + breasts.setTextureSize(width, height); + breasts.setRotationPoint(-3.6F, 5.2f, -3f); + breasts.setScale(0.17f, 0.19f); + breasts.setThickness(1); + this.addChild(breasts); - breasts2 = new ModelRenderer(base); - breasts2.setTextureSize(width, height); - this.addChild(breasts2); + breasts2 = new ModelRenderer(base); + breasts2.setTextureSize(width, height); + this.addChild(breasts2); - Model2DRenderer bottom = new Model2DRenderer(base, 20f, 22, 8, 4, width, height); - bottom.setTextureSize(width, height); - bottom.setRotationPoint(-3.6F, 5f, -3.1f); - bottom.setScale(0.225f, 0.20f); - bottom.setThickness(2f); - bottom.rotateAngleX = -(float) (Math.PI / 10); - breasts2.addChild(bottom); + Model2DRenderer bottom = new Model2DRenderer(base, 20f, 22, 8, 4, width, height); + bottom.setTextureSize(width, height); + bottom.setRotationPoint(-3.6F, 5f, -3.1f); + bottom.setScale(0.225f, 0.20f); + bottom.setThickness(2f); + bottom.rotateAngleX = -(float) (Math.PI / 10); + breasts2.addChild(bottom); - breasts3 = new ModelRenderer(base); - breasts3.setTextureSize(width, height); - this.addChild(breasts3); + breasts3 = new ModelRenderer(base); + breasts3.setTextureSize(width, height); + this.addChild(breasts3); - Model2DRenderer right = new Model2DRenderer(base, 20f, 22, 3, 2, width, height); - right.setTextureSize(width, height); - right.setRotationPoint(-3.8F, 5.3f, -3.6f); - right.setScale(0.12f, 0.14f); - right.setThickness(1.75f); - breasts3.addChild(right); + Model2DRenderer right = new Model2DRenderer(base, 20f, 22, 3, 2, width, height); + right.setTextureSize(width, height); + right.setRotationPoint(-3.8F, 5.3f, -3.6f); + right.setScale(0.12f, 0.14f); + right.setThickness(1.75f); + breasts3.addChild(right); - Model2DRenderer right2 = new Model2DRenderer(base, 20f, 22, 3, 1, width, height); - right2.setTextureSize(width, height); - right2.setRotationPoint(-3.8F, 4.1f, -3.14f); - right2.setScale(0.06f, 0.07f); - right2.setThickness(1.75f); - right2.rotateAngleX = (float) (Math.PI / 9); - breasts3.addChild(right2); + Model2DRenderer right2 = new Model2DRenderer(base, 20f, 22, 3, 1, width, height); + right2.setTextureSize(width, height); + right2.setRotationPoint(-3.8F, 4.1f, -3.14f); + right2.setScale(0.06f, 0.07f); + right2.setThickness(1.75f); + right2.rotateAngleX = (float) (Math.PI / 9); + breasts3.addChild(right2); - Model2DRenderer right3 = new Model2DRenderer(base, 20f, 24, 3, 1, width, height); - right3.setTextureSize(width, height); - right3.setRotationPoint(-3.8F, 5.3f, -3.6f); - right3.setScale(0.06f, 0.07f); - right3.setThickness(1.75f); - right3.rotateAngleX = (float) (-Math.PI / 9); - breasts3.addChild(right3); + Model2DRenderer right3 = new Model2DRenderer(base, 20f, 24, 3, 1, width, height); + right3.setTextureSize(width, height); + right3.setRotationPoint(-3.8F, 5.3f, -3.6f); + right3.setScale(0.06f, 0.07f); + right3.setThickness(1.75f); + right3.rotateAngleX = (float) (-Math.PI / 9); + breasts3.addChild(right3); - Model2DRenderer right4 = new Model2DRenderer(base, 23f, 22, 1, 2, width, height); - right4.setTextureSize(width, height); - right4.setRotationPoint(-1.8f, 5.3f, -3.14f); - right4.setScale(0.12f, 0.14f); - right4.setThickness(1.75f); - right4.rotateAngleY = (float) (Math.PI / 9); - breasts3.addChild(right4); + Model2DRenderer right4 = new Model2DRenderer(base, 23f, 22, 1, 2, width, height); + right4.setTextureSize(width, height); + right4.setRotationPoint(-1.8f, 5.3f, -3.14f); + right4.setScale(0.12f, 0.14f); + right4.setThickness(1.75f); + right4.rotateAngleY = (float) (Math.PI / 9); + breasts3.addChild(right4); - Model2DRenderer left = new Model2DRenderer(base, 25f, 22, 3, 2, width, height); - left.setTextureSize(width, height); - left.setRotationPoint(0.8F, 5.3f, -3.6f); - left.setScale(0.12f, 0.14f); - left.setThickness(1.75f); - breasts3.addChild(left); + Model2DRenderer left = new Model2DRenderer(base, 25f, 22, 3, 2, width, height); + left.setTextureSize(width, height); + left.setRotationPoint(0.8F, 5.3f, -3.6f); + left.setScale(0.12f, 0.14f); + left.setThickness(1.75f); + breasts3.addChild(left); - Model2DRenderer left2 = new Model2DRenderer(base, 25f, 22, 3, 1, width, height); - left2.setTextureSize(width, height); - left2.setRotationPoint(0.8F, 4.1f, -3.18f); - left2.setScale(0.06f, 0.07f); - left2.setThickness(1.75f); - left2.rotateAngleX = (float) (Math.PI / 9); - breasts3.addChild(left2); + Model2DRenderer left2 = new Model2DRenderer(base, 25f, 22, 3, 1, width, height); + left2.setTextureSize(width, height); + left2.setRotationPoint(0.8F, 4.1f, -3.18f); + left2.setScale(0.06f, 0.07f); + left2.setThickness(1.75f); + left2.rotateAngleX = (float) (Math.PI / 9); + breasts3.addChild(left2); - Model2DRenderer left3 = new Model2DRenderer(base, 25f, 24, 3, 1, width, height); - left3.setTextureSize(width, height); - left3.setRotationPoint(0.8F, 5.3f, -3.6f); - left3.setScale(0.06f, 0.07f); - left3.setThickness(1.75f); - left3.rotateAngleX = (float) (-Math.PI / 9); - breasts3.addChild(left3); + Model2DRenderer left3 = new Model2DRenderer(base, 25f, 24, 3, 1, width, height); + left3.setTextureSize(width, height); + left3.setRotationPoint(0.8F, 5.3f, -3.6f); + left3.setScale(0.06f, 0.07f); + left3.setThickness(1.75f); + left3.rotateAngleX = (float) (-Math.PI / 9); + breasts3.addChild(left3); - Model2DRenderer left4 = new Model2DRenderer(base, 24f, 22, 1, 2, width, height); - left4.setTextureSize(width, height); - left4.setRotationPoint(0.8f, 5.3f, -3.6f); - left4.setScale(0.12f, 0.14f); - left4.setThickness(1.75f); - left4.rotateAngleY = (float) (-Math.PI / 9); - breasts3.addChild(left4); - } + Model2DRenderer left4 = new Model2DRenderer(base, 24f, 22, 1, 2, width, height); + left4.setTextureSize(width, height); + left4.setRotationPoint(0.8f, 5.3f, -3.6f); + left4.setScale(0.12f, 0.14f); + left4.setThickness(1.75f); + left4.rotateAngleY = (float) (-Math.PI / 9); + breasts3.addChild(left4); + } - @Override - public void setRotationAngles(float par1, float par2, float par3, - float par4, float par5, float par6, Entity entity) { + @Override + public void setRotationAngles(float par1, float par2, float par3, + float par4, float par5, float par6, Entity entity) { - } + } - @Override - public void initData(ModelData data) { - this.isHidden = data.breasts == 0; - breasts.isHidden = data.breasts != 1; - breasts2.isHidden = data.breasts != 2; - breasts3.isHidden = data.breasts != 3; - } + @Override + public void initData(ModelData data) { + this.isHidden = data.breasts == 0; + breasts.isHidden = data.breasts != 1; + breasts2.isHidden = data.breasts != 2; + breasts3.isHidden = data.breasts != 3; + } } diff --git a/src/main/java/noppes/npcs/client/model/part/ModelClaws.java b/src/main/java/noppes/npcs/client/model/part/ModelClaws.java index 72ae93bed..36cc1bd7e 100644 --- a/src/main/java/noppes/npcs/client/model/part/ModelClaws.java +++ b/src/main/java/noppes/npcs/client/model/part/ModelClaws.java @@ -8,38 +8,36 @@ import noppes.npcs.entity.data.ModelPartData; public class ModelClaws extends ModelPartInterface { - private Model2DRenderer model; - private boolean isRight = false; + private Model2DRenderer model; + private boolean isRight = false; - public ModelClaws(ModelMPM base, boolean isRight) { - super(base); - this.isRight = isRight; - model = new Model2DRenderer(base, 0, 16, 4, 4, 64, 32); - if(isRight) - model.setRotationPoint(-2F, 14f, -2); - else - model.setRotationPoint(3F, 14f, -2); - model.rotateAngleY = (float) (Math.PI / -2); - model.setScale(0.25f); - this.addChild(model); - } + public ModelClaws(ModelMPM base, boolean isRight) { + super(base); + this.isRight = isRight; + model = new Model2DRenderer(base, 0, 16, 4, 4, 64, 32); + if (isRight) + model.setRotationPoint(-2F, 14f, -2); + else + model.setRotationPoint(3F, 14f, -2); + model.rotateAngleY = (float) (Math.PI / -2); + model.setScale(0.25f); + this.addChild(model); + } - @Override - public void initData(ModelData data) { - ModelPartData config = data.getPartData("claws"); - if(config == null || isRight && config.type == 1 || !isRight && config.type == 2) - { - isHidden = true; - return; - } - color = config.color; - isHidden = false; + @Override + public void initData(ModelData data) { + ModelPartData config = data.getPartData("claws"); + if (config == null || isRight && config.type == 1 || !isRight && config.type == 2) { + isHidden = true; + return; + } + color = config.color; + isHidden = false; - if(!config.playerTexture){ - location = config.getResource(); - } - else - location = null; - } + if (!config.playerTexture) { + location = config.getResource(); + } else + location = null; + } } diff --git a/src/main/java/noppes/npcs/client/model/part/ModelDuckBeak.java b/src/main/java/noppes/npcs/client/model/part/ModelDuckBeak.java index 5bd1b7a8e..79522a925 100644 --- a/src/main/java/noppes/npcs/client/model/part/ModelDuckBeak.java +++ b/src/main/java/noppes/npcs/client/model/part/ModelDuckBeak.java @@ -5,77 +5,76 @@ import noppes.npcs.client.model.ModelMPM; import org.lwjgl.opengl.GL11; public class ModelDuckBeak extends ModelRenderer { - ModelRenderer Top3; - ModelRenderer Top2; - ModelRenderer Bottom; - ModelRenderer Left; - ModelRenderer Right; - ModelRenderer Middle; - ModelRenderer Top; + ModelRenderer Top3; + ModelRenderer Top2; + ModelRenderer Bottom; + ModelRenderer Left; + ModelRenderer Right; + ModelRenderer Middle; + ModelRenderer Top; - public ModelDuckBeak(ModelMPM base) { - super(base); - - Top3 = new ModelRenderer(base, 14, 0); - Top3.setTextureSize(64,32); - Top3.addBox(0F, 0F, 0F, 2, 1, 3); - Top3.setRotationPoint(-1F, -2F, -5F); - setRotation(Top3, 0.3346075F, 0F, 0F); - addChild(Top3); + public ModelDuckBeak(ModelMPM base) { + super(base); - Top2 = new ModelRenderer(base, 0, 0); - Top2.setTextureSize(64,32); - Top2.addBox(0F, 0F, -0.4F, 4, 1, 3); - Top2.setRotationPoint(-2F, -3F, -2F); - setRotation(Top2, 0.3346075F, 0F, 0F); - addChild(Top2); + Top3 = new ModelRenderer(base, 14, 0); + Top3.setTextureSize(64, 32); + Top3.addBox(0F, 0F, 0F, 2, 1, 3); + Top3.setRotationPoint(-1F, -2F, -5F); + setRotation(Top3, 0.3346075F, 0F, 0F); + addChild(Top3); - Bottom = new ModelRenderer(base, 24, 0); - Bottom.setTextureSize(64,32); - Bottom.addBox(0F, 0F, 0F, 2, 1, 5); - Bottom.setRotationPoint(-1F, -1F, -5F); - addChild(Bottom); + Top2 = new ModelRenderer(base, 0, 0); + Top2.setTextureSize(64, 32); + Top2.addBox(0F, 0F, -0.4F, 4, 1, 3); + Top2.setRotationPoint(-2F, -3F, -2F); + setRotation(Top2, 0.3346075F, 0F, 0F); + addChild(Top2); - Left = new ModelRenderer(base, 0, 4); - Left.setTextureSize(64,32); - Left.mirror = true; - Left.addBox(0F, 0F, 0F, 1, 3, 2); - Left.setRotationPoint(0.98F, -3F, -2F); - addChild(Left); + Bottom = new ModelRenderer(base, 24, 0); + Bottom.setTextureSize(64, 32); + Bottom.addBox(0F, 0F, 0F, 2, 1, 5); + Bottom.setRotationPoint(-1F, -1F, -5F); + addChild(Bottom); - Right = new ModelRenderer(base, 0, 4); - Right.setTextureSize(64,32); - Right.addBox(0F, 0F, 0F, 1, 3, 2); - Right.setRotationPoint(-1.98F, -3F, -2F); - addChild(Right); + Left = new ModelRenderer(base, 0, 4); + Left.setTextureSize(64, 32); + Left.mirror = true; + Left.addBox(0F, 0F, 0F, 1, 3, 2); + Left.setRotationPoint(0.98F, -3F, -2F); + addChild(Left); - Middle = new ModelRenderer(base, 3, 0); - Middle.setTextureSize(64,32); - Middle.addBox(0F, 0F, 0F, 2, 1, 3); - Middle.setRotationPoint(-1F, -2F, -5F); - addChild(Middle); + Right = new ModelRenderer(base, 0, 4); + Right.setTextureSize(64, 32); + Right.addBox(0F, 0F, 0F, 1, 3, 2); + Right.setRotationPoint(-1.98F, -3F, -2F); + addChild(Right); - Top = new ModelRenderer(base, 6, 4); - Top.setTextureSize(64,32); - Top.addBox(0F, 0F, 0F, 2, 2, 1); - Top.setRotationPoint(-1F, -4.4F, -1F); - addChild(Top); - } - - @Override - public void render(float f) - { - GL11.glPushMatrix(); - GL11.glTranslatef(0, 0, -1f * f); - GL11.glScalef(0.82f, 0.82f, 0.70f); - super.render(f); - GL11.glPopMatrix(); + Middle = new ModelRenderer(base, 3, 0); + Middle.setTextureSize(64, 32); + Middle.addBox(0F, 0F, 0F, 2, 1, 3); + Middle.setRotationPoint(-1F, -2F, -5F); + addChild(Middle); + + Top = new ModelRenderer(base, 6, 4); + Top.setTextureSize(64, 32); + Top.addBox(0F, 0F, 0F, 2, 2, 1); + Top.setRotationPoint(-1F, -4.4F, -1F); + addChild(Top); } - private void setRotation(ModelRenderer model, float x, float y, float z) { - model.rotateAngleX = x; - model.rotateAngleY = y; - model.rotateAngleZ = z; - } + @Override + public void render(float f) { + GL11.glPushMatrix(); + GL11.glTranslatef(0, 0, -1f * f); + GL11.glScalef(0.82f, 0.82f, 0.70f); + super.render(f); + GL11.glPopMatrix(); + } + + private void setRotation(ModelRenderer model, float x, float y, float z) { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } } diff --git a/src/main/java/noppes/npcs/client/model/part/ModelEars.java b/src/main/java/noppes/npcs/client/model/part/ModelEars.java index ce9708f50..8e70c4b2e 100644 --- a/src/main/java/noppes/npcs/client/model/part/ModelEars.java +++ b/src/main/java/noppes/npcs/client/model/part/ModelEars.java @@ -8,75 +8,74 @@ import noppes.npcs.entity.data.ModelData; import noppes.npcs.entity.data.ModelPartData; public class ModelEars extends ModelPartInterface { - private ModelRenderer ears; - private ModelRenderer bunny; - public ModelEars(ModelMPM par1ModelBase) { - super(par1ModelBase); + private ModelRenderer ears; + private ModelRenderer bunny; - ears = new ModelRenderer(base); - this.addChild(ears); + public ModelEars(ModelMPM par1ModelBase) { + super(par1ModelBase); - Model2DRenderer right = new Model2DRenderer(base, 56, 0, 8, 4, 64, 32); - right.setRotationPoint(-7.44f, -7.3f, -0.0f); - right.setScale(0.234f, 0.234f); - right.setThickness(1.16f); - ears.addChild(right); + ears = new ModelRenderer(base); + this.addChild(ears); - Model2DRenderer left = new Model2DRenderer(base, 56, 0, 8, 4, 64, 32); - left.setRotationPoint(7.44f, -7.3f, 1.15f); - left.setScale(0.234f, 0.234f); - setRotation(left, 0, (float)(Math.PI), 0); + Model2DRenderer right = new Model2DRenderer(base, 56, 0, 8, 4, 64, 32); + right.setRotationPoint(-7.44f, -7.3f, -0.0f); + right.setScale(0.234f, 0.234f); + right.setThickness(1.16f); + ears.addChild(right); + + Model2DRenderer left = new Model2DRenderer(base, 56, 0, 8, 4, 64, 32); + left.setRotationPoint(7.44f, -7.3f, 1.15f); + left.setScale(0.234f, 0.234f); + setRotation(left, 0, (float) (Math.PI), 0); left.setThickness(1.16f); ears.addChild(left); - Model2DRenderer right2 = new Model2DRenderer(base, 56, 4, 8, 4, 64, 32); - right2.setRotationPoint(-7.44f, -7.3f, 1.14f); - right2.setScale(0.234f, 0.234f); - right2.setThickness(1.16f); - ears.addChild(right2); + Model2DRenderer right2 = new Model2DRenderer(base, 56, 4, 8, 4, 64, 32); + right2.setRotationPoint(-7.44f, -7.3f, 1.14f); + right2.setScale(0.234f, 0.234f); + right2.setThickness(1.16f); + ears.addChild(right2); - Model2DRenderer left2 = new Model2DRenderer(base, 56, 4, 8, 4, 64, 32); - left2.setRotationPoint(7.44f, -7.3f, 2.31f); - left2.setScale(0.234f, 0.234f); - setRotation(left2, 0, (float)(Math.PI), 0); + Model2DRenderer left2 = new Model2DRenderer(base, 56, 4, 8, 4, 64, 32); + left2.setRotationPoint(7.44f, -7.3f, 2.31f); + left2.setScale(0.234f, 0.234f); + setRotation(left2, 0, (float) (Math.PI), 0); left2.setThickness(1.16f); ears.addChild(left2); - bunny = new ModelRenderer(base); - this.addChild(bunny); + bunny = new ModelRenderer(base); + this.addChild(bunny); - ModelRenderer earleft = new ModelRenderer(base, 56, 0); - earleft.mirror = true; - earleft.addBox(-1.466667F, -4F, 0F, 3, 7, 1); - earleft.setRotationPoint(2.533333F, -11F, 0F); - bunny.addChild(earleft); + ModelRenderer earleft = new ModelRenderer(base, 56, 0); + earleft.mirror = true; + earleft.addBox(-1.466667F, -4F, 0F, 3, 7, 1); + earleft.setRotationPoint(2.533333F, -11F, 0F); + bunny.addChild(earleft); - ModelRenderer earright = new ModelRenderer(base, 56, 0); - earright.addBox(-1.5F, -4F, 0F, 3, 7, 1); - earright.setRotationPoint(-2.466667F, -11F, 0F); - bunny.addChild(earright); - } + ModelRenderer earright = new ModelRenderer(base, 56, 0); + earright.addBox(-1.5F, -4F, 0F, 3, 7, 1); + earright.setRotationPoint(-2.466667F, -11F, 0F); + bunny.addChild(earright); + } - @Override - public void initData(ModelData data) { - ModelPartData config = data.getPartData("ears"); - if(config == null) - { - isHidden = true; - return; - } - isHidden = false; - this.color = config.color; + @Override + public void initData(ModelData data) { + ModelPartData config = data.getPartData("ears"); + if (config == null) { + isHidden = true; + return; + } + isHidden = false; + this.color = config.color; - ears.isHidden = config.type != 0; - bunny.isHidden = config.type != 1; + ears.isHidden = config.type != 0; + bunny.isHidden = config.type != 1; - if(!config.playerTexture){ - location = config.getResource(); - } - else - location = null; - } + if (!config.playerTexture) { + location = config.getResource(); + } else + location = null; + } } diff --git a/src/main/java/noppes/npcs/client/model/part/ModelFin.java b/src/main/java/noppes/npcs/client/model/part/ModelFin.java index 0bf398ea0..3bf5ec535 100644 --- a/src/main/java/noppes/npcs/client/model/part/ModelFin.java +++ b/src/main/java/noppes/npcs/client/model/part/ModelFin.java @@ -8,33 +8,31 @@ import noppes.npcs.entity.data.ModelPartData; public class ModelFin extends ModelPartInterface { - private Model2DRenderer model; + private Model2DRenderer model; - public ModelFin(ModelMPM base) { - super(base); - model = new Model2DRenderer(base, 48, 8, 16, 24, 64, 32); - model.setRotationPoint(-0.5F, 12, 10); - model.setScale(0.74f); - model.rotateAngleY = (float)Math.PI / 2; - this.addChild(model); - } + public ModelFin(ModelMPM base) { + super(base); + model = new Model2DRenderer(base, 48, 8, 16, 24, 64, 32); + model.setRotationPoint(-0.5F, 12, 10); + model.setScale(0.74f); + model.rotateAngleY = (float) Math.PI / 2; + this.addChild(model); + } - @Override - public void initData(ModelData data) { - ModelPartData config = data.getPartData("fin"); - if(config == null) - { - isHidden = true; - return; - } - color = config.color; - isHidden = false; + @Override + public void initData(ModelData data) { + ModelPartData config = data.getPartData("fin"); + if (config == null) { + isHidden = true; + return; + } + color = config.color; + isHidden = false; - if(!config.playerTexture){ - location = config.getResource(); - } - else - location = null; - } + if (!config.playerTexture) { + location = config.getResource(); + } else + location = null; + } } diff --git a/src/main/java/noppes/npcs/client/model/part/ModelHair.java b/src/main/java/noppes/npcs/client/model/part/ModelHair.java index 8dd20e0b1..9ea59830e 100644 --- a/src/main/java/noppes/npcs/client/model/part/ModelHair.java +++ b/src/main/java/noppes/npcs/client/model/part/ModelHair.java @@ -9,49 +9,46 @@ import noppes.npcs.entity.data.ModelData; import noppes.npcs.entity.data.ModelPartData; public class ModelHair extends ModelPartInterface { - private Model2DRenderer model; + private Model2DRenderer model; - public ModelHair(ModelMPM base) { - super(base); - model = new Model2DRenderer(base, 56, 20, 8, 12, 64, 32); - model.setRotationPoint(-4F, 12, 3); - model.setScale(0.75f); - addChild(model); - } + public ModelHair(ModelMPM base) { + super(base); + model = new Model2DRenderer(base, 56, 20, 8, 12, 64, 32); + model.setRotationPoint(-4F, 12, 3); + model.setScale(0.75f); + addChild(model); + } - @Override - public void setRotationAngles(float par1, float par2, float par3, - float par4, float par5, float par6, Entity entity) { - ModelRenderer parent = this.base.bipedHead; - if(parent.rotateAngleX < 0){ - rotateAngleX = -parent.rotateAngleX * 1.2f; - if(parent.rotateAngleX > -1){ - rotationPointY = -parent.rotateAngleX * 1.5f; - rotationPointZ = -parent.rotateAngleX * 1.5f; - } - } - else{ - rotateAngleX = 0; - rotationPointY = 0; - rotationPointZ = 0; - } - } + @Override + public void setRotationAngles(float par1, float par2, float par3, + float par4, float par5, float par6, Entity entity) { + ModelRenderer parent = this.base.bipedHead; + if (parent.rotateAngleX < 0) { + rotateAngleX = -parent.rotateAngleX * 1.2f; + if (parent.rotateAngleX > -1) { + rotationPointY = -parent.rotateAngleX * 1.5f; + rotationPointZ = -parent.rotateAngleX * 1.5f; + } + } else { + rotateAngleX = 0; + rotationPointY = 0; + rotationPointZ = 0; + } + } - @Override - public void initData(ModelData data) { - ModelPartData config = data.getPartData("hair"); - if(config == null) - { - isHidden = true; - return; - } - this.color = config.color; - isHidden = false; - if(!config.playerTexture){ - location = config.getResource(); - } - else - location = null; - } + @Override + public void initData(ModelData data) { + ModelPartData config = data.getPartData("hair"); + if (config == null) { + isHidden = true; + return; + } + this.color = config.color; + isHidden = false; + if (!config.playerTexture) { + location = config.getResource(); + } else + location = null; + } } diff --git a/src/main/java/noppes/npcs/client/model/part/ModelHeadwear.java b/src/main/java/noppes/npcs/client/model/part/ModelHeadwear.java index bed9137a8..524121be5 100644 --- a/src/main/java/noppes/npcs/client/model/part/ModelHeadwear.java +++ b/src/main/java/noppes/npcs/client/model/part/ModelHeadwear.java @@ -5,102 +5,102 @@ import net.minecraft.client.model.ModelRenderer; import noppes.npcs.client.model.util.Model2DRenderer; import noppes.npcs.client.model.util.ModelScaleRenderer; -public class ModelHeadwear extends ModelScaleRenderer{ +public class ModelHeadwear extends ModelScaleRenderer { - public ModelHeadwear(ModelBase base) { - super(base); - Model2DRenderer right = new Model2DRenderer(base, 32, 8, 8, 8, 64, 64); - right.setRotationPoint(-4.641F, .8f, 4.64f); - right.setScale(0.58f); - right.setThickness(0.65f); - setRotation(right, 0, (float)(Math.PI/2f), 0); - this.addChild(right); + public ModelHeadwear(ModelBase base) { + super(base); + Model2DRenderer right = new Model2DRenderer(base, 32, 8, 8, 8, 64, 64); + right.setRotationPoint(-4.641F, .8f, 4.64f); + right.setScale(0.58f); + right.setThickness(0.65f); + setRotation(right, 0, (float) (Math.PI / 2f), 0); + this.addChild(right); - Model2DRenderer left = new Model2DRenderer(base, 48, 8, 8, 8, 64, 64); - left.setRotationPoint(4.639F, .8f, -4.64f); - left.setScale(0.58f); - left.setThickness(0.65f); - setRotation(left, 0, (float)(Math.PI/-2f), 0); - this.addChild(left); + Model2DRenderer left = new Model2DRenderer(base, 48, 8, 8, 8, 64, 64); + left.setRotationPoint(4.639F, .8f, -4.64f); + left.setScale(0.58f); + left.setThickness(0.65f); + setRotation(left, 0, (float) (Math.PI / -2f), 0); + this.addChild(left); - Model2DRenderer front = new Model2DRenderer(base, 40, 8, 8, 8, 64, 64); - front.setRotationPoint(-4.64F, .801f, -4.641f); - front.setScale(0.58f); - front.setThickness(0.65f); - setRotation(front, 0, 0, 0); - this.addChild(front); + Model2DRenderer front = new Model2DRenderer(base, 40, 8, 8, 8, 64, 64); + front.setRotationPoint(-4.64F, .801f, -4.641f); + front.setScale(0.58f); + front.setThickness(0.65f); + setRotation(front, 0, 0, 0); + this.addChild(front); - Model2DRenderer back = new Model2DRenderer(base, 56, 8, 8, 8, 64, 64); - back.setRotationPoint(4.64F, .801f, 4.639f); - back.setScale(0.58f); - back.setThickness(0.65f); - setRotation(back, 0, (float)(Math.PI), 0); - this.addChild(back); + Model2DRenderer back = new Model2DRenderer(base, 56, 8, 8, 8, 64, 64); + back.setRotationPoint(4.64F, .801f, 4.639f); + back.setScale(0.58f); + back.setThickness(0.65f); + setRotation(back, 0, (float) (Math.PI), 0); + this.addChild(back); - Model2DRenderer top = new Model2DRenderer(base, 40, 0, 8, 8, 64, 64); - top.setRotationPoint(-4.64F, -8.5f, -4.64f); - top.setScale(0.5799f); - top.setThickness(0.65f); - setRotation(top, (float)(Math.PI / -2), 0, 0); - this.addChild(top); + Model2DRenderer top = new Model2DRenderer(base, 40, 0, 8, 8, 64, 64); + top.setRotationPoint(-4.64F, -8.5f, -4.64f); + top.setScale(0.5799f); + top.setThickness(0.65f); + setRotation(top, (float) (Math.PI / -2), 0, 0); + this.addChild(top); - Model2DRenderer bottom = new Model2DRenderer(base, 48, 0, 8, 8, 64, 64); - bottom.setRotationPoint(-4.64F, 0f, -4.64f); - bottom.setScale(0.5799f); - bottom.setThickness(0.65f); - setRotation(bottom, (float)(Math.PI / -2), 0, 0); - this.addChild(bottom); - } + Model2DRenderer bottom = new Model2DRenderer(base, 48, 0, 8, 8, 64, 64); + bottom.setRotationPoint(-4.64F, 0f, -4.64f); + bottom.setScale(0.5799f); + bottom.setThickness(0.65f); + setRotation(bottom, (float) (Math.PI / -2), 0, 0); + this.addChild(bottom); + } - public ModelHeadwear(ModelBase base, boolean steve32) { - super(base); - Model2DRenderer right = new Model2DRenderer(base, 32, 8, 8, 8, 64, 32); - right.setRotationPoint(-4.641F, .8f, 4.64f); - right.setScale(0.58f); - right.setThickness(0.65f); - setRotation(right, 0, (float)(Math.PI/2f), 0); - this.addChild(right); + public ModelHeadwear(ModelBase base, boolean steve32) { + super(base); + Model2DRenderer right = new Model2DRenderer(base, 32, 8, 8, 8, 64, 32); + right.setRotationPoint(-4.641F, .8f, 4.64f); + right.setScale(0.58f); + right.setThickness(0.65f); + setRotation(right, 0, (float) (Math.PI / 2f), 0); + this.addChild(right); - Model2DRenderer left = new Model2DRenderer(base, 48, 8, 8, 8, 64, 32); - left.setRotationPoint(4.639F, .8f, -4.64f); - left.setScale(0.58f); - left.setThickness(0.65f); - setRotation(left, 0, (float)(Math.PI/-2f), 0); - this.addChild(left); + Model2DRenderer left = new Model2DRenderer(base, 48, 8, 8, 8, 64, 32); + left.setRotationPoint(4.639F, .8f, -4.64f); + left.setScale(0.58f); + left.setThickness(0.65f); + setRotation(left, 0, (float) (Math.PI / -2f), 0); + this.addChild(left); - Model2DRenderer front = new Model2DRenderer(base, 40, 8, 8, 8, 64, 32); - front.setRotationPoint(-4.64F, .801f, -4.641f); - front.setScale(0.58f); - front.setThickness(0.65f); - setRotation(front, 0, 0, 0); - this.addChild(front); + Model2DRenderer front = new Model2DRenderer(base, 40, 8, 8, 8, 64, 32); + front.setRotationPoint(-4.64F, .801f, -4.641f); + front.setScale(0.58f); + front.setThickness(0.65f); + setRotation(front, 0, 0, 0); + this.addChild(front); - Model2DRenderer back = new Model2DRenderer(base, 56, 8, 8, 8, 64, 32); - back.setRotationPoint(4.64F, .801f, 4.639f); - back.setScale(0.58f); - back.setThickness(0.65f); - setRotation(back, 0, (float)(Math.PI), 0); - this.addChild(back); + Model2DRenderer back = new Model2DRenderer(base, 56, 8, 8, 8, 64, 32); + back.setRotationPoint(4.64F, .801f, 4.639f); + back.setScale(0.58f); + back.setThickness(0.65f); + setRotation(back, 0, (float) (Math.PI), 0); + this.addChild(back); - Model2DRenderer top = new Model2DRenderer(base, 40, 0, 8, 8, 64, 32); - top.setRotationPoint(-4.64F, -8.5f, -4.64f); - top.setScale(0.5799f); - top.setThickness(0.65f); - setRotation(top, (float)(Math.PI / -2), 0, 0); - this.addChild(top); + Model2DRenderer top = new Model2DRenderer(base, 40, 0, 8, 8, 64, 32); + top.setRotationPoint(-4.64F, -8.5f, -4.64f); + top.setScale(0.5799f); + top.setThickness(0.65f); + setRotation(top, (float) (Math.PI / -2), 0, 0); + this.addChild(top); - Model2DRenderer bottom = new Model2DRenderer(base, 48, 0, 8, 8, 64, 32); - bottom.setRotationPoint(-4.64F, 0f, -4.64f); - bottom.setScale(0.5799f); - bottom.setThickness(0.65f); - setRotation(bottom, (float)(Math.PI / -2), 0, 0); - this.addChild(bottom); - } + Model2DRenderer bottom = new Model2DRenderer(base, 48, 0, 8, 8, 64, 32); + bottom.setRotationPoint(-4.64F, 0f, -4.64f); + bottom.setScale(0.5799f); + bottom.setThickness(0.65f); + setRotation(bottom, (float) (Math.PI / -2), 0, 0); + this.addChild(bottom); + } + + public void setRotation(ModelRenderer model, float x, float y, float z) { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } - public void setRotation(ModelRenderer model, float x, float y, float z) { - model.rotateAngleX = x; - model.rotateAngleY = y; - model.rotateAngleZ = z; - } - } diff --git a/src/main/java/noppes/npcs/client/model/part/ModelHorns.java b/src/main/java/noppes/npcs/client/model/part/ModelHorns.java index 4390d1603..8f96c4be2 100644 --- a/src/main/java/noppes/npcs/client/model/part/ModelHorns.java +++ b/src/main/java/noppes/npcs/client/model/part/ModelHorns.java @@ -12,46 +12,44 @@ import noppes.npcs.entity.data.ModelData; import noppes.npcs.entity.data.ModelPartData; public class ModelHorns extends ModelPartInterface { - private ModelRenderer bull; - private ModelRenderer antlers; - private ModelRenderer antennasBack; - private ModelRenderer antennasFront; + private ModelRenderer bull; + private ModelRenderer antlers; + private ModelRenderer antennasBack; + private ModelRenderer antennasFront; - public ModelHorns(ModelMPM base) { - super(base); + public ModelHorns(ModelMPM base) { + super(base); - this.addChild(bull = new ModelBullHorns(base)); - this.addChild(antlers = new ModelAntlerHorns(base)); - this.addChild(antennasBack = new ModelAntennasBack(base)); - this.addChild(antennasFront = new ModelAntennasFront(base)); - } + this.addChild(bull = new ModelBullHorns(base)); + this.addChild(antlers = new ModelAntlerHorns(base)); + this.addChild(antennasBack = new ModelAntennasBack(base)); + this.addChild(antennasFront = new ModelAntennasFront(base)); + } - @Override - public void setRotationAngles(float par1, float par2, float par3, - float par4, float par5, float par6, Entity entity) { + @Override + public void setRotationAngles(float par1, float par2, float par3, + float par4, float par5, float par6, Entity entity) { - } + } - @Override - public void initData(ModelData data) { - ModelPartData config = data.getPartData("horns"); - if(config == null) - { - isHidden = true; - return; - } - color = config.color; - isHidden = false; + @Override + public void initData(ModelData data) { + ModelPartData config = data.getPartData("horns"); + if (config == null) { + isHidden = true; + return; + } + color = config.color; + isHidden = false; - bull.isHidden = config.type != 0; - antlers.isHidden = config.type != 1; - antennasBack.isHidden = config.type != 2; - antennasFront.isHidden = config.type != 3; + bull.isHidden = config.type != 0; + antlers.isHidden = config.type != 1; + antennasBack.isHidden = config.type != 2; + antennasFront.isHidden = config.type != 3; - if(!config.playerTexture){ - location = config.getResource(); - } - else - location = null; - } + if (!config.playerTexture) { + location = config.getResource(); + } else + location = null; + } } diff --git a/src/main/java/noppes/npcs/client/model/part/ModelLegs.java b/src/main/java/noppes/npcs/client/model/part/ModelLegs.java index 191833e04..aa1e4ed48 100644 --- a/src/main/java/noppes/npcs/client/model/part/ModelLegs.java +++ b/src/main/java/noppes/npcs/client/model/part/ModelLegs.java @@ -16,17 +16,17 @@ import noppes.npcs.entity.EntityCustomNpc; import noppes.npcs.entity.data.ModelPartData; import org.lwjgl.opengl.GL11; -public class ModelLegs extends ModelScaleRenderer{ - private EntityCustomNpc entity; - private ModelScaleRenderer leg1, leg2; - private ModelRenderer spider; - private ModelRenderer horse; - private ModelNagaLegs naga; - private ModelDigitigradeLegs digitigrade; - private ModelMermaidLegs mermaid; - private ModelMermaidLegs2 mermaid2; +public class ModelLegs extends ModelScaleRenderer { + private EntityCustomNpc entity; + private ModelScaleRenderer leg1, leg2; + private ModelRenderer spider; + private ModelRenderer horse; + private ModelNagaLegs naga; + private ModelDigitigradeLegs digitigrade; + private ModelMermaidLegs mermaid; + private ModelMermaidLegs2 mermaid2; - private ModelRenderer spiderLeg1; + private ModelRenderer spiderLeg1; private ModelRenderer spiderLeg2; private ModelRenderer spiderLeg3; private ModelRenderer spiderLeg4; @@ -55,78 +55,78 @@ public class ModelLegs extends ModelScaleRenderer{ private ModelMPM base; - public ModelLegs(ModelMPM base, ModelScaleRenderer leg1, ModelScaleRenderer leg2, int textWidth, int textHeight) { - super(base); + public ModelLegs(ModelMPM base, ModelScaleRenderer leg1, ModelScaleRenderer leg2, int textWidth, int textHeight) { + super(base); - this.base = base; - this.leg1 = leg1; - this.leg2 = leg2; + this.base = base; + this.leg1 = leg1; + this.leg2 = leg2; - if(base.isArmor) - return; - spider = new ModelRenderer(base); + if (base.isArmor) + return; + spider = new ModelRenderer(base); this.addChild(spider); float var1 = 0.0F; byte var2 = 15; spiderNeck = new ModelRenderer(base, 0, 0); - spiderNeck.setTextureSize(64,32); + spiderNeck.setTextureSize(64, 32); spiderNeck.addBox(-3.0F, -3.0F, -3.0F, 6, 6, 6, var1); - spiderNeck.setRotationPoint(0.0F, (float)var2, 2.0F); + spiderNeck.setRotationPoint(0.0F, (float) var2, 2.0F); spider.addChild(spiderNeck); spiderBody = new ModelRenderer(base, 0, 12); - spiderBody.setTextureSize(64,32); + spiderBody.setTextureSize(64, 32); spiderBody.addBox(-5.0F, -4.0F, -6.0F, 10, 8, 12, var1); - spiderBody.setRotationPoint(0.0F, (float)var2, 11.0F); + spiderBody.setRotationPoint(0.0F, (float) var2, 11.0F); spider.addChild(spiderBody); this.spiderLeg1 = new ModelRenderer(base, 18, 0); - this.spiderLeg1.setTextureSize(64,32); + this.spiderLeg1.setTextureSize(64, 32); this.spiderLeg1.addBox(-15.0F, -1.0F, -1.0F, 16, 2, 2, var1); - this.spiderLeg1.setRotationPoint(-4.0F, (float)var2, 4.0F); + this.spiderLeg1.setRotationPoint(-4.0F, (float) var2, 4.0F); spider.addChild(spiderLeg1); this.spiderLeg2 = new ModelRenderer(base, 18, 0); - this.spiderLeg2.setTextureSize(64,32); + this.spiderLeg2.setTextureSize(64, 32); this.spiderLeg2.addBox(-1.0F, -1.0F, -1.0F, 16, 2, 2, var1); - this.spiderLeg2.setRotationPoint(4.0F, (float)var2, 4.0F); + this.spiderLeg2.setRotationPoint(4.0F, (float) var2, 4.0F); spider.addChild(spiderLeg2); this.spiderLeg3 = new ModelRenderer(base, 18, 0); - this.spiderLeg3.setTextureSize(64,32); + this.spiderLeg3.setTextureSize(64, 32); this.spiderLeg3.addBox(-15.0F, -1.0F, -1.0F, 16, 2, 2, var1); - this.spiderLeg3.setRotationPoint(-4.0F, (float)var2, 3.0F); + this.spiderLeg3.setRotationPoint(-4.0F, (float) var2, 3.0F); spider.addChild(spiderLeg3); this.spiderLeg4 = new ModelRenderer(base, 18, 0); - this.spiderLeg4.setTextureSize(64,32); + this.spiderLeg4.setTextureSize(64, 32); this.spiderLeg4.addBox(-1.0F, -1.0F, -1.0F, 16, 2, 2, var1); - this.spiderLeg4.setRotationPoint(4.0F, (float)var2, 3.0F); + this.spiderLeg4.setRotationPoint(4.0F, (float) var2, 3.0F); spider.addChild(spiderLeg4); this.spiderLeg5 = new ModelRenderer(base, 18, 0); - this.spiderLeg5.setTextureSize(64,32); + this.spiderLeg5.setTextureSize(64, 32); this.spiderLeg5.addBox(-15.0F, -1.0F, -1.0F, 16, 2, 2, var1); - this.spiderLeg5.setRotationPoint(-4.0F, (float)var2, 2.0F); + this.spiderLeg5.setRotationPoint(-4.0F, (float) var2, 2.0F); spider.addChild(spiderLeg5); this.spiderLeg6 = new ModelRenderer(base, 18, 0); - this.spiderLeg6.setTextureSize(64,32); + this.spiderLeg6.setTextureSize(64, 32); this.spiderLeg6.addBox(-1.0F, -1.0F, -1.0F, 16, 2, 2, var1); - this.spiderLeg6.setRotationPoint(4.0F, (float)var2, 2.0F); + this.spiderLeg6.setRotationPoint(4.0F, (float) var2, 2.0F); spider.addChild(spiderLeg6); this.spiderLeg7 = new ModelRenderer(base, 18, 0); - this.spiderLeg7.setTextureSize(64,32); + this.spiderLeg7.setTextureSize(64, 32); this.spiderLeg7.addBox(-15.0F, -1.0F, -1.0F, 16, 2, 2, var1); - this.spiderLeg7.setRotationPoint(-4.0F, (float)var2, 1.0F); + this.spiderLeg7.setRotationPoint(-4.0F, (float) var2, 1.0F); spider.addChild(spiderLeg7); this.spiderLeg8 = new ModelRenderer(base, 18, 0); - this.spiderLeg8.setTextureSize(64,32); + this.spiderLeg8.setTextureSize(64, 32); this.spiderLeg8.addBox(-1.0F, -1.0F, -1.0F, 16, 2, 2, var1); - this.spiderLeg8.setRotationPoint(4.0F, (float)var2, 1.0F); + this.spiderLeg8.setRotationPoint(4.0F, (float) var2, 1.0F); spider.addChild(spiderLeg8); @@ -205,118 +205,116 @@ public class ModelLegs extends ModelScaleRenderer{ this.frontRightHoof.setRotationPoint(0F, 7, 0); frontRightLeg.addChild(frontRightHoof); - naga = new ModelNagaLegs(base); + naga = new ModelNagaLegs(base); this.addChild(naga); // Add Mermaid Legs - mermaid = new ModelMermaidLegs(base); - mermaid2 = new ModelMermaidLegs2(base); + mermaid = new ModelMermaidLegs(base); + mermaid2 = new ModelMermaidLegs2(base); this.addChild(mermaid); - this.addChild(mermaid2); + this.addChild(mermaid2); - boolean mirror = false; - if(textHeight != textWidth){ + boolean mirror = false; + if (textHeight != textWidth) { mirror = true; } - digitigrade = new ModelDigitigradeLegs(base, mirror, textWidth, textHeight); + digitigrade = new ModelDigitigradeLegs(base, mirror, textWidth, textHeight); this.addChild(digitigrade); - } - public void setRotation(ModelRenderer model, float x, float y, float z) { - model.rotateAngleX = x; - model.rotateAngleY = y; - model.rotateAngleZ = z; - } - public void setRotationAngles(float par1, float par2, float par3, float par4, float par5, float par6, Entity entity) - { - if(this.entity==null) return; + } - ModelPartData part = this.entity.modelData.legParts; - rotationPointZ = 0; - rotationPointY = 0; + public void setRotation(ModelRenderer model, float x, float y, float z) { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } - if(base.isArmor) - return; - if(part.type == 2){ - this.rotateAngleX = 0; - spiderBody.rotationPointY = 15; - spiderBody.rotationPointZ = 11; - spiderNeck.rotateAngleX = 0; + public void setRotationAngles(float par1, float par2, float par3, float par4, float par5, float par6, Entity entity) { + if (this.entity == null) return; - float var8 = ((float)Math.PI / 4F); - this.spiderLeg1.rotateAngleZ = -var8; - this.spiderLeg2.rotateAngleZ = var8; - this.spiderLeg3.rotateAngleZ = -var8 * 0.74F; - this.spiderLeg4.rotateAngleZ = var8 * 0.74F; - this.spiderLeg5.rotateAngleZ = -var8 * 0.74F; - this.spiderLeg6.rotateAngleZ = var8 * 0.74F; - this.spiderLeg7.rotateAngleZ = -var8; - this.spiderLeg8.rotateAngleZ = var8; - float var9 = -0.0F; - float var10 = 0.3926991F; - this.spiderLeg1.rotateAngleY = var10 * 2.0F + var9; - this.spiderLeg2.rotateAngleY = -var10 * 2.0F - var9; - this.spiderLeg3.rotateAngleY = var10 * 1.0F + var9; - this.spiderLeg4.rotateAngleY = -var10 * 1.0F - var9; - this.spiderLeg5.rotateAngleY = -var10 * 1.0F + var9; - this.spiderLeg6.rotateAngleY = var10 * 1.0F - var9; - this.spiderLeg7.rotateAngleY = -var10 * 2.0F + var9; - this.spiderLeg8.rotateAngleY = var10 * 2.0F - var9; - float var11 = -(MathHelper.cos(par1 * 0.6662F * 2.0F + 0.0F) * 0.4F) * par2; - float var12 = -(MathHelper.cos(par1 * 0.6662F * 2.0F + (float)Math.PI) * 0.4F) * par2; - float var13 = -(MathHelper.cos(par1 * 0.6662F * 2.0F + ((float)Math.PI / 2F)) * 0.4F) * par2; - float var14 = -(MathHelper.cos(par1 * 0.6662F * 2.0F + ((float)Math.PI * 3F / 2F)) * 0.4F) * par2; - float var15 = Math.abs(MathHelper.sin(par1 * 0.6662F + 0.0F) * 0.4F) * par2; - float var16 = Math.abs(MathHelper.sin(par1 * 0.6662F + (float)Math.PI) * 0.4F) * par2; - float var17 = Math.abs(MathHelper.sin(par1 * 0.6662F + ((float)Math.PI / 2F)) * 0.4F) * par2; - float var18 = Math.abs(MathHelper.sin(par1 * 0.6662F + ((float)Math.PI * 3F / 2F)) * 0.4F) * par2; - this.spiderLeg1.rotateAngleY += var11; - this.spiderLeg2.rotateAngleY += -var11; - this.spiderLeg3.rotateAngleY += var12; - this.spiderLeg4.rotateAngleY += -var12; - this.spiderLeg5.rotateAngleY += var13; - this.spiderLeg6.rotateAngleY += -var13; - this.spiderLeg7.rotateAngleY += var14; - this.spiderLeg8.rotateAngleY += -var14; - this.spiderLeg1.rotateAngleZ += var15; - this.spiderLeg2.rotateAngleZ += -var15; - this.spiderLeg3.rotateAngleZ += var16; - this.spiderLeg4.rotateAngleZ += -var16; - this.spiderLeg5.rotateAngleZ += var17; - this.spiderLeg6.rotateAngleZ += -var17; - this.spiderLeg7.rotateAngleZ += var18; - this.spiderLeg8.rotateAngleZ += -var18; + ModelPartData part = this.entity.modelData.legParts; + rotationPointZ = 0; + rotationPointY = 0; + + if (base.isArmor) + return; + if (part.type == 2) { + this.rotateAngleX = 0; + spiderBody.rotationPointY = 15; + spiderBody.rotationPointZ = 11; + spiderNeck.rotateAngleX = 0; + + float var8 = ((float) Math.PI / 4F); + this.spiderLeg1.rotateAngleZ = -var8; + this.spiderLeg2.rotateAngleZ = var8; + this.spiderLeg3.rotateAngleZ = -var8 * 0.74F; + this.spiderLeg4.rotateAngleZ = var8 * 0.74F; + this.spiderLeg5.rotateAngleZ = -var8 * 0.74F; + this.spiderLeg6.rotateAngleZ = var8 * 0.74F; + this.spiderLeg7.rotateAngleZ = -var8; + this.spiderLeg8.rotateAngleZ = var8; + float var9 = -0.0F; + float var10 = 0.3926991F; + this.spiderLeg1.rotateAngleY = var10 * 2.0F + var9; + this.spiderLeg2.rotateAngleY = -var10 * 2.0F - var9; + this.spiderLeg3.rotateAngleY = var10 * 1.0F + var9; + this.spiderLeg4.rotateAngleY = -var10 * 1.0F - var9; + this.spiderLeg5.rotateAngleY = -var10 * 1.0F + var9; + this.spiderLeg6.rotateAngleY = var10 * 1.0F - var9; + this.spiderLeg7.rotateAngleY = -var10 * 2.0F + var9; + this.spiderLeg8.rotateAngleY = var10 * 2.0F - var9; + float var11 = -(MathHelper.cos(par1 * 0.6662F * 2.0F + 0.0F) * 0.4F) * par2; + float var12 = -(MathHelper.cos(par1 * 0.6662F * 2.0F + (float) Math.PI) * 0.4F) * par2; + float var13 = -(MathHelper.cos(par1 * 0.6662F * 2.0F + ((float) Math.PI / 2F)) * 0.4F) * par2; + float var14 = -(MathHelper.cos(par1 * 0.6662F * 2.0F + ((float) Math.PI * 3F / 2F)) * 0.4F) * par2; + float var15 = Math.abs(MathHelper.sin(par1 * 0.6662F + 0.0F) * 0.4F) * par2; + float var16 = Math.abs(MathHelper.sin(par1 * 0.6662F + (float) Math.PI) * 0.4F) * par2; + float var17 = Math.abs(MathHelper.sin(par1 * 0.6662F + ((float) Math.PI / 2F)) * 0.4F) * par2; + float var18 = Math.abs(MathHelper.sin(par1 * 0.6662F + ((float) Math.PI * 3F / 2F)) * 0.4F) * par2; + this.spiderLeg1.rotateAngleY += var11; + this.spiderLeg2.rotateAngleY += -var11; + this.spiderLeg3.rotateAngleY += var12; + this.spiderLeg4.rotateAngleY += -var12; + this.spiderLeg5.rotateAngleY += var13; + this.spiderLeg6.rotateAngleY += -var13; + this.spiderLeg7.rotateAngleY += var14; + this.spiderLeg8.rotateAngleY += -var14; + this.spiderLeg1.rotateAngleZ += var15; + this.spiderLeg2.rotateAngleZ += -var15; + this.spiderLeg3.rotateAngleZ += var16; + this.spiderLeg4.rotateAngleZ += -var16; + this.spiderLeg5.rotateAngleZ += var17; + this.spiderLeg6.rotateAngleZ += -var17; + this.spiderLeg7.rotateAngleZ += var18; + this.spiderLeg8.rotateAngleZ += -var18; - if(base.isSneak){ - rotationPointZ = 5; - rotationPointY = -1; - spiderBody.rotationPointY = 16; - spiderBody.rotationPointZ = 10; - spiderNeck.rotateAngleX = (float) (Math.PI / -8); - } - if(base.isSleeping(entity) || this.entity.currentAnimation == EnumAnimation.CRAWLING){ - rotationPointY = 12 * this.entity.modelData.modelScale.legs.scaleY; - rotationPointZ = 15 * this.entity.modelData.modelScale.legs.scaleY; + if (base.isSneak) { + rotationPointZ = 5; + rotationPointY = -1; + spiderBody.rotationPointY = 16; + spiderBody.rotationPointZ = 10; + spiderNeck.rotateAngleX = (float) (Math.PI / -8); + } + if (base.isSleeping(entity) || this.entity.currentAnimation == EnumAnimation.CRAWLING) { + rotationPointY = 12 * this.entity.modelData.modelScale.legs.scaleY; + rotationPointZ = 15 * this.entity.modelData.modelScale.legs.scaleY; - this.rotateAngleX = (float) (Math.PI / -2); - } - } - else if(part.type == 3){ + this.rotateAngleX = (float) (Math.PI / -2); + } + } else if (part.type == 3) { this.frontLeftLeg.rotateAngleX = MathHelper.cos(par1 * 0.6662F) * .4F * par2; - this.frontRightLeg.rotateAngleX = MathHelper.cos(par1 * 0.6662F + (float)Math.PI) * .4F * par2; - this.backLeftLeg.rotateAngleX = MathHelper.cos(par1 * 0.6662F + (float)Math.PI) * .4F * par2; + this.frontRightLeg.rotateAngleX = MathHelper.cos(par1 * 0.6662F + (float) Math.PI) * .4F * par2; + this.backLeftLeg.rotateAngleX = MathHelper.cos(par1 * 0.6662F + (float) Math.PI) * .4F * par2; this.backRightLeg.rotateAngleX = MathHelper.cos(par1 * 0.6662F) * .4F * par2; - } - else if(part.type == 1){ - naga.isRiding = base.isRiding; - naga.isSleeping = base.isSleeping(entity); - naga.isCrawling = this.entity.currentAnimation == EnumAnimation.CRAWLING; - naga.isSneaking = base.isSneak; - naga.setRotationAngles(par1, par2, par3, par4, par5, par6, entity); - } - else if(part.type == 4 || part.type == 6){ + } else if (part.type == 1) { + naga.isRiding = base.isRiding; + naga.isSleeping = base.isSleeping(entity); + naga.isCrawling = this.entity.currentAnimation == EnumAnimation.CRAWLING; + naga.isSneaking = base.isSneak; + naga.setRotationAngles(par1, par2, par3, par4, par5, par6, entity); + } else if (part.type == 4 || part.type == 6) { mermaid.isRiding = base.isRiding; mermaid.isSleeping = base.isSleeping(entity); mermaid.isCrawling = this.entity.currentAnimation == EnumAnimation.CRAWLING; @@ -327,82 +325,77 @@ public class ModelLegs extends ModelScaleRenderer{ mermaid2.isSneaking = base.isSneak; mermaid.setRotationAngles(par1, par2, par3, par4, par5, par6, entity); mermaid2.setRotationAngles(par1, par2, par3, par4, par5, par6, entity); + } else if (part.type == 5) { + digitigrade.setRotationAngles(par1, par2, par3, par4, par5, par6, entity); } - else if(part.type == 5){ - digitigrade.setRotationAngles(par1, par2, par3, par4, par5, par6, entity); - } } - @Override - public void render(float par1) - { - if(!showModel || isHidden) - return; - ModelPartData part = entity.modelData.legParts; - if(part.type < 0) - return; - GL11.glPushMatrix(); - if(part.type == 4) - part.playerTexture = false; - if(!base.isArmor){ - if(!part.playerTexture){ - ClientProxy.bindTexture(part.getResource()); - base.currentlyPlayerTexture = false; - } - else if(!base.currentlyPlayerTexture){ - ClientProxy.bindTexture(entity.textureLocation); - base.currentlyPlayerTexture = true; - } - } - if(part.type == 0){ + @Override + public void render(float par1) { + if (!showModel || isHidden) + return; + ModelPartData part = entity.modelData.legParts; + if (part.type < 0) + return; + GL11.glPushMatrix(); + if (part.type == 4) + part.playerTexture = false; + if (!base.isArmor) { + if (!part.playerTexture) { + ClientProxy.bindTexture(part.getResource()); + base.currentlyPlayerTexture = false; + } else if (!base.currentlyPlayerTexture) { + ClientProxy.bindTexture(entity.textureLocation); + base.currentlyPlayerTexture = true; + } + } + if (part.type == 0) { leg1.setConfig(config, x, y, z); leg1.render(par1); leg2.setConfig(config, -x, y, z); leg2.render(par1); } - if(!base.isArmor){ - naga.isHidden = part.type != 1; - spider.isHidden = part.type != 2; - horse.isHidden = part.type != 3; - mermaid.isHidden = part.type != 4; + if (!base.isArmor) { + naga.isHidden = part.type != 1; + spider.isHidden = part.type != 2; + horse.isHidden = part.type != 3; + mermaid.isHidden = part.type != 4; mermaid2.isHidden = part.type != 6; - digitigrade.isHidden = part.type != 5; + digitigrade.isHidden = part.type != 5; - if(!horse.isHidden){ - x = 0; - y *= 1.8f; - GL11.glScalef(0.9f, 0.9f, 0.9f); - } - else if(!spider.isHidden){ - x = 0; - y *= 2f; - } - else if(!naga.isHidden){ - x = 0; - y *= 2f; - } - else if(!mermaid.isHidden || !mermaid2.isHidden || !digitigrade.isHidden){ - x = 0; - y *= 2f; - } - } + if (!horse.isHidden) { + x = 0; + y *= 1.8f; + GL11.glScalef(0.9f, 0.9f, 0.9f); + } else if (!spider.isHidden) { + x = 0; + y *= 2f; + } else if (!naga.isHidden) { + x = 0; + y *= 2f; + } else if (!mermaid.isHidden || !mermaid2.isHidden || !digitigrade.isHidden) { + x = 0; + y *= 2f; + } + } TintData tintData = entity.display.tintData; boolean showColor = !base.isArmor && tintData.processColor(entity.hurtTime > 0 || entity.deathTime > 0); - if(showColor){ - float red = (entity.modelData.legParts.color >> 16 & 255) / 255f; - float green = (entity.modelData.legParts.color >> 8 & 255) / 255f; - float blue = (entity.modelData.legParts.color & 255) / 255f; - GL11.glColor4f(red, green, blue, base.alpha); - } - super.render(par1); - if(showColor){ - GL11.glColor4f(1, 1, 1, base.alpha); - } - GL11.glPopMatrix(); + if (showColor) { + float red = (entity.modelData.legParts.color >> 16 & 255) / 255f; + float green = (entity.modelData.legParts.color >> 8 & 255) / 255f; + float blue = (entity.modelData.legParts.color & 255) / 255f; + GL11.glColor4f(red, green, blue, base.alpha); + } + super.render(par1); + if (showColor) { + GL11.glColor4f(1, 1, 1, base.alpha); + } + GL11.glPopMatrix(); } - public void setData(EntityCustomNpc entity) { - this.entity = entity; - } + + public void setData(EntityCustomNpc entity) { + this.entity = entity; + } } diff --git a/src/main/java/noppes/npcs/client/model/part/ModelLimbWear.java b/src/main/java/noppes/npcs/client/model/part/ModelLimbWear.java index c6346d09f..1d265b800 100644 --- a/src/main/java/noppes/npcs/client/model/part/ModelLimbWear.java +++ b/src/main/java/noppes/npcs/client/model/part/ModelLimbWear.java @@ -1,5 +1,3 @@ - - package noppes.npcs.client.model.part; import net.minecraft.client.model.ModelBase; @@ -12,9 +10,9 @@ public class ModelLimbWear extends ModelScaleRenderer { super(base); float thick = 0.55f; - switch (limb){ + switch (limb) { case "arm": - switch(type) { + switch (type) { case "Steve": switch (side) { case "right": @@ -38,12 +36,12 @@ public class ModelLimbWear extends ModelScaleRenderer { } break; case "leg": - switch (side){ + switch (side) { case "right": - rightLeg(base,thick); + rightLeg(base, thick); break; case "left": - leftLeg(base,thick); + leftLeg(base, thick); break; } break; @@ -52,288 +50,288 @@ public class ModelLimbWear extends ModelScaleRenderer { } - public void rightArmAlex(ModelBase base, float thick){ + public void rightArmAlex(ModelBase base, float thick) { float x = 0.95f; float y = -2.0f; Model2DRenderer front = new Model2DRenderer(base, 44, 36, 3, 12, 64, 64); - front.setRotationPoint(-3.39375f+x, 12.535f+y, -2.58f); - front.setScale(0.96f,0.8175f); + front.setRotationPoint(-3.39375f + x, 12.535f + y, -2.58f); + front.setScale(0.96f, 0.8175f); front.setThickness(thick); setRotation(front, 0, 0, 0); this.addChild(front); Model2DRenderer back = new Model2DRenderer(base, 51, 36, 3, 12, 64, 64); - back.setRotationPoint(0.44f+x, 12.535f+y, 2.58f); - back.setScale(0.96f,0.8175f); + back.setRotationPoint(0.44f + x, 12.535f + y, 2.58f); + back.setScale(0.96f, 0.8175f); back.setThickness(thick); - setRotation(back, 0, (float)(Math.PI), 0); + setRotation(back, 0, (float) (Math.PI), 0); this.addChild(back); Model2DRenderer right = new Model2DRenderer(base, 47, 36, 4, 12, 64, 64); - right.setRotationPoint(0.45f+x, 12.55f+y, -2.55f); - right.setScale(0.96f,0.82f); + right.setRotationPoint(0.45f + x, 12.55f + y, -2.55f); + right.setScale(0.96f, 0.82f); right.setThickness(thick); - setRotation(right, 0, (float)(Math.PI/-2f), 0); + setRotation(right, 0, (float) (Math.PI / -2f), 0); this.addChild(right); Model2DRenderer left = new Model2DRenderer(base, 40, 36, 4, 12, 64, 64); - left.setRotationPoint(-3.405f+x, 12.55f+y, 2.55f); - left.setScale(0.96f,0.82f); + left.setRotationPoint(-3.405f + x, 12.55f + y, 2.55f); + left.setScale(0.96f, 0.82f); left.setThickness(thick); - setRotation(left, 0, (float)(Math.PI/2f), 0); + setRotation(left, 0, (float) (Math.PI / 2f), 0); this.addChild(left); Model2DRenderer top = new Model2DRenderer(base, 44, 32, 3, 4, 64, 64); - top.setRotationPoint(-3.39375f+x, -0.6f+y, -2.55f); + top.setRotationPoint(-3.39375f + x, -0.6f + y, -2.55f); top.setScale(0.32f); top.setThickness(thick); - setRotation(top, (float)(Math.PI / -2), 0, 0); + setRotation(top, (float) (Math.PI / -2), 0, 0); this.addChild(top); Model2DRenderer bottom = new Model2DRenderer(base, 47, 32, 3, 4, 64, 64); - bottom.setRotationPoint(-3.39375f+x, 12.0f+y, -2.545f); + bottom.setRotationPoint(-3.39375f + x, 12.0f + y, -2.545f); bottom.setScale(0.32f); bottom.setThickness(thick); - setRotation(bottom, (float)(Math.PI / -2), 0, 0); + setRotation(bottom, (float) (Math.PI / -2), 0, 0); this.addChild(bottom); } - public void leftArmAlex(ModelBase base,float thick){ + public void leftArmAlex(ModelBase base, float thick) { float x = 1.95f; float y = -2.0f; - Model2DRenderer front = new Model2DRenderer(base, 44+8, 36+16, 3, 12, 64, 64); - front.setRotationPoint(-3.39375f+x, 12.535f+y, -2.58f); - front.setScale(0.96f,0.8175f); + Model2DRenderer front = new Model2DRenderer(base, 44 + 8, 36 + 16, 3, 12, 64, 64); + front.setRotationPoint(-3.39375f + x, 12.535f + y, -2.58f); + front.setScale(0.96f, 0.8175f); front.setThickness(thick); setRotation(front, 0, 0, 0); this.addChild(front); - Model2DRenderer back = new Model2DRenderer(base, 51+8, 36+16, 3, 12, 64, 64); - back.setRotationPoint(0.44f+x, 12.535f+y, 2.58f); - back.setScale(0.96f,0.8175f); + Model2DRenderer back = new Model2DRenderer(base, 51 + 8, 36 + 16, 3, 12, 64, 64); + back.setRotationPoint(0.44f + x, 12.535f + y, 2.58f); + back.setScale(0.96f, 0.8175f); back.setThickness(thick); - setRotation(back, 0, (float)(Math.PI), 0); + setRotation(back, 0, (float) (Math.PI), 0); this.addChild(back); - Model2DRenderer right = new Model2DRenderer(base, 47+8, 36+16, 4, 12, 64, 64); - right.setRotationPoint(0.45f+x, 12.55f+y, -2.55f); - right.setScale(0.96f,0.82f); + Model2DRenderer right = new Model2DRenderer(base, 47 + 8, 36 + 16, 4, 12, 64, 64); + right.setRotationPoint(0.45f + x, 12.55f + y, -2.55f); + right.setScale(0.96f, 0.82f); right.setThickness(thick); - setRotation(right, 0, (float)(Math.PI/-2f), 0); + setRotation(right, 0, (float) (Math.PI / -2f), 0); this.addChild(right); - Model2DRenderer left = new Model2DRenderer(base, 40+8, 36+16, 4, 12, 64, 64); - left.setRotationPoint(-3.405f+x, 12.55f+y, 2.55f); - left.setScale(0.96f,0.82f); + Model2DRenderer left = new Model2DRenderer(base, 40 + 8, 36 + 16, 4, 12, 64, 64); + left.setRotationPoint(-3.405f + x, 12.55f + y, 2.55f); + left.setScale(0.96f, 0.82f); left.setThickness(thick); - setRotation(left, 0, (float)(Math.PI/2f), 0); + setRotation(left, 0, (float) (Math.PI / 2f), 0); this.addChild(left); - Model2DRenderer top = new Model2DRenderer(base, 44+8, 32+16, 3, 4, 64, 64); - top.setRotationPoint(-3.39375f+x, -0.6f+y, -2.55f); + Model2DRenderer top = new Model2DRenderer(base, 44 + 8, 32 + 16, 3, 4, 64, 64); + top.setRotationPoint(-3.39375f + x, -0.6f + y, -2.55f); top.setScale(0.32f); top.setThickness(thick); - setRotation(top, (float)(Math.PI / -2), 0, 0); + setRotation(top, (float) (Math.PI / -2), 0, 0); this.addChild(top); - Model2DRenderer bottom = new Model2DRenderer(base, 47+8, 32+16, 3, 4, 64, 64); - bottom.setRotationPoint(-3.39375f+x, 12.0f+y, -2.545f); + Model2DRenderer bottom = new Model2DRenderer(base, 47 + 8, 32 + 16, 3, 4, 64, 64); + bottom.setRotationPoint(-3.39375f + x, 12.0f + y, -2.545f); bottom.setScale(0.32f); bottom.setThickness(thick); - setRotation(bottom, (float)(Math.PI / -2), 0, 0); + setRotation(bottom, (float) (Math.PI / -2), 0, 0); this.addChild(bottom); } - public void rightArm(ModelBase base, float thick){ + public void rightArm(ModelBase base, float thick) { float x = 0.95f; float y = -2.0f; Model2DRenderer front = new Model2DRenderer(base, 44, 36, 4, 12, 64, 64); - front.setRotationPoint(-4.52f+x, 12.535f+y, -2.58f); - front.setScale(0.96f,0.8175f); + front.setRotationPoint(-4.52f + x, 12.535f + y, -2.58f); + front.setScale(0.96f, 0.8175f); front.setThickness(thick); setRotation(front, 0, 0, 0); this.addChild(front); Model2DRenderer back = new Model2DRenderer(base, 52, 36, 4, 12, 64, 64); - back.setRotationPoint(0.6f+x, 12.535f+y, 2.58f); - back.setScale(0.96f,0.8175f); + back.setRotationPoint(0.6f + x, 12.535f + y, 2.58f); + back.setScale(0.96f, 0.8175f); back.setThickness(thick); - setRotation(back, 0, (float)(Math.PI), 0); + setRotation(back, 0, (float) (Math.PI), 0); this.addChild(back); Model2DRenderer right = new Model2DRenderer(base, 48, 36, 4, 12, 64, 64); - right.setRotationPoint(0.62f+x, 12.55f+y, -2.55f); - right.setScale(0.96f,0.82f); + right.setRotationPoint(0.62f + x, 12.55f + y, -2.55f); + right.setScale(0.96f, 0.82f); right.setThickness(thick); - setRotation(right, 0, (float)(Math.PI/-2f), 0); + setRotation(right, 0, (float) (Math.PI / -2f), 0); this.addChild(right); Model2DRenderer left = new Model2DRenderer(base, 40, 36, 4, 12, 64, 64); - left.setRotationPoint(-4.56f+x, 12.55f+y, 2.55f); - left.setScale(0.96f,0.82f); + left.setRotationPoint(-4.56f + x, 12.55f + y, 2.55f); + left.setScale(0.96f, 0.82f); left.setThickness(thick); - setRotation(left, 0, (float)(Math.PI/2f), 0); + setRotation(left, 0, (float) (Math.PI / 2f), 0); this.addChild(left); Model2DRenderer top = new Model2DRenderer(base, 44, 32, 4, 4, 64, 64); - top.setRotationPoint(-4.525f+x, -0.6f+y, -2.55f); + top.setRotationPoint(-4.525f + x, -0.6f + y, -2.55f); top.setScale(0.32f); top.setThickness(thick); - setRotation(top, (float)(Math.PI / -2), 0, 0); + setRotation(top, (float) (Math.PI / -2), 0, 0); this.addChild(top); Model2DRenderer bottom = new Model2DRenderer(base, 48, 32, 4, 4, 64, 64); - bottom.setRotationPoint(-4.5f+x, 12.0f+y, -2.525f); + bottom.setRotationPoint(-4.5f + x, 12.0f + y, -2.525f); bottom.setScale(0.32f); bottom.setThickness(thick); - setRotation(bottom, (float)(Math.PI / -2), 0, 0); + setRotation(bottom, (float) (Math.PI / -2), 0, 0); this.addChild(bottom); } - public void leftArm(ModelBase base,float thick){ + public void leftArm(ModelBase base, float thick) { float x = 2.95f; float y = -2.0f; Model2DRenderer front = new Model2DRenderer(base, 52, 52, 4, 12, 64, 64); - front.setRotationPoint(-4.52f+x, 12.535f+y, -2.58f); - front.setScale(0.96f,0.8175f); + front.setRotationPoint(-4.52f + x, 12.535f + y, -2.58f); + front.setScale(0.96f, 0.8175f); front.setThickness(thick); setRotation(front, 0, 0, 0); this.addChild(front); Model2DRenderer back = new Model2DRenderer(base, 60, 52, 4, 12, 64, 64); - back.setRotationPoint(0.6f+x, 12.535f+y, 2.58f); - back.setScale(0.96f,0.8175f); + back.setRotationPoint(0.6f + x, 12.535f + y, 2.58f); + back.setScale(0.96f, 0.8175f); back.setThickness(thick); - setRotation(back, 0, (float)(Math.PI), 0); + setRotation(back, 0, (float) (Math.PI), 0); this.addChild(back); Model2DRenderer right = new Model2DRenderer(base, 56, 52, 4, 12, 64, 64); - right.setRotationPoint(0.62f+x, 12.55f+y, -2.55f); - right.setScale(0.96f,0.82f); + right.setRotationPoint(0.62f + x, 12.55f + y, -2.55f); + right.setScale(0.96f, 0.82f); right.setThickness(thick); - setRotation(right, 0, (float)(Math.PI/-2f), 0); + setRotation(right, 0, (float) (Math.PI / -2f), 0); this.addChild(right); Model2DRenderer left = new Model2DRenderer(base, 48, 52, 4, 12, 64, 64); - left.setRotationPoint(-4.56f+x, 12.55f+y, 2.55f); - left.setScale(0.96f,0.82f); + left.setRotationPoint(-4.56f + x, 12.55f + y, 2.55f); + left.setScale(0.96f, 0.82f); left.setThickness(thick); - setRotation(left, 0, (float)(Math.PI/2f), 0); + setRotation(left, 0, (float) (Math.PI / 2f), 0); this.addChild(left); Model2DRenderer top = new Model2DRenderer(base, 52, 48, 4, 4, 64, 64); - top.setRotationPoint(-4.525f+x, -0.6f+y, -2.55f); + top.setRotationPoint(-4.525f + x, -0.6f + y, -2.55f); top.setScale(0.32f); top.setThickness(thick); - setRotation(top, (float)(Math.PI / -2), 0, 0); + setRotation(top, (float) (Math.PI / -2), 0, 0); this.addChild(top); Model2DRenderer bottom = new Model2DRenderer(base, 56, 48, 4, 4, 64, 64); - bottom.setRotationPoint(-4.56f+x, 12.0f+y, -2.55f); + bottom.setRotationPoint(-4.56f + x, 12.0f + y, -2.55f); bottom.setScale(0.32f); bottom.setThickness(thick); - setRotation(bottom, (float)(Math.PI / -2), 0, 0); + setRotation(bottom, (float) (Math.PI / -2), 0, 0); this.addChild(bottom); } - public void rightLeg(ModelBase base, float thick){ + public void rightLeg(ModelBase base, float thick) { float x = 1.8f; float y = 0.0f; Model2DRenderer front = new Model2DRenderer(base, 4, 36, 4, 12, 64, 64); - front.setRotationPoint(-4.52f+x, 12.535f+y, -2.58f); - front.setScale(0.96f,0.8175f); + front.setRotationPoint(-4.52f + x, 12.535f + y, -2.58f); + front.setScale(0.96f, 0.8175f); front.setThickness(thick); setRotation(front, 0, 0, 0); this.addChild(front); Model2DRenderer back = new Model2DRenderer(base, 12, 36, 4, 12, 64, 64); - back.setRotationPoint(0.6f+x, 12.535f+y, 2.58f); - back.setScale(0.96f,0.8175f); + back.setRotationPoint(0.6f + x, 12.535f + y, 2.58f); + back.setScale(0.96f, 0.8175f); back.setThickness(thick); - setRotation(back, 0, (float)(Math.PI), 0); + setRotation(back, 0, (float) (Math.PI), 0); this.addChild(back); Model2DRenderer right = new Model2DRenderer(base, 8, 36, 4, 12, 64, 64); - right.setRotationPoint(0.62f+x, 12.55f+y, -2.55f); - right.setScale(0.96f,0.82f); + right.setRotationPoint(0.62f + x, 12.55f + y, -2.55f); + right.setScale(0.96f, 0.82f); right.setThickness(thick); - setRotation(right, 0, (float)(Math.PI/-2f), 0); + setRotation(right, 0, (float) (Math.PI / -2f), 0); this.addChild(right); Model2DRenderer left = new Model2DRenderer(base, 0, 36, 4, 12, 64, 64); - left.setRotationPoint(-4.53f+x, 12.55f+y, 2.55f); - left.setScale(0.96f,0.82f); + left.setRotationPoint(-4.53f + x, 12.55f + y, 2.55f); + left.setScale(0.96f, 0.82f); left.setThickness(thick); - setRotation(left, 0, (float)(Math.PI/2f), 0); + setRotation(left, 0, (float) (Math.PI / 2f), 0); this.addChild(left); Model2DRenderer top = new Model2DRenderer(base, 4, 32, 4, 4, 64, 64); - top.setRotationPoint(-4.525f+x, -0.6f+y, -2.55f); + top.setRotationPoint(-4.525f + x, -0.6f + y, -2.55f); top.setScale(0.32f); top.setThickness(thick); - setRotation(top, (float)(Math.PI / -2), 0, 0); + setRotation(top, (float) (Math.PI / -2), 0, 0); this.addChild(top); Model2DRenderer bottom = new Model2DRenderer(base, 8, 32, 4, 4, 64, 64); - bottom.setRotationPoint(-4.5f+x, 12.11f+y, -2.525f); + bottom.setRotationPoint(-4.5f + x, 12.11f + y, -2.525f); bottom.setScale(0.32f); bottom.setThickness(thick); - setRotation(bottom, (float)(Math.PI / -2), 0, 0); + setRotation(bottom, (float) (Math.PI / -2), 0, 0); this.addChild(bottom); } - public void leftLeg(ModelBase base,float thick){ + public void leftLeg(ModelBase base, float thick) { float x = 2.05f; float y = 0.0f; Model2DRenderer front = new Model2DRenderer(base, 4, 52, 4, 12, 64, 64); - front.setRotationPoint(-4.52f+x, 12.535f+y, -2.58f); - front.setScale(0.96f,0.8175f); + front.setRotationPoint(-4.52f + x, 12.535f + y, -2.58f); + front.setScale(0.96f, 0.8175f); front.setThickness(thick); setRotation(front, 0, 0, 0); this.addChild(front); Model2DRenderer back = new Model2DRenderer(base, 12, 52, 4, 12, 64, 64); - back.setRotationPoint(0.6f+x, 12.535f+y, 2.58f); - back.setScale(0.96f,0.8175f); + back.setRotationPoint(0.6f + x, 12.535f + y, 2.58f); + back.setScale(0.96f, 0.8175f); back.setThickness(thick); - setRotation(back, 0, (float)(Math.PI), 0); + setRotation(back, 0, (float) (Math.PI), 0); this.addChild(back); Model2DRenderer right = new Model2DRenderer(base, 8, 52, 4, 12, 64, 64); - right.setRotationPoint(0.62f+x, 12.55f+y, -2.55f); - right.setScale(0.96f,0.82f); + right.setRotationPoint(0.62f + x, 12.55f + y, -2.55f); + right.setScale(0.96f, 0.82f); right.setThickness(thick); - setRotation(right, 0, (float)(Math.PI/-2f), 0); + setRotation(right, 0, (float) (Math.PI / -2f), 0); this.addChild(right); Model2DRenderer left = new Model2DRenderer(base, 0, 52, 4, 12, 64, 64); - left.setRotationPoint(-4.53f+x, 12.55f+y, 2.55f); - left.setScale(0.96f,0.82f); + left.setRotationPoint(-4.53f + x, 12.55f + y, 2.55f); + left.setScale(0.96f, 0.82f); left.setThickness(thick); - setRotation(left, 0, (float)(Math.PI/2f), 0); + setRotation(left, 0, (float) (Math.PI / 2f), 0); this.addChild(left); Model2DRenderer top = new Model2DRenderer(base, 4, 48, 4, 4, 64, 64); - top.setRotationPoint(-4.525f+x, -0.6f+y, -2.55f); + top.setRotationPoint(-4.525f + x, -0.6f + y, -2.55f); top.setScale(0.32f); top.setThickness(thick); - setRotation(top, (float)(Math.PI / -2), 0, 0); + setRotation(top, (float) (Math.PI / -2), 0, 0); this.addChild(top); Model2DRenderer bottom = new Model2DRenderer(base, 8, 48, 4, 4, 64, 64); - bottom.setRotationPoint(-4.5f+x, 12.11f+y, -2.525f); + bottom.setRotationPoint(-4.5f + x, 12.11f + y, -2.525f); bottom.setScale(0.32f); bottom.setThickness(thick); - setRotation(bottom, (float)(Math.PI / -2), 0, 0); + setRotation(bottom, (float) (Math.PI / -2), 0, 0); this.addChild(bottom); } diff --git a/src/main/java/noppes/npcs/client/model/part/ModelMohawk.java b/src/main/java/noppes/npcs/client/model/part/ModelMohawk.java index 11069e209..a18c39d6c 100644 --- a/src/main/java/noppes/npcs/client/model/part/ModelMohawk.java +++ b/src/main/java/noppes/npcs/client/model/part/ModelMohawk.java @@ -8,36 +8,36 @@ import noppes.npcs.entity.data.ModelData; import noppes.npcs.entity.data.ModelPartData; public class ModelMohawk extends ModelPartInterface { - private Model2DRenderer model; - public ModelMohawk(ModelMPM base) { - super(base); + private Model2DRenderer model; - model = new Model2DRenderer(base, 0, 0, 13 , 13); - model.setRotationPoint(-0.5F, 0f, 9F); - setRotation(model, 0, (float)(Math.PI/2f), 0); + public ModelMohawk(ModelMPM base) { + super(base); + + model = new Model2DRenderer(base, 0, 0, 13, 13); + model.setRotationPoint(-0.5F, 0f, 9F); + setRotation(model, 0, (float) (Math.PI / 2f), 0); model.setScale(0.825f); this.addChild(model); - } + } - @Override - public void setRotationAngles(float par1, float par2, float par3, - float par4, float par5, float par6, Entity entity) { + @Override + public void setRotationAngles(float par1, float par2, float par3, + float par4, float par5, float par6, Entity entity) { - } + } - @Override - public void initData(ModelData data) { - ModelPartData config = data.getPartData("mohawk"); - if(config == null) - { - isHidden = true; - return; - } - color = config.color; - isHidden = false; - location = config.getResource(); + @Override + public void initData(ModelData data) { + ModelPartData config = data.getPartData("mohawk"); + if (config == null) { + isHidden = true; + return; + } + color = config.color; + isHidden = false; + location = config.getResource(); - } + } } diff --git a/src/main/java/noppes/npcs/client/model/part/ModelSkirt.java b/src/main/java/noppes/npcs/client/model/part/ModelSkirt.java index c82d27c23..ba06b3639 100644 --- a/src/main/java/noppes/npcs/client/model/part/ModelSkirt.java +++ b/src/main/java/noppes/npcs/client/model/part/ModelSkirt.java @@ -11,62 +11,63 @@ import noppes.npcs.entity.data.ModelPartData; import org.lwjgl.opengl.GL11; public class ModelSkirt extends ModelPartInterface { - private ModelPlaneRenderer Shape1; - public ModelSkirt(ModelMPM base) { - super(base); - float pi = (float) (Math.PI / 5); + private ModelPlaneRenderer Shape1; - textureWidth = 64; - textureHeight = 32; + public ModelSkirt(ModelMPM base) { + super(base); + float pi = (float) (Math.PI / 5); - Shape1 = new ModelPlaneRenderer(base, 58, 18); - Shape1.setTextureSize(64,32); - Shape1.addSidePlane(0, 0, 0, 9, 2); + textureWidth = 64; + textureHeight = 32; - ModelPlaneRenderer part1 = new ModelPlaneRenderer(base, 58, 18); - part1.setTextureSize(64,32); - part1.addSidePlane(2, 0, 0, 9, 2); - part1.rotateAngleY = -(float) (Math.PI/2); - Shape1.addChild(part1); + Shape1 = new ModelPlaneRenderer(base, 58, 18); + Shape1.setTextureSize(64, 32); + Shape1.addSidePlane(0, 0, 0, 9, 2); - Shape1.setRotationPoint(2.4F, 8.8F, 0F); - setRotation(Shape1, 0.3F, -0.2f, -0.2F); - } - public void render(float par1) - { - if (this.isHidden || !this.showModel) - return; - GL11.glPushMatrix(); - GL11.glScalef(1.7f, 1.04f, 1.6f); - super.render(par1); - GL11.glPopMatrix(); + ModelPlaneRenderer part1 = new ModelPlaneRenderer(base, 58, 18); + part1.setTextureSize(64, 32); + part1.addSidePlane(2, 0, 0, 9, 2); + part1.rotateAngleY = -(float) (Math.PI / 2); + Shape1.addChild(part1); + + Shape1.setRotationPoint(2.4F, 8.8F, 0F); + setRotation(Shape1, 0.3F, -0.2f, -0.2F); } - public void renderParts(float par1) { - for(int i = 0; i < 10; i++){ - GL11.glRotatef(36, 0, 1, 0); - Shape1.render(par1); - } - } - public void setRotationAngles(float par1, float par2, float par3, - float par4, float par5, float par6, Entity entity) { - setRotation(Shape1, 0.3F, -0.2f, -0.2F); - Shape1.rotateAngleX += base.bipedLeftArm.rotateAngleX * 0.04f; - Shape1.rotateAngleZ += base.bipedLeftArm.rotateAngleX * 0.06f; + public void render(float par1) { + if (this.isHidden || !this.showModel) + return; + GL11.glPushMatrix(); + GL11.glScalef(1.7f, 1.04f, 1.6f); + super.render(par1); + GL11.glPopMatrix(); + } + + public void renderParts(float par1) { + for (int i = 0; i < 10; i++) { + GL11.glRotatef(36, 0, 1, 0); + Shape1.render(par1); + } + } + + public void setRotationAngles(float par1, float par2, float par3, + float par4, float par5, float par6, Entity entity) { + setRotation(Shape1, 0.3F, -0.2f, -0.2F); + Shape1.rotateAngleX += base.bipedLeftArm.rotateAngleX * 0.04f; + Shape1.rotateAngleZ += base.bipedLeftArm.rotateAngleX * 0.06f; //this.Shape1.rotateAngleX -= MathHelper.sin(par3 * 0.067F) * 0.05F; this.Shape1.rotateAngleZ -= MathHelper.cos(par3 * 0.09F) * 0.04F - 0.05F; - } + } - @Override - public void initData(ModelData data) { - ModelPartData config = data.getPartData("skirt"); - if(config == null) - { - isHidden = true; - return; - } - color = config.color; - isHidden = false; - location = (ResourceLocation) config.getResource(); - } + @Override + public void initData(ModelData data) { + ModelPartData config = data.getPartData("skirt"); + if (config == null) { + isHidden = true; + return; + } + color = config.color; + isHidden = false; + location = (ResourceLocation) config.getResource(); + } } diff --git a/src/main/java/noppes/npcs/client/model/part/ModelSnout.java b/src/main/java/noppes/npcs/client/model/part/ModelSnout.java index 31ca94964..398f1a6b9 100644 --- a/src/main/java/noppes/npcs/client/model/part/ModelSnout.java +++ b/src/main/java/noppes/npcs/client/model/part/ModelSnout.java @@ -8,78 +8,76 @@ import noppes.npcs.entity.data.ModelData; import noppes.npcs.entity.data.ModelPartData; public class ModelSnout extends ModelPartInterface { - private ModelRenderer small; - private ModelRenderer medium; - private ModelRenderer large; - private ModelRenderer bunny; - private ModelRenderer beak; + private ModelRenderer small; + private ModelRenderer medium; + private ModelRenderer large; + private ModelRenderer bunny; + private ModelRenderer beak; - public ModelSnout(ModelMPM base) { - super(base); + public ModelSnout(ModelMPM base) { + super(base); - small = new ModelRenderer(base, 24, 0); - small.setTextureSize(64,32); - small.addBox(0F, 0F, 0F, 4, 3, 1); - small.setRotationPoint(-2F, -3F, -5F); - this.addChild(small); + small = new ModelRenderer(base, 24, 0); + small.setTextureSize(64, 32); + small.addBox(0F, 0F, 0F, 4, 3, 1); + small.setRotationPoint(-2F, -3F, -5F); + this.addChild(small); - medium = new ModelRenderer(base, 24, 0); - medium.setTextureSize(64,32); - medium.addBox(0F, 0F, 0F, 4, 3, 2); - medium.setRotationPoint(-2F, -3F, -6F); - this.addChild(medium); + medium = new ModelRenderer(base, 24, 0); + medium.setTextureSize(64, 32); + medium.addBox(0F, 0F, 0F, 4, 3, 2); + medium.setRotationPoint(-2F, -3F, -6F); + this.addChild(medium); - large = new ModelRenderer(base, 24, 0); - large.setTextureSize(64,32); - large.addBox(0F, 0F, 0F, 4, 3, 3); - large.setRotationPoint(-2F, -3F, -7F); - this.addChild(large); + large = new ModelRenderer(base, 24, 0); + large.setTextureSize(64, 32); + large.addBox(0F, 0F, 0F, 4, 3, 3); + large.setRotationPoint(-2F, -3F, -7F); + this.addChild(large); - bunny = new ModelRenderer(base, 24, 0); - bunny.setTextureSize(64,32); - bunny.addBox(1F, 1F, 0F, 4, 2, 1); - bunny.setRotationPoint(-3F, -4F, -5F); - this.addChild(bunny); + bunny = new ModelRenderer(base, 24, 0); + bunny.setTextureSize(64, 32); + bunny.addBox(1F, 1F, 0F, 4, 2, 1); + bunny.setRotationPoint(-3F, -4F, -5F); + this.addChild(bunny); - ModelRenderer tooth = new ModelRenderer(base, 24, 3); - tooth.setTextureSize(64,32); - tooth.addBox(2F, 3f, 0F, 2, 1, 1); - tooth.setRotationPoint(0F, 0F, 0F); - bunny.addChild(tooth); + ModelRenderer tooth = new ModelRenderer(base, 24, 3); + tooth.setTextureSize(64, 32); + tooth.addBox(2F, 3f, 0F, 2, 1, 1); + tooth.setRotationPoint(0F, 0F, 0F); + bunny.addChild(tooth); - beak = new ModelDuckBeak(base); - beak.setTextureSize(64,32); - beak.setRotationPoint(0, 0, -4F); - this.addChild(beak); - } + beak = new ModelDuckBeak(base); + beak.setTextureSize(64, 32); + beak.setRotationPoint(0, 0, -4F); + this.addChild(beak); + } - @Override - public void setRotationAngles(float par1, float par2, float par3, - float par4, float par5, float par6, Entity entity) { + @Override + public void setRotationAngles(float par1, float par2, float par3, + float par4, float par5, float par6, Entity entity) { - } + } - @Override - public void initData(ModelData data) { - ModelPartData config = data.getPartData("snout"); - if(config == null) - { - isHidden = true; - return; - } + @Override + public void initData(ModelData data) { + ModelPartData config = data.getPartData("snout"); + if (config == null) { + isHidden = true; + return; + } - color = config.color; - isHidden = false; - small.isHidden = config.type != 0; - medium.isHidden = config.type != 1; - large.isHidden = config.type != 2; - bunny.isHidden = config.type != 3; - beak.isHidden = config.type != 4; + color = config.color; + isHidden = false; + small.isHidden = config.type != 0; + medium.isHidden = config.type != 1; + large.isHidden = config.type != 2; + bunny.isHidden = config.type != 3; + beak.isHidden = config.type != 4; - if(!config.playerTexture){ - location = config.getResource(); - } - else - location = null; - } + if (!config.playerTexture) { + location = config.getResource(); + } else + location = null; + } } diff --git a/src/main/java/noppes/npcs/client/model/part/ModelTail.java b/src/main/java/noppes/npcs/client/model/part/ModelTail.java index 64a149996..d49eb565f 100644 --- a/src/main/java/noppes/npcs/client/model/part/ModelTail.java +++ b/src/main/java/noppes/npcs/client/model/part/ModelTail.java @@ -16,8 +16,8 @@ import noppes.npcs.entity.data.ModelPartData; import org.lwjgl.opengl.GL11; public class ModelTail extends ModelScaleRenderer { - private EntityCustomNpc entity; - private ModelMPM base; + private EntityCustomNpc entity; + private ModelMPM base; public ModelRenderer tail; public ModelRenderer dragon; @@ -29,28 +29,28 @@ public class ModelTail extends ModelScaleRenderer { public ModelCanineTail fox; public ModelMonkeyTail monkey; - private int color = 0xFFFFFF; + private int color = 0xFFFFFF; - private ResourceLocation location = null; + private ResourceLocation location = null; - public ModelTail(ModelMPM base) { - super(base); - this.base = base; - this.rotationPointY = 11; + public ModelTail(ModelMPM base) { + super(base); + this.base = base; + this.rotationPointY = 11; - tail = new ModelRenderer(base, 56, 21); - tail.setTextureSize(64, 32); - tail.addBox(-1F, 0F, 0F, 2, 9, 2); - tail.setRotationPoint(0F, 0, 1F); - setRotation(tail, 0.8714253F, 0F, 0F); - this.addChild(tail); + tail = new ModelRenderer(base, 56, 21); + tail.setTextureSize(64, 32); + tail.addBox(-1F, 0F, 0F, 2, 9, 2); + tail.setRotationPoint(0F, 0, 1F); + setRotation(tail, 0.8714253F, 0F, 0F); + this.addChild(tail); - horse = new ModelRenderer(base); - horse.setTextureSize(32, 32); - horse.setRotationPoint(0, -1, 1); - this.addChild(horse); + horse = new ModelRenderer(base); + horse.setTextureSize(32, 32); + horse.setRotationPoint(0, -1, 1); + this.addChild(horse); - ModelRenderer tailBase = new ModelRenderer(base, 0, 26); + ModelRenderer tailBase = new ModelRenderer(base, 0, 26); tailBase.setTextureSize(32, 32); tailBase.addBox(-1.0F, -1.0F, 0.0F, 2, 2, 3); setRotation(tailBase, -1.134464F, 0.0F, 0.0F); @@ -67,63 +67,61 @@ public class ModelTail extends ModelScaleRenderer { horse.addChild(tailTip); horse.rotateAngleX = 0.5f; - this.addChild(dragon = new ModelDragonTail(base)); - this.addChild(squirrel = new ModelSquirrelTail(base)); - this.addChild(fin = new ModelTailFin(base)); - this.addChild(rodent = new ModelRodentTail(base)); - this.addChild(feather = new ModelFeatherTail(base)); + this.addChild(dragon = new ModelDragonTail(base)); + this.addChild(squirrel = new ModelSquirrelTail(base)); + this.addChild(fin = new ModelTailFin(base)); + this.addChild(rodent = new ModelRodentTail(base)); + this.addChild(feather = new ModelFeatherTail(base)); this.addChild(fox = new ModelCanineTail(base)); this.addChild(monkey = new ModelMonkeyTail(base)); - } + } - public void setData(EntityCustomNpc entity) { - this.entity = entity; - initData(entity); - } + public void setData(EntityCustomNpc entity) { + this.entity = entity; + initData(entity); + } - public void setRotationAngles(float par1, float par2, float par3, - float par4, float par5, float par6, Entity entity) { - if(this.entity==null) return; + public void setRotationAngles(float par1, float par2, float par3, + float par4, float par5, float par6, Entity entity) { + if (this.entity == null) return; float rotateAngleY = MathHelper.cos(par1 * 0.6662F) * 0.3f * par2; float rotateAngleX = MathHelper.sin(par3 * 0.067F) * 0.05F; rotationPointY = 11; - if(this.entity.modelData.legParts.type == 2){ - rotationPointY = 13f; - rotationPointZ = 14 * this.entity.modelData.modelScale.legs.scaleZ; + if (this.entity.modelData.legParts.type == 2) { + rotationPointY = 13f; + rotationPointZ = 14 * this.entity.modelData.modelScale.legs.scaleZ; - if(base.isSleeping(entity) || this.entity.currentAnimation == EnumAnimation.CRAWLING){ - rotationPointY = 12 + 16 * this.entity.modelData.modelScale.legs.scaleZ; - rotationPointZ = this.entity.modelData.modelScale.legs.scaleY; + if (base.isSleeping(entity) || this.entity.currentAnimation == EnumAnimation.CRAWLING) { + rotationPointY = 12 + 16 * this.entity.modelData.modelScale.legs.scaleZ; + rotationPointZ = this.entity.modelData.modelScale.legs.scaleY; - rotateAngleX = (float) (Math.PI / -4); - } - } - else if(this.entity.modelData.legParts.type == 3){ - // rotationPointY = 8.6f; + rotateAngleX = (float) (Math.PI / -4); + } + } else if (this.entity.modelData.legParts.type == 3) { + // rotationPointY = 8.6f; rotationPointY = 10; rotationPointZ = 19 * this.entity.modelData.modelScale.legs.scaleZ; - } - else { - // this.rotationPointZ = -1; + } else { + // this.rotationPointZ = -1; rotationPointZ = -1; } ModelPartData partTail = this.entity.modelData.getPartData("tail"); - if(partTail != null){ - if(partTail.type == 2) { + if (partTail != null) { + if (partTail.type == 2) { rotateAngleX += 0.5F; } - if(partTail.type == 0) { + if (partTail.type == 0) { rotateAngleX += 0.87F; } - if(partTail.type == 7){ + if (partTail.type == 7) { rotationPointY -= 1; fox.setRotationAngles(par1, par2, par3, par4, par5, par6, entity); } - if(partTail.type == 8){ + if (partTail.type == 8) { monkey.setRotationAngles(par1, par2, par3, par4, par5, par6, entity); - if(partTail.pattern == 1){ + if (partTail.pattern == 1) { rotationPointZ += 1; rotateAngleX = 0; } @@ -137,22 +135,21 @@ public class ModelTail extends ModelScaleRenderer { public void setLivingAnimations(ModelPartData data, EntityLivingBase entity, float par2, float par3, float par4) { } - public void initData(EntityCustomNpc data) { - ModelPartData config = data.modelData.getPartData("tail"); - if(config == null) - { - isHidden = true; - return; - } - color = config.color; - isHidden = false; - tail.isHidden = config.type != 0; - dragon.isHidden = config.type != 1; - horse.isHidden = config.type != 2; - squirrel.isHidden = config.type != 3; + public void initData(EntityCustomNpc data) { + ModelPartData config = data.modelData.getPartData("tail"); + if (config == null) { + isHidden = true; + return; + } + color = config.color; + isHidden = false; + tail.isHidden = config.type != 0; + dragon.isHidden = config.type != 1; + horse.isHidden = config.type != 2; + squirrel.isHidden = config.type != 3; fin.isHidden = config.type != 4; rodent.isHidden = config.type != 5; - feather.isHidden = config.type != 6; + feather.isHidden = config.type != 6; fox.isHidden = config.type != 7; monkey.isHidden = config.type != 8; @@ -160,40 +157,37 @@ public class ModelTail extends ModelScaleRenderer { monkey.monkey_wrapped.isHidden = config.pattern != 1; monkey.monkey_large.isHidden = config.pattern != 2; - if(!config.playerTexture){ - location = config.getResource(); - } - else - location = null; - } + if (!config.playerTexture) { + location = config.getResource(); + } else + location = null; + } - @Override - public void render(float par1) - { - if(isHidden) - return; - if(!base.isArmor){ - if(location != null){ - ClientProxy.bindTexture(location); - base.currentlyPlayerTexture = false; - } - else if(!base.currentlyPlayerTexture){ - ClientProxy.bindTexture(entity.textureLocation); - base.currentlyPlayerTexture = true; - } - } + @Override + public void render(float par1) { + if (isHidden) + return; + if (!base.isArmor) { + if (location != null) { + ClientProxy.bindTexture(location); + base.currentlyPlayerTexture = false; + } else if (!base.currentlyPlayerTexture) { + ClientProxy.bindTexture(entity.textureLocation); + base.currentlyPlayerTexture = true; + } + } TintData tintData = entity.display.tintData; boolean showColor = !base.isArmor && tintData.processColor(entity.hurtTime > 0 || entity.deathTime > 0); - if(showColor){ - float red = (color >> 16 & 255) / 255f; - float green = (color >> 8 & 255) / 255f; - float blue = (color & 255) / 255f; - GL11.glColor4f(red, green, blue, base.alpha); - } - super.render(par1); - if(showColor){ - GL11.glColor4f(1, 1, 1, base.alpha); - } + if (showColor) { + float red = (color >> 16 & 255) / 255f; + float green = (color >> 8 & 255) / 255f; + float blue = (color & 255) / 255f; + GL11.glColor4f(red, green, blue, base.alpha); + } + super.render(par1); + if (showColor) { + GL11.glColor4f(1, 1, 1, base.alpha); + } } } diff --git a/src/main/java/noppes/npcs/client/model/part/ModelWings.java b/src/main/java/noppes/npcs/client/model/part/ModelWings.java index e26208076..b26e72d91 100644 --- a/src/main/java/noppes/npcs/client/model/part/ModelWings.java +++ b/src/main/java/noppes/npcs/client/model/part/ModelWings.java @@ -10,16 +10,16 @@ import noppes.npcs.entity.data.ModelPartData; public class ModelWings extends ModelPartInterface { - private Model2DRenderer lWing; - private Model2DRenderer rWing; + private Model2DRenderer lWing; + private Model2DRenderer rWing; - public ModelWings(ModelMPM base) { - super(base); + public ModelWings(ModelMPM base) { + super(base); - lWing = new Model2DRenderer(base, 48, 32, 16, 32, 64, 32); - lWing.mirror = true; - lWing.setRotationPoint(2F, 4, 2F); - lWing.setRotationOffset(-16, -12); + lWing = new Model2DRenderer(base, 48, 32, 16, 32, 64, 32); + lWing.mirror = true; + lWing.setRotationPoint(2F, 4, 2F); + lWing.setRotationOffset(-16, -12); setRotation(lWing, 0.7141593F, -0.5235988F, -0.5090659F); this.addChild(lWing); @@ -28,20 +28,20 @@ public class ModelWings extends ModelPartInterface { rWing.setRotationOffset(-16, -12); setRotation(rWing, 0.7141593F, 0.5235988F, 0.5090659F); this.addChild(rWing); - } + } - @Override - public void setRotationAngles(float par1, float par2, float par3, - float par4, float par5, float par6, Entity entity) { - rWing.rotateAngleX = 0.7141593F; - rWing.rotateAngleZ = 0.5090659F; + @Override + public void setRotationAngles(float par1, float par2, float par3, + float par4, float par5, float par6, Entity entity) { + rWing.rotateAngleX = 0.7141593F; + rWing.rotateAngleZ = 0.5090659F; - lWing.rotateAngleX = 0.7141593F; - lWing.rotateAngleZ = -0.5090659F; + lWing.rotateAngleX = 0.7141593F; + lWing.rotateAngleZ = -0.5090659F; - float motion = Math.abs(MathHelper.sin(par1 * 0.033F + (float)Math.PI) * 0.4F) * par2; - if ((!entity.worldObj.isRemote && !entity.onGround) || motion > 0.1D) { - float speed = (float) (0.55f + 0.5f * motion); + float motion = Math.abs(MathHelper.sin(par1 * 0.033F + (float) Math.PI) * 0.4F) * par2; + if ((!entity.worldObj.isRemote && !entity.onGround) || motion > 0.1D) { + float speed = (float) (0.55f + 0.5f * motion); float y = MathHelper.sin(par3 * 0.67F); rWing.rotateAngleZ += y * 0.5f * speed; @@ -49,28 +49,26 @@ public class ModelWings extends ModelPartInterface { lWing.rotateAngleZ -= y * 0.5f * speed; lWing.rotateAngleX += y * 0.5f * speed; - } else { - lWing.rotateAngleZ += MathHelper.cos(par3 * 0.09F) * 0.05F + 0.05F; - rWing.rotateAngleZ -= MathHelper.cos(par3 * 0.09F) * 0.05F + 0.05F; - lWing.rotateAngleX += MathHelper.sin(par3 * 0.067F) * 0.05F; - rWing.rotateAngleX += MathHelper.sin(par3 * 0.067F) * 0.05F; - } - } + } else { + lWing.rotateAngleZ += MathHelper.cos(par3 * 0.09F) * 0.05F + 0.05F; + rWing.rotateAngleZ -= MathHelper.cos(par3 * 0.09F) * 0.05F + 0.05F; + lWing.rotateAngleX += MathHelper.sin(par3 * 0.067F) * 0.05F; + rWing.rotateAngleX += MathHelper.sin(par3 * 0.067F) * 0.05F; + } + } - @Override - public void initData(ModelData data) { - ModelPartData config = data.getPartData("wings"); - if(config == null) - { - isHidden = true; - return; - } - color = config.color; - isHidden = false; - if(!config.playerTexture){ - location = config.getResource(); - } - else - location = null; - } + @Override + public void initData(ModelData data) { + ModelPartData config = data.getPartData("wings"); + if (config == null) { + isHidden = true; + return; + } + color = config.color; + isHidden = false; + if (!config.playerTexture) { + location = config.getResource(); + } else + location = null; + } } diff --git a/src/main/java/noppes/npcs/client/model/part/horns/ModelAntennasBack.java b/src/main/java/noppes/npcs/client/model/part/horns/ModelAntennasBack.java index f6b701c49..1ffafd64c 100644 --- a/src/main/java/noppes/npcs/client/model/part/horns/ModelAntennasBack.java +++ b/src/main/java/noppes/npcs/client/model/part/horns/ModelAntennasBack.java @@ -5,43 +5,43 @@ import noppes.npcs.client.model.ModelMPM; public class ModelAntennasBack extends ModelRenderer { - public ModelAntennasBack(ModelMPM base) { - super(base); + public ModelAntennasBack(ModelMPM base) { + super(base); - ModelRenderer rightantenna1 = new ModelRenderer(base, 36, 0); - rightantenna1.setTextureSize(64,32); - rightantenna1.addBox(-1F, 0F, 0F, 1, 4, 1); - rightantenna1.setRotationPoint(3F, -10.9F, 0F); - setRotation(rightantenna1, -0.7504916F, 0.0698132F, 0.0698132F); - addChild(rightantenna1); - - ModelRenderer leftantenna1 = new ModelRenderer(base, 32, 0); - leftantenna1.setTextureSize(64,32); - leftantenna1.mirror = true; - leftantenna1.addBox(0F, 0F, 0F, 1, 4, 1); - leftantenna1.setRotationPoint(-3F, -10.9F, 0F); - setRotation(leftantenna1, -0.7504916F, -0.0698132F, -0.0698132F); - addChild(leftantenna1); - - ModelRenderer rightantenna2 = new ModelRenderer(base, 36, 0); - rightantenna2.setTextureSize(64,32); - rightantenna2.addBox(-1F, 0F, 0F, 1, 4, 1); - rightantenna2.setRotationPoint(4.6F, -12.2F, 3.4F); - setRotation(rightantenna2, -1.22173F, 0.4363323F, 0.0698132F); - addChild(rightantenna2); - - ModelRenderer leftantenna2 = new ModelRenderer(base, 32, 0); - leftantenna2.setTextureSize(64,32); - leftantenna2.mirror = true; - leftantenna2.addBox(0F, 0F, 0F, 1, 4, 1); - leftantenna2.setRotationPoint(-4.6F, -12.2F, 3.4F); - setRotation(leftantenna2, -1.22173F, -0.4363323F, -0.0698132F); - addChild(leftantenna2); - } + ModelRenderer rightantenna1 = new ModelRenderer(base, 36, 0); + rightantenna1.setTextureSize(64, 32); + rightantenna1.addBox(-1F, 0F, 0F, 1, 4, 1); + rightantenna1.setRotationPoint(3F, -10.9F, 0F); + setRotation(rightantenna1, -0.7504916F, 0.0698132F, 0.0698132F); + addChild(rightantenna1); - private void setRotation(ModelRenderer model, float x, float y, float z) { - model.rotateAngleX = x; - model.rotateAngleY = y; - model.rotateAngleZ = z; - } + ModelRenderer leftantenna1 = new ModelRenderer(base, 32, 0); + leftantenna1.setTextureSize(64, 32); + leftantenna1.mirror = true; + leftantenna1.addBox(0F, 0F, 0F, 1, 4, 1); + leftantenna1.setRotationPoint(-3F, -10.9F, 0F); + setRotation(leftantenna1, -0.7504916F, -0.0698132F, -0.0698132F); + addChild(leftantenna1); + + ModelRenderer rightantenna2 = new ModelRenderer(base, 36, 0); + rightantenna2.setTextureSize(64, 32); + rightantenna2.addBox(-1F, 0F, 0F, 1, 4, 1); + rightantenna2.setRotationPoint(4.6F, -12.2F, 3.4F); + setRotation(rightantenna2, -1.22173F, 0.4363323F, 0.0698132F); + addChild(rightantenna2); + + ModelRenderer leftantenna2 = new ModelRenderer(base, 32, 0); + leftantenna2.setTextureSize(64, 32); + leftantenna2.mirror = true; + leftantenna2.addBox(0F, 0F, 0F, 1, 4, 1); + leftantenna2.setRotationPoint(-4.6F, -12.2F, 3.4F); + setRotation(leftantenna2, -1.22173F, -0.4363323F, -0.0698132F); + addChild(leftantenna2); + } + + private void setRotation(ModelRenderer model, float x, float y, float z) { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } } diff --git a/src/main/java/noppes/npcs/client/model/part/horns/ModelAntennasFront.java b/src/main/java/noppes/npcs/client/model/part/horns/ModelAntennasFront.java index c3c06c772..001fbf359 100644 --- a/src/main/java/noppes/npcs/client/model/part/horns/ModelAntennasFront.java +++ b/src/main/java/noppes/npcs/client/model/part/horns/ModelAntennasFront.java @@ -5,43 +5,43 @@ import noppes.npcs.client.model.ModelMPM; public class ModelAntennasFront extends ModelRenderer { - public ModelAntennasFront(ModelMPM base) { - super(base); + public ModelAntennasFront(ModelMPM base) { + super(base); - ModelRenderer rightantenna1 = new ModelRenderer(base, 36, 0); - rightantenna1.setTextureSize(64,32); - rightantenna1.addBox(0F, 0F, 0F, 1, 4, 1); - rightantenna1.setRotationPoint(2F, -9.4F, -2F); - setRotation(rightantenna1, 0.4014257F, 0.0698132F, 0.0698132F); - addChild(rightantenna1); + ModelRenderer rightantenna1 = new ModelRenderer(base, 36, 0); + rightantenna1.setTextureSize(64, 32); + rightantenna1.addBox(0F, 0F, 0F, 1, 4, 1); + rightantenna1.setRotationPoint(2F, -9.4F, -2F); + setRotation(rightantenna1, 0.4014257F, 0.0698132F, 0.0698132F); + addChild(rightantenna1); - ModelRenderer leftantenna1 = new ModelRenderer(base, 32, 0); - leftantenna1.setTextureSize(64,32); - leftantenna1.mirror = true; - leftantenna1.addBox(-1F, 0F, 0F, 1, 4, 1); - leftantenna1.setRotationPoint(-2F, -9.4F, -2F); - setRotation(leftantenna1, 0.4014257F, -0.0698132F, -0.0698132F); - addChild(leftantenna1); + ModelRenderer leftantenna1 = new ModelRenderer(base, 32, 0); + leftantenna1.setTextureSize(64, 32); + leftantenna1.mirror = true; + leftantenna1.addBox(-1F, 0F, 0F, 1, 4, 1); + leftantenna1.setRotationPoint(-2F, -9.4F, -2F); + setRotation(leftantenna1, 0.4014257F, -0.0698132F, -0.0698132F); + addChild(leftantenna1); - ModelRenderer rightantenna2 = new ModelRenderer(base, 36, 0); - rightantenna2.setTextureSize(64,32); - rightantenna2.addBox(0F, 0F, 0F, 1, 4, 1); - rightantenna2.setRotationPoint(3F, -10.2F, -5.3F); - setRotation(rightantenna2, 1.22173F, -0.2094395F, 0.0698132F); - addChild(rightantenna2); + ModelRenderer rightantenna2 = new ModelRenderer(base, 36, 0); + rightantenna2.setTextureSize(64, 32); + rightantenna2.addBox(0F, 0F, 0F, 1, 4, 1); + rightantenna2.setRotationPoint(3F, -10.2F, -5.3F); + setRotation(rightantenna2, 1.22173F, -0.2094395F, 0.0698132F); + addChild(rightantenna2); - ModelRenderer leftantenna2 = new ModelRenderer(base, 32, 0); - leftantenna2.setTextureSize(64,32); - leftantenna2.mirror = true; - leftantenna2.addBox(-1F, 0F, 0F, 1, 4, 1); - leftantenna2.setRotationPoint(-3F, -10.2F, -5.3F); - setRotation(leftantenna2, 1.22173F, 0.2094395F, -0.0698132F); - addChild(leftantenna2); - } + ModelRenderer leftantenna2 = new ModelRenderer(base, 32, 0); + leftantenna2.setTextureSize(64, 32); + leftantenna2.mirror = true; + leftantenna2.addBox(-1F, 0F, 0F, 1, 4, 1); + leftantenna2.setRotationPoint(-3F, -10.2F, -5.3F); + setRotation(leftantenna2, 1.22173F, 0.2094395F, -0.0698132F); + addChild(leftantenna2); + } - private void setRotation(ModelRenderer model, float x, float y, float z) { - model.rotateAngleX = x; - model.rotateAngleY = y; - model.rotateAngleZ = z; - } + private void setRotation(ModelRenderer model, float x, float y, float z) { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } } diff --git a/src/main/java/noppes/npcs/client/model/part/horns/ModelAntlerHorns.java b/src/main/java/noppes/npcs/client/model/part/horns/ModelAntlerHorns.java index 447d49b86..f0b176f8e 100644 --- a/src/main/java/noppes/npcs/client/model/part/horns/ModelAntlerHorns.java +++ b/src/main/java/noppes/npcs/client/model/part/horns/ModelAntlerHorns.java @@ -5,86 +5,86 @@ import noppes.npcs.client.model.ModelMPM; public class ModelAntlerHorns extends ModelRenderer { - public ModelAntlerHorns(ModelMPM base) { - super(base); + public ModelAntlerHorns(ModelMPM base) { + super(base); - textureWidth = 64; - textureHeight = 32; + textureWidth = 64; + textureHeight = 32; - ModelRenderer right_base_horn = new ModelRenderer(base, 58, 20); - right_base_horn.setTextureSize(64,32); - right_base_horn.addBox(0F, -5F, 0F, 1, 6, 1); - right_base_horn.setRotationPoint(-2.5F, -6F, -1F); - setRotation(right_base_horn, 0F, 0F, -0.2F); - addChild(right_base_horn); + ModelRenderer right_base_horn = new ModelRenderer(base, 58, 20); + right_base_horn.setTextureSize(64, 32); + right_base_horn.addBox(0F, -5F, 0F, 1, 6, 1); + right_base_horn.setRotationPoint(-2.5F, -6F, -1F); + setRotation(right_base_horn, 0F, 0F, -0.2F); + addChild(right_base_horn); - ModelRenderer right_horn1 = new ModelRenderer(base, 58, 20); - right_horn1.setTextureSize(64,32); - right_horn1.addBox(0F, -5F, 0F, 1, 5, 1); - right_horn1.setRotationPoint(0F, -4F, 0F); - setRotation(right_horn1, 1F, 0F, -1F); - right_base_horn.addChild(right_horn1); + ModelRenderer right_horn1 = new ModelRenderer(base, 58, 20); + right_horn1.setTextureSize(64, 32); + right_horn1.addBox(0F, -5F, 0F, 1, 5, 1); + right_horn1.setRotationPoint(0F, -4F, 0F); + setRotation(right_horn1, 1F, 0F, -1F); + right_base_horn.addChild(right_horn1); - ModelRenderer right_horn2 = new ModelRenderer(base, 58, 20); - right_horn2.setTextureSize(64,32); - right_horn2.addBox(0F, -4F, 0F, 1, 5, 1); - right_horn2.setRotationPoint(-0F, -6F, -0F); - setRotation(right_horn2, -0.5F, -0.5F, 0F); - right_base_horn.addChild(right_horn2); + ModelRenderer right_horn2 = new ModelRenderer(base, 58, 20); + right_horn2.setTextureSize(64, 32); + right_horn2.addBox(0F, -4F, 0F, 1, 5, 1); + right_horn2.setRotationPoint(-0F, -6F, -0F); + setRotation(right_horn2, -0.5F, -0.5F, 0F); + right_base_horn.addChild(right_horn2); - ModelRenderer things1 = new ModelRenderer(base, 58, 20); - things1.setTextureSize(64,32); - things1.addBox(0F, -5F, 0F, 1, 5, 1); - things1.setRotationPoint(0F, -3F, 1F); - setRotation(things1, 2F, 0.5f, 0.5f); - right_horn2.addChild(things1); + ModelRenderer things1 = new ModelRenderer(base, 58, 20); + things1.setTextureSize(64, 32); + things1.addBox(0F, -5F, 0F, 1, 5, 1); + things1.setRotationPoint(0F, -3F, 1F); + setRotation(things1, 2F, 0.5f, 0.5f); + right_horn2.addChild(things1); - ModelRenderer things2 = new ModelRenderer(base, 58, 20); - things2.setTextureSize(64,32); - things2.addBox(0F, -5F, 0F, 1, 5, 1); - things2.setRotationPoint(0F, -3F, 1F); - setRotation(things2, 2F, -0.5f, -0.5f); - right_horn2.addChild(things2); + ModelRenderer things2 = new ModelRenderer(base, 58, 20); + things2.setTextureSize(64, 32); + things2.addBox(0F, -5F, 0F, 1, 5, 1); + things2.setRotationPoint(0F, -3F, 1F); + setRotation(things2, 2F, -0.5f, -0.5f); + right_horn2.addChild(things2); - ModelRenderer left_base_horn = new ModelRenderer(base, 58, 20); - left_base_horn.setTextureSize(64,32); - left_base_horn.addBox(0F, -5F, 0F, 1, 6, 1); - left_base_horn.setRotationPoint(1.5F, -6F, -1F); - setRotation(left_base_horn, 0F, 0F, 0.2F); - addChild(left_base_horn); + ModelRenderer left_base_horn = new ModelRenderer(base, 58, 20); + left_base_horn.setTextureSize(64, 32); + left_base_horn.addBox(0F, -5F, 0F, 1, 6, 1); + left_base_horn.setRotationPoint(1.5F, -6F, -1F); + setRotation(left_base_horn, 0F, 0F, 0.2F); + addChild(left_base_horn); - ModelRenderer left_horn1 = new ModelRenderer(base, 58, 20); - left_horn1.setTextureSize(64,32); - left_horn1.addBox(0F, -5F, 0F, 1, 5, 1); - left_horn1.setRotationPoint(0F, -5F, 0F); - setRotation(left_horn1, 1F, 0F, 1F); - left_base_horn.addChild(left_horn1); + ModelRenderer left_horn1 = new ModelRenderer(base, 58, 20); + left_horn1.setTextureSize(64, 32); + left_horn1.addBox(0F, -5F, 0F, 1, 5, 1); + left_horn1.setRotationPoint(0F, -5F, 0F); + setRotation(left_horn1, 1F, 0F, 1F); + left_base_horn.addChild(left_horn1); - ModelRenderer left_horn2 = new ModelRenderer(base, 58, 20); - left_horn2.setTextureSize(64,32); - left_horn2.addBox(0F, -4F, 0F, 1, 5, 1); - left_horn2.setRotationPoint(0F, -6F, 1F); - setRotation(left_horn2, -0.5F, 0.5F, 0F); - left_base_horn.addChild(left_horn2); + ModelRenderer left_horn2 = new ModelRenderer(base, 58, 20); + left_horn2.setTextureSize(64, 32); + left_horn2.addBox(0F, -4F, 0F, 1, 5, 1); + left_horn2.setRotationPoint(0F, -6F, 1F); + setRotation(left_horn2, -0.5F, 0.5F, 0F); + left_base_horn.addChild(left_horn2); - ModelRenderer things8 = new ModelRenderer(base, 58, 20); - things8.setTextureSize(64,32); - things8.addBox(0F, -5F, 0F, 1, 5, 1); - things8.setRotationPoint(0F, -3F, 1F); - setRotation(things8, 2F, -0.5f, -0.5f); - left_horn2.addChild(things8); + ModelRenderer things8 = new ModelRenderer(base, 58, 20); + things8.setTextureSize(64, 32); + things8.addBox(0F, -5F, 0F, 1, 5, 1); + things8.setRotationPoint(0F, -3F, 1F); + setRotation(things8, 2F, -0.5f, -0.5f); + left_horn2.addChild(things8); - ModelRenderer things4 = new ModelRenderer(base, 58, 20); - things4.setTextureSize(64,32); - things4.addBox(0F, -5F, 0F, 1, 5, 1); - things4.setRotationPoint(0F, -3F, 1F); - setRotation(things4, 2F, 0.5f, 0.5f); - left_horn2.addChild(things4); - } + ModelRenderer things4 = new ModelRenderer(base, 58, 20); + things4.setTextureSize(64, 32); + things4.addBox(0F, -5F, 0F, 1, 5, 1); + things4.setRotationPoint(0F, -3F, 1F); + setRotation(things4, 2F, 0.5f, 0.5f); + left_horn2.addChild(things4); + } - private void setRotation(ModelRenderer model, float x, float y, float z) { - model.rotateAngleX = x; - model.rotateAngleY = y; - model.rotateAngleZ = z; - } + private void setRotation(ModelRenderer model, float x, float y, float z) { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } } diff --git a/src/main/java/noppes/npcs/client/model/part/horns/ModelBullHorns.java b/src/main/java/noppes/npcs/client/model/part/horns/ModelBullHorns.java index b1fe8e393..21069c452 100644 --- a/src/main/java/noppes/npcs/client/model/part/horns/ModelBullHorns.java +++ b/src/main/java/noppes/npcs/client/model/part/horns/ModelBullHorns.java @@ -5,59 +5,59 @@ import noppes.npcs.client.model.ModelMPM; public class ModelBullHorns extends ModelRenderer { - public ModelBullHorns(ModelMPM base) { - super(base); + public ModelBullHorns(ModelMPM base) { + super(base); - textureWidth = 64; - textureHeight = 32; + textureWidth = 64; + textureHeight = 32; - ModelRenderer Left1 = new ModelRenderer(base, 36, 16); - Left1.setTextureSize(64,32); - Left1.mirror = true; - Left1.addBox(0F, 0F, 0F, 2, 2, 2); - Left1.setRotationPoint(4F, -8F, -2F); - addChild(Left1); + ModelRenderer Left1 = new ModelRenderer(base, 36, 16); + Left1.setTextureSize(64, 32); + Left1.mirror = true; + Left1.addBox(0F, 0F, 0F, 2, 2, 2); + Left1.setRotationPoint(4F, -8F, -2F); + addChild(Left1); - ModelRenderer Right1 = new ModelRenderer(base, 36, 16); - Right1.setTextureSize(64,32); - Right1.addBox(-3F, 0F, 0F, 2, 2, 2); - Right1.setRotationPoint(-3F, -8F, -2F); - addChild(Right1); - - ModelRenderer Left2 = new ModelRenderer(base, 12, 16); - Left2.setTextureSize(64,32); - Left2.mirror = true; - Left2.addBox(0F, 0F, 0F, 2, 2, 2); - Left2.setRotationPoint(5F, -8F, -2F); - setRotation(Left2, 0.0371786F, 0.3346075F, -0.2602503F); - addChild(Left2); + ModelRenderer Right1 = new ModelRenderer(base, 36, 16); + Right1.setTextureSize(64, 32); + Right1.addBox(-3F, 0F, 0F, 2, 2, 2); + Right1.setRotationPoint(-3F, -8F, -2F); + addChild(Right1); - ModelRenderer Right2 = new ModelRenderer(base, 12, 16); - Right2.setTextureSize(64,32); - Right2.addBox(-2F, 0F, 0F, 2, 2, 2); - Right2.setRotationPoint(-5F, -8F, -2F); - setRotation(Right2, 0.0371786F, -0.3346075F, 0.2602503F); - addChild(Right2); + ModelRenderer Left2 = new ModelRenderer(base, 12, 16); + Left2.setTextureSize(64, 32); + Left2.mirror = true; + Left2.addBox(0F, 0F, 0F, 2, 2, 2); + Left2.setRotationPoint(5F, -8F, -2F); + setRotation(Left2, 0.0371786F, 0.3346075F, -0.2602503F); + addChild(Left2); - ModelRenderer Left3 = new ModelRenderer(base, 13, 17); - Left3.setTextureSize(64,32); - Left3.mirror = true; - Left3.addBox(-1F, 0F, 0F, 2, 1, 1); - Left3.setRotationPoint(7F, -8F, -2F); - setRotation(Left3, 0.2602503F, 0.8551081F, -0.4089647F); - addChild(Left3); - - ModelRenderer Right3 = new ModelRenderer(base, 13, 17); - Right3.setTextureSize(64,32); - Right3.addBox(-1F, 0F, 0F, 2, 1, 1); - Right3.setRotationPoint(-7F, -8F, -2F); - setRotation(Right3, -0.2602503F, -0.8551081F, 0.4089647F); - addChild(Right3); - } + ModelRenderer Right2 = new ModelRenderer(base, 12, 16); + Right2.setTextureSize(64, 32); + Right2.addBox(-2F, 0F, 0F, 2, 2, 2); + Right2.setRotationPoint(-5F, -8F, -2F); + setRotation(Right2, 0.0371786F, -0.3346075F, 0.2602503F); + addChild(Right2); - private void setRotation(ModelRenderer model, float x, float y, float z) { - model.rotateAngleX = x; - model.rotateAngleY = y; - model.rotateAngleZ = z; - } + ModelRenderer Left3 = new ModelRenderer(base, 13, 17); + Left3.setTextureSize(64, 32); + Left3.mirror = true; + Left3.addBox(-1F, 0F, 0F, 2, 1, 1); + Left3.setRotationPoint(7F, -8F, -2F); + setRotation(Left3, 0.2602503F, 0.8551081F, -0.4089647F); + addChild(Left3); + + ModelRenderer Right3 = new ModelRenderer(base, 13, 17); + Right3.setTextureSize(64, 32); + Right3.addBox(-1F, 0F, 0F, 2, 1, 1); + Right3.setRotationPoint(-7F, -8F, -2F); + setRotation(Right3, -0.2602503F, -0.8551081F, 0.4089647F); + addChild(Right3); + } + + private void setRotation(ModelRenderer model, float x, float y, float z) { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } } diff --git a/src/main/java/noppes/npcs/client/model/part/legs/ModelDigitigradeLegs.java b/src/main/java/noppes/npcs/client/model/part/legs/ModelDigitigradeLegs.java index 5b401cb73..101ad743f 100644 --- a/src/main/java/noppes/npcs/client/model/part/legs/ModelDigitigradeLegs.java +++ b/src/main/java/noppes/npcs/client/model/part/legs/ModelDigitigradeLegs.java @@ -6,105 +6,104 @@ import noppes.npcs.client.model.ModelMPM; public class ModelDigitigradeLegs extends ModelRenderer { - private ModelRenderer rightleg; - private ModelRenderer rightleg2; - private ModelRenderer rightleglow; - private ModelRenderer rightfoot; - private ModelRenderer leftleg; - private ModelRenderer leftleg2; - private ModelRenderer leftleglow; - private ModelRenderer leftfoot; + private ModelRenderer rightleg; + private ModelRenderer rightleg2; + private ModelRenderer rightleglow; + private ModelRenderer rightfoot; + private ModelRenderer leftleg; + private ModelRenderer leftleg2; + private ModelRenderer leftleglow; + private ModelRenderer leftfoot; - public boolean isRiding = false; - public boolean isSneaking = false; - public boolean isSleeping = false; - public boolean isCrawling = false; + public boolean isRiding = false; + public boolean isSneaking = false; + public boolean isSleeping = false; + public boolean isCrawling = false; - private ModelMPM base; + private ModelMPM base; - public ModelDigitigradeLegs(ModelMPM base, boolean mirror, int textWidth, int textHeight) { - super(base); - this.base = base; + public ModelDigitigradeLegs(ModelMPM base, boolean mirror, int textWidth, int textHeight) { + super(base); + this.base = base; - rightleg = new ModelRenderer(base, 0, 16); - rightleg.setTextureSize(textWidth, textHeight); - rightleg.addBox(-2F, 0F, -2F, 4, 6, 4); - rightleg.setRotationPoint(-2.1F, 11F, 0F); - setRotation(rightleg, -0.3F, 0F, 0F); - this.addChild(rightleg); + rightleg = new ModelRenderer(base, 0, 16); + rightleg.setTextureSize(textWidth, textHeight); + rightleg.addBox(-2F, 0F, -2F, 4, 6, 4); + rightleg.setRotationPoint(-2.1F, 11F, 0F); + setRotation(rightleg, -0.3F, 0F, 0F); + this.addChild(rightleg); - rightleg2 = new ModelRenderer(base, 0, 20); - rightleg2.setTextureSize(textWidth, textHeight); - rightleg2.addBox(-1.5F, -1F, -2F, 3, 7, 3); - rightleg2.setRotationPoint(0F, 4.1F, 0F); - setRotation(rightleg2, 1.1f, 0F, 0F); - rightleg.addChild(rightleg2); + rightleg2 = new ModelRenderer(base, 0, 20); + rightleg2.setTextureSize(textWidth, textHeight); + rightleg2.addBox(-1.5F, -1F, -2F, 3, 7, 3); + rightleg2.setRotationPoint(0F, 4.1F, 0F); + setRotation(rightleg2, 1.1f, 0F, 0F); + rightleg.addChild(rightleg2); - rightleglow = new ModelRenderer(base, 0, 24); - rightleglow.setTextureSize(textWidth, textHeight); - rightleglow.addBox(-1.5F, 0F, -1F, 3, 5, 2); - rightleglow.setRotationPoint(0F, 5F, 0F); - setRotation(rightleglow, -1.35F, 0F, 0F); - rightleg2.addChild(rightleglow); + rightleglow = new ModelRenderer(base, 0, 24); + rightleglow.setTextureSize(textWidth, textHeight); + rightleglow.addBox(-1.5F, 0F, -1F, 3, 5, 2); + rightleglow.setRotationPoint(0F, 5F, 0F); + setRotation(rightleglow, -1.35F, 0F, 0F); + rightleg2.addChild(rightleglow); - rightfoot = new ModelRenderer(base, 1, 26); - rightfoot.setTextureSize(textWidth, textHeight); - rightfoot.addBox(-1.5F, 0F, -5F, 3, 2, 4); - rightfoot.setRotationPoint(0F, 3.7F, 1.2F); - setRotation(rightfoot, 0.55F, 0F, 0F); - rightleglow.addChild(rightfoot); + rightfoot = new ModelRenderer(base, 1, 26); + rightfoot.setTextureSize(textWidth, textHeight); + rightfoot.addBox(-1.5F, 0F, -5F, 3, 2, 4); + rightfoot.setRotationPoint(0F, 3.7F, 1.2F); + setRotation(rightfoot, 0.55F, 0F, 0F); + rightleglow.addChild(rightfoot); - leftleg = new ModelRenderer(base, 0, 16); - leftleg.setTextureSize(textWidth, textHeight); - leftleg.mirror = true; - leftleg.addBox(-2F, 0F, -2F, 4, 6, 4); - leftleg.setRotationPoint(2.1F, 11F, 0F); - setRotation(leftleg, -0.3F, 0F, 0F); - this.addChild(leftleg); + leftleg = new ModelRenderer(base, 0, 16); + leftleg.setTextureSize(textWidth, textHeight); + leftleg.mirror = true; + leftleg.addBox(-2F, 0F, -2F, 4, 6, 4); + leftleg.setRotationPoint(2.1F, 11F, 0F); + setRotation(leftleg, -0.3F, 0F, 0F); + this.addChild(leftleg); - leftleg2 = new ModelRenderer(base, 0, 20); - leftleg2.setTextureSize(textWidth, textHeight); - leftleg2.mirror = true; - leftleg2.addBox(-1.5F, -1F, -2F, 3, 7, 3); - leftleg2.setRotationPoint(0F, 4.1F, 0F); - setRotation(leftleg2, 1.1f, 0F, 0F); - leftleg.addChild(leftleg2); + leftleg2 = new ModelRenderer(base, 0, 20); + leftleg2.setTextureSize(textWidth, textHeight); + leftleg2.mirror = true; + leftleg2.addBox(-1.5F, -1F, -2F, 3, 7, 3); + leftleg2.setRotationPoint(0F, 4.1F, 0F); + setRotation(leftleg2, 1.1f, 0F, 0F); + leftleg.addChild(leftleg2); - leftleglow = new ModelRenderer(base, 0, 24); - leftleglow.setTextureSize(textWidth, textHeight); - leftleglow.mirror = true; - leftleglow.addBox(-1.5F, 0F, -1F, 3, 5, 2); - leftleglow.setRotationPoint(0F, 5F, 0F); - setRotation(leftleglow, -1.35F, 0F, 0F); - leftleg2.addChild(leftleglow); + leftleglow = new ModelRenderer(base, 0, 24); + leftleglow.setTextureSize(textWidth, textHeight); + leftleglow.mirror = true; + leftleglow.addBox(-1.5F, 0F, -1F, 3, 5, 2); + leftleglow.setRotationPoint(0F, 5F, 0F); + setRotation(leftleglow, -1.35F, 0F, 0F); + leftleg2.addChild(leftleglow); - leftfoot = new ModelRenderer(base, 1, 26); - leftfoot.setTextureSize(textWidth, textHeight); - leftfoot.mirror = true; - leftfoot.addBox(-1.5F, 0F, -5F, 3, 2, 4); - leftfoot.setRotationPoint(0F, 3.7F, 1.2F); - setRotation(leftfoot, 0.55F, 0F, 0F); - leftleglow.addChild(leftfoot); - } - - public void setRotationAngles(float par1, float par2, float par3, float par4, float par5, float par6, Entity entity) - { - rightleg.rotateAngleX = base.bipedRightLeg.rotateAngleX - 0.3f; - leftleg.rotateAngleX = base.bipedLeftLeg.rotateAngleX - 0.3f; - rightleg.rotationPointY = base.bipedRightLeg.rotationPointY; - leftleg.rotationPointY = base.bipedLeftLeg.rotationPointY; - rightleg.rotationPointZ = base.bipedRightLeg.rotationPointZ; - leftleg.rotationPointZ = base.bipedLeftLeg.rotationPointZ; - if(!base.isSneak){ - leftleg.rotationPointY--; - rightleg.rotationPointY--; - } - + leftfoot = new ModelRenderer(base, 1, 26); + leftfoot.setTextureSize(textWidth, textHeight); + leftfoot.mirror = true; + leftfoot.addBox(-1.5F, 0F, -5F, 3, 2, 4); + leftfoot.setRotationPoint(0F, 3.7F, 1.2F); + setRotation(leftfoot, 0.55F, 0F, 0F); + leftleglow.addChild(leftfoot); } - private void setRotation(ModelRenderer model, float x, float y, float z) { - model.rotateAngleX = x; - model.rotateAngleY = y; - model.rotateAngleZ = z; - } + public void setRotationAngles(float par1, float par2, float par3, float par4, float par5, float par6, Entity entity) { + rightleg.rotateAngleX = base.bipedRightLeg.rotateAngleX - 0.3f; + leftleg.rotateAngleX = base.bipedLeftLeg.rotateAngleX - 0.3f; + rightleg.rotationPointY = base.bipedRightLeg.rotationPointY; + leftleg.rotationPointY = base.bipedLeftLeg.rotationPointY; + rightleg.rotationPointZ = base.bipedRightLeg.rotationPointZ; + leftleg.rotationPointZ = base.bipedLeftLeg.rotationPointZ; + if (!base.isSneak) { + leftleg.rotationPointY--; + rightleg.rotationPointY--; + } + + } + + private void setRotation(ModelRenderer model, float x, float y, float z) { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } } diff --git a/src/main/java/noppes/npcs/client/model/part/legs/ModelMermaidLegs.java b/src/main/java/noppes/npcs/client/model/part/legs/ModelMermaidLegs.java index 3767566f4..e87490157 100644 --- a/src/main/java/noppes/npcs/client/model/part/legs/ModelMermaidLegs.java +++ b/src/main/java/noppes/npcs/client/model/part/legs/ModelMermaidLegs.java @@ -7,51 +7,51 @@ import net.minecraft.util.MathHelper; public class ModelMermaidLegs extends ModelRenderer { - ModelRenderer top; - ModelRenderer middle; - ModelRenderer bottom; - ModelRenderer fin1; - ModelRenderer fin2; + ModelRenderer top; + ModelRenderer middle; + ModelRenderer bottom; + ModelRenderer fin1; + ModelRenderer fin2; - public boolean isRiding = false; - public boolean isSneaking = false; - public boolean isSleeping = false; - public boolean isCrawling = false; + public boolean isRiding = false; + public boolean isSneaking = false; + public boolean isSleeping = false; + public boolean isCrawling = false; - public ModelMermaidLegs(ModelBase base) { + public ModelMermaidLegs(ModelBase base) { super(base); textureWidth = 64; textureHeight = 32; top = new ModelRenderer(base, 0, 16); - top.setTextureSize(64,32); + top.setTextureSize(64, 32); top.addBox(-2F, -2.5F, -2F, 8, 9, 4); top.setRotationPoint(-2F, 14F, 1F); setRotation(top, 0.26F, 0F, 0F); middle = new ModelRenderer(base, 28, 0); - middle.setTextureSize(64,32); + middle.setTextureSize(64, 32); middle.addBox(0F, 0F, 0F, 7, 6, 4); middle.setRotationPoint(-1.5F, 6.5F, -1F); setRotation(middle, 0.86f, 0F, 0F); top.addChild(middle); bottom = new ModelRenderer(base, 24, 16); - bottom.setTextureSize(64,32); + bottom.setTextureSize(64, 32); bottom.addBox(0F, 0F, 0F, 6, 7, 3); bottom.setRotationPoint(0.5F, 6F, 0.5f); setRotation(bottom, 0.15f, 0F, 0F); middle.addChild(bottom); fin1 = new ModelRenderer(base, 0, 0); - fin1.setTextureSize(64,32); + fin1.setTextureSize(64, 32); fin1.addBox(0F, 0F, 0F, 5, 9, 1); fin1.setRotationPoint(0F, 4.5F, 1F); setRotation(fin1, 0.05f, 0, 0.5911399F); bottom.addChild(fin1); fin2 = new ModelRenderer(base, 0, 0); - fin2.setTextureSize(64,32); + fin2.setTextureSize(64, 32); fin2.mirror = true; fin2.addBox(-5F, 0F, 0F, 5, 9, 1); fin2.setRotationPoint(6F, 4.5F, 1F); @@ -60,37 +60,36 @@ public class ModelMermaidLegs extends ModelRenderer { } - @Override - public void render(float f5) { - if (isHidden || !showModel) - return; - top.render(f5); - } + @Override + public void render(float f5) { + if (isHidden || !showModel) + return; + top.render(f5); + } - private void setRotation(ModelRenderer model, float x, float y, float z) { - model.rotateAngleX = x; - model.rotateAngleY = y; - model.rotateAngleZ = z; - } + private void setRotation(ModelRenderer model, float x, float y, float z) { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } - public void setRotationAngles(float par1, float par2, float par3, - float par4, float par5, float par6, Entity entity) { - float ani = MathHelper.sin(par1 * 0.6662F); - top.setRotationPoint(-2F, 14F, 1F); - if(ani > 0.2) - ani /= 3f; - if(this.isSleeping || this.isCrawling){ - top.rotateAngleX = middle.rotateAngleX = bottom.rotateAngleX = fin2.rotateAngleX = 0; - } - else{ - top.rotateAngleX = 0.26F - ani * 0.2F * par2; - middle.rotateAngleX = 0.86f - ani * 0.24F * par2; - bottom.rotateAngleX = 0.15f - ani * 0.28F * par2; - fin2.rotateAngleX = fin1.rotateAngleX = 0.05f - ani * 0.35F * par2; + public void setRotationAngles(float par1, float par2, float par3, + float par4, float par5, float par6, Entity entity) { + float ani = MathHelper.sin(par1 * 0.6662F); + top.setRotationPoint(-2F, 14F, 1F); + if (ani > 0.2) + ani /= 3f; + if (this.isSleeping || this.isCrawling) { + top.rotateAngleX = middle.rotateAngleX = bottom.rotateAngleX = fin2.rotateAngleX = 0; + } else { + top.rotateAngleX = 0.26F - ani * 0.2F * par2; + middle.rotateAngleX = 0.86f - ani * 0.24F * par2; + bottom.rotateAngleX = 0.15f - ani * 0.28F * par2; + fin2.rotateAngleX = fin1.rotateAngleX = 0.05f - ani * 0.35F * par2; - if(entity.isSneaking()){ - top.setRotationPoint(-2F, 12F, 6F); - } - } - } + if (entity.isSneaking()) { + top.setRotationPoint(-2F, 12F, 6F); + } + } + } } diff --git a/src/main/java/noppes/npcs/client/model/part/legs/ModelMermaidLegs2.java b/src/main/java/noppes/npcs/client/model/part/legs/ModelMermaidLegs2.java index ed69d0ac9..78c192721 100644 --- a/src/main/java/noppes/npcs/client/model/part/legs/ModelMermaidLegs2.java +++ b/src/main/java/noppes/npcs/client/model/part/legs/ModelMermaidLegs2.java @@ -7,114 +7,113 @@ import net.minecraft.util.MathHelper; public class ModelMermaidLegs2 extends ModelRenderer { - ModelRenderer Tail1; - ModelRenderer Tail2; - ModelRenderer Tail3; - ModelRenderer Tail4; - ModelRenderer Tail5; - ModelRenderer Tail6; - ModelRenderer Tail7; - ModelRenderer Tail8; + ModelRenderer Tail1; + ModelRenderer Tail2; + ModelRenderer Tail3; + ModelRenderer Tail4; + ModelRenderer Tail5; + ModelRenderer Tail6; + ModelRenderer Tail7; + ModelRenderer Tail8; public boolean isRiding = false; public boolean isSneaking = false; public boolean isSleeping = false; public boolean isCrawling = false; - public ModelMermaidLegs2(ModelBase base) { - super(base); - textureWidth = 64; - textureHeight = 32; + public ModelMermaidLegs2(ModelBase base) { + super(base); + textureWidth = 64; + textureHeight = 32; - Tail1 = new ModelRenderer(base, 0, 18); - Tail1.setTextureSize(64,32); - Tail1.addBox(0F, 0F, 0F, 8, 6, 4); - Tail1.setRotationPoint(-4F, 12F, -2F); - setRotation(Tail1, 0.075F, 0F, 0F); + Tail1 = new ModelRenderer(base, 0, 18); + Tail1.setTextureSize(64, 32); + Tail1.addBox(0F, 0F, 0F, 8, 6, 4); + Tail1.setRotationPoint(-4F, 12F, -2F); + setRotation(Tail1, 0.075F, 0F, 0F); - Tail2 = new ModelRenderer(base, 0, 18); - Tail2.setTextureSize(64,32); - Tail2.addBox(0F, 0F, 0F, 6, 5, 3); - Tail2.setRotationPoint(1F, 5.5F, 0.3F); - setRotation(Tail2, 0.56F, 0F, 0F); - Tail1.addChild(Tail2); + Tail2 = new ModelRenderer(base, 0, 18); + Tail2.setTextureSize(64, 32); + Tail2.addBox(0F, 0F, 0F, 6, 5, 3); + Tail2.setRotationPoint(1F, 5.5F, 0.3F); + setRotation(Tail2, 0.56F, 0F, 0F); + Tail1.addChild(Tail2); - Tail3 = new ModelRenderer(base, 0, 18); - Tail3.setTextureSize(64,32); - Tail3.addBox(0F, 0F, 0F, 5, 5, 2); - Tail3.setRotationPoint(5.5F, 4F, 2.5F); - setRotation(Tail3, -0.37818F, 3.141593F, 0F); - Tail2.addChild(Tail3); + Tail3 = new ModelRenderer(base, 0, 18); + Tail3.setTextureSize(64, 32); + Tail3.addBox(0F, 0F, 0F, 5, 5, 2); + Tail3.setRotationPoint(5.5F, 4F, 2.5F); + setRotation(Tail3, -0.37818F, 3.141593F, 0F); + Tail2.addChild(Tail3); - Tail4 = new ModelRenderer(base, 0, 20); - Tail4.setTextureSize(64,32); - Tail4.addBox(0F, 0F, 0F, 4, 3, 1); - Tail4.setRotationPoint(0.5F, 4.5F, 0.5F); - setRotation(Tail4, -0.1f, 0, 0F); - Tail3.addChild(Tail4); + Tail4 = new ModelRenderer(base, 0, 20); + Tail4.setTextureSize(64, 32); + Tail4.addBox(0F, 0F, 0F, 4, 3, 1); + Tail4.setRotationPoint(0.5F, 4.5F, 0.5F); + setRotation(Tail4, -0.1f, 0, 0F); + Tail3.addChild(Tail4); - Tail5 = new ModelRenderer(base, 0, 20); - Tail5.setTextureSize(64,32); - Tail5.addBox(0F, 0F, 0F, 1, 3, 1); - Tail5.setRotationPoint(-1F, 1.5F, 0F); - setRotation(Tail5, 0, 0, 0F); - Tail4.addChild(Tail5); + Tail5 = new ModelRenderer(base, 0, 20); + Tail5.setTextureSize(64, 32); + Tail5.addBox(0F, 0F, 0F, 1, 3, 1); + Tail5.setRotationPoint(-1F, 1.5F, 0F); + setRotation(Tail5, 0, 0, 0F); + Tail4.addChild(Tail5); - Tail6 = new ModelRenderer(base, 0, 20); - Tail6.setTextureSize(64,32); - Tail6.addBox(0F, 0F, 0F, 1, 3, 1); - Tail6.setRotationPoint(-2F, 3F, 0F); - setRotation(Tail6, 0, 0, 0F); - Tail4.addChild(Tail6); + Tail6 = new ModelRenderer(base, 0, 20); + Tail6.setTextureSize(64, 32); + Tail6.addBox(0F, 0F, 0F, 1, 3, 1); + Tail6.setRotationPoint(-2F, 3F, 0F); + setRotation(Tail6, 0, 0, 0F); + Tail4.addChild(Tail6); - Tail7 = new ModelRenderer(base, 0, 20); - Tail7.setTextureSize(64,32); - Tail7.addBox(0F, 0F, 0F, 1, 3, 1); - Tail7.setRotationPoint(4F, 1.5F, 0F); - setRotation(Tail7, 0, 0, 0F); - Tail4.addChild(Tail7); + Tail7 = new ModelRenderer(base, 0, 20); + Tail7.setTextureSize(64, 32); + Tail7.addBox(0F, 0F, 0F, 1, 3, 1); + Tail7.setRotationPoint(4F, 1.5F, 0F); + setRotation(Tail7, 0, 0, 0F); + Tail4.addChild(Tail7); - Tail8 = new ModelRenderer(base, 0, 20); - Tail8.setTextureSize(64,32); - Tail8.addBox(0F, 0F, 0F, 1, 3, 1); - Tail8.setRotationPoint(5F, 3F, 0F); - setRotation(Tail8, 0, 0, 0F); - Tail4.addChild(Tail8); + Tail8 = new ModelRenderer(base, 0, 20); + Tail8.setTextureSize(64, 32); + Tail8.addBox(0F, 0F, 0F, 1, 3, 1); + Tail8.setRotationPoint(5F, 3F, 0F); + setRotation(Tail8, 0, 0, 0F); + Tail4.addChild(Tail8); - } + } - @Override - public void render(float f5) { - if (isHidden || !showModel) - return; - Tail1.render(f5); - } + @Override + public void render(float f5) { + if (isHidden || !showModel) + return; + Tail1.render(f5); + } - private void setRotation(ModelRenderer model, float x, float y, float z) { - model.rotateAngleX = x; - model.rotateAngleY = y; - model.rotateAngleZ = z; - } + private void setRotation(ModelRenderer model, float x, float y, float z) { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } - public void setRotationAngles(float par1, float par2, float par3, float par4, float par5, float par6, - Entity entity) { - Tail1.setRotationPoint(-4F, 12F, -2F); - float ani = MathHelper.sin(par1 * 0.6662F); - if (ani > 0.2) - ani /= 3f; - if(this.isSleeping || this.isCrawling){ - Tail1.rotateAngleX = Tail2.rotateAngleX = Tail3.rotateAngleX = Tail4.rotateAngleX = 0; - } - else{ - Tail1.rotateAngleX = 0.2F - ani * 0.2F * par2; - Tail2.rotateAngleX = 0.56F - ani * 0.24F * par2; - Tail3.rotateAngleX = -0.4F + ani * 0.24F * par2; - Tail4.rotateAngleX = -0.1f + ani * 0.10F * par2; + public void setRotationAngles(float par1, float par2, float par3, float par4, float par5, float par6, + Entity entity) { + Tail1.setRotationPoint(-4F, 12F, -2F); + float ani = MathHelper.sin(par1 * 0.6662F); + if (ani > 0.2) + ani /= 3f; + if (this.isSleeping || this.isCrawling) { + Tail1.rotateAngleX = Tail2.rotateAngleX = Tail3.rotateAngleX = Tail4.rotateAngleX = 0; + } else { + Tail1.rotateAngleX = 0.2F - ani * 0.2F * par2; + Tail2.rotateAngleX = 0.56F - ani * 0.24F * par2; + Tail3.rotateAngleX = -0.4F + ani * 0.24F * par2; + Tail4.rotateAngleX = -0.1f + ani * 0.10F * par2; - if(entity.isSneaking()){ - Tail1.setRotationPoint(-4F, 10F, 3F); - } - } + if (entity.isSneaking()) { + Tail1.setRotationPoint(-4F, 10F, 3F); + } + } - } -} \ No newline at end of file + } +} diff --git a/src/main/java/noppes/npcs/client/model/part/legs/ModelNagaLegs.java b/src/main/java/noppes/npcs/client/model/part/legs/ModelNagaLegs.java index 5b34f1683..345878668 100644 --- a/src/main/java/noppes/npcs/client/model/part/legs/ModelNagaLegs.java +++ b/src/main/java/noppes/npcs/client/model/part/legs/ModelNagaLegs.java @@ -7,7 +7,7 @@ import net.minecraft.util.MathHelper; import noppes.npcs.client.model.util.ModelPlaneRenderer; import org.lwjgl.opengl.GL11; -public class ModelNagaLegs extends ModelRenderer{ +public class ModelNagaLegs extends ModelRenderer { private ModelRenderer nagaPart1; private ModelRenderer nagaPart2; @@ -19,202 +19,201 @@ public class ModelNagaLegs extends ModelRenderer{ public boolean isSneaking = false; public boolean isSleeping = false; public boolean isCrawling = false; - - public ModelNagaLegs(ModelBase base) { - super(base); - - nagaPart1 = new ModelRenderer(base,0,0); + + public ModelNagaLegs(ModelBase base) { + super(base); + + nagaPart1 = new ModelRenderer(base, 0, 0); // nagaPart1.setTextureSize(64,32); - - ModelRenderer legPart = new ModelRenderer(base,0,16); + + ModelRenderer legPart = new ModelRenderer(base, 0, 16); // legPart.setTextureSize(64,32); - legPart.addBox(0, -2, -2, 4, 4, 4); - legPart.setRotationPoint(-4, 0, 0); - nagaPart1.addChild(legPart); - legPart = new ModelRenderer(base,0,16); - legPart.mirror = true; - legPart.addBox(0, -2, -2, 4, 4, 4); - nagaPart1.addChild(legPart); + legPart.addBox(0, -2, -2, 4, 4, 4); + legPart.setRotationPoint(-4, 0, 0); + nagaPart1.addChild(legPart); + legPart = new ModelRenderer(base, 0, 16); + legPart.mirror = true; + legPart.addBox(0, -2, -2, 4, 4, 4); + nagaPart1.addChild(legPart); - nagaPart2 = new ModelRenderer(base,0,0); + nagaPart2 = new ModelRenderer(base, 0, 0); // nagaPart2.setTextureSize(64,32); - nagaPart2.childModels = nagaPart1.childModels; + nagaPart2.childModels = nagaPart1.childModels; - nagaPart3 = new ModelRenderer(base,0,0); + nagaPart3 = new ModelRenderer(base, 0, 0); // nagaPart3.setTextureSize(64,32); - - ModelPlaneRenderer plane = new ModelPlaneRenderer(base, 4, 24); - plane.addBackPlane(0,-2, 0, 4, 4); - plane.setRotationPoint(-4, 0, 0); - nagaPart3.addChild(plane); - plane = new ModelPlaneRenderer(base, 4, 24); - plane.mirror = true; - plane.addBackPlane(0,-2, 0, 4, 4); - nagaPart3.addChild(plane); - - plane = new ModelPlaneRenderer(base, 8, 24); - plane.addBackPlane(0,-2, 6, 4, 4); - plane.setRotationPoint(-4, 0, 0); - nagaPart3.addChild(plane); - plane = new ModelPlaneRenderer(base, 8, 24); - plane.mirror = true; - plane.addBackPlane(0,-2, 6, 4, 4); - nagaPart3.addChild(plane); - plane = new ModelPlaneRenderer(base, 4, 26); - plane.addTopPlane(0,-2, -6, 4, 6); - plane.setRotationPoint(-4, 0, 0); - plane.rotateAngleX = (float) (Math.PI); - nagaPart3.addChild(plane); - plane = new ModelPlaneRenderer(base, 4, 26); - plane.mirror = true; - plane.addTopPlane(0,-2, -6, 4, 6); - plane.rotateAngleX = (float) (Math.PI); - nagaPart3.addChild(plane); + ModelPlaneRenderer plane = new ModelPlaneRenderer(base, 4, 24); + plane.addBackPlane(0, -2, 0, 4, 4); + plane.setRotationPoint(-4, 0, 0); + nagaPart3.addChild(plane); + plane = new ModelPlaneRenderer(base, 4, 24); + plane.mirror = true; + plane.addBackPlane(0, -2, 0, 4, 4); + nagaPart3.addChild(plane); - plane = new ModelPlaneRenderer(base, 8, 26); - plane.addTopPlane(0,-2, 0, 4, 6); - plane.setRotationPoint(-4, 0, 0); - nagaPart3.addChild(plane); - plane = new ModelPlaneRenderer(base, 8, 26); - plane.mirror = true; - plane.addTopPlane(0,-2, 0, 4, 6); - nagaPart3.addChild(plane);; + plane = new ModelPlaneRenderer(base, 8, 24); + plane.addBackPlane(0, -2, 6, 4, 4); + plane.setRotationPoint(-4, 0, 0); + nagaPart3.addChild(plane); + plane = new ModelPlaneRenderer(base, 8, 24); + plane.mirror = true; + plane.addBackPlane(0, -2, 6, 4, 4); + nagaPart3.addChild(plane); - plane = new ModelPlaneRenderer(base, 0, 26); - plane.rotateAngleX = (float) (Math.PI / 2); - plane.addSidePlane(0,0, -2, 6, 4); - plane.setRotationPoint(-4, 0, 0); - nagaPart3.addChild(plane); - plane = new ModelPlaneRenderer(base, 0, 26); - plane.rotateAngleX = (float) (Math.PI / 2); - plane.addSidePlane(4,0, -2, 6, 4); - nagaPart3.addChild(plane); + plane = new ModelPlaneRenderer(base, 4, 26); + plane.addTopPlane(0, -2, -6, 4, 6); + plane.setRotationPoint(-4, 0, 0); + plane.rotateAngleX = (float) (Math.PI); + nagaPart3.addChild(plane); + plane = new ModelPlaneRenderer(base, 4, 26); + plane.mirror = true; + plane.addTopPlane(0, -2, -6, 4, 6); + plane.rotateAngleX = (float) (Math.PI); + nagaPart3.addChild(plane); - nagaPart4 = new ModelRenderer(base,0,0); + plane = new ModelPlaneRenderer(base, 8, 26); + plane.addTopPlane(0, -2, 0, 4, 6); + plane.setRotationPoint(-4, 0, 0); + nagaPart3.addChild(plane); + plane = new ModelPlaneRenderer(base, 8, 26); + plane.mirror = true; + plane.addTopPlane(0, -2, 0, 4, 6); + nagaPart3.addChild(plane); + ; + + plane = new ModelPlaneRenderer(base, 0, 26); + plane.rotateAngleX = (float) (Math.PI / 2); + plane.addSidePlane(0, 0, -2, 6, 4); + plane.setRotationPoint(-4, 0, 0); + nagaPart3.addChild(plane); + plane = new ModelPlaneRenderer(base, 0, 26); + plane.rotateAngleX = (float) (Math.PI / 2); + plane.addSidePlane(4, 0, -2, 6, 4); + nagaPart3.addChild(plane); + + nagaPart4 = new ModelRenderer(base, 0, 0); // nagaPart4.setTextureSize(64,32); - nagaPart4.childModels = nagaPart3.childModels; - - nagaPart5 = new ModelRenderer(base,0,0); -// nagaPart5.setTextureSize(64,32); - - legPart = new ModelRenderer(base,56,20); - legPart.addBox(0, 0, -2, 2, 5, 2); - legPart.setRotationPoint(-2, 0, 0); - legPart.rotateAngleX = (float) (Math.PI/2); - nagaPart5.addChild(legPart); - legPart = new ModelRenderer(base,56,20); - legPart.mirror = true; - legPart.addBox(0, 0, -2, 2, 5, 2); - legPart.rotateAngleX = (float) (Math.PI/2); - nagaPart5.addChild(legPart); + nagaPart4.childModels = nagaPart3.childModels; - this.addChild(nagaPart1); - this.addChild(nagaPart2); - this.addChild(nagaPart3); - this.addChild(nagaPart4); - this.addChild(nagaPart5); + nagaPart5 = new ModelRenderer(base, 0, 0); +// nagaPart5.setTextureSize(64,32); + + legPart = new ModelRenderer(base, 56, 20); + legPart.addBox(0, 0, -2, 2, 5, 2); + legPart.setRotationPoint(-2, 0, 0); + legPart.rotateAngleX = (float) (Math.PI / 2); + nagaPart5.addChild(legPart); + legPart = new ModelRenderer(base, 56, 20); + legPart.mirror = true; + legPart.addBox(0, 0, -2, 2, 5, 2); + legPart.rotateAngleX = (float) (Math.PI / 2); + nagaPart5.addChild(legPart); + + this.addChild(nagaPart1); + this.addChild(nagaPart2); + this.addChild(nagaPart3); + this.addChild(nagaPart4); + this.addChild(nagaPart5); nagaPart1.setRotationPoint(0F, 14.0F, 0.0F); nagaPart2.setRotationPoint(0, 18.0F, 0.6F); nagaPart3.setRotationPoint(0F, 22.0F, -0.3F); nagaPart4.setRotationPoint(0F, 22.0F, 5F); nagaPart5.setRotationPoint(0F, 22.0F, 10F); - } - public void setRotationAngles(float par1, float par2, float par3, float par4, float par5, float par6, Entity entity) - { - this.nagaPart1.rotateAngleY = MathHelper.cos(par1 * 0.6662F) * 0.26F * par2; - this.nagaPart2.rotateAngleY = MathHelper.cos(par1 * 0.6662F) * 0.5F * par2; - this.nagaPart3.rotateAngleY = MathHelper.cos(par1 * 0.6662F) * 0.26F * par2; - this.nagaPart4.rotateAngleY = -MathHelper.cos(par1 * 0.6662F) * 0.16F * par2; - this.nagaPart5.rotateAngleY = -MathHelper.cos(par1 * 0.6662F) * 0.3F * par2; + } - nagaPart1.setRotationPoint(0F, 14.0F, 0.0F); - nagaPart2.setRotationPoint(0, 18.0F, 0.6F); - nagaPart3.setRotationPoint(0F, 22.0F, -0.3F); - nagaPart4.setRotationPoint(0F, 22.0F, 5F); - nagaPart5.setRotationPoint(0F, 22.0F, 10F); + public void setRotationAngles(float par1, float par2, float par3, float par4, float par5, float par6, Entity entity) { + this.nagaPart1.rotateAngleY = MathHelper.cos(par1 * 0.6662F) * 0.26F * par2; + this.nagaPart2.rotateAngleY = MathHelper.cos(par1 * 0.6662F) * 0.5F * par2; + this.nagaPart3.rotateAngleY = MathHelper.cos(par1 * 0.6662F) * 0.26F * par2; + this.nagaPart4.rotateAngleY = -MathHelper.cos(par1 * 0.6662F) * 0.16F * par2; + this.nagaPart5.rotateAngleY = -MathHelper.cos(par1 * 0.6662F) * 0.3F * par2; - nagaPart1.rotateAngleX = 0; - nagaPart2.rotateAngleX = 0; - nagaPart3.rotateAngleX = 0; - nagaPart4.rotateAngleX = 0; - nagaPart5.rotateAngleX = 0; - - if(isSleeping || isCrawling){ - nagaPart3.rotateAngleX = (float) -(Math.PI/2); - nagaPart4.rotateAngleX = (float) -(Math.PI/2); - nagaPart5.rotateAngleX = (float) -(Math.PI/2); + nagaPart1.setRotationPoint(0F, 14.0F, 0.0F); + nagaPart2.setRotationPoint(0, 18.0F, 0.6F); + nagaPart3.setRotationPoint(0F, 22.0F, -0.3F); + nagaPart4.setRotationPoint(0F, 22.0F, 5F); + nagaPart5.setRotationPoint(0F, 22.0F, 10F); - nagaPart3.rotationPointY -= 2; - nagaPart3.rotationPointZ = 0.9f; + nagaPart1.rotateAngleX = 0; + nagaPart2.rotateAngleX = 0; + nagaPart3.rotateAngleX = 0; + nagaPart4.rotateAngleX = 0; + nagaPart5.rotateAngleX = 0; - nagaPart4.rotationPointY += 4; - nagaPart4.rotationPointZ = 0.9f; - - nagaPart5.rotationPointY += 7; - nagaPart5.rotationPointZ = 2.9f; - } - if(this.isRiding){ - nagaPart1.rotationPointY-= 1; - nagaPart1.rotateAngleX = (float) -(Math.PI/16f); - nagaPart1.rotationPointZ = -1; - - nagaPart2.rotationPointY-= 4; - nagaPart2.rotationPointZ = -1; - - nagaPart3.rotationPointY-= 9; - nagaPart3.rotationPointZ -= 1; - nagaPart4.rotationPointY-= 13; - nagaPart4.rotationPointZ -= 1; - nagaPart5.rotationPointY-= 9; - nagaPart5.rotationPointZ -= 1; - if (this.isSneaking){ - nagaPart1.rotationPointZ += 5; - nagaPart3.rotationPointZ += 5; - nagaPart4.rotationPointZ += 5; - nagaPart5.rotationPointZ += 4; - nagaPart1.rotationPointY--; - nagaPart2.rotationPointY--; - nagaPart3.rotationPointY--; - nagaPart4.rotationPointY--; - nagaPart5.rotationPointY--; - } - } - else if (this.isSneaking){ - nagaPart1.rotationPointY--; - nagaPart2.rotationPointY--; - nagaPart3.rotationPointY--; - nagaPart4.rotationPointY--; - nagaPart5.rotationPointY--; + if (isSleeping || isCrawling) { + nagaPart3.rotateAngleX = (float) -(Math.PI / 2); + nagaPart4.rotateAngleX = (float) -(Math.PI / 2); + nagaPart5.rotateAngleX = (float) -(Math.PI / 2); - nagaPart1.rotationPointZ = 5; - nagaPart2.rotationPointZ = 3; + nagaPart3.rotationPointY -= 2; + nagaPart3.rotationPointZ = 0.9f; + + nagaPart4.rotationPointY += 4; + nagaPart4.rotationPointZ = 0.9f; + + nagaPart5.rotationPointY += 7; + nagaPart5.rotationPointZ = 2.9f; + } + if (this.isRiding) { + nagaPart1.rotationPointY -= 1; + nagaPart1.rotateAngleX = (float) -(Math.PI / 16f); + nagaPart1.rotationPointZ = -1; + + nagaPart2.rotationPointY -= 4; + nagaPart2.rotationPointZ = -1; + + nagaPart3.rotationPointY -= 9; + nagaPart3.rotationPointZ -= 1; + nagaPart4.rotationPointY -= 13; + nagaPart4.rotationPointZ -= 1; + nagaPart5.rotationPointY -= 9; + nagaPart5.rotationPointZ -= 1; + if (this.isSneaking) { + nagaPart1.rotationPointZ += 5; + nagaPart3.rotationPointZ += 5; + nagaPart4.rotationPointZ += 5; + nagaPart5.rotationPointZ += 4; + nagaPart1.rotationPointY--; + nagaPart2.rotationPointY--; + nagaPart3.rotationPointY--; + nagaPart4.rotationPointY--; + nagaPart5.rotationPointY--; + } + } else if (this.isSneaking) { + nagaPart1.rotationPointY--; + nagaPart2.rotationPointY--; + nagaPart3.rotationPointY--; + nagaPart4.rotationPointY--; + nagaPart5.rotationPointY--; + + nagaPart1.rotationPointZ = 5; + nagaPart2.rotationPointZ = 3; } } - - @Override - public void render(float par7) - { - if(isHidden || !showModel) - return; - - nagaPart1.render(par7); - nagaPart3.render(par7); - if(!this.isRiding) - nagaPart2.render(par7); + @Override + public void render(float par7) { + if (isHidden || !showModel) + return; + + nagaPart1.render(par7); + nagaPart3.render(par7); + + if (!this.isRiding) + nagaPart2.render(par7); GL11.glPushMatrix(); - GL11.glScalef(0.74f, 0.7f,0.85f); + GL11.glScalef(0.74f, 0.7f, 0.85f); GL11.glTranslatef(nagaPart3.rotateAngleY, 0.66f, 0.06F); nagaPart4.render(par7); - GL11.glPopMatrix(); - + GL11.glPopMatrix(); + GL11.glPushMatrix(); GL11.glTranslatef(nagaPart3.rotateAngleY + nagaPart4.rotateAngleY, 0, 0); nagaPart5.render(par7); - GL11.glPopMatrix(); + GL11.glPopMatrix(); } } diff --git a/src/main/java/noppes/npcs/client/model/part/tails/ModelCanineTail.java b/src/main/java/noppes/npcs/client/model/part/tails/ModelCanineTail.java index 16715a9bb..cdb31eec6 100644 --- a/src/main/java/noppes/npcs/client/model/part/tails/ModelCanineTail.java +++ b/src/main/java/noppes/npcs/client/model/part/tails/ModelCanineTail.java @@ -5,63 +5,63 @@ import net.minecraft.client.model.ModelRenderer; import net.minecraft.entity.Entity; public class ModelCanineTail extends ModelRenderer { - ModelRenderer Base_1; - ModelRenderer BaseB_1; - ModelRenderer Mid_1; - ModelRenderer Mid_2; - ModelRenderer MidB_1; - ModelRenderer End_1; + ModelRenderer Base_1; + ModelRenderer BaseB_1; + ModelRenderer Mid_1; + ModelRenderer Mid_2; + ModelRenderer MidB_1; + ModelRenderer End_1; - public ModelCanineTail(ModelBiped base) { - super(base); + public ModelCanineTail(ModelBiped base) { + super(base); - Base_1 = new ModelRenderer(base, 56, 16); - Base_1.addBox(-1F, 0F, -3F, 2, 3, 2); - Base_1.setRotationPoint(0F, 1F, -1.2F); - setRotation(Base_1, -0.4490659F, 3.141593F, 0F); - addChild(Base_1); + Base_1 = new ModelRenderer(base, 56, 16); + Base_1.addBox(-1F, 0F, -3F, 2, 3, 2); + Base_1.setRotationPoint(0F, 1F, -1.2F); + setRotation(Base_1, -0.4490659F, 3.141593F, 0F); + addChild(Base_1); - BaseB_1 = new ModelRenderer(base, 56, 16); - BaseB_1.addBox(-0.5F, 0F, -1.5F, 1, 3, 1); - Base_1.addChild(BaseB_1); + BaseB_1 = new ModelRenderer(base, 56, 16); + BaseB_1.addBox(-0.5F, 0F, -1.5F, 1, 3, 1); + Base_1.addChild(BaseB_1); - Mid_1 = new ModelRenderer(base, 56, 20); - Mid_1.addBox(-1F, 3F, -2.8F, 2, 2, 2); - setRotation(Mid_1, -0.16F, 0F, 0F); - Base_1.addChild(Mid_1); + Mid_1 = new ModelRenderer(base, 56, 20); + Mid_1.addBox(-1F, 3F, -2.8F, 2, 2, 2); + setRotation(Mid_1, -0.16F, 0F, 0F); + Base_1.addChild(Mid_1); - Mid_2 = new ModelRenderer(base, 56, 22); - Mid_2.addBox(-1.5F, 5F, -1.5F, 3, 6, 3); - Mid_2.setRotationPoint(0, 0, -1.5f); - setRotation(Mid_2, -0F, 0F, 0F); - Mid_1.addChild(Mid_2); + Mid_2 = new ModelRenderer(base, 56, 22); + Mid_2.addBox(-1.5F, 5F, -1.5F, 3, 6, 3); + Mid_2.setRotationPoint(0, 0, -1.5f); + setRotation(Mid_2, -0F, 0F, 0F); + Mid_1.addChild(Mid_2); - ModelRenderer Mid_2b = new ModelRenderer(base, 56, 22); - Mid_2b.addBox(-1.5F, 5F, -1.5F, 3, 6, 3); - setRotation(Mid_2b, -0F, (float)Math.PI, 0F); - Mid_2.addChild(Mid_2b); + ModelRenderer Mid_2b = new ModelRenderer(base, 56, 22); + Mid_2b.addBox(-1.5F, 5F, -1.5F, 3, 6, 3); + setRotation(Mid_2b, -0F, (float) Math.PI, 0F); + Mid_2.addChild(Mid_2b); - MidB_1 = new ModelRenderer(base, 56, 20); - MidB_1.addBox(-0.5F, 3F, -1F, 1, 2, 1); - Mid_1.addChild(MidB_1); + MidB_1 = new ModelRenderer(base, 56, 20); + MidB_1.addBox(-0.5F, 3F, -1F, 1, 2, 1); + Mid_1.addChild(MidB_1); - End_1 = new ModelRenderer(base, 56, 29); - End_1.addBox(-1F, 10.7F, -1F, 2, 1, 2); - Mid_2.addChild(End_1); - } + End_1 = new ModelRenderer(base, 56, 29); + End_1.addBox(-1F, 10.7F, -1F, 2, 1, 2); + Mid_2.addChild(End_1); + } - private void setRotation(ModelRenderer model, float x, float y, float z) { - model.rotateAngleX = x; - model.rotateAngleY = y; - model.rotateAngleZ = z; - } + private void setRotation(ModelRenderer model, float x, float y, float z) { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } - public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5, Entity entity) { - Base_1.rotateAngleX = -0.5490659F - f1 * 0.7f; + public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5, Entity entity) { + Base_1.rotateAngleX = -0.5490659F - f1 * 0.7f; - Base_1.rotateAngleY = 3.141593F + rotateAngleY * 0.1f; - Mid_1.rotateAngleY = rotateAngleY * 0.2f; - Mid_2.rotateAngleY = rotateAngleY * 0.2f; - } + Base_1.rotateAngleY = 3.141593F + rotateAngleY * 0.1f; + Mid_1.rotateAngleY = rotateAngleY * 0.2f; + Mid_2.rotateAngleY = rotateAngleY * 0.2f; + } } diff --git a/src/main/java/noppes/npcs/client/model/part/tails/ModelDragonTail.java b/src/main/java/noppes/npcs/client/model/part/tails/ModelDragonTail.java index 8516d385d..1cdb91bf6 100644 --- a/src/main/java/noppes/npcs/client/model/part/tails/ModelDragonTail.java +++ b/src/main/java/noppes/npcs/client/model/part/tails/ModelDragonTail.java @@ -7,100 +7,99 @@ import noppes.npcs.client.model.util.ModelPlaneRenderer; public class ModelDragonTail extends ModelRenderer { - public ModelDragonTail(ModelMPM base) { - super(base); - - int x = 52; - int y = 16; + public ModelDragonTail(ModelMPM base) { + super(base); - ModelRenderer dragon = new ModelRenderer(base, x, y); - dragon.setTextureSize(64,32); + int x = 52; + int y = 16; + + ModelRenderer dragon = new ModelRenderer(base, x, y); + dragon.setTextureSize(64, 32); dragon.setRotationPoint(0F, 0F, 3F); this.addChild(dragon); - + ModelRenderer DragonTail2 = new ModelRenderer(base, x, y); DragonTail2.setTextureSize(64, 32); - DragonTail2.setRotationPoint(0F, 2F, 2F); + DragonTail2.setRotationPoint(0F, 2F, 2F); - ModelRenderer DragonTail3 = new ModelRenderer(base, x, y); - DragonTail3.setTextureSize(64, 32); - DragonTail3.setRotationPoint(0F, 4.5F, 4F); - - ModelRenderer DragonTail4 = new ModelRenderer(base, x, y); - DragonTail4.setTextureSize(64, 32); - DragonTail4.setRotationPoint(0F, 7F, 5.75F); - - ModelRenderer DragonTail5 = new ModelRenderer(base, x, y); - DragonTail5.setTextureSize(64, 32); - DragonTail5.setRotationPoint(0F, 9F, 8F); + ModelRenderer DragonTail3 = new ModelRenderer(base, x, y); + DragonTail3.setTextureSize(64, 32); + DragonTail3.setRotationPoint(0F, 4.5F, 4F); - ModelPlaneRenderer planeLeft = new ModelPlaneRenderer(base, x, y); - planeLeft.setTextureSize(64, 32); - planeLeft.addSidePlane(-1.5F, -1.5F, -1.5F, 3, 3); - ModelPlaneRenderer planeRight = new ModelPlaneRenderer(base, x, y); - planeRight.setTextureSize(64, 32); - planeRight.addSidePlane(-1.5F, -1.5F, -1.5F, 3, 3); - setRotation(planeRight, (float)Math.PI, (float)Math.PI ,0); + ModelRenderer DragonTail4 = new ModelRenderer(base, x, y); + DragonTail4.setTextureSize(64, 32); + DragonTail4.setRotationPoint(0F, 7F, 5.75F); - ModelPlaneRenderer planeTop = new ModelPlaneRenderer(base, x, y); - planeTop.setTextureSize(64, 32); - planeTop.addTopPlane(-1.5F, -1.5F, -1.5F, 3, 3); - setRotation(planeTop, 0 ,-(float)Math.PI / 2,0); - ModelPlaneRenderer planeBottom = new ModelPlaneRenderer(base, x, y); - planeBottom.setTextureSize(64, 32); - planeBottom.addTopPlane(-1.5F, -1.5F, -1.5F, 3, 3); - setRotation(planeBottom, 0 ,-(float)Math.PI / 2, (float)Math.PI); + ModelRenderer DragonTail5 = new ModelRenderer(base, x, y); + DragonTail5.setTextureSize(64, 32); + DragonTail5.setRotationPoint(0F, 9F, 8F); - ModelPlaneRenderer planeBack = new ModelPlaneRenderer(base, x, y); - planeBack.setTextureSize(64, 32); - planeBack.addBackPlane(-1.5F, -1.5F, -1.5F, 3, 3); - setRotation(planeBack, 0, 0 ,(float)Math.PI / 2); - ModelPlaneRenderer planeFront = new ModelPlaneRenderer(base, x, y); - planeFront.setTextureSize(64, 32); - planeFront.addBackPlane(-1.5F, -1.5F, -1.5F, 3, 3); - setRotation(planeFront, 0, (float)Math.PI ,-(float)Math.PI / 2); + ModelPlaneRenderer planeLeft = new ModelPlaneRenderer(base, x, y); + planeLeft.setTextureSize(64, 32); + planeLeft.addSidePlane(-1.5F, -1.5F, -1.5F, 3, 3); + ModelPlaneRenderer planeRight = new ModelPlaneRenderer(base, x, y); + planeRight.setTextureSize(64, 32); + planeRight.addSidePlane(-1.5F, -1.5F, -1.5F, 3, 3); + setRotation(planeRight, (float) Math.PI, (float) Math.PI, 0); - dragon.addChild(planeLeft); - dragon.addChild(planeRight); - dragon.addChild(planeTop); - dragon.addChild(planeBottom); - dragon.addChild(planeFront); - dragon.addChild(planeBack); + ModelPlaneRenderer planeTop = new ModelPlaneRenderer(base, x, y); + planeTop.setTextureSize(64, 32); + planeTop.addTopPlane(-1.5F, -1.5F, -1.5F, 3, 3); + setRotation(planeTop, 0, -(float) Math.PI / 2, 0); + ModelPlaneRenderer planeBottom = new ModelPlaneRenderer(base, x, y); + planeBottom.setTextureSize(64, 32); + planeBottom.addTopPlane(-1.5F, -1.5F, -1.5F, 3, 3); + setRotation(planeBottom, 0, -(float) Math.PI / 2, (float) Math.PI); - DragonTail2.addChild(planeLeft); - DragonTail2.addChild(planeRight); - DragonTail2.addChild(planeTop); - DragonTail2.addChild(planeBottom); - DragonTail2.addChild(planeFront); - DragonTail2.addChild(planeBack); + ModelPlaneRenderer planeBack = new ModelPlaneRenderer(base, x, y); + planeBack.setTextureSize(64, 32); + planeBack.addBackPlane(-1.5F, -1.5F, -1.5F, 3, 3); + setRotation(planeBack, 0, 0, (float) Math.PI / 2); + ModelPlaneRenderer planeFront = new ModelPlaneRenderer(base, x, y); + planeFront.setTextureSize(64, 32); + planeFront.addBackPlane(-1.5F, -1.5F, -1.5F, 3, 3); + setRotation(planeFront, 0, (float) Math.PI, -(float) Math.PI / 2); - DragonTail3.addChild(planeLeft); - DragonTail3.addChild(planeRight); - DragonTail3.addChild(planeTop); - DragonTail3.addChild(planeBottom); - DragonTail3.addChild(planeFront); - DragonTail3.addChild(planeBack); + dragon.addChild(planeLeft); + dragon.addChild(planeRight); + dragon.addChild(planeTop); + dragon.addChild(planeBottom); + dragon.addChild(planeFront); + dragon.addChild(planeBack); - DragonTail4.addChild(planeLeft); - DragonTail4.addChild(planeRight); - DragonTail4.addChild(planeTop); - DragonTail4.addChild(planeBottom); - DragonTail4.addChild(planeFront); - DragonTail4.addChild(planeBack); + DragonTail2.addChild(planeLeft); + DragonTail2.addChild(planeRight); + DragonTail2.addChild(planeTop); + DragonTail2.addChild(planeBottom); + DragonTail2.addChild(planeFront); + DragonTail2.addChild(planeBack); - dragon.addChild(DragonTail2); - dragon.addChild(DragonTail3); - dragon.addChild(DragonTail4); - } + DragonTail3.addChild(planeLeft); + DragonTail3.addChild(planeRight); + DragonTail3.addChild(planeTop); + DragonTail3.addChild(planeBottom); + DragonTail3.addChild(planeFront); + DragonTail3.addChild(planeBack); - public void setRotationAngles(float par1, float par2, float par3, float par4, float par5, float par6, Entity entity) - { - + DragonTail4.addChild(planeLeft); + DragonTail4.addChild(planeRight); + DragonTail4.addChild(planeTop); + DragonTail4.addChild(planeBottom); + DragonTail4.addChild(planeFront); + DragonTail4.addChild(planeBack); + + dragon.addChild(DragonTail2); + dragon.addChild(DragonTail3); + dragon.addChild(DragonTail4); } - private void setRotation(ModelRenderer model, float x, float y, float z) { - model.rotateAngleX = x; - model.rotateAngleY = y; - model.rotateAngleZ = z; - } + public void setRotationAngles(float par1, float par2, float par3, float par4, float par5, float par6, Entity entity) { + + } + + private void setRotation(ModelRenderer model, float x, float y, float z) { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } } diff --git a/src/main/java/noppes/npcs/client/model/part/tails/ModelFeatherTail.java b/src/main/java/noppes/npcs/client/model/part/tails/ModelFeatherTail.java index 9a27cf380..00f5ee8e0 100644 --- a/src/main/java/noppes/npcs/client/model/part/tails/ModelFeatherTail.java +++ b/src/main/java/noppes/npcs/client/model/part/tails/ModelFeatherTail.java @@ -17,21 +17,21 @@ public class ModelFeatherTail extends ModelRenderer { int y = 16; feather1 = new ModelRenderer(base, x, y); - feather1.setTextureSize(64,32); + feather1.setTextureSize(64, 32); feather1.addBox(-1.5F, 0F, 0F, 3, 8, 0); feather1.setRotationPoint(1F, -0.5F, 2F); setRotation(feather1, 1.482807F, 0.2602503F, 0.1487144F); addChild(feather1); feather2 = new ModelRenderer(base, x, y); - feather2.setTextureSize(64,32); + feather2.setTextureSize(64, 32); feather2.addBox(-1.5F, 0F, 0F, 3, 8, 0); feather2.setRotationPoint(0F, -0.5F, 1F); setRotation(feather2, 1.200559F, 0.3717861F, 0.1858931F); addChild(feather2); feather3 = new ModelRenderer(base, x, y); - feather3.setTextureSize(64,32); + feather3.setTextureSize(64, 32); feather3.mirror = true; feather3.addBox(-1.5F, -0.5F, 0F, 3, 8, 0); feather3.setRotationPoint(-1F, 0, 2F); @@ -39,14 +39,14 @@ public class ModelFeatherTail extends ModelRenderer { addChild(feather3); feather4 = new ModelRenderer(base, x, y); - feather4.setTextureSize(64,32); + feather4.setTextureSize(64, 32); feather4.addBox(-1.5F, 0F, 0F, 3, 8, 0); feather4.setRotationPoint(0F, -0.5F, 2F); setRotation(feather4, 1.786329F, 0F, 0F); addChild(feather4); feather5 = new ModelRenderer(base, x, y); - feather5.setTextureSize(64,32); + feather5.setTextureSize(64, 32); feather5.mirror = true; feather5.addBox(-1.5F, 0F, 0F, 3, 8, 0); feather5.setRotationPoint(-1F, -0.5F, 2F); diff --git a/src/main/java/noppes/npcs/client/model/part/tails/ModelMonkeyTail.java b/src/main/java/noppes/npcs/client/model/part/tails/ModelMonkeyTail.java index 755f609b4..fae556349 100644 --- a/src/main/java/noppes/npcs/client/model/part/tails/ModelMonkeyTail.java +++ b/src/main/java/noppes/npcs/client/model/part/tails/ModelMonkeyTail.java @@ -6,251 +6,251 @@ import net.minecraft.entity.Entity; import net.minecraft.util.MathHelper; public class ModelMonkeyTail extends ModelRenderer { - public boolean isAnimated = true; + public boolean isAnimated = true; - // Monkey Tail - public ModelRenderer monkey; - public ModelRenderer m1; - public ModelRenderer m2; - public ModelRenderer m3; - public ModelRenderer m4; - public ModelRenderer m5; - public ModelRenderer m6; + // Monkey Tail + public ModelRenderer monkey; + public ModelRenderer m1; + public ModelRenderer m2; + public ModelRenderer m3; + public ModelRenderer m4; + public ModelRenderer m5; + public ModelRenderer m6; - // Monkey Tail (Belt) - public ModelRenderer monkey_wrapped; - public ModelRenderer mw1; - public ModelRenderer mw2; - public ModelRenderer mw3; - public ModelRenderer mw4; + // Monkey Tail (Belt) + public ModelRenderer monkey_wrapped; + public ModelRenderer mw1; + public ModelRenderer mw2; + public ModelRenderer mw3; + public ModelRenderer mw4; - // Monkey Tail (Large) - public ModelRenderer monkey_large; - public ModelRenderer ml1; - public ModelRenderer ml2; - public ModelRenderer ml3; - public ModelRenderer ml4; - public ModelRenderer ml5; + // Monkey Tail (Large) + public ModelRenderer monkey_large; + public ModelRenderer ml1; + public ModelRenderer ml2; + public ModelRenderer ml3; + public ModelRenderer ml4; + public ModelRenderer ml5; - public ModelMonkeyTail(ModelBiped base) { - super(base); - float heightFactor = -9.0f; + public ModelMonkeyTail(ModelBiped base) { + super(base); + float heightFactor = -9.0f; - (this.monkey_large = new ModelRenderer(base, 38, 54)).addBox(-2.0f, -2.0f, 0.0f, 4, 4, 6); - this.setRotation(this.monkey_large, -0.5235988f, 0.0f, 0.0f); - (this.ml1 = new ModelRenderer(base, 38, 54)).addBox(-2.0f, -2.0f, 0.0f, 4, 4, 6); - this.setRotation(this.ml1, 0.5235988f, 8.727E-4f, 0.0f); - (this.ml2 = new ModelRenderer(base, 38, 54)).addBox(-2.0f, -2.0f, 0.0f, 4, 4, 6); - this.setRotation(this.ml2, 0.0f, 0.0f, 0.0f); - (this.ml3 = new ModelRenderer(base, 38, 54)).addBox(-2.0f, -2.0f, 0.0f, 4, 4, 6); - this.setRotation(this.ml3, 0.0f, 0.0f, 0.0f); - (this.ml4 = new ModelRenderer(base, 38, 54)).addBox(-2.0f, -2.0f, 0.0f, 4, 4, 6); - this.setRotation(this.ml4, 0.0f, 0.0f, 0.0f); - (this.ml5 = new ModelRenderer(base, 38, 54)).addBox(-2.0f, -2.0f, 0.0f, 4, 4, 6); - this.setRotation(this.ml5, 0.0f, 0.0f, 0.0f); + (this.monkey_large = new ModelRenderer(base, 38, 54)).addBox(-2.0f, -2.0f, 0.0f, 4, 4, 6); + this.setRotation(this.monkey_large, -0.5235988f, 0.0f, 0.0f); + (this.ml1 = new ModelRenderer(base, 38, 54)).addBox(-2.0f, -2.0f, 0.0f, 4, 4, 6); + this.setRotation(this.ml1, 0.5235988f, 8.727E-4f, 0.0f); + (this.ml2 = new ModelRenderer(base, 38, 54)).addBox(-2.0f, -2.0f, 0.0f, 4, 4, 6); + this.setRotation(this.ml2, 0.0f, 0.0f, 0.0f); + (this.ml3 = new ModelRenderer(base, 38, 54)).addBox(-2.0f, -2.0f, 0.0f, 4, 4, 6); + this.setRotation(this.ml3, 0.0f, 0.0f, 0.0f); + (this.ml4 = new ModelRenderer(base, 38, 54)).addBox(-2.0f, -2.0f, 0.0f, 4, 4, 6); + this.setRotation(this.ml4, 0.0f, 0.0f, 0.0f); + (this.ml5 = new ModelRenderer(base, 38, 54)).addBox(-2.0f, -2.0f, 0.0f, 4, 4, 6); + this.setRotation(this.ml5, 0.0f, 0.0f, 0.0f); - this.monkey_large.rotateAngleX = 0.65f ; - this.monkey_large.rotationPointY = -2.0f ; - this.ml1.rotationPointZ = 5.0f; - this.ml2.rotationPointZ = 5.0f; - this.ml3.rotationPointZ = 5.0f; - this.ml4.rotationPointZ = 5.0f; - this.ml5.rotationPointZ = 5.0f; + this.monkey_large.rotateAngleX = 0.65f; + this.monkey_large.rotationPointY = -2.0f; + this.ml1.rotationPointZ = 5.0f; + this.ml2.rotationPointZ = 5.0f; + this.ml3.rotationPointZ = 5.0f; + this.ml4.rotationPointZ = 5.0f; + this.ml5.rotationPointZ = 5.0f; - this.ml4.addChild(this.ml5); - this.ml3.addChild(this.ml4); - this.ml2.addChild(this.ml3); - this.ml1.addChild(this.ml2); - this.monkey_large.addChild(this.ml1); + this.ml4.addChild(this.ml5); + this.ml3.addChild(this.ml4); + this.ml2.addChild(this.ml3); + this.ml1.addChild(this.ml2); + this.monkey_large.addChild(this.ml1); - (this.monkey = new ModelRenderer(base, 0, 0)).addBox(-0.0f, -0.0f, -0.0f, 0, 0, 0, 0.02f); - this.m1 = new ModelRenderer(base, 32, 48).addBox(-1.0f, -1.0f, 0.0f, 2, 2, 4); - this.setRotation(this.m1, -0.5235988f, 0.0f, 0.0f); - this.m2 = new ModelRenderer(base, 32, 48).addBox(-1.0f, -1.0f, 0.0f, 2, 2, 4); - this.setRotation(this.m2, 0.5235988f, 8.727E-4f, 0.0f); - this.m3 = new ModelRenderer(base, 32, 48).addBox(-1.0f, -1.0f, 0.0f, 2, 2, 4); - this.setRotation(this.m3, 0.0f, 0.0f, 0.0f); - this.m4 = new ModelRenderer(base, 32, 48).addBox(-1.0f, -1.0f, 0.0f, 2, 2, 4); - this.setRotation(this.m4, 0.0f, 0.0f, 0.0f); - this.m5 = new ModelRenderer(base, 32, 48).addBox(-1.0f, -1.0f, 0.0f, 2, 2, 4); - this.setRotation(this.m5, 0.0f, 0.0f, 0.0f); - this.m6 = new ModelRenderer(base, 32, 48).addBox(-1.0f, -1.0f, 0.0f, 2, 2, 4); - this.setRotation(this.m6, 0.0f, 0.0f, 0.0f); + (this.monkey = new ModelRenderer(base, 0, 0)).addBox(-0.0f, -0.0f, -0.0f, 0, 0, 0, 0.02f); + this.m1 = new ModelRenderer(base, 32, 48).addBox(-1.0f, -1.0f, 0.0f, 2, 2, 4); + this.setRotation(this.m1, -0.5235988f, 0.0f, 0.0f); + this.m2 = new ModelRenderer(base, 32, 48).addBox(-1.0f, -1.0f, 0.0f, 2, 2, 4); + this.setRotation(this.m2, 0.5235988f, 8.727E-4f, 0.0f); + this.m3 = new ModelRenderer(base, 32, 48).addBox(-1.0f, -1.0f, 0.0f, 2, 2, 4); + this.setRotation(this.m3, 0.0f, 0.0f, 0.0f); + this.m4 = new ModelRenderer(base, 32, 48).addBox(-1.0f, -1.0f, 0.0f, 2, 2, 4); + this.setRotation(this.m4, 0.0f, 0.0f, 0.0f); + this.m5 = new ModelRenderer(base, 32, 48).addBox(-1.0f, -1.0f, 0.0f, 2, 2, 4); + this.setRotation(this.m5, 0.0f, 0.0f, 0.0f); + this.m6 = new ModelRenderer(base, 32, 48).addBox(-1.0f, -1.0f, 0.0f, 2, 2, 4); + this.setRotation(this.m6, 0.0f, 0.0f, 0.0f); - this.m5.addChild(this.m6); - this.m4.addChild(this.m5); - this.m3.addChild(this.m4); - this.m2.addChild(this.m3); - this.m1.addChild(this.m2); - this.monkey.addChild(this.m1); + this.m5.addChild(this.m6); + this.m4.addChild(this.m5); + this.m3.addChild(this.m4); + this.m2.addChild(this.m3); + this.m1.addChild(this.m2); + this.monkey.addChild(this.m1); - // Init Rotation Points - this.monkey.rotationPointX = 1.0f; - this.monkey.rotationPointY = 10.0f + heightFactor; - this.monkey.rotationPointZ = 2.0f; - this.m1.rotationPointX = -1.0f; - this.m1.rotationPointY = -1.0f; - this.m2.rotationPointZ = 4.0f; - this.m3.rotationPointZ = 4.0f; - this.m4.rotationPointZ = 4.0f; - this.m5.rotationPointZ = 4.0f; - this.m6.rotationPointZ = 4.0f; + // Init Rotation Points + this.monkey.rotationPointX = 1.0f; + this.monkey.rotationPointY = 10.0f + heightFactor; + this.monkey.rotationPointZ = 2.0f; + this.m1.rotationPointX = -1.0f; + this.m1.rotationPointY = -1.0f; + this.m2.rotationPointZ = 4.0f; + this.m3.rotationPointZ = 4.0f; + this.m4.rotationPointZ = 4.0f; + this.m5.rotationPointZ = 4.0f; + this.m6.rotationPointZ = 4.0f; - (this.monkey_wrapped = new ModelRenderer(base, 0, 0)).addBox(-0.0f, -0.0f, -0.0f, 0, 0, 0, 0.02f); - this.monkey_wrapped.setRotationPoint(0.0f, 0.0f + heightFactor, 0.0f); - this.mw1 = new ModelRenderer(base, 32, 48).addBox(3.5f, 8.0f, -2.5f, 1, 2, 5); - this.mw1.setRotationPoint(0.0f, 0.0f, 0.0f); - this.setRotation(this.mw1, 0.0f, 0.0f, 0.0f); - this.mw2 = new ModelRenderer(base, 32, 48).addBox(-4.433333f, 8.0f, -2.5f, 1, 2, 5); - this.mw2.setRotationPoint(0.0f, 0.0f, 0.0f); - this.setRotation(this.mw2, 0.0f, 0.0f, 0.0f); - this.mw3 = new ModelRenderer(base, 32, 48).addBox(-3.433333f, 8.0f, 1.5f, 7, 2, 1); - this.mw3.setRotationPoint(0.0f, 0.0f, 0.0f); - this.setRotation(this.mw3, 0.0f, 0.0f, 0.0f); - this.mw4 = new ModelRenderer(base, 32, 48).addBox(-3.433333f, 8.0f, -2.5f, 7, 2, 1); - this.mw4.setRotationPoint(0.0f, 0.0f, 0.0f); - this.setRotation(this.mw4, 0.0f, 0.0f, 0.0f); + (this.monkey_wrapped = new ModelRenderer(base, 0, 0)).addBox(-0.0f, -0.0f, -0.0f, 0, 0, 0, 0.02f); + this.monkey_wrapped.setRotationPoint(0.0f, 0.0f + heightFactor, 0.0f); + this.mw1 = new ModelRenderer(base, 32, 48).addBox(3.5f, 8.0f, -2.5f, 1, 2, 5); + this.mw1.setRotationPoint(0.0f, 0.0f, 0.0f); + this.setRotation(this.mw1, 0.0f, 0.0f, 0.0f); + this.mw2 = new ModelRenderer(base, 32, 48).addBox(-4.433333f, 8.0f, -2.5f, 1, 2, 5); + this.mw2.setRotationPoint(0.0f, 0.0f, 0.0f); + this.setRotation(this.mw2, 0.0f, 0.0f, 0.0f); + this.mw3 = new ModelRenderer(base, 32, 48).addBox(-3.433333f, 8.0f, 1.5f, 7, 2, 1); + this.mw3.setRotationPoint(0.0f, 0.0f, 0.0f); + this.setRotation(this.mw3, 0.0f, 0.0f, 0.0f); + this.mw4 = new ModelRenderer(base, 32, 48).addBox(-3.433333f, 8.0f, -2.5f, 7, 2, 1); + this.mw4.setRotationPoint(0.0f, 0.0f, 0.0f); + this.setRotation(this.mw4, 0.0f, 0.0f, 0.0f); - this.monkey_wrapped.rotationPointZ = -0.5f; + this.monkey_wrapped.rotationPointZ = -0.5f; - this.monkey_wrapped.addChild(this.mw1); - this.monkey_wrapped.addChild(this.mw2); - this.monkey_wrapped.addChild(this.mw3); - this.monkey_wrapped.addChild(this.mw4); + this.monkey_wrapped.addChild(this.mw1); + this.monkey_wrapped.addChild(this.mw2); + this.monkey_wrapped.addChild(this.mw3); + this.monkey_wrapped.addChild(this.mw4); - this.addChild(monkey); - this.addChild(monkey_wrapped); - this.addChild(monkey_large); - } + this.addChild(monkey); + this.addChild(monkey_wrapped); + this.addChild(monkey_large); + } - private void setRotation(ModelRenderer model, float x, float y, float z) { - model.rotateAngleX = x; - model.rotateAngleY = y; - model.rotateAngleZ = z; - } + private void setRotation(ModelRenderer model, float x, float y, float z) { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } - public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5, Entity entity) { - // Scale down the motion values to control the effect - float scale = 0.18f; // Adjust the scale factor as needed + public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5, Entity entity) { + // Scale down the motion values to control the effect + float scale = 0.18f; // Adjust the scale factor as needed - // Define a damping factor for smoother motion - float damping = 0.6f; // Adjust the damping factor as needed + // Define a damping factor for smoother motion + float damping = 0.6f; // Adjust the damping factor as needed - double motionX = entity.motionX; - double motionY = -entity.motionY; + double motionX = entity.motionX; + double motionY = -entity.motionY; - if(!monkey_large.isHidden){ - this.monkey_large.rotateAngleY = 0.2f; - this.monkey_large.rotateAngleX = -0.3f; - this.ml1.rotateAngleY = 0.2f; - this.ml1.rotateAngleX = 0.4f; - this.ml2.rotateAngleY = 0.1f; - this.ml2.rotateAngleX = 0.6f; - this.ml3.rotateAngleY = 0.1f; - this.ml3.rotateAngleX = 0.3f; - this.ml4.rotateAngleY = 0.2f; - this.ml4.rotateAngleX = -0.2f; - this.ml5.rotateAngleY = 0.2f; - this.ml5.rotateAngleX = -0.4f; + if (!monkey_large.isHidden) { + this.monkey_large.rotateAngleY = 0.2f; + this.monkey_large.rotateAngleX = -0.3f; + this.ml1.rotateAngleY = 0.2f; + this.ml1.rotateAngleX = 0.4f; + this.ml2.rotateAngleY = 0.1f; + this.ml2.rotateAngleX = 0.6f; + this.ml3.rotateAngleY = 0.1f; + this.ml3.rotateAngleX = 0.3f; + this.ml4.rotateAngleY = 0.2f; + this.ml4.rotateAngleX = -0.2f; + this.ml5.rotateAngleY = 0.2f; + this.ml5.rotateAngleX = -0.4f; - if(isAnimated){ - float angleOffset = 0.01f; - final float r = MathHelper.sin(f2 * 0.02f) * angleOffset; - final float r2 = MathHelper.cos(f2 * 0.02f) * angleOffset; - final float r3 = MathHelper.cos(f2 * 0.14f) * angleOffset; - final float angleSpeed = 0.05f; - float xMotionReducer = 0.2f; - float yMotionReducer = 0.4f; + if (isAnimated) { + float angleOffset = 0.01f; + final float r = MathHelper.sin(f2 * 0.02f) * angleOffset; + final float r2 = MathHelper.cos(f2 * 0.02f) * angleOffset; + final float r3 = MathHelper.cos(f2 * 0.14f) * angleOffset; + final float angleSpeed = 0.05f; + float xMotionReducer = 0.2f; + float yMotionReducer = 0.4f; - monkey_large.rotateAngleY += yMotionReducer * (MathHelper.cos(f2 * angleSpeed) * 0.2f - 0.2f + r); - ml1.rotateAngleY += yMotionReducer * (MathHelper.cos(f2 * angleSpeed) * 0.2f - 0.2f + r2 + r3); - ml2.rotateAngleY += yMotionReducer * (MathHelper.cos(f2 * angleSpeed) * 0.1f - 0.1f + r + r3); - ml2.rotateAngleX += xMotionReducer * (MathHelper.sin(f2 * angleSpeed) * 0.4f + 0.3f); - ml3.rotateAngleY += yMotionReducer * (MathHelper.cos(f2 * angleSpeed) * 0.4f - 0.1f + r2); - ml3.rotateAngleX += xMotionReducer * (MathHelper.sin(f2 * angleSpeed) * 0.1f - 0.2f); - ml4.rotateAngleY += yMotionReducer * (MathHelper.cos(f2 * angleSpeed) * 0.4f - 0.2f + r + r3); - ml4.rotateAngleX += xMotionReducer * (MathHelper.sin(f2 * angleSpeed) * 0.1f - 0.3f); - ml5.rotateAngleY += yMotionReducer * (MathHelper.cos(f2 * angleSpeed) * 0.4f - 0.2f + r2 + r3); - ml5.rotateAngleX += xMotionReducer * (MathHelper.sin(f2 * angleSpeed) * 0.4f - 0.4f); - } + monkey_large.rotateAngleY += yMotionReducer * (MathHelper.cos(f2 * angleSpeed) * 0.2f - 0.2f + r); + ml1.rotateAngleY += yMotionReducer * (MathHelper.cos(f2 * angleSpeed) * 0.2f - 0.2f + r2 + r3); + ml2.rotateAngleY += yMotionReducer * (MathHelper.cos(f2 * angleSpeed) * 0.1f - 0.1f + r + r3); + ml2.rotateAngleX += xMotionReducer * (MathHelper.sin(f2 * angleSpeed) * 0.4f + 0.3f); + ml3.rotateAngleY += yMotionReducer * (MathHelper.cos(f2 * angleSpeed) * 0.4f - 0.1f + r2); + ml3.rotateAngleX += xMotionReducer * (MathHelper.sin(f2 * angleSpeed) * 0.1f - 0.2f); + ml4.rotateAngleY += yMotionReducer * (MathHelper.cos(f2 * angleSpeed) * 0.4f - 0.2f + r + r3); + ml4.rotateAngleX += xMotionReducer * (MathHelper.sin(f2 * angleSpeed) * 0.1f - 0.3f); + ml5.rotateAngleY += yMotionReducer * (MathHelper.cos(f2 * angleSpeed) * 0.4f - 0.2f + r2 + r3); + ml5.rotateAngleX += xMotionReducer * (MathHelper.sin(f2 * angleSpeed) * 0.4f - 0.4f); + } - // Calculate the difference between the current rotation angle and the motion influence - double deltaY = motionY * scale - monkey.rotateAngleX; - double deltaX = motionX * scale - monkey.rotateAngleY; + // Calculate the difference between the current rotation angle and the motion influence + double deltaY = motionY * scale - monkey.rotateAngleX; + double deltaX = motionX * scale - monkey.rotateAngleY; - // Apply damping to smooth out the motion + // Apply damping to smooth out the motion - monkey_large.rotateAngleX += deltaY * damping; - ml1.rotateAngleX += deltaY * damping; - ml2.rotateAngleX += deltaY * damping; - ml3.rotateAngleX += deltaY * damping; - ml4.rotateAngleX += deltaY * damping; - ml5.rotateAngleX += deltaY * damping; + monkey_large.rotateAngleX += deltaY * damping; + ml1.rotateAngleX += deltaY * damping; + ml2.rotateAngleX += deltaY * damping; + ml3.rotateAngleX += deltaY * damping; + ml4.rotateAngleX += deltaY * damping; + ml5.rotateAngleX += deltaY * damping; - monkey_large.rotateAngleY += deltaX * damping; - ml1.rotateAngleY += deltaX * damping; - ml2.rotateAngleY += deltaX * damping; - ml3.rotateAngleY += deltaX * damping; - ml4.rotateAngleY += deltaX * damping; - ml5.rotateAngleY += deltaX * damping; + monkey_large.rotateAngleY += deltaX * damping; + ml1.rotateAngleY += deltaX * damping; + ml2.rotateAngleY += deltaX * damping; + ml3.rotateAngleY += deltaX * damping; + ml4.rotateAngleY += deltaX * damping; + ml5.rotateAngleY += deltaX * damping; - } else if (!monkey.isHidden){ - this.m1.rotateAngleX = -0.3f; - this.m1.rotateAngleY = 0.2f; - this.m2.rotateAngleX = 0.4f; - this.m2.rotateAngleY = 0.2f; - this.m3.rotateAngleX = 0.6f; - this.m3.rotateAngleY = 0.1f; - this.m4.rotateAngleX = 0.3f; - this.m4.rotateAngleY = 0.1f; - this.m5.rotateAngleX = -0.2f; - this.m5.rotateAngleY = 0.2f; - this.m6.rotateAngleX = -0.4f; - this.m6.rotateAngleY = 0.2f; + } else if (!monkey.isHidden) { + this.m1.rotateAngleX = -0.3f; + this.m1.rotateAngleY = 0.2f; + this.m2.rotateAngleX = 0.4f; + this.m2.rotateAngleY = 0.2f; + this.m3.rotateAngleX = 0.6f; + this.m3.rotateAngleY = 0.1f; + this.m4.rotateAngleX = 0.3f; + this.m4.rotateAngleY = 0.1f; + this.m5.rotateAngleX = -0.2f; + this.m5.rotateAngleY = 0.2f; + this.m6.rotateAngleX = -0.4f; + this.m6.rotateAngleY = 0.2f; - if(isAnimated){ - float angleOffset = 0.01f; - final float r4 = MathHelper.sin(f2 * 0.02f) * angleOffset; - final float r5 = MathHelper.cos(f2 * 0.02f) * angleOffset; - final float r6 = MathHelper.cos(f2 * 0.14f) * angleOffset; - final float angleSpeed = 0.05f; - float xMotionReducer = 0.4f; - float yMotionReducer = 0.4f; + if (isAnimated) { + float angleOffset = 0.01f; + final float r4 = MathHelper.sin(f2 * 0.02f) * angleOffset; + final float r5 = MathHelper.cos(f2 * 0.02f) * angleOffset; + final float r6 = MathHelper.cos(f2 * 0.14f) * angleOffset; + final float angleSpeed = 0.05f; + float xMotionReducer = 0.4f; + float yMotionReducer = 0.4f; - this.m1.rotateAngleY += yMotionReducer * (MathHelper.cos(f2 * angleSpeed) * 0.2f - 0.2f + r4); - this.m2.rotateAngleY += yMotionReducer * (MathHelper.cos(f2 * angleSpeed) * 0.2f - 0.2f + r5 + r6); + this.m1.rotateAngleY += yMotionReducer * (MathHelper.cos(f2 * angleSpeed) * 0.2f - 0.2f + r4); + this.m2.rotateAngleY += yMotionReducer * (MathHelper.cos(f2 * angleSpeed) * 0.2f - 0.2f + r5 + r6); - this.m3.rotateAngleX += xMotionReducer * (MathHelper.sin(f2 * angleSpeed) * 0.4f + 0.1f); - this.m3.rotateAngleY += yMotionReducer * (MathHelper.cos(f2 * angleSpeed) * 0.1f - 0.1f + r4 + r6); + this.m3.rotateAngleX += xMotionReducer * (MathHelper.sin(f2 * angleSpeed) * 0.4f + 0.1f); + this.m3.rotateAngleY += yMotionReducer * (MathHelper.cos(f2 * angleSpeed) * 0.1f - 0.1f + r4 + r6); - this.m4.rotateAngleX += xMotionReducer * (MathHelper.sin(f2 * angleSpeed) * 0.1f - 0.2f); - this.m4.rotateAngleY += yMotionReducer * (MathHelper.cos(f2 * angleSpeed) * 0.4f - 0.1f + r5); + this.m4.rotateAngleX += xMotionReducer * (MathHelper.sin(f2 * angleSpeed) * 0.1f - 0.2f); + this.m4.rotateAngleY += yMotionReducer * (MathHelper.cos(f2 * angleSpeed) * 0.4f - 0.1f + r5); - this.m5.rotateAngleX += xMotionReducer * (MathHelper.sin(f2 * angleSpeed) * 0.1f - 0.1f); - this.m5.rotateAngleY += yMotionReducer * (MathHelper.cos(f2 * angleSpeed) * 0.4f - 0.2f + r4 + r6); + this.m5.rotateAngleX += xMotionReducer * (MathHelper.sin(f2 * angleSpeed) * 0.1f - 0.1f); + this.m5.rotateAngleY += yMotionReducer * (MathHelper.cos(f2 * angleSpeed) * 0.4f - 0.2f + r4 + r6); - this.m6.rotateAngleX += xMotionReducer * (MathHelper.sin(f2 * angleSpeed) * 0.4f - 0.4f); - this.m6.rotateAngleY += yMotionReducer * (MathHelper.cos(f2 * angleSpeed) * 0.4f - 0.2f + r5 + r6); - } + this.m6.rotateAngleX += xMotionReducer * (MathHelper.sin(f2 * angleSpeed) * 0.4f - 0.4f); + this.m6.rotateAngleY += yMotionReducer * (MathHelper.cos(f2 * angleSpeed) * 0.4f - 0.2f + r5 + r6); + } - // Calculate the difference between the current rotation angle and the motion influence - double deltaY = motionY * scale - monkey.rotateAngleX; - double deltaX = motionX * scale - monkey.rotateAngleY; + // Calculate the difference between the current rotation angle and the motion influence + double deltaY = motionY * scale - monkey.rotateAngleX; + double deltaX = motionX * scale - monkey.rotateAngleY; - // Apply damping to smooth out the motion - m1.rotateAngleX += deltaY * damping; - m2.rotateAngleX += deltaY * damping; - m3.rotateAngleX += deltaY * damping; - m4.rotateAngleX += deltaY * damping; - m5.rotateAngleX += deltaY * damping; - m6.rotateAngleX += deltaY * damping; + // Apply damping to smooth out the motion + m1.rotateAngleX += deltaY * damping; + m2.rotateAngleX += deltaY * damping; + m3.rotateAngleX += deltaY * damping; + m4.rotateAngleX += deltaY * damping; + m5.rotateAngleX += deltaY * damping; + m6.rotateAngleX += deltaY * damping; - m1.rotateAngleY += deltaX * damping; - m2.rotateAngleY += deltaX * damping; - m3.rotateAngleY += deltaX * damping; - m4.rotateAngleY += deltaX * damping; - m5.rotateAngleY += deltaX * damping; - m6.rotateAngleY += deltaX * damping; - } - } + m1.rotateAngleY += deltaX * damping; + m2.rotateAngleY += deltaX * damping; + m3.rotateAngleY += deltaX * damping; + m4.rotateAngleY += deltaX * damping; + m5.rotateAngleY += deltaX * damping; + m6.rotateAngleY += deltaX * damping; + } + } } diff --git a/src/main/java/noppes/npcs/client/model/part/tails/ModelRodentTail.java b/src/main/java/noppes/npcs/client/model/part/tails/ModelRodentTail.java index 46327032c..5a8f5af52 100644 --- a/src/main/java/noppes/npcs/client/model/part/tails/ModelRodentTail.java +++ b/src/main/java/noppes/npcs/client/model/part/tails/ModelRodentTail.java @@ -4,30 +4,30 @@ import net.minecraft.client.model.ModelRenderer; import noppes.npcs.client.model.ModelMPM; public class ModelRodentTail extends ModelRenderer { - ModelRenderer Shape1; - ModelRenderer Shape2; + ModelRenderer Shape1; + ModelRenderer Shape2; - public ModelRodentTail(ModelMPM base) { - super(base); + public ModelRodentTail(ModelMPM base) { + super(base); - Shape1 = new ModelRenderer(base, 0, 0); - Shape1.setTextureSize(64,32); - Shape1.addBox(-0.5333334F, -0.4666667F, -1F, 1, 1, 6); - Shape1.setRotationPoint(0F, 0F, 2F); - setRotation(Shape1, -0.9294653F, 0F, 0F); - addChild(Shape1); - - Shape2 = new ModelRenderer(base, 1, 1); - Shape2.setTextureSize(64,32); - Shape2.addBox(-0.5F, -0.1666667F, 1F, 1, 1, 5); - Shape2.setRotationPoint(0F, 3F, 4F); - setRotation(Shape2, -0.4833219F, 0F, 0F); - addChild(Shape2); - } + Shape1 = new ModelRenderer(base, 0, 0); + Shape1.setTextureSize(64, 32); + Shape1.addBox(-0.5333334F, -0.4666667F, -1F, 1, 1, 6); + Shape1.setRotationPoint(0F, 0F, 2F); + setRotation(Shape1, -0.9294653F, 0F, 0F); + addChild(Shape1); - private void setRotation(ModelRenderer model, float x, float y, float z) { - model.rotateAngleX = x; - model.rotateAngleY = y; - model.rotateAngleZ = z; - } + Shape2 = new ModelRenderer(base, 1, 1); + Shape2.setTextureSize(64, 32); + Shape2.addBox(-0.5F, -0.1666667F, 1F, 1, 1, 5); + Shape2.setRotationPoint(0F, 3F, 4F); + setRotation(Shape2, -0.4833219F, 0F, 0F); + addChild(Shape2); + } + + private void setRotation(ModelRenderer model, float x, float y, float z) { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } } diff --git a/src/main/java/noppes/npcs/client/model/part/tails/ModelSquirrelTail.java b/src/main/java/noppes/npcs/client/model/part/tails/ModelSquirrelTail.java index bfce7c823..00ba7db0f 100644 --- a/src/main/java/noppes/npcs/client/model/part/tails/ModelSquirrelTail.java +++ b/src/main/java/noppes/npcs/client/model/part/tails/ModelSquirrelTail.java @@ -6,59 +6,59 @@ import noppes.npcs.client.model.ModelMPM; public class ModelSquirrelTail extends ModelRenderer { - private ModelMPM base; + private ModelMPM base; - public ModelSquirrelTail(ModelMPM base) { - super(base); - this.base = base; + public ModelSquirrelTail(ModelMPM base) { + super(base); + this.base = base; - textureWidth = 64; - textureHeight = 32; + textureWidth = 64; + textureHeight = 32; - ModelRenderer Shape1 = new ModelRenderer(base, 0, 0); - Shape1.setTextureSize(64,32); - Shape1.addBox(-1F, -1F, -1F, 2, 2, 3); - Shape1.setRotationPoint(0F, -1F, 3F); - setRotation(Shape1, 0F, 0F, 0F); - this.addChild(Shape1); - - ModelRenderer Shape2 = new ModelRenderer(base, 0, 9); - Shape2.setTextureSize(64,32); - Shape2.addBox(-2F, -5F, -1F, 4, 5, 3); - Shape2.setRotationPoint(0F, 0F, 1F); - setRotation(Shape2, -0.37F, 0F, 0F); - Shape1.addChild(Shape2); - - ModelRenderer Shape3 = new ModelRenderer(base, 0, 18); - Shape3.setTextureSize(64,32); - Shape3.addBox(-2.466667F, -6F, -1F, 5, 7, 3); - Shape3.setRotationPoint(0F, -5F, 0F); - setRotation(Shape3, 0.3f, 0F, 0F); - Shape2.addChild(Shape3); - - ModelRenderer Shape4 = new ModelRenderer(base, 25, 0); - Shape4.setTextureSize(64,32); - Shape4.addBox(-3F, -0.6F, -1F, 6, 5, 3); - Shape4.setRotationPoint(0F, -5F, 1F); - setRotation(Shape4, 2.5F, 0F, 0F); - Shape3.addChild(Shape4); - - ModelRenderer Shape5 = new ModelRenderer(base, 25, 10); - Shape5.setTextureSize(64,32); - Shape5.addBox(-3F, -2F, -1F, 6, 3, 5); - Shape5.setRotationPoint(0F, 3.5F, 0F); - setRotation(Shape5, -2.5F, 0F, 0F); - Shape4.addChild(Shape5); - } + ModelRenderer Shape1 = new ModelRenderer(base, 0, 0); + Shape1.setTextureSize(64, 32); + Shape1.addBox(-1F, -1F, -1F, 2, 2, 3); + Shape1.setRotationPoint(0F, -1F, 3F); + setRotation(Shape1, 0F, 0F, 0F); + this.addChild(Shape1); - public void setRotationAngles(float par1, float par2, float par3, - float par4, float par5, float par6, Entity entity) { + ModelRenderer Shape2 = new ModelRenderer(base, 0, 9); + Shape2.setTextureSize(64, 32); + Shape2.addBox(-2F, -5F, -1F, 4, 5, 3); + Shape2.setRotationPoint(0F, 0F, 1F); + setRotation(Shape2, -0.37F, 0F, 0F); + Shape1.addChild(Shape2); - } + ModelRenderer Shape3 = new ModelRenderer(base, 0, 18); + Shape3.setTextureSize(64, 32); + Shape3.addBox(-2.466667F, -6F, -1F, 5, 7, 3); + Shape3.setRotationPoint(0F, -5F, 0F); + setRotation(Shape3, 0.3f, 0F, 0F); + Shape2.addChild(Shape3); - private void setRotation(ModelRenderer model, float x, float y, float z) { - model.rotateAngleX = x; - model.rotateAngleY = y; - model.rotateAngleZ = z; - } + ModelRenderer Shape4 = new ModelRenderer(base, 25, 0); + Shape4.setTextureSize(64, 32); + Shape4.addBox(-3F, -0.6F, -1F, 6, 5, 3); + Shape4.setRotationPoint(0F, -5F, 1F); + setRotation(Shape4, 2.5F, 0F, 0F); + Shape3.addChild(Shape4); + + ModelRenderer Shape5 = new ModelRenderer(base, 25, 10); + Shape5.setTextureSize(64, 32); + Shape5.addBox(-3F, -2F, -1F, 6, 3, 5); + Shape5.setRotationPoint(0F, 3.5F, 0F); + setRotation(Shape5, -2.5F, 0F, 0F); + Shape4.addChild(Shape5); + } + + public void setRotationAngles(float par1, float par2, float par3, + float par4, float par5, float par6, Entity entity) { + + } + + private void setRotation(ModelRenderer model, float x, float y, float z) { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } } diff --git a/src/main/java/noppes/npcs/client/model/part/tails/ModelTailFin.java b/src/main/java/noppes/npcs/client/model/part/tails/ModelTailFin.java index 24b2571fe..aa492d173 100644 --- a/src/main/java/noppes/npcs/client/model/part/tails/ModelTailFin.java +++ b/src/main/java/noppes/npcs/client/model/part/tails/ModelTailFin.java @@ -5,47 +5,47 @@ import noppes.npcs.client.model.ModelMPM; public class ModelTailFin extends ModelRenderer { - public ModelTailFin(ModelMPM base) { - super(base); + public ModelTailFin(ModelMPM base) { + super(base); - textureWidth = 64; - textureHeight = 32; + textureWidth = 64; + textureHeight = 32; - ModelRenderer Shape1 = new ModelRenderer(base, 0, 0); - Shape1.setTextureSize(64,32); - Shape1.addBox(-2F, -2F, -2F, 3, 3, 8); - Shape1.setRotationPoint(0.5F, 0F, 1F); - setRotation(Shape1, -0.669215F, 0F, 0F); - addChild(Shape1); - - ModelRenderer Shape2 = new ModelRenderer(base, 2, 2); - Shape2.setTextureSize(64,32); - Shape2.addBox(-1F, -1F, 1F, 3, 2, 6); - Shape2.setRotationPoint(-0.5F, 3F, 4.5F); - setRotation(Shape2, -0.2602503F, 0F, 0F); - addChild(Shape2); - - ModelRenderer Shape3 = new ModelRenderer(base, 0, 11); - Shape3.setTextureSize(64,32); - Shape3.addBox(-1F, -1F, -1F, 3, 1, 6); - Shape3.setRotationPoint(0.5F, 5F, 12F); - setRotation(Shape3, 0F, 1.07818F, 0F); - addChild(Shape3); - - ModelRenderer Shape4 = new ModelRenderer(base, 0, 11); - Shape4.setTextureSize(64,32); - Shape4.mirror = true; - Shape4.addBox(-2F, 0F, -1F, 3, 1, 6); - Shape4.setRotationPoint(-0.5F, 4F, 12F); - setRotation(Shape4, 0F, -1.003822F, 0F); - addChild(Shape4); - } + ModelRenderer Shape1 = new ModelRenderer(base, 0, 0); + Shape1.setTextureSize(64, 32); + Shape1.addBox(-2F, -2F, -2F, 3, 3, 8); + Shape1.setRotationPoint(0.5F, 0F, 1F); + setRotation(Shape1, -0.669215F, 0F, 0F); + addChild(Shape1); - private void setRotation(ModelRenderer model, float x, float y, float z) { - model.rotateAngleX = x; - model.rotateAngleY = y; - model.rotateAngleZ = z; - } + ModelRenderer Shape2 = new ModelRenderer(base, 2, 2); + Shape2.setTextureSize(64, 32); + Shape2.addBox(-1F, -1F, 1F, 3, 2, 6); + Shape2.setRotationPoint(-0.5F, 3F, 4.5F); + setRotation(Shape2, -0.2602503F, 0F, 0F); + addChild(Shape2); + + ModelRenderer Shape3 = new ModelRenderer(base, 0, 11); + Shape3.setTextureSize(64, 32); + Shape3.addBox(-1F, -1F, -1F, 3, 1, 6); + Shape3.setRotationPoint(0.5F, 5F, 12F); + setRotation(Shape3, 0F, 1.07818F, 0F); + addChild(Shape3); + + ModelRenderer Shape4 = new ModelRenderer(base, 0, 11); + Shape4.setTextureSize(64, 32); + Shape4.mirror = true; + Shape4.addBox(-2F, 0F, -1F, 3, 1, 6); + Shape4.setRotationPoint(-0.5F, 4F, 12F); + setRotation(Shape4, 0F, -1.003822F, 0F); + addChild(Shape4); + } + + private void setRotation(ModelRenderer model, float x, float y, float z) { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } } diff --git a/src/main/java/noppes/npcs/client/model/util/Model2DRenderer.java b/src/main/java/noppes/npcs/client/model/util/Model2DRenderer.java index 62038fa9f..2c9b25d74 100644 --- a/src/main/java/noppes/npcs/client/model/util/Model2DRenderer.java +++ b/src/main/java/noppes/npcs/client/model/util/Model2DRenderer.java @@ -10,83 +10,84 @@ import org.lwjgl.opengl.GL11; public class Model2DRenderer extends ModelRenderer { - private boolean compiledModel; + private boolean compiledModel; - private int displayListModel; + private int displayListModel; - private float x1, x2, y1, y2; - private int width, height; - private float rotationOffsetX, rotationOffsetY; + private float x1, x2, y1, y2; + private int width, height; + private float rotationOffsetX, rotationOffsetY; - private float scaleX = 1, scaleY = 1, thickness = 1; + private float scaleX = 1, scaleY = 1, thickness = 1; - public Model2DRenderer(ModelBase par1ModelBase, float x, float y, int width, int height, float textureWidth, float textureHeight) { - super(par1ModelBase); - this.width = width; - this.height = height; - this.textureWidth = textureWidth; - this.textureHeight = textureHeight; + public Model2DRenderer(ModelBase par1ModelBase, float x, float y, int width, int height, float textureWidth, float textureHeight) { + super(par1ModelBase); + this.width = width; + this.height = height; + this.textureWidth = textureWidth; + this.textureHeight = textureHeight; - x1 = x / textureWidth; - y1 = y / textureHeight; + x1 = x / textureWidth; + y1 = y / textureHeight; - x2 = (x + width) / textureWidth; - y2 = (y + height) / textureHeight; - } + x2 = (x + width) / textureWidth; + y2 = (y + height) / textureHeight; + } - public Model2DRenderer(ModelBase base, int x, int y, int width, int height) { - this(base, x, y, width, height, width, height); - } + public Model2DRenderer(ModelBase base, int x, int y, int width, int height) { + this(base, x, y, width, height, width, height); + } - public void render(float par1) { - if(!showModel || isHidden) - return; - if(!compiledModel) - compileDisplayListModel(par1); + public void render(float par1) { + if (!showModel || isHidden) + return; + if (!compiledModel) + compileDisplayListModel(par1); - GL11.glPushMatrix(); - this.postRender(par1); + GL11.glPushMatrix(); + this.postRender(par1); - GL11.glCallList(this.displayListModel); - GL11.glPopMatrix(); - } + GL11.glCallList(this.displayListModel); + GL11.glPopMatrix(); + } - public void setRotationOffset(float x, float y){ - rotationOffsetX = x; - rotationOffsetY = y; - } + public void setRotationOffset(float x, float y) { + rotationOffsetX = x; + rotationOffsetY = y; + } - public void setScale(float scale){ - this.scaleX = scale; - this.scaleY = scale; - } - public void setScale(float x, float y){ - this.scaleX = x; - this.scaleY = y; - } + public void setScale(float scale) { + this.scaleX = scale; + this.scaleY = scale; + } - public void setThickness(float thickness) { - this.thickness = thickness; - } - @SideOnly(Side.CLIENT) - private void compileDisplayListModel(float par1) - { - this.displayListModel = GLAllocation.generateDisplayLists(1); - GL11.glNewList(this.displayListModel, GL11.GL_COMPILE); + public void setScale(float x, float y) { + this.scaleX = x; + this.scaleY = y; + } - GL11.glScalef(scaleX * width / height, scaleY, thickness); - GL11.glRotatef(180, 1F, 0F, 0F); - if(mirror){ - GL11.glTranslatef(0, 0, -1f * par1); - GL11.glRotatef(180, 0, 1F, 0F); - } + public void setThickness(float thickness) { + this.thickness = thickness; + } - GL11.glTranslated( rotationOffsetX * par1, rotationOffsetY * par1, 0); - renderItemIn2D(x1, y1, x2, y2, width, height, par1); + @SideOnly(Side.CLIENT) + private void compileDisplayListModel(float par1) { + this.displayListModel = GLAllocation.generateDisplayLists(1); + GL11.glNewList(this.displayListModel, GL11.GL_COMPILE); - GL11.glEndList(); - this.compiledModel = true; - } + GL11.glScalef(scaleX * width / height, scaleY, thickness); + GL11.glRotatef(180, 1F, 0F, 0F); + if (mirror) { + GL11.glTranslatef(0, 0, -1f * par1); + GL11.glRotatef(180, 0, 1F, 0F); + } + + GL11.glTranslated(rotationOffsetX * par1, rotationOffsetY * par1, 0); + renderItemIn2D(x1, y1, x2, y2, width, height, par1); + + GL11.glEndList(); + this.compiledModel = true; + } public static void renderItemIn2D(float p_78439_1_, float p_78439_2_, float p_78439_3_, float p_78439_4_, int p_78439_5_, int p_78439_6_, float p_78439_7_) { Tessellator tessellator = Tessellator.instance; diff --git a/src/main/java/noppes/npcs/client/model/util/ModelPartInterface.java b/src/main/java/noppes/npcs/client/model/util/ModelPartInterface.java index 8fffe075a..73c3ef3ec 100644 --- a/src/main/java/noppes/npcs/client/model/util/ModelPartInterface.java +++ b/src/main/java/noppes/npcs/client/model/util/ModelPartInterface.java @@ -14,66 +14,65 @@ import org.lwjgl.opengl.GL11; public abstract class ModelPartInterface extends ModelRenderer { - public ModelData data; - private EntityCustomNpc entity; - public float scale = 1; - protected ResourceLocation location; - public int color = 0xFFFFFF; + public ModelData data; + private EntityCustomNpc entity; + public float scale = 1; + protected ResourceLocation location; + public int color = 0xFFFFFF; - public ModelMPM base; + public ModelMPM base; - public ModelPartInterface(ModelMPM par1ModelBase) { - super(par1ModelBase); - this.base = par1ModelBase; - this.setTextureSize(0, 0); - } + public ModelPartInterface(ModelMPM par1ModelBase) { + super(par1ModelBase); + this.base = par1ModelBase; + this.setTextureSize(0, 0); + } - public void setRotation(ModelRenderer model, float x, float y, float z) { - model.rotateAngleX = x; - model.rotateAngleY = y; - model.rotateAngleZ = z; - } + public void setRotation(ModelRenderer model, float x, float y, float z) { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } - public void setRotationAngles(float par1, float par2, float par3, - float par4, float par5, float par6, Entity entity) { - } + public void setRotationAngles(float par1, float par2, float par3, + float par4, float par5, float par6, Entity entity) { + } - public void setLivingAnimations(ModelPartData data, - EntityLivingBase entityliving, float f, float f1, float f2) { - } + public void setLivingAnimations(ModelPartData data, + EntityLivingBase entityliving, float f, float f1, float f2) { + } - public void setData(ModelData data, EntityCustomNpc entity) { - this.data = data; - this.entity = entity; - initData(data); - } + public void setData(ModelData data, EntityCustomNpc entity) { + this.data = data; + this.entity = entity; + initData(data); + } - public void render(float par1) - { - if(!base.isArmor){ - if(location != null){ - ClientProxy.bindTexture(location); - base.currentlyPlayerTexture = false; - } - else if(!base.currentlyPlayerTexture){ - ClientProxy.bindTexture(entity.textureLocation); - base.currentlyPlayerTexture = true; - } - } + public void render(float par1) { + if (!base.isArmor) { + if (location != null) { + ClientProxy.bindTexture(location); + base.currentlyPlayerTexture = false; + } else if (!base.currentlyPlayerTexture) { + ClientProxy.bindTexture(entity.textureLocation); + base.currentlyPlayerTexture = true; + } + } TintData tintData = entity.display.tintData; boolean showColor = !base.isArmor && tintData.processColor(entity.hurtTime > 0 || entity.deathTime > 0); - if(showColor){ - float red = (color >> 16 & 255) / 255f; - float green = (color >> 8 & 255) / 255f; - float blue = (color & 255) / 255f; - GL11.glColor4f(red, green, blue, base.alpha); - } - super.render(par1); - if(showColor){ - GL11.glColor4f(1, 1, 1, base.alpha); - } + if (showColor) { + float red = (color >> 16 & 255) / 255f; + float green = (color >> 8 & 255) / 255f; + float blue = (color & 255) / 255f; + GL11.glColor4f(red, green, blue, base.alpha); + } + super.render(par1); + if (showColor) { + GL11.glColor4f(1, 1, 1, base.alpha); + } } - public abstract void initData(ModelData data); + + public abstract void initData(ModelData data); } diff --git a/src/main/java/noppes/npcs/client/model/util/ModelPlane.java b/src/main/java/noppes/npcs/client/model/util/ModelPlane.java index bf2522b77..e3f7501a8 100644 --- a/src/main/java/noppes/npcs/client/model/util/ModelPlane.java +++ b/src/main/java/noppes/npcs/client/model/util/ModelPlane.java @@ -7,19 +7,19 @@ import net.minecraft.client.model.TexturedQuad; import net.minecraft.client.renderer.Tessellator; import noppes.npcs.client.renderer.EnumPlanePosition; -public class ModelPlane extends ModelBox{ +public class ModelPlane extends ModelBox { private PositionTextureVertex[] vertexPositions; private TexturedQuad quad; - - public ModelPlane(ModelRenderer par1ModelRenderer, int textureOffsetX, int textureOffsetY, float par4, float par5, float par6, - int par7, int par8, int par9, float par10, EnumPlanePosition position) { - super(par1ModelRenderer, textureOffsetX, textureOffsetY, par4, par5, par6, par7, par8, par9, par10); + + public ModelPlane(ModelRenderer par1ModelRenderer, int textureOffsetX, int textureOffsetY, float par4, float par5, float par6, + int par7, int par8, int par9, float par10, EnumPlanePosition position) { + super(par1ModelRenderer, textureOffsetX, textureOffsetY, par4, par5, par6, par7, par8, par9, par10); this.vertexPositions = new PositionTextureVertex[8]; - float var11 = par4 + (float)par7; - float var12 = par5 + (float)par8; - float var13 = par6 + (float)par9; + float var11 = par4 + (float) par7; + float var12 = par5 + (float) par8; + float var13 = par6 + (float) par9; par4 -= par10; par5 -= par10; par6 -= par10; @@ -27,8 +27,7 @@ public class ModelPlane extends ModelBox{ var12 += par10; var13 += par10; - if (par1ModelRenderer.mirror) - { + if (par1ModelRenderer.mirror) { float var14 = var11; var11 = par4; par4 = var14; @@ -50,26 +49,25 @@ public class ModelPlane extends ModelBox{ this.vertexPositions[5] = var19; this.vertexPositions[6] = var20; this.vertexPositions[7] = var21; - - if(position == EnumPlanePosition.LEFT) - this.quad = new TexturedQuad(new PositionTextureVertex[] {var19, var15, var16, var20}, textureOffsetX, textureOffsetY, textureOffsetX + par9, textureOffsetY + par8, par1ModelRenderer.textureWidth, par1ModelRenderer.textureHeight); + + if (position == EnumPlanePosition.LEFT) + this.quad = new TexturedQuad(new PositionTextureVertex[]{var19, var15, var16, var20}, textureOffsetX, textureOffsetY, textureOffsetX + par9, textureOffsetY + par8, par1ModelRenderer.textureWidth, par1ModelRenderer.textureHeight); //this.quad = new TexturedQuad(new PositionTextureVertex[] {var23, var18, var21, var17}, textureOffsetX, textureOffsetY + par9, textureOffsetX + par9, textureOffsetY + par9 + par8, par1ModelRenderer.textureWidth, par1ModelRenderer.textureHeight); - - if(position == EnumPlanePosition.TOP) - this.quad = new TexturedQuad(new PositionTextureVertex[] {var19, var18, var23, var15}, textureOffsetX, textureOffsetY, textureOffsetX + par7, textureOffsetY + par9, par1ModelRenderer.textureWidth, par1ModelRenderer.textureHeight); + + if (position == EnumPlanePosition.TOP) + this.quad = new TexturedQuad(new PositionTextureVertex[]{var19, var18, var23, var15}, textureOffsetX, textureOffsetY, textureOffsetX + par7, textureOffsetY + par9, par1ModelRenderer.textureWidth, par1ModelRenderer.textureHeight); //this.quad = new TexturedQuad(new PositionTextureVertex[] {var16, var17, var21, var20}, textureOffsetX + par9 + par7, textureOffsetY + par9, textureOffsetX + par9 + par7 + par7, textureOffsetY, par1ModelRenderer.textureWidth, par1ModelRenderer.textureHeight); - - if(position == EnumPlanePosition.BACK) - this.quad = new TexturedQuad(new PositionTextureVertex[] {var15, var23, var17, var16}, textureOffsetX, textureOffsetY, textureOffsetX + par7, textureOffsetY + par8, par1ModelRenderer.textureWidth, par1ModelRenderer.textureHeight); + + if (position == EnumPlanePosition.BACK) + this.quad = new TexturedQuad(new PositionTextureVertex[]{var15, var23, var17, var16}, textureOffsetX, textureOffsetY, textureOffsetX + par7, textureOffsetY + par8, par1ModelRenderer.textureWidth, par1ModelRenderer.textureHeight); //this.quad = new TexturedQuad(new PositionTextureVertex[] {var18, var19, var20, var21}, textureOffsetX + par9 + par7, textureOffsetY + par9, textureOffsetX + par9 + par7 + par7, textureOffsetY + par9 + par8, par1ModelRenderer.textureWidth, par1ModelRenderer.textureHeight); - + if (par1ModelRenderer.mirror) - quad.flipFace(); - } - + quad.flipFace(); + } + @Override - public void render(Tessellator par1Tessellator, float par2) - { - quad.draw(par1Tessellator, par2); + public void render(Tessellator par1Tessellator, float par2) { + quad.draw(par1Tessellator, par2); } } diff --git a/src/main/java/noppes/npcs/client/model/util/ModelPlaneRenderer.java b/src/main/java/noppes/npcs/client/model/util/ModelPlaneRenderer.java index f3353b8a9..63ce8aa3b 100644 --- a/src/main/java/noppes/npcs/client/model/util/ModelPlaneRenderer.java +++ b/src/main/java/noppes/npcs/client/model/util/ModelPlaneRenderer.java @@ -4,50 +4,42 @@ import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelRenderer; import noppes.npcs.client.renderer.EnumPlanePosition; -public class ModelPlaneRenderer extends ModelRenderer -{ +public class ModelPlaneRenderer extends ModelRenderer { private int textureOffsetX; private int textureOffsetY; - public ModelPlaneRenderer(ModelBase modelbase, int i, int j) - { - super(modelbase, i, j); + public ModelPlaneRenderer(ModelBase modelbase, int i, int j) { + super(modelbase, i, j); textureOffsetX = i; textureOffsetY = j; } - public void addBackPlane(float f, float f1, float f2, int i, int j) - { - addPlane(f, f1, f2, i, j, 0, 0.0F,EnumPlanePosition.BACK); + public void addBackPlane(float f, float f1, float f2, int i, int j) { + addPlane(f, f1, f2, i, j, 0, 0.0F, EnumPlanePosition.BACK); } - public void addSidePlane(float f, float f1, float f2, int j, int k) - { - addPlane(f, f1, f2, 0, j, k, 0.0F,EnumPlanePosition.LEFT); + public void addSidePlane(float f, float f1, float f2, int j, int k) { + addPlane(f, f1, f2, 0, j, k, 0.0F, EnumPlanePosition.LEFT); } - public void addTopPlane(float f, float f1, float f2, int i, int k) - { - addPlane(f, f1, f2, i, 0, k, 0.0F,EnumPlanePosition.TOP); + public void addTopPlane(float f, float f1, float f2, int i, int k) { + addPlane(f, f1, f2, i, 0, k, 0.0F, EnumPlanePosition.TOP); } - public void addBackPlane(float f, float f1, float f2, int i, int j, float scale) - { - addPlane(f, f1, f2, i, j, 0, scale,EnumPlanePosition.BACK); + public void addBackPlane(float f, float f1, float f2, int i, int j, float scale) { + addPlane(f, f1, f2, i, j, 0, scale, EnumPlanePosition.BACK); } - public void addSidePlane(float f, float f1, float f2, int j, int k, float scale) - { - addPlane(f, f1, f2, 0, j, k, scale,EnumPlanePosition.LEFT); + public void addSidePlane(float f, float f1, float f2, int j, int k, float scale) { + addPlane(f, f1, f2, 0, j, k, scale, EnumPlanePosition.LEFT); } - public void addTopPlane(float f, float f1, float f2, int i, int k, float scale) - { - addPlane(f, f1, f2, i, 0, k, scale,EnumPlanePosition.TOP); + public void addTopPlane(float f, float f1, float f2, int i, int k, float scale) { + addPlane(f, f1, f2, i, 0, k, scale, EnumPlanePosition.TOP); } - - public void addPlane(float par1, float par2, float par3, int par4, int par5, int par6, float f3,EnumPlanePosition pos){ - this.cubeList.add(new ModelPlane(this, this.textureOffsetX, this.textureOffsetY, par1, par2, par3, par4, par5, par6, f3,pos)); + + public void addPlane(float par1, float par2, float par3, int par4, int par5, int par6, float f3, EnumPlanePosition pos) { + this.cubeList.add(new ModelPlane(this, this.textureOffsetX, this.textureOffsetY, par1, par2, par3, par4, par5, par6, f3, pos)); } } diff --git a/src/main/java/noppes/npcs/client/model/util/ModelRenderPassHelper.java b/src/main/java/noppes/npcs/client/model/util/ModelRenderPassHelper.java index 55eb67962..952311b4a 100644 --- a/src/main/java/noppes/npcs/client/model/util/ModelRenderPassHelper.java +++ b/src/main/java/noppes/npcs/client/model/util/ModelRenderPassHelper.java @@ -6,20 +6,20 @@ import net.minecraft.client.renderer.entity.RendererLivingEntity; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; -public class ModelRenderPassHelper extends ModelBase{ +public class ModelRenderPassHelper extends ModelBase { - public RendererLivingEntity renderer; - public EntityLivingBase entity; + public RendererLivingEntity renderer; + public EntityLivingBase entity; public void render(Entity par1Entity, float par2, float par3, float par4, float par5, float par6, float par7) { - ModelBase model = NPCRendererHelper.getPassModel(renderer); - model.isChild = isChild; - model.render(entity, par2, par3, par4, par5, par6, par7); + ModelBase model = NPCRendererHelper.getPassModel(renderer); + model.isChild = isChild; + model.render(entity, par2, par3, par4, par5, par6, par7); } public void setLivingAnimations(EntityLivingBase par1EntityLivingBase, float par2, float par3, float par4) { - ModelBase model = NPCRendererHelper.getPassModel(renderer); - model.isChild = isChild; - model.setLivingAnimations(entity, par2, par3, par4); + ModelBase model = NPCRendererHelper.getPassModel(renderer); + model.isChild = isChild; + model.setLivingAnimations(entity, par2, par3, par4); } } diff --git a/src/main/java/noppes/npcs/client/model/util/ModelScaleRenderer.java b/src/main/java/noppes/npcs/client/model/util/ModelScaleRenderer.java index 586109151..c57b04b19 100644 --- a/src/main/java/noppes/npcs/client/model/util/ModelScaleRenderer.java +++ b/src/main/java/noppes/npcs/client/model/util/ModelScaleRenderer.java @@ -12,7 +12,9 @@ public class ModelScaleRenderer extends ModelRenderer { public boolean compiledModel; - /** The GL display list rendered by the Tessellator for this model */ + /** + * The GL display list rendered by the Tessellator for this model + */ public int displayListModel; protected ModelScalePart config; @@ -22,13 +24,13 @@ public class ModelScaleRenderer extends ModelRenderer { public ModelScaleRenderer(ModelBase par1ModelBase) { super(par1ModelBase); } - public ModelScaleRenderer(ModelBase par1ModelBase, int par2, int par3) - { + + public ModelScaleRenderer(ModelBase par1ModelBase, int par2, int par3) { this(par1ModelBase); this.setTextureOffset(par2, par3); } - public void setConfig(ModelScalePart config, float x, float y, float z){ + public void setConfig(ModelScalePart config, float x, float y, float z) { this.config = config; this.x = x; this.y = y; @@ -41,39 +43,34 @@ public class ModelScaleRenderer extends ModelRenderer { model.rotateAngleZ = z; } - public void render(float par1) - { - if(!showModel || isHidden) + public void render(float par1) { + if (!showModel || isHidden) return; - if(!compiledModel) + if (!compiledModel) compileDisplayListModel(par1); GL11.glPushMatrix(); GL11.glTranslatef(x, y, z); - if(config != null) + if (config != null) GL11.glTranslatef(0, 0, 0); this.postRender(par1); - if(config != null) + if (config != null) GL11.glScalef(config.scaleX, config.scaleY, config.scaleZ); GL11.glCallList(this.displayListModel); - if (this.childModels != null) - { - for (int i = 0; i < this.childModels.size(); ++i) - { - ((ModelRenderer)this.childModels.get(i)).render(par1); + if (this.childModels != null) { + for (int i = 0; i < this.childModels.size(); ++i) { + ((ModelRenderer) this.childModels.get(i)).render(par1); } } GL11.glPopMatrix(); } - public void compileDisplayListModel(float par1) - { + public void compileDisplayListModel(float par1) { this.displayListModel = GLAllocation.generateDisplayLists(1); GL11.glNewList(this.displayListModel, GL11.GL_COMPILE); Tessellator tessellator = Tessellator.instance; - for (int i = 0; i < this.cubeList.size(); ++i) - { - ((ModelBox)this.cubeList.get(i)).render(tessellator, par1); + for (int i = 0; i < this.cubeList.size(); ++i) { + ((ModelBox) this.cubeList.get(i)).render(tessellator, par1); } GL11.glEndList(); diff --git a/src/main/java/noppes/npcs/client/renderer/EnumPlanePosition.java b/src/main/java/noppes/npcs/client/renderer/EnumPlanePosition.java index 98f5b0043..f88f48bd5 100644 --- a/src/main/java/noppes/npcs/client/renderer/EnumPlanePosition.java +++ b/src/main/java/noppes/npcs/client/renderer/EnumPlanePosition.java @@ -1,5 +1,5 @@ package noppes.npcs.client.renderer; public enum EnumPlanePosition { -TOP,BOTTOM,RIGHT,LEFT,FRONT,BACK + TOP, BOTTOM, RIGHT, LEFT, FRONT, BACK } diff --git a/src/main/java/noppes/npcs/client/renderer/ImageBufferDownloadAlt.java b/src/main/java/noppes/npcs/client/renderer/ImageBufferDownloadAlt.java index 2fe78bcce..f236f0e5d 100644 --- a/src/main/java/noppes/npcs/client/renderer/ImageBufferDownloadAlt.java +++ b/src/main/java/noppes/npcs/client/renderer/ImageBufferDownloadAlt.java @@ -14,11 +14,11 @@ public class ImageBufferDownloadAlt extends ImageBufferDownload { public boolean skinTexture = true; // If Version == true, use 64 Loader - public ImageBufferDownloadAlt(boolean ver){ + public ImageBufferDownloadAlt(boolean ver) { this.version = ver; } - public ImageBufferDownloadAlt(boolean ver, boolean skinTexture){ + public ImageBufferDownloadAlt(boolean ver, boolean skinTexture) { this.version = ver; this.skinTexture = skinTexture; } @@ -26,7 +26,7 @@ public class ImageBufferDownloadAlt extends ImageBufferDownload { @Override public BufferedImage parseUserSkin(BufferedImage bufferedimage) { - if(this.version){ + if (this.version) { imageWidth = bufferedimage.getWidth(null); imageHeight = bufferedimage.getHeight(null); @@ -36,12 +36,10 @@ public class ImageBufferDownloadAlt extends ImageBufferDownload { g.dispose(); imageData = ((DataBufferInt) bufferedimage1.getRaster().getDataBuffer()).getData(); - if(skinTexture) + if (skinTexture) setAreaTransparent(imageWidth / 2, 0, imageWidth, imageHeight / 4); return bufferedimage1; - } - - else{ + } else { imageWidth = bufferedimage.getWidth(null); imageHeight = imageWidth / 2; @@ -49,7 +47,7 @@ public class ImageBufferDownloadAlt extends ImageBufferDownload { Graphics g = bufferedimage1.getGraphics(); g.drawImage(bufferedimage, 0, 0, null); g.dispose(); - imageData = ((DataBufferInt)bufferedimage1.getRaster().getDataBuffer()).getData(); + imageData = ((DataBufferInt) bufferedimage1.getRaster().getDataBuffer()).getData(); setAreaTransparent(imageWidth / 2, 0, imageWidth, imageHeight / 2); return bufferedimage1; @@ -87,4 +85,4 @@ public class ImageBufferDownloadAlt extends ImageBufferDownload { return false; } -} \ No newline at end of file +} diff --git a/src/main/java/noppes/npcs/client/renderer/ImageData.java b/src/main/java/noppes/npcs/client/renderer/ImageData.java index 5ca7cf33c..a9afad5c8 100644 --- a/src/main/java/noppes/npcs/client/renderer/ImageData.java +++ b/src/main/java/noppes/npcs/client/renderer/ImageData.java @@ -52,7 +52,8 @@ public class ImageData { } else { this.getURLWidthHeight(); } - } catch (Exception ignored) {} + } catch (Exception ignored) { + } } return !this.invalid && this.location != null && this.gotWidthHeight; } @@ -94,7 +95,8 @@ public class ImageData { IResource iresource = Minecraft.getMinecraft().getResourceManager().getResource(location); InputStream inputstream = iresource.getInputStream(); this.bufferedImage = ImageIO.read(inputstream); - } catch (IOException ignored) {} + } catch (IOException ignored) { + } } else { this.bufferedImage = this.imageDownloadAlt.getBufferedImage(); } @@ -126,8 +128,8 @@ public class ImageData { } } - private void getURLWidthHeight(){ - if(this.imageDownloadAlt.getBufferedImage() != null && !this.invalid) { + private void getURLWidthHeight() { + if (this.imageDownloadAlt.getBufferedImage() != null && !this.invalid) { this.gotWidthHeight = true; this.totalWidth = this.imageDownloadAlt.getBufferedImage().getWidth(); this.totalHeight = this.imageDownloadAlt.getBufferedImage().getHeight(); @@ -135,7 +137,7 @@ public class ImageData { } } - private void correctWidthHeight(){ + private void correctWidthHeight() { this.totalWidth = Math.max(this.totalWidth, 1); this.totalHeight = Math.max(this.totalHeight, 1); } diff --git a/src/main/java/noppes/npcs/client/renderer/MarkRenderer.java b/src/main/java/noppes/npcs/client/renderer/MarkRenderer.java index 0655f6da8..fbafd2a8b 100644 --- a/src/main/java/noppes/npcs/client/renderer/MarkRenderer.java +++ b/src/main/java/noppes/npcs/client/renderer/MarkRenderer.java @@ -10,49 +10,48 @@ import noppes.npcs.controllers.data.MarkData; import org.lwjgl.opengl.GL11; public class MarkRenderer { - public static ResourceLocation markExclamation = new ResourceLocation("customnpcs", "textures/marks/exclamation.png"); - public static ResourceLocation markQuestion = new ResourceLocation("customnpcs", "textures/marks/question.png"); - public static ResourceLocation markPointer = new ResourceLocation("customnpcs", "textures/marks/pointer.png"); - public static ResourceLocation markCross = new ResourceLocation("customnpcs", "textures/marks/cross.png"); - public static ResourceLocation markSkull = new ResourceLocation("customnpcs", "textures/marks/skull.png"); - public static ResourceLocation markStar = new ResourceLocation("customnpcs", "textures/marks/star.png"); + public static ResourceLocation markExclamation = new ResourceLocation("customnpcs", "textures/marks/exclamation.png"); + public static ResourceLocation markQuestion = new ResourceLocation("customnpcs", "textures/marks/question.png"); + public static ResourceLocation markPointer = new ResourceLocation("customnpcs", "textures/marks/pointer.png"); + public static ResourceLocation markCross = new ResourceLocation("customnpcs", "textures/marks/cross.png"); + public static ResourceLocation markSkull = new ResourceLocation("customnpcs", "textures/marks/skull.png"); + public static ResourceLocation markStar = new ResourceLocation("customnpcs", "textures/marks/star.png"); - public static int displayList = -1; + public static int displayList = -1; - public static void render(EntityLivingBase entity, double x, double y, double z, MarkData.Mark mark){ + public static void render(EntityLivingBase entity, double x, double y, double z, MarkData.Mark mark) { GL11.glPushMatrix(); int color = mark.color; - float red = (float)(color >> 16 & 255) / 255.0F; - float blue = (float)(color >> 8 & 255) / 255.0F; - float green = (float)(color & 255) / 255.0F; + float red = (float) (color >> 16 & 255) / 255.0F; + float blue = (float) (color >> 8 & 255) / 255.0F; + float green = (float) (color & 255) / 255.0F; GL11.glColor4f(red, blue, green, 1); GL11.glTranslatef((float) x, (float) (y + entity.height + 0.6), (float) z); GL11.glRotatef(-entity.rotationYawHead, 0, 1, 0); - if(mark.type == MarkType.EXCLAMATION) - Minecraft.getMinecraft().getTextureManager().bindTexture(markExclamation); - else if(mark.type == MarkType.QUESTION) - Minecraft.getMinecraft().getTextureManager().bindTexture(markQuestion); - else if(mark.type == MarkType.POINTER) - Minecraft.getMinecraft().getTextureManager().bindTexture(markPointer); - else if(mark.type == MarkType.CROSS) - Minecraft.getMinecraft().getTextureManager().bindTexture(markCross); - else if(mark.type == MarkType.SKULL) - Minecraft.getMinecraft().getTextureManager().bindTexture(markSkull); - else if(mark.type == MarkType.STAR) - Minecraft.getMinecraft().getTextureManager().bindTexture(markStar); + if (mark.type == MarkType.EXCLAMATION) + Minecraft.getMinecraft().getTextureManager().bindTexture(markExclamation); + else if (mark.type == MarkType.QUESTION) + Minecraft.getMinecraft().getTextureManager().bindTexture(markQuestion); + else if (mark.type == MarkType.POINTER) + Minecraft.getMinecraft().getTextureManager().bindTexture(markPointer); + else if (mark.type == MarkType.CROSS) + Minecraft.getMinecraft().getTextureManager().bindTexture(markCross); + else if (mark.type == MarkType.SKULL) + Minecraft.getMinecraft().getTextureManager().bindTexture(markSkull); + else if (mark.type == MarkType.STAR) + Minecraft.getMinecraft().getTextureManager().bindTexture(markStar); - if(displayList >= 0){ + if (displayList >= 0) { GL11.glCallList(displayList); - } - else{ - displayList = GLAllocation.generateDisplayLists(1); - GL11.glNewList(displayList, GL11.GL_COMPILE); + } else { + displayList = GLAllocation.generateDisplayLists(1); + GL11.glNewList(displayList, GL11.GL_COMPILE); GL11.glTranslatef((float) -0.5, 0, 0); Model2DRenderer.renderItemIn2D(0f, 0f, 1f, 1f, 32, 32, 0.0625F); - GL11.glEndList(); - } + GL11.glEndList(); + } GL11.glPopMatrix(); - } + } } diff --git a/src/main/java/noppes/npcs/client/renderer/NpcItemRenderer.java b/src/main/java/noppes/npcs/client/renderer/NpcItemRenderer.java index 624ed82c7..9205958b2 100644 --- a/src/main/java/noppes/npcs/client/renderer/NpcItemRenderer.java +++ b/src/main/java/noppes/npcs/client/renderer/NpcItemRenderer.java @@ -14,93 +14,93 @@ import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; public class NpcItemRenderer implements IItemRenderer { - private static final ResourceLocation enchant = new ResourceLocation("textures/misc/enchanted_item_glint.png"); + private static final ResourceLocation enchant = new ResourceLocation("textures/misc/enchanted_item_glint.png"); - @Override - public boolean handleRenderType(ItemStack item, ItemRenderType type) { - if (type == ItemRenderType.EQUIPPED || type == ItemRenderType.EQUIPPED_FIRST_PERSON) { - return true; - } - return false; - } + @Override + public boolean handleRenderType(ItemStack item, ItemRenderType type) { + if (type == ItemRenderType.EQUIPPED || type == ItemRenderType.EQUIPPED_FIRST_PERSON) { + return true; + } + return false; + } - @Override - public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) { - return false; - } + @Override + public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) { + return false; + } - @Override - public void renderItem(ItemRenderType type, ItemStack par2ItemStack, Object... data) { - if (!(par2ItemStack.getItem() instanceof ItemRenderInterface)) - return; - EntityLivingBase par1EntityLiving = (EntityLivingBase) data[1]; - GL11.glTranslatef(0.9375F, 0.0625F, 0.0F); - GL11.glRotatef(-315.0F, 0.0F, 0.0F, 1.0F); + @Override + public void renderItem(ItemRenderType type, ItemStack par2ItemStack, Object... data) { + if (!(par2ItemStack.getItem() instanceof ItemRenderInterface)) + return; + EntityLivingBase par1EntityLiving = (EntityLivingBase) data[1]; + GL11.glTranslatef(0.9375F, 0.0625F, 0.0F); + GL11.glRotatef(-315.0F, 0.0F, 0.0F, 1.0F); - ((ItemRenderInterface) par2ItemStack.getItem()).renderSpecial(); - GL11.glRotatef(-20.0F, 0.0F, 0.0F, 1.0F); - GL11.glRotatef(-50.0F, 0.0F, 1.0F, 0.0F); - GL11.glTranslatef(-0.09375F, 0.0625F, 0.0F); - renderItem3d(par1EntityLiving, par2ItemStack); - } + ((ItemRenderInterface) par2ItemStack.getItem()).renderSpecial(); + GL11.glRotatef(-20.0F, 0.0F, 0.0F, 1.0F); + GL11.glRotatef(-50.0F, 0.0F, 1.0F, 0.0F); + GL11.glTranslatef(-0.09375F, 0.0625F, 0.0F); + renderItem3d(par1EntityLiving, par2ItemStack); + } - public void renderItem3d(EntityLivingBase par1EntityLiving, ItemStack par2ItemStack) { - Minecraft mc = Minecraft.getMinecraft(); - TextureManager texturemanager = mc.getTextureManager(); - int par3 = 0; - texturemanager.bindTexture(texturemanager.getResourceLocation(par2ItemStack.getItemSpriteNumber())); - Tessellator tessellator = Tessellator.instance; - IIcon icon = par1EntityLiving.getItemIcon(par2ItemStack, par3); + public void renderItem3d(EntityLivingBase par1EntityLiving, ItemStack par2ItemStack) { + Minecraft mc = Minecraft.getMinecraft(); + TextureManager texturemanager = mc.getTextureManager(); + int par3 = 0; + texturemanager.bindTexture(texturemanager.getResourceLocation(par2ItemStack.getItemSpriteNumber())); + Tessellator tessellator = Tessellator.instance; + IIcon icon = par1EntityLiving.getItemIcon(par2ItemStack, par3); - if (icon == null) { - return; - } - float f = icon.getMinU(); - float f1 = icon.getMaxU(); - float f2 = icon.getMinV(); - float f3 = icon.getMaxV(); - float f4 = 0.0F; - float f5 = 0.3F; - GL11.glEnable(GL12.GL_RESCALE_NORMAL); - GL11.glTranslatef(-f4, -f5, 0.0F); - float f6 = 1.5F; - GL11.glScalef(f6, f6, f6); - GL11.glRotatef(50.0F, 0.0F, 1.0F, 0.0F); - GL11.glRotatef(335.0F, 0.0F, 0.0F, 1.0F); - GL11.glTranslatef(-0.9375F, -0.0625F, 0.0F); - ItemRenderer.renderItemIn2D(tessellator, f1, f2, f, f3, icon.getIconWidth(), icon.getIconHeight(), 0.0625F); + if (icon == null) { + return; + } + float f = icon.getMinU(); + float f1 = icon.getMaxU(); + float f2 = icon.getMinV(); + float f3 = icon.getMaxV(); + float f4 = 0.0F; + float f5 = 0.3F; + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + GL11.glTranslatef(-f4, -f5, 0.0F); + float f6 = 1.5F; + GL11.glScalef(f6, f6, f6); + GL11.glRotatef(50.0F, 0.0F, 1.0F, 0.0F); + GL11.glRotatef(335.0F, 0.0F, 0.0F, 1.0F); + GL11.glTranslatef(-0.9375F, -0.0625F, 0.0F); + ItemRenderer.renderItemIn2D(tessellator, f1, f2, f, f3, icon.getIconWidth(), icon.getIconHeight(), 0.0625F); - if (par2ItemStack.hasEffect(par3)) { - GL11.glDepthFunc(GL11.GL_EQUAL); - GL11.glDisable(GL11.GL_LIGHTING); - texturemanager.bindTexture(enchant); - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_COLOR, GL11.GL_ONE); - float f7 = 0.76F; - GL11.glColor4f(0.5F * f7, 0.25F * f7, 0.8F * f7, 1.0F); - GL11.glMatrixMode(GL11.GL_TEXTURE); - GL11.glPushMatrix(); - float f8 = 0.125F; - GL11.glScalef(f8, f8, f8); - float f9 = (float) (Minecraft.getSystemTime() % 3000L) / 3000.0F * 8.0F; - GL11.glTranslatef(f9, 0.0F, 0.0F); - GL11.glRotatef(-50.0F, 0.0F, 0.0F, 1.0F); - ItemRenderer.renderItemIn2D(tessellator, 0.0F, 0.0F, 1.0F, 1.0F, 256, 256, 0.0625F); - GL11.glPopMatrix(); - GL11.glPushMatrix(); - GL11.glScalef(f8, f8, f8); - f9 = (float) (Minecraft.getSystemTime() % 4873L) / 4873.0F * 8.0F; - GL11.glTranslatef(-f9, 0.0F, 0.0F); - GL11.glRotatef(10.0F, 0.0F, 0.0F, 1.0F); - ItemRenderer.renderItemIn2D(tessellator, 0.0F, 0.0F, 1.0F, 1.0F, 256, 256, 0.0625F); - GL11.glPopMatrix(); - GL11.glMatrixMode(GL11.GL_MODELVIEW); - GL11.glDisable(GL11.GL_BLEND); - GL11.glEnable(GL11.GL_LIGHTING); - GL11.glDepthFunc(GL11.GL_LEQUAL); - } + if (par2ItemStack.hasEffect(par3)) { + GL11.glDepthFunc(GL11.GL_EQUAL); + GL11.glDisable(GL11.GL_LIGHTING); + texturemanager.bindTexture(enchant); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_COLOR, GL11.GL_ONE); + float f7 = 0.76F; + GL11.glColor4f(0.5F * f7, 0.25F * f7, 0.8F * f7, 1.0F); + GL11.glMatrixMode(GL11.GL_TEXTURE); + GL11.glPushMatrix(); + float f8 = 0.125F; + GL11.glScalef(f8, f8, f8); + float f9 = (float) (Minecraft.getSystemTime() % 3000L) / 3000.0F * 8.0F; + GL11.glTranslatef(f9, 0.0F, 0.0F); + GL11.glRotatef(-50.0F, 0.0F, 0.0F, 1.0F); + ItemRenderer.renderItemIn2D(tessellator, 0.0F, 0.0F, 1.0F, 1.0F, 256, 256, 0.0625F); + GL11.glPopMatrix(); + GL11.glPushMatrix(); + GL11.glScalef(f8, f8, f8); + f9 = (float) (Minecraft.getSystemTime() % 4873L) / 4873.0F * 8.0F; + GL11.glTranslatef(-f9, 0.0F, 0.0F); + GL11.glRotatef(10.0F, 0.0F, 0.0F, 1.0F); + ItemRenderer.renderItemIn2D(tessellator, 0.0F, 0.0F, 1.0F, 1.0F, 256, 256, 0.0625F); + GL11.glPopMatrix(); + GL11.glMatrixMode(GL11.GL_MODELVIEW); + GL11.glDisable(GL11.GL_BLEND); + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glDepthFunc(GL11.GL_LEQUAL); + } - GL11.glDisable(GL12.GL_RESCALE_NORMAL); - } + GL11.glDisable(GL12.GL_RESCALE_NORMAL); + } } diff --git a/src/main/java/noppes/npcs/client/renderer/RenderCNPCHand.java b/src/main/java/noppes/npcs/client/renderer/RenderCNPCHand.java index d4d4cdb1b..d4e94b31b 100644 --- a/src/main/java/noppes/npcs/client/renderer/RenderCNPCHand.java +++ b/src/main/java/noppes/npcs/client/renderer/RenderCNPCHand.java @@ -17,13 +17,19 @@ import org.lwjgl.opengl.GL12; import static noppes.npcs.client.ClientEventHandler.renderCNPCSelf; public class RenderCNPCHand extends ItemRenderer { - /** A reference to the Minecraft object. */ + /** + * A reference to the Minecraft object. + */ private Minecraft mc; private ItemStack itemToRender; - /** How far the current item has been equipped (0 disequipped and 1 fully up) */ + /** + * How far the current item has been equipped (0 disequipped and 1 fully up) + */ private float equippedProgress; private float prevEquippedProgress; - /** The index of the currently held item (0-8, or -1 if not yet updated) */ + /** + * The index of the currently held item (0-8, or -1 if not yet updated) + */ private int equippedItemSlot = -1; public RenderCNPCHand(Minecraft mc) { @@ -34,8 +40,7 @@ public class RenderCNPCHand extends ItemRenderer { /** * Renders the active item in the player's hand when in first person mode. Args: partialTickTime */ - public void renderOverlayInFirstPerson(float partialTickTime) - { + public void renderOverlayInFirstPerson(float partialTickTime) { float f1 = this.prevEquippedProgress + (this.equippedProgress - this.prevEquippedProgress) * partialTickTime; EntityClientPlayerMP entityclientplayermp = this.mc.thePlayer; float f2 = entityclientplayermp.prevRotationPitch + (entityclientplayermp.rotationPitch - entityclientplayermp.prevRotationPitch) * partialTickTime; @@ -44,8 +49,8 @@ public class RenderCNPCHand extends ItemRenderer { GL11.glRotatef(entityclientplayermp.prevRotationYaw + (entityclientplayermp.rotationYaw - entityclientplayermp.prevRotationYaw) * partialTickTime, 0.0F, 1.0F, 0.0F); RenderHelper.enableStandardItemLighting(); GL11.glPopMatrix(); - float f3 = ((EntityPlayerSP)entityclientplayermp).prevRenderArmPitch + (((EntityPlayerSP)entityclientplayermp).renderArmPitch - ((EntityPlayerSP)entityclientplayermp).prevRenderArmPitch) * partialTickTime; - float f4 = ((EntityPlayerSP)entityclientplayermp).prevRenderArmYaw + (((EntityPlayerSP)entityclientplayermp).renderArmYaw - ((EntityPlayerSP)entityclientplayermp).prevRenderArmYaw) * partialTickTime; + float f3 = ((EntityPlayerSP) entityclientplayermp).prevRenderArmPitch + (((EntityPlayerSP) entityclientplayermp).renderArmPitch - ((EntityPlayerSP) entityclientplayermp).prevRenderArmPitch) * partialTickTime; + float f4 = ((EntityPlayerSP) entityclientplayermp).prevRenderArmYaw + (((EntityPlayerSP) entityclientplayermp).renderArmYaw - ((EntityPlayerSP) entityclientplayermp).prevRenderArmYaw) * partialTickTime; GL11.glRotatef((entityclientplayermp.rotationPitch - f3) * 0.1F, 1.0F, 0.0F, 0.0F); GL11.glRotatef((entityclientplayermp.rotationYaw - f4) * 0.1F, 0.0F, 1.0F, 0.0F); @@ -53,7 +58,7 @@ public class RenderCNPCHand extends ItemRenderer { int i = this.mc.theWorld.getLightBrightnessForSkyBlocks(MathHelper.floor_double(entityclientplayermp.posX), MathHelper.floor_double(entityclientplayermp.posY), MathHelper.floor_double(entityclientplayermp.posZ), 0); int j = i % 65536; int k = i / 65536; - OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float)j / 1.0F, (float)k / 1.0F); + OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float) j / 1.0F, (float) k / 1.0F); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); float f5; float f6; @@ -64,20 +69,19 @@ public class RenderCNPCHand extends ItemRenderer { Render render; RenderPlayer renderplayer; - if (itemstack == null && !entityclientplayermp.isInvisible()) - { + if (itemstack == null && !entityclientplayermp.isInvisible()) { GL11.glPushMatrix(); f13 = 0.8F; f5 = entityclientplayermp.getSwingProgress(partialTickTime); - f6 = MathHelper.sin(f5 * (float)Math.PI); - f7 = MathHelper.sin(MathHelper.sqrt_float(f5) * (float)Math.PI); - GL11.glTranslatef(-f7 * 0.3F, MathHelper.sin(MathHelper.sqrt_float(f5) * (float)Math.PI * 2.0F) * 0.4F, -f6 * 0.4F); + f6 = MathHelper.sin(f5 * (float) Math.PI); + f7 = MathHelper.sin(MathHelper.sqrt_float(f5) * (float) Math.PI); + GL11.glTranslatef(-f7 * 0.3F, MathHelper.sin(MathHelper.sqrt_float(f5) * (float) Math.PI * 2.0F) * 0.4F, -f6 * 0.4F); GL11.glTranslatef(0.8F * f13, -0.75F * f13 - (1.0F - f1) * 0.6F, -0.9F * f13); GL11.glRotatef(45.0F, 0.0F, 1.0F, 0.0F); GL11.glEnable(GL12.GL_RESCALE_NORMAL); f5 = entityclientplayermp.getSwingProgress(partialTickTime); - f6 = MathHelper.sin(f5 * f5 * (float)Math.PI); - f7 = MathHelper.sin(MathHelper.sqrt_float(f5) * (float)Math.PI); + f6 = MathHelper.sin(f5 * f5 * (float) Math.PI); + f7 = MathHelper.sin(MathHelper.sqrt_float(f5) * (float) Math.PI); GL11.glRotatef(f7 * 70.0F, 0.0F, 1.0F, 0.0F); GL11.glRotatef(-f6 * 20.0F, 0.0F, 0.0F, 1.0F); GL11.glTranslatef(-1.0F, 3.6F, 3.5F); @@ -102,20 +106,17 @@ public class RenderCNPCHand extends ItemRenderer { RenderHelper.disableStandardItemLighting(); } - public void updateEquippedItem() - { + public void updateEquippedItem() { this.prevEquippedProgress = this.equippedProgress; EntityClientPlayerMP entityclientplayermp = this.mc.thePlayer; ItemStack itemstack = entityclientplayermp.inventory.getCurrentItem(); boolean flag = this.equippedItemSlot == entityclientplayermp.inventory.currentItem && itemstack == this.itemToRender; - if (this.itemToRender == null && itemstack == null) - { + if (this.itemToRender == null && itemstack == null) { flag = true; } - if (itemstack != null && this.itemToRender != null && itemstack != this.itemToRender && itemstack.getItem() == this.itemToRender.getItem() && itemstack.getItemDamage() == this.itemToRender.getItemDamage()) - { + if (itemstack != null && this.itemToRender != null && itemstack != this.itemToRender && itemstack.getItem() == this.itemToRender.getItem() && itemstack.getItemDamage() == this.itemToRender.getItemDamage()) { this.itemToRender = itemstack; flag = true; } @@ -124,20 +125,17 @@ public class RenderCNPCHand extends ItemRenderer { float f1 = flag ? 1.0F : 0.0F; float f2 = f1 - this.equippedProgress; - if (f2 < -f) - { + if (f2 < -f) { f2 = -f; } - if (f2 > f) - { + if (f2 > f) { f2 = f; } this.equippedProgress += f2; - if (this.equippedProgress < 0.1F) - { + if (this.equippedProgress < 0.1F) { this.itemToRender = itemstack; this.equippedItemSlot = entityclientplayermp.inventory.currentItem; } diff --git a/src/main/java/noppes/npcs/client/renderer/RenderCNPCPlayer.java b/src/main/java/noppes/npcs/client/renderer/RenderCNPCPlayer.java index 9ccd98016..9e3b87090 100644 --- a/src/main/java/noppes/npcs/client/renderer/RenderCNPCPlayer.java +++ b/src/main/java/noppes/npcs/client/renderer/RenderCNPCPlayer.java @@ -41,12 +41,12 @@ public class RenderCNPCPlayer extends RenderPlayer { public RenderCNPCPlayer() { super(); - this.modelBipedMain = (ModelBiped)this.mainModel; + this.modelBipedMain = (ModelBiped) this.mainModel; this.modelArmorChestplate = new ModelBiped(1.0F); this.modelArmor = new ModelBiped(0.5F); this.setRenderManager(RenderManager.instance); - if(Loader.isModLoaded("moreplayermodels")) + if (Loader.isModLoaded("moreplayermodels")) hasMPM = true; } @@ -54,7 +54,7 @@ public class RenderCNPCPlayer extends RenderPlayer { if (overlayData.texture.isEmpty()) return false; - ImageData imageData = ClientCacheHandler.getImageData(((SkinOverlay)overlayData).texture); + ImageData imageData = ClientCacheHandler.getImageData(((SkinOverlay) overlayData).texture); if (!imageData.imageLoaded()) return false; @@ -75,7 +75,7 @@ public class RenderCNPCPlayer extends RenderPlayer { if (overlayData.glow) { GL11.glDisable(GL11.GL_LIGHTING); - Minecraft.getMinecraft().entityRenderer.disableLightmap((double)0); + Minecraft.getMinecraft().entityRenderer.disableLightmap((double) 0); RenderHelper.disableStandardItemLighting(); } @@ -96,6 +96,7 @@ public class RenderCNPCPlayer extends RenderPlayer { return true; } + public void postRenderOverlay() { GL11.glPopMatrix(); @@ -114,21 +115,20 @@ public class RenderCNPCPlayer extends RenderPlayer { @Override protected void renderModel(EntityLivingBase entity, float par2, float par3, float par4, float par5, float par6, float par7) { EntityPlayer player = (EntityPlayer) entity; - if (!entity.isInvisible()) - { + if (!entity.isInvisible()) { if (ClientCacheHandler.skinOverlays.containsKey(player.getUniqueID())) { for (SkinOverlay overlayData : ClientCacheHandler.skinOverlays.get(player.getUniqueID()).values()) { - if (((SkinOverlay)overlayData).texture.isEmpty()) + if (((SkinOverlay) overlayData).texture.isEmpty()) continue; - ImageData imageData = ClientCacheHandler.getImageData(((SkinOverlay)overlayData).texture); + ImageData imageData = ClientCacheHandler.getImageData(((SkinOverlay) overlayData).texture); if (!imageData.imageLoaded()) continue; if (!this.preRenderOverlay(overlayData, player)) continue; - if(hasMPM){ + if (hasMPM) { renderMorePlayerModel(entity, par2, par3, par4, par5, par6, par7); } else { this.modelBipedMain.render(entity, par2, par3, par4, par5, par6, par7); @@ -139,8 +139,7 @@ public class RenderCNPCPlayer extends RenderPlayer { } } - protected int shouldRenderPass(AbstractClientPlayer p_77032_1_, int p_77032_2_, float p_77032_3_) - { + protected int shouldRenderPass(AbstractClientPlayer p_77032_1_, int p_77032_2_, float p_77032_3_) { return -1; } @@ -161,27 +160,25 @@ public class RenderCNPCPlayer extends RenderPlayer { } } - protected void func_96449_a(AbstractClientPlayer p_96449_1_, double p_96449_2_, double p_96449_4_, double p_96449_6_, String p_96449_8_, float p_96449_9_, double p_96449_10_) {} + protected void func_96449_a(AbstractClientPlayer p_96449_1_, double p_96449_2_, double p_96449_4_, double p_96449_6_, String p_96449_8_, float p_96449_9_, double p_96449_10_) { + } public void renderHand(float partialTicks, int renderPass) { Minecraft mc = Minecraft.getMinecraft(); EntityRenderer entityRenderer = mc.entityRenderer; - if (entityRenderer.debugViewDirection <= 0) - { + if (entityRenderer.debugViewDirection <= 0) { GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadIdentity(); float f1 = 0.07F; - if (mc.gameSettings.anaglyph) - { - GL11.glTranslatef((float)(-(renderPass * 2 - 1)) * f1, 0.0F, 0.0F); + if (mc.gameSettings.anaglyph) { + GL11.glTranslatef((float) (-(renderPass * 2 - 1)) * f1, 0.0F, 0.0F); } - Project.gluPerspective(this.getFOVModifier(partialTicks, false), (float)mc.displayWidth / (float)mc.displayHeight, 0.05F, mc.gameSettings.renderDistanceChunks * 16 * 2.0F); + Project.gluPerspective(this.getFOVModifier(partialTicks, false), (float) mc.displayWidth / (float) mc.displayHeight, 0.05F, mc.gameSettings.renderDistanceChunks * 16 * 2.0F); - if (mc.playerController.enableEverythingIsScrewedUpMode()) - { + if (mc.playerController.enableEverythingIsScrewedUpMode()) { float f2 = 0.6666667F; GL11.glScalef(1.0F, f2, 1.0F); } @@ -189,80 +186,69 @@ public class RenderCNPCPlayer extends RenderPlayer { GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glLoadIdentity(); - if (mc.gameSettings.anaglyph) - { - GL11.glTranslatef((float)(renderPass * 2 - 1) * 0.1F, 0.0F, 0.0F); + if (mc.gameSettings.anaglyph) { + GL11.glTranslatef((float) (renderPass * 2 - 1) * 0.1F, 0.0F, 0.0F); } GL11.glPushMatrix(); hurtCameraEffect(partialTicks); - if (mc.gameSettings.viewBobbing) - { + if (mc.gameSettings.viewBobbing) { setupViewBobbing(partialTicks); } - if (mc.gameSettings.thirdPersonView == 0 && !mc.renderViewEntity.isPlayerSleeping() && !mc.gameSettings.hideGUI && !mc.playerController.enableEverythingIsScrewedUpMode()) - { - entityRenderer.enableLightmap((double)partialTicks); + if (mc.gameSettings.thirdPersonView == 0 && !mc.renderViewEntity.isPlayerSleeping() && !mc.gameSettings.hideGUI && !mc.playerController.enableEverythingIsScrewedUpMode()) { + entityRenderer.enableLightmap((double) partialTicks); itemRenderer.renderOverlayInFirstPerson(partialTicks); - entityRenderer.disableLightmap((double)partialTicks); + entityRenderer.disableLightmap((double) partialTicks); } GL11.glPopMatrix(); - if (mc.gameSettings.viewBobbing) - { + if (mc.gameSettings.viewBobbing) { setupViewBobbing(partialTicks); } } } - private float getFOVModifier(float p_78481_1_, boolean p_78481_2_) - { + private float getFOVModifier(float p_78481_1_, boolean p_78481_2_) { Minecraft mc = Minecraft.getMinecraft(); - EntityLivingBase entityplayer = (EntityLivingBase)mc.renderViewEntity; + EntityLivingBase entityplayer = (EntityLivingBase) mc.renderViewEntity; float f1 = 70.0F; - if (p_78481_2_) - { + if (p_78481_2_) { f1 = mc.gameSettings.fovSetting; f1 *= this.fovModifierHandPrev + (this.fovModifierHand - this.fovModifierHandPrev) * p_78481_1_; } - if (entityplayer.getHealth() <= 0.0F) - { - float f2 = (float)entityplayer.deathTime + p_78481_1_; + if (entityplayer.getHealth() <= 0.0F) { + float f2 = (float) entityplayer.deathTime + p_78481_1_; f1 /= (1.0F - 500.0F / (f2 + 500.0F)) * 2.0F + 1.0F; } Block block = ActiveRenderInfo.getBlockAtEntityViewpoint(mc.theWorld, entityplayer, p_78481_1_); - if (block.getMaterial() == Material.water) - { + if (block.getMaterial() == Material.water) { f1 = f1 * 60.0F / 70.0F; } return f1 + this.prevDebugCamFOV + (this.debugCamFOV - this.prevDebugCamFOV) * p_78481_1_; } - private void hurtCameraEffect(float p_78482_1_) - { + private void hurtCameraEffect(float p_78482_1_) { Minecraft mc = Minecraft.getMinecraft(); EntityLivingBase entitylivingbase = mc.renderViewEntity; - float f1 = (float)entitylivingbase.hurtTime - p_78482_1_; + float f1 = (float) entitylivingbase.hurtTime - p_78482_1_; float f2; - if (entitylivingbase.getHealth() <= 0.0F) - { - f2 = (float)entitylivingbase.deathTime + p_78482_1_; + if (entitylivingbase.getHealth() <= 0.0F) { + f2 = (float) entitylivingbase.deathTime + p_78482_1_; GL11.glRotatef(40.0F - 8000.0F / (f2 + 200.0F), 0.0F, 0.0F, 1.0F); } - if (f1 >= 0.0F) - { - f1 /= (float)entitylivingbase.maxHurtTime; - f1 = MathHelper.sin(f1 * f1 * f1 * f1 * (float)Math.PI); + if (f1 >= 0.0F) { + f1 /= (float) entitylivingbase.maxHurtTime; + f1 = MathHelper.sin(f1 * f1 * f1 * f1 * (float) Math.PI); f2 = entitylivingbase.attackedAtYaw; GL11.glRotatef(-f2, 0.0F, 1.0F, 0.0F); GL11.glRotatef(-f1 * 14.0F, 0.0F, 0.0F, 1.0F); @@ -270,19 +256,17 @@ public class RenderCNPCPlayer extends RenderPlayer { } } - private void setupViewBobbing(float p_78475_1_) - { + private void setupViewBobbing(float p_78475_1_) { Minecraft mc = Minecraft.getMinecraft(); - if (mc.renderViewEntity instanceof EntityPlayer) - { - EntityPlayer entityplayer = (EntityPlayer)mc.renderViewEntity; + if (mc.renderViewEntity instanceof EntityPlayer) { + EntityPlayer entityplayer = (EntityPlayer) mc.renderViewEntity; float f1 = entityplayer.distanceWalkedModified - entityplayer.prevDistanceWalkedModified; float f2 = -(entityplayer.distanceWalkedModified + f1 * p_78475_1_); float f3 = entityplayer.prevCameraYaw + (entityplayer.cameraYaw - entityplayer.prevCameraYaw) * p_78475_1_; float f4 = entityplayer.prevCameraPitch + (entityplayer.cameraPitch - entityplayer.prevCameraPitch) * p_78475_1_; - GL11.glTranslatef(MathHelper.sin(f2 * (float)Math.PI) * f3 * 0.5F, -Math.abs(MathHelper.cos(f2 * (float)Math.PI) * f3), 0.0F); - GL11.glRotatef(MathHelper.sin(f2 * (float)Math.PI) * f3 * 3.0F, 0.0F, 0.0F, 1.0F); - GL11.glRotatef(Math.abs(MathHelper.cos(f2 * (float)Math.PI - 0.2F) * f3) * 5.0F, 1.0F, 0.0F, 0.0F); + GL11.glTranslatef(MathHelper.sin(f2 * (float) Math.PI) * f3 * 0.5F, -Math.abs(MathHelper.cos(f2 * (float) Math.PI) * f3), 0.0F); + GL11.glRotatef(MathHelper.sin(f2 * (float) Math.PI) * f3 * 3.0F, 0.0F, 0.0F, 1.0F); + GL11.glRotatef(Math.abs(MathHelper.cos(f2 * (float) Math.PI - 0.2F) * f3) * 5.0F, 1.0F, 0.0F, 0.0F); GL11.glRotatef(f4, 1.0F, 0.0F, 0.0F); } } @@ -297,7 +281,8 @@ public class RenderCNPCPlayer extends RenderPlayer { try { Class RenderPlayerJBRA = Class.forName("JinRyuu.JBRA.RenderPlayerJBRA"); gender = (float) RenderPlayerJBRA.getMethod("genGet").invoke(null); - } catch (Exception ignored) {} + } catch (Exception ignored) { + } // Check if the skinOverlays map exists for this player's UUID UUID uuid = player.getUniqueID(); @@ -340,14 +325,15 @@ public class RenderCNPCPlayer extends RenderPlayer { } } - public void renderMorePlayerModel(EntityLivingBase entity, float par2, float par3, float par4, float par5, float par6, float par7){ + public void renderMorePlayerModel(EntityLivingBase entity, float par2, float par3, float par4, float par5, float par6, float par7) { Class ModelMPMClass = null; Field isArmor = null; try { ModelMPMClass = Class.forName("noppes.mpm.client.model.ModelMPM"); isArmor = ModelMPMClass.getDeclaredField("isArmor"); - } catch (Exception ignored) {} + } catch (Exception ignored) { + } // Assuming this.modelBipedMain is an instance of ModelMPM if (ModelMPMClass != null && ModelMPMClass.isInstance(this.modelBipedMain)) { @@ -358,7 +344,8 @@ public class RenderCNPCPlayer extends RenderPlayer { this.modelBipedMain.render(entity, par2, par3, par4, par5, par6, par7); isArmor.setBoolean(this.modelBipedMain, false); } - } catch (IllegalAccessException ignored) {} + } catch (IllegalAccessException ignored) { + } } } @@ -369,11 +356,11 @@ public class RenderCNPCPlayer extends RenderPlayer { Class ModelBipedDBC = null; Class ModelBipedBody = null; Method renderDBC = null; - Field rot1 = null,rot2 = null,rot3 = null,rot4 = null,rot5 = null,rot6 = null; + Field rot1 = null, rot2 = null, rot3 = null, rot4 = null, rot5 = null, rot6 = null; Object m = null; - ModelRenderer bipedHead = null,bipedBody = null,bipedRA = null,bipedLA = null,bipedRL = null,bipedLL = null; - ModelRenderer Brightarm = null,Bleftarm = null,rightleg = null,leftleg = null,body = null,hip = null; - ModelRenderer waist = null,bottom = null,Bbreast = null,Bbreast2 = null,breast = null,breast2 = null; + ModelRenderer bipedHead = null, bipedBody = null, bipedRA = null, bipedLA = null, bipedRL = null, bipedLL = null; + ModelRenderer Brightarm = null, Bleftarm = null, rightleg = null, leftleg = null, body = null, hip = null; + ModelRenderer waist = null, bottom = null, Bbreast = null, Bbreast2 = null, breast = null, breast2 = null; float childScl = 0.0F; try { @@ -381,7 +368,7 @@ public class RenderCNPCPlayer extends RenderPlayer { ModelBipedDBC = Class.forName("JinRyuu.JBRA.ModelBipedDBC"); ModelBipedBody = Class.forName("JinRyuu.JRMCore.entity.ModelBipedBody"); - renderDBC = ModelBipedBody.getMethod("render",Entity.class,float.class,float.class,float.class,float.class,float.class,float.class); + renderDBC = ModelBipedBody.getMethod("render", Entity.class, float.class, float.class, float.class, float.class, float.class, float.class); rot1 = ModelBipedDBC.getField("rot1"); rot2 = ModelBipedDBC.getField("rot2"); rot3 = ModelBipedDBC.getField("rot3"); @@ -415,14 +402,15 @@ public class RenderCNPCPlayer extends RenderPlayer { breast = (ModelRenderer) ModelBipedBody.getField("breast").get(m); breast2 = (ModelRenderer) ModelBipedBody.getField("breast2").get(m); childScl = (float) RenderPlayerJBRA.getMethod("childSclGet").invoke(null); - } catch (Exception ignored) {} + } catch (Exception ignored) { + } try { RenderPlayerJBRA = Class.forName("JinRyuu.JBRA.RenderPlayerJBRA"); ModelBipedDBC = Class.forName("JinRyuu.JBRA.ModelBipedDBC"); ModelBipedBody = Class.forName("JinRyuu.JRMCore.entity.ModelBipedBody"); - renderDBC = ModelBipedBody.getMethod("func_78088_a",Entity.class,float.class,float.class,float.class,float.class,float.class,float.class); + renderDBC = ModelBipedBody.getMethod("func_78088_a", Entity.class, float.class, float.class, float.class, float.class, float.class, float.class); rot1 = ModelBipedDBC.getField("rot1"); rot2 = ModelBipedDBC.getField("rot2"); rot3 = ModelBipedDBC.getField("rot3"); @@ -456,29 +444,32 @@ public class RenderCNPCPlayer extends RenderPlayer { breast = (ModelRenderer) ModelBipedBody.getField("breast").get(m); breast2 = (ModelRenderer) ModelBipedBody.getField("breast2").get(m); childScl = (float) RenderPlayerJBRA.getMethod("childSclGet").invoke(null); - } catch (Exception ignored) {} + } catch (Exception ignored) { + } try { if (ClientCacheHandler.skinOverlays.containsKey(player.getUniqueID())) { for (SkinOverlay overlayData : ClientCacheHandler.skinOverlays.get(player.getUniqueID()).values()) { - if (((SkinOverlay)overlayData).texture.isEmpty()) + if (((SkinOverlay) overlayData).texture.isEmpty()) continue; - ImageData imageData = ClientCacheHandler.getImageData(((SkinOverlay)overlayData).texture); + ImageData imageData = ClientCacheHandler.getImageData(((SkinOverlay) overlayData).texture); if (!imageData.imageLoaded()) continue; try { imageData.bindTexture(); - } catch (Exception e) { continue; } + } catch (Exception e) { + continue; + } if (!this.preRenderOverlay(overlayData, player)) continue; bipedHead.isHidden = true; renderDBC.invoke(m, player, - (float) rot1.get(m), (float) rot2.get(m), (float) rot3.get(m), - (float) rot4.get(m), (float) rot5.get(m), (float) rot6.get(m) + (float) rot1.get(m), (float) rot2.get(m), (float) rot3.get(m), + (float) rot4.get(m), (float) rot5.get(m), (float) rot6.get(m) ); bipedHead.isHidden = false; @@ -516,8 +507,8 @@ public class RenderCNPCPlayer extends RenderPlayer { } } renderDBC.invoke(m, player, - (float) rot1.get(m), (float) rot2.get(m), (float) rot3.get(m), - (float) rot4.get(m), (float) rot5.get(m), (float) rot6.get(m) + (float) rot1.get(m), (float) rot2.get(m), (float) rot3.get(m), + (float) rot4.get(m), (float) rot5.get(m), (float) rot6.get(m) ); bipedBody.isHidden = false; bipedRA.isHidden = false; @@ -541,6 +532,7 @@ public class RenderCNPCPlayer extends RenderPlayer { postRenderOverlay(); } } - } catch (Exception ignored) {} + } catch (Exception ignored) { + } } } diff --git a/src/main/java/noppes/npcs/client/renderer/RenderCustomNpc.java b/src/main/java/noppes/npcs/client/renderer/RenderCustomNpc.java index 1734506af..a2be8c19c 100644 --- a/src/main/java/noppes/npcs/client/renderer/RenderCustomNpc.java +++ b/src/main/java/noppes/npcs/client/renderer/RenderCustomNpc.java @@ -16,106 +16,105 @@ import org.lwjgl.opengl.GL11; import java.lang.reflect.Method; -public class RenderCustomNpc extends RenderNPCHumanMale{ +public class RenderCustomNpc extends RenderNPCHumanMale { - private RendererLivingEntity renderEntity; - public static EntityLivingBase entity; + private RendererLivingEntity renderEntity; + public static EntityLivingBase entity; - private ModelRenderPassHelper renderpass = new ModelRenderPassHelper(); + private ModelRenderPassHelper renderpass = new ModelRenderPassHelper(); - // Default Renderer - public RenderCustomNpc() { - super(new ModelMPM(0,0), new ModelMPM(1,0), new ModelMPM(0.5f,0)); - } - - @Override - public void renderPlayer(EntityNPCInterface npcInterface, double d, double d1, double d2, float f, float f1){ - EntityCustomNpc npc = (EntityCustomNpc) npcInterface; - entity = npc.modelData.getEntity(npc); - ModelBase model = null; - renderEntity = null; - if(entity != null){ - renderEntity = (RendererLivingEntity) RenderManager.instance.getEntityRenderObject(entity); - model = NPCRendererHelper.getMainModel(renderEntity); - if(PixelmonHelper.isPixelmon(entity)){ - try { - Class c = Class.forName("com.pixelmonmod.pixelmon.entities.pixelmon.Entity2HasModel"); - Method m = c.getMethod("getModel"); - model = (ModelBase) m.invoke(entity); - } catch (Exception e) { - e.printStackTrace(); - } - } - if(EntityList.getEntityString(entity).equals("doggystyle.Dog")){ - try { - Method m = entity.getClass().getMethod("getBreed"); - Object breed = m.invoke(entity); - m = breed.getClass().getMethod("getModel"); - model = (ModelBase) m.invoke(breed); - model.getClass().getMethod("setPosition", int.class).invoke(model, 0); - } catch (Exception e) { - e.printStackTrace(); - } - } - renderPassModel = renderpass; - renderpass.renderer = renderEntity; - renderpass.entity = entity; - } - ((ModelMPM)this.modelArmor).entityModel = model; - ((ModelMPM)this.modelArmor).entity = entity; - - ((ModelMPM)this.modelArmorChestplate).entityModel = model; - ((ModelMPM)this.modelArmorChestplate).entity = entity; - - ((ModelMPM)this.mainModel).entityModel = model; - ((ModelMPM)this.mainModel).entity = entity; - - super.renderPlayer(npc, d, d1, d2, f, f1); - - } - - @Override - protected void renderEquippedItems(EntityLivingBase entityliving, float f){ - if(renderEntity != null) - NPCRendererHelper.renderEquippedItems(entity, f, renderEntity); - else - super.renderEquippedItems(entityliving, f); + // Default Renderer + public RenderCustomNpc() { + super(new ModelMPM(0, 0), new ModelMPM(1, 0), new ModelMPM(0.5f, 0)); } - @Override - protected int shouldRenderPass(EntityLivingBase par1EntityLivingBase, int par2, float par3){ - if(renderEntity != null){ - return NPCRendererHelper.shouldRenderPass(entity, par2, par3, renderEntity); - } - return this.func_130006_a((EntityLiving)par1EntityLivingBase, par2, par3); - } - - @Override - protected void preRenderCallback(EntityLivingBase entityliving, float f){ - if(renderEntity != null){ - EntityNPCInterface npc = (EntityNPCInterface) entityliving; - int size = npc.display.modelSize; - if(entity instanceof EntityNPCInterface){ - ((EntityNPCInterface)entity).display.modelSize = 5; - } - NPCRendererHelper.preRenderCallback(entity, f, renderEntity); - npc.display.modelSize = size; - GL11.glScalef(0.2f * npc.display.modelSize, 0.2f * npc.display.modelSize, 0.2f * npc.display.modelSize); - } - else - super.preRenderCallback(entityliving, f); + @Override + public void renderPlayer(EntityNPCInterface npcInterface, double d, double d1, double d2, float f, float f1) { + EntityCustomNpc npc = (EntityCustomNpc) npcInterface; + entity = npc.modelData.getEntity(npc); + ModelBase model = null; + renderEntity = null; + if (entity != null) { + renderEntity = (RendererLivingEntity) RenderManager.instance.getEntityRenderObject(entity); + model = NPCRendererHelper.getMainModel(renderEntity); + if (PixelmonHelper.isPixelmon(entity)) { + try { + Class c = Class.forName("com.pixelmonmod.pixelmon.entities.pixelmon.Entity2HasModel"); + Method m = c.getMethod("getModel"); + model = (ModelBase) m.invoke(entity); + } catch (Exception e) { + e.printStackTrace(); + } + } + if (EntityList.getEntityString(entity).equals("doggystyle.Dog")) { + try { + Method m = entity.getClass().getMethod("getBreed"); + Object breed = m.invoke(entity); + m = breed.getClass().getMethod("getModel"); + model = (ModelBase) m.invoke(breed); + model.getClass().getMethod("setPosition", int.class).invoke(model, 0); + } catch (Exception e) { + e.printStackTrace(); + } + } + renderPassModel = renderpass; + renderpass.renderer = renderEntity; + renderpass.entity = entity; + } + ((ModelMPM) this.modelArmor).entityModel = model; + ((ModelMPM) this.modelArmor).entity = entity; + + ((ModelMPM) this.modelArmorChestplate).entityModel = model; + ((ModelMPM) this.modelArmorChestplate).entity = entity; + + ((ModelMPM) this.mainModel).entityModel = model; + ((ModelMPM) this.mainModel).entity = entity; + + super.renderPlayer(npc, d, d1, d2, f, f1); + } - @Override - public void doRender(EntityLiving entityliving, double d, double d1, double d2, float f, float f1){ - super.doRender(entityliving, d, d1, d2, f, f1); - } + @Override + protected void renderEquippedItems(EntityLivingBase entityliving, float f) { + if (renderEntity != null) + NPCRendererHelper.renderEquippedItems(entity, f, renderEntity); + else + super.renderEquippedItems(entityliving, f); + } - @Override - protected float handleRotationFloat(EntityLivingBase par1EntityLivingBase, float par2){ - if(renderEntity != null){ - return NPCRendererHelper.handleRotationFloat(entity, par2, renderEntity); - } + @Override + protected int shouldRenderPass(EntityLivingBase par1EntityLivingBase, int par2, float par3) { + if (renderEntity != null) { + return NPCRendererHelper.shouldRenderPass(entity, par2, par3, renderEntity); + } + return this.func_130006_a((EntityLiving) par1EntityLivingBase, par2, par3); + } + + @Override + protected void preRenderCallback(EntityLivingBase entityliving, float f) { + if (renderEntity != null) { + EntityNPCInterface npc = (EntityNPCInterface) entityliving; + int size = npc.display.modelSize; + if (entity instanceof EntityNPCInterface) { + ((EntityNPCInterface) entity).display.modelSize = 5; + } + NPCRendererHelper.preRenderCallback(entity, f, renderEntity); + npc.display.modelSize = size; + GL11.glScalef(0.2f * npc.display.modelSize, 0.2f * npc.display.modelSize, 0.2f * npc.display.modelSize); + } else + super.preRenderCallback(entityliving, f); + } + + @Override + public void doRender(EntityLiving entityliving, double d, double d1, double d2, float f, float f1) { + super.doRender(entityliving, d, d1, d2, f, f1); + } + + @Override + protected float handleRotationFloat(EntityLivingBase par1EntityLivingBase, float par2) { + if (renderEntity != null) { + return NPCRendererHelper.handleRotationFloat(entity, par2, renderEntity); + } return super.handleRotationFloat(par1EntityLivingBase, par2); } -} \ No newline at end of file +} diff --git a/src/main/java/noppes/npcs/client/renderer/RenderNPCHumanMale.java b/src/main/java/noppes/npcs/client/renderer/RenderNPCHumanMale.java index 927d09683..dcd19ce2d 100644 --- a/src/main/java/noppes/npcs/client/renderer/RenderNPCHumanMale.java +++ b/src/main/java/noppes/npcs/client/renderer/RenderNPCHumanMale.java @@ -22,8 +22,7 @@ import org.lwjgl.opengl.GL11; import static net.minecraftforge.client.IItemRenderer.ItemRenderType.EQUIPPED; import static net.minecraftforge.client.IItemRenderer.ItemRendererHelper.BLOCK_3D; -public class RenderNPCHumanMale extends RenderNPCInterface -{ +public class RenderNPCHumanMale extends RenderNPCInterface { private ModelNPCMale modelBipedMain; protected ModelNPCMale modelArmorChestplate; @@ -33,14 +32,13 @@ public class RenderNPCHumanMale extends RenderNPCInterface protected final static ModelMPM steve64 = new ModelMPM(0, false); protected final static ModelMPM alex = new ModelMPM(0, true); - protected final static ModelMPM steveArmorChest = new ModelMPM(1,0); - protected final static ModelMPM steveArmor = new ModelMPM(0.5F,0); + protected final static ModelMPM steveArmorChest = new ModelMPM(1, 0); + protected final static ModelMPM steveArmor = new ModelMPM(0.5F, 0); - protected final static ModelMPM alex32armorChest = new ModelMPM(1,1); - protected final static ModelMPM alex32armor = new ModelMPM(0.5F,1); + protected final static ModelMPM alex32armorChest = new ModelMPM(1, 1); + protected final static ModelMPM alex32armor = new ModelMPM(0.5F, 1); - public RenderNPCHumanMale(ModelNPCMale mainmodel, ModelNPCMale armorChest, ModelNPCMale armor) - { + public RenderNPCHumanMale(ModelNPCMale mainmodel, ModelNPCMale armorChest, ModelNPCMale armor) { super(mainmodel, 0.5F); modelBipedMain = mainmodel; originalBipedMain = mainmodel; @@ -48,17 +46,14 @@ public class RenderNPCHumanMale extends RenderNPCInterface modelArmor = armor; } - protected int func_130006_a(EntityLiving par1EntityLiving, int par2, float par3) - { + protected int func_130006_a(EntityLiving par1EntityLiving, int par2, float par3) { ItemStack itemstack = par1EntityLiving.func_130225_q(3 - par2); - if (itemstack != null) - { + if (itemstack != null) { Item item = itemstack.getItem(); - if (item instanceof ItemArmor) - { - ItemArmor itemarmor = (ItemArmor)item; + if (item instanceof ItemArmor) { + ItemArmor itemarmor = (ItemArmor) item; this.bindTexture(RenderBiped.getArmorResource(par1EntityLiving, itemstack, par2, null)); ModelBiped modelbiped = par2 == 2 ? this.modelArmor : this.modelArmorChestplate; modelbiped.bipedHead.showModel = par2 == 0; @@ -77,15 +72,13 @@ public class RenderNPCHumanMale extends RenderNPCInterface //Move out of if to allow for more then just CLOTH to have color int j = itemarmor.getColor(itemstack); - if (j != -1) - { - float f2 = (float)(j >> 16 & 255) / 255.0F; - float f3 = (float)(j >> 8 & 255) / 255.0F; - float f4 = (float)(j & 255) / 255.0F; + if (j != -1) { + float f2 = (float) (j >> 16 & 255) / 255.0F; + float f3 = (float) (j >> 8 & 255) / 255.0F; + float f4 = (float) (j & 255) / 255.0F; GL11.glColor3f(f1 * f2, f1 * f3, f1 * f4); - if (itemstack.isItemEnchanted()) - { + if (itemstack.isItemEnchanted()) { return 31; } @@ -94,8 +87,7 @@ public class RenderNPCHumanMale extends RenderNPCInterface GL11.glColor3f(f1, f1, f1); - if (itemstack.isItemEnchanted()) - { + if (itemstack.isItemEnchanted()) { return 15; } @@ -105,31 +97,29 @@ public class RenderNPCHumanMale extends RenderNPCInterface return -1; } + @Override - protected int shouldRenderPass(EntityLivingBase par1EntityLivingBase, int par2, float par3){ - return this.func_130006_a((EntityLiving)par1EntityLivingBase, par2, par3); + protected int shouldRenderPass(EntityLivingBase par1EntityLivingBase, int par2, float par3) { + return this.func_130006_a((EntityLiving) par1EntityLivingBase, par2, par3); } - public void renderPlayer(EntityNPCInterface npc, double d, double d1, double d2, - float f, float f1) - { - if(npc instanceof EntityCustomNpc){ + public void renderPlayer(EntityNPCInterface npc, double d, double d1, double d2, + float f, float f1) { + if (npc instanceof EntityCustomNpc) { EntityCustomNpc test = (EntityCustomNpc) npc; - if(test.modelData.entityClass == null){ + if (test.modelData.entityClass == null) { int modelVal = npc.display.modelType; - if(modelVal == 1){ + if (modelVal == 1) { this.mainModel = steve64; this.modelBipedMain = steve64; this.modelArmorChestplate = steveArmorChest; this.modelArmor = steveArmor; - } - else if(modelVal == 2){ + } else if (modelVal == 2) { this.mainModel = alex; this.modelBipedMain = alex; this.modelArmorChestplate = alex32armorChest; this.modelArmor = alex32armor; - } - else{ + } else { ((EntityCustomNpc) npc).modelData.bodywear = 0; ((EntityCustomNpc) npc).modelData.armwear = 0; ((EntityCustomNpc) npc).modelData.legwear = 0; @@ -143,10 +133,10 @@ public class RenderNPCHumanMale extends RenderNPCInterface ItemStack itemstack = npc.getHeldItem(); modelArmorChestplate.heldItemRight = modelArmor.heldItemRight = modelBipedMain.heldItemRight = - itemstack == null ? 0 : npc.hurtResistantTime > 0 ? 3 : 1; + itemstack == null ? 0 : npc.hurtResistantTime > 0 ? 3 : 1; modelArmorChestplate.heldItemLeft = modelArmor.heldItemLeft = modelBipedMain.heldItemLeft = - npc.getOffHand() == null ? 0 : npc.hurtResistantTime > 0 ? 3 : 1; + npc.getOffHand() == null ? 0 : npc.hurtResistantTime > 0 ? 3 : 1; modelArmorChestplate.isSneak = modelArmor.isSneak = modelBipedMain.isSneak = npc.isSneaking(); @@ -156,9 +146,8 @@ public class RenderNPCHumanMale extends RenderNPCInterface modelArmorChestplate.isRiding = modelArmor.isRiding = modelBipedMain.isRiding = npc.isRiding(); - double d3 = d1 - (double)npc.yOffset; - if(npc.isSneaking()) - { + double d3 = d1 - (double) npc.yOffset; + if (npc.isSneaking()) { d3 -= 0.125D; } super.doRender(npc, d, d3, d2, f, f1); @@ -168,35 +157,30 @@ public class RenderNPCHumanMale extends RenderNPCInterface modelArmorChestplate.heldItemLeft = modelArmor.heldItemLeft = modelBipedMain.heldItemLeft = 0; } - protected void renderSpecials(EntityNPCInterface npc, float f) - { + protected void renderSpecials(EntityNPCInterface npc, float f) { super.renderEquippedItems(npc, f); - GL11.glColor3f(1,1,1); + GL11.glColor3f(1, 1, 1); int i = npc.getBrightnessForRender(f); int j = i % 65536; int k = i / 65536; - OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float)j / 1.0F, (float)k / 1.0F); - GL11.glColor3f(1,1,1); + OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float) j / 1.0F, (float) k / 1.0F); + GL11.glColor3f(1, 1, 1); ItemStack itemstack = npc.inventory.armorItemInSlot(0); - if(itemstack != null) - { + if (itemstack != null) { GL11.glPushMatrix(); - if(npc instanceof EntityCustomNpc){ - EntityCustomNpc cnpc = (EntityCustomNpc) npc; - GL11.glTranslatef(0, cnpc.modelData.getBodyY(), 0); - this.modelBipedMain.bipedHead.postRender(0.0625F); - GL11.glScalef(cnpc.modelData.modelScale.head.scaleX, cnpc.modelData.modelScale.head.scaleY, cnpc.modelData.modelScale.head.scaleZ); - } - else - this.modelBipedMain.bipedHead.postRender(0.0625F); + if (npc instanceof EntityCustomNpc) { + EntityCustomNpc cnpc = (EntityCustomNpc) npc; + GL11.glTranslatef(0, cnpc.modelData.getBodyY(), 0); + this.modelBipedMain.bipedHead.postRender(0.0625F); + GL11.glScalef(cnpc.modelData.modelScale.head.scaleX, cnpc.modelData.modelScale.head.scaleY, cnpc.modelData.modelScale.head.scaleZ); + } else + this.modelBipedMain.bipedHead.postRender(0.0625F); IItemRenderer customRenderer = MinecraftForgeClient.getItemRenderer(itemstack, EQUIPPED); boolean is3D = (customRenderer != null && customRenderer.shouldUseRenderHelper(EQUIPPED, itemstack, BLOCK_3D)); - if (itemstack.getItem() instanceof ItemBlock) - { - if (is3D || RenderBlocks.renderItemIn3d(Block.getBlockFromItem(itemstack.getItem()).getRenderType())) - { + if (itemstack.getItem() instanceof ItemBlock) { + if (is3D || RenderBlocks.renderItemIn3d(Block.getBlockFromItem(itemstack.getItem()).getRenderType())) { float var6 = 0.625F; GL11.glTranslatef(0.0F, -0.25F, 0.0F); GL11.glRotatef(90.0F, 0.0F, 1.0F, 0.0F); @@ -208,26 +192,24 @@ public class RenderNPCHumanMale extends RenderNPCInterface GL11.glPopMatrix(); } - GL11.glColor3f(1,1,1); + GL11.glColor3f(1, 1, 1); ItemStack itemstack2 = npc.getHeldItem(); - if(itemstack2 != null) - { + if (itemstack2 != null) { float var6; GL11.glPushMatrix(); float y = 0; float x = 0; - if(npc instanceof EntityCustomNpc){ - EntityCustomNpc cnpc = (EntityCustomNpc) npc; + if (npc instanceof EntityCustomNpc) { + EntityCustomNpc cnpc = (EntityCustomNpc) npc; y = (cnpc.modelData.modelScale.arms.scaleY - 1) * 0.7f; - x = (1 - cnpc.modelData.modelScale.body.scaleX) * 0.28f + (1 - cnpc.modelData.modelScale.arms.scaleX) * 0.175f; + x = (1 - cnpc.modelData.modelScale.body.scaleX) * 0.28f + (1 - cnpc.modelData.modelScale.arms.scaleX) * 0.175f; GL11.glTranslatef(x, cnpc.modelData.getBodyY(), 0); } - this.modelBipedMain.bipedRightArm.postRender(0.0625F); + this.modelBipedMain.bipedRightArm.postRender(0.0625F); - if(npc.getModelType() == 2){ + if (npc.getModelType() == 2) { GL11.glTranslatef(-0.0125F, 0.4375F + y, 0.0625F); - } - else { + } else { GL11.glTranslatef(-0.0625F, 0.4375F + y, 0.0625F); } @@ -236,36 +218,29 @@ public class RenderNPCHumanMale extends RenderNPCInterface Class clazz = itemstack2.getItem().getClass(); boolean pluginMod = itemstack2.getItem().getUnlocalizedName().contains("plug:"); - if (itemstack2.getItem() instanceof ItemBlock && (is3D || RenderBlocks.renderItemIn3d(Block.getBlockFromItem(itemstack2.getItem()).getRenderType()))) - { + if (itemstack2.getItem() instanceof ItemBlock && (is3D || RenderBlocks.renderItemIn3d(Block.getBlockFromItem(itemstack2.getItem()).getRenderType()))) { var6 = 0.5F; GL11.glTranslatef(0.0F, 0.1875F, -0.3125F); var6 *= 0.75F; GL11.glRotatef(20.0F, 1.0F, 0.0F, 0.0F); GL11.glRotatef(45.0F, 0.0F, 1.0F, 0.0F); GL11.glScalef(-var6, -var6, var6); - } - else if (itemstack2.getItem() instanceof ItemBow && (customRenderer == null || pluginMod)) - { + } else if (itemstack2.getItem() instanceof ItemBow && (customRenderer == null || pluginMod)) { var6 = 0.625F; GL11.glTranslatef(0.0F, 0.125F, 0.3125F); GL11.glRotatef(-20.0F, 0.0F, 1.0F, 0.0F); GL11.glScalef(var6, -var6, var6); GL11.glRotatef(-100.0F, 1.0F, 0.0F, 0.0F); GL11.glRotatef(45.0F, 0.0F, 1.0F, 0.0F); - } - else if (itemstack2.getItem().isFull3D() && !is3D) - { + } else if (itemstack2.getItem().isFull3D() && !is3D) { var6 = 0.625F; - if (itemstack2.getItem().shouldRotateAroundWhenRendering()) - { + if (itemstack2.getItem().shouldRotateAroundWhenRendering()) { GL11.glRotatef(180.0F, 0.0F, 0.0F, 1.0F); GL11.glTranslatef(0.0F, -0.125F, 0.0F); } - if (npc.hurtResistantTime > 0 && npc.stats.resistances.playermelee > 1f) - { + if (npc.hurtResistantTime > 0 && npc.stats.resistances.playermelee > 1f) { GL11.glTranslatef(0.05F, 0.0F, -0.1F); GL11.glRotatef(-50.0F, 0.0F, 1.0F, 0.0F); GL11.glRotatef(-10.0F, 1.0F, 0.0F, 0.0F); @@ -276,17 +251,14 @@ public class RenderNPCHumanMale extends RenderNPCInterface GL11.glScalef(var6, -var6, var6); GL11.glRotatef(-100.0F, 1.0F, 0.0F, 0.0F); GL11.glRotatef(45.0F, 0.0F, 1.0F, 0.0F); - } - else if(is3D){ + } else if (is3D) { var6 = 0.5F; GL11.glTranslatef(0.0F, 0.1875F, -0.3125F); var6 *= 0.75F; GL11.glRotatef(20.0F, 1.0F, 0.0F, 0.0F); GL11.glRotatef(45.0F, 0.0F, 1.0F, 0.0F); GL11.glScalef(-var6, -var6, var6); - } - else - { + } else { var6 = 0.375F; GL11.glTranslatef(0.25F, 0.1875F, -0.1875F); GL11.glScalef(var6, var6, var6); @@ -295,85 +267,73 @@ public class RenderNPCHumanMale extends RenderNPCInterface GL11.glRotatef(20.0F, 0.0F, 0.0F, 1.0F); } - if (itemstack2.getItem().requiresMultipleRenderPasses()) - { - for (int var25 = 0; var25 < itemstack2.getItem().getRenderPasses(itemstack2.getItemDamage()); ++var25) - { + if (itemstack2.getItem().requiresMultipleRenderPasses()) { + for (int var25 = 0; var25 < itemstack2.getItem().getRenderPasses(itemstack2.getItemDamage()); ++var25) { int var24 = itemstack2.getItem().getColorFromItemStack(itemstack2, var25); - float var26 = (float)(var24 >> 16 & 255) / 255.0F; - float var9 = (float)(var24 >> 8 & 255) / 255.0F; - float var10 = (float)(var24 & 255) / 255.0F; + float var26 = (float) (var24 >> 16 & 255) / 255.0F; + float var9 = (float) (var24 >> 8 & 255) / 255.0F; + float var10 = (float) (var24 & 255) / 255.0F; GL11.glColor4f(var26, var9, var10, 1.0F); this.renderManager.itemRenderer.renderItem(npc, itemstack2, var25); } - } - else + } else renderManager.itemRenderer.renderItem(npc, itemstack2, 0); GL11.glPopMatrix(); } GL11.glColor4f(1, 1, 1, 1.0F); itemstack2 = npc.getOffHand(); - if(itemstack2 != null) - { + if (itemstack2 != null) { GL11.glPushMatrix(); float y = 0; float x = 0; - if(npc instanceof EntityCustomNpc){ - EntityCustomNpc cnpc = (EntityCustomNpc) npc; + if (npc instanceof EntityCustomNpc) { + EntityCustomNpc cnpc = (EntityCustomNpc) npc; y = (cnpc.modelData.modelScale.arms.scaleY - 1) * 0.7f; - x = (1 - cnpc.modelData.modelScale.body.scaleX) * -0.28f + (1 - cnpc.modelData.modelScale.arms.scaleX) * -0.175f; + x = (1 - cnpc.modelData.modelScale.body.scaleX) * -0.28f + (1 - cnpc.modelData.modelScale.arms.scaleX) * -0.175f; GL11.glTranslatef(x, cnpc.modelData.getBodyY(), 0); } - this.modelBipedMain.bipedLeftArm.postRender(0.0625F); + this.modelBipedMain.bipedLeftArm.postRender(0.0625F); - if(npc.getModelType() == 2){ + if (npc.getModelType() == 2) { GL11.glTranslatef(0.0125F, 0.4375F + y, 0.0625F); - } - else { + } else { GL11.glTranslatef(0.0625F, 0.4375F + y, 0.0625F); } - float var6; - + float var6; + IItemRenderer customRenderer = MinecraftForgeClient.getItemRenderer(itemstack2, EQUIPPED); boolean is3D = (customRenderer != null && customRenderer.shouldUseRenderHelper(EQUIPPED, itemstack2, BLOCK_3D)); Class clazz = itemstack2.getItem().getClass(); boolean pluginMod = itemstack2.getItem().getUnlocalizedName().contains("plug:"); - if(clazz.getSimpleName().equals("ItemShield") || clazz.getSimpleName().equals("ItemRotatedShield") || clazz.getSimpleName().equals("ItemClaw")) - GL11.glTranslatef(0.30f, 0, 0f); - - if (itemstack2.getItem() instanceof ItemBlock && (is3D || RenderBlocks.renderItemIn3d(Block.getBlockFromItem(itemstack2.getItem()).getRenderType()))) - { + if (clazz.getSimpleName().equals("ItemShield") || clazz.getSimpleName().equals("ItemRotatedShield") || clazz.getSimpleName().equals("ItemClaw")) + GL11.glTranslatef(0.30f, 0, 0f); + + if (itemstack2.getItem() instanceof ItemBlock && (is3D || RenderBlocks.renderItemIn3d(Block.getBlockFromItem(itemstack2.getItem()).getRenderType()))) { var6 = 0.5F; GL11.glTranslatef(0.0F, 0.1875F, -0.3125F); var6 *= 0.75F; GL11.glRotatef(20.0F, 1.0F, 0.0F, 0.0F); GL11.glRotatef(45.0F, 0.0F, 1.0F, 0.0F); GL11.glScalef(var6, -var6, var6); - } - else if (itemstack2.getItem() instanceof ItemBow && (customRenderer == null || pluginMod)) - { + } else if (itemstack2.getItem() instanceof ItemBow && (customRenderer == null || pluginMod)) { var6 = 0.625F; GL11.glTranslatef(0.0F, 0.125F, 0.3125F); GL11.glRotatef(-20.0F, 0.0F, 1.0F, 0.0F); GL11.glScalef(var6, -var6, var6); GL11.glRotatef(-100.0F, 1.0F, 0.0F, 0.0F); GL11.glRotatef(45.0F, 0.0F, 1.0F, 0.0F); - } - else if (itemstack2.getItem().isFull3D() && !is3D) - { + } else if (itemstack2.getItem().isFull3D() && !is3D) { var6 = 0.625F; - if (itemstack2.getItem().shouldRotateAroundWhenRendering()) - { + if (itemstack2.getItem().shouldRotateAroundWhenRendering()) { GL11.glRotatef(180.0F, 0.0F, 0.0F, 1.0F); GL11.glTranslatef(0.0F, -0.125F, 0.0F); } - - if (npc.hurtResistantTime > 0 && npc.stats.resistances.arrow > 1f) - { + + if (npc.hurtResistantTime > 0 && npc.stats.resistances.arrow > 1f) { GL11.glTranslatef(0.05F, 0.0F, -0.1F); GL11.glRotatef(50.0F, 0.0F, 1.0F, 0.0F); GL11.glRotatef(-10.0F, 1.0F, 0.0F, 0.0F); @@ -384,9 +344,7 @@ public class RenderNPCHumanMale extends RenderNPCInterface GL11.glScalef(var6, -var6, var6); GL11.glRotatef(-100.0F, 1.0F, 0.0F, 0.0F); GL11.glRotatef(45.0F, 0.0F, 1.0F, 0.0F); - } - else - { + } else { var6 = 0.375F; GL11.glTranslatef(0.25F, 0.1875F, -0.1875F); GL11.glScalef(var6, var6, var6); @@ -395,19 +353,16 @@ public class RenderNPCHumanMale extends RenderNPCInterface GL11.glRotatef(20.0F, 0.0F, 0.0F, 1.0F); } - if (itemstack2.getItem().requiresMultipleRenderPasses()) - { - for (int var25 = 0; var25 < itemstack2.getItem().getRenderPasses(itemstack2.getItemDamage()); ++var25) - { + if (itemstack2.getItem().requiresMultipleRenderPasses()) { + for (int var25 = 0; var25 < itemstack2.getItem().getRenderPasses(itemstack2.getItemDamage()); ++var25) { int var24 = itemstack2.getItem().getColorFromItemStack(itemstack2, var25); - float var26 = (float)(var24 >> 16 & 255) / 255.0F; - float var9 = (float)(var24 >> 8 & 255) / 255.0F; - float var10 = (float)(var24 & 255) / 255.0F; + float var26 = (float) (var24 >> 16 & 255) / 255.0F; + float var9 = (float) (var24 >> 8 & 255) / 255.0F; + float var10 = (float) (var24 & 255) / 255.0F; GL11.glColor4f(var26, var9, var10, 1.0F); this.renderManager.itemRenderer.renderItem(npc, itemstack2, var25); } - }else - { + } else { renderManager.itemRenderer.renderItem(npc, itemstack2, 0); } GL11.glPopMatrix(); @@ -415,18 +370,18 @@ public class RenderNPCHumanMale extends RenderNPCInterface } @Override - protected void renderEquippedItems(EntityLivingBase entityliving, float f){ - renderSpecials((EntityNPCInterface)entityliving, f); + protected void renderEquippedItems(EntityLivingBase entityliving, float f) { + renderSpecials((EntityNPCInterface) entityliving, f); } @Override - public void doRender(EntityLiving entityliving, double d, double d1, double d2, float f, float f1){ - renderPlayer((EntityNPCInterface)entityliving, d, d1, d2, f, f1); + public void doRender(EntityLiving entityliving, double d, double d1, double d2, float f, float f1) { + renderPlayer((EntityNPCInterface) entityliving, d, d1, d2, f, f1); } @Override - public void doRender(Entity entity, double d, double d1, double d2, float f, float f1){ - renderPlayer((EntityNPCInterface)entity, d, d1, d2, f, f1); + public void doRender(Entity entity, double d, double d1, double d2, float f, float f1) { + renderPlayer((EntityNPCInterface) entity, d, d1, d2, f, f1); } } diff --git a/src/main/java/noppes/npcs/client/renderer/RenderNPCInterface.java b/src/main/java/noppes/npcs/client/renderer/RenderNPCInterface.java index 19e9ce232..2d1d1f258 100644 --- a/src/main/java/noppes/npcs/client/renderer/RenderNPCInterface.java +++ b/src/main/java/noppes/npcs/client/renderer/RenderNPCInterface.java @@ -43,240 +43,228 @@ import java.security.MessageDigest; import java.util.Map; -public class RenderNPCInterface extends RenderLiving{ - public static long LastTextureTick = 0; - public static RenderManager staticRenderManager; - public ModelBase originalModel; +public class RenderNPCInterface extends RenderLiving { + public static long LastTextureTick = 0; + public static RenderManager staticRenderManager; + public ModelBase originalModel; - public static ResourceLocation steve64 = new ResourceLocation("customnpcs","textures/entity/64-Textures/humanmale/Steve.png"); - public static ResourceLocation alex = new ResourceLocation("customnpcs","textures/entity/64-Textures/humanfemale/Alex.png"); + public static ResourceLocation steve64 = new ResourceLocation("customnpcs", "textures/entity/64-Textures/humanmale/Steve.png"); + public static ResourceLocation alex = new ResourceLocation("customnpcs", "textures/entity/64-Textures/humanfemale/Alex.png"); - public RenderNPCInterface(ModelBase model, float f){ - super(model, f); - this.originalModel = model; - } + public RenderNPCInterface(ModelBase model, float f) { + super(model, f); + this.originalModel = model; + } - protected void renderName(EntityNPCInterface npc, double d, double d1, double d2) { - if (!this.func_110813_b(npc)) - return; - float f2 = npc.getDistanceToEntity(renderManager.livingPlayer); - float f3 = npc.isSneaking() ? 32F : 64F; + protected void renderName(EntityNPCInterface npc, double d, double d1, double d2) { + if (!this.func_110813_b(npc)) + return; + float f2 = npc.getDistanceToEntity(renderManager.livingPlayer); + float f3 = npc.isSneaking() ? 32F : 64F; - if (f2 > f3) - return; - if (npc.messages != null){ - float height = ((npc.baseHeight / 5f) * npc.display.modelSize); - float offset = npc.height * (1.2f + (!npc.display.showName()?0:npc.display.title.isEmpty()?0.15f:0.25f)); + if (f2 > f3) + return; + if (npc.messages != null) { + float height = ((npc.baseHeight / 5f) * npc.display.modelSize); + float offset = npc.height * (1.2f + (!npc.display.showName() ? 0 : npc.display.title.isEmpty() ? 0.15f : 0.25f)); - npc.messages.renderMessages(d, d1 + offset, d2, 0.666667F * height, npc.isInRange(renderManager.livingPlayer, 4)); - } - float scale = (npc.baseHeight / 5f) * npc.display.modelSize; - int height = 0; - if (npc.display.showName()) { - String s = npc.getCommandSenderName(); - if(!npc.display.title.isEmpty()){ - renderLivingLabel(npc, d, d1 + npc.height - 0.06f * scale, d2, 64, "<" + npc.display.title + ">", 0.6f, s, 1f); - height = 2; - } - else{ - renderLivingLabel(npc, d, d1 + npc.height - 0.06f * scale, d2, 64, s, 1f); - height = 1; - } - } - } + npc.messages.renderMessages(d, d1 + offset, d2, 0.666667F * height, npc.isInRange(renderManager.livingPlayer, 4)); + } + float scale = (npc.baseHeight / 5f) * npc.display.modelSize; + int height = 0; + if (npc.display.showName()) { + String s = npc.getCommandSenderName(); + if (!npc.display.title.isEmpty()) { + renderLivingLabel(npc, d, d1 + npc.height - 0.06f * scale, d2, 64, "<" + npc.display.title + ">", 0.6f, s, 1f); + height = 2; + } else { + renderLivingLabel(npc, d, d1 + npc.height - 0.06f * scale, d2, 64, s, 1f); + height = 1; + } + } + } - public void doRenderShadowAndFire(Entity par1Entity, double par2, double par4, double par6, float par8, float par9){ - EntityNPCInterface npc = (EntityNPCInterface) par1Entity; - if(!npc.isKilled() && !npc.scriptInvisibleToPlayer(Minecraft.getMinecraft().thePlayer)) - super.doRenderShadowAndFire(par1Entity, par2, par4, par6, par8, par9); - } + public void doRenderShadowAndFire(Entity par1Entity, double par2, double par4, double par6, float par8, float par9) { + EntityNPCInterface npc = (EntityNPCInterface) par1Entity; + if (!npc.isKilled() && !npc.scriptInvisibleToPlayer(Minecraft.getMinecraft().thePlayer)) + super.doRenderShadowAndFire(par1Entity, par2, par4, par6, par8, par9); + } - protected void renderLivingLabel(EntityNPCInterface npc, double d, double d1, double d2, int i, Object... obs){ - FontRenderer fontrenderer = getFontRendererFromRenderManager(); + protected void renderLivingLabel(EntityNPCInterface npc, double d, double d1, double d2, int i, Object... obs) { + FontRenderer fontrenderer = getFontRendererFromRenderManager(); - i = npc.getBrightnessForRender(0); - int j = i % 65536; - int k = i / 65536; - OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float)j / 1.0F, (float)k / 1.0F); + i = npc.getBrightnessForRender(0); + int j = i % 65536; + int k = i / 65536; + OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float) j / 1.0F, (float) k / 1.0F); - float f1 = (npc.baseHeight / 5f) * npc.display.modelSize; - float f2 = 0.01666667F * f1; - GL11.glPushMatrix(); - GL11.glTranslatef((float)d + 0.0F, (float)d1, (float)d2); - GL11.glNormal3f(0.0F, 1.0F, 0.0F); - GL11.glRotatef(-renderManager.playerViewY, 0.0F, 1.0F, 0.0F); - GL11.glRotatef(renderManager.playerViewX, 1.0F, 0.0F, 0.0F); - Tessellator tessellator = Tessellator.instance; - float height = f1 / 6.5f; - for(j = 0; j < obs.length; j += 2){ - float scale = (Float) obs[j + 1]; - height += f1 / 6.5f * scale; - GL11.glPushMatrix(); - GL11.glDisable(GL11.GL_LIGHTING); - GL11.glDepthMask(false); - GL11.glDisable(GL11.GL_ALPHA_TEST); - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - GL11.glDisable(GL11.GL_TEXTURE_2D); - String s = obs[j].toString(); - GL11.glTranslatef(0, height, 0); - GL11.glScalef(-f2 * scale, -f2 * scale, f2 * scale); - tessellator.startDrawingQuads(); - int size = fontrenderer.getStringWidth(s) / 2; - tessellator.setColorRGBA_F(0.0F, 0.0F, 0.0F, 0.25F); - tessellator.addVertex(-size - 1, -1, 0.0D); - tessellator.addVertex(-size - 1, 8 , 0.0D); - tessellator.addVertex(size + 1, 8 , 0.0D); - tessellator.addVertex(size + 1, -1 , 0.0D); - tessellator.draw(); - GL11.glEnable(GL11.GL_TEXTURE_2D); - GL11.glEnable(GL11.GL_DEPTH_TEST); - GL11.glDepthMask(true); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + float f1 = (npc.baseHeight / 5f) * npc.display.modelSize; + float f2 = 0.01666667F * f1; + GL11.glPushMatrix(); + GL11.glTranslatef((float) d + 0.0F, (float) d1, (float) d2); + GL11.glNormal3f(0.0F, 1.0F, 0.0F); + GL11.glRotatef(-renderManager.playerViewY, 0.0F, 1.0F, 0.0F); + GL11.glRotatef(renderManager.playerViewX, 1.0F, 0.0F, 0.0F); + Tessellator tessellator = Tessellator.instance; + float height = f1 / 6.5f; + for (j = 0; j < obs.length; j += 2) { + float scale = (Float) obs[j + 1]; + height += f1 / 6.5f * scale; + GL11.glPushMatrix(); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glDepthMask(false); + GL11.glDisable(GL11.GL_ALPHA_TEST); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glDisable(GL11.GL_TEXTURE_2D); + String s = obs[j].toString(); + GL11.glTranslatef(0, height, 0); + GL11.glScalef(-f2 * scale, -f2 * scale, f2 * scale); + tessellator.startDrawingQuads(); + int size = fontrenderer.getStringWidth(s) / 2; + tessellator.setColorRGBA_F(0.0F, 0.0F, 0.0F, 0.25F); + tessellator.addVertex(-size - 1, -1, 0.0D); + tessellator.addVertex(-size - 1, 8, 0.0D); + tessellator.addVertex(size + 1, 8, 0.0D); + tessellator.addVertex(size + 1, -1, 0.0D); + tessellator.draw(); + GL11.glEnable(GL11.GL_TEXTURE_2D); + GL11.glEnable(GL11.GL_DEPTH_TEST); + GL11.glDepthMask(true); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - int color = npc.faction.color; - fontrenderer.drawString(s, -fontrenderer.getStringWidth(s) / 2, 0, color); - GL11.glPopMatrix(); - } - GL11.glEnable(GL11.GL_ALPHA_TEST); - GL11.glEnable(GL11.GL_LIGHTING /*GL_LIGHTING*/); - GL11.glDisable(GL11.GL_BLEND /*GL_BLEND*/); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - GL11.glPopMatrix(); - } + int color = npc.faction.color; + fontrenderer.drawString(s, -fontrenderer.getStringWidth(s) / 2, 0, color); + GL11.glPopMatrix(); + } + GL11.glEnable(GL11.GL_ALPHA_TEST); + GL11.glEnable(GL11.GL_LIGHTING /*GL_LIGHTING*/); + GL11.glDisable(GL11.GL_BLEND /*GL_BLEND*/); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GL11.glPopMatrix(); + } - protected void renderPlayerScale(EntityNPCInterface npc, float f){ - GL11.glScalef((npc.scaleX / 5) * npc.display.modelSize, (npc.scaleY / 5) * npc.display.modelSize, (npc.scaleZ / 5) * npc.display.modelSize); - } + protected void renderPlayerScale(EntityNPCInterface npc, float f) { + GL11.glScalef((npc.scaleX / 5) * npc.display.modelSize, (npc.scaleY / 5) * npc.display.modelSize, (npc.scaleZ / 5) * npc.display.modelSize); + } - protected void renderPlayerSleep(EntityNPCInterface npc, double d, double d1, double d2){ - shadowSize = npc.display.modelSize / 10f; + protected void renderPlayerSleep(EntityNPCInterface npc, double d, double d1, double d2) { + shadowSize = npc.display.modelSize / 10f; - float xOffset = 0; - float yOffset = npc.currentAnimation == EnumAnimation.NONE?npc.ais.bodyOffsetY / 10 - 0.5f:0; - float zOffset = 0; + float xOffset = 0; + float yOffset = npc.currentAnimation == EnumAnimation.NONE ? npc.ais.bodyOffsetY / 10 - 0.5f : 0; + float zOffset = 0; - if(npc.isEntityAlive()){ - if(npc.isPlayerSleeping()){ - xOffset = (float) -Math.cos(Math.toRadians(180 - npc.ais.orientation)); - zOffset = (float) -Math.sin(Math.toRadians(npc.ais.orientation)); - yOffset += 0.14f; - } - else if(npc.isRiding()){ - yOffset -= 0.5f - ((EntityCustomNpc)npc).modelData.getLegsY() * 0.8f; - } - } - renderLiving(npc, d, d1, d2, xOffset, yOffset, zOffset); - } - private void renderLiving(EntityNPCInterface npc, double d, double d1, double d2,float xoffset,float yoffset,float zoffset){ - xoffset = (xoffset/ 5f) * npc.display.modelSize; - yoffset = (yoffset/ 5f) * npc.display.modelSize; - zoffset = (zoffset/ 5f) * npc.display.modelSize; - super.renderLivingAt(npc, d+xoffset, d1+yoffset, d2 + zoffset); - } + if (npc.isEntityAlive()) { + if (npc.isPlayerSleeping()) { + xOffset = (float) -Math.cos(Math.toRadians(180 - npc.ais.orientation)); + zOffset = (float) -Math.sin(Math.toRadians(npc.ais.orientation)); + yOffset += 0.14f; + } else if (npc.isRiding()) { + yOffset -= 0.5f - ((EntityCustomNpc) npc).modelData.getLegsY() * 0.8f; + } + } + renderLiving(npc, d, d1, d2, xOffset, yOffset, zOffset); + } - @Override - protected void rotateCorpse(EntityLivingBase entity, float f, float f1, float f2){ - EntityNPCInterface npc = (EntityNPCInterface) entity; - if(npc.isEntityAlive() && npc.isPlayerSleeping()) - { - GL11.glRotatef(npc.ais.orientation, 0.0F, 1.0F, 0.0F); - GL11.glRotatef(getDeathMaxRotation(npc), 0.0F, 0.0F, 1.0F); - GL11.glRotatef(270F, 0.0F, 1.0F, 0.0F); - } - else if(npc.isEntityAlive() && npc.currentAnimation == EnumAnimation.CRAWLING){ - GL11.glRotatef(270.0F - f1, 0.0F, 1.0F, 0.0F); - float scale = ((EntityCustomNpc)npc).display.modelSize / 5f; - GL11.glTranslated(-scale +((EntityCustomNpc)npc).modelData.getLegsY() * scale, 0.14f, 0); - GL11.glRotatef(270F, 0.0F, 0.0F, 1.0F); - GL11.glRotatef(270F, 0.0F, 1.0F, 0.0F); - } - else { - super.rotateCorpse(npc, f, f1, f2); - } - } + private void renderLiving(EntityNPCInterface npc, double d, double d1, double d2, float xoffset, float yoffset, float zoffset) { + xoffset = (xoffset / 5f) * npc.display.modelSize; + yoffset = (yoffset / 5f) * npc.display.modelSize; + zoffset = (zoffset / 5f) * npc.display.modelSize; + super.renderLivingAt(npc, d + xoffset, d1 + yoffset, d2 + zoffset); + } - @Override - public void passSpecialRender(EntityLivingBase par1EntityLivingBase, double par2, double par4, double par6){ - renderName((EntityNPCInterface)par1EntityLivingBase, par2, par4, par6); - } + @Override + protected void rotateCorpse(EntityLivingBase entity, float f, float f1, float f2) { + EntityNPCInterface npc = (EntityNPCInterface) entity; + if (npc.isEntityAlive() && npc.isPlayerSleeping()) { + GL11.glRotatef(npc.ais.orientation, 0.0F, 1.0F, 0.0F); + GL11.glRotatef(getDeathMaxRotation(npc), 0.0F, 0.0F, 1.0F); + GL11.glRotatef(270F, 0.0F, 1.0F, 0.0F); + } else if (npc.isEntityAlive() && npc.currentAnimation == EnumAnimation.CRAWLING) { + GL11.glRotatef(270.0F - f1, 0.0F, 1.0F, 0.0F); + float scale = ((EntityCustomNpc) npc).display.modelSize / 5f; + GL11.glTranslated(-scale + ((EntityCustomNpc) npc).modelData.getLegsY() * scale, 0.14f, 0); + GL11.glRotatef(270F, 0.0F, 0.0F, 1.0F); + GL11.glRotatef(270F, 0.0F, 1.0F, 0.0F); + } else { + super.rotateCorpse(npc, f, f1, f2); + } + } - @Override - protected void preRenderCallback(EntityLivingBase entityliving, float f){ - renderPlayerScale((EntityNPCInterface)entityliving, f); - } + @Override + public void passSpecialRender(EntityLivingBase par1EntityLivingBase, double par2, double par4, double par6) { + renderName((EntityNPCInterface) par1EntityLivingBase, par2, par4, par6); + } - @Override - public void doRender(EntityLiving entityliving, double d, double d1, double d2, float f, float f1){ - EntityNPCInterface npc = (EntityNPCInterface) entityliving; + @Override + protected void preRenderCallback(EntityLivingBase entityliving, float f) { + renderPlayerScale((EntityNPCInterface) entityliving, f); + } - if(npc.isKilled() && npc.stats.hideKilledBody && npc.deathTime > 20){ - return; - } - if((npc.display.showBossBar == 1 || npc.display.showBossBar == 2 && npc.isAttacking()) && !npc.isKilled() && npc.deathTime <= 20 && npc.canSee(Minecraft.getMinecraft().thePlayer)) - BossStatus.setBossStatus(npc, true); + @Override + public void doRender(EntityLiving entityliving, double d, double d1, double d2, float f, float f1) { + EntityNPCInterface npc = (EntityNPCInterface) entityliving; - if(npc.ais.standingType == EnumStandingType.HeadRotation && !npc.isWalking() && !npc.isInteracting()){ - npc.prevRenderYawOffset = npc.renderYawOffset = npc.ais.orientation; - } + if (npc.isKilled() && npc.stats.hideKilledBody && npc.deathTime > 20) { + return; + } + if ((npc.display.showBossBar == 1 || npc.display.showBossBar == 2 && npc.isAttacking()) && !npc.isKilled() && npc.deathTime <= 20 && npc.canSee(Minecraft.getMinecraft().thePlayer)) + BossStatus.setBossStatus(npc, true); - staticRenderManager = this.renderManager; + if (npc.ais.standingType == EnumStandingType.HeadRotation && !npc.isWalking() && !npc.isInteracting()) { + npc.prevRenderYawOffset = npc.renderYawOffset = npc.ais.orientation; + } - doRenderLiving(npc, d, d1, d2, f, f1); - } + staticRenderManager = this.renderManager; - public void doRenderLiving(EntityNPCInterface p_76986_1_, double p_76986_2_, double p_76986_4_, double p_76986_6_, float p_76986_8_, float p_76986_9_) - { - if (MinecraftForge.EVENT_BUS.post(new RenderLivingEvent.Pre(p_76986_1_, this, p_76986_2_, p_76986_4_, p_76986_6_))) return; + doRenderLiving(npc, d, d1, d2, f, f1); + } + + public void doRenderLiving(EntityNPCInterface p_76986_1_, double p_76986_2_, double p_76986_4_, double p_76986_6_, float p_76986_8_, float p_76986_9_) { + if (MinecraftForge.EVENT_BUS.post(new RenderLivingEvent.Pre(p_76986_1_, this, p_76986_2_, p_76986_4_, p_76986_6_))) + return; GL11.glPushMatrix(); GL11.glDisable(GL11.GL_CULL_FACE); this.mainModel.onGround = this.renderSwingProgress(p_76986_1_, p_76986_9_); - if (this.renderPassModel != null) - { + if (this.renderPassModel != null) { this.renderPassModel.onGround = this.mainModel.onGround; } this.mainModel.isRiding = p_76986_1_.isRiding(); - if (this.renderPassModel != null) - { + if (this.renderPassModel != null) { this.renderPassModel.isRiding = this.mainModel.isRiding; } this.mainModel.isChild = p_76986_1_.isChild(); - if (this.renderPassModel != null) - { + if (this.renderPassModel != null) { this.renderPassModel.isChild = this.mainModel.isChild; } - try - { + try { float f2 = this.interpolateRotation(p_76986_1_.prevRenderYawOffset, p_76986_1_.renderYawOffset, p_76986_9_); float f3 = this.interpolateRotation(p_76986_1_.prevRotationYawHead, p_76986_1_.rotationYawHead, p_76986_9_); float f4; - if (p_76986_1_.isRiding() && p_76986_1_.ridingEntity instanceof EntityLivingBase) - { - EntityLivingBase entitylivingbase1 = (EntityLivingBase)p_76986_1_.ridingEntity; + if (p_76986_1_.isRiding() && p_76986_1_.ridingEntity instanceof EntityLivingBase) { + EntityLivingBase entitylivingbase1 = (EntityLivingBase) p_76986_1_.ridingEntity; f2 = this.interpolateRotation(entitylivingbase1.prevRenderYawOffset, entitylivingbase1.renderYawOffset, p_76986_9_); f4 = MathHelper.wrapAngleTo180_float(f3 - f2); - if (f4 < -85.0F) - { + if (f4 < -85.0F) { f4 = -85.0F; } - if (f4 >= 85.0F) - { + if (f4 >= 85.0F) { f4 = 85.0F; } f2 = f3 - f4; - if (f4 * f4 > 2500.0F) - { + if (f4 * f4 > 2500.0F) { f2 += f4 * 0.2F; } } @@ -293,13 +281,11 @@ public class RenderNPCInterface extends RenderLiving{ float f6 = p_76986_1_.prevLimbSwingAmount + (p_76986_1_.limbSwingAmount - p_76986_1_.prevLimbSwingAmount) * p_76986_9_; float f7 = p_76986_1_.limbSwing - p_76986_1_.limbSwingAmount * (1.0F - p_76986_9_); - if (p_76986_1_.isChild()) - { + if (p_76986_1_.isChild()) { f7 *= 3.0F; } - if (f6 > 1.0F) - { + if (f6 > 1.0F) { f6 = 1.0F; } @@ -311,24 +297,20 @@ public class RenderNPCInterface extends RenderLiving{ float f9; float f10; - for (int i = 0; i < 4; ++i) - { + for (int i = 0; i < 4; ++i) { j = this.shouldRenderPass(p_76986_1_, i, p_76986_9_); - if (j > 0) - { + if (j > 0) { this.renderPassModel.setLivingAnimations(p_76986_1_, f7, f6, p_76986_9_); this.renderPassModel.render(p_76986_1_, f7, f6, f4, f3 - f2, f13, f5); - if ((j & 240) == 16) - { + if ((j & 240) == 16) { this.func_82408_c(p_76986_1_, i, p_76986_9_); this.renderPassModel.render(p_76986_1_, f7, f6, f4, f3 - f2, f13, f5); } - if ((j & 15) == 15) - { - f8 = (float)p_76986_1_.ticksExisted + p_76986_9_; + if ((j & 15) == 15) { + f8 = (float) p_76986_1_.ticksExisted + p_76986_9_; this.bindTexture(new ResourceLocation("textures/misc/enchanted_item_glint.png")); GL11.glEnable(GL11.GL_BLEND); f9 = 0.5F; @@ -336,18 +318,17 @@ public class RenderNPCInterface extends RenderLiving{ GL11.glDepthFunc(GL11.GL_EQUAL); GL11.glDepthMask(false); - for (int k = 0; k < 2; ++k) - { + for (int k = 0; k < 2; ++k) { GL11.glDisable(GL11.GL_LIGHTING); f10 = 0.76F; GL11.glColor4f(0.5F * f10, 0.25F * f10, 0.8F * f10, 1.0F); GL11.glBlendFunc(GL11.GL_SRC_COLOR, GL11.GL_ONE); GL11.glMatrixMode(GL11.GL_TEXTURE); GL11.glLoadIdentity(); - float f11 = f8 * (0.001F + (float)k * 0.003F) * 20.0F; + float f11 = f8 * (0.001F + (float) k * 0.003F) * 20.0F; float f12 = 0.33333334F; GL11.glScalef(f12, f12, f12); - GL11.glRotatef(30.0F - (float)k * 60.0F, 0.0F, 0.0F, 1.0F); + GL11.glRotatef(30.0F - (float) k * 60.0F, 0.0F, 0.0F, 1.0F); GL11.glTranslatef(0.0F, f11, 0.0F); GL11.glMatrixMode(GL11.GL_MODELVIEW); this.renderPassModel.render(p_76986_1_, f7, f6, f4, f3 - f2, f13, f5); @@ -376,52 +357,45 @@ public class RenderNPCInterface extends RenderLiving{ GL11.glDisable(GL11.GL_TEXTURE_2D); OpenGlHelper.setActiveTexture(OpenGlHelper.defaultTexUnit); TintData tintData = p_76986_1_.display.tintData; - if ((j >> 24 & 255) > 0 || p_76986_1_.hurtTime > 0 || p_76986_1_.deathTime > 0 || (tintData.isTintEnabled() && tintData.isGeneralTintEnabled())) - { + if ((j >> 24 & 255) > 0 || p_76986_1_.hurtTime > 0 || p_76986_1_.deathTime > 0 || (tintData.isTintEnabled() && tintData.isGeneralTintEnabled())) { GL11.glDisable(GL11.GL_TEXTURE_2D); GL11.glDisable(GL11.GL_ALPHA_TEST); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glDepthFunc(GL11.GL_EQUAL); - if ((p_76986_1_.hurtTime > 0 || p_76986_1_.deathTime > 0) && (!tintData.isTintEnabled() || tintData.isHurtTintEnabled())) - { + if ((p_76986_1_.hurtTime > 0 || p_76986_1_.deathTime > 0) && (!tintData.isTintEnabled() || tintData.isHurtTintEnabled())) { float r, g, b; - if(tintData.isTintEnabled()) { + if (tintData.isTintEnabled()) { r = (float) (tintData.getHurtTint() >> 16 & 255) / 255.0F * f14; g = (float) (tintData.getHurtTint() >> 8 & 255) / 255.0F * f14; b = (float) (tintData.getHurtTint() & 255) / 255.0F * f14; - }else{ - r=f14; - g=0; - b=0; + } else { + r = f14; + g = 0; + b = 0; } - GL11.glColor4f(r,g,b, 0.4F); + GL11.glColor4f(r, g, b, 0.4F); this.mainModel.render(p_76986_1_, f7, f6, f4, f3 - f2, f13, f5); - for (int l = 0; l < 4; ++l) - { - if (this.inheritRenderPass(p_76986_1_, l, p_76986_9_) >= 0) - { - GL11.glColor4f(r,g,b, 0.4F); + for (int l = 0; l < 4; ++l) { + if (this.inheritRenderPass(p_76986_1_, l, p_76986_9_) >= 0) { + GL11.glColor4f(r, g, b, 0.4F); this.renderPassModel.render(p_76986_1_, f7, f6, f4, f3 - f2, f13, f5); } } } - if ((j >> 24 & 255) > 0) - { - f8 = (float)(j >> 16 & 255) / 255.0F; - f9 = (float)(j >> 8 & 255) / 255.0F; - float f15 = (float)(j & 255) / 255.0F; - f10 = (float)(j >> 24 & 255) / 255.0F; + if ((j >> 24 & 255) > 0) { + f8 = (float) (j >> 16 & 255) / 255.0F; + f9 = (float) (j >> 8 & 255) / 255.0F; + float f15 = (float) (j & 255) / 255.0F; + f10 = (float) (j >> 24 & 255) / 255.0F; GL11.glColor4f(f8, f9, f15, f10); this.mainModel.render(p_76986_1_, f7, f6, f4, f3 - f2, f13, f5); - for (int i1 = 0; i1 < 4; ++i1) - { - if (this.inheritRenderPass(p_76986_1_, i1, p_76986_9_) >= 0) - { + for (int i1 = 0; i1 < 4; ++i1) { + if (this.inheritRenderPass(p_76986_1_, i1, p_76986_9_) >= 0) { GL11.glColor4f(f8, f9, f15, f10); this.renderPassModel.render(p_76986_1_, f7, f6, f4, f3 - f2, f13, f5); } @@ -435,9 +409,7 @@ public class RenderNPCInterface extends RenderLiving{ } GL11.glDisable(GL12.GL_RESCALE_NORMAL); - } - catch (Exception exception) - { + } catch (Exception exception) { } @@ -451,226 +423,226 @@ public class RenderNPCInterface extends RenderLiving{ this.func_110827_b(p_76986_1_, p_76986_2_, p_76986_4_, p_76986_6_, p_76986_8_, p_76986_9_); } - private float interpolateRotation(float p_77034_1_, float p_77034_2_, float p_77034_3_) - { + private float interpolateRotation(float p_77034_1_, float p_77034_2_, float p_77034_3_) { float f3; - for (f3 = p_77034_2_ - p_77034_1_; f3 < -180.0F; f3 += 360.0F) - { + for (f3 = p_77034_2_ - p_77034_1_; f3 < -180.0F; f3 += 360.0F) { ; } - while (f3 >= 180.0F) - { + while (f3 >= 180.0F) { f3 -= 360.0F; } return p_77034_1_ + p_77034_3_ * f3; } - protected int getColorMultiplier(EntityLivingBase p_77030_1_, float p_77030_2_, float p_77030_3_) - { + protected int getColorMultiplier(EntityLivingBase p_77030_1_, float p_77030_2_, float p_77030_3_) { EntityNPCInterface npc = (EntityNPCInterface) p_77030_1_; TintData tintData = npc.display.tintData; - int alpha = (int) (0xff*((double)tintData.getGeneralAlpha()/100d)) << 24; - return (tintData.isTintEnabled() && tintData.isGeneralTintEnabled())?tintData.getGeneralTint()+alpha:0; + int alpha = (int) (0xff * ((double) tintData.getGeneralAlpha() / 100d)) << 24; + return (tintData.isTintEnabled() && tintData.isGeneralTintEnabled()) ? tintData.getGeneralTint() + alpha : 0; } - protected void renderModel(EntityLivingBase entityliving, float par2, float par3, float par4, float par5, float par6, float par7) { - EntityNPCInterface npc = (EntityNPCInterface) entityliving; - if(GeckoAddonClient.Instance.isGeckoModel(mainModel)){ - GeckoAddonClient.Instance.geckoRenderModel((ModelMPM) mainModel, npc, npc.rotationYaw, Minecraft.getMinecraft().timer.renderPartialTicks); - } else if (this.getEntityTexture(entityliving) != null) { - super.renderModel(entityliving, par2, par3, par4, par5, par6, par7); - } + protected void renderModel(EntityLivingBase entityliving, float par2, float par3, float par4, float par5, float par6, float par7) { + EntityNPCInterface npc = (EntityNPCInterface) entityliving; + if (GeckoAddonClient.Instance.isGeckoModel(mainModel)) { + GeckoAddonClient.Instance.geckoRenderModel((ModelMPM) mainModel, npc, npc.rotationYaw, Minecraft.getMinecraft().timer.renderPartialTicks); + } else if (this.getEntityTexture(entityliving) != null) { + super.renderModel(entityliving, par2, par3, par4, par5, par6, par7); + } - if (!npc.display.skinOverlayData.overlayList.isEmpty()) { - for (ISkinOverlay overlayData : npc.display.skinOverlayData.overlayList.values()) { - try { - if (((SkinOverlay)overlayData).texture.isEmpty()) - continue; + if (!npc.display.skinOverlayData.overlayList.isEmpty()) { + for (ISkinOverlay overlayData : npc.display.skinOverlayData.overlayList.values()) { + try { + if (((SkinOverlay) overlayData).texture.isEmpty()) + continue; - ImageData imageData = ClientCacheHandler.getImageData(((SkinOverlay)overlayData).texture); - if (!imageData.imageLoaded()) - continue; + ImageData imageData = ClientCacheHandler.getImageData(((SkinOverlay) overlayData).texture); + if (!imageData.imageLoaded()) + continue; - try { - imageData.bindTexture(); - } catch (Exception e) { continue; } + try { + imageData.bindTexture(); + } catch (Exception e) { + continue; + } - // Overlay & Glow - GL11.glEnable(GL11.GL_BLEND); - if (overlayData.getBlend()) { - GL11.glBlendFunc(GL11.GL_ONE, GL11.GL_ONE); - } else { - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - } - GL11.glAlphaFunc(GL11.GL_GREATER, 0.003921569F); + // Overlay & Glow + GL11.glEnable(GL11.GL_BLEND); + if (overlayData.getBlend()) { + GL11.glBlendFunc(GL11.GL_ONE, GL11.GL_ONE); + } else { + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + } + GL11.glAlphaFunc(GL11.GL_GREATER, 0.003921569F); - if (overlayData.getGlow()) { - GL11.glDisable(GL11.GL_LIGHTING); - Minecraft.getMinecraft().entityRenderer.disableLightmap((double) 0); - } + if (overlayData.getGlow()) { + GL11.glDisable(GL11.GL_LIGHTING); + Minecraft.getMinecraft().entityRenderer.disableLightmap((double) 0); + } - GL11.glColor4f(1.0F, 1.0F, 1.0F, overlayData.getAlpha()); + GL11.glColor4f(1.0F, 1.0F, 1.0F, overlayData.getAlpha()); - GL11.glDepthMask(!npc.isInvisible()); + GL11.glDepthMask(!npc.isInvisible()); - GL11.glPushMatrix(); - GL11.glMatrixMode(GL11.GL_TEXTURE); - GL11.glLoadIdentity(); - GL11.glTranslatef(npc.display.overlayRenderTicks * 0.001F * overlayData.getSpeedX(), npc.display.overlayRenderTicks * 0.001F * overlayData.getSpeedY(), 0.0F); - GL11.glScalef(overlayData.getTextureScaleX(), overlayData.getTextureScaleY(), 1.0F); + GL11.glPushMatrix(); + GL11.glMatrixMode(GL11.GL_TEXTURE); + GL11.glLoadIdentity(); + GL11.glTranslatef(npc.display.overlayRenderTicks * 0.001F * overlayData.getSpeedX(), npc.display.overlayRenderTicks * 0.001F * overlayData.getSpeedY(), 0.0F); + GL11.glScalef(overlayData.getTextureScaleX(), overlayData.getTextureScaleY(), 1.0F); - GL11.glMatrixMode(GL11.GL_MODELVIEW); - float scale = 1.005f * overlayData.getSize(); - GL11.glTranslatef(overlayData.getOffsetX(), overlayData.getOffsetY(), overlayData.getOffsetZ()); - GL11.glScalef(scale, scale, scale); - if(mainModel instanceof ModelMPM){ - ((ModelMPM)mainModel).isArmor = true; - mainModel.render(entityliving, par2, par3, par4, par5, par6, par7); - ((ModelMPM)mainModel).isArmor = false; - } - else - mainModel.render(entityliving, par2, par3, par4, par5, par6, par7); - GL11.glPopMatrix(); + GL11.glMatrixMode(GL11.GL_MODELVIEW); + float scale = 1.005f * overlayData.getSize(); + GL11.glTranslatef(overlayData.getOffsetX(), overlayData.getOffsetY(), overlayData.getOffsetZ()); + GL11.glScalef(scale, scale, scale); + if (mainModel instanceof ModelMPM) { + ((ModelMPM) mainModel).isArmor = true; + mainModel.render(entityliving, par2, par3, par4, par5, par6, par7); + ((ModelMPM) mainModel).isArmor = false; + } else + mainModel.render(entityliving, par2, par3, par4, par5, par6, par7); + GL11.glPopMatrix(); - GL11.glMatrixMode(GL11.GL_TEXTURE); - GL11.glLoadIdentity(); - GL11.glMatrixMode(GL11.GL_MODELVIEW); + GL11.glMatrixMode(GL11.GL_TEXTURE); + GL11.glLoadIdentity(); + GL11.glMatrixMode(GL11.GL_MODELVIEW); - GL11.glEnable(GL11.GL_LIGHTING); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - GL11.glDepthFunc(GL11.GL_LEQUAL); - GL11.glDisable(GL11.GL_BLEND); - GL11.glAlphaFunc(GL11.GL_GREATER, 0.1F); - Minecraft.getMinecraft().entityRenderer.enableLightmap((double) 0); - } catch (Exception ignored) { - } - } - npc.display.overlayRenderTicks++; - } - } + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GL11.glDepthFunc(GL11.GL_LEQUAL); + GL11.glDisable(GL11.GL_BLEND); + GL11.glAlphaFunc(GL11.GL_GREATER, 0.1F); + Minecraft.getMinecraft().entityRenderer.enableLightmap((double) 0); + } catch (Exception ignored) { + } + } + npc.display.overlayRenderTicks++; + } + } - @Override - protected float handleRotationFloat(EntityLivingBase par1EntityLiving, float par2){ - EntityNPCInterface npc = (EntityNPCInterface) par1EntityLiving; - if(npc.isKilled() || npc.display.disableLivingAnimation) - return 0; - return super.handleRotationFloat(par1EntityLiving, par2); - } + @Override + protected float handleRotationFloat(EntityLivingBase par1EntityLiving, float par2) { + EntityNPCInterface npc = (EntityNPCInterface) par1EntityLiving; + if (npc.isKilled() || npc.display.disableLivingAnimation) + return 0; + return super.handleRotationFloat(par1EntityLiving, par2); + } - @Override - protected void renderLivingAt(EntityLivingBase entityliving, double d, double d1, double d2){ - renderPlayerSleep((EntityNPCInterface)entityliving, d, d1, d2); - } + @Override + protected void renderLivingAt(EntityLivingBase entityliving, double d, double d1, double d2) { + renderPlayerSleep((EntityNPCInterface) entityliving, d, d1, d2); + } - @Override - public ResourceLocation getEntityTexture(Entity entity) { + @Override + public ResourceLocation getEntityTexture(Entity entity) { - EntityNPCInterface npc = (EntityNPCInterface) entity; - if (npc.textureLocation == null) { - if (npc.display.skinType == 0) { - if (npc instanceof EntityCustomNpc && ((EntityCustomNpc) npc).modelData.entityClass == null) { - if (!(npc.display.texture).isEmpty()) { - try { - npc.textureLocation = adjustLocalTexture(npc, new ResourceLocation(npc.display.texture)); - } catch (IOException ignored) {} - } - } else { - npc.textureLocation = new ResourceLocation(npc.display.texture); - } - } else if(npc.display.skinType == 1 && npc.display.playerProfile != null) { - Minecraft minecraft = Minecraft.getMinecraft(); - Map map = minecraft.func_152342_ad().func_152788_a(npc.display.playerProfile); - if (map.containsKey(Type.SKIN)){ - npc.textureLocation = minecraft.func_152342_ad().func_152792_a((MinecraftProfileTexture)map.get(Type.SKIN), Type.SKIN); - } - LastTextureTick = 0; - } else if (npc.display.skinType == 2 || npc.display.skinType == 3) { + EntityNPCInterface npc = (EntityNPCInterface) entity; + if (npc.textureLocation == null) { + if (npc.display.skinType == 0) { + if (npc instanceof EntityCustomNpc && ((EntityCustomNpc) npc).modelData.entityClass == null) { + if (!(npc.display.texture).isEmpty()) { + try { + npc.textureLocation = adjustLocalTexture(npc, new ResourceLocation(npc.display.texture)); + } catch (IOException ignored) { + } + } + } else { + npc.textureLocation = new ResourceLocation(npc.display.texture); + } + } else if (npc.display.skinType == 1 && npc.display.playerProfile != null) { + Minecraft minecraft = Minecraft.getMinecraft(); + Map map = minecraft.func_152342_ad().func_152788_a(npc.display.playerProfile); + if (map.containsKey(Type.SKIN)) { + npc.textureLocation = minecraft.func_152342_ad().func_152792_a((MinecraftProfileTexture) map.get(Type.SKIN), Type.SKIN); + } + LastTextureTick = 0; + } else if (npc.display.skinType == 2 || npc.display.skinType == 3) { ResourceLocation location = new ResourceLocation("skins/" + (npc.display.skinType + npc.display.url).hashCode()); // If URL Empty Steve - if(npc.display.url.isEmpty()){ + if (npc.display.url.isEmpty()) { return fallBackSkin(npc); } // If URL Cached then grab it - else if(ClientCacheHandler.isCachedNPC(location)){ + else if (ClientCacheHandler.isCachedNPC(location)) { try { ResourceLocation loc = ClientCacheHandler.getNPCTexture(npc.display.url, npc.display.skinType == 3, location).getLocation(); - if(loc != null){ + if (loc != null) { npc.textureLocation = loc; } else { return fallBackSkin(npc); } - } catch(Exception ignored){} + } catch (Exception ignored) { + } } // For New URL Requests do not spam it - else if(LastTextureTick < 5) { //fixes request flood somewhat + else if (LastTextureTick < 5) { //fixes request flood somewhat return fallBackSkin(npc); - } - else { + } else { try { ResourceLocation loc = ClientCacheHandler.getNPCTexture(npc.display.url, npc.display.skinType == 3, location).getLocation(); - if(loc != null){ + if (loc != null) { npc.textureLocation = loc; } else { return fallBackSkin(npc); } LastTextureTick = 0; - } catch(Exception ignored){} + } catch (Exception ignored) { + } } - } else { - return fallBackSkin(npc); - } - } - return npc.textureLocation; - } + } else { + return fallBackSkin(npc); + } + } + return npc.textureLocation; + } - private ResourceLocation adjustLocalTexture(EntityNPCInterface npc, ResourceLocation location) throws IOException { - InputStream inputstream = null; - try { - TextureManager texturemanager = Minecraft.getMinecraft().getTextureManager(); - texturemanager.deleteTexture(location); + private ResourceLocation adjustLocalTexture(EntityNPCInterface npc, ResourceLocation location) throws IOException { + InputStream inputstream = null; + try { + TextureManager texturemanager = Minecraft.getMinecraft().getTextureManager(); + texturemanager.deleteTexture(location); - IResource iresource = Minecraft.getMinecraft().getResourceManager().getResource(location); - inputstream = iresource.getInputStream(); + IResource iresource = Minecraft.getMinecraft().getResourceManager().getResource(location); + inputstream = iresource.getInputStream(); - BufferedImage bufferedimage = ImageIO.read(inputstream); + BufferedImage bufferedimage = ImageIO.read(inputstream); - int totalWidth = bufferedimage.getWidth(); - int totalHeight = bufferedimage.getHeight(); - if (totalWidth == totalHeight && npc.display.modelType == 0) { - bufferedimage = bufferedimage.getSubimage(0, 0, totalWidth, totalWidth / 2); - } + int totalWidth = bufferedimage.getWidth(); + int totalHeight = bufferedimage.getHeight(); + if (totalWidth == totalHeight && npc.display.modelType == 0) { + bufferedimage = bufferedimage.getSubimage(0, 0, totalWidth, totalWidth / 2); + } - ImageDownloadAlt object = new ImageDownloadAlt(null, npc.display.texture, SkinManager.field_152793_a, new ImageBufferDownloadAlt(true)); - object.setBufferedImage(bufferedimage); + ImageDownloadAlt object = new ImageDownloadAlt(null, npc.display.texture, SkinManager.field_152793_a, new ImageBufferDownloadAlt(true)); + object.setBufferedImage(bufferedimage); - try { - MessageDigest digest = MessageDigest.getInstance("MD5"); - byte[] hash = digest.digest(npc.display.texture.getBytes("UTF-8")); - StringBuilder sb = new StringBuilder(2*hash.length); - for (byte b : hash) { - sb.append(String.format("%02x", b&0xff)); - } - if (npc.display.modelType == 0) { - location = new ResourceLocation("skin/" + sb.toString()); - } else { - location = new ResourceLocation("skin64/" + sb.toString()); - } - } catch(Exception ignored){} - texturemanager.loadTexture(location, object); - return location; - } finally { - if (inputstream != null) { - inputstream.close(); - } - } - } + try { + MessageDigest digest = MessageDigest.getInstance("MD5"); + byte[] hash = digest.digest(npc.display.texture.getBytes("UTF-8")); + StringBuilder sb = new StringBuilder(2 * hash.length); + for (byte b : hash) { + sb.append(String.format("%02x", b & 0xff)); + } + if (npc.display.modelType == 0) { + location = new ResourceLocation("skin/" + sb.toString()); + } else { + location = new ResourceLocation("skin64/" + sb.toString()); + } + } catch (Exception ignored) { + } + texturemanager.loadTexture(location, object); + return location; + } finally { + if (inputstream != null) { + inputstream.close(); + } + } + } - private ResourceLocation fallBackSkin(EntityNPCInterface npcInterface){ - switch (npcInterface.display.modelType){ + private ResourceLocation fallBackSkin(EntityNPCInterface npcInterface) { + switch (npcInterface.display.modelType) { case 2: return alex; case 1: diff --git a/src/main/java/noppes/npcs/client/renderer/RenderNPCPony.java b/src/main/java/noppes/npcs/client/renderer/RenderNPCPony.java index 95125d420..82970525f 100644 --- a/src/main/java/noppes/npcs/client/renderer/RenderNPCPony.java +++ b/src/main/java/noppes/npcs/client/renderer/RenderNPCPony.java @@ -25,39 +25,34 @@ import java.awt.*; import java.awt.image.BufferedImage; import java.io.IOException; -public class RenderNPCPony extends RenderNPCInterface -{ +public class RenderNPCPony extends RenderNPCInterface { private ModelPony modelBipedMain; private ModelPonyArmor modelArmorChestplate; private ModelPonyArmor modelArmor; - public RenderNPCPony() - { + public RenderNPCPony() { super(new ModelPony(0.0F), 0.5F); - modelBipedMain = (ModelPony)mainModel; + modelBipedMain = (ModelPony) mainModel; modelArmorChestplate = new ModelPonyArmor(1.0F); modelArmor = new ModelPonyArmor(0.5F); } - protected int setArmorModel(EntityNPCInterface entityplayer, int i, float f) - { + protected int setArmorModel(EntityNPCInterface entityplayer, int i, float f) { ItemStack itemstack = entityplayer.inventory.armorItemInSlot(i); - if(itemstack != null) - { + if (itemstack != null) { Item item = itemstack.getItem(); - if(item instanceof ItemArmor) - { - ItemArmor itemarmor = (ItemArmor)item; + if (item instanceof ItemArmor) { + ItemArmor itemarmor = (ItemArmor) item; this.bindTexture(RenderBiped.getArmorResource(entityplayer, itemstack, i, null)); ModelPonyArmor modelbiped = i != 2 ? modelArmorChestplate : modelArmor; modelbiped.head.showModel = i == 0; - modelbiped.Body.showModel = i == 1 ; - modelbiped.BodyBack.showModel = i == 1 ; + modelbiped.Body.showModel = i == 1; + modelbiped.BodyBack.showModel = i == 1; modelbiped.rightarm.showModel = i == 3; modelbiped.LeftArm.showModel = i == 3; - modelbiped.RightLeg.showModel = i == 3; + modelbiped.RightLeg.showModel = i == 3; modelbiped.LeftLeg.showModel = i == 3; modelbiped.rightarm2.showModel = i == 2; @@ -68,16 +63,14 @@ public class RenderNPCPony extends RenderNPCInterface float var8 = 1.0F; - if (itemarmor.getArmorMaterial() == ArmorMaterial.CLOTH) - { + if (itemarmor.getArmorMaterial() == ArmorMaterial.CLOTH) { int var9 = itemarmor.getColor(itemstack); - float var10 = (float)(var9 >> 16 & 255) / 255.0F; - float var11 = (float)(var9 >> 8 & 255) / 255.0F; - float var12 = (float)(var9 & 255) / 255.0F; + float var10 = (float) (var9 >> 16 & 255) / 255.0F; + float var11 = (float) (var9 >> 8 & 255) / 255.0F; + float var12 = (float) (var9 & 255) / 255.0F; GL11.glColor3f(var8 * var10, var8 * var11, var8 * var12); - if (itemstack.isItemEnchanted()) - { + if (itemstack.isItemEnchanted()) { return 31; } @@ -85,70 +78,64 @@ public class RenderNPCPony extends RenderNPCInterface } GL11.glColor3f(var8, var8, var8); - + return !itemstack.isItemEnchanted() ? 1 : 15; } } return -1; } - @Override - public ResourceLocation getEntityTexture(Entity entity) { - EntityNpcPony pony = (EntityNpcPony) entity; - boolean check = pony.textureLocation == null || pony.textureLocation != pony.checked; - ResourceLocation loc = super.getEntityTexture(pony); - if(check){ - try { - IResource resource = Minecraft.getMinecraft().getResourceManager().getResource(loc); - BufferedImage bufferedimage = ImageIO.read(resource.getInputStream()); + @Override + public ResourceLocation getEntityTexture(Entity entity) { + EntityNpcPony pony = (EntityNpcPony) entity; + boolean check = pony.textureLocation == null || pony.textureLocation != pony.checked; + ResourceLocation loc = super.getEntityTexture(pony); + if (check) { + try { + IResource resource = Minecraft.getMinecraft().getResourceManager().getResource(loc); + BufferedImage bufferedimage = ImageIO.read(resource.getInputStream()); - pony.isPegasus = false; - pony.isUnicorn = false; - Color color = new Color(bufferedimage.getRGB(0, 0), true); - Color color1 = new Color(249, 177, 49, 255); - Color color2 = new Color(136, 202, 240, 255); - Color color3 = new Color(209, 159, 228, 255); - Color color4 = new Color(254, 249, 252, 255); - if(color.equals(color1)) - { - } - if(color.equals(color2)) - { - pony.isPegasus = true; - } - if(color.equals(color3)) - { - pony.isUnicorn = true; - } - if(color.equals(color4)) - { - pony.isPegasus = true; - pony.isUnicorn = true; - } - pony.checked = loc; - - } catch (IOException e) { - - } - } - return loc; - } + pony.isPegasus = false; + pony.isUnicorn = false; + Color color = new Color(bufferedimage.getRGB(0, 0), true); + Color color1 = new Color(249, 177, 49, 255); + Color color2 = new Color(136, 202, 240, 255); + Color color3 = new Color(209, 159, 228, 255); + Color color4 = new Color(254, 249, 252, 255); + if (color.equals(color1)) { + } + if (color.equals(color2)) { + pony.isPegasus = true; + } + if (color.equals(color3)) { + pony.isUnicorn = true; + } + if (color.equals(color4)) { + pony.isPegasus = true; + pony.isUnicorn = true; + } + pony.checked = loc; - public void renderPlayer(EntityNpcPony pony, double d, double d1, double d2, - float f, float f1) - { + } catch (IOException e) { + + } + } + return loc; + } + + public void renderPlayer(EntityNpcPony pony, double d, double d1, double d2, + float f, float f1) { ItemStack itemstack = pony.getHeldItem(); setRenderPassModel(modelBipedMain); - + modelArmorChestplate.heldItemRight = modelArmor.heldItemRight = modelBipedMain.heldItemRight = itemstack == null ? 0 : 1; modelArmorChestplate.isSneak = modelArmor.isSneak = modelBipedMain.isSneak = pony.isSneaking(); modelArmorChestplate.isRiding = modelArmor.isRiding = modelBipedMain.isRiding = false; modelArmorChestplate.isSleeping = modelArmor.isSleeping = modelBipedMain.isSleeping = pony.isPlayerSleeping(); modelArmorChestplate.isUnicorn = modelArmor.isUnicorn = modelBipedMain.isUnicorn = pony.isUnicorn; modelArmorChestplate.isPegasus = modelArmor.isPegasus = modelBipedMain.isPegasus = pony.isPegasus; - double d3 = d1 - (double)pony.yOffset; - if(pony.isSneaking()) - { + double d3 = d1 - (double) pony.yOffset; + if (pony.isSneaking()) { d3 -= 0.125D; } super.doRender(pony, d, d3, d2, f, f1); @@ -157,7 +144,8 @@ public class RenderNPCPony extends RenderNPCInterface modelArmorChestplate.isSneak = modelArmor.isSneak = modelBipedMain.isSneak = false; modelArmorChestplate.heldItemRight = modelArmor.heldItemRight = modelBipedMain.heldItemRight = 0; } -// @Override + + // @Override // protected void rotatePlayer(EntityNPCInterface entityplayer, float f, float f1, float f2) // { // if(entityplayer.isEntityAlive() && entityplayer.isPlayerSleeping()) @@ -180,56 +168,43 @@ public class RenderNPCPony extends RenderNPCInterface // } // } // } - protected void renderSpecials(EntityNpcPony entityplayer, float f) - { + protected void renderSpecials(EntityNpcPony entityplayer, float f) { super.renderEquippedItems(entityplayer, f); - if(!entityplayer.isPlayerSleeping()) - { - if(entityplayer.isUnicorn) - { + if (!entityplayer.isPlayerSleeping()) { + if (entityplayer.isUnicorn) { renderDrop(this.renderManager, entityplayer, modelBipedMain.unicornarm, 1.0F, 0.35F, 0.5375F, -0.45F); - } else - { + } else { renderDrop(this.renderManager, entityplayer, modelBipedMain.RightArm, 1.0F, -0.0625F, 0.8375F, 0.0625F); } } } - protected void renderDrop(RenderManager rendermanager, EntityNpcPony entityplayer, ModelRenderer modelrenderer, float f, float f1, float f2, float f3) - { + protected void renderDrop(RenderManager rendermanager, EntityNpcPony entityplayer, ModelRenderer modelrenderer, float f, float f1, float f2, float f3) { ItemStack itemstack = entityplayer.getHeldItem(); - if(itemstack == null) - { + if (itemstack == null) { return; } GL11.glPushMatrix(); - if(modelrenderer != null) - { + if (modelrenderer != null) { modelrenderer.postRender(f * 0.0625F); } GL11.glTranslatef(f1, f2, f3); - if(itemstack.getItem() instanceof ItemBlock && RenderBlocks.renderItemIn3d(Block.getBlockFromItem(itemstack.getItem()).getRenderType())) - { + if (itemstack.getItem() instanceof ItemBlock && RenderBlocks.renderItemIn3d(Block.getBlockFromItem(itemstack.getItem()).getRenderType())) { GL11.glTranslatef(0.0F, 0.1875F, -0.3125F); GL11.glRotatef(20F, 1.0F, 0.0F, 0.0F); GL11.glRotatef(45F, 0.0F, 1.0F, 0.0F); float f4 = 0.375F * f; GL11.glScalef(f4, -f4, f4); - } else - if(itemstack.getItem() instanceof ItemBow) - { + } else if (itemstack.getItem() instanceof ItemBow) { GL11.glTranslatef(0.0F, 0.125F, 0.3125F); GL11.glRotatef(-20F, 0.0F, 1.0F, 0.0F); float f5 = 0.625F * f; GL11.glScalef(f5, -f5, f5); GL11.glRotatef(-100F, 1.0F, 0.0F, 0.0F); GL11.glRotatef(45F, 0.0F, 1.0F, 0.0F); - } else - if(itemstack.getItem().isFull3D()) - { - if(itemstack.getItem().shouldRotateAroundWhenRendering()) - { + } else if (itemstack.getItem().isFull3D()) { + if (itemstack.getItem().shouldRotateAroundWhenRendering()) { GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); GL11.glTranslatef(0.0F, -0.125F, 0.0F); } @@ -238,8 +213,7 @@ public class RenderNPCPony extends RenderNPCInterface GL11.glScalef(f6, -f6, f6); GL11.glRotatef(-100F, 1.0F, 0.0F, 0.0F); GL11.glRotatef(45F, 0.0F, 1.0F, 0.0F); - } else - { + } else { GL11.glTranslatef(0.25F, 0.1875F, -0.1875F); float f7 = 0.375F * f; GL11.glScalef(f7, f7, f7); @@ -247,47 +221,41 @@ public class RenderNPCPony extends RenderNPCInterface GL11.glRotatef(-90F, 1.0F, 0.0F, 0.0F); GL11.glRotatef(20F, 0.0F, 0.0F, 1.0F); } - if(itemstack.getItem() == Items.potionitem) - { - for (int j = 0; j <= 1; j++) - { + if (itemstack.getItem() == Items.potionitem) { + for (int j = 0; j <= 1; j++) { int k = itemstack.getItem().getColorFromItemStack(itemstack, j); - float f9 = (float)(k >> 16 & 0xff) / 255F; - float f10 = (float)(k >> 8 & 0xff) / 255F; - float f12 = (float)(k & 0xff) / 255F; + float f9 = (float) (k >> 16 & 0xff) / 255F; + float f10 = (float) (k >> 8 & 0xff) / 255F; + float f12 = (float) (k & 0xff) / 255F; GL11.glColor4f(f9, f10, f12, 1.0F); renderManager.itemRenderer.renderItem(entityplayer, itemstack, j); } - } else - { + } else { rendermanager.itemRenderer.renderItem(entityplayer, itemstack, 0); } GL11.glPopMatrix(); } + @Override - protected int shouldRenderPass(EntityLivingBase entityliving, int i, float f) - { - return setArmorModel((EntityNPCInterface)entityliving, i, f); + protected int shouldRenderPass(EntityLivingBase entityliving, int i, float f) { + return setArmorModel((EntityNPCInterface) entityliving, i, f); } @Override - protected void renderEquippedItems(EntityLivingBase entityliving, float f) - { - renderSpecials((EntityNpcPony)entityliving, f); + protected void renderEquippedItems(EntityLivingBase entityliving, float f) { + renderSpecials((EntityNpcPony) entityliving, f); } @Override - public void doRender(EntityLiving entityliving, double d, double d1, double d2, - float f, float f1) - { - renderPlayer((EntityNpcPony)entityliving, d, d1, d2, f, f1); + public void doRender(EntityLiving entityliving, double d, double d1, double d2, + float f, float f1) { + renderPlayer((EntityNpcPony) entityliving, d, d1, d2, f, f1); } @Override - public void doRender(Entity entity, double d, double d1, double d2, - float f, float f1) - { - renderPlayer((EntityNpcPony)entity, d, d1, d2, f, f1); + public void doRender(Entity entity, double d, double d1, double d2, + float f, float f1) { + renderPlayer((EntityNpcPony) entity, d, d1, d2, f, f1); } } diff --git a/src/main/java/noppes/npcs/client/renderer/RenderNpcCrystal.java b/src/main/java/noppes/npcs/client/renderer/RenderNpcCrystal.java index 9f703b1ef..87b694efe 100644 --- a/src/main/java/noppes/npcs/client/renderer/RenderNpcCrystal.java +++ b/src/main/java/noppes/npcs/client/renderer/RenderNpcCrystal.java @@ -2,12 +2,11 @@ package noppes.npcs.client.renderer; import noppes.npcs.client.model.ModelNpcCrystal; -public class RenderNpcCrystal extends RenderNPCInterface -{ - ModelNpcCrystal mainmodel; - public RenderNpcCrystal(ModelNpcCrystal model) - { - super(model,0); - mainmodel = model; +public class RenderNpcCrystal extends RenderNPCInterface { + ModelNpcCrystal mainmodel; + + public RenderNpcCrystal(ModelNpcCrystal model) { + super(model, 0); + mainmodel = model; } } diff --git a/src/main/java/noppes/npcs/client/renderer/RenderNpcDragon.java b/src/main/java/noppes/npcs/client/renderer/RenderNpcDragon.java index a393936ac..56c19cc66 100644 --- a/src/main/java/noppes/npcs/client/renderer/RenderNpcDragon.java +++ b/src/main/java/noppes/npcs/client/renderer/RenderNpcDragon.java @@ -4,16 +4,15 @@ import net.minecraft.client.model.ModelBase; import noppes.npcs.entity.EntityNPCInterface; import org.lwjgl.opengl.GL11; -public class RenderNpcDragon extends RenderNPCInterface{ +public class RenderNpcDragon extends RenderNPCInterface { - public RenderNpcDragon(ModelBase model, float f) { - super(model, f); - } + public RenderNpcDragon(ModelBase model, float f) { + super(model, f); + } - @Override - protected void renderPlayerScale(EntityNPCInterface npc, float f) - { - GL11.glTranslatef(0, 0, 0.6f / 5 * npc.display.modelSize); - super.renderPlayerScale(npc, f); + @Override + protected void renderPlayerScale(EntityNPCInterface npc, float f) { + GL11.glTranslatef(0, 0, 0.6f / 5 * npc.display.modelSize); + super.renderPlayerScale(npc, f); } } diff --git a/src/main/java/noppes/npcs/client/renderer/RenderNpcSlime.java b/src/main/java/noppes/npcs/client/renderer/RenderNpcSlime.java index 526977631..8e257da77 100644 --- a/src/main/java/noppes/npcs/client/renderer/RenderNpcSlime.java +++ b/src/main/java/noppes/npcs/client/renderer/RenderNpcSlime.java @@ -5,12 +5,10 @@ import net.minecraft.entity.EntityLivingBase; import noppes.npcs.entity.EntityNPCInterface; import org.lwjgl.opengl.GL11; -public class RenderNpcSlime extends RenderNPCInterface -{ +public class RenderNpcSlime extends RenderNPCInterface { private ModelBase scaleAmount; - public RenderNpcSlime(ModelBase par1ModelBase, ModelBase par2ModelBase, float par3) - { + public RenderNpcSlime(ModelBase par1ModelBase, ModelBase par2ModelBase, float par3) { super(par1ModelBase, par3); this.scaleAmount = par2ModelBase; } @@ -18,25 +16,17 @@ public class RenderNpcSlime extends RenderNPCInterface /** * Determines whether Slime Render should pass or not. */ - protected int shouldSlimeRenderPass(EntityNPCInterface par1EntitySlime, int par2, float par3) - { - if (par1EntitySlime.isInvisible()) - { + protected int shouldSlimeRenderPass(EntityNPCInterface par1EntitySlime, int par2, float par3) { + if (par1EntitySlime.isInvisible()) { return 0; - } - else - if (par2 == 0) - { + } else if (par2 == 0) { this.setRenderPassModel(this.scaleAmount); GL11.glEnable(GL11.GL_NORMALIZE); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); return 1; - } - else - { - if (par2 == 1) - { + } else { + if (par2 == 1) { GL11.glDisable(GL11.GL_BLEND); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); } @@ -69,8 +59,7 @@ public class RenderNpcSlime extends RenderNPCInterface * Queries whether should render the specified pass or not. */ @Override - protected int shouldRenderPass(EntityLivingBase par1EntityLiving, int par2, float par3) - { - return this.shouldSlimeRenderPass((EntityNPCInterface)par1EntityLiving, par2, par3); + protected int shouldRenderPass(EntityLivingBase par1EntityLiving, int par2, float par3) { + return this.shouldSlimeRenderPass((EntityNPCInterface) par1EntityLiving, par2, par3); } } diff --git a/src/main/java/noppes/npcs/client/renderer/RenderProjectile.java b/src/main/java/noppes/npcs/client/renderer/RenderProjectile.java index c18bef3d7..aaafdf66b 100644 --- a/src/main/java/noppes/npcs/client/renderer/RenderProjectile.java +++ b/src/main/java/noppes/npcs/client/renderer/RenderProjectile.java @@ -23,44 +23,41 @@ import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; @SideOnly(Side.CLIENT) -public class RenderProjectile extends Render -{ - - public boolean renderWithColor = true; - private static final ResourceLocation field_110780_a = new ResourceLocation("textures/entity/arrow.png"); - private static final ResourceLocation field_110798_h = new ResourceLocation("textures/misc/enchanted_item_glint.png"); - private RenderBlocks itemRenderBlocks = new RenderBlocks(); +public class RenderProjectile extends Render { - public void doRenderProjectile(EntityProjectile par1EntityProjectile, double par2, double par4, double par6, float par8, float par9) - { + public boolean renderWithColor = true; + private static final ResourceLocation field_110780_a = new ResourceLocation("textures/entity/arrow.png"); + private static final ResourceLocation field_110798_h = new ResourceLocation("textures/misc/enchanted_item_glint.png"); + private RenderBlocks itemRenderBlocks = new RenderBlocks(); + + public void doRenderProjectile(EntityProjectile par1EntityProjectile, double par2, double par4, double par6, float par8, float par9) { GL11.glPushMatrix(); - GL11.glTranslatef((float)par2, (float)par4, (float)par6); + GL11.glTranslatef((float) par2, (float) par4, (float) par6); GL11.glEnable(GL12.GL_RESCALE_NORMAL); - float f = (float)par1EntityProjectile.getDataWatcher().getWatchableObjectInt(23) / 10.0F; + float f = (float) par1EntityProjectile.getDataWatcher().getWatchableObjectInt(23) / 10.0F; ItemStack item = par1EntityProjectile.getItemDisplay(); GL11.glScalef(f, f, f); Tessellator tessellator = Tessellator.instance; - + if (par1EntityProjectile.isArrow()) { //If it's the special case we are rendering an arrow - this.bindEntityTexture(par1EntityProjectile); + this.bindEntityTexture(par1EntityProjectile); GL11.glRotatef(par1EntityProjectile.prevRotationYaw + (par1EntityProjectile.rotationYaw - par1EntityProjectile.prevRotationYaw) * par9 - 90.0F, 0.0F, 1.0F, 0.0F); GL11.glRotatef(par1EntityProjectile.prevRotationPitch + (par1EntityProjectile.rotationPitch - par1EntityProjectile.prevRotationPitch) * par9, 0.0F, 0.0F, 1.0F); byte b0 = 0; float f2 = 0.0F; float f3 = 0.5F; - float f4 = (float)(0 + b0 * 10) / 32.0F; - float f5 = (float)(5 + b0 * 10) / 32.0F; + float f4 = (float) (0 + b0 * 10) / 32.0F; + float f5 = (float) (5 + b0 * 10) / 32.0F; float f6 = 0.0F; float f7 = 0.15625F; - float f8 = (float)(5 + b0 * 10) / 32.0F; - float f9 = (float)(10 + b0 * 10) / 32.0F; + float f8 = (float) (5 + b0 * 10) / 32.0F; + float f9 = (float) (10 + b0 * 10) / 32.0F; float f10 = 0.05625F; GL11.glEnable(GL12.GL_RESCALE_NORMAL); - float f11 = (float)par1EntityProjectile.arrowShake - par9; + float f11 = (float) par1EntityProjectile.arrowShake - par9; - if (f11 > 0.0F) - { + if (f11 > 0.0F) { float f12 = -MathHelper.sin(f11 * 3.0F) * f11; GL11.glRotatef(f12, 0.0F, 0.0F, 1.0F); } @@ -70,139 +67,119 @@ public class RenderProjectile extends Render GL11.glTranslatef(-4.0F, 0.0F, 0.0F); GL11.glNormal3f(f10, 0.0F, 0.0F); tessellator.startDrawingQuads(); - tessellator.addVertexWithUV(-7.0D, -2.0D, -2.0D, (double)f6, (double)f8); - tessellator.addVertexWithUV(-7.0D, -2.0D, 2.0D, (double)f7, (double)f8); - tessellator.addVertexWithUV(-7.0D, 2.0D, 2.0D, (double)f7, (double)f9); - tessellator.addVertexWithUV(-7.0D, 2.0D, -2.0D, (double)f6, (double)f9); + tessellator.addVertexWithUV(-7.0D, -2.0D, -2.0D, (double) f6, (double) f8); + tessellator.addVertexWithUV(-7.0D, -2.0D, 2.0D, (double) f7, (double) f8); + tessellator.addVertexWithUV(-7.0D, 2.0D, 2.0D, (double) f7, (double) f9); + tessellator.addVertexWithUV(-7.0D, 2.0D, -2.0D, (double) f6, (double) f9); tessellator.draw(); GL11.glNormal3f(-f10, 0.0F, 0.0F); tessellator.startDrawingQuads(); - tessellator.addVertexWithUV(-7.0D, 2.0D, -2.0D, (double)f6, (double)f8); - tessellator.addVertexWithUV(-7.0D, 2.0D, 2.0D, (double)f7, (double)f8); - tessellator.addVertexWithUV(-7.0D, -2.0D, 2.0D, (double)f7, (double)f9); - tessellator.addVertexWithUV(-7.0D, -2.0D, -2.0D, (double)f6, (double)f9); + tessellator.addVertexWithUV(-7.0D, 2.0D, -2.0D, (double) f6, (double) f8); + tessellator.addVertexWithUV(-7.0D, 2.0D, 2.0D, (double) f7, (double) f8); + tessellator.addVertexWithUV(-7.0D, -2.0D, 2.0D, (double) f7, (double) f9); + tessellator.addVertexWithUV(-7.0D, -2.0D, -2.0D, (double) f6, (double) f9); tessellator.draw(); - for (int i = 0; i < 4; ++i) - { + for (int i = 0; i < 4; ++i) { GL11.glRotatef(90.0F, 1.0F, 0.0F, 0.0F); GL11.glNormal3f(0.0F, 0.0F, f10); tessellator.startDrawingQuads(); - tessellator.addVertexWithUV(-8.0D, -2.0D, 0.0D, (double)f2, (double)f4); - tessellator.addVertexWithUV(8.0D, -2.0D, 0.0D, (double)f3, (double)f4); - tessellator.addVertexWithUV(8.0D, 2.0D, 0.0D, (double)f3, (double)f5); - tessellator.addVertexWithUV(-8.0D, 2.0D, 0.0D, (double)f2, (double)f5); + tessellator.addVertexWithUV(-8.0D, -2.0D, 0.0D, (double) f2, (double) f4); + tessellator.addVertexWithUV(8.0D, -2.0D, 0.0D, (double) f3, (double) f4); + tessellator.addVertexWithUV(8.0D, 2.0D, 0.0D, (double) f3, (double) f5); + tessellator.addVertexWithUV(-8.0D, 2.0D, 0.0D, (double) f2, (double) f5); tessellator.draw(); } - } - - else if (par1EntityProjectile.is3D()) { - GL11.glRotatef(par1EntityProjectile.prevRotationYaw + (par1EntityProjectile.rotationYaw - par1EntityProjectile.prevRotationYaw) * par9 - 90.0F, 0.0F, 1.0F, 0.0F); + } else if (par1EntityProjectile.is3D()) { + GL11.glRotatef(par1EntityProjectile.prevRotationYaw + (par1EntityProjectile.rotationYaw - par1EntityProjectile.prevRotationYaw) * par9 - 90.0F, 0.0F, 1.0F, 0.0F); GL11.glRotatef(par1EntityProjectile.prevRotationPitch + (par1EntityProjectile.rotationPitch - par1EntityProjectile.prevRotationPitch) * par9 - 180, 0.0F, 0.0F, 1.0F); - - //Render a block - if (item.getItemSpriteNumber() == 0 && item.getItem() instanceof ItemBlock && RenderBlocks.renderItemIn3d(Block.getBlockFromItem(item.getItem()).getRenderType())) - { - Block block = Block.getBlockFromItem(item.getItem()); - this.bindTexture(TextureMap.locationBlocksTexture); - float f7 = 0.25F; - int j = block.getRenderType(); - if (j == 1 || j == 19 || j == 12 || j == 2) - { - f7 = 0.5F; - } + //Render a block + if (item.getItemSpriteNumber() == 0 && item.getItem() instanceof ItemBlock && RenderBlocks.renderItemIn3d(Block.getBlockFromItem(item.getItem()).getRenderType())) { + Block block = Block.getBlockFromItem(item.getItem()); + this.bindTexture(TextureMap.locationBlocksTexture); + float f7 = 0.25F; + int j = block.getRenderType(); - float f5 = 1.0F; - this.itemRenderBlocks.renderBlockAsItem(block, item.getItemDamage(), 1.0F); - //this.renderBlocks.renderBlockAsItem(block, item.getItemDamage(), f5); - } - else //render a 3D item - { - float f4, f5, f6, f8; - GL11.glTranslatef(-0.6f, -0.6f, 0); + if (j == 1 || j == 19 || j == 12 || j == 2) { + f7 = 0.5F; + } - if (item.getItem().requiresMultipleRenderPasses()) - { + float f5 = 1.0F; + this.itemRenderBlocks.renderBlockAsItem(block, item.getItemDamage(), 1.0F); + //this.renderBlocks.renderBlockAsItem(block, item.getItemDamage(), f5); + } else //render a 3D item + { + float f4, f5, f6, f8; + GL11.glTranslatef(-0.6f, -0.6f, 0); - for (int k = 0; k < item.getItem().getRenderPasses(item.getItemDamage()); ++k) - { - IIcon icon = item.getItem().getIcon(item, k); - f8 = 1.0F; + if (item.getItem().requiresMultipleRenderPasses()) { - if (this.renderWithColor) - { - int i = item.getItem().getColorFromItemStack(item, k); - f5 = (float)(i >> 16 & 255) / 255.0F; - f4 = (float)(i >> 8 & 255) / 255.0F; - f6 = (float)(i & 255) / 255.0F; - GL11.glColor4f(f5 * f8, f4 * f8, f6 * f8, 1.0F); - this.renderManager.itemRenderer.renderItem(Minecraft.getMinecraft().thePlayer, item, 0); - } - else - { - this.renderManager.itemRenderer.renderItem(Minecraft.getMinecraft().thePlayer, item, 0); - } - } - } - else - { + for (int k = 0; k < item.getItem().getRenderPasses(item.getItemDamage()); ++k) { + IIcon icon = item.getItem().getIcon(item, k); + f8 = 1.0F; - IIcon icon1 = item.getIconIndex(); + if (this.renderWithColor) { + int i = item.getItem().getColorFromItemStack(item, k); + f5 = (float) (i >> 16 & 255) / 255.0F; + f4 = (float) (i >> 8 & 255) / 255.0F; + f6 = (float) (i & 255) / 255.0F; + GL11.glColor4f(f5 * f8, f4 * f8, f6 * f8, 1.0F); + this.renderManager.itemRenderer.renderItem(Minecraft.getMinecraft().thePlayer, item, 0); + } else { + this.renderManager.itemRenderer.renderItem(Minecraft.getMinecraft().thePlayer, item, 0); + } + } + } else { - if (this.renderWithColor) - { - int l = item.getItem().getColorFromItemStack(item, 0); - f8 = (float)(l >> 16 & 255) / 255.0F; - float f9 = (float)(l >> 8 & 255) / 255.0F; - f5 = (float)(l & 255) / 255.0F; - f4 = 1.0F; - this.renderDroppedItem(item, icon1, par9, f8 * f4, f9 * f4, f5 * f4, f); - } - else - { - this.renderDroppedItem(item, icon1, par9, 1.0F, 1.0F, 1.0F, f); - } - } - } - } - else //If the render is a sprite + IIcon icon1 = item.getIconIndex(); + + if (this.renderWithColor) { + int l = item.getItem().getColorFromItemStack(item, 0); + f8 = (float) (l >> 16 & 255) / 255.0F; + float f9 = (float) (l >> 8 & 255) / 255.0F; + f5 = (float) (l & 255) / 255.0F; + f4 = 1.0F; + this.renderDroppedItem(item, icon1, par9, f8 * f4, f9 * f4, f5 * f4, f); + } else { + this.renderDroppedItem(item, icon1, par9, 1.0F, 1.0F, 1.0F, f); + } + } + } + } else //If the render is a sprite { // IIcon icon = item.getIconIndex(); - IIcon icon = item.getItem().getIconFromDamage(item.getItemDamage()); - - this.bindTexture(TextureMap.locationItemsTexture); - if (item.getItem().requiresMultipleRenderPasses()) - { - for (int k = 0; k < item.getItem().getRenderPasses(item.getItemDamage()); ++k) - { + IIcon icon = item.getItem().getIconFromDamage(item.getItemDamage()); + + this.bindTexture(TextureMap.locationItemsTexture); + if (item.getItem().requiresMultipleRenderPasses()) { + for (int k = 0; k < item.getItem().getRenderPasses(item.getItemDamage()); ++k) { int i = item.getItem().getColorFromItemStack(item, k); - float f5 = (float)(i >> 16 & 255) / 255.0F; - float f4 = (float)(i >> 8 & 255) / 255.0F; - float f6 = (float)(i & 255) / 255.0F; + float f5 = (float) (i >> 16 & 255) / 255.0F; + float f4 = (float) (i >> 8 & 255) / 255.0F; + float f6 = (float) (i & 255) / 255.0F; GL11.glColor4f(f5, f4, f6, 1.0F); } } - if (icon == ItemPotion.func_94589_d("bottle_splash") || icon == ItemPotion.func_94589_d("bottle_drinkable")) - { - int var12 = PotionHelper.func_77915_a(item.getItemDamage(), false); - float var13 = (float)(var12 >> 16 & 255) / 255.0F; - float var14 = (float)(var12 >> 8 & 255) / 255.0F; - float var15 = (float)(var12 & 255) / 255.0F; + if (icon == ItemPotion.func_94589_d("bottle_splash") || icon == ItemPotion.func_94589_d("bottle_drinkable")) { + int var12 = PotionHelper.func_77915_a(item.getItemDamage(), false); + float var13 = (float) (var12 >> 16 & 255) / 255.0F; + float var14 = (float) (var12 >> 8 & 255) / 255.0F; + float var15 = (float) (var12 & 255) / 255.0F; GL11.glColor3f(var13, var14, var15); GL11.glPushMatrix(); this.renderSprite(tessellator, ItemPotion.func_94589_d("overlay")); GL11.glPopMatrix(); GL11.glColor3f(1.0F, 1.0F, 1.0F); } - this.renderSprite(tessellator, icon); + this.renderSprite(tessellator, icon); } if (par1EntityProjectile.is3D() && par1EntityProjectile.glows()) { - GL11.glDisable(GL11.GL_LIGHTING); + GL11.glDisable(GL11.GL_LIGHTING); } GL11.glDisable(GL12.GL_RESCALE_NORMAL); GL11.glPopMatrix(); - GL11.glEnable(GL11.GL_LIGHTING); + GL11.glEnable(GL11.GL_LIGHTING); } /** @@ -211,9 +188,8 @@ public class RenderProjectile extends Render * (Render> 16 & 255) / 255.0F; - f4 = (float)(l >> 8 & 255) / 255.0F; - f = (float)(l & 255) / 255.0F; + f3 = (float) (l >> 16 & 255) / 255.0F; + f4 = (float) (l >> 8 & 255) / 255.0F; + f = (float) (l & 255) / 255.0F; - if (renderer.renderWithColor) - { + if (renderer.renderWithColor) { GL11.glColor4f(f3, f4, f, 1.0F); } @@ -206,50 +201,50 @@ public class BlockBannerRenderer extends BlockRendererInterface{ GL11.glEnable(GL11.GL_ALPHA_TEST); GL11.glEnable(GL11.GL_BLEND); - renderer.renderIcon(p_77015_4_, p_77015_5_, (IIcon)object, 16, 16); + renderer.renderIcon(p_77015_4_, p_77015_5_, (IIcon) object, 16, 16); GL11.glEnable(GL11.GL_LIGHTING); GL11.glDisable(GL11.GL_ALPHA_TEST); GL11.glDisable(GL11.GL_BLEND); - if (renderEffect && item.hasEffect(0)) - { + if (renderEffect && item.hasEffect(0)) { renderer.renderEffect(txtMng, p_77015_4_, p_77015_5_); } GL11.glEnable(GL11.GL_LIGHTING); GL11.glEnable(GL11.GL_CULL_FACE); } - @Override - public void renderInventoryBlock(Block block, int metadata, int modelId, - RenderBlocks renderer) {} + @Override + public void renderInventoryBlock(Block block, int metadata, int modelId, + RenderBlocks renderer) { + } - @Override - public int getRenderId() { - return CustomItems.banner.getRenderType(); - } + @Override + public int getRenderId() { + return CustomItems.banner.getRenderType(); + } - public int specialRenderDistance(){ - return 26; - } + public int specialRenderDistance() { + return 26; + } - public static void setBannerMaterial(int meta){ + public static void setBannerMaterial(int meta) { TextureManager manager = Minecraft.getMinecraft().getTextureManager(); - if(meta == 1) + if (meta == 1) manager.bindTexture(BannerStone); - else if(meta == 2) + else if (meta == 2) manager.bindTexture(BannerIron); - else if(meta == 3) + else if (meta == 3) manager.bindTexture(BannerGold); - else if(meta == 4) + else if (meta == 4) manager.bindTexture(BannerDiamond); else manager.bindTexture(BannerWood); } - public static void setFlagType(EnumBannerVariant variant){ + public static void setFlagType(EnumBannerVariant variant) { TextureManager manager = Minecraft.getMinecraft().getTextureManager(); - switch (variant){ + switch (variant) { case Pointy: manager.bindTexture(pointyFlag); break; diff --git a/src/main/java/noppes/npcs/client/renderer/blocks/BlockBarrelRenderer.java b/src/main/java/noppes/npcs/client/renderer/blocks/BlockBarrelRenderer.java index f92dfa046..53e36f5a0 100644 --- a/src/main/java/noppes/npcs/client/renderer/blocks/BlockBarrelRenderer.java +++ b/src/main/java/noppes/npcs/client/renderer/blocks/BlockBarrelRenderer.java @@ -17,42 +17,42 @@ import noppes.npcs.config.ConfigClient; import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; -public class BlockBarrelRenderer extends BlockRendererInterface{ +public class BlockBarrelRenderer extends BlockRendererInterface { // Legacy - private final ModelLegacyBarrel legacyModel = new ModelLegacyBarrel(); - private final ModelLegacyBarrelLid legacyLid = new ModelLegacyBarrelLid(); - private static final ResourceLocation legacy_texture = new ResourceLocation("customnpcs","textures/models/Barrel.png"); + private final ModelLegacyBarrel legacyModel = new ModelLegacyBarrel(); + private final ModelLegacyBarrelLid legacyLid = new ModelLegacyBarrelLid(); + private static final ResourceLocation legacy_texture = new ResourceLocation("customnpcs", "textures/models/Barrel.png"); // Modern private final ModelBarrel barrel = new ModelBarrel(); - private static final ResourceLocation trimTexture = new ResourceLocation("customnpcs","textures/models/barrel/trim.png"); + private static final ResourceLocation trimTexture = new ResourceLocation("customnpcs", "textures/models/barrel/trim.png"); - private static final ResourceLocation oak_lid = new ResourceLocation("customnpcs","textures/models/barrel/oak_lid.png"); - private static final ResourceLocation spruce_lid = new ResourceLocation("customnpcs","textures/models/barrel/spruce_lid.png"); - private static final ResourceLocation birch_lid = new ResourceLocation("customnpcs","textures/models/barrel/birch_lid.png"); - private static final ResourceLocation jungle_lid = new ResourceLocation("customnpcs","textures/models/barrel/jungle_lid.png"); - private static final ResourceLocation acacia_lid = new ResourceLocation("customnpcs","textures/models/barrel/acacia_lid.png"); - private static final ResourceLocation dark_oak_lid = new ResourceLocation("customnpcs","textures/models/barrel/dark_oak_lid.png"); + private static final ResourceLocation oak_lid = new ResourceLocation("customnpcs", "textures/models/barrel/oak_lid.png"); + private static final ResourceLocation spruce_lid = new ResourceLocation("customnpcs", "textures/models/barrel/spruce_lid.png"); + private static final ResourceLocation birch_lid = new ResourceLocation("customnpcs", "textures/models/barrel/birch_lid.png"); + private static final ResourceLocation jungle_lid = new ResourceLocation("customnpcs", "textures/models/barrel/jungle_lid.png"); + private static final ResourceLocation acacia_lid = new ResourceLocation("customnpcs", "textures/models/barrel/acacia_lid.png"); + private static final ResourceLocation dark_oak_lid = new ResourceLocation("customnpcs", "textures/models/barrel/dark_oak_lid.png"); - public BlockBarrelRenderer(){ - ((BlockBarrel)CustomItems.barrel).renderId = RenderingRegistry.getNextAvailableRenderId(); - RenderingRegistry.registerBlockHandler(this); - } + public BlockBarrelRenderer() { + ((BlockBarrel) CustomItems.barrel).renderId = RenderingRegistry.getNextAvailableRenderId(); + RenderingRegistry.registerBlockHandler(this); + } - @Override - public void renderTileEntityAt(TileEntity var1, double var2, double var4, - double var6, float var8) { - TileVariant tile = (TileVariant) var1; + @Override + public void renderTileEntityAt(TileEntity var1, double var2, double var4, + double var6, float var8) { + TileVariant tile = (TileVariant) var1; GL11.glDisable(GL12.GL_RESCALE_NORMAL); GL11.glEnable(GL11.GL_ALPHA_TEST); GL11.glPushMatrix(); - if(ConfigClient.LegacyBarrel){ - GL11.glTranslatef((float)var2 + 0.5f, (float)var4 + 1.42f, (float)var6 + 0.5f); - GL11.glScalef(1.2f, 0.94f,1.2f); + if (ConfigClient.LegacyBarrel) { + GL11.glTranslatef((float) var2 + 0.5f, (float) var4 + 1.42f, (float) var6 + 0.5f); + GL11.glScalef(1.2f, 0.94f, 1.2f); GL11.glRotatef(180, 0, 0, 1); GL11.glRotatef(45 * tile.rotation, 0, 1, 0); GL11.glColor3f(1, 1, 1); @@ -63,10 +63,9 @@ public class BlockBarrelRenderer extends BlockRendererInterface{ legacyModel.render(null, 0, 0, 0, 0, 0.0F, 0.0625F); Minecraft.getMinecraft().getTextureManager().bindTexture(legacy_texture); legacyLid.render(null, 0, 0, 0, 0, 0.0F, 0.0625F); - } - else { - GL11.glTranslatef((float)var2 + 0.5f, (float)var4 + 1.5f, (float)var6 + 0.5f); - GL11.glScalef(1.0f, 1.0f,1.0f); + } else { + GL11.glTranslatef((float) var2 + 0.5f, (float) var4 + 1.5f, (float) var6 + 0.5f); + GL11.glScalef(1.0f, 1.0f, 1.0f); GL11.glRotatef(180, 0, 0, 1); GL11.glRotatef(45 * tile.rotation, 0, 1, 0); GL11.glColor3f(1, 1, 1); @@ -81,14 +80,14 @@ public class BlockBarrelRenderer extends BlockRendererInterface{ barrel.renderBase(0.0625F); } - GL11.glPopMatrix(); - } + GL11.glPopMatrix(); + } - @Override - public void renderInventoryBlock(Block block, int metadata, int modelId, - RenderBlocks renderer) { + @Override + public void renderInventoryBlock(Block block, int metadata, int modelId, + RenderBlocks renderer) { GL11.glPushMatrix(); - if(ConfigClient.LegacyBarrel){ + if (ConfigClient.LegacyBarrel) { GL11.glTranslatef(0, 0.75f, 0); GL11.glScalef(0.7f, 0.7f, 0.7f); GL11.glRotatef(180, 0, 0, 1); @@ -100,8 +99,7 @@ public class BlockBarrelRenderer extends BlockRendererInterface{ Minecraft.getMinecraft().getTextureManager().bindTexture(legacy_texture); legacyLid.render(null, 0, 0, 0, 0, 0.0F, 0.0625F); - } - else { + } else { GL11.glTranslatef(0, 0.9f, 0); GL11.glScalef(0.9f, 0.9f, 0.9f); GL11.glRotatef(180, 0, 0, 1); @@ -116,20 +114,20 @@ public class BlockBarrelRenderer extends BlockRendererInterface{ barrel.renderBase(0.0625F); } - GL11.glPopMatrix(); - } + GL11.glPopMatrix(); + } - public void setLidTexture(int meta){ + public void setLidTexture(int meta) { TextureManager manager = Minecraft.getMinecraft().getTextureManager(); - if(meta == 1) + if (meta == 1) manager.bindTexture(spruce_lid); - else if(meta == 2) + else if (meta == 2) manager.bindTexture(birch_lid); - else if(meta == 3) + else if (meta == 3) manager.bindTexture(jungle_lid); - else if(meta == 4) + else if (meta == 4) manager.bindTexture(acacia_lid); - else if(meta == 5) + else if (meta == 5) manager.bindTexture(dark_oak_lid); else manager.bindTexture(oak_lid); @@ -137,7 +135,7 @@ public class BlockBarrelRenderer extends BlockRendererInterface{ @Override - public int getRenderId() { - return CustomItems.barrel.getRenderType(); - } + public int getRenderId() { + return CustomItems.barrel.getRenderType(); + } } diff --git a/src/main/java/noppes/npcs/client/renderer/blocks/BlockBeamRenderer.java b/src/main/java/noppes/npcs/client/renderer/blocks/BlockBeamRenderer.java index 60e9b5d3c..64b37340f 100644 --- a/src/main/java/noppes/npcs/client/renderer/blocks/BlockBeamRenderer.java +++ b/src/main/java/noppes/npcs/client/renderer/blocks/BlockBeamRenderer.java @@ -13,21 +13,22 @@ import noppes.npcs.client.model.blocks.ModelBeam; import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; -public class BlockBeamRenderer extends BlockRendererInterface{ +public class BlockBeamRenderer extends BlockRendererInterface { - private final ModelBeam model = new ModelBeam(); + private final ModelBeam model = new ModelBeam(); - public BlockBeamRenderer(){ - ((BlockRotated)CustomItems.beam).renderId = RenderingRegistry.getNextAvailableRenderId(); - RenderingRegistry.registerBlockHandler(this); - } - @Override - public void renderTileEntityAt(TileEntity var1, double var2, double var4, - double var6, float var8) { - TileVariant tile = (TileVariant) var1; + public BlockBeamRenderer() { + ((BlockRotated) CustomItems.beam).renderId = RenderingRegistry.getNextAvailableRenderId(); + RenderingRegistry.registerBlockHandler(this); + } + + @Override + public void renderTileEntityAt(TileEntity var1, double var2, double var4, + double var6, float var8) { + TileVariant tile = (TileVariant) var1; GL11.glDisable(GL12.GL_RESCALE_NORMAL); GL11.glPushMatrix(); - GL11.glTranslatef((float)var2 + 0.5f, (float)var4 + 1.5f, (float)var6 + 0.5f); + GL11.glTranslatef((float) var2 + 0.5f, (float) var4 + 1.5f, (float) var6 + 0.5f); //GL11.glScalef(1.2f, 1.1f, 1.2f); GL11.glRotatef(180, 0, 0, 1); GL11.glRotatef(90 * tile.rotation, 0, 1, 0); @@ -36,18 +37,19 @@ public class BlockBeamRenderer extends BlockRendererInterface{ setWoodTexture(var1.getBlockMetadata()); model.render(null, 0, 0, 0, 0, 0.0F, 0.0625F); - GL11.glPopMatrix(); - } - private boolean shouldDraw(World world,int x, int y, int z, int rotation){ - TileEntity tile = world.getTileEntity(x, y, z); - if(tile == null || !(tile instanceof TileShelf)) - return true; - return ((TileShelf)tile).rotation != rotation; - } + GL11.glPopMatrix(); + } - @Override - public void renderInventoryBlock(Block block, int metadata, int modelId, - RenderBlocks renderer) { + private boolean shouldDraw(World world, int x, int y, int z, int rotation) { + TileEntity tile = world.getTileEntity(x, y, z); + if (tile == null || !(tile instanceof TileShelf)) + return true; + return ((TileShelf) tile).rotation != rotation; + } + + @Override + public void renderInventoryBlock(Block block, int metadata, int modelId, + RenderBlocks renderer) { GL11.glPushMatrix(); GL11.glTranslatef(0, 0.9f, 0); GL11.glScalef(1f, 1f, 1f); @@ -58,13 +60,12 @@ public class BlockBeamRenderer extends BlockRendererInterface{ GL11.glColor3f(1, 1, 1); model.render(null, 0, 0, 0, 0, 0.0F, 0.0625F); - GL11.glPopMatrix(); - } + GL11.glPopMatrix(); + } - - @Override - public int getRenderId() { - return CustomItems.beam.getRenderType(); - } + @Override + public int getRenderId() { + return CustomItems.beam.getRenderType(); + } } diff --git a/src/main/java/noppes/npcs/client/renderer/blocks/BlockBigSignRenderer.java b/src/main/java/noppes/npcs/client/renderer/blocks/BlockBigSignRenderer.java index eb66276f9..ff45286bb 100644 --- a/src/main/java/noppes/npcs/client/renderer/blocks/BlockBigSignRenderer.java +++ b/src/main/java/noppes/npcs/client/renderer/blocks/BlockBigSignRenderer.java @@ -17,109 +17,110 @@ import noppes.npcs.client.model.blocks.ModelBigSign; import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; -public class BlockBigSignRenderer extends BlockRendererInterface{ +public class BlockBigSignRenderer extends BlockRendererInterface { private final ModelBigSign model = new ModelBigSign(); private static final ResourceLocation resource = new ResourceLocation("customnpcs:textures/models/BigSign.png"); - - public BlockBigSignRenderer(){ - ((BlockBigSign)CustomItems.bigsign).renderId = RenderingRegistry.getNextAvailableRenderId(); - RenderingRegistry.registerBlockHandler(this); - } - @Override - public void renderTileEntityAt(TileEntity var1, double var2, double var4, - double var6, float var8) { + + public BlockBigSignRenderer() { + ((BlockBigSign) CustomItems.bigsign).renderId = RenderingRegistry.getNextAvailableRenderId(); + RenderingRegistry.registerBlockHandler(this); + } + + @Override + public void renderTileEntityAt(TileEntity var1, double var2, double var4, + double var6, float var8) { Block block = var1.getBlockType(); - TileBigSign tile = (TileBigSign) var1; - Minecraft mc = Minecraft.getMinecraft(); - if(tile.block == null || tile.hasChanged){ - tile.block = new TextBlockClient(tile.getText(), 112, true, mc.thePlayer); - tile.hasChanged = false; - } + TileBigSign tile = (TileBigSign) var1; + Minecraft mc = Minecraft.getMinecraft(); + if (tile.block == null || tile.hasChanged) { + tile.block = new TextBlockClient(tile.getText(), 112, true, mc.thePlayer); + tile.hasChanged = false; + } GL11.glDisable(GL12.GL_RESCALE_NORMAL); GL11.glPushMatrix(); float xOffset = 0, yOffset = 0; - if(tile.rotation == 1) - xOffset = -0.44f; - else if(tile.rotation == 3) - xOffset = 0.44f; - else if(tile.rotation == 2) - yOffset = -0.44f; - else if(tile.rotation == 0) - yOffset = 0.44f; - - GL11.glTranslatef((float)var2 + 0.5f + xOffset, (float)var4 + 0.5f, (float)var6 + 0.5f + yOffset); + if (tile.rotation == 1) + xOffset = -0.44f; + else if (tile.rotation == 3) + xOffset = 0.44f; + else if (tile.rotation == 2) + yOffset = -0.44f; + else if (tile.rotation == 0) + yOffset = 0.44f; + + GL11.glTranslatef((float) var2 + 0.5f + xOffset, (float) var4 + 0.5f, (float) var6 + 0.5f + yOffset); float f1 = 0.6666667F; GL11.glRotatef(90 * tile.rotation, 0, 1, 0); GL11.glColor3f(1, 1, 1); - if(tile.rotation % 2 == 0) + if (tile.rotation % 2 == 0) GL11.glRotatef(180, 0, 1, 0); GL11.glPushMatrix(); GL11.glRotatef(180, 1, 0, 0); GL11.glRotatef(180, 0, 0, 1); - TextureManager manager = Minecraft.getMinecraft().getTextureManager(); - manager.bindTexture(resource); + TextureManager manager = Minecraft.getMinecraft().getTextureManager(); + manager.bindTexture(resource); model.renderSign(); - GL11.glPopMatrix(); - if(!tile.block.lines.isEmpty() && !this.playerTooFar(tile)){ - - float f3 = 0.0133F * f1; - GL11.glTranslatef(0.0F, 0.5f, 0.065F); - GL11.glScalef(f3, -f3, f3); - GL11.glNormal3f(0.0F, 0.0F, -1.0F * f3); - GL11.glDepthMask(false); - FontRenderer fontrenderer = this.func_147498_b(); - - float lineOffset = 0; - if(tile.block.lines.size() < 14) - lineOffset = (14f - tile.block.lines.size()) / 2; - for(int i = 0; i < tile.block.lines.size(); i++){ - String text = tile.block.lines.get(i).getFormattedText(); - fontrenderer.drawString(text, -fontrenderer.getStringWidth(text) / 2, (int)((lineOffset + i) * (fontrenderer.FONT_HEIGHT - 0.3)), 0); - if(i == 12) - break; - } - - GL11.glDepthMask(true); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - } - GL11.glPopMatrix(); - } + GL11.glPopMatrix(); + if (!tile.block.lines.isEmpty() && !this.playerTooFar(tile)) { - @Override - public void renderInventoryBlock(Block block, int metadata, int modelId, - RenderBlocks renderer) { + float f3 = 0.0133F * f1; + GL11.glTranslatef(0.0F, 0.5f, 0.065F); + GL11.glScalef(f3, -f3, f3); + GL11.glNormal3f(0.0F, 0.0F, -1.0F * f3); + GL11.glDepthMask(false); + FontRenderer fontrenderer = this.func_147498_b(); + + float lineOffset = 0; + if (tile.block.lines.size() < 14) + lineOffset = (14f - tile.block.lines.size()) / 2; + for (int i = 0; i < tile.block.lines.size(); i++) { + String text = tile.block.lines.get(i).getFormattedText(); + fontrenderer.drawString(text, -fontrenderer.getStringWidth(text) / 2, (int) ((lineOffset + i) * (fontrenderer.FONT_HEIGHT - 0.3)), 0); + if (i == 12) + break; + } + + GL11.glDepthMask(true); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + } + GL11.glPopMatrix(); + } + + @Override + public void renderInventoryBlock(Block block, int metadata, int modelId, + RenderBlocks renderer) { GL11.glPushMatrix(); GL11.glRotatef(180, 0, 0, 1); GL11.glRotatef(180, 0, 1, 0); - TextureManager manager = Minecraft.getMinecraft().getTextureManager(); - manager.bindTexture(resource); + TextureManager manager = Minecraft.getMinecraft().getTextureManager(); + manager.bindTexture(resource); GL11.glColor3f(1, 1, 1); model.renderSign(); - - GL11.glPopMatrix(); - } + + GL11.glPopMatrix(); + } - @Override - public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, - Block block, int modelId, RenderBlocks renderer) { - return false; - } + @Override + public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, + Block block, int modelId, RenderBlocks renderer) { + return false; + } - @Override - public boolean shouldRender3DInInventory(int modelId) { - return true; - } + @Override + public boolean shouldRender3DInInventory(int modelId) { + return true; + } - @Override - public int getRenderId() { - return CustomItems.bigsign.getRenderType(); - } + @Override + public int getRenderId() { + return CustomItems.bigsign.getRenderType(); + } } diff --git a/src/main/java/noppes/npcs/client/renderer/blocks/BlockBloodRenderer.java b/src/main/java/noppes/npcs/client/renderer/blocks/BlockBloodRenderer.java index 556502c00..4c4b5d020 100644 --- a/src/main/java/noppes/npcs/client/renderer/blocks/BlockBloodRenderer.java +++ b/src/main/java/noppes/npcs/client/renderer/blocks/BlockBloodRenderer.java @@ -8,41 +8,41 @@ import noppes.npcs.CustomItems; public class BlockBloodRenderer implements ISimpleBlockRenderingHandler { - @Override - public void renderInventoryBlock(Block block, int metadata, int modelId, - RenderBlocks renderer) { - renderer.renderStandardBlock(block, 0, 0, 0); - } + @Override + public void renderInventoryBlock(Block block, int metadata, int modelId, + RenderBlocks renderer) { + renderer.renderStandardBlock(block, 0, 0, 0); + } - @Override - public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, - Block block, int modelId, RenderBlocks renderer) { - if (!shouldDraw(world, x, y, z, block)) - return false; - renderer.setRenderFromInside(true); - renderer.renderStandardBlock(block, x, y, z); - renderer.setRenderFromInside(false); - return true; - } + @Override + public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, + Block block, int modelId, RenderBlocks renderer) { + if (!shouldDraw(world, x, y, z, block)) + return false; + renderer.setRenderFromInside(true); + renderer.renderStandardBlock(block, x, y, z); + renderer.setRenderFromInside(false); + return true; + } - private boolean shouldDraw(IBlockAccess world, int x, int y, int z, - Block block) { - return block.shouldSideBeRendered(world, x + 1, y, z, 0) - || block.shouldSideBeRendered(world, x - 1, y, z, 0) - || block.shouldSideBeRendered(world, x, y + 1, z, 0) - || block.shouldSideBeRendered(world, x, y - 1, z, 0) - || block.shouldSideBeRendered(world, x, y, z + 1, 0) - || block.shouldSideBeRendered(world, x, y, z - 1, 0); - } + private boolean shouldDraw(IBlockAccess world, int x, int y, int z, + Block block) { + return block.shouldSideBeRendered(world, x + 1, y, z, 0) + || block.shouldSideBeRendered(world, x - 1, y, z, 0) + || block.shouldSideBeRendered(world, x, y + 1, z, 0) + || block.shouldSideBeRendered(world, x, y - 1, z, 0) + || block.shouldSideBeRendered(world, x, y, z + 1, 0) + || block.shouldSideBeRendered(world, x, y, z - 1, 0); + } - @Override - public boolean shouldRender3DInInventory(int modelId) { - return false; - } + @Override + public boolean shouldRender3DInInventory(int modelId) { + return false; + } - @Override - public int getRenderId() { - return CustomItems.blood.getRenderType(); - } + @Override + public int getRenderId() { + return CustomItems.blood.getRenderType(); + } } diff --git a/src/main/java/noppes/npcs/client/renderer/blocks/BlockBookRenderer.java b/src/main/java/noppes/npcs/client/renderer/blocks/BlockBookRenderer.java index bae25201e..bf06129c1 100644 --- a/src/main/java/noppes/npcs/client/renderer/blocks/BlockBookRenderer.java +++ b/src/main/java/noppes/npcs/client/renderer/blocks/BlockBookRenderer.java @@ -15,70 +15,71 @@ import noppes.npcs.client.model.blocks.ModelInk; import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; -public class BlockBookRenderer extends BlockRendererInterface{ +public class BlockBookRenderer extends BlockRendererInterface { - private final ModelInk ink = new ModelInk(); + private final ModelInk ink = new ModelInk(); private final ResourceLocation resource = new ResourceLocation("textures/entity/enchanting_table_book.png"); private final ResourceLocation resource2 = new ResourceLocation("customnpcs:textures/models/Ink.png"); private final ModelBook book = new ModelBook(); - public BlockBookRenderer(){ - ((BlockRotated)CustomItems.book).renderId = RenderingRegistry.getNextAvailableRenderId(); - RenderingRegistry.registerBlockHandler(this); - } - @Override - public void renderTileEntityAt(TileEntity var1, double var2, double var4, - double var6, float var8) { - TileVariant tile = (TileVariant) var1; + public BlockBookRenderer() { + ((BlockRotated) CustomItems.book).renderId = RenderingRegistry.getNextAvailableRenderId(); + RenderingRegistry.registerBlockHandler(this); + } + + @Override + public void renderTileEntityAt(TileEntity var1, double var2, double var4, + double var6, float var8) { + TileVariant tile = (TileVariant) var1; GL11.glDisable(GL12.GL_RESCALE_NORMAL); GL11.glPushMatrix(); - GL11.glTranslatef((float)var2 + 0.5f, (float)var4 + 1.5f, (float)var6 + 0.5f); + GL11.glTranslatef((float) var2 + 0.5f, (float) var4 + 1.5f, (float) var6 + 0.5f); //GL11.glScalef(0.85f, 0.85f, 0.7f); GL11.glRotatef(180, 0, 0, 1); GL11.glRotatef(90 * tile.rotation - 90, 0, 1, 0); GL11.glColor3f(1, 1, 1); - TextureManager manager = Minecraft.getMinecraft().getTextureManager(); - manager.bindTexture(resource2); - if(!playerTooFar(tile)){ - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - } + TextureManager manager = Minecraft.getMinecraft().getTextureManager(); + manager.bindTexture(resource2); + if (!playerTooFar(tile)) { + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + } ink.render(null, 0, 0, 0, 0, 0.0F, 0.0625F); - manager.bindTexture(resource); + manager.bindTexture(resource); GL11.glRotatef(-90, 0, 0, 1); GL11.glTranslatef(-1.49f, -0.18f, 0); book.render(null, 0, 0, 1, 1.24f, 1.0F, 0.0625F); GL11.glDisable(GL11.GL_BLEND); - GL11.glPopMatrix(); - } + GL11.glPopMatrix(); + } - @Override - public void renderInventoryBlock(Block block, int metadata, int modelId, - RenderBlocks renderer) { + @Override + public void renderInventoryBlock(Block block, int metadata, int modelId, + RenderBlocks renderer) { GL11.glPushMatrix(); GL11.glTranslatef(0.2f, 1.7f, 0); GL11.glScalef(1.4f, 1.4f, 1.4f); GL11.glRotatef(180, 0, 0, 1); GL11.glRotatef(180, 0, 1, 0); - GL11.glRotatef( -90, 0, 1, 0); + GL11.glRotatef(-90, 0, 1, 0); GL11.glColor3f(1, 1, 1); GL11.glEnable(GL11.GL_CULL_FACE); - TextureManager manager = Minecraft.getMinecraft().getTextureManager(); - manager.bindTexture(resource2); + TextureManager manager = Minecraft.getMinecraft().getTextureManager(); + manager.bindTexture(resource2); ink.render(null, 0, 0, 0, 0, 0.0F, 0.0625F); - manager.bindTexture(resource); + manager.bindTexture(resource); GL11.glRotatef(-90, 0, 0, 1); GL11.glTranslatef(-1.45f, -0.18f, 0); book.render(null, 0, 0, 1, 1.24f, 1.0F, 0.0625F); - GL11.glPopMatrix(); - } + GL11.glPopMatrix(); + } - @Override - public int getRenderId() { - return CustomItems.book.getRenderType(); - } + @Override + public int getRenderId() { + return CustomItems.book.getRenderType(); + } } diff --git a/src/main/java/noppes/npcs/client/renderer/blocks/BlockBorderRenderer.java b/src/main/java/noppes/npcs/client/renderer/blocks/BlockBorderRenderer.java index 774e96e17..4dc763658 100644 --- a/src/main/java/noppes/npcs/client/renderer/blocks/BlockBorderRenderer.java +++ b/src/main/java/noppes/npcs/client/renderer/blocks/BlockBorderRenderer.java @@ -10,43 +10,43 @@ import noppes.npcs.blocks.BlockBorder; import noppes.npcs.blocks.tiles.TileBorder; import org.lwjgl.opengl.GL11; -public class BlockBorderRenderer implements ISimpleBlockRenderingHandler{ - public BlockBorderRenderer(){ - ((BlockBorder)CustomItems.border).renderId = RenderingRegistry.getNextAvailableRenderId(); +public class BlockBorderRenderer implements ISimpleBlockRenderingHandler { + public BlockBorderRenderer() { + ((BlockBorder) CustomItems.border).renderId = RenderingRegistry.getNextAvailableRenderId(); } - @Override - public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, - Block block, int modelId, RenderBlocks renderer) { - TileBorder tile = (TileBorder) world.getTileEntity(x, y, z); - - GL11.glPushMatrix(); - if(tile.rotation == 1) - renderer.uvRotateTop = 1; - else if(tile.rotation == 3) - renderer.uvRotateTop = 2; - else if(tile.rotation == 2) - renderer.uvRotateTop = 3; - - renderer.renderStandardBlock(CustomItems.border, x, y, z); - renderer.uvRotateTop = 0; - GL11.glPopMatrix(); - return true; - } + @Override + public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, + Block block, int modelId, RenderBlocks renderer) { + TileBorder tile = (TileBorder) world.getTileEntity(x, y, z); - @Override - public boolean shouldRender3DInInventory(int modelId) { - return false; - } + GL11.glPushMatrix(); + if (tile.rotation == 1) + renderer.uvRotateTop = 1; + else if (tile.rotation == 3) + renderer.uvRotateTop = 2; + else if (tile.rotation == 2) + renderer.uvRotateTop = 3; + + renderer.renderStandardBlock(CustomItems.border, x, y, z); + renderer.uvRotateTop = 0; + GL11.glPopMatrix(); + return true; + } + + @Override + public boolean shouldRender3DInInventory(int modelId) { + return false; + } - @Override - public int getRenderId() { - return CustomItems.border.getRenderType(); - } + @Override + public int getRenderId() { + return CustomItems.border.getRenderType(); + } - @Override - public void renderInventoryBlock(Block block, int metadata, int modelId, - RenderBlocks renderer) { - } + @Override + public void renderInventoryBlock(Block block, int metadata, int modelId, + RenderBlocks renderer) { + } } diff --git a/src/main/java/noppes/npcs/client/renderer/blocks/BlockCampfireRenderer.java b/src/main/java/noppes/npcs/client/renderer/blocks/BlockCampfireRenderer.java index 7632b2849..ef072a19c 100644 --- a/src/main/java/noppes/npcs/client/renderer/blocks/BlockCampfireRenderer.java +++ b/src/main/java/noppes/npcs/client/renderer/blocks/BlockCampfireRenderer.java @@ -21,7 +21,7 @@ import org.lwjgl.opengl.GL12; public class BlockCampfireRenderer extends BlockRendererInterface { // Legacy - private final ModelCampfire legacy_model = new ModelCampfire(); + private final ModelCampfire legacy_model = new ModelCampfire(); // Modern private final ModelCampfireFlame flameModel = new ModelCampfireFlame(); @@ -29,40 +29,39 @@ public class BlockCampfireRenderer extends BlockRendererInterface { private final ModelCampfireStone stonesModel = new ModelCampfireStone(); private final ModelCampfireCoals coalsModel = new ModelCampfireCoals(); - protected static final ResourceLocation coalsTexture = new ResourceLocation("customnpcs","textures/models/CampfireCoals.png"); + protected static final ResourceLocation coalsTexture = new ResourceLocation("customnpcs", "textures/models/CampfireCoals.png"); - public BlockCampfireRenderer(){ - ((BlockRotated)CustomItems.campfire).renderId = RenderingRegistry.getNextAvailableRenderId(); - ((BlockRotated)CustomItems.campfire_unlit).renderId = ((BlockRotated)CustomItems.campfire).renderId; - RenderingRegistry.registerBlockHandler(this); + public BlockCampfireRenderer() { + ((BlockRotated) CustomItems.campfire).renderId = RenderingRegistry.getNextAvailableRenderId(); + ((BlockRotated) CustomItems.campfire_unlit).renderId = ((BlockRotated) CustomItems.campfire).renderId; + RenderingRegistry.registerBlockHandler(this); } - @Override - public void renderTileEntityAt(TileEntity var1, double var2, double var4, - double var6, float var8) { - TileVariant tile = (TileVariant) var1; + @Override + public void renderTileEntityAt(TileEntity var1, double var2, double var4, + double var6, float var8) { + TileVariant tile = (TileVariant) var1; GL11.glDisable(GL12.GL_RESCALE_NORMAL); GL11.glPushMatrix(); - GL11.glTranslatef((float)var2 + 0.5f, (float)var4 + 1.5f, (float)var6 + 0.5f); + GL11.glTranslatef((float) var2 + 0.5f, (float) var4 + 1.5f, (float) var6 + 0.5f); GL11.glRotatef(180, 0, 0, 1); GL11.glRotatef(45 * tile.rotation, 0, 1, 0); GL11.glColor3f(1, 1, 1); - if(ConfigClient.LegacyCampfire){ + if (ConfigClient.LegacyCampfire) { Minecraft.getMinecraft().getTextureManager().bindTexture(PlanksOak); legacy_model.renderLog(0.0625F); Minecraft.getMinecraft().getTextureManager().bindTexture(Stone); legacy_model.renderRock(0.0625F); - } - else { + } else { Block block = tile.getBlockType(); Minecraft.getMinecraft().getTextureManager().bindTexture(Logs); logsModel.render(null, 0, 0, 0, 0, 0.0F, 0.0625F); Minecraft.getMinecraft().getTextureManager().bindTexture(Cobble); stonesModel.render(null, 0, 0, 0, 0, 0.0F, 0.0625F); - if(block == CustomItems.campfire){ + if (block == CustomItems.campfire) { GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS); GL11.glDisable(GL11.GL_LIGHTING); GL11.glEnable(GL11.GL_ALPHA_TEST); @@ -76,12 +75,12 @@ public class BlockCampfireRenderer extends BlockRendererInterface { coalsModel.render(null, 0, 0, 0, 0, 0.0F, 0.0625F); } - GL11.glPopMatrix(); - } + GL11.glPopMatrix(); + } - @Override - public void renderInventoryBlock(Block block, int metadata, int modelId, - RenderBlocks renderer) { + @Override + public void renderInventoryBlock(Block block, int metadata, int modelId, + RenderBlocks renderer) { GL11.glPushMatrix(); GL11.glTranslatef(0, 1.2f, 0); GL11.glScalef(1f, 1f, 1f); @@ -89,29 +88,28 @@ public class BlockCampfireRenderer extends BlockRendererInterface { GL11.glRotatef(180, 0, 1, 0); GL11.glColor3f(1, 1, 1); - if(ConfigClient.LegacyCampfire){ + if (ConfigClient.LegacyCampfire) { Minecraft.getMinecraft().getTextureManager().bindTexture(PlanksOak); legacy_model.renderLog(0.0625F); Minecraft.getMinecraft().getTextureManager().bindTexture(Stone); legacy_model.renderRock(0.0625F); - } - else { + } else { Minecraft.getMinecraft().getTextureManager().bindTexture(Logs); logsModel.render(null, 0, 0, 0, 0, 0.0F, 0.0625F); Minecraft.getMinecraft().getTextureManager().bindTexture(Cobble); stonesModel.render(null, 0, 0, 0, 0, 0.0F, 0.0625F); } - GL11.glPopMatrix(); - } + GL11.glPopMatrix(); + } @Override public boolean shouldRender3DInInventory(int modelId) { return ConfigClient.LegacyCampfire; } - @Override - public int getRenderId() { - return CustomItems.campfire.getRenderType(); - } + @Override + public int getRenderId() { + return CustomItems.campfire.getRenderType(); + } } diff --git a/src/main/java/noppes/npcs/client/renderer/blocks/BlockCandleRenderer.java b/src/main/java/noppes/npcs/client/renderer/blocks/BlockCandleRenderer.java index 61be97441..dd7440b37 100644 --- a/src/main/java/noppes/npcs/client/renderer/blocks/BlockCandleRenderer.java +++ b/src/main/java/noppes/npcs/client/renderer/blocks/BlockCandleRenderer.java @@ -22,65 +22,63 @@ import noppes.npcs.config.ConfigClient; import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; -public class BlockCandleRenderer extends TileEntitySpecialRenderer implements ISimpleBlockRenderingHandler{ +public class BlockCandleRenderer extends TileEntitySpecialRenderer implements ISimpleBlockRenderingHandler { - private final ModelLegacyCandle legacyCandle = new ModelLegacyCandle(); - private final ModelLegacyCandleWall legacyCandleWall = new ModelLegacyCandleWall(); - private final ModelLegacyCandleCeiling legacyCandleCeiling = new ModelLegacyCandleCeiling(); + private final ModelLegacyCandle legacyCandle = new ModelLegacyCandle(); + private final ModelLegacyCandleWall legacyCandleWall = new ModelLegacyCandleWall(); + private final ModelLegacyCandleCeiling legacyCandleCeiling = new ModelLegacyCandleCeiling(); private final ModelCandle candle = new ModelCandle(); private final ModelCandleWall candleWall = new ModelCandleWall(); private final ModelCandleCeiling candleCeiling = new ModelCandleCeiling(); - private static final ResourceLocation legacy = new ResourceLocation("customnpcs","textures/models/legacy/Candle.png"); - private static final ResourceLocation texture = new ResourceLocation("customnpcs","textures/models/candle.png"); + private static final ResourceLocation legacy = new ResourceLocation("customnpcs", "textures/models/legacy/Candle.png"); + private static final ResourceLocation texture = new ResourceLocation("customnpcs", "textures/models/candle.png"); - public BlockCandleRenderer(){ - ((BlockCandle)CustomItems.candle).renderId = RenderingRegistry.getNextAvailableRenderId(); - ((BlockCandle)CustomItems.candle_unlit).renderId = ((BlockCandle)CustomItems.candle).renderId; - RenderingRegistry.registerBlockHandler(this); + public BlockCandleRenderer() { + ((BlockCandle) CustomItems.candle).renderId = RenderingRegistry.getNextAvailableRenderId(); + ((BlockCandle) CustomItems.candle_unlit).renderId = ((BlockCandle) CustomItems.candle).renderId; + RenderingRegistry.registerBlockHandler(this); } - @Override - public void renderTileEntityAt(TileEntity var1, double var2, double var4, - double var6, float var8) { - TileCandle tile = (TileCandle) var1; + @Override + public void renderTileEntityAt(TileEntity var1, double var2, double var4, + double var6, float var8) { + TileCandle tile = (TileCandle) var1; GL11.glDisable(GL12.GL_RESCALE_NORMAL); GL11.glPushMatrix(); - GL11.glTranslatef((float)var2 + 0.5f, (float)var4 + 1.5f, (float)var6 + 0.5f); + GL11.glTranslatef((float) var2 + 0.5f, (float) var4 + 1.5f, (float) var6 + 0.5f); //GL11.glScalef(0.95f, 0.95f, 0.95f); GL11.glRotatef(180, 0, 0, 1); GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS); GL11.glEnable(GL11.GL_ALPHA_TEST); - if(ConfigClient.LegacyCandle){ + if (ConfigClient.LegacyCandle) { GL11.glRotatef(45 * tile.rotation, 0, 1, 0); GL11.glColor3f(1, 1, 1); Minecraft.getMinecraft().getTextureManager().bindTexture(legacy); - if(tile.variant == 0) + if (tile.variant == 0) legacyCandle.render(null, 0, 0, 0, 0, 0.0F, 0.0625F); - else if(tile.variant == 1) + else if (tile.variant == 1) legacyCandleCeiling.render(null, 0, 0, 0, 0, 0.0F, 0.0625F); - else{ + else { GL11.glRotatef(180, 0, 1, 0); legacyCandleWall.render(null, 0, 0, 0, 0, 0.0F, 0.0625F); } } else { Minecraft.getMinecraft().getTextureManager().bindTexture(texture); - if(tile.variant == 0){ + if (tile.variant == 0) { GL11.glRotatef(45 * tile.rotation, 0, 1, 0); GL11.glColor3f(1, 1, 1); candle.render(null, 0, 0, 0, 0, 0.0F, 0.0625F); - } - else if(tile.variant == 1){ + } else if (tile.variant == 1) { GL11.glPushMatrix(); GL11.glColor3f(1, 1, 1); - GL11.glRotatef( 90, 0, 1, 0); + GL11.glRotatef(90, 0, 1, 0); candleCeiling.Chain.render(0.0625F); GL11.glPopMatrix(); GL11.glRotatef(45 * tile.rotation, 0, 1, 0); candleCeiling.render(null, 0, 0, 0, 0, 0.0F, 0.0625F); - } - else{ + } else { GL11.glRotatef(45 * tile.rotation, 0, 1, 0); GL11.glColor3f(1, 1, 1); candleWall.render(null, 0, 0, 0, 0, 0.0F, 0.0625F); @@ -88,19 +86,19 @@ public class BlockCandleRenderer extends TileEntitySpecialRenderer implements IS } GL11.glDisable(GL11.GL_ALPHA_TEST); GL11.glPopAttrib(); - GL11.glPopMatrix(); - } + GL11.glPopMatrix(); + } - @Override - public void renderInventoryBlock(Block block, int metadata, int modelId, - RenderBlocks renderer) { + @Override + public void renderInventoryBlock(Block block, int metadata, int modelId, + RenderBlocks renderer) { GL11.glPushMatrix(); GL11.glTranslatef(0, 2.6f, 0); GL11.glScalef(2f, 2f, 2f); GL11.glRotatef(180, 0, 0, 1); GL11.glRotatef(180, 0, 1, 0); - if(ConfigClient.LegacyCandle){ + if (ConfigClient.LegacyCandle) { Minecraft.getMinecraft().getTextureManager().bindTexture(legacy); GL11.glColor3f(1, 1, 1); legacyCandle.render(null, 0, 0, 0, 0, 0.0F, 0.0625F); @@ -110,25 +108,25 @@ public class BlockCandleRenderer extends TileEntitySpecialRenderer implements IS candle.render(null, 0, 0, 0, 0, 0.0F, 0.0625F); } - GL11.glPopMatrix(); - } + GL11.glPopMatrix(); + } - @Override - public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, - Block block, int modelId, RenderBlocks renderer) { - return false; - } + @Override + public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, + Block block, int modelId, RenderBlocks renderer) { + return false; + } - @Override - public boolean shouldRender3DInInventory(int modelId) { - return ConfigClient.LegacyCandle; - } + @Override + public boolean shouldRender3DInInventory(int modelId) { + return ConfigClient.LegacyCandle; + } - @Override - public int getRenderId() { - return CustomItems.candle.getRenderType(); - } + @Override + public int getRenderId() { + return CustomItems.candle.getRenderType(); + } } diff --git a/src/main/java/noppes/npcs/client/renderer/blocks/BlockCarpentryBenchRenderer.java b/src/main/java/noppes/npcs/client/renderer/blocks/BlockCarpentryBenchRenderer.java index a43e5b91c..23e6955d5 100644 --- a/src/main/java/noppes/npcs/client/renderer/blocks/BlockCarpentryBenchRenderer.java +++ b/src/main/java/noppes/npcs/client/renderer/blocks/BlockCarpentryBenchRenderer.java @@ -18,37 +18,37 @@ import noppes.npcs.client.model.blocks.legacy.ModelLegacyCarpentryBench; import noppes.npcs.config.ConfigClient; import org.lwjgl.opengl.GL11; -public class BlockCarpentryBenchRenderer extends TileEntitySpecialRenderer implements ISimpleBlockRenderingHandler{ +public class BlockCarpentryBenchRenderer extends TileEntitySpecialRenderer implements ISimpleBlockRenderingHandler { - private final ModelCarpentryBench modelCarpentryBench = new ModelCarpentryBench(); - private static final ResourceLocation carpentryBenchTexture = new ResourceLocation("customnpcs","textures/models/CarpentryBench.png"); + private final ModelCarpentryBench modelCarpentryBench = new ModelCarpentryBench(); + private static final ResourceLocation carpentryBenchTexture = new ResourceLocation("customnpcs", "textures/models/CarpentryBench.png"); - private static final ResourceLocation legacyAnvilTexture = new ResourceLocation("customnpcs","textures/models/legacy/Steel.png"); - private static final ResourceLocation anvilTexture = new ResourceLocation("customnpcs","textures/models/anvil.png"); + private static final ResourceLocation legacyAnvilTexture = new ResourceLocation("customnpcs", "textures/models/legacy/Steel.png"); + private static final ResourceLocation anvilTexture = new ResourceLocation("customnpcs", "textures/models/anvil.png"); private final ModelLegacyCarpentryBench legacyBench = new ModelLegacyCarpentryBench(); - private static final ResourceLocation legacyCarpentryBench = new ResourceLocation("customnpcs","textures/models/legacy/bench.png"); + private static final ResourceLocation legacyCarpentryBench = new ResourceLocation("customnpcs", "textures/models/legacy/bench.png"); private final ModelLegacyAnvil legacyAnvil = new ModelLegacyAnvil(); private final ModelAnvil anvil = new ModelAnvil(); - public BlockCarpentryBenchRenderer(){ - ((BlockCarpentryBench)CustomItems.carpentyBench).renderId = RenderingRegistry.getNextAvailableRenderId(); - RenderingRegistry.registerBlockHandler(this); + public BlockCarpentryBenchRenderer() { + ((BlockCarpentryBench) CustomItems.carpentyBench).renderId = RenderingRegistry.getNextAvailableRenderId(); + RenderingRegistry.registerBlockHandler(this); } - @Override - public void renderTileEntityAt(TileEntity var1, double var2, double var4, - double var6, float var8) { - int meta = var1.getBlockMetadata(); + @Override + public void renderTileEntityAt(TileEntity var1, double var2, double var4, + double var6, float var8) { + int meta = var1.getBlockMetadata(); GL11.glPushMatrix(); - GL11.glTranslatef((float)var2 + 0.5f, (float)var4 +1.4f, (float)var6 + 0.5f); + GL11.glTranslatef((float) var2 + 0.5f, (float) var4 + 1.4f, (float) var6 + 0.5f); GL11.glScalef(0.99f, 0.99f, 0.99f); GL11.glRotatef(180, 0, 0, 1); GL11.glRotatef(90 * (meta % 4), 0, 1, 0); GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS); - if(meta >= 4){ - if(ConfigClient.LegacyAnvil){ + if (meta >= 4) { + if (ConfigClient.LegacyAnvil) { this.bindTexture(legacyAnvilTexture); legacyAnvil.render(null, 0, 0, 0, 0, 0.0F, 0.0625F); } else { @@ -64,21 +64,20 @@ public class BlockCarpentryBenchRenderer extends TileEntitySpecialRenderer imple int fullBright = 0xF000F0; int fullBrightX = fullBright % 65536; int fullBrightY = fullBright / 65536; - OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float)fullBrightX, (float)fullBrightY); + OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float) fullBrightX, (float) fullBrightY); // Render the lava part glowing anvil.Lava.render(0.0625F); - OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float)brightX, (float)brightY); + OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float) brightX, (float) brightY); // Now render the rest (the anvil) normally anvil.render(null, 0, 0, 0, 0, 0.0F, 0.0625F); GL11.glDisable(GL11.GL_ALPHA_TEST); } - } - else { + } else { GL11.glEnable(GL11.GL_ALPHA_TEST); - if(ConfigClient.LegacyCarpentryBench){ + if (ConfigClient.LegacyCarpentryBench) { this.bindTexture(legacyCarpentryBench); legacyBench.render(null, 0, 0, 0, 0, 0.0F, 0.0625F); } else { @@ -88,30 +87,29 @@ public class BlockCarpentryBenchRenderer extends TileEntitySpecialRenderer imple GL11.glDisable(GL11.GL_ALPHA_TEST); } GL11.glPopAttrib(); - GL11.glPopMatrix(); - } + GL11.glPopMatrix(); + } - @Override - public void renderInventoryBlock(Block block, int metadata, int modelId, - RenderBlocks renderer) { + @Override + public void renderInventoryBlock(Block block, int metadata, int modelId, + RenderBlocks renderer) { GL11.glPushMatrix(); GL11.glTranslatef(0, 0.85f, 0); GL11.glRotatef(180, 0, 0, 1); GL11.glRotatef(180, 0, 1, 0); GL11.glColor3f(1, 1, 1); - if(metadata == 0){ - if(ConfigClient.LegacyCarpentryBench){ + if (metadata == 0) { + if (ConfigClient.LegacyCarpentryBench) { this.bindTexture(legacyCarpentryBench); legacyBench.render(null, 0, 0, 0, 0, 0.0F, 0.0625F); } else { this.bindTexture(carpentryBenchTexture); modelCarpentryBench.render(null, 0, 0, 0, 0, 0.0F, 0.0625F); } - } - else{ - if(ConfigClient.LegacyAnvil){ + } else { + if (ConfigClient.LegacyAnvil) { this.bindTexture(legacyAnvilTexture); legacyAnvil.render(null, 0, 0, 0, 0, 0.0F, 0.0625F); } else { @@ -121,26 +119,26 @@ public class BlockCarpentryBenchRenderer extends TileEntitySpecialRenderer imple } } - GL11.glPopMatrix(); - } + GL11.glPopMatrix(); + } - @Override - public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, - Block block, int modelId, RenderBlocks renderer) { + @Override + public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, + Block block, int modelId, RenderBlocks renderer) { - return false; - } + return false; + } - @Override - public boolean shouldRender3DInInventory(int modelId) { - return true; - } + @Override + public boolean shouldRender3DInInventory(int modelId) { + return true; + } - @Override - public int getRenderId() { - return CustomItems.carpentyBench.getRenderType(); - } + @Override + public int getRenderId() { + return CustomItems.carpentyBench.getRenderType(); + } } diff --git a/src/main/java/noppes/npcs/client/renderer/blocks/BlockChairRenderer.java b/src/main/java/noppes/npcs/client/renderer/blocks/BlockChairRenderer.java index 7e196df09..bf35acdab 100644 --- a/src/main/java/noppes/npcs/client/renderer/blocks/BlockChairRenderer.java +++ b/src/main/java/noppes/npcs/client/renderer/blocks/BlockChairRenderer.java @@ -18,41 +18,42 @@ import noppes.npcs.config.ConfigClient; import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; -public class BlockChairRenderer extends BlockRendererInterface{ +public class BlockChairRenderer extends BlockRendererInterface { private final ModelLegacyChair legacyModel = new ModelLegacyChair(); private final ModelChairSpoof chairSpoof = new ModelChairSpoof(); private final ModelChair chair = new ModelChair(); - private static final ResourceLocation oak = new ResourceLocation("customnpcs","textures/models/chair/oak.png"); - private static final ResourceLocation spruce = new ResourceLocation("customnpcs","textures/models/chair/spruce.png"); - private static final ResourceLocation birch = new ResourceLocation("customnpcs","textures/models/chair/birch.png"); - private static final ResourceLocation jungle = new ResourceLocation("customnpcs","textures/models/chair/jungle.png"); - private static final ResourceLocation dark_oak = new ResourceLocation("customnpcs","textures/models/chair/dark_oak.png"); - private static final ResourceLocation acacia = new ResourceLocation("customnpcs","textures/models/chair/acacia.png"); + private static final ResourceLocation oak = new ResourceLocation("customnpcs", "textures/models/chair/oak.png"); + private static final ResourceLocation spruce = new ResourceLocation("customnpcs", "textures/models/chair/spruce.png"); + private static final ResourceLocation birch = new ResourceLocation("customnpcs", "textures/models/chair/birch.png"); + private static final ResourceLocation jungle = new ResourceLocation("customnpcs", "textures/models/chair/jungle.png"); + private static final ResourceLocation dark_oak = new ResourceLocation("customnpcs", "textures/models/chair/dark_oak.png"); + private static final ResourceLocation acacia = new ResourceLocation("customnpcs", "textures/models/chair/acacia.png"); - public BlockChairRenderer(){ - ((BlockChair)CustomItems.chair).renderId = RenderingRegistry.getNextAvailableRenderId(); - RenderingRegistry.registerBlockHandler(this); - } - @Override - public void renderTileEntityAt(TileEntity var1, double var2, double var4, - double var6, float var8) { - TileVariant tile = (TileVariant) var1; + public BlockChairRenderer() { + ((BlockChair) CustomItems.chair).renderId = RenderingRegistry.getNextAvailableRenderId(); + RenderingRegistry.registerBlockHandler(this); + } + + @Override + public void renderTileEntityAt(TileEntity var1, double var2, double var4, + double var6, float var8) { + TileVariant tile = (TileVariant) var1; GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS); GL11.glDisable(GL12.GL_RESCALE_NORMAL); GL11.glPushMatrix(); - GL11.glTranslatef((float)var2 + 0.5f, (float)var4 + 1.5f, (float)var6 + 0.5f); + GL11.glTranslatef((float) var2 + 0.5f, (float) var4 + 1.5f, (float) var6 + 0.5f); // GL11.glScalef(1.2f, 1.1f, 1.2f); GL11.glRotatef(180, 0, 0, 1); // Apply push translation if this is a pushed chair. - if(tile instanceof TileChair) { + if (tile instanceof TileChair) { TileChair chairTile = (TileChair) tile; - if(chairTile.isPushed()) { + if (chairTile.isPushed()) { float pushDistance = 0.6f; // adjust as needed for visual effect - switch(tile.rotation) { + switch (tile.rotation) { case 0: // Facing north – push the model backwards. GL11.glTranslatef(0, 0, -pushDistance); break; @@ -75,10 +76,10 @@ public class BlockChairRenderer extends BlockRendererInterface{ GL11.glEnable(GL11.GL_ALPHA_TEST); setWoodTexture(var1.getBlockMetadata()); - if(ConfigClient.LegacyChair) + if (ConfigClient.LegacyChair) legacyModel.render(null, 0, 0, 0, 0, 0.0F, 0.0625F); else { - if(ConfigClient.WoodTextures) + if (ConfigClient.WoodTextures) chairSpoof.render(null, 0, 0, 0, 0, 0.0F, 0.0625F); else { setChairTexture(var1.getBlockMetadata()); @@ -87,56 +88,55 @@ public class BlockChairRenderer extends BlockRendererInterface{ } GL11.glDisable(GL11.GL_ALPHA_TEST); GL11.glPopAttrib(); - GL11.glPopMatrix(); - } + GL11.glPopMatrix(); + } - @Override - public void renderInventoryBlock(Block block, int metadata, int modelId, - RenderBlocks renderer) { + @Override + public void renderInventoryBlock(Block block, int metadata, int modelId, + RenderBlocks renderer) { GL11.glPushMatrix(); GL11.glTranslatef(0, 1f, 0); GL11.glColor3f(1, 1, 1); - if(ConfigClient.LegacyChair){ + if (ConfigClient.LegacyChair) { setWoodTexture(metadata); GL11.glScalef(1.2f, 1.1f, 1.2f); GL11.glRotatef(180, 0, 0, 1); GL11.glRotatef(180, 0, 1, 0); legacyModel.render(null, 0, 0, 0, 0, 0.0F, 0.0625F); - } - else { + } else { GL11.glTranslatef(0, -0.15f, 0); GL11.glScalef(1f, 0.9f, 1f); GL11.glRotatef(180, 0, 0, 1); GL11.glRotatef(180, 0, 1, 0); - if(ConfigClient.WoodTextures) + if (ConfigClient.WoodTextures) chairSpoof.render(null, 0, 0, 0, 0, 0.0F, 0.0625F); else { setChairTexture(metadata); chair.render(null, 0, 0, 0, 0, 0.0F, 0.0625F); } } - GL11.glPopMatrix(); - } + GL11.glPopMatrix(); + } - public void setChairTexture(int meta){ + public void setChairTexture(int meta) { TextureManager manager = Minecraft.getMinecraft().getTextureManager(); - if(meta == 1) + if (meta == 1) manager.bindTexture(spruce); - else if(meta == 2) + else if (meta == 2) manager.bindTexture(birch); - else if(meta == 3) + else if (meta == 3) manager.bindTexture(jungle); - else if(meta == 4) + else if (meta == 4) manager.bindTexture(acacia); - else if(meta == 5) + else if (meta == 5) manager.bindTexture(dark_oak); else manager.bindTexture(oak); } - @Override - public int getRenderId() { - return CustomItems.chair.getRenderType(); - } + @Override + public int getRenderId() { + return CustomItems.chair.getRenderType(); + } } diff --git a/src/main/java/noppes/npcs/client/renderer/blocks/BlockCouchWoodRenderer.java b/src/main/java/noppes/npcs/client/renderer/blocks/BlockCouchWoodRenderer.java index 15974b322..d8d6f3ea8 100644 --- a/src/main/java/noppes/npcs/client/renderer/blocks/BlockCouchWoodRenderer.java +++ b/src/main/java/noppes/npcs/client/renderer/blocks/BlockCouchWoodRenderer.java @@ -15,45 +15,46 @@ import noppes.npcs.client.model.blocks.legacy.couch.ModelCouchWoodSingle; import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; -public class BlockCouchWoodRenderer extends BlockRendererInterface{ +public class BlockCouchWoodRenderer extends BlockRendererInterface { - private final ModelBase model = new ModelCouchWoodMiddle(); - private final ModelBase modelLeft = new ModelCouchWoodLeft(); - private final ModelBase modelRight = new ModelCouchWoodRight(); - private final ModelBase modelCorner = new ModelCouchWoodSingle(); + private final ModelBase model = new ModelCouchWoodMiddle(); + private final ModelBase modelLeft = new ModelCouchWoodLeft(); + private final ModelBase modelRight = new ModelCouchWoodRight(); + private final ModelBase modelCorner = new ModelCouchWoodSingle(); - public BlockCouchWoodRenderer(){ - ((BlockCouchWood)CustomItems.couchWood).renderId = RenderingRegistry.getNextAvailableRenderId(); - RenderingRegistry.registerBlockHandler(this); + public BlockCouchWoodRenderer() { + ((BlockCouchWood) CustomItems.couchWood).renderId = RenderingRegistry.getNextAvailableRenderId(); + RenderingRegistry.registerBlockHandler(this); } - @Override - public void renderTileEntityAt(TileEntity var1, double var2, double var4, - double var6, float var8) { - TileCouchWood tile = (TileCouchWood) var1; + + @Override + public void renderTileEntityAt(TileEntity var1, double var2, double var4, + double var6, float var8) { + TileCouchWood tile = (TileCouchWood) var1; GL11.glDisable(GL12.GL_RESCALE_NORMAL); GL11.glPushMatrix(); - GL11.glTranslatef((float)var2 + 0.5f, (float)var4 + 1.5f, (float)var6 + 0.5f); + GL11.glTranslatef((float) var2 + 0.5f, (float) var4 + 1.5f, (float) var6 + 0.5f); //GL11.glScalef(0.95f, 0.95f, 0.95f); GL11.glRotatef(180, 0, 0, 1); GL11.glRotatef(90 * tile.rotation, 0, 1, 0); GL11.glColor3f(1, 1, 1); setWoodTexture(var1.getBlockMetadata()); - if(tile.hasLeft && tile.hasRight) - model.render(null, 0, 0, 0, 0, 0.0F, 0.0625F); - else if(tile.hasLeft) - modelLeft.render(null, 0, 0, 0, 0, 0.0F, 0.0625F); - else if(tile.hasRight) - modelRight.render(null, 0, 0, 0, 0, 0.0F, 0.0625F); + if (tile.hasLeft && tile.hasRight) + model.render(null, 0, 0, 0, 0, 0.0F, 0.0625F); + else if (tile.hasLeft) + modelLeft.render(null, 0, 0, 0, 0, 0.0F, 0.0625F); + else if (tile.hasRight) + modelRight.render(null, 0, 0, 0, 0, 0.0F, 0.0625F); else - modelCorner.render(null, 0, 0, 0, 0, 0.0F, 0.0625F); + modelCorner.render(null, 0, 0, 0, 0, 0.0F, 0.0625F); - GL11.glPopMatrix(); - } + GL11.glPopMatrix(); + } - @Override - public void renderInventoryBlock(Block block, int metadata, int modelId, - RenderBlocks renderer) { + @Override + public void renderInventoryBlock(Block block, int metadata, int modelId, + RenderBlocks renderer) { GL11.glPushMatrix(); GL11.glTranslatef(0, 0.9f, 0.1f); GL11.glScalef(0.9f, 0.9f, 0.9f); @@ -64,12 +65,12 @@ public class BlockCouchWoodRenderer extends BlockRendererInterface{ GL11.glColor3f(1, 1, 1); modelCorner.render(null, 0, 0, 0, 0, 0.0F, 0.0625F); - GL11.glPopMatrix(); - } + GL11.glPopMatrix(); + } - @Override - public int getRenderId() { - return CustomItems.couchWood.getRenderType(); - } + @Override + public int getRenderId() { + return CustomItems.couchWood.getRenderType(); + } } diff --git a/src/main/java/noppes/npcs/client/renderer/blocks/BlockCouchWoolRenderer.java b/src/main/java/noppes/npcs/client/renderer/blocks/BlockCouchWoolRenderer.java index 2ce9df885..bba634853 100644 --- a/src/main/java/noppes/npcs/client/renderer/blocks/BlockCouchWoolRenderer.java +++ b/src/main/java/noppes/npcs/client/renderer/blocks/BlockCouchWoolRenderer.java @@ -18,117 +18,116 @@ import noppes.npcs.config.ConfigClient; import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; -public class BlockCouchWoolRenderer extends BlockRendererInterface{ +public class BlockCouchWoolRenderer extends BlockRendererInterface { private final ModelCouchLeft modelCouchLeft = new ModelCouchLeft(); private final ModelCouchRight modelCouchRight = new ModelCouchRight(); private final ModelCouchCorner modelCouchCorner = new ModelCouchCorner(); - public static final ModelCouchMiddle modelCouch = new ModelCouchMiddle(); + public static final ModelCouchMiddle modelCouch = new ModelCouchMiddle(); private final ModelCouchSingle modelCouchSingle = new ModelCouchSingle(); public static final ModelBase modelLegacyCouchMiddle = new ModelLegacyCouchMiddle(); - public static final ModelBase modelLegacyCouchMiddleWool = new ModelLegacyCouchMiddleWool(); + public static final ModelBase modelLegacyCouchMiddleWool = new ModelLegacyCouchMiddleWool(); - private final ModelBase modelLegacyCouchLeft = new ModelLegacyCouchLeft(); - private final ModelBase modelLegacyCouchLeftWool = new ModelLegacyCouchLeftWool(); + private final ModelBase modelLegacyCouchLeft = new ModelLegacyCouchLeft(); + private final ModelBase modelLegacyCouchLeftWool = new ModelLegacyCouchLeftWool(); - private final ModelBase modelLegacyCouchRight = new ModelLegacyCouchRight(); - private final ModelBase modelLegacyCouchRightWool = new ModelLegacyCouchRightWool(); + private final ModelBase modelLegacyCouchRight = new ModelLegacyCouchRight(); + private final ModelBase modelLegacyCouchRightWool = new ModelLegacyCouchRightWool(); - private final ModelBase modelLegacyCouchCorner = new ModelLegacyCouchCorner(); - private final ModelBase modelLegacyCouchCornerWool = new ModelLegacyCouchCornerWool(); + private final ModelBase modelLegacyCouchCorner = new ModelLegacyCouchCorner(); + private final ModelBase modelLegacyCouchCornerWool = new ModelLegacyCouchCornerWool(); - public static final ResourceLocation oak = new ResourceLocation("customnpcs","textures/models/couch/oak.png"); - public static final ResourceLocation spruce = new ResourceLocation("customnpcs","textures/models/couch/spruce.png"); - public static final ResourceLocation birch = new ResourceLocation("customnpcs","textures/models/couch/birch.png"); - public static final ResourceLocation jungle = new ResourceLocation("customnpcs","textures/models/couch/jungle.png"); - public static final ResourceLocation acacia = new ResourceLocation("customnpcs","textures/models/couch/acacia.png"); - public static final ResourceLocation dark_oak = new ResourceLocation("customnpcs","textures/models/couch/dark_oak.png"); + public static final ResourceLocation oak = new ResourceLocation("customnpcs", "textures/models/couch/oak.png"); + public static final ResourceLocation spruce = new ResourceLocation("customnpcs", "textures/models/couch/spruce.png"); + public static final ResourceLocation birch = new ResourceLocation("customnpcs", "textures/models/couch/birch.png"); + public static final ResourceLocation jungle = new ResourceLocation("customnpcs", "textures/models/couch/jungle.png"); + public static final ResourceLocation acacia = new ResourceLocation("customnpcs", "textures/models/couch/acacia.png"); + public static final ResourceLocation dark_oak = new ResourceLocation("customnpcs", "textures/models/couch/dark_oak.png"); - public static final ResourceLocation wool = new ResourceLocation("customnpcs","textures/models/couch/wool.png"); + public static final ResourceLocation wool = new ResourceLocation("customnpcs", "textures/models/couch/wool.png"); - public BlockCouchWoolRenderer(){ - ((BlockCouchWool)CustomItems.couchWool).renderId = RenderingRegistry.getNextAvailableRenderId(); - RenderingRegistry.registerBlockHandler(this); + public BlockCouchWoolRenderer() { + ((BlockCouchWool) CustomItems.couchWool).renderId = RenderingRegistry.getNextAvailableRenderId(); + RenderingRegistry.registerBlockHandler(this); } - @Override - public void renderTileEntityAt(TileEntity var1, double var2, double var4, - double var6, float var8) { - TileCouchWool tile = (TileCouchWool) var1; + + @Override + public void renderTileEntityAt(TileEntity var1, double var2, double var4, + double var6, float var8) { + TileCouchWool tile = (TileCouchWool) var1; GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS); GL11.glDisable(GL12.GL_RESCALE_NORMAL); GL11.glPushMatrix(); - GL11.glTranslatef((float)var2 + 0.5f, (float)var4 + 1.5f, (float)var6 + 0.5f); + GL11.glTranslatef((float) var2 + 0.5f, (float) var4 + 1.5f, (float) var6 + 0.5f); //GL11.glS calef(0.95f, 0.95f, 0.95f); GL11.glRotatef(180, 0, 0, 1); GL11.glRotatef(90 * tile.rotation, 0, 1, 0); GL11.glColor3f(1, 1, 1); GL11.glEnable(GL11.GL_ALPHA_TEST); - if(ConfigClient.LegacyCouch){ + if (ConfigClient.LegacyCouch) { setWoodTexture(var1.getBlockMetadata()); - if(tile.hasCornerLeft) + if (tile.hasCornerLeft) modelLegacyCouchCorner.render(null, 0, 0, 0, 0, 0.0F, 0.0625F); - else if(tile.hasCornerRight){ + else if (tile.hasCornerRight) { GL11.glRotatef(90, 0, 1, 0); modelLegacyCouchCorner.render(null, 0, 0, 0, 0, 0.0F, 0.0625F); - } - else if(tile.hasLeft && tile.hasRight) + } else if (tile.hasLeft && tile.hasRight) modelLegacyCouchMiddle.render(null, 0, 0, 0, 0, 0.0F, 0.0625F); - else if(tile.hasLeft) + else if (tile.hasLeft) modelLegacyCouchLeft.render(null, 0, 0, 0, 0, 0.0F, 0.0625F); - else if(tile.hasRight) + else if (tile.hasRight) modelLegacyCouchRight.render(null, 0, 0, 0, 0, 0.0F, 0.0625F); else modelLegacyCouchMiddle.render(null, 0, 0, 0, 0, 0.0F, 0.0625F); this.bindTexture(BlockTallLampRenderer.resourceTop); - float[] color = ColorUtil.hexToRGB(tile.color); + float[] color = ColorUtil.hexToRGB(tile.color); GL11.glColor3f(color[0], color[1], color[2]); - if(tile.hasCornerLeft || tile.hasCornerRight) + if (tile.hasCornerLeft || tile.hasCornerRight) modelLegacyCouchCornerWool.render(null, 0, 0, 0, 0, 0.0F, 0.0625F); - else if(tile.hasLeft && tile.hasRight) + else if (tile.hasLeft && tile.hasRight) modelLegacyCouchMiddleWool.render(null, 0, 0, 0, 0, 0.0F, 0.0625F); - else if(tile.hasLeft) + else if (tile.hasLeft) modelLegacyCouchLeftWool.render(null, 0, 0, 0, 0, 0.0F, 0.0625F); - else if(tile.hasRight) + else if (tile.hasRight) modelLegacyCouchRightWool.render(null, 0, 0, 0, 0, 0.0F, 0.0625F); else modelLegacyCouchMiddleWool.render(null, 0, 0, 0, 0, 0.0F, 0.0625F); } else { setCouchWood(var1.getBlockMetadata()); - if(tile.hasCornerLeft){ + if (tile.hasCornerLeft) { GL11.glPushMatrix(); GL11.glRotatef(90, 0, 1, 0); modelCouchCorner.CouchBack.render(0.0625F); GL11.glPopMatrix(); - } - else if(tile.hasCornerRight) + } else if (tile.hasCornerRight) modelCouchCorner.CouchBack.render(0.0625F); - else if(tile.hasLeft && tile.hasRight) + else if (tile.hasLeft && tile.hasRight) modelCouch.CouchBack.render(0.0625F); - else if(tile.hasLeft) + else if (tile.hasLeft) modelCouchLeft.CouchBack.render(0.0625F); - else if(tile.hasRight) + else if (tile.hasRight) modelCouchRight.CouchBack.render(0.0625F); else { modelCouchSingle.CouchBack.render(0.0625F); } Minecraft.getMinecraft().getTextureManager().bindTexture(wool); - float[] color = ColorUtil.hexToRGB(tile.color); + float[] color = ColorUtil.hexToRGB(tile.color); GL11.glColor3f(color[0], color[1], color[2]); - if(tile.hasCornerLeft) + if (tile.hasCornerLeft) modelCouchCorner.Cussion.render(0.0625F); - else if(tile.hasCornerRight) + else if (tile.hasCornerRight) modelCouchCorner.Cussion.render(0.0625F); - else if(tile.hasLeft && tile.hasRight) + else if (tile.hasLeft && tile.hasRight) modelCouch.Cussion.render(0.0625F); - else if(tile.hasLeft) + else if (tile.hasLeft) modelCouchLeft.Cussion.render(0.0625F); - else if(tile.hasRight) + else if (tile.hasRight) modelCouchRight.Cussion.render(0.0625F); else { modelCouchSingle.Cussion.render(0.0625F); @@ -136,30 +135,31 @@ public class BlockCouchWoolRenderer extends BlockRendererInterface{ } GL11.glDisable(GL11.GL_ALPHA_TEST); GL11.glPopAttrib(); - GL11.glPopMatrix(); - } + GL11.glPopMatrix(); + } - public void setCouchWood(int meta){ + public void setCouchWood(int meta) { TextureManager manager = Minecraft.getMinecraft().getTextureManager(); - if(meta == 1) + if (meta == 1) manager.bindTexture(spruce); - else if(meta == 2) + else if (meta == 2) manager.bindTexture(birch); - else if(meta == 3) + else if (meta == 3) manager.bindTexture(jungle); - else if(meta == 4) + else if (meta == 4) manager.bindTexture(acacia); - else if(meta == 5) + else if (meta == 5) manager.bindTexture(dark_oak); else manager.bindTexture(oak); } @Override - public void renderInventoryBlock(Block block, int metadata, int modelId, RenderBlocks renderer) {} + public void renderInventoryBlock(Block block, int metadata, int modelId, RenderBlocks renderer) { + } @Override - public int getRenderId() { - return CustomItems.couchWool.getRenderType(); - } + public int getRenderId() { + return CustomItems.couchWool.getRenderType(); + } } diff --git a/src/main/java/noppes/npcs/client/renderer/blocks/BlockCrateRenderer.java b/src/main/java/noppes/npcs/client/renderer/blocks/BlockCrateRenderer.java index 4fa667c57..1a6c92c1c 100644 --- a/src/main/java/noppes/npcs/client/renderer/blocks/BlockCrateRenderer.java +++ b/src/main/java/noppes/npcs/client/renderer/blocks/BlockCrateRenderer.java @@ -11,21 +11,22 @@ import noppes.npcs.client.model.blocks.ModelCrate; import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; -public class BlockCrateRenderer extends BlockRendererInterface{ +public class BlockCrateRenderer extends BlockRendererInterface { - private final ModelCrate model = new ModelCrate(); + private final ModelCrate model = new ModelCrate(); - public BlockCrateRenderer(){ - ((BlockCrate)CustomItems.crate).renderId = RenderingRegistry.getNextAvailableRenderId(); - RenderingRegistry.registerBlockHandler(this); - } - @Override - public void renderTileEntityAt(TileEntity var1, double var2, double var4, - double var6, float var8) { - TileVariant tile = (TileVariant) var1; + public BlockCrateRenderer() { + ((BlockCrate) CustomItems.crate).renderId = RenderingRegistry.getNextAvailableRenderId(); + RenderingRegistry.registerBlockHandler(this); + } + + @Override + public void renderTileEntityAt(TileEntity var1, double var2, double var4, + double var6, float var8) { + TileVariant tile = (TileVariant) var1; GL11.glDisable(GL12.GL_RESCALE_NORMAL); GL11.glPushMatrix(); - GL11.glTranslatef((float)var2 + 0.5f, (float)var4 + 1.5f, (float)var6 + 0.5f); + GL11.glTranslatef((float) var2 + 0.5f, (float) var4 + 1.5f, (float) var6 + 0.5f); //GL11.glScalef(0.85f, 0.85f, 0.7f); GL11.glRotatef(180, 0, 0, 1); GL11.glRotatef(90 * tile.rotation, 0, 1, 0); @@ -34,12 +35,12 @@ public class BlockCrateRenderer extends BlockRendererInterface{ setWoodTexture(var1.getBlockMetadata()); model.render(null, 0, 0, 0, 0, 0.0F, 0.0625F); - GL11.glPopMatrix(); - } + GL11.glPopMatrix(); + } - @Override - public void renderInventoryBlock(Block block, int metadata, int modelId, - RenderBlocks renderer) { + @Override + public void renderInventoryBlock(Block block, int metadata, int modelId, + RenderBlocks renderer) { GL11.glPushMatrix(); GL11.glTranslatef(0, 0.99f, 0); //GL11.glScalef(0.7f, 0.7f, 0.7f); @@ -50,11 +51,11 @@ public class BlockCrateRenderer extends BlockRendererInterface{ GL11.glColor3f(1, 1, 1); model.render(null, 0, 0, 0, 0, 0.0F, 0.0625F); - GL11.glPopMatrix(); - } + GL11.glPopMatrix(); + } - @Override - public int getRenderId() { - return CustomItems.crate.getRenderType(); - } + @Override + public int getRenderId() { + return CustomItems.crate.getRenderType(); + } } diff --git a/src/main/java/noppes/npcs/client/renderer/blocks/BlockLanternRenderer.java b/src/main/java/noppes/npcs/client/renderer/blocks/BlockLanternRenderer.java index 57e4da380..25307d33a 100644 --- a/src/main/java/noppes/npcs/client/renderer/blocks/BlockLanternRenderer.java +++ b/src/main/java/noppes/npcs/client/renderer/blocks/BlockLanternRenderer.java @@ -22,59 +22,57 @@ import noppes.npcs.config.ConfigClient; import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; -public class BlockLanternRenderer extends TileEntitySpecialRenderer implements ISimpleBlockRenderingHandler{ +public class BlockLanternRenderer extends TileEntitySpecialRenderer implements ISimpleBlockRenderingHandler { - private final ModelLegacyLantern modelLegacyLantern = new ModelLegacyLantern(); - private final ModelLegacyCeiling modelLegacyCeiling = new ModelLegacyCeiling(); - private final ModelLegacyWall modelLegacyWall = new ModelLegacyWall(); - private static final ResourceLocation legacyTexture = new ResourceLocation("customnpcs","textures/models/legacy/Lamp.png"); + private final ModelLegacyLantern modelLegacyLantern = new ModelLegacyLantern(); + private final ModelLegacyCeiling modelLegacyCeiling = new ModelLegacyCeiling(); + private final ModelLegacyWall modelLegacyWall = new ModelLegacyWall(); + private static final ResourceLocation legacyTexture = new ResourceLocation("customnpcs", "textures/models/legacy/Lamp.png"); private final LanternFloor modelLantern = new LanternFloor(); private final LanternWall modelLanternWall = new LanternWall(); private final LanternCeiling modelLanternCeiling = new LanternCeiling(); - private static final ResourceLocation texture = new ResourceLocation("customnpcs","textures/models/lantern.png"); + private static final ResourceLocation texture = new ResourceLocation("customnpcs", "textures/models/lantern.png"); - public BlockLanternRenderer(){ - ((BlockLantern)CustomItems.lantern).renderId = RenderingRegistry.getNextAvailableRenderId(); - ((BlockLantern)CustomItems.lantern_unlit).renderId = ((BlockLantern)CustomItems.lantern).renderId; - RenderingRegistry.registerBlockHandler(this); + public BlockLanternRenderer() { + ((BlockLantern) CustomItems.lantern).renderId = RenderingRegistry.getNextAvailableRenderId(); + ((BlockLantern) CustomItems.lantern_unlit).renderId = ((BlockLantern) CustomItems.lantern).renderId; + RenderingRegistry.registerBlockHandler(this); } - @Override - public void renderTileEntityAt(TileEntity var1, double var2, double var4, - double var6, float var8) { - TileLamp tile = (TileLamp) var1; + @Override + public void renderTileEntityAt(TileEntity var1, double var2, double var4, + double var6, float var8) { + TileLamp tile = (TileLamp) var1; GL11.glDisable(GL12.GL_RESCALE_NORMAL); GL11.glPushMatrix(); - GL11.glTranslatef((float)var2 + 0.5f, (float)var4 + 1.5f, (float)var6 + 0.5f); + GL11.glTranslatef((float) var2 + 0.5f, (float) var4 + 1.5f, (float) var6 + 0.5f); GL11.glRotatef(180, 0, 0, 1); GL11.glColor3f(1, 1, 1); GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS); GL11.glEnable(GL11.GL_ALPHA_TEST); - if(ConfigClient.LegacyLantern){ + if (ConfigClient.LegacyLantern) { GL11.glRotatef(45 * tile.rotation, 0, 1, 0); Minecraft.getMinecraft().getTextureManager().bindTexture(legacyTexture); - if(tile.variant == 0) + if (tile.variant == 0) modelLegacyLantern.render(null, 0, 0, 0, 0, 0.0F, 0.0625F); - else if(tile.variant == 1) + else if (tile.variant == 1) modelLegacyCeiling.render(null, 0, 0, 0, 0, 0.0F, 0.0625F); else modelLegacyWall.render(null, 0, 0, 0, 0, 0.0F, 0.0625F); } else { Minecraft.getMinecraft().getTextureManager().bindTexture(texture); - if(tile.variant == 0){ + if (tile.variant == 0) { GL11.glRotatef(45 * tile.rotation, 0, 1, 0); modelLantern.render(null, 0, 0, 0, 0, 0.0F, 0.0625F); - } - else if(tile.variant == 1){ + } else if (tile.variant == 1) { GL11.glRotatef(90, 0, 1, 0); modelLanternCeiling.Chain.render(0.0625F); GL11.glRotatef(45 * tile.rotation, 0, 1, 0); modelLanternCeiling.Lantern.render(0.0625F); modelLanternCeiling.Light.render(0.0625F); - } - else { + } else { GL11.glRotatef(45 * tile.rotation, 0, 1, 0); GL11.glTranslatef(0, 0.3f, 0); modelLanternWall.render(null, 0, 0, 0, 0, 0.0F, 0.0625F); @@ -83,24 +81,23 @@ public class BlockLanternRenderer extends TileEntitySpecialRenderer implements I GL11.glDisable(GL11.GL_ALPHA_TEST); GL11.glPopAttrib(); - GL11.glPopMatrix(); - } + GL11.glPopMatrix(); + } - @Override - public void renderInventoryBlock(Block block, int metadata, int modelId, - RenderBlocks renderer) { + @Override + public void renderInventoryBlock(Block block, int metadata, int modelId, + RenderBlocks renderer) { GL11.glPushMatrix(); GL11.glTranslatef(0, 2.2f, 0); GL11.glScalef(2f, 2f, 2f); GL11.glRotatef(180, 0, 0, 1); GL11.glRotatef(180, 0, 1, 0); - if(ConfigClient.LegacyLantern){ + if (ConfigClient.LegacyLantern) { Minecraft.getMinecraft().getTextureManager().bindTexture(legacyTexture); GL11.glColor3f(1, 1, 1); modelLegacyLantern.render(null, 0, 0, 0, 0, 0.0F, 0.0625F); - } - else { + } else { GL11.glScalef(0.7f, 0.7f, 0.7f); GL11.glTranslatef(0, 0.4f, 0); Minecraft.getMinecraft().getTextureManager().bindTexture(texture); @@ -108,25 +105,25 @@ public class BlockLanternRenderer extends TileEntitySpecialRenderer implements I modelLantern.render(null, 0, 0, 0, 0, 0.0F, 0.0625F); } - GL11.glPopMatrix(); - } + GL11.glPopMatrix(); + } - @Override - public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, - Block block, int modelId, RenderBlocks renderer) { - return false; - } + @Override + public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, + Block block, int modelId, RenderBlocks renderer) { + return false; + } - @Override - public boolean shouldRender3DInInventory(int modelId) { + @Override + public boolean shouldRender3DInInventory(int modelId) { return ConfigClient.LegacyLantern; - } + } - @Override - public int getRenderId() { - return CustomItems.lantern.getRenderType(); - } + @Override + public int getRenderId() { + return CustomItems.lantern.getRenderType(); + } } diff --git a/src/main/java/noppes/npcs/client/renderer/blocks/BlockMailboxRenderer.java b/src/main/java/noppes/npcs/client/renderer/blocks/BlockMailboxRenderer.java index 87a25b902..f1a136903 100644 --- a/src/main/java/noppes/npcs/client/renderer/blocks/BlockMailboxRenderer.java +++ b/src/main/java/noppes/npcs/client/renderer/blocks/BlockMailboxRenderer.java @@ -11,36 +11,37 @@ import net.minecraft.world.IBlockAccess; import noppes.npcs.CustomItems; import noppes.npcs.blocks.BlockMailbox; import noppes.npcs.client.model.blocks.ModelMailbox; -import noppes.npcs.client.model.blocks.legacy.ModelLegacyMailboxUS; import noppes.npcs.client.model.blocks.ModelMailboxWow; +import noppes.npcs.client.model.blocks.legacy.ModelLegacyMailboxUS; import noppes.npcs.config.ConfigClient; import org.lwjgl.opengl.GL11; -public class BlockMailboxRenderer extends TileEntitySpecialRenderer implements ISimpleBlockRenderingHandler{ +public class BlockMailboxRenderer extends TileEntitySpecialRenderer implements ISimpleBlockRenderingHandler { private final ModelMailbox mailbox = new ModelMailbox(); - private static final ResourceLocation mailbox_texture = new ResourceLocation("customnpcs","textures/models/mailbox.png"); + private static final ResourceLocation mailbox_texture = new ResourceLocation("customnpcs", "textures/models/mailbox.png"); - private final ModelLegacyMailboxUS model = new ModelLegacyMailboxUS(); - private final ModelMailboxWow model2 = new ModelMailboxWow(); + private final ModelLegacyMailboxUS model = new ModelLegacyMailboxUS(); + private final ModelMailboxWow model2 = new ModelMailboxWow(); - private static final ResourceLocation text1 = new ResourceLocation("customnpcs","textures/models/legacy/mailbox1.png"); - private static final ResourceLocation text2 = new ResourceLocation("customnpcs","textures/models/mailbox2.png"); + private static final ResourceLocation text1 = new ResourceLocation("customnpcs", "textures/models/legacy/mailbox1.png"); + private static final ResourceLocation text2 = new ResourceLocation("customnpcs", "textures/models/mailbox2.png"); - public BlockMailboxRenderer(){ - ((BlockMailbox)CustomItems.mailbox).renderId = RenderingRegistry.getNextAvailableRenderId(); - RenderingRegistry.registerBlockHandler(this); + public BlockMailboxRenderer() { + ((BlockMailbox) CustomItems.mailbox).renderId = RenderingRegistry.getNextAvailableRenderId(); + RenderingRegistry.registerBlockHandler(this); } - @Override - public void renderTileEntityAt(TileEntity var1, double var2, double var4, double var6, float var8) { - int meta = var1.getBlockMetadata() | 4; - int type = var1.getBlockMetadata() >> 2; + + @Override + public void renderTileEntityAt(TileEntity var1, double var2, double var4, double var6, float var8) { + int meta = var1.getBlockMetadata() | 4; + int type = var1.getBlockMetadata() >> 2; GL11.glPushMatrix(); - GL11.glTranslatef((float)var2 + 0.5f, (float)var4 + 1.5f, (float)var6 + 0.5f); + GL11.glTranslatef((float) var2 + 0.5f, (float) var4 + 1.5f, (float) var6 + 0.5f); GL11.glRotatef(180, 0, 0, 1); GL11.glRotatef(90 * meta, 0, 1, 0); - if(type == 0){ - if(ConfigClient.LegacyMailbox){ + if (type == 0) { + if (ConfigClient.LegacyMailbox) { this.bindTexture(text1); model.render(null, 0, 0, 0, 0, 0.0F, 0.0625F); } else { @@ -49,23 +50,23 @@ public class BlockMailboxRenderer extends TileEntitySpecialRenderer implements I mailbox.render(null, 0, 0, 0, 0, 0.0F, 0.0625F); } } - if(type == 1){ - this.bindTexture(text2); - model2.render(null, 0, 0, 0, 0, 0.0F, 0.0625F); + if (type == 1) { + this.bindTexture(text2); + model2.render(null, 0, 0, 0, 0, 0.0F, 0.0625F); } - GL11.glPopMatrix(); - } + GL11.glPopMatrix(); + } - @Override - public void renderInventoryBlock(Block block, int metadata, int modelID, - RenderBlocks renderer) { + @Override + public void renderInventoryBlock(Block block, int metadata, int modelID, + RenderBlocks renderer) { GL11.glPushMatrix(); GL11.glTranslatef(0, 0.74f, 0); GL11.glScalef(0.9f, 0.86f, 0.9f); GL11.glRotatef(180, 0, 0, 1); GL11.glRotatef(180, 0, 1, 0); - if(metadata == 0){ - if(ConfigClient.LegacyMailbox){ + if (metadata == 0) { + if (ConfigClient.LegacyMailbox) { this.bindTexture(text1); model.render(null, 0, 0, 0, 0, 0.0F, 0.0625F); } else { @@ -73,26 +74,26 @@ public class BlockMailboxRenderer extends TileEntitySpecialRenderer implements I mailbox.render(null, 0, 0, 0, 0, 0.0F, 0.0625F); } } - if(metadata == 1){ - this.bindTexture(text2); - model2.render(null, 0, 0, 0, 0, 0.0F, 0.0625F); + if (metadata == 1) { + this.bindTexture(text2); + model2.render(null, 0, 0, 0, 0, 0.0F, 0.0625F); } - GL11.glPopMatrix(); - } + GL11.glPopMatrix(); + } - @Override - public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, - Block block, int modelId, RenderBlocks renderer) { - return false; - } + @Override + public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, + Block block, int modelId, RenderBlocks renderer) { + return false; + } - @Override - public int getRenderId() { - return CustomItems.mailbox.getRenderType(); - } + @Override + public int getRenderId() { + return CustomItems.mailbox.getRenderType(); + } - @Override - public boolean shouldRender3DInInventory(int modelId) { - return true; - } + @Override + public boolean shouldRender3DInInventory(int modelId) { + return true; + } } diff --git a/src/main/java/noppes/npcs/client/renderer/blocks/BlockPedestalRenderer.java b/src/main/java/noppes/npcs/client/renderer/blocks/BlockPedestalRenderer.java index e866193ee..878e0088c 100644 --- a/src/main/java/noppes/npcs/client/renderer/blocks/BlockPedestalRenderer.java +++ b/src/main/java/noppes/npcs/client/renderer/blocks/BlockPedestalRenderer.java @@ -19,10 +19,10 @@ import noppes.npcs.config.ConfigClient; import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; -public class BlockPedestalRenderer extends BlockRendererInterface{ +public class BlockPedestalRenderer extends BlockRendererInterface { - private final ModelLegacyPedestal legacyModel = new ModelLegacyPedestal(); - private final static ResourceLocation resource = new ResourceLocation("customnpcs:textures/models/legacy/npcPedestal.png"); + private final ModelLegacyPedestal legacyModel = new ModelLegacyPedestal(); + private final static ResourceLocation resource = new ResourceLocation("customnpcs:textures/models/legacy/npcPedestal.png"); private final ModelPedestal model = new ModelPedestal(); private final static ResourceLocation wood = new ResourceLocation("customnpcs:textures/models/pedestal/wood.png"); @@ -31,24 +31,24 @@ public class BlockPedestalRenderer extends BlockRendererInterface{ private final static ResourceLocation gold = new ResourceLocation("customnpcs:textures/models/pedestal/gold.png"); private final static ResourceLocation diamond = new ResourceLocation("customnpcs:textures/models/pedestal/diamond.png"); - public BlockPedestalRenderer(){ - ((BlockRotated)CustomItems.pedestal).renderId = RenderingRegistry.getNextAvailableRenderId(); - RenderingRegistry.registerBlockHandler(this); + public BlockPedestalRenderer() { + ((BlockRotated) CustomItems.pedestal).renderId = RenderingRegistry.getNextAvailableRenderId(); + RenderingRegistry.registerBlockHandler(this); } - @Override - public void renderTileEntityAt(TileEntity var1, double var2, double var4, - double var6, float var8) { - TilePedestal tile = (TilePedestal) var1; + @Override + public void renderTileEntityAt(TileEntity var1, double var2, double var4, + double var6, float var8) { + TilePedestal tile = (TilePedestal) var1; GL11.glDisable(GL12.GL_RESCALE_NORMAL); GL11.glEnable(GL11.GL_ALPHA_TEST); GL11.glPushMatrix(); - GL11.glTranslatef((float)var2 + 0.5f, (float)var4 + 1.5f, (float)var6 + 0.5f); + GL11.glTranslatef((float) var2 + 0.5f, (float) var4 + 1.5f, (float) var6 + 0.5f); GL11.glRotatef(180, 0, 0, 1); GL11.glRotatef(90 * tile.rotation, 0, 1, 0); GL11.glColor3f(1, 1, 1); - if(ConfigClient.LegacyPedestal){ + if (ConfigClient.LegacyPedestal) { setMaterialTexture(var1.getBlockMetadata()); legacyModel.render(null, 0, 0, 0, 0, 0.0F, 0.0625F); GL11.glScalef(1f, 0.99f, 1f); @@ -64,62 +64,58 @@ public class BlockPedestalRenderer extends BlockRendererInterface{ GL11.glPopMatrix(); GL11.glScalef(1f, 0.99f, 1f); } - if(!this.playerTooFar(tile)) - doRender(tile.getStackInSlot(0)); - GL11.glPopMatrix(); + if (!this.playerTooFar(tile)) + doRender(tile.getStackInSlot(0)); + GL11.glPopMatrix(); GL11.glColor3f(1, 1, 1); - } - private void doRender(ItemStack item){ - if(item == null || item.getItem() == null || item.getItem() instanceof ItemBlock) - return; + } + + private void doRender(ItemStack item) { + if (item == null || item.getItem() == null || item.getItem() instanceof ItemBlock) + return; GL11.glPushMatrix(); - if(ConfigClient.LegacyPedestal) + if (ConfigClient.LegacyPedestal) GL11.glTranslatef(0.06f, 0.30f, 0.02f); else GL11.glTranslatef(0.06f, 0.490f, 0.02f); GL11.glRotatef(180, 0, 0, 1); GL11.glRotatef(90, 0, 1, 0); GL11.glScalef(0.6f, 0.6f, 0.6f); - if(item.getItem().shouldRotateAroundWhenRendering()){ - GL11.glTranslatef(0.14f, 0, 0.5f); - GL11.glRotatef(90.0F, 0.0F, 1.0F, 0.0F); - } - else - GL11.glRotatef(-90.0F, 0.0F, 1.0F, 0.0F); + if (item.getItem().shouldRotateAroundWhenRendering()) { + GL11.glTranslatef(0.14f, 0, 0.5f); + GL11.glRotatef(90.0F, 0.0F, 1.0F, 0.0F); + } else + GL11.glRotatef(-90.0F, 0.0F, 1.0F, 0.0F); GL11.glRotatef(-200.0F, 0.0F, 0.0F, 1.0F); GL11.glRotatef(-50.0F, 0.0F, 1.0F, 0.0F); - if (item.getItem().requiresMultipleRenderPasses()) - { - for (int k = 0; k <= item.getItem().getRenderPasses(item.getItemDamage()); ++k) - { + if (item.getItem().requiresMultipleRenderPasses()) { + for (int k = 0; k <= item.getItem().getRenderPasses(item.getItemDamage()); ++k) { int i = item.getItem().getColorFromItemStack(item, k); - float f12 = (float)(i >> 16 & 255) / 255.0F; - float f4 = (float)(i >> 8 & 255) / 255.0F; - float f5 = (float)(i & 255) / 255.0F; + float f12 = (float) (i >> 16 & 255) / 255.0F; + float f4 = (float) (i >> 8 & 255) / 255.0F; + float f5 = (float) (i & 255) / 255.0F; GL11.glColor4f(f12, f4, f5, 1.0F); RenderManager.instance.itemRenderer.renderItem(Minecraft.getMinecraft().thePlayer, item, k); } - } - else - { + } else { int k = item.getItem().getColorFromItemStack(item, 0); - float f11 = (float)(k >> 16 & 255) / 255.0F; - float f12 = (float)(k >> 8 & 255) / 255.0F; - float f4 = (float)(k & 255) / 255.0F; + float f11 = (float) (k >> 16 & 255) / 255.0F; + float f12 = (float) (k >> 8 & 255) / 255.0F; + float f4 = (float) (k & 255) / 255.0F; GL11.glColor4f(f11, f12, f4, 1.0F); RenderManager.instance.itemRenderer.renderItem(Minecraft.getMinecraft().thePlayer, item, 0); } - GL11.glPopMatrix(); + GL11.glPopMatrix(); - } + } - @Override - public void renderInventoryBlock(Block block, int metadata, int modelId, - RenderBlocks renderer) { + @Override + public void renderInventoryBlock(Block block, int metadata, int modelId, + RenderBlocks renderer) { GL11.glPushMatrix(); - if(ConfigClient.LegacyPedestal){ + if (ConfigClient.LegacyPedestal) { GL11.glTranslatef(0, 0.44f, 0); GL11.glScalef(0.76f, 0.66f, 0.76f); GL11.glRotatef(180, 0, 0, 1); @@ -136,29 +132,29 @@ public class BlockPedestalRenderer extends BlockRendererInterface{ GL11.glColor3f(1, 1, 1); model.render(null, 0, 0, 0, 0, 0.0F, 0.0625F); } - GL11.glPopMatrix(); - } + GL11.glPopMatrix(); + } - public void setPedestalTexture(int meta){ + public void setPedestalTexture(int meta) { TextureManager manager = Minecraft.getMinecraft().getTextureManager(); - if(meta == 1) + if (meta == 1) manager.bindTexture(stone); - else if(meta == 2) + else if (meta == 2) manager.bindTexture(iron); - else if(meta == 3) + else if (meta == 3) manager.bindTexture(gold); - else if(meta == 4) + else if (meta == 4) manager.bindTexture(diamond); else manager.bindTexture(wood); } - @Override - public int getRenderId() { - return CustomItems.pedestal.getRenderType(); - } + @Override + public int getRenderId() { + return CustomItems.pedestal.getRenderType(); + } - public int specialRenderDistance(){ - return 40; - } + public int specialRenderDistance() { + return 40; + } } diff --git a/src/main/java/noppes/npcs/client/renderer/blocks/BlockRendererInterface.java b/src/main/java/noppes/npcs/client/renderer/blocks/BlockRendererInterface.java index baaef5372..692314428 100644 --- a/src/main/java/noppes/npcs/client/renderer/blocks/BlockRendererInterface.java +++ b/src/main/java/noppes/npcs/client/renderer/blocks/BlockRendererInterface.java @@ -11,24 +11,24 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ResourceLocation; import net.minecraft.world.IBlockAccess; -public abstract class BlockRendererInterface extends TileEntitySpecialRenderer implements ISimpleBlockRenderingHandler{ - protected static final ResourceLocation Stone = new ResourceLocation("customnpcs","textures/cache/stone.png"); - protected static final ResourceLocation Iron = new ResourceLocation("customnpcs","textures/cache/iron_block.png"); - protected static final ResourceLocation Gold = new ResourceLocation("customnpcs","textures/cache/gold_block.png"); - protected static final ResourceLocation Diamond = new ResourceLocation("customnpcs","textures/cache/diamond_block.png"); +public abstract class BlockRendererInterface extends TileEntitySpecialRenderer implements ISimpleBlockRenderingHandler { + protected static final ResourceLocation Stone = new ResourceLocation("customnpcs", "textures/cache/stone.png"); + protected static final ResourceLocation Iron = new ResourceLocation("customnpcs", "textures/cache/iron_block.png"); + protected static final ResourceLocation Gold = new ResourceLocation("customnpcs", "textures/cache/gold_block.png"); + protected static final ResourceLocation Diamond = new ResourceLocation("customnpcs", "textures/cache/diamond_block.png"); - protected static final ResourceLocation PlanksOak = new ResourceLocation("customnpcs","textures/cache/planks_oak.png"); - protected static final ResourceLocation PlanksBigOak = new ResourceLocation("customnpcs","textures/cache/planks_big_oak.png"); - protected static final ResourceLocation PlanksSpruce = new ResourceLocation("customnpcs","textures/cache/planks_spruce.png"); - protected static final ResourceLocation PlanksBirch = new ResourceLocation("customnpcs","textures/cache/planks_birch.png"); - protected static final ResourceLocation PlanksAcacia = new ResourceLocation("customnpcs","textures/cache/planks_acacia.png"); - protected static final ResourceLocation PlanksJungle = new ResourceLocation("customnpcs","textures/cache/planks_jungle.png"); + protected static final ResourceLocation PlanksOak = new ResourceLocation("customnpcs", "textures/cache/planks_oak.png"); + protected static final ResourceLocation PlanksBigOak = new ResourceLocation("customnpcs", "textures/cache/planks_big_oak.png"); + protected static final ResourceLocation PlanksSpruce = new ResourceLocation("customnpcs", "textures/cache/planks_spruce.png"); + protected static final ResourceLocation PlanksBirch = new ResourceLocation("customnpcs", "textures/cache/planks_birch.png"); + protected static final ResourceLocation PlanksAcacia = new ResourceLocation("customnpcs", "textures/cache/planks_acacia.png"); + protected static final ResourceLocation PlanksJungle = new ResourceLocation("customnpcs", "textures/cache/planks_jungle.png"); - protected static final ResourceLocation Steel = new ResourceLocation("customnpcs","textures/models/legacy/Steel.png"); + protected static final ResourceLocation Steel = new ResourceLocation("customnpcs", "textures/models/legacy/Steel.png"); protected static final ResourceLocation Logs = new ResourceLocation("textures/blocks/log_oak.png"); protected static final ResourceLocation Cobble = new ResourceLocation("textures/blocks/cobblestone.png"); - protected static final ResourceLocation Flame = new ResourceLocation("customnpcs","textures/models/flame.png"); + protected static final ResourceLocation Flame = new ResourceLocation("customnpcs", "textures/models/flame.png"); protected static final RenderItem renderer = new RenderItem(); @@ -69,57 +69,59 @@ public abstract class BlockRendererInterface extends TileEntitySpecialRenderer i // }; @Override - public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, - Block block, int modelId, RenderBlocks renderer) { - return false; - } + public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, + Block block, int modelId, RenderBlocks renderer) { + return false; + } - @Override - public boolean shouldRender3DInInventory(int modelId) { - return true; - } + @Override + public boolean shouldRender3DInInventory(int modelId) { + return true; + } - public boolean playerTooFar(TileEntity tile){ - Minecraft mc = Minecraft.getMinecraft(); + public boolean playerTooFar(TileEntity tile) { + Minecraft mc = Minecraft.getMinecraft(); double d6 = mc.renderViewEntity.posX - tile.xCoord; double d7 = mc.renderViewEntity.posY - tile.yCoord; - double d8 = mc.renderViewEntity.posZ - tile.zCoord;; + double d8 = mc.renderViewEntity.posZ - tile.zCoord; + ; return d6 * d6 + d7 * d7 + d8 * d8 > specialRenderDistance() * specialRenderDistance(); - } - - public int specialRenderDistance(){ - return 20; - } - public static void setWoodTexture(int meta){ - TextureManager manager = Minecraft.getMinecraft().getTextureManager(); - if(meta == 1) - manager.bindTexture(PlanksSpruce); - else if(meta == 2) - manager.bindTexture(PlanksBirch); - else if(meta == 3) - manager.bindTexture(PlanksJungle); - else if(meta == 4) - manager.bindTexture(PlanksAcacia); - else if(meta == 5) - manager.bindTexture(PlanksBigOak); - else - manager.bindTexture(PlanksOak); } - public static void setMaterialTexture(int meta){ - TextureManager manager = Minecraft.getMinecraft().getTextureManager(); - if(meta == 1) - manager.bindTexture(Stone); - else if(meta == 2) - manager.bindTexture(Iron); - else if(meta == 3) - manager.bindTexture(Gold); - else if(meta == 4) - manager.bindTexture(Diamond); + public int specialRenderDistance() { + return 20; + } + + public static void setWoodTexture(int meta) { + TextureManager manager = Minecraft.getMinecraft().getTextureManager(); + if (meta == 1) + manager.bindTexture(PlanksSpruce); + else if (meta == 2) + manager.bindTexture(PlanksBirch); + else if (meta == 3) + manager.bindTexture(PlanksJungle); + else if (meta == 4) + manager.bindTexture(PlanksAcacia); + else if (meta == 5) + manager.bindTexture(PlanksBigOak); else - manager.bindTexture(PlanksOak); + manager.bindTexture(PlanksOak); + } + + public static void setMaterialTexture(int meta) { + TextureManager manager = Minecraft.getMinecraft().getTextureManager(); + if (meta == 1) + manager.bindTexture(Stone); + else if (meta == 2) + manager.bindTexture(Iron); + else if (meta == 3) + manager.bindTexture(Gold); + else if (meta == 4) + manager.bindTexture(Diamond); + else + manager.bindTexture(PlanksOak); } } diff --git a/src/main/java/noppes/npcs/client/renderer/blocks/BlockScriptedRenderer.java b/src/main/java/noppes/npcs/client/renderer/blocks/BlockScriptedRenderer.java index c6a48e3bc..9aa8cdcaa 100644 --- a/src/main/java/noppes/npcs/client/renderer/blocks/BlockScriptedRenderer.java +++ b/src/main/java/noppes/npcs/client/renderer/blocks/BlockScriptedRenderer.java @@ -26,7 +26,7 @@ import org.lwjgl.opengl.GL11; import java.awt.*; import java.util.Random; -public class BlockScriptedRenderer extends BlockRendererInterface{ +public class BlockScriptedRenderer extends BlockRendererInterface { private static final RenderBlocks renderBlocks = new RenderBlocks(); private static final Random random = new Random(); @@ -148,7 +148,7 @@ public class BlockScriptedRenderer extends BlockRendererInterface{ if (!ForgeHooksClient.renderEntityItem(new EntityItem(tile.getWorldObj(), tile.xCoord, tile.yCoord, tile.zCoord, stack), stack, 0F, 0F, tile.getWorldObj().rand, mc.renderEngine, renderBlocks, 1)) { GL11.glScalef(0.5F, 0.5F, 0.5F); if (stack.getItem() instanceof ItemBlock && (RenderBlocks.renderItemIn3d(Block.getBlockFromItem(stack.getItem()).getRenderType()) - || Block.getBlockFromItem(stack.getItem()) instanceof BlockScripted)) { + || Block.getBlockFromItem(stack.getItem()) instanceof BlockScripted)) { renderBlocks.renderBlockAsItem(Block.getBlockFromItem(stack.getItem()), stack.getItemDamage(), 1F); } else { int renderPass = 0; @@ -166,7 +166,7 @@ public class BlockScriptedRenderer extends BlockRendererInterface{ GL11.glColor3f(1F, 1F, 1F); } renderPass++; - } while(renderPass < stack.getItem().getRenderPasses(stack.getItemDamage())); + } while (renderPass < stack.getItem().getRenderPasses(stack.getItemDamage())); } } } @@ -195,7 +195,8 @@ public class BlockScriptedRenderer extends BlockRendererInterface{ } @Override - public void renderInventoryBlock(Block block, int metadata, int modelId, RenderBlocks renderer) {} + public void renderInventoryBlock(Block block, int metadata, int modelId, RenderBlocks renderer) { + } @Override public boolean shouldRender3DInInventory(int modelId) { diff --git a/src/main/java/noppes/npcs/client/renderer/blocks/BlockShelfRenderer.java b/src/main/java/noppes/npcs/client/renderer/blocks/BlockShelfRenderer.java index ef4cd98db..e04667397 100644 --- a/src/main/java/noppes/npcs/client/renderer/blocks/BlockShelfRenderer.java +++ b/src/main/java/noppes/npcs/client/renderer/blocks/BlockShelfRenderer.java @@ -13,21 +13,22 @@ import noppes.npcs.client.model.blocks.ModelShelf; import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; -public class BlockShelfRenderer extends BlockRendererInterface{ +public class BlockShelfRenderer extends BlockRendererInterface { - private final ModelShelf model = new ModelShelf(); + private final ModelShelf model = new ModelShelf(); - public BlockShelfRenderer(){ - ((BlockRotated)CustomItems.shelf).renderId = RenderingRegistry.getNextAvailableRenderId(); - RenderingRegistry.registerBlockHandler(this); - } - @Override - public void renderTileEntityAt(TileEntity var1, double var2, double var4, - double var6, float var8) { - TileVariant tile = (TileVariant) var1; + public BlockShelfRenderer() { + ((BlockRotated) CustomItems.shelf).renderId = RenderingRegistry.getNextAvailableRenderId(); + RenderingRegistry.registerBlockHandler(this); + } + + @Override + public void renderTileEntityAt(TileEntity var1, double var2, double var4, + double var6, float var8) { + TileVariant tile = (TileVariant) var1; GL11.glDisable(GL12.GL_RESCALE_NORMAL); GL11.glPushMatrix(); - GL11.glTranslatef((float)var2 + 0.5f, (float)var4 + 1.5f, (float)var6 + 0.5f); + GL11.glTranslatef((float) var2 + 0.5f, (float) var4 + 1.5f, (float) var6 + 0.5f); //GL11.glScalef(1.2f, 1.1f, 1.2f); GL11.glRotatef(180, 0, 0, 1); GL11.glRotatef(90 * tile.rotation, 0, 1, 0); @@ -36,21 +37,18 @@ public class BlockShelfRenderer extends BlockRendererInterface{ boolean drawLeft = true; boolean drawRight = true; - if(tile.rotation == 3){ - drawLeft = shouldDraw(var1.getWorldObj(), var1.xCoord, var1.yCoord, var1.zCoord - 1, 3); - drawRight = shouldDraw(var1.getWorldObj(), var1.xCoord, var1.yCoord, var1.zCoord + 1, 3); - } - else if(tile.rotation == 1){ - drawLeft = shouldDraw(var1.getWorldObj(), var1.xCoord, var1.yCoord, var1.zCoord + 1, 1); - drawRight = shouldDraw(var1.getWorldObj(), var1.xCoord, var1.yCoord, var1.zCoord - 1, 1); - } - else if(tile.rotation == 0){ - drawLeft = shouldDraw(var1.getWorldObj(), var1.xCoord + 1, var1.yCoord, var1.zCoord, 0); - drawRight = shouldDraw(var1.getWorldObj(), var1.xCoord - 1, var1.yCoord, var1.zCoord, 0); - } - else if(tile.rotation == 2){ - drawLeft = shouldDraw(var1.getWorldObj(), var1.xCoord - 1, var1.yCoord, var1.zCoord, 2); - drawRight = shouldDraw(var1.getWorldObj(), var1.xCoord + 1, var1.yCoord, var1.zCoord, 2); + if (tile.rotation == 3) { + drawLeft = shouldDraw(var1.getWorldObj(), var1.xCoord, var1.yCoord, var1.zCoord - 1, 3); + drawRight = shouldDraw(var1.getWorldObj(), var1.xCoord, var1.yCoord, var1.zCoord + 1, 3); + } else if (tile.rotation == 1) { + drawLeft = shouldDraw(var1.getWorldObj(), var1.xCoord, var1.yCoord, var1.zCoord + 1, 1); + drawRight = shouldDraw(var1.getWorldObj(), var1.xCoord, var1.yCoord, var1.zCoord - 1, 1); + } else if (tile.rotation == 0) { + drawLeft = shouldDraw(var1.getWorldObj(), var1.xCoord + 1, var1.yCoord, var1.zCoord, 0); + drawRight = shouldDraw(var1.getWorldObj(), var1.xCoord - 1, var1.yCoord, var1.zCoord, 0); + } else if (tile.rotation == 2) { + drawLeft = shouldDraw(var1.getWorldObj(), var1.xCoord - 1, var1.yCoord, var1.zCoord, 2); + drawRight = shouldDraw(var1.getWorldObj(), var1.xCoord + 1, var1.yCoord, var1.zCoord, 2); } @@ -60,18 +58,19 @@ public class BlockShelfRenderer extends BlockRendererInterface{ setWoodTexture(var1.getBlockMetadata()); model.render(null, 0, 0, 0, 0, 0.0F, 0.0625F); - GL11.glPopMatrix(); - } - private boolean shouldDraw(World world,int x, int y, int z, int rotation){ - TileEntity tile = world.getTileEntity(x, y, z); - if(tile == null || !(tile instanceof TileShelf)) - return true; - return ((TileShelf)tile).rotation != rotation; - } + GL11.glPopMatrix(); + } - @Override - public void renderInventoryBlock(Block block, int metadata, int modelId, - RenderBlocks renderer) { + private boolean shouldDraw(World world, int x, int y, int z, int rotation) { + TileEntity tile = world.getTileEntity(x, y, z); + if (tile == null || !(tile instanceof TileShelf)) + return true; + return ((TileShelf) tile).rotation != rotation; + } + + @Override + public void renderInventoryBlock(Block block, int metadata, int modelId, + RenderBlocks renderer) { GL11.glPushMatrix(); GL11.glTranslatef(0, 0.6f, 0); GL11.glScalef(1f, 1f, 1f); @@ -84,13 +83,12 @@ public class BlockShelfRenderer extends BlockRendererInterface{ model.SupportRight1.showModel = model.SupportRight2.showModel = true; model.render(null, 0, 0, 0, 0, 0.0F, 0.0625F); - GL11.glPopMatrix(); - } + GL11.glPopMatrix(); + } - - @Override - public int getRenderId() { - return CustomItems.shelf.getRenderType(); - } + @Override + public int getRenderId() { + return CustomItems.shelf.getRenderType(); + } } diff --git a/src/main/java/noppes/npcs/client/renderer/blocks/BlockShortLampRenderer.java b/src/main/java/noppes/npcs/client/renderer/blocks/BlockShortLampRenderer.java index aacbeb2f4..1f557d751 100644 --- a/src/main/java/noppes/npcs/client/renderer/blocks/BlockShortLampRenderer.java +++ b/src/main/java/noppes/npcs/client/renderer/blocks/BlockShortLampRenderer.java @@ -20,14 +20,14 @@ public class BlockShortLampRenderer extends BlockRendererInterface { public static final ModelShortLamp model = new ModelShortLamp(); - public static final ResourceLocation wood = new ResourceLocation("customnpcs","textures/models/lamp/short/wood.png"); - public static final ResourceLocation stone = new ResourceLocation("customnpcs","textures/models/lamp/short/stone.png"); - public static final ResourceLocation iron = new ResourceLocation("customnpcs","textures/models/lamp/short/iron.png"); - public static final ResourceLocation gold = new ResourceLocation("customnpcs","textures/models/lamp/short/gold.png"); - public static final ResourceLocation diamond = new ResourceLocation("customnpcs","textures/models/lamp/short/diamond.png"); + public static final ResourceLocation wood = new ResourceLocation("customnpcs", "textures/models/lamp/short/wood.png"); + public static final ResourceLocation stone = new ResourceLocation("customnpcs", "textures/models/lamp/short/stone.png"); + public static final ResourceLocation iron = new ResourceLocation("customnpcs", "textures/models/lamp/short/iron.png"); + public static final ResourceLocation gold = new ResourceLocation("customnpcs", "textures/models/lamp/short/gold.png"); + public static final ResourceLocation diamond = new ResourceLocation("customnpcs", "textures/models/lamp/short/diamond.png"); - public BlockShortLampRenderer(){ - ((BlockShortLamp)CustomItems.shortLamp).renderId = RenderingRegistry.getNextAvailableRenderId(); + public BlockShortLampRenderer() { + ((BlockShortLamp) CustomItems.shortLamp).renderId = RenderingRegistry.getNextAvailableRenderId(); RenderingRegistry.registerBlockHandler(this); } @@ -38,7 +38,7 @@ public class BlockShortLampRenderer extends BlockRendererInterface { GL11.glDisable(GL12.GL_RESCALE_NORMAL); GL11.glPushMatrix(); - GL11.glTranslatef((float)x + 0.5f, (float)y + 1.5f, (float)z + 0.5f); + GL11.glTranslatef((float) x + 0.5f, (float) y + 1.5f, (float) z + 0.5f); GL11.glRotatef(180, 0, 0, 1); GL11.glRotatef(90 * tile.rotation, 0, 1, 0); GL11.glColor3f(1, 1, 1); @@ -53,10 +53,10 @@ public class BlockShortLampRenderer extends BlockRendererInterface { int fullBright = 0xF000F0; int fullBrightX = fullBright % 65536; int fullBrightY = fullBright / 65536; - OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float)fullBrightX, (float)fullBrightY); + OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float) fullBrightX, (float) fullBrightY); model.Light.render(0.0625F); - OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float)brightX, (float)brightY); - float[] color = ColorUtil.hexToRGB(tile.color); + OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float) brightX, (float) brightY); + float[] color = ColorUtil.hexToRGB(tile.color); GL11.glColor3f(color[0], color[1], color[2]); model.Shade.render(0.0625F); @@ -65,17 +65,18 @@ public class BlockShortLampRenderer extends BlockRendererInterface { } @Override - public void renderInventoryBlock(Block block, int metadata, int modelId, RenderBlocks renderer){} + public void renderInventoryBlock(Block block, int metadata, int modelId, RenderBlocks renderer) { + } - public static void setLampTexture(int meta){ + public static void setLampTexture(int meta) { TextureManager manager = Minecraft.getMinecraft().getTextureManager(); - if(meta == 1) + if (meta == 1) manager.bindTexture(stone); - else if(meta == 2) + else if (meta == 2) manager.bindTexture(iron); - else if(meta == 3) + else if (meta == 3) manager.bindTexture(gold); - else if(meta == 4) + else if (meta == 4) manager.bindTexture(diamond); else manager.bindTexture(wood); diff --git a/src/main/java/noppes/npcs/client/renderer/blocks/BlockSignRenderer.java b/src/main/java/noppes/npcs/client/renderer/blocks/BlockSignRenderer.java index c42b21e32..53ce8a227 100644 --- a/src/main/java/noppes/npcs/client/renderer/blocks/BlockSignRenderer.java +++ b/src/main/java/noppes/npcs/client/renderer/blocks/BlockSignRenderer.java @@ -18,41 +18,41 @@ import noppes.npcs.client.model.blocks.ModelSign; import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; -public class BlockSignRenderer extends BlockRendererInterface{ +public class BlockSignRenderer extends BlockRendererInterface { - private final ModelSign model = new ModelSign(); - - public BlockSignRenderer(){ - ((BlockRotated)CustomItems.sign).renderId = RenderingRegistry.getNextAvailableRenderId(); - RenderingRegistry.registerBlockHandler(this); - } - @Override - public void renderTileEntityAt(TileEntity var1, double var2, double var4, - double var6, float var8) { - TileSign tile = (TileSign) var1; + private final ModelSign model = new ModelSign(); + + public BlockSignRenderer() { + ((BlockRotated) CustomItems.sign).renderId = RenderingRegistry.getNextAvailableRenderId(); + RenderingRegistry.registerBlockHandler(this); + } + + @Override + public void renderTileEntityAt(TileEntity var1, double var2, double var4, + double var6, float var8) { + TileSign tile = (TileSign) var1; GL11.glDisable(GL12.GL_RESCALE_NORMAL); GL11.glPushMatrix(); - GL11.glTranslatef((float)var2 + 0.5f, (float)var4 + 1.62f, (float)var6 + 0.5f); + GL11.glTranslatef((float) var2 + 0.5f, (float) var4 + 1.62f, (float) var6 + 0.5f); //GL11.glScalef(1.2f, 1.1f, 1.2f); GL11.glRotatef(180, 0, 0, 1); GL11.glRotatef(90 * tile.rotation + 90, 0, 1, 0); GL11.glColor3f(1, 1, 1); - + Minecraft.getMinecraft().getTextureManager().bindTexture(Steel); model.render(null, 0, 0, 0, 0, 0.0F, 0.0625F); setWoodTexture(tile.getBlockMetadata()); model.Sign.render(0.0625F); - - if(tile.icon != null && !this.playerTooFar(tile)){ - doRender(var2, var4, var6, tile.rotation, tile.icon); + + if (tile.icon != null && !this.playerTooFar(tile)) { + doRender(var2, var4, var6, tile.rotation, tile.icon); } - - GL11.glPopMatrix(); - } - - public void doRender(double par2, double par4, double par6, int meta, ItemStack iicon) - { + + GL11.glPopMatrix(); + } + + public void doRender(double par2, double par4, double par6, int meta, ItemStack iicon) { GL11.glPushMatrix(); bindTexture(TextureMap.locationItemsTexture); GL11.glTranslatef(0, 1.02f, -0.03f); @@ -69,8 +69,7 @@ public class BlockSignRenderer extends BlockRendererInterface{ } - public void renderItemBanner(TextureManager txtMng, ItemStack item, int p_77015_4_, int p_77015_5_, boolean renderEffect) - { + public void renderItemBanner(TextureManager txtMng, ItemStack item, int p_77015_4_, int p_77015_5_, boolean renderEffect) { Object object = item.getIconIndex(); int l; float f; @@ -83,18 +82,16 @@ public class BlockSignRenderer extends BlockRendererInterface{ ResourceLocation resourcelocation = txtMng.getResourceLocation(item.getItemSpriteNumber()); txtMng.bindTexture(resourcelocation); - if (object == null) - { - object = ((TextureMap)Minecraft.getMinecraft().getTextureManager().getTexture(resourcelocation)).getAtlasSprite("missingno"); + if (object == null) { + object = ((TextureMap) Minecraft.getMinecraft().getTextureManager().getTexture(resourcelocation)).getAtlasSprite("missingno"); } l = item.getItem().getColorFromItemStack(item, 0); - f3 = (float)(l >> 16 & 255) / 255.0F; - f4 = (float)(l >> 8 & 255) / 255.0F; - f = (float)(l & 255) / 255.0F; + f3 = (float) (l >> 16 & 255) / 255.0F; + f4 = (float) (l >> 8 & 255) / 255.0F; + f = (float) (l & 255) / 255.0F; - if (renderer.renderWithColor) - { + if (renderer.renderWithColor) { GL11.glColor4f(f3, f4, f, 1.0F); } @@ -102,23 +99,22 @@ public class BlockSignRenderer extends BlockRendererInterface{ GL11.glEnable(GL11.GL_ALPHA_TEST); GL11.glEnable(GL11.GL_BLEND); - renderer.renderIcon(p_77015_4_, p_77015_5_, (IIcon)object, 16, 16); + renderer.renderIcon(p_77015_4_, p_77015_5_, (IIcon) object, 16, 16); GL11.glEnable(GL11.GL_LIGHTING); GL11.glDisable(GL11.GL_ALPHA_TEST); GL11.glDisable(GL11.GL_BLEND); - if (renderEffect && item.hasEffect(0)) - { + if (renderEffect && item.hasEffect(0)) { renderer.renderEffect(txtMng, p_77015_4_, p_77015_5_); } GL11.glEnable(GL11.GL_LIGHTING); GL11.glEnable(GL11.GL_CULL_FACE); } - @Override - public void renderInventoryBlock(Block block, int metadata, int modelId, - RenderBlocks renderer) { + @Override + public void renderInventoryBlock(Block block, int metadata, int modelId, + RenderBlocks renderer) { GL11.glPushMatrix(); GL11.glTranslatef(0, 0.6f, 0); GL11.glScalef(1f, 1f, 1f); @@ -131,14 +127,13 @@ public class BlockSignRenderer extends BlockRendererInterface{ setWoodTexture(metadata); model.Sign.render(0.0625F); - - GL11.glPopMatrix(); - } + + GL11.glPopMatrix(); + } - - @Override - public int getRenderId() { - return CustomItems.sign.getRenderType(); - } + @Override + public int getRenderId() { + return CustomItems.sign.getRenderType(); + } } diff --git a/src/main/java/noppes/npcs/client/renderer/blocks/BlockStoolRenderer.java b/src/main/java/noppes/npcs/client/renderer/blocks/BlockStoolRenderer.java index 101da2e94..722f5d23d 100644 --- a/src/main/java/noppes/npcs/client/renderer/blocks/BlockStoolRenderer.java +++ b/src/main/java/noppes/npcs/client/renderer/blocks/BlockStoolRenderer.java @@ -16,94 +16,92 @@ import noppes.npcs.config.ConfigClient; import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; -public class BlockStoolRenderer extends BlockRendererInterface{ +public class BlockStoolRenderer extends BlockRendererInterface { - private final ModelLegacyStool legacyStool = new ModelLegacyStool(); + private final ModelLegacyStool legacyStool = new ModelLegacyStool(); private final ModelStool stool = new ModelStool(); - private static final ResourceLocation oak = new ResourceLocation("customnpcs","textures/models/stool/oak.png"); - private static final ResourceLocation spruce = new ResourceLocation("customnpcs","textures/models/stool/spruce.png"); - private static final ResourceLocation birch = new ResourceLocation("customnpcs","textures/models/stool/birch.png"); - private static final ResourceLocation jungle = new ResourceLocation("customnpcs","textures/models/stool/jungle.png"); - private static final ResourceLocation dark_oak = new ResourceLocation("customnpcs","textures/models/stool/dark_oak.png"); - private static final ResourceLocation acacia = new ResourceLocation("customnpcs","textures/models/stool/acacia.png"); + private static final ResourceLocation oak = new ResourceLocation("customnpcs", "textures/models/stool/oak.png"); + private static final ResourceLocation spruce = new ResourceLocation("customnpcs", "textures/models/stool/spruce.png"); + private static final ResourceLocation birch = new ResourceLocation("customnpcs", "textures/models/stool/birch.png"); + private static final ResourceLocation jungle = new ResourceLocation("customnpcs", "textures/models/stool/jungle.png"); + private static final ResourceLocation dark_oak = new ResourceLocation("customnpcs", "textures/models/stool/dark_oak.png"); + private static final ResourceLocation acacia = new ResourceLocation("customnpcs", "textures/models/stool/acacia.png"); - public BlockStoolRenderer(){ - ((BlockStool)CustomItems.stool).renderId = RenderingRegistry.getNextAvailableRenderId(); - RenderingRegistry.registerBlockHandler(this); - } - @Override - public void renderTileEntityAt(TileEntity var1, double var2, double var4, - double var6, float var8) { - TileVariant tile = (TileVariant) var1; + public BlockStoolRenderer() { + ((BlockStool) CustomItems.stool).renderId = RenderingRegistry.getNextAvailableRenderId(); + RenderingRegistry.registerBlockHandler(this); + } + + @Override + public void renderTileEntityAt(TileEntity var1, double var2, double var4, + double var6, float var8) { + TileVariant tile = (TileVariant) var1; GL11.glDisable(GL12.GL_RESCALE_NORMAL); GL11.glPushMatrix(); - GL11.glTranslatef((float)var2 + 0.5f, (float)var4 + 1.65f, (float)var6 + 0.5f); + GL11.glTranslatef((float) var2 + 0.5f, (float) var4 + 1.65f, (float) var6 + 0.5f); GL11.glScalef(1.2f, 1.1f, 1.2f); GL11.glRotatef(180, 0, 0, 1); GL11.glColor3f(1, 1, 1); GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS); GL11.glEnable(GL11.GL_ALPHA_TEST); - if(ConfigClient.LegacyStool){ + if (ConfigClient.LegacyStool) { setWoodTexture(var1.getBlockMetadata()); legacyStool.render(null, 0, 0, 0, 0, 0.0F, 0.0625F); - } - else { - if(ConfigClient.WoodTextures) { + } else { + if (ConfigClient.WoodTextures) { setWoodTexture(var1.getBlockMetadata()); - } - else { + } else { setStoolTexture(var1.getBlockMetadata()); } stool.render(null, 0, 0, 0, 0, 0.0F, 0.0625F); } GL11.glDisable(GL11.GL_ALPHA_TEST); GL11.glPopAttrib(); - GL11.glPopMatrix(); - } + GL11.glPopMatrix(); + } - @Override - public void renderInventoryBlock(Block block, int metadata, int modelId, - RenderBlocks renderer) { + @Override + public void renderInventoryBlock(Block block, int metadata, int modelId, + RenderBlocks renderer) { GL11.glPushMatrix(); GL11.glTranslatef(0, 1f, 0); GL11.glScalef(1.2f, 1.1f, 1.2f); GL11.glRotatef(180, 0, 0, 1); GL11.glRotatef(180, 0, 1, 0); - if(ConfigClient.LegacyStool){ + if (ConfigClient.LegacyStool) { setWoodTexture(metadata); GL11.glColor3f(1, 1, 1); legacyStool.render(null, 0, 0, 0, 0, 0.0F, 0.0625F); - } - else { + } else { setStoolTexture(metadata); GL11.glColor3f(1, 1, 1); stool.render(null, 0, 0, 0, 0, 0.0F, 0.0625F); } - GL11.glPopMatrix(); - } + GL11.glPopMatrix(); + } - public void setStoolTexture(int meta){ + public void setStoolTexture(int meta) { TextureManager manager = Minecraft.getMinecraft().getTextureManager(); - if(meta == 1) + if (meta == 1) manager.bindTexture(spruce); - else if(meta == 2) + else if (meta == 2) manager.bindTexture(birch); - else if(meta == 3) + else if (meta == 3) manager.bindTexture(jungle); - else if(meta == 4) + else if (meta == 4) manager.bindTexture(acacia); - else if(meta == 5) + else if (meta == 5) manager.bindTexture(dark_oak); else manager.bindTexture(oak); } - @Override - public int getRenderId() { - return CustomItems.stool.getRenderType(); - } + @Override + public int getRenderId() { + return CustomItems.stool.getRenderType(); + } } diff --git a/src/main/java/noppes/npcs/client/renderer/blocks/BlockTableRenderer.java b/src/main/java/noppes/npcs/client/renderer/blocks/BlockTableRenderer.java index 2e69f4b15..5aeda0918 100644 --- a/src/main/java/noppes/npcs/client/renderer/blocks/BlockTableRenderer.java +++ b/src/main/java/noppes/npcs/client/renderer/blocks/BlockTableRenderer.java @@ -15,28 +15,29 @@ import noppes.npcs.client.model.blocks.legacy.ModelLegacyTable; import noppes.npcs.config.ConfigClient; import org.lwjgl.opengl.GL11; -public class BlockTableRenderer extends BlockRendererInterface{ +public class BlockTableRenderer extends BlockRendererInterface { - private final ModelLegacyTable legacyTable = new ModelLegacyTable(); + private final ModelLegacyTable legacyTable = new ModelLegacyTable(); private final ModelTable table = new ModelTable(); - private static final ResourceLocation oak = new ResourceLocation("customnpcs","textures/models/table/oak.png"); - private static final ResourceLocation spruce = new ResourceLocation("customnpcs","textures/models/table/spruce.png"); - private static final ResourceLocation birch = new ResourceLocation("customnpcs","textures/models/table/birch.png"); - private static final ResourceLocation jungle = new ResourceLocation("customnpcs","textures/models/table/jungle.png"); - private static final ResourceLocation acacia = new ResourceLocation("customnpcs","textures/models/table/acacia.png"); - private static final ResourceLocation dark_oak = new ResourceLocation("customnpcs","textures/models/table/dark_oak.png"); + private static final ResourceLocation oak = new ResourceLocation("customnpcs", "textures/models/table/oak.png"); + private static final ResourceLocation spruce = new ResourceLocation("customnpcs", "textures/models/table/spruce.png"); + private static final ResourceLocation birch = new ResourceLocation("customnpcs", "textures/models/table/birch.png"); + private static final ResourceLocation jungle = new ResourceLocation("customnpcs", "textures/models/table/jungle.png"); + private static final ResourceLocation acacia = new ResourceLocation("customnpcs", "textures/models/table/acacia.png"); + private static final ResourceLocation dark_oak = new ResourceLocation("customnpcs", "textures/models/table/dark_oak.png"); - public BlockTableRenderer(){ - ((BlockTable)CustomItems.table).renderId = RenderingRegistry.getNextAvailableRenderId(); - RenderingRegistry.registerBlockHandler(this); - } - @Override - public void renderTileEntityAt(TileEntity var1, double var2, double var4, - double var6, float var8) { - TileVariant tile = (TileVariant) var1; + public BlockTableRenderer() { + ((BlockTable) CustomItems.table).renderId = RenderingRegistry.getNextAvailableRenderId(); + RenderingRegistry.registerBlockHandler(this); + } + + @Override + public void renderTileEntityAt(TileEntity var1, double var2, double var4, + double var6, float var8) { + TileVariant tile = (TileVariant) var1; GL11.glPushMatrix(); - GL11.glTranslatef((float)var2 + 0.5f, (float)var4 + 1.5f, (float)var6 + 0.5f); + GL11.glTranslatef((float) var2 + 0.5f, (float) var4 + 1.5f, (float) var6 + 0.5f); GL11.glRotatef(180, 0, 0, 1); GL11.glColor3f(1, 1, 1); @@ -52,7 +53,7 @@ public class BlockTableRenderer extends BlockRendererInterface{ GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS); GL11.glEnable(GL11.GL_ALPHA_TEST); - if(ConfigClient.LegacyTable){ + if (ConfigClient.LegacyTable) { setWoodTexture(var1.getBlockMetadata()); legacyTable.render(null, 0, 0, 0, 0, 0.0F, 0.0625F); GL11.glRotatef(90 * tile.rotation, 0, 1, 0); @@ -66,18 +67,18 @@ public class BlockTableRenderer extends BlockRendererInterface{ } GL11.glPopAttrib(); - GL11.glPopMatrix(); - } + GL11.glPopMatrix(); + } - @Override - public void renderInventoryBlock(Block block, int metadata, int modelId, - RenderBlocks renderer) { + @Override + public void renderInventoryBlock(Block block, int metadata, int modelId, + RenderBlocks renderer) { GL11.glPushMatrix(); GL11.glTranslatef(0, 0.9f, 0); GL11.glRotatef(180, 0, 0, 1); GL11.glRotatef(180, 0, 1, 0); - if(ConfigClient.LegacyTable){ + if (ConfigClient.LegacyTable) { setWoodTexture(metadata); GL11.glColor3f(1, 1, 1); legacyTable.Table.render(0.0625f); @@ -97,27 +98,27 @@ public class BlockTableRenderer extends BlockRendererInterface{ table.render(null, 0, 0, 0, 0, 0.0F, 0.0625F); } - GL11.glPopMatrix(); - } + GL11.glPopMatrix(); + } - public void setTableTexture(int meta){ + public void setTableTexture(int meta) { TextureManager manager = Minecraft.getMinecraft().getTextureManager(); - if(meta == 1) + if (meta == 1) manager.bindTexture(spruce); - else if(meta == 2) + else if (meta == 2) manager.bindTexture(birch); - else if(meta == 3) + else if (meta == 3) manager.bindTexture(jungle); - else if(meta == 4) + else if (meta == 4) manager.bindTexture(acacia); - else if(meta == 5) + else if (meta == 5) manager.bindTexture(dark_oak); else manager.bindTexture(oak); } - @Override - public int getRenderId() { - return CustomItems.table.getRenderType(); - } + @Override + public int getRenderId() { + return CustomItems.table.getRenderType(); + } } diff --git a/src/main/java/noppes/npcs/client/renderer/blocks/BlockTallLampRenderer.java b/src/main/java/noppes/npcs/client/renderer/blocks/BlockTallLampRenderer.java index 515b19cd8..2d2bba3d9 100644 --- a/src/main/java/noppes/npcs/client/renderer/blocks/BlockTallLampRenderer.java +++ b/src/main/java/noppes/npcs/client/renderer/blocks/BlockTallLampRenderer.java @@ -19,39 +19,39 @@ import noppes.npcs.config.ConfigClient; import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; -public class BlockTallLampRenderer extends BlockRendererInterface{ +public class BlockTallLampRenderer extends BlockRendererInterface { - public static final ModelLegacyTallLamp modelLegacy = new ModelLegacyTallLamp(); + public static final ModelLegacyTallLamp modelLegacy = new ModelLegacyTallLamp(); public static final ModelLegacyTallLampTop topLegacy = new ModelLegacyTallLampTop(); - public static final ResourceLocation resourceTop = new ResourceLocation("customnpcs","textures/cache/wool_colored_white.png"); + public static final ResourceLocation resourceTop = new ResourceLocation("customnpcs", "textures/cache/wool_colored_white.png"); public static final ModelTallLamp model = new ModelTallLamp(); - public static final ResourceLocation wood = new ResourceLocation("customnpcs","textures/models/lamp/tall/wood.png"); - public static final ResourceLocation stone = new ResourceLocation("customnpcs","textures/models/lamp/tall/stone.png"); - public static final ResourceLocation iron = new ResourceLocation("customnpcs","textures/models/lamp/tall/iron.png"); - public static final ResourceLocation gold = new ResourceLocation("customnpcs","textures/models/lamp/tall/gold.png"); - public static final ResourceLocation diamond = new ResourceLocation("customnpcs","textures/models/lamp/tall/diamond.png"); + public static final ResourceLocation wood = new ResourceLocation("customnpcs", "textures/models/lamp/tall/wood.png"); + public static final ResourceLocation stone = new ResourceLocation("customnpcs", "textures/models/lamp/tall/stone.png"); + public static final ResourceLocation iron = new ResourceLocation("customnpcs", "textures/models/lamp/tall/iron.png"); + public static final ResourceLocation gold = new ResourceLocation("customnpcs", "textures/models/lamp/tall/gold.png"); + public static final ResourceLocation diamond = new ResourceLocation("customnpcs", "textures/models/lamp/tall/diamond.png"); - public BlockTallLampRenderer(){ - ((BlockTallLamp)CustomItems.tallLamp).renderId = RenderingRegistry.getNextAvailableRenderId(); - RenderingRegistry.registerBlockHandler(this); + public BlockTallLampRenderer() { + ((BlockTallLamp) CustomItems.tallLamp).renderId = RenderingRegistry.getNextAvailableRenderId(); + RenderingRegistry.registerBlockHandler(this); } - @Override - public void renderTileEntityAt(TileEntity var1, double var2, double var4, - double var6, float var8) { - TileTallLamp tile = (TileTallLamp) var1; + @Override + public void renderTileEntityAt(TileEntity var1, double var2, double var4, + double var6, float var8) { + TileTallLamp tile = (TileTallLamp) var1; GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS); GL11.glDisable(GL12.GL_RESCALE_NORMAL); GL11.glPushMatrix(); - GL11.glTranslatef((float)var2 + 0.5f, (float)var4 + 1.5f, (float)var6 + 0.5f); + GL11.glTranslatef((float) var2 + 0.5f, (float) var4 + 1.5f, (float) var6 + 0.5f); GL11.glRotatef(180, 0, 0, 1); GL11.glRotatef(90 * tile.rotation, 0, 1, 0); GL11.glColor3f(1, 1, 1); - if(ConfigClient.LegacyTallLamp){ + if (ConfigClient.LegacyTallLamp) { setMaterialTexture(var1.getBlockMetadata()); modelLegacy.render(null, 0, 0, 0, 0, 0.0F, 0.0625F); @@ -70,9 +70,9 @@ public class BlockTallLampRenderer extends BlockRendererInterface{ int fullBright = 0xF000F0; int fullBrightX = fullBright % 65536; int fullBrightY = fullBright / 65536; - OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float)fullBrightX, (float)fullBrightY); + OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float) fullBrightX, (float) fullBrightY); model.Light.render(0.0625F); - OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float)brightX, (float)brightY); + OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float) brightX, (float) brightY); float[] color = ColorUtil.hexToRGB(tile.color); GL11.glColor3f(color[0], color[1], color[2]); @@ -80,29 +80,30 @@ public class BlockTallLampRenderer extends BlockRendererInterface{ } GL11.glPopAttrib(); - GL11.glPopMatrix(); - } + GL11.glPopMatrix(); + } - @Override - public void renderInventoryBlock(Block block, int metadata, int modelId, - RenderBlocks renderer) {} + @Override + public void renderInventoryBlock(Block block, int metadata, int modelId, + RenderBlocks renderer) { + } - public static void setLampTexture(int meta){ + public static void setLampTexture(int meta) { TextureManager manager = Minecraft.getMinecraft().getTextureManager(); - if(meta == 1) + if (meta == 1) manager.bindTexture(stone); - else if(meta == 2) + else if (meta == 2) manager.bindTexture(iron); - else if(meta == 3) + else if (meta == 3) manager.bindTexture(gold); - else if(meta == 4) + else if (meta == 4) manager.bindTexture(diamond); else manager.bindTexture(wood); } - @Override - public int getRenderId() { - return CustomItems.tallLamp.getRenderType(); - } + @Override + public int getRenderId() { + return CustomItems.tallLamp.getRenderType(); + } } diff --git a/src/main/java/noppes/npcs/client/renderer/blocks/BlockTombstoneRenderer.java b/src/main/java/noppes/npcs/client/renderer/blocks/BlockTombstoneRenderer.java index 3c2dafcf4..494bd0899 100644 --- a/src/main/java/noppes/npcs/client/renderer/blocks/BlockTombstoneRenderer.java +++ b/src/main/java/noppes/npcs/client/renderer/blocks/BlockTombstoneRenderer.java @@ -16,80 +16,80 @@ import noppes.npcs.client.model.blocks.ModelTombstone3; import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; -public class BlockTombstoneRenderer extends BlockRendererInterface{ +public class BlockTombstoneRenderer extends BlockRendererInterface { - private final ModelTombstone1 model = new ModelTombstone1(); - private final ModelTombstone2 model2 = new ModelTombstone2(); - private final ModelTombstone3 model3 = new ModelTombstone3(); - - public BlockTombstoneRenderer(){ - ((BlockTombstone)CustomItems.tombstone).renderId = RenderingRegistry.getNextAvailableRenderId(); - RenderingRegistry.registerBlockHandler(this); + private final ModelTombstone1 model = new ModelTombstone1(); + private final ModelTombstone2 model2 = new ModelTombstone2(); + private final ModelTombstone3 model3 = new ModelTombstone3(); + + public BlockTombstoneRenderer() { + ((BlockTombstone) CustomItems.tombstone).renderId = RenderingRegistry.getNextAvailableRenderId(); + RenderingRegistry.registerBlockHandler(this); } - @Override - public void renderTileEntityAt(TileEntity var1, double var2, double var4, - double var6, float var8) { - TileTombstone tile = (TileTombstone) var1; + @Override + public void renderTileEntityAt(TileEntity var1, double var2, double var4, + double var6, float var8) { + TileTombstone tile = (TileTombstone) var1; int meta = tile.getBlockMetadata(); GL11.glDisable(GL12.GL_RESCALE_NORMAL); GL11.glPushMatrix(); - GL11.glTranslatef((float)var2 + 0.5f, (float)var4 + 1.5f, (float)var6 + 0.5f); - if(meta == 2) - GL11.glScalef(1f, 1f, 1.14f); + GL11.glTranslatef((float) var2 + 0.5f, (float) var4 + 1.5f, (float) var6 + 0.5f); + if (meta == 2) + GL11.glScalef(1f, 1f, 1.14f); GL11.glRotatef(180, 0, 0, 1); GL11.glRotatef(90 * tile.rotation, 0, 1, 0); GL11.glColor3f(1, 1, 1); - - + + Minecraft.getMinecraft().getTextureManager().bindTexture(Stone); - if(meta == 0) - model.render(null, 0, 0, 0, 0, 0.0F, 0.0625F); - else if(meta == 1) - model2.render(null, 0, 0, 0, 0, 0.0F, 0.0625F); + if (meta == 0) + model.render(null, 0, 0, 0, 0, 0.0F, 0.0625F); + else if (meta == 1) + model2.render(null, 0, 0, 0, 0, 0.0F, 0.0625F); else - model3.render(null, 0, 0, 0, 0, 0.0F, 0.0625F); - if(meta < 2 && !playerTooFar(tile)) - renderText(tile, meta); + model3.render(null, 0, 0, 0, 0, 0.0F, 0.0625F); + if (meta < 2 && !playerTooFar(tile)) + renderText(tile, meta); - GL11.glPopMatrix(); - } + GL11.glPopMatrix(); + } - - private void renderText(TileTombstone tile, int meta){ - - if(tile.block == null || tile.hasChanged){ - tile.block = new TextBlockClient(tile.getText(), 94, true, Minecraft.getMinecraft().thePlayer); - tile.hasChanged = false; - } - if(!tile.block.lines.isEmpty()){ - GL11.glRotatef(180, 1, 0, 0); - float f3 = 0.0133F * 0.5f; - GL11.glTranslatef(0.0F, -0.64f, meta == 0?0.095F:0.126f); - GL11.glScalef(f3, -f3, f3); - GL11.glNormal3f(0.0F, 0.0F, -1.0F * f3); - GL11.glDepthMask(false); - FontRenderer fontrenderer = this.func_147498_b(); - - float lineOffset = 0; - if(tile.block.lines.size() < 11) - lineOffset = (11f - tile.block.lines.size()) / 2; - for(int i = 0; i < tile.block.lines.size(); i++){ - String text = tile.block.lines.get(i).getFormattedText(); - fontrenderer.drawString(text, -fontrenderer.getStringWidth(text) / 2, (int)((lineOffset + i) * (fontrenderer.FONT_HEIGHT - 0.3)), 0xffffff); - if(i == 13) - break; - } - - GL11.glDepthMask(true); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - } - } - - @Override - public void renderInventoryBlock(Block block, int meta, int modelId, - RenderBlocks renderer) { + private void renderText(TileTombstone tile, int meta) { + + if (tile.block == null || tile.hasChanged) { + tile.block = new TextBlockClient(tile.getText(), 94, true, Minecraft.getMinecraft().thePlayer); + tile.hasChanged = false; + } + if (!tile.block.lines.isEmpty()) { + GL11.glRotatef(180, 1, 0, 0); + float f3 = 0.0133F * 0.5f; + GL11.glTranslatef(0.0F, -0.64f, meta == 0 ? 0.095F : 0.126f); + GL11.glScalef(f3, -f3, f3); + GL11.glNormal3f(0.0F, 0.0F, -1.0F * f3); + GL11.glDepthMask(false); + FontRenderer fontrenderer = this.func_147498_b(); + + float lineOffset = 0; + if (tile.block.lines.size() < 11) + lineOffset = (11f - tile.block.lines.size()) / 2; + for (int i = 0; i < tile.block.lines.size(); i++) { + String text = tile.block.lines.get(i).getFormattedText(); + fontrenderer.drawString(text, -fontrenderer.getStringWidth(text) / 2, (int) ((lineOffset + i) * (fontrenderer.FONT_HEIGHT - 0.3)), 0xffffff); + if (i == 13) + break; + } + + GL11.glDepthMask(true); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + } + } + + + @Override + public void renderInventoryBlock(Block block, int meta, int modelId, + RenderBlocks renderer) { GL11.glPushMatrix(); GL11.glTranslatef(0, 1f, 0); GL11.glScalef(1f, 1f, 1f); @@ -98,19 +98,19 @@ public class BlockTombstoneRenderer extends BlockRendererInterface{ Minecraft.getMinecraft().getTextureManager().bindTexture(Stone); GL11.glColor3f(1, 1, 1); - if(meta == 0) - model.render(null, 0, 0, 0, 0, 0.0F, 0.0625F); - else if(meta == 1) - model2.render(null, 0, 0, 0, 0, 0.0F, 0.0625F); + if (meta == 0) + model.render(null, 0, 0, 0, 0, 0.0F, 0.0625F); + else if (meta == 1) + model2.render(null, 0, 0, 0, 0, 0.0F, 0.0625F); else - model3.render(null, 0, 0, 0, 0, 0.0F, 0.0625F); + model3.render(null, 0, 0, 0, 0, 0.0F, 0.0625F); - GL11.glPopMatrix(); - } + GL11.glPopMatrix(); + } - @Override - public int getRenderId() { - return CustomItems.tombstone.getRenderType(); - } + @Override + public int getRenderId() { + return CustomItems.tombstone.getRenderType(); + } } diff --git a/src/main/java/noppes/npcs/client/renderer/blocks/BlockWallBannerRenderer.java b/src/main/java/noppes/npcs/client/renderer/blocks/BlockWallBannerRenderer.java index 945775a0f..1a7f4e3c7 100644 --- a/src/main/java/noppes/npcs/client/renderer/blocks/BlockWallBannerRenderer.java +++ b/src/main/java/noppes/npcs/client/renderer/blocks/BlockWallBannerRenderer.java @@ -30,37 +30,36 @@ import noppes.npcs.client.model.blocks.legacy.ModelLegacyWallBannerFlag; import noppes.npcs.client.renderer.ImageData; import noppes.npcs.config.ConfigClient; import noppes.npcs.scripted.NpcAPI; -import noppes.npcs.scripted.item.ScriptItemStack; import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; -public class BlockWallBannerRenderer extends BlockRendererInterface{ +public class BlockWallBannerRenderer extends BlockRendererInterface { - public static final ModelLegacyWallBanner modelLegacyWallBanner = new ModelLegacyWallBanner(); + public static final ModelLegacyWallBanner modelLegacyWallBanner = new ModelLegacyWallBanner(); public static final ModelLegacyWallBannerFlag modelLegacyWallBannerFlag = new ModelLegacyWallBannerFlag(); public static final ModelBannerWall model = new ModelBannerWall(); public static final ModelBannerWallFlag flag = new ModelBannerWallFlag(); - public BlockWallBannerRenderer(){ - ((BlockWallBanner)CustomItems.wallBanner).renderId = RenderingRegistry.getNextAvailableRenderId(); - RenderingRegistry.registerBlockHandler(this); + public BlockWallBannerRenderer() { + ((BlockWallBanner) CustomItems.wallBanner).renderId = RenderingRegistry.getNextAvailableRenderId(); + RenderingRegistry.registerBlockHandler(this); } - @Override - public void renderTileEntityAt(TileEntity var1, double var2, double var4, - double var6, float var8) { - TileWallBanner tile = (TileWallBanner) var1; + @Override + public void renderTileEntityAt(TileEntity var1, double var2, double var4, + double var6, float var8) { + TileWallBanner tile = (TileWallBanner) var1; GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS); GL11.glDisable(GL12.GL_RESCALE_NORMAL); GL11.glEnable(GL11.GL_ALPHA_TEST); GL11.glPushMatrix(); - GL11.glTranslatef((float)var2 + 0.5f, (float)var4 +0.4f, (float)var6 + 0.5f); + GL11.glTranslatef((float) var2 + 0.5f, (float) var4 + 0.4f, (float) var6 + 0.5f); //GL11.glScalef(0.95f, 0.95f, 0.95f); GL11.glRotatef(180, 0, 0, 1); GL11.glRotatef(90 * tile.rotation, 0, 1, 0); - if(ConfigClient.LegacyBanner){ + if (ConfigClient.LegacyBanner) { setMaterialTexture(var1.getBlockMetadata()); GL11.glColor3f(1, 1, 1); modelLegacyWallBanner.render(null, 0, 0, 0, 0, 0.0F, 0.0625F); @@ -72,11 +71,10 @@ public class BlockWallBannerRenderer extends BlockRendererInterface{ GL11.glPopMatrix(); GL11.glColor3f(1, 1, 1); - if(tile.icon != null && !this.playerTooFar(tile)){ + if (tile.icon != null && !this.playerTooFar(tile)) { doRender(var2, var4, var6, tile.rotation, tile.icon, 0); } - } - else { + } else { long worldTime = tile.getWorldObj() != null ? tile.getWorldObj().getTotalWorldTime() : 0; // 100 is one full revolution, so we can just mod by 100 without affecting the result int animationProgress100 = (((tile.xCoord % 100) * 7 + (tile.yCoord % 100) * 9 + (tile.zCoord % 100) * 13) + (int) (worldTime % 100)) % 100; @@ -96,17 +94,17 @@ public class BlockWallBannerRenderer extends BlockRendererInterface{ GL11.glPopMatrix(); GL11.glColor3f(1, 1, 1); - if(tile.icon != null && !this.playerTooFar(tile)){ + if (tile.icon != null && !this.playerTooFar(tile)) { doRender(var2, var4, var6, tile.rotation, tile.icon, angle_x); } } GL11.glPopAttrib(); - } + } public void doRender(double par2, double par4, double par6, int meta, ItemStack iicon, float rotate) { GL11.glPushMatrix(); bindTexture(TextureMap.locationItemsTexture); - GL11.glTranslatef((float)par2 + 0.5f, (float)par4 + 0.2f, (float)par6 + 0.5f); + GL11.glTranslatef((float) par2 + 0.5f, (float) par4 + 0.2f, (float) par6 + 0.5f); GL11.glRotatef(180, 0, 0, 1); GL11.glRotatef(90 * meta, 0, 1, 0); if (ConfigClient.LegacyBanner) { @@ -164,8 +162,7 @@ public class BlockWallBannerRenderer extends BlockRendererInterface{ } - public void renderItemBanner(TextureManager txtMng, ItemStack item, int p_77015_4_, int p_77015_5_, boolean renderEffect) - { + public void renderItemBanner(TextureManager txtMng, ItemStack item, int p_77015_4_, int p_77015_5_, boolean renderEffect) { Object object = item.getIconIndex(); int l; float f; @@ -178,35 +175,31 @@ public class BlockWallBannerRenderer extends BlockRendererInterface{ ResourceLocation resourcelocation = txtMng.getResourceLocation(item.getItemSpriteNumber()); txtMng.bindTexture(resourcelocation); - if (object == null) - { - object = ((TextureMap)Minecraft.getMinecraft().getTextureManager().getTexture(resourcelocation)).getAtlasSprite("missingno"); + if (object == null) { + object = ((TextureMap) Minecraft.getMinecraft().getTextureManager().getTexture(resourcelocation)).getAtlasSprite("missingno"); } l = item.getItem().getColorFromItemStack(item, 0); Item loadingItem = item.getItem(); - if(loadingItem instanceof ItemBlock) { + if (loadingItem instanceof ItemBlock) { Block block = ((ItemBlock) loadingItem).field_150939_a; - if(block != null){ - if(block == Blocks.enchanting_table || block == Blocks.end_portal_frame){ + if (block != null) { + if (block == Blocks.enchanting_table || block == Blocks.end_portal_frame) { object = block.getIcon(1, item.getItemDamage()); - } - else if (block == Blocks.furnace || block == Blocks.tnt){ + } else if (block == Blocks.furnace || block == Blocks.tnt) { object = block.getIcon(2, 1); - } - else { + } else { object = block.getIcon(0, item.getItemDamage()); } } } - f3 = (float)(l >> 16 & 255) / 255.0F; - f4 = (float)(l >> 8 & 255) / 255.0F; - f = (float)(l & 255) / 255.0F; + f3 = (float) (l >> 16 & 255) / 255.0F; + f4 = (float) (l >> 8 & 255) / 255.0F; + f = (float) (l & 255) / 255.0F; - if (renderer.renderWithColor) - { + if (renderer.renderWithColor) { GL11.glColor4f(f3, f4, f, 1.0F); } @@ -214,14 +207,13 @@ public class BlockWallBannerRenderer extends BlockRendererInterface{ GL11.glEnable(GL11.GL_ALPHA_TEST); GL11.glEnable(GL11.GL_BLEND); - renderer.renderIcon(p_77015_4_, p_77015_5_, (IIcon)object, 16, 16); + renderer.renderIcon(p_77015_4_, p_77015_5_, (IIcon) object, 16, 16); GL11.glEnable(GL11.GL_LIGHTING); GL11.glDisable(GL11.GL_ALPHA_TEST); GL11.glDisable(GL11.GL_BLEND); - if (renderEffect && item.hasEffect(0)) - { + if (renderEffect && item.hasEffect(0)) { renderer.renderEffect(txtMng, p_77015_4_, p_77015_5_); } GL11.glEnable(GL11.GL_LIGHTING); @@ -229,16 +221,17 @@ public class BlockWallBannerRenderer extends BlockRendererInterface{ } - @Override - public void renderInventoryBlock(Block block, int metadata, int modelId, - RenderBlocks renderer) {} + @Override + public void renderInventoryBlock(Block block, int metadata, int modelId, + RenderBlocks renderer) { + } - @Override - public int getRenderId() { - return CustomItems.wallBanner.getRenderType(); - } + @Override + public int getRenderId() { + return CustomItems.wallBanner.getRenderType(); + } - public int specialRenderDistance(){ - return 26; - } + public int specialRenderDistance() { + return 26; + } } diff --git a/src/main/java/noppes/npcs/client/renderer/blocks/BlockWeaponRackRenderer.java b/src/main/java/noppes/npcs/client/renderer/blocks/BlockWeaponRackRenderer.java index 616e87ad6..ecaaf4575 100644 --- a/src/main/java/noppes/npcs/client/renderer/blocks/BlockWeaponRackRenderer.java +++ b/src/main/java/noppes/npcs/client/renderer/blocks/BlockWeaponRackRenderer.java @@ -15,79 +15,75 @@ import noppes.npcs.client.model.blocks.ModelWeaponRack; import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; -public class BlockWeaponRackRenderer extends BlockRendererInterface{ +public class BlockWeaponRackRenderer extends BlockRendererInterface { - private final ModelWeaponRack model = new ModelWeaponRack(); - - public BlockWeaponRackRenderer(){ - ((BlockWeaponRack)CustomItems.weaponsRack).renderId = RenderingRegistry.getNextAvailableRenderId(); - RenderingRegistry.registerBlockHandler(this); - } - @Override - public void renderTileEntityAt(TileEntity var1, double var2, double var4, - double var6, float var8) { - TileWeaponRack tile = (TileWeaponRack) var1; + private final ModelWeaponRack model = new ModelWeaponRack(); + + public BlockWeaponRackRenderer() { + ((BlockWeaponRack) CustomItems.weaponsRack).renderId = RenderingRegistry.getNextAvailableRenderId(); + RenderingRegistry.registerBlockHandler(this); + } + + @Override + public void renderTileEntityAt(TileEntity var1, double var2, double var4, + double var6, float var8) { + TileWeaponRack tile = (TileWeaponRack) var1; GL11.glDisable(GL12.GL_RESCALE_NORMAL); GL11.glEnable(GL11.GL_ALPHA_TEST); GL11.glPushMatrix(); - GL11.glTranslatef((float)var2 + 0.5f, (float)var4 + 1.34f, (float)var6 + 0.5f); + GL11.glTranslatef((float) var2 + 0.5f, (float) var4 + 1.34f, (float) var6 + 0.5f); GL11.glScalef(0.9f, 0.9f, 0.9f); GL11.glRotatef(180, 0, 0, 1); GL11.glRotatef(90 * tile.rotation, 0, 1, 0); GL11.glColor3f(1, 1, 1); - + setWoodTexture(var1.getBlockMetadata()); model.render(null, 0, 0, 0, 0, 0.0F, 0.0625F); - if(!this.playerTooFar(tile)){ - for(int i = 0; i < 3; i++) - doRender(tile.getStackInSlot(i), i); + if (!this.playerTooFar(tile)) { + for (int i = 0; i < 3; i++) + doRender(tile.getStackInSlot(i), i); } - GL11.glPopMatrix(); - } - - private void doRender(ItemStack item, int pos){ - if(item == null || item.getItem() == null || item.getItem() instanceof ItemBlock) - return; + GL11.glPopMatrix(); + } + + private void doRender(ItemStack item, int pos) { + if (item == null || item.getItem() == null || item.getItem() instanceof ItemBlock) + return; GL11.glPushMatrix(); - GL11.glTranslatef(-0.40f + pos * 0.37f, 0.8f, 0.23f); + GL11.glTranslatef(-0.40f + pos * 0.37f, 0.8f, 0.23f); GL11.glScalef(0.5f, 0.5f, 0.5f); - if(item.getItem().shouldRotateAroundWhenRendering()){ - GL11.glTranslatef(0.14f, 0, 0.5f); - GL11.glRotatef(90.0F, 0.0F, 1.0F, 0.0F); - } - else - GL11.glRotatef(-90.0F, 0.0F, 1.0F, 0.0F); + if (item.getItem().shouldRotateAroundWhenRendering()) { + GL11.glTranslatef(0.14f, 0, 0.5f); + GL11.glRotatef(90.0F, 0.0F, 1.0F, 0.0F); + } else + GL11.glRotatef(-90.0F, 0.0F, 1.0F, 0.0F); GL11.glRotatef(-200.0F, 0.0F, 0.0F, 1.0F); GL11.glRotatef(-50.0F, 0.0F, 1.0F, 0.0F); - if (item.getItem().requiresMultipleRenderPasses()) - { - for (int k = 0; k <= item.getItem().getRenderPasses(item.getItemDamage()); ++k) - { + if (item.getItem().requiresMultipleRenderPasses()) { + for (int k = 0; k <= item.getItem().getRenderPasses(item.getItemDamage()); ++k) { int i = item.getItem().getColorFromItemStack(item, k); - float f12 = (float)(i >> 16 & 255) / 255.0F; - float f4 = (float)(i >> 8 & 255) / 255.0F; - float f5 = (float)(i & 255) / 255.0F; + float f12 = (float) (i >> 16 & 255) / 255.0F; + float f4 = (float) (i >> 8 & 255) / 255.0F; + float f5 = (float) (i & 255) / 255.0F; GL11.glColor4f(f12, f4, f5, 1.0F); RenderManager.instance.itemRenderer.renderItem(Minecraft.getMinecraft().thePlayer, item, k); } - } - else - { + } else { int k = item.getItem().getColorFromItemStack(item, 0); - float f11 = (float)(k >> 16 & 255) / 255.0F; - float f12 = (float)(k >> 8 & 255) / 255.0F; - float f4 = (float)(k & 255) / 255.0F; + float f11 = (float) (k >> 16 & 255) / 255.0F; + float f12 = (float) (k >> 8 & 255) / 255.0F; + float f4 = (float) (k & 255) / 255.0F; GL11.glColor4f(f11, f12, f4, 1.0F); RenderManager.instance.itemRenderer.renderItem(Minecraft.getMinecraft().thePlayer, item, 0); } - GL11.glPopMatrix(); - - } + GL11.glPopMatrix(); - @Override - public void renderInventoryBlock(Block block, int metadata, int modelId, - RenderBlocks renderer) { + } + + @Override + public void renderInventoryBlock(Block block, int metadata, int modelId, + RenderBlocks renderer) { GL11.glPushMatrix(); GL11.glTranslatef(-0.3f, 0.15f, 0); GL11.glScalef(0.9f, 0.7f, 0.9f); @@ -97,16 +93,16 @@ public class BlockWeaponRackRenderer extends BlockRendererInterface{ setWoodTexture(metadata); GL11.glColor3f(1, 1, 1); model.render(null, 0, 0, 0, 0, 0.0F, 0.0625F); - - GL11.glPopMatrix(); - } - @Override - public int getRenderId() { - return CustomItems.weaponsRack.getRenderType(); - } - - public int specialRenderDistance(){ - return 26; - } + GL11.glPopMatrix(); + } + + @Override + public int getRenderId() { + return CustomItems.weaponsRack.getRenderType(); + } + + public int specialRenderDistance() { + return 26; + } } diff --git a/src/main/java/noppes/npcs/client/renderer/items/ItemBannerRenderer.java b/src/main/java/noppes/npcs/client/renderer/items/ItemBannerRenderer.java index a99a09135..0e3120d69 100644 --- a/src/main/java/noppes/npcs/client/renderer/items/ItemBannerRenderer.java +++ b/src/main/java/noppes/npcs/client/renderer/items/ItemBannerRenderer.java @@ -36,7 +36,7 @@ public class ItemBannerRenderer implements IItemRenderer { GL11.glEnable(GL11.GL_ALPHA_TEST); GL11.glPushMatrix(); - if (type == ItemRenderType.EQUIPPED || type == ItemRenderType.EQUIPPED_FIRST_PERSON){ + if (type == ItemRenderType.EQUIPPED || type == ItemRenderType.EQUIPPED_FIRST_PERSON) { GL11.glTranslatef(0.5F, 0.5F, 0.5F); } @@ -45,7 +45,7 @@ public class ItemBannerRenderer implements IItemRenderer { GL11.glRotatef(180, 0, 0, 1); GL11.glRotatef(180, 0, 1, 0); - if(ConfigClient.LegacyBanner){ + if (ConfigClient.LegacyBanner) { BlockBannerRenderer.setMaterialTexture(meta); GL11.glColor3f(1, 1, 1); BlockBannerRenderer.legacyBanner.render(null, 0, 0, 0, 0, 0.0F, 0.0625F); @@ -53,8 +53,7 @@ public class ItemBannerRenderer implements IItemRenderer { manager.bindTexture(BlockBannerRenderer.legacyFlagResource); GL11.glColor3f(color[0], color[1], color[2]); BlockBannerRenderer.legacyFlag.render(null, 0, 0, 0, 0, 0.0F, 0.0625F); - } - else { + } else { BlockBannerRenderer.setBannerMaterial(meta); BlockBannerRenderer.banner.render(null, 0, 0, 0, 0, 0.0F, 0.0625F); diff --git a/src/main/java/noppes/npcs/client/renderer/items/ItemBannerWallRenderer.java b/src/main/java/noppes/npcs/client/renderer/items/ItemBannerWallRenderer.java index 6de47be5b..33f834158 100644 --- a/src/main/java/noppes/npcs/client/renderer/items/ItemBannerWallRenderer.java +++ b/src/main/java/noppes/npcs/client/renderer/items/ItemBannerWallRenderer.java @@ -34,7 +34,7 @@ public class ItemBannerWallRenderer implements IItemRenderer { TextureManager manager = Minecraft.getMinecraft().getTextureManager(); GL11.glPushMatrix(); - if (type == ItemRenderType.EQUIPPED || type == ItemRenderType.EQUIPPED_FIRST_PERSON){ + if (type == ItemRenderType.EQUIPPED || type == ItemRenderType.EQUIPPED_FIRST_PERSON) { GL11.glTranslatef(0.5F, 0.5F, 0.5F); } @@ -46,7 +46,7 @@ public class ItemBannerWallRenderer implements IItemRenderer { GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS); GL11.glEnable(GL11.GL_ALPHA_TEST); - if(ConfigClient.LegacyBanner){ + if (ConfigClient.LegacyBanner) { BlockWallBannerRenderer.setMaterialTexture(meta); GL11.glColor3f(1, 1, 1); BlockWallBannerRenderer.modelLegacyWallBanner.render(null, 0, 0, 0, 0, 0.0F, 0.0625F); @@ -54,8 +54,7 @@ public class ItemBannerWallRenderer implements IItemRenderer { manager.bindTexture(BlockBannerRenderer.legacyFlagResource); GL11.glColor3f(color[0], color[1], color[2]); BlockWallBannerRenderer.modelLegacyWallBannerFlag.render(null, 0, 0, 0, 0, 0.0F, 0.0625F); - } - else { + } else { BlockWallBannerRenderer.flag.BannerFlag.rotateAngleX = 0; BlockBannerRenderer.setBannerMaterial(meta); BlockWallBannerRenderer.model.render(null, 0, 0, 0, 0, 0.0F, 0.0625F); diff --git a/src/main/java/noppes/npcs/client/renderer/items/ItemCouchWoolRenderer.java b/src/main/java/noppes/npcs/client/renderer/items/ItemCouchWoolRenderer.java index 2dd59dabe..59a1de496 100644 --- a/src/main/java/noppes/npcs/client/renderer/items/ItemCouchWoolRenderer.java +++ b/src/main/java/noppes/npcs/client/renderer/items/ItemCouchWoolRenderer.java @@ -38,7 +38,7 @@ public class ItemCouchWoolRenderer implements IItemRenderer { GL11.glEnable(GL11.GL_ALPHA_TEST); GL11.glPushMatrix(); - if (type == ItemRenderType.EQUIPPED || type == ItemRenderType.EQUIPPED_FIRST_PERSON){ + if (type == ItemRenderType.EQUIPPED || type == ItemRenderType.EQUIPPED_FIRST_PERSON) { GL11.glTranslatef(0.5F, 0.5F, 0.5F); } @@ -63,7 +63,7 @@ public class ItemCouchWoolRenderer implements IItemRenderer { BlockCouchWoolRenderer.modelCouch.CouchBack.render(0.0625F); mc.getTextureManager().bindTexture(BlockCouchWoolRenderer.wool); GL11.glColor3f(color[0], color[1], color[2]); - BlockCouchWoolRenderer. modelCouch.Cussion.render(0.0625F); + BlockCouchWoolRenderer.modelCouch.Cussion.render(0.0625F); } GL11.glDisable(GL11.GL_ALPHA_TEST); diff --git a/src/main/java/noppes/npcs/client/renderer/items/ItemCustomRenderer.java b/src/main/java/noppes/npcs/client/renderer/items/ItemCustomRenderer.java index 0c06432fc..8b8c1f452 100644 --- a/src/main/java/noppes/npcs/client/renderer/items/ItemCustomRenderer.java +++ b/src/main/java/noppes/npcs/client/renderer/items/ItemCustomRenderer.java @@ -71,7 +71,7 @@ public class ItemCustomRenderer implements IItemRenderer { if (!entityItem.ignoreFrustumCheck) { entityItem.ignoreFrustumCheck = true; - float entityXZSize = (float) Math.sqrt(Math.pow(scriptCustomItem.getScaleX(),2) + Math.pow(scriptCustomItem.getScaleZ(),2)); + float entityXZSize = (float) Math.sqrt(Math.pow(scriptCustomItem.getScaleX(), 2) + Math.pow(scriptCustomItem.getScaleZ(), 2)); this.setEntitySize(entityItem, entityXZSize * 0.25F, scriptCustomItem.getScaleY() * 0.25F); double XSize = entityItem.boundingBox.maxX - entityItem.boundingBox.minX; @@ -83,21 +83,21 @@ public class ItemCustomRenderer implements IItemRenderer { } float entityRenderTicks = Minecraft.getMinecraft().timer.renderPartialTicks; - float bobbing = MathHelper.sin(((float)entityItem.age + entityRenderTicks) / 10.0F + entityItem.hoverStart) * 0.1F + 0.1F; + float bobbing = MathHelper.sin(((float) entityItem.age + entityRenderTicks) / 10.0F + entityItem.hoverStart) * 0.1F + 0.1F; if (Minecraft.getMinecraft().gameSettings.fancyGraphics) { - if(!scriptCustomItem.isNormalItem()){ + if (!scriptCustomItem.isNormalItem()) { GL11.glRotatef(scriptCustomItem.getRotationX(), 1, 0, 0); GL11.glRotatef(scriptCustomItem.getRotationY(), 0, 1, 0); GL11.glRotatef(scriptCustomItem.getRotationZ(), 0, 0, 1); } - GL11.glRotatef(scriptCustomItem.getRotationXRate() * entityRenderTicks %360, 1, 0, 0); - GL11.glRotatef(scriptCustomItem.getRotationYRate() * entityRenderTicks %360, 0, 1, 0); - GL11.glRotatef(scriptCustomItem.getRotationZRate() * entityRenderTicks %360, 0, 0, 1); + GL11.glRotatef(scriptCustomItem.getRotationXRate() * entityRenderTicks % 360, 1, 0, 0); + GL11.glRotatef(scriptCustomItem.getRotationYRate() * entityRenderTicks % 360, 0, 1, 0); + GL11.glRotatef(scriptCustomItem.getRotationZRate() * entityRenderTicks % 360, 0, 0, 1); } if (!renderInFrame) { - if(!scriptCustomItem.isNormalItem()){ + if (!scriptCustomItem.isNormalItem()) { GL11.glScalef(scriptCustomItem.getScaleX(), scriptCustomItem.getScaleY(), scriptCustomItem.getScaleZ()); GL11.glTranslatef(0.0F, (Math.max(scriptCustomItem.getScaleY(), 1) - 1) * (1.0F / 4), 0.0F); } @@ -106,7 +106,7 @@ public class ItemCustomRenderer implements IItemRenderer { int color = scriptCustomItem.getColor(); float itemRed = (color >> 16 & 255) / 255f; - float itemGreen = (color >> 8 & 255) / 255f; + float itemGreen = (color >> 8 & 255) / 255f; float itemBlue = (color & 255) / 255f; GL11.glColor4f(itemRed, itemGreen, itemBlue, 1.0F); @@ -124,7 +124,7 @@ public class ItemCustomRenderer implements IItemRenderer { int color = scriptCustomItem.getColor(); float itemRed = (color >> 16 & 255) / 255f; - float itemGreen = (color >> 8 & 255) / 255f; + float itemGreen = (color >> 8 & 255) / 255f; float itemBlue = (color & 255) / 255f; GL11.glColor4f(itemRed, itemGreen, itemBlue, 1.0F); @@ -145,34 +145,33 @@ public class ItemCustomRenderer implements IItemRenderer { GL11.glRotatef(-315.0F, 0.0F, 0.0F, 1.0F); ((ItemCustomizable) itemStack.getItem()).renderOffset(scriptCustomItem); - if(scriptCustomItem.isNormalItem()){ + if (scriptCustomItem.isNormalItem()) { GL11.glTranslatef(-0.05F, 0.3F, 0.3F); GL11.glRotatef(50, 1, 0, 0); GL11.glRotatef(-80, 0, 1, 0); GL11.glRotatef(80, 0, 0, 1); - GL11.glRotatef(scriptCustomItem.getRotationXRate() * item3dRenderTicks %360, 1, 0, 0); - GL11.glRotatef(scriptCustomItem.getRotationYRate() * item3dRenderTicks %360, 0, 1, 0); - GL11.glRotatef(scriptCustomItem.getRotationZRate() * item3dRenderTicks %360, 0, 0, 1); + GL11.glRotatef(scriptCustomItem.getRotationXRate() * item3dRenderTicks % 360, 1, 0, 0); + GL11.glRotatef(scriptCustomItem.getRotationYRate() * item3dRenderTicks % 360, 0, 1, 0); + GL11.glRotatef(scriptCustomItem.getRotationZRate() * item3dRenderTicks % 360, 0, 0, 1); - GL11.glScalef(0.6F, 0.6F,0.6F); - } - else { + GL11.glScalef(0.6F, 0.6F, 0.6F); + } else { GL11.glTranslatef(scriptCustomItem.getTranslateX(), scriptCustomItem.getTranslateY(), scriptCustomItem.getTranslateZ()); GL11.glRotatef(scriptCustomItem.getRotationX(), 1, 0, 0); GL11.glRotatef(scriptCustomItem.getRotationY(), 0, 1, 0); GL11.glRotatef(scriptCustomItem.getRotationZ(), 0, 0, 1); - GL11.glRotatef(scriptCustomItem.getRotationXRate() * item3dRenderTicks %360, 1, 0, 0); - GL11.glRotatef(scriptCustomItem.getRotationYRate() * item3dRenderTicks %360, 0, 1, 0); - GL11.glRotatef(scriptCustomItem.getRotationZRate() * item3dRenderTicks %360, 0, 0, 1); + GL11.glRotatef(scriptCustomItem.getRotationXRate() * item3dRenderTicks % 360, 1, 0, 0); + GL11.glRotatef(scriptCustomItem.getRotationYRate() * item3dRenderTicks % 360, 0, 1, 0); + GL11.glRotatef(scriptCustomItem.getRotationZRate() * item3dRenderTicks % 360, 0, 0, 1); GL11.glScalef(scriptCustomItem.getScaleX(), scriptCustomItem.getScaleY(), scriptCustomItem.getScaleZ()); } int color = scriptCustomItem.getColor(); float itemRed = (color >> 16 & 255) / 255f; - float itemGreen = (color >> 8 & 255) / 255f; + float itemGreen = (color >> 8 & 255) / 255f; float itemBlue = (color & 255) / 255f; GL11.glColor4f(itemRed, itemGreen, itemBlue, 1.0F); @@ -186,49 +185,35 @@ public class ItemCustomRenderer implements IItemRenderer { GL11.glPopMatrix(); } - private void setEntitySize(EntityItem entityItem, float p_70105_1_, float p_70105_2_) - { + private void setEntitySize(EntityItem entityItem, float p_70105_1_, float p_70105_2_) { float f2; - if (p_70105_1_ != entityItem.width || p_70105_2_ != entityItem.height) - { + if (p_70105_1_ != entityItem.width || p_70105_2_ != entityItem.height) { f2 = entityItem.width; entityItem.width = p_70105_1_; entityItem.height = p_70105_2_; - entityItem.boundingBox.maxX = entityItem.boundingBox.minX + (double)entityItem.width; - entityItem.boundingBox.maxZ = entityItem.boundingBox.minZ + (double)entityItem.width; - entityItem.boundingBox.maxY = entityItem.boundingBox.minY + (double)entityItem.height; + entityItem.boundingBox.maxX = entityItem.boundingBox.minX + (double) entityItem.width; + entityItem.boundingBox.maxZ = entityItem.boundingBox.minZ + (double) entityItem.width; + entityItem.boundingBox.maxY = entityItem.boundingBox.minY + (double) entityItem.height; - if (entityItem.width > f2 && !entityItem.firstUpdate && !entityItem.worldObj.isRemote) - { - entityItem.moveEntity((double)(f2 - entityItem.width), 0.0D, (double)(f2 - entityItem.width)); + if (entityItem.width > f2 && !entityItem.firstUpdate && !entityItem.worldObj.isRemote) { + entityItem.moveEntity((double) (f2 - entityItem.width), 0.0D, (double) (f2 - entityItem.width)); } } f2 = p_70105_1_ % 2.0F; - if ((double)f2 < 0.375D) - { + if ((double) f2 < 0.375D) { entityItem.myEntitySize = Entity.EnumEntitySize.SIZE_1; - } - else if ((double)f2 < 0.75D) - { + } else if ((double) f2 < 0.75D) { entityItem.myEntitySize = Entity.EnumEntitySize.SIZE_2; - } - else if ((double)f2 < 1.0D) - { + } else if ((double) f2 < 1.0D) { entityItem.myEntitySize = Entity.EnumEntitySize.SIZE_3; - } - else if ((double)f2 < 1.375D) - { + } else if ((double) f2 < 1.375D) { entityItem.myEntitySize = Entity.EnumEntitySize.SIZE_4; - } - else if ((double)f2 < 1.75D) - { + } else if ((double) f2 < 1.75D) { entityItem.myEntitySize = Entity.EnumEntitySize.SIZE_5; - } - else - { + } else { entityItem.myEntitySize = Entity.EnumEntitySize.SIZE_6; } } @@ -237,182 +222,157 @@ public class ItemCustomRenderer implements IItemRenderer { int pass = 0; GL11.glPushMatrix(); - ClientCacheHandler.getImageData(scriptCustomItem.getTexture()).bindTexture(); + ClientCacheHandler.getImageData(scriptCustomItem.getTexture()).bindTexture(); - if (renderInFrame) - { - GL11.glTranslatef(0.0F, -0.05F, 0.0F); - GL11.glScalef(1.025641F,1.025641F,1.025641F); - GL11.glRotatef(180.0F, 0.0F, 1.0F, 0.0F); - GL11.glTranslatef(scriptCustomItem.getTranslateX(), scriptCustomItem.getTranslateY(), scriptCustomItem.getTranslateZ()); + if (renderInFrame) { + GL11.glTranslatef(0.0F, -0.05F, 0.0F); + GL11.glScalef(1.025641F, 1.025641F, 1.025641F); + GL11.glRotatef(180.0F, 0.0F, 1.0F, 0.0F); + GL11.glTranslatef(scriptCustomItem.getTranslateX(), scriptCustomItem.getTranslateY(), scriptCustomItem.getTranslateZ()); + } + + Tessellator tessellator = Tessellator.instance; + + float f14 = 0.0F; + float f15 = 1.0F; + float f4 = 0.0F; + float f5 = 1.0F; + float f6 = 1.0F; + float f7 = 0.5F; + float f8 = 0.25F; + float f10; + + if (RenderManager.instance.options.fancyGraphics) { + GL11.glPushMatrix(); + + float f9 = 0.0625F; + f10 = 0.021875F; + int j = itemStack.stackSize; + byte b0; + + if (j < 2) { + b0 = 1; + } else if (j < 16) { + b0 = 2; + } else if (j < 32) { + b0 = 3; + } else { + b0 = 4; } - Tessellator tessellator = Tessellator.instance; + if (!scriptCustomItem.isNormalItem()) + GL11.glScalef(scriptCustomItem.getScaleX(), scriptCustomItem.getScaleY(), scriptCustomItem.getScaleZ()); + GL11.glTranslatef(-f7, -f8, -((f9 + f10) * (float) b0 / 2.0F)); - float f14 = 0.0F; - float f15 = 1.0F; - float f4 = 0.0F; - float f5 = 1.0F; - float f6 = 1.0F; - float f7 = 0.5F; - float f8 = 0.25F; - float f10; - - if (RenderManager.instance.options.fancyGraphics) - { - GL11.glPushMatrix(); - - float f9 = 0.0625F; - f10 = 0.021875F; - int j = itemStack.stackSize; - byte b0; - - if (j < 2) - { - b0 = 1; - } - else if (j < 16) - { - b0 = 2; - } - else if (j < 32) - { - b0 = 3; - } - else - { - b0 = 4; - } - - if(!scriptCustomItem.isNormalItem()) - GL11.glScalef(scriptCustomItem.getScaleX(), scriptCustomItem.getScaleY(), scriptCustomItem.getScaleZ()); - GL11.glTranslatef(-f7, -f8, -((f9 + f10) * (float)b0 / 2.0F)); - - for (int k = 0; k < b0; ++k) - { - // Makes items offset when in 3D, like when in 2D, looks much better. Considered a vanilla bug... - GL11.glTranslatef(0f, 0f, f9 + f10); + for (int k = 0; k < b0; ++k) { + // Makes items offset when in 3D, like when in 2D, looks much better. Considered a vanilla bug... + GL11.glTranslatef(0f, 0f, f9 + f10); /*if (renderInFrame) { GL11.glTranslatef(0.5F, 0.0F, 0.0F); GL11.glRotatef(-90.0F, 0.0F, 0.0F, 1.0F); }*/ - ImageData imageData = ClientCacheHandler.getImageData(scriptCustomItem.getTexture()); - ItemRenderer.renderItemIn2D(tessellator, f15, f4, f14, f5, imageData.getTotalWidth(), imageData.getTotalHeight(), f9); + ImageData imageData = ClientCacheHandler.getImageData(scriptCustomItem.getTexture()); + ItemRenderer.renderItemIn2D(tessellator, f15, f4, f14, f5, imageData.getTotalWidth(), imageData.getTotalHeight(), f9); - if (itemStack.hasEffect(pass)) - { - GL11.glDepthFunc(GL11.GL_EQUAL); - GL11.glDisable(GL11.GL_LIGHTING); - RenderManager.instance.renderEngine.bindTexture(RES_ITEM_GLINT); - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_COLOR, GL11.GL_ONE); - float f11 = 0.76F; - GL11.glColor4f(0.5F * f11, 0.25F * f11, 0.8F * f11, 1.0F); - GL11.glMatrixMode(GL11.GL_TEXTURE); - GL11.glPushMatrix(); - float f12 = 0.125F; - GL11.glScalef(f12, f12, f12); - float f13 = (float)(Minecraft.getSystemTime() % 3000L) / 3000.0F * 8.0F; - GL11.glTranslatef(f13, 0.0F, 0.0F); - GL11.glRotatef(-50.0F, 0.0F, 0.0F, 1.0F); - ItemRenderer.renderItemIn2D(tessellator, 0.0F, 0.0F, 1.0F, 1.0F, 255, 255, f9); - GL11.glPopMatrix(); - GL11.glPushMatrix(); - GL11.glScalef(f12, f12, f12); - f13 = (float)(Minecraft.getSystemTime() % 4873L) / 4873.0F * 8.0F; - GL11.glTranslatef(-f13, 0.0F, 0.0F); - GL11.glRotatef(10.0F, 0.0F, 0.0F, 1.0F); - ItemRenderer.renderItemIn2D(tessellator, 0.0F, 0.0F, 1.0F, 1.0F, 255, 255, f9); - GL11.glPopMatrix(); - GL11.glMatrixMode(GL11.GL_MODELVIEW); - GL11.glDisable(GL11.GL_BLEND); - GL11.glEnable(GL11.GL_LIGHTING); - GL11.glDepthFunc(GL11.GL_LEQUAL); - } + if (itemStack.hasEffect(pass)) { + GL11.glDepthFunc(GL11.GL_EQUAL); + GL11.glDisable(GL11.GL_LIGHTING); + RenderManager.instance.renderEngine.bindTexture(RES_ITEM_GLINT); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_COLOR, GL11.GL_ONE); + float f11 = 0.76F; + GL11.glColor4f(0.5F * f11, 0.25F * f11, 0.8F * f11, 1.0F); + GL11.glMatrixMode(GL11.GL_TEXTURE); + GL11.glPushMatrix(); + float f12 = 0.125F; + GL11.glScalef(f12, f12, f12); + float f13 = (float) (Minecraft.getSystemTime() % 3000L) / 3000.0F * 8.0F; + GL11.glTranslatef(f13, 0.0F, 0.0F); + GL11.glRotatef(-50.0F, 0.0F, 0.0F, 1.0F); + ItemRenderer.renderItemIn2D(tessellator, 0.0F, 0.0F, 1.0F, 1.0F, 255, 255, f9); + GL11.glPopMatrix(); + GL11.glPushMatrix(); + GL11.glScalef(f12, f12, f12); + f13 = (float) (Minecraft.getSystemTime() % 4873L) / 4873.0F * 8.0F; + GL11.glTranslatef(-f13, 0.0F, 0.0F); + GL11.glRotatef(10.0F, 0.0F, 0.0F, 1.0F); + ItemRenderer.renderItemIn2D(tessellator, 0.0F, 0.0F, 1.0F, 1.0F, 255, 255, f9); + GL11.glPopMatrix(); + GL11.glMatrixMode(GL11.GL_MODELVIEW); + GL11.glDisable(GL11.GL_BLEND); + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glDepthFunc(GL11.GL_LEQUAL); + } + } + + GL11.glPopMatrix(); + } else { + int j = itemStack.stackSize; + int b0; + + if (j < 2) { + b0 = 1; + } else if (j < 16) { + b0 = 2; + } else if (j < 32) { + b0 = 3; + } else { + b0 = 4; + } + + for (int l = 0; l < b0; ++l) { + GL11.glPushMatrix(); + + if (l > 0) { + f10 = (this.random.nextFloat() * 2.0F - 1.0F) * 0.3F; + float f16 = (this.random.nextFloat() * 2.0F - 1.0F) * 0.3F; + float f17 = (this.random.nextFloat() * 2.0F - 1.0F) * 0.3F; + GL11.glTranslatef(f10, f16, f17); } + if (!renderInFrame) { + GL11.glRotatef(180.0F - RenderManager.instance.playerViewY, 0.0F, 1.0F, 0.0F); + } + + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, 1.0F, 0.0F); + tessellator.addVertexWithUV((double) (0.0F - f7), (double) (0.0F - f8), 0.0D, (double) f14, (double) f5); + tessellator.addVertexWithUV((double) (f6 - f7), (double) (0.0F - f8), 0.0D, (double) f15, (double) f5); + tessellator.addVertexWithUV((double) (f6 - f7), (double) (1.0F - f8), 0.0D, (double) f15, (double) f4); + tessellator.addVertexWithUV((double) (0.0F - f7), (double) (1.0F - f8), 0.0D, (double) f14, (double) f4); + tessellator.draw(); GL11.glPopMatrix(); } - else - { - int j = itemStack.stackSize; - int b0; - - if (j < 2) - { - b0 = 1; - } - else if (j < 16) - { - b0 = 2; - } - else if (j < 32) - { - b0 = 3; - } - else - { - b0 = 4; - } - - for (int l = 0; l < b0; ++l) - { - GL11.glPushMatrix(); - - if (l > 0) - { - f10 = (this.random.nextFloat() * 2.0F - 1.0F) * 0.3F; - float f16 = (this.random.nextFloat() * 2.0F - 1.0F) * 0.3F; - float f17 = (this.random.nextFloat() * 2.0F - 1.0F) * 0.3F; - GL11.glTranslatef(f10, f16, f17); - } - - if (!renderInFrame) - { - GL11.glRotatef(180.0F - RenderManager.instance.playerViewY, 0.0F, 1.0F, 0.0F); - } - - tessellator.startDrawingQuads(); - tessellator.setNormal(0.0F, 1.0F, 0.0F); - tessellator.addVertexWithUV((double)(0.0F - f7), (double)(0.0F - f8), 0.0D, (double)f14, (double)f5); - tessellator.addVertexWithUV((double)(f6 - f7), (double)(0.0F - f8), 0.0D, (double)f15, (double)f5); - tessellator.addVertexWithUV((double)(f6 - f7), (double)(1.0F - f8), 0.0D, (double)f15, (double)f4); - tessellator.addVertexWithUV((double)(0.0F - f7), (double)(1.0F - f8), 0.0D, (double)f14, (double)f4); - tessellator.draw(); - GL11.glPopMatrix(); - } - } + } GL11.glPopMatrix(); } public void renderInventoryCustomItem(IItemCustomizable scriptCustomItem) { GL11.glPushMatrix(); - int color = scriptCustomItem.getColor(); - float itemRed = (color >> 16 & 255) / 255f; - float itemGreen = (color >> 8 & 255) / 255f; - float itemBlue = (color & 255) / 255f; - GL11.glColor4f(itemRed, itemGreen, itemBlue, 1.0F); + int color = scriptCustomItem.getColor(); + float itemRed = (color >> 16 & 255) / 255f; + float itemGreen = (color >> 8 & 255) / 255f; + float itemBlue = (color & 255) / 255f; + GL11.glColor4f(itemRed, itemGreen, itemBlue, 1.0F); - GL11.glDisable(GL11.GL_LIGHTING); //Forge: Make sure that render states are reset, a renderEffect can derp them up. - GL11.glEnable(GL11.GL_ALPHA_TEST); + GL11.glDisable(GL11.GL_LIGHTING); //Forge: Make sure that render states are reset, a renderEffect can derp them up. + GL11.glEnable(GL11.GL_ALPHA_TEST); - ClientCacheHandler.getImageData(scriptCustomItem.getTexture()).bindTexture(); - renderCustomItemSlot(0,0,16,16, itemRed, itemGreen, itemBlue); + ClientCacheHandler.getImageData(scriptCustomItem.getTexture()).bindTexture(); + renderCustomItemSlot(0, 0, 16, 16, itemRed, itemGreen, itemBlue); - GL11.glEnable(GL11.GL_LIGHTING); - GL11.glDisable(GL11.GL_ALPHA_TEST); + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glDisable(GL11.GL_ALPHA_TEST); - if (scriptCustomItem.getMCItemStack().hasEffect(0)) - { - renderEffect(Minecraft.getMinecraft().getTextureManager(), 0, 0); - } - GL11.glEnable(GL11.GL_LIGHTING); + if (scriptCustomItem.getMCItemStack().hasEffect(0)) { + renderEffect(Minecraft.getMinecraft().getTextureManager(), 0, 0); + } + GL11.glEnable(GL11.GL_LIGHTING); GL11.glPopMatrix(); } - public void renderEffect(TextureManager manager, int x, int y) - { + public void renderEffect(TextureManager manager, int x, int y) { GL11.glDepthFunc(GL11.GL_EQUAL); GL11.glDisable(GL11.GL_LIGHTING); GL11.glDepthMask(false); @@ -428,28 +388,25 @@ public class ItemCustomRenderer implements IItemRenderer { GL11.glDepthFunc(GL11.GL_LEQUAL); } - private void renderGlint(int p_77018_2_, int p_77018_3_, int p_77018_4_, int p_77018_5_) - { - for (int j1 = 0; j1 < 2; ++j1) - { + private void renderGlint(int p_77018_2_, int p_77018_3_, int p_77018_4_, int p_77018_5_) { + for (int j1 = 0; j1 < 2; ++j1) { OpenGlHelper.glBlendFunc(772, 1, 0, 0); float f = 0.00390625F; float f1 = 0.00390625F; - float f2 = (float)(Minecraft.getSystemTime() % (long)(3000 + j1 * 1873)) / (3000.0F + (float)(j1 * 1873)) * 256.0F; + float f2 = (float) (Minecraft.getSystemTime() % (long) (3000 + j1 * 1873)) / (3000.0F + (float) (j1 * 1873)) * 256.0F; float f3 = 0.0F; Tessellator tessellator = Tessellator.instance; float f4 = 4.0F; - if (j1 == 1) - { + if (j1 == 1) { f4 = -1.0F; } tessellator.startDrawingQuads(); - tessellator.addVertexWithUV((double)(p_77018_2_ + 0), (double)(p_77018_3_ + p_77018_5_), 0, (double)((f2 + (float)p_77018_5_ * f4) * f), (double)((f3 + (float)p_77018_5_) * f1)); - tessellator.addVertexWithUV((double)(p_77018_2_ + p_77018_4_), (double)(p_77018_3_ + p_77018_5_), 0, (double)((f2 + (float)p_77018_4_ + (float)p_77018_5_ * f4) * f), (double)((f3 + (float)p_77018_5_) * f1)); - tessellator.addVertexWithUV((double)(p_77018_2_ + p_77018_4_), (double)(p_77018_3_ + 0), 0, (double)((f2 + (float)p_77018_4_) * f), (double)((f3 + 0.0F) * f1)); - tessellator.addVertexWithUV((double)(p_77018_2_ + 0), (double)(p_77018_3_ + 0), 0, (double)((f2 + 0.0F) * f), (double)((f3 + 0.0F) * f1)); + tessellator.addVertexWithUV((double) (p_77018_2_ + 0), (double) (p_77018_3_ + p_77018_5_), 0, (double) ((f2 + (float) p_77018_5_ * f4) * f), (double) ((f3 + (float) p_77018_5_) * f1)); + tessellator.addVertexWithUV((double) (p_77018_2_ + p_77018_4_), (double) (p_77018_3_ + p_77018_5_), 0, (double) ((f2 + (float) p_77018_4_ + (float) p_77018_5_ * f4) * f), (double) ((f3 + (float) p_77018_5_) * f1)); + tessellator.addVertexWithUV((double) (p_77018_2_ + p_77018_4_), (double) (p_77018_3_ + 0), 0, (double) ((f2 + (float) p_77018_4_) * f), (double) ((f3 + 0.0F) * f1)); + tessellator.addVertexWithUV((double) (p_77018_2_ + 0), (double) (p_77018_3_ + 0), 0, (double) ((f2 + 0.0F) * f), (double) ((f3 + 0.0F) * f1)); tessellator.draw(); } } @@ -458,10 +415,10 @@ public class ItemCustomRenderer implements IItemRenderer { Tessellator tessellator = Tessellator.instance; tessellator.startDrawingQuads(); tessellator.setColorRGBA_F(itemRed, itemGreen, itemBlue, 1.0F); - tessellator.addVertexWithUV((double)(posX), (double)(posY + imageHeight), 0, 0, 1); - tessellator.addVertexWithUV((double)(posX + imageWidth), (double)(posY + imageHeight), 0, 1, 1); - tessellator.addVertexWithUV((double)(posX + imageWidth), (double)(posY), 0, 1, 0); - tessellator.addVertexWithUV((double)(posX), (double)(posY), 0, 0, 0); + tessellator.addVertexWithUV((double) (posX), (double) (posY + imageHeight), 0, 0, 1); + tessellator.addVertexWithUV((double) (posX + imageWidth), (double) (posY + imageHeight), 0, 1, 1); + tessellator.addVertexWithUV((double) (posX + imageWidth), (double) (posY), 0, 1, 0); + tessellator.addVertexWithUV((double) (posX), (double) (posY), 0, 0, 0); tessellator.draw(); } @@ -525,42 +482,40 @@ public class ItemCustomRenderer implements IItemRenderer { GL11.glDisable(GL12.GL_RESCALE_NORMAL); } - public static void renderCustomItemIn2D(IItemCustomizable wrapper, Tessellator p_78439_0_, float p_78439_1_, float p_78439_2_, float p_78439_3_, float p_78439_4_, float p_78439_7_) - { + public static void renderCustomItemIn2D(IItemCustomizable wrapper, Tessellator p_78439_0_, float p_78439_1_, float p_78439_2_, float p_78439_3_, float p_78439_4_, float p_78439_7_) { ImageData imageData = ClientCacheHandler.getImageData(wrapper.getTexture()); int width = imageData.getTotalWidth(); int height = imageData.getTotalHeight(); p_78439_0_.startDrawingQuads(); p_78439_0_.setNormal(0.0F, 0.0F, 1.0F); - p_78439_0_.addVertexWithUV(0.0D, 0.0D, 0.0D, (double)p_78439_1_, (double)p_78439_4_); - p_78439_0_.addVertexWithUV(1.0D, 0.0D, 0.0D, (double)p_78439_3_, (double)p_78439_4_); - p_78439_0_.addVertexWithUV(1.0D, 1.0D, 0.0D, (double)p_78439_3_, (double)p_78439_2_); - p_78439_0_.addVertexWithUV(0.0D, 1.0D, 0.0D, (double)p_78439_1_, (double)p_78439_2_); + p_78439_0_.addVertexWithUV(0.0D, 0.0D, 0.0D, (double) p_78439_1_, (double) p_78439_4_); + p_78439_0_.addVertexWithUV(1.0D, 0.0D, 0.0D, (double) p_78439_3_, (double) p_78439_4_); + p_78439_0_.addVertexWithUV(1.0D, 1.0D, 0.0D, (double) p_78439_3_, (double) p_78439_2_); + p_78439_0_.addVertexWithUV(0.0D, 1.0D, 0.0D, (double) p_78439_1_, (double) p_78439_2_); p_78439_0_.draw(); p_78439_0_.startDrawingQuads(); p_78439_0_.setNormal(0.0F, 0.0F, -1.0F); - p_78439_0_.addVertexWithUV(0.0D, 1.0D, (double)(0.0F - p_78439_7_), (double)p_78439_1_, (double)p_78439_2_); - p_78439_0_.addVertexWithUV(1.0D, 1.0D, (double)(0.0F - p_78439_7_), (double)p_78439_3_, (double)p_78439_2_); - p_78439_0_.addVertexWithUV(1.0D, 0.0D, (double)(0.0F - p_78439_7_), (double)p_78439_3_, (double)p_78439_4_); - p_78439_0_.addVertexWithUV(0.0D, 0.0D, (double)(0.0F - p_78439_7_), (double)p_78439_1_, (double)p_78439_4_); + p_78439_0_.addVertexWithUV(0.0D, 1.0D, (double) (0.0F - p_78439_7_), (double) p_78439_1_, (double) p_78439_2_); + p_78439_0_.addVertexWithUV(1.0D, 1.0D, (double) (0.0F - p_78439_7_), (double) p_78439_3_, (double) p_78439_2_); + p_78439_0_.addVertexWithUV(1.0D, 0.0D, (double) (0.0F - p_78439_7_), (double) p_78439_3_, (double) p_78439_4_); + p_78439_0_.addVertexWithUV(0.0D, 0.0D, (double) (0.0F - p_78439_7_), (double) p_78439_1_, (double) p_78439_4_); p_78439_0_.draw(); - float f5 = 0.5F * (p_78439_1_ - p_78439_3_) / (float)width; - float f6 = 0.5F * (p_78439_4_ - p_78439_2_) / (float)height; + float f5 = 0.5F * (p_78439_1_ - p_78439_3_) / (float) width; + float f6 = 0.5F * (p_78439_4_ - p_78439_2_) / (float) height; p_78439_0_.startDrawingQuads(); p_78439_0_.setNormal(-1.0F, 0.0F, 0.0F); int k; float f7; float f8; - for (k = 0; k < width; ++k) - { - f7 = (float)k / (float)width; + for (k = 0; k < width; ++k) { + f7 = (float) k / (float) width; f8 = p_78439_1_ + (p_78439_3_ - p_78439_1_) * f7 - f5; - p_78439_0_.addVertexWithUV((double)f7, 0.0D, (double)(0.0F - p_78439_7_), (double)f8, (double)p_78439_4_); - p_78439_0_.addVertexWithUV((double)f7, 0.0D, 0.0D, (double)f8, (double)p_78439_4_); - p_78439_0_.addVertexWithUV((double)f7, 1.0D, 0.0D, (double)f8, (double)p_78439_2_); - p_78439_0_.addVertexWithUV((double)f7, 1.0D, (double)(0.0F - p_78439_7_), (double)f8, (double)p_78439_2_); + p_78439_0_.addVertexWithUV((double) f7, 0.0D, (double) (0.0F - p_78439_7_), (double) f8, (double) p_78439_4_); + p_78439_0_.addVertexWithUV((double) f7, 0.0D, 0.0D, (double) f8, (double) p_78439_4_); + p_78439_0_.addVertexWithUV((double) f7, 1.0D, 0.0D, (double) f8, (double) p_78439_2_); + p_78439_0_.addVertexWithUV((double) f7, 1.0D, (double) (0.0F - p_78439_7_), (double) f8, (double) p_78439_2_); } p_78439_0_.draw(); @@ -568,44 +523,41 @@ public class ItemCustomRenderer implements IItemRenderer { p_78439_0_.setNormal(1.0F, 0.0F, 0.0F); float f9; - for (k = 0; k < width; ++k) - { - f7 = (float)k / (float)width; + for (k = 0; k < width; ++k) { + f7 = (float) k / (float) width; f8 = p_78439_1_ + (p_78439_3_ - p_78439_1_) * f7 - f5; - f9 = f7 + 1.0F / (float)width; - p_78439_0_.addVertexWithUV((double)f9, 1.0D, (double)(0.0F - p_78439_7_), (double)f8, (double)p_78439_2_); - p_78439_0_.addVertexWithUV((double)f9, 1.0D, 0.0D, (double)f8, (double)p_78439_2_); - p_78439_0_.addVertexWithUV((double)f9, 0.0D, 0.0D, (double)f8, (double)p_78439_4_); - p_78439_0_.addVertexWithUV((double)f9, 0.0D, (double)(0.0F - p_78439_7_), (double)f8, (double)p_78439_4_); + f9 = f7 + 1.0F / (float) width; + p_78439_0_.addVertexWithUV((double) f9, 1.0D, (double) (0.0F - p_78439_7_), (double) f8, (double) p_78439_2_); + p_78439_0_.addVertexWithUV((double) f9, 1.0D, 0.0D, (double) f8, (double) p_78439_2_); + p_78439_0_.addVertexWithUV((double) f9, 0.0D, 0.0D, (double) f8, (double) p_78439_4_); + p_78439_0_.addVertexWithUV((double) f9, 0.0D, (double) (0.0F - p_78439_7_), (double) f8, (double) p_78439_4_); } p_78439_0_.draw(); p_78439_0_.startDrawingQuads(); p_78439_0_.setNormal(0.0F, 1.0F, 0.0F); - for (k = 0; k < height; ++k) - { - f7 = (float)k / (float)height; + for (k = 0; k < height; ++k) { + f7 = (float) k / (float) height; f8 = p_78439_4_ + (p_78439_2_ - p_78439_4_) * f7 - f6; - f9 = f7 + 1.0F / (float)height; - p_78439_0_.addVertexWithUV(0.0D, (double)f9, 0.0D, (double)p_78439_1_, (double)f8); - p_78439_0_.addVertexWithUV(1.0D, (double)f9, 0.0D, (double)p_78439_3_, (double)f8); - p_78439_0_.addVertexWithUV(1.0D, (double)f9, (double)(0.0F - p_78439_7_), (double)p_78439_3_, (double)f8); - p_78439_0_.addVertexWithUV(0.0D, (double)f9, (double)(0.0F - p_78439_7_), (double)p_78439_1_, (double)f8); + f9 = f7 + 1.0F / (float) height; + p_78439_0_.addVertexWithUV(0.0D, (double) f9, 0.0D, (double) p_78439_1_, (double) f8); + p_78439_0_.addVertexWithUV(1.0D, (double) f9, 0.0D, (double) p_78439_3_, (double) f8); + p_78439_0_.addVertexWithUV(1.0D, (double) f9, (double) (0.0F - p_78439_7_), (double) p_78439_3_, (double) f8); + p_78439_0_.addVertexWithUV(0.0D, (double) f9, (double) (0.0F - p_78439_7_), (double) p_78439_1_, (double) f8); } p_78439_0_.draw(); p_78439_0_.startDrawingQuads(); p_78439_0_.setNormal(0.0F, -1.0F, 0.0F); - for (k = 0; k < height; ++k) - { - f7 = (float)k / (float)height; + for (k = 0; k < height; ++k) { + f7 = (float) k / (float) height; f8 = p_78439_4_ + (p_78439_2_ - p_78439_4_) * f7 - f6; - p_78439_0_.addVertexWithUV(1.0D, (double)f7, 0.0D, (double)p_78439_3_, (double)f8); - p_78439_0_.addVertexWithUV(0.0D, (double)f7, 0.0D, (double)p_78439_1_, (double)f8); - p_78439_0_.addVertexWithUV(0.0D, (double)f7, (double)(0.0F - p_78439_7_), (double)p_78439_1_, (double)f8); - p_78439_0_.addVertexWithUV(1.0D, (double)f7, (double)(0.0F - p_78439_7_), (double)p_78439_3_, (double)f8); + p_78439_0_.addVertexWithUV(1.0D, (double) f7, 0.0D, (double) p_78439_3_, (double) f8); + p_78439_0_.addVertexWithUV(0.0D, (double) f7, 0.0D, (double) p_78439_1_, (double) f8); + p_78439_0_.addVertexWithUV(0.0D, (double) f7, (double) (0.0F - p_78439_7_), (double) p_78439_1_, (double) f8); + p_78439_0_.addVertexWithUV(1.0D, (double) f7, (double) (0.0F - p_78439_7_), (double) p_78439_3_, (double) f8); } p_78439_0_.draw(); diff --git a/src/main/java/noppes/npcs/client/renderer/items/ItemShortLampRenderer.java b/src/main/java/noppes/npcs/client/renderer/items/ItemShortLampRenderer.java index 00f00da84..8f6f360c4 100644 --- a/src/main/java/noppes/npcs/client/renderer/items/ItemShortLampRenderer.java +++ b/src/main/java/noppes/npcs/client/renderer/items/ItemShortLampRenderer.java @@ -31,7 +31,7 @@ public class ItemShortLampRenderer implements IItemRenderer { GL11.glEnable(GL11.GL_ALPHA_TEST); GL11.glPushMatrix(); - if (type == ItemRenderType.EQUIPPED || type == ItemRenderType.EQUIPPED_FIRST_PERSON){ + if (type == ItemRenderType.EQUIPPED || type == ItemRenderType.EQUIPPED_FIRST_PERSON) { GL11.glTranslatef(0.5F, 0.5F, 0.5F); } diff --git a/src/main/java/noppes/npcs/client/renderer/items/ItemTallLampRenderer.java b/src/main/java/noppes/npcs/client/renderer/items/ItemTallLampRenderer.java index a40705fac..70e45f8e1 100644 --- a/src/main/java/noppes/npcs/client/renderer/items/ItemTallLampRenderer.java +++ b/src/main/java/noppes/npcs/client/renderer/items/ItemTallLampRenderer.java @@ -35,7 +35,7 @@ public class ItemTallLampRenderer implements IItemRenderer { GL11.glEnable(GL11.GL_ALPHA_TEST); GL11.glPushMatrix(); - if (type == ItemRenderType.EQUIPPED || type == ItemRenderType.EQUIPPED_FIRST_PERSON){ + if (type == ItemRenderType.EQUIPPED || type == ItemRenderType.EQUIPPED_FIRST_PERSON) { GL11.glTranslatef(0.5F, 0.5F, 0.5F); } @@ -45,7 +45,7 @@ public class ItemTallLampRenderer implements IItemRenderer { GL11.glRotatef(180, 0, 1, 0); TextureManager manager = Minecraft.getMinecraft().getTextureManager(); - if(ConfigClient.LegacyTallLamp){ + if (ConfigClient.LegacyTallLamp) { BlockRendererInterface.setMaterialTexture(meta); GL11.glColor3f(1, 1, 1); BlockTallLampRenderer.modelLegacy.render(null, 0, 0, 0, 0, 0.0F, 0.0625F); @@ -58,7 +58,7 @@ public class ItemTallLampRenderer implements IItemRenderer { BlockTallLampRenderer.model.Lamp.render(0.0625F); BlockTallLampRenderer.model.Light.render(0.0625F); GL11.glColor3f(color[0], color[1], color[2]); - BlockTallLampRenderer. model.Shade.render(0.0625F); + BlockTallLampRenderer.model.Shade.render(0.0625F); } GL11.glDisable(GL11.GL_ALPHA_TEST); diff --git a/src/main/java/noppes/npcs/client/renderer/items/ItemToolRenderer.java b/src/main/java/noppes/npcs/client/renderer/items/ItemToolRenderer.java index 6cf9aac84..c2ef3c5d1 100644 --- a/src/main/java/noppes/npcs/client/renderer/items/ItemToolRenderer.java +++ b/src/main/java/noppes/npcs/client/renderer/items/ItemToolRenderer.java @@ -60,7 +60,7 @@ public class ItemToolRenderer implements IItemRenderer { if (!entityItem.ignoreFrustumCheck) { entityItem.ignoreFrustumCheck = true; - float entityXZSize = (float) Math.sqrt(Math.pow(1,2) + Math.pow(1,2)); + float entityXZSize = (float) Math.sqrt(Math.pow(1, 2) + Math.pow(1, 2)); this.setEntitySize(entityItem, entityXZSize * 0.25F, 1 * 0.25F); double XSize = entityItem.boundingBox.maxX - entityItem.boundingBox.minX; @@ -70,7 +70,7 @@ public class ItemToolRenderer implements IItemRenderer { entityItem.boundingBox.maxY = entityItem.boundingBox.minY + YSize * 1; entityItem.boundingBox.maxZ = entityItem.boundingBox.minZ + ZSize * 1; } - if(itemStack.getItemDamage() == 1){ + if (itemStack.getItemDamage() == 1) { renderEntityCustomItem(itemStack, entityItem, PAINTBRUSH_HANDLE); int color = ItemNpcTool.getColor(itemStack.getTagCompound()); float red = ((color >> 16) & 0xFF) / 255.0F; @@ -98,7 +98,7 @@ public class ItemToolRenderer implements IItemRenderer { EntityLivingBase entityLivingBase = (EntityLivingBase) data[1]; - if(itemStack.getItemDamage() == 1){ + if (itemStack.getItemDamage() == 1) { GL11.glPushMatrix(); renderItem3d(entityLivingBase, itemStack, PAINTBRUSH_HANDLE); GL11.glPopMatrix(); @@ -121,49 +121,35 @@ public class ItemToolRenderer implements IItemRenderer { GL11.glPopMatrix(); } - private void setEntitySize(EntityItem entityItem, float p_70105_1_, float p_70105_2_) - { + private void setEntitySize(EntityItem entityItem, float p_70105_1_, float p_70105_2_) { float f2; - if (p_70105_1_ != entityItem.width || p_70105_2_ != entityItem.height) - { + if (p_70105_1_ != entityItem.width || p_70105_2_ != entityItem.height) { f2 = entityItem.width; entityItem.width = p_70105_1_; entityItem.height = p_70105_2_; - entityItem.boundingBox.maxX = entityItem.boundingBox.minX + (double)entityItem.width; - entityItem.boundingBox.maxZ = entityItem.boundingBox.minZ + (double)entityItem.width; - entityItem.boundingBox.maxY = entityItem.boundingBox.minY + (double)entityItem.height; + entityItem.boundingBox.maxX = entityItem.boundingBox.minX + (double) entityItem.width; + entityItem.boundingBox.maxZ = entityItem.boundingBox.minZ + (double) entityItem.width; + entityItem.boundingBox.maxY = entityItem.boundingBox.minY + (double) entityItem.height; - if (entityItem.width > f2 && !entityItem.firstUpdate && !entityItem.worldObj.isRemote) - { - entityItem.moveEntity((double)(f2 - entityItem.width), 0.0D, (double)(f2 - entityItem.width)); + if (entityItem.width > f2 && !entityItem.firstUpdate && !entityItem.worldObj.isRemote) { + entityItem.moveEntity((double) (f2 - entityItem.width), 0.0D, (double) (f2 - entityItem.width)); } } f2 = p_70105_1_ % 2.0F; - if ((double)f2 < 0.375D) - { + if ((double) f2 < 0.375D) { entityItem.myEntitySize = Entity.EnumEntitySize.SIZE_1; - } - else if ((double)f2 < 0.75D) - { + } else if ((double) f2 < 0.75D) { entityItem.myEntitySize = Entity.EnumEntitySize.SIZE_2; - } - else if ((double)f2 < 1.0D) - { + } else if ((double) f2 < 1.0D) { entityItem.myEntitySize = Entity.EnumEntitySize.SIZE_3; - } - else if ((double)f2 < 1.375D) - { + } else if ((double) f2 < 1.375D) { entityItem.myEntitySize = Entity.EnumEntitySize.SIZE_4; - } - else if ((double)f2 < 1.75D) - { + } else if ((double) f2 < 1.75D) { entityItem.myEntitySize = Entity.EnumEntitySize.SIZE_5; - } - else - { + } else { entityItem.myEntitySize = Entity.EnumEntitySize.SIZE_6; } } @@ -175,10 +161,9 @@ public class ItemToolRenderer implements IItemRenderer { TextureManager textureManager = Minecraft.getMinecraft().getTextureManager(); textureManager.bindTexture(location); - if (renderInFrame) - { + if (renderInFrame) { GL11.glTranslatef(0.0F, -0.05F, 0.0F); - GL11.glScalef(1.025641F,1.025641F,1.025641F); + GL11.glScalef(1.025641F, 1.025641F, 1.025641F); GL11.glRotatef(180.0F, 0.0F, 1.0F, 0.0F); } @@ -193,8 +178,7 @@ public class ItemToolRenderer implements IItemRenderer { float f8 = 0.25F; float f10; - if (RenderManager.instance.options.fancyGraphics) - { + if (RenderManager.instance.options.fancyGraphics) { GL11.glPushMatrix(); float f9 = 0.0625F; @@ -202,31 +186,22 @@ public class ItemToolRenderer implements IItemRenderer { int j = itemStack.stackSize; byte b0; - if (j < 2) - { + if (j < 2) { b0 = 1; - } - else if (j < 16) - { + } else if (j < 16) { b0 = 2; - } - else if (j < 32) - { + } else if (j < 32) { b0 = 3; - } - else - { + } else { b0 = 4; } - GL11.glTranslatef(-f7, -f8, -((f9 + f10) * (float)b0 / 2.0F)); + GL11.glTranslatef(-f7, -f8, -((f9 + f10) * (float) b0 / 2.0F)); - for (int k = 0; k < b0; ++k) - { + for (int k = 0; k < b0; ++k) { GL11.glTranslatef(0f, 0f, f9 + f10); ItemRenderer.renderItemIn2D(tessellator, 1.0F, 0.0F, 0.0F, 1.0F, 16, 16, f9); - if (itemStack.hasEffect(pass)) - { + if (itemStack.hasEffect(pass)) { GL11.glDepthFunc(GL11.GL_EQUAL); GL11.glDisable(GL11.GL_LIGHTING); RenderManager.instance.renderEngine.bindTexture(RES_ITEM_GLINT); @@ -238,14 +213,14 @@ public class ItemToolRenderer implements IItemRenderer { GL11.glPushMatrix(); float f12 = 0.125F; GL11.glScalef(f12, f12, f12); - float f13 = (float)(Minecraft.getSystemTime() % 3000L) / 3000.0F * 8.0F; + float f13 = (float) (Minecraft.getSystemTime() % 3000L) / 3000.0F * 8.0F; GL11.glTranslatef(f13, 0.0F, 0.0F); GL11.glRotatef(-50.0F, 0.0F, 0.0F, 1.0F); ItemRenderer.renderItemIn2D(tessellator, 0.0F, 0.0F, 1.0F, 1.0F, 255, 255, f9); GL11.glPopMatrix(); GL11.glPushMatrix(); GL11.glScalef(f12, f12, f12); - f13 = (float)(Minecraft.getSystemTime() % 4873L) / 4873.0F * 8.0F; + f13 = (float) (Minecraft.getSystemTime() % 4873L) / 4873.0F * 8.0F; GL11.glTranslatef(-f13, 0.0F, 0.0F); GL11.glRotatef(10.0F, 0.0F, 0.0F, 1.0F); ItemRenderer.renderItemIn2D(tessellator, 0.0F, 0.0F, 1.0F, 1.0F, 255, 255, f9); @@ -258,52 +233,40 @@ public class ItemToolRenderer implements IItemRenderer { } GL11.glPopMatrix(); - } - else - { + } else { int j = itemStack.stackSize; int b0; - if (j < 2) - { + if (j < 2) { b0 = 1; - } - else if (j < 16) - { + } else if (j < 16) { b0 = 2; - } - else if (j < 32) - { + } else if (j < 32) { b0 = 3; - } - else - { + } else { b0 = 4; } - for (int l = 0; l < b0; ++l) - { + for (int l = 0; l < b0; ++l) { GL11.glPushMatrix(); - if (l > 0) - { + if (l > 0) { f10 = (this.random.nextFloat() * 2.0F - 1.0F) * 0.3F; float f16 = (this.random.nextFloat() * 2.0F - 1.0F) * 0.3F; float f17 = (this.random.nextFloat() * 2.0F - 1.0F) * 0.3F; GL11.glTranslatef(f10, f16, f17); } - if (!renderInFrame) - { + if (!renderInFrame) { GL11.glRotatef(180.0F - RenderManager.instance.playerViewY, 0.0F, 1.0F, 0.0F); } tessellator.startDrawingQuads(); tessellator.setNormal(0.0F, 1.0F, 0.0F); - tessellator.addVertexWithUV((double)(0.0F - f7), (double)(0.0F - f8), 0.0D, (double)f14, (double)f5); - tessellator.addVertexWithUV((double)(f6 - f7), (double)(0.0F - f8), 0.0D, (double)f15, (double)f5); - tessellator.addVertexWithUV((double)(f6 - f7), (double)(1.0F - f8), 0.0D, (double)f15, (double)f4); - tessellator.addVertexWithUV((double)(0.0F - f7), (double)(1.0F - f8), 0.0D, (double)f14, (double)f4); + tessellator.addVertexWithUV((double) (0.0F - f7), (double) (0.0F - f8), 0.0D, (double) f14, (double) f5); + tessellator.addVertexWithUV((double) (f6 - f7), (double) (0.0F - f8), 0.0D, (double) f15, (double) f5); + tessellator.addVertexWithUV((double) (f6 - f7), (double) (1.0F - f8), 0.0D, (double) f15, (double) f4); + tessellator.addVertexWithUV((double) (0.0F - f7), (double) (1.0F - f8), 0.0D, (double) f14, (double) f4); tessellator.draw(); GL11.glPopMatrix(); } @@ -318,26 +281,25 @@ public class ItemToolRenderer implements IItemRenderer { GL11.glDisable(GL11.GL_LIGHTING); GL11.glEnable(GL11.GL_ALPHA_TEST); - if(itemStack.getItemDamage() == 1){ + if (itemStack.getItemDamage() == 1) { textureManager.bindTexture(PAINTBRUSH_HANDLE); - renderCustomItemSlot(0,0,16,16, 1.0f, 1.0f, 1.0f); + renderCustomItemSlot(0, 0, 16, 16, 1.0f, 1.0f, 1.0f); int color = ItemNpcTool.getColor(itemStack.getTagCompound()); float red = ((color >> 16) & 0xFF) / 255.0F; float green = ((color >> 8) & 0xFF) / 255.0F; float blue = (color & 0xFF) / 255.0F; textureManager.bindTexture(PAINTBRUSH_BRUSH); - renderCustomItemSlot(0,0,16,16, red, green, blue); + renderCustomItemSlot(0, 0, 16, 16, red, green, blue); } else { textureManager.bindTexture(HAMMER); - renderCustomItemSlot(0,0,16,16, 1.0f, 1.0f, 1.0f); + renderCustomItemSlot(0, 0, 16, 16, 1.0f, 1.0f, 1.0f); } GL11.glEnable(GL11.GL_LIGHTING); GL11.glDisable(GL11.GL_ALPHA_TEST); - if (itemStack.hasEffect(0)) - { + if (itemStack.hasEffect(0)) { renderEffect(Minecraft.getMinecraft().getTextureManager(), 0, 0); } @@ -345,8 +307,7 @@ public class ItemToolRenderer implements IItemRenderer { GL11.glPopMatrix(); } - public void renderEffect(TextureManager manager, int x, int y) - { + public void renderEffect(TextureManager manager, int x, int y) { GL11.glDepthFunc(GL11.GL_EQUAL); GL11.glDisable(GL11.GL_LIGHTING); GL11.glDepthMask(false); @@ -362,28 +323,25 @@ public class ItemToolRenderer implements IItemRenderer { GL11.glDepthFunc(GL11.GL_LEQUAL); } - private void renderGlint(int p_77018_2_, int p_77018_3_, int p_77018_4_, int p_77018_5_) - { - for (int j1 = 0; j1 < 2; ++j1) - { + private void renderGlint(int p_77018_2_, int p_77018_3_, int p_77018_4_, int p_77018_5_) { + for (int j1 = 0; j1 < 2; ++j1) { OpenGlHelper.glBlendFunc(772, 1, 0, 0); float f = 0.00390625F; float f1 = 0.00390625F; - float f2 = (float)(Minecraft.getSystemTime() % (long)(3000 + j1 * 1873)) / (3000.0F + (float)(j1 * 1873)) * 256.0F; + float f2 = (float) (Minecraft.getSystemTime() % (long) (3000 + j1 * 1873)) / (3000.0F + (float) (j1 * 1873)) * 256.0F; float f3 = 0.0F; Tessellator tessellator = Tessellator.instance; float f4 = 4.0F; - if (j1 == 1) - { + if (j1 == 1) { f4 = -1.0F; } tessellator.startDrawingQuads(); - tessellator.addVertexWithUV((double)(p_77018_2_ + 0), (double)(p_77018_3_ + p_77018_5_), 0, (double)((f2 + (float)p_77018_5_ * f4) * f), (double)((f3 + (float)p_77018_5_) * f1)); - tessellator.addVertexWithUV((double)(p_77018_2_ + p_77018_4_), (double)(p_77018_3_ + p_77018_5_), 0, (double)((f2 + (float)p_77018_4_ + (float)p_77018_5_ * f4) * f), (double)((f3 + (float)p_77018_5_) * f1)); - tessellator.addVertexWithUV((double)(p_77018_2_ + p_77018_4_), (double)(p_77018_3_ + 0), 0, (double)((f2 + (float)p_77018_4_) * f), (double)((f3 + 0.0F) * f1)); - tessellator.addVertexWithUV((double)(p_77018_2_ + 0), (double)(p_77018_3_ + 0), 0, (double)((f2 + 0.0F) * f), (double)((f3 + 0.0F) * f1)); + tessellator.addVertexWithUV((double) (p_77018_2_ + 0), (double) (p_77018_3_ + p_77018_5_), 0, (double) ((f2 + (float) p_77018_5_ * f4) * f), (double) ((f3 + (float) p_77018_5_) * f1)); + tessellator.addVertexWithUV((double) (p_77018_2_ + p_77018_4_), (double) (p_77018_3_ + p_77018_5_), 0, (double) ((f2 + (float) p_77018_4_ + (float) p_77018_5_ * f4) * f), (double) ((f3 + (float) p_77018_5_) * f1)); + tessellator.addVertexWithUV((double) (p_77018_2_ + p_77018_4_), (double) (p_77018_3_ + 0), 0, (double) ((f2 + (float) p_77018_4_) * f), (double) ((f3 + 0.0F) * f1)); + tessellator.addVertexWithUV((double) (p_77018_2_ + 0), (double) (p_77018_3_ + 0), 0, (double) ((f2 + 0.0F) * f), (double) ((f3 + 0.0F) * f1)); tessellator.draw(); } } @@ -392,10 +350,10 @@ public class ItemToolRenderer implements IItemRenderer { Tessellator tessellator = Tessellator.instance; tessellator.startDrawingQuads(); tessellator.setColorRGBA_F(itemRed, itemGreen, itemBlue, 1.0F); - tessellator.addVertexWithUV((double)(posX), (double)(posY + imageHeight), 0, 0, 1); - tessellator.addVertexWithUV((double)(posX + imageWidth), (double)(posY + imageHeight), 0, 1, 1); - tessellator.addVertexWithUV((double)(posX + imageWidth), (double)(posY), 0, 1, 0); - tessellator.addVertexWithUV((double)(posX), (double)(posY), 0, 0, 0); + tessellator.addVertexWithUV((double) (posX), (double) (posY + imageHeight), 0, 0, 1); + tessellator.addVertexWithUV((double) (posX + imageWidth), (double) (posY + imageHeight), 0, 1, 1); + tessellator.addVertexWithUV((double) (posX + imageWidth), (double) (posY), 0, 1, 0); + tessellator.addVertexWithUV((double) (posX), (double) (posY), 0, 0, 0); tessellator.draw(); } @@ -457,41 +415,39 @@ public class ItemToolRenderer implements IItemRenderer { GL11.glDisable(GL12.GL_RESCALE_NORMAL); } - public static void renderCustomItemIn2D(Tessellator p_78439_0_, float p_78439_1_, float p_78439_2_, float p_78439_3_, float p_78439_4_, float p_78439_7_) - { + public static void renderCustomItemIn2D(Tessellator p_78439_0_, float p_78439_1_, float p_78439_2_, float p_78439_3_, float p_78439_4_, float p_78439_7_) { int width = 16; int height = 16; p_78439_0_.startDrawingQuads(); p_78439_0_.setNormal(0.0F, 0.0F, 1.0F); - p_78439_0_.addVertexWithUV(0.0D, 0.0D, 0.0D, (double)p_78439_1_, (double)p_78439_4_); - p_78439_0_.addVertexWithUV(1.0D, 0.0D, 0.0D, (double)p_78439_3_, (double)p_78439_4_); - p_78439_0_.addVertexWithUV(1.0D, 1.0D, 0.0D, (double)p_78439_3_, (double)p_78439_2_); - p_78439_0_.addVertexWithUV(0.0D, 1.0D, 0.0D, (double)p_78439_1_, (double)p_78439_2_); + p_78439_0_.addVertexWithUV(0.0D, 0.0D, 0.0D, (double) p_78439_1_, (double) p_78439_4_); + p_78439_0_.addVertexWithUV(1.0D, 0.0D, 0.0D, (double) p_78439_3_, (double) p_78439_4_); + p_78439_0_.addVertexWithUV(1.0D, 1.0D, 0.0D, (double) p_78439_3_, (double) p_78439_2_); + p_78439_0_.addVertexWithUV(0.0D, 1.0D, 0.0D, (double) p_78439_1_, (double) p_78439_2_); p_78439_0_.draw(); p_78439_0_.startDrawingQuads(); p_78439_0_.setNormal(0.0F, 0.0F, -1.0F); - p_78439_0_.addVertexWithUV(0.0D, 1.0D, (double)(0.0F - p_78439_7_), (double)p_78439_1_, (double)p_78439_2_); - p_78439_0_.addVertexWithUV(1.0D, 1.0D, (double)(0.0F - p_78439_7_), (double)p_78439_3_, (double)p_78439_2_); - p_78439_0_.addVertexWithUV(1.0D, 0.0D, (double)(0.0F - p_78439_7_), (double)p_78439_3_, (double)p_78439_4_); - p_78439_0_.addVertexWithUV(0.0D, 0.0D, (double)(0.0F - p_78439_7_), (double)p_78439_1_, (double)p_78439_4_); + p_78439_0_.addVertexWithUV(0.0D, 1.0D, (double) (0.0F - p_78439_7_), (double) p_78439_1_, (double) p_78439_2_); + p_78439_0_.addVertexWithUV(1.0D, 1.0D, (double) (0.0F - p_78439_7_), (double) p_78439_3_, (double) p_78439_2_); + p_78439_0_.addVertexWithUV(1.0D, 0.0D, (double) (0.0F - p_78439_7_), (double) p_78439_3_, (double) p_78439_4_); + p_78439_0_.addVertexWithUV(0.0D, 0.0D, (double) (0.0F - p_78439_7_), (double) p_78439_1_, (double) p_78439_4_); p_78439_0_.draw(); - float f5 = 0.5F * (p_78439_1_ - p_78439_3_) / (float)width; - float f6 = 0.5F * (p_78439_4_ - p_78439_2_) / (float)height; + float f5 = 0.5F * (p_78439_1_ - p_78439_3_) / (float) width; + float f6 = 0.5F * (p_78439_4_ - p_78439_2_) / (float) height; p_78439_0_.startDrawingQuads(); p_78439_0_.setNormal(-1.0F, 0.0F, 0.0F); int k; float f7; float f8; - for (k = 0; k < width; ++k) - { - f7 = (float)k / (float)width; + for (k = 0; k < width; ++k) { + f7 = (float) k / (float) width; f8 = p_78439_1_ + (p_78439_3_ - p_78439_1_) * f7 - f5; - p_78439_0_.addVertexWithUV((double)f7, 0.0D, (double)(0.0F - p_78439_7_), (double)f8, (double)p_78439_4_); - p_78439_0_.addVertexWithUV((double)f7, 0.0D, 0.0D, (double)f8, (double)p_78439_4_); - p_78439_0_.addVertexWithUV((double)f7, 1.0D, 0.0D, (double)f8, (double)p_78439_2_); - p_78439_0_.addVertexWithUV((double)f7, 1.0D, (double)(0.0F - p_78439_7_), (double)f8, (double)p_78439_2_); + p_78439_0_.addVertexWithUV((double) f7, 0.0D, (double) (0.0F - p_78439_7_), (double) f8, (double) p_78439_4_); + p_78439_0_.addVertexWithUV((double) f7, 0.0D, 0.0D, (double) f8, (double) p_78439_4_); + p_78439_0_.addVertexWithUV((double) f7, 1.0D, 0.0D, (double) f8, (double) p_78439_2_); + p_78439_0_.addVertexWithUV((double) f7, 1.0D, (double) (0.0F - p_78439_7_), (double) f8, (double) p_78439_2_); } p_78439_0_.draw(); @@ -499,44 +455,41 @@ public class ItemToolRenderer implements IItemRenderer { p_78439_0_.setNormal(1.0F, 0.0F, 0.0F); float f9; - for (k = 0; k < width; ++k) - { - f7 = (float)k / (float)width; + for (k = 0; k < width; ++k) { + f7 = (float) k / (float) width; f8 = p_78439_1_ + (p_78439_3_ - p_78439_1_) * f7 - f5; - f9 = f7 + 1.0F / (float)width; - p_78439_0_.addVertexWithUV((double)f9, 1.0D, (double)(0.0F - p_78439_7_), (double)f8, (double)p_78439_2_); - p_78439_0_.addVertexWithUV((double)f9, 1.0D, 0.0D, (double)f8, (double)p_78439_2_); - p_78439_0_.addVertexWithUV((double)f9, 0.0D, 0.0D, (double)f8, (double)p_78439_4_); - p_78439_0_.addVertexWithUV((double)f9, 0.0D, (double)(0.0F - p_78439_7_), (double)f8, (double)p_78439_4_); + f9 = f7 + 1.0F / (float) width; + p_78439_0_.addVertexWithUV((double) f9, 1.0D, (double) (0.0F - p_78439_7_), (double) f8, (double) p_78439_2_); + p_78439_0_.addVertexWithUV((double) f9, 1.0D, 0.0D, (double) f8, (double) p_78439_2_); + p_78439_0_.addVertexWithUV((double) f9, 0.0D, 0.0D, (double) f8, (double) p_78439_4_); + p_78439_0_.addVertexWithUV((double) f9, 0.0D, (double) (0.0F - p_78439_7_), (double) f8, (double) p_78439_4_); } p_78439_0_.draw(); p_78439_0_.startDrawingQuads(); p_78439_0_.setNormal(0.0F, 1.0F, 0.0F); - for (k = 0; k < height; ++k) - { - f7 = (float)k / (float)height; + for (k = 0; k < height; ++k) { + f7 = (float) k / (float) height; f8 = p_78439_4_ + (p_78439_2_ - p_78439_4_) * f7 - f6; - f9 = f7 + 1.0F / (float)height; - p_78439_0_.addVertexWithUV(0.0D, (double)f9, 0.0D, (double)p_78439_1_, (double)f8); - p_78439_0_.addVertexWithUV(1.0D, (double)f9, 0.0D, (double)p_78439_3_, (double)f8); - p_78439_0_.addVertexWithUV(1.0D, (double)f9, (double)(0.0F - p_78439_7_), (double)p_78439_3_, (double)f8); - p_78439_0_.addVertexWithUV(0.0D, (double)f9, (double)(0.0F - p_78439_7_), (double)p_78439_1_, (double)f8); + f9 = f7 + 1.0F / (float) height; + p_78439_0_.addVertexWithUV(0.0D, (double) f9, 0.0D, (double) p_78439_1_, (double) f8); + p_78439_0_.addVertexWithUV(1.0D, (double) f9, 0.0D, (double) p_78439_3_, (double) f8); + p_78439_0_.addVertexWithUV(1.0D, (double) f9, (double) (0.0F - p_78439_7_), (double) p_78439_3_, (double) f8); + p_78439_0_.addVertexWithUV(0.0D, (double) f9, (double) (0.0F - p_78439_7_), (double) p_78439_1_, (double) f8); } p_78439_0_.draw(); p_78439_0_.startDrawingQuads(); p_78439_0_.setNormal(0.0F, -1.0F, 0.0F); - for (k = 0; k < height; ++k) - { - f7 = (float)k / (float)height; + for (k = 0; k < height; ++k) { + f7 = (float) k / (float) height; f8 = p_78439_4_ + (p_78439_2_ - p_78439_4_) * f7 - f6; - p_78439_0_.addVertexWithUV(1.0D, (double)f7, 0.0D, (double)p_78439_3_, (double)f8); - p_78439_0_.addVertexWithUV(0.0D, (double)f7, 0.0D, (double)p_78439_1_, (double)f8); - p_78439_0_.addVertexWithUV(0.0D, (double)f7, (double)(0.0F - p_78439_7_), (double)p_78439_1_, (double)f8); - p_78439_0_.addVertexWithUV(1.0D, (double)f7, (double)(0.0F - p_78439_7_), (double)p_78439_3_, (double)f8); + p_78439_0_.addVertexWithUV(1.0D, (double) f7, 0.0D, (double) p_78439_3_, (double) f8); + p_78439_0_.addVertexWithUV(0.0D, (double) f7, 0.0D, (double) p_78439_1_, (double) f8); + p_78439_0_.addVertexWithUV(0.0D, (double) f7, (double) (0.0F - p_78439_7_), (double) p_78439_1_, (double) f8); + p_78439_0_.addVertexWithUV(1.0D, (double) f7, (double) (0.0F - p_78439_7_), (double) p_78439_3_, (double) f8); } p_78439_0_.draw(); diff --git a/src/main/java/noppes/npcs/compat/PixelmonHelper.java b/src/main/java/noppes/npcs/compat/PixelmonHelper.java index 2a4e996e1..670fe1015 100644 --- a/src/main/java/noppes/npcs/compat/PixelmonHelper.java +++ b/src/main/java/noppes/npcs/compat/PixelmonHelper.java @@ -26,290 +26,285 @@ import java.util.List; public class PixelmonHelper { public static boolean Enabled = false; - - private static Object PokeballManager = null; + + private static Object PokeballManager = null; private static Method getPlayerStorage = null; - + private static Object ComputerManager = null; private static Method getPlayerComputerStorage = null; private static Constructor attackByID = null; - private static Constructor attackByName = null; + private static Constructor attackByName = null; private static Field baseAttack = null; private static Field getAttackID = null; private static Field getAttackName = null; private static Method getPixelmonModel = null; - - public static void load(){ - Enabled = Loader.isModLoaded("pixelmon"); - if(!Enabled) - return; - try{ - Class c = Class.forName("com.pixelmonmod.pixelmon.storage.PixelmonStorage"); - PokeballManager = c.getField("PokeballManager").get(null); - ComputerManager = c.getField("ComputerManager").get(null); + public static void load() { + Enabled = Loader.isModLoaded("pixelmon"); + if (!Enabled) + return; - getPlayerStorage = PokeballManager.getClass().getMethod("getPlayerStorage", EntityPlayerMP.class); - getPlayerComputerStorage = ComputerManager.getClass().getMethod("getPlayerStorage", EntityPlayerMP.class); - - c = Class.forName("com.pixelmonmod.pixelmon.battles.attacks.Attack"); - attackByID = c.getConstructor(int.class); - attackByName = c.getConstructor(String.class); - baseAttack = c.getField("baseAttack"); + try { + Class c = Class.forName("com.pixelmonmod.pixelmon.storage.PixelmonStorage"); + PokeballManager = c.getField("PokeballManager").get(null); + ComputerManager = c.getField("ComputerManager").get(null); - c = Class.forName("com.pixelmonmod.pixelmon.battles.attacks.AttackBase"); - getAttackID = c.getField("attackIndex"); - getAttackName = c.getDeclaredField("attackName"); - + getPlayerStorage = PokeballManager.getClass().getMethod("getPlayerStorage", EntityPlayerMP.class); + getPlayerComputerStorage = ComputerManager.getClass().getMethod("getPlayerStorage", EntityPlayerMP.class); - c = Class.forName("com.pixelmonmod.pixelmon.entities.pixelmon.Entity2HasModel"); - getPixelmonModel = c.getMethod("getModel"); + c = Class.forName("com.pixelmonmod.pixelmon.battles.attacks.Attack"); + attackByID = c.getConstructor(int.class); + attackByName = c.getConstructor(String.class); + baseAttack = c.getField("baseAttack"); + + c = Class.forName("com.pixelmonmod.pixelmon.battles.attacks.AttackBase"); + getAttackID = c.getField("attackIndex"); + getAttackName = c.getDeclaredField("attackName"); + + + c = Class.forName("com.pixelmonmod.pixelmon.entities.pixelmon.Entity2HasModel"); + getPixelmonModel = c.getMethod("getModel"); + } catch (Exception e) { + LogWriter.except(e); } - catch(Exception e){ - LogWriter.except(e); + + } + + public static List getPixelmonList() { + List list = new ArrayList(); + if (!Enabled) + return list; + try { + Class c = Class.forName("com.pixelmonmod.pixelmon.enums.EnumPokemon"); + Object[] array = c.getEnumConstants(); + for (Object ob : array) + list.add(ob.toString()); + + } catch (Exception e) { + LogManager.getLogger().error("getPixelmonList", e); } - - } - - public static List getPixelmonList(){ - List list = new ArrayList(); - if(!Enabled) - return list; - try { - Class c = Class.forName("com.pixelmonmod.pixelmon.enums.EnumPokemon"); - Object[] array = c.getEnumConstants(); - for(Object ob : array) - list.add(ob.toString()); - - } catch (Exception e) { - LogManager.getLogger().error("getPixelmonList", e); - } - return list; - } + return list; + } - public static boolean isPixelmon(Entity entity) { - if(!Enabled) - return false; - String s = EntityList.getEntityString(entity); - if(s == null) - return false; - return s.equals("pixelmon.Pixelmon"); - } + public static boolean isPixelmon(Entity entity) { + if (!Enabled) + return false; + String s = EntityList.getEntityString(entity); + if (s == null) + return false; + return s.equals("pixelmon.Pixelmon"); + } - public static void setName(EntityLivingBase entity, String name) { - if(!Enabled || !isPixelmon(entity)) - return; - try { - Method m = entity.getClass().getMethod("init", String.class); - m.invoke(entity, name); + public static void setName(EntityLivingBase entity, String name) { + if (!Enabled || !isPixelmon(entity)) + return; + try { + Method m = entity.getClass().getMethod("init", String.class); + m.invoke(entity, name); - Class c = Class.forName("com.pixelmonmod.pixelmon.entities.pixelmon.Entity2HasModel"); - m = c.getDeclaredMethod("loadModel"); - m.setAccessible(true); - m.invoke(entity); - } catch (Exception e) { - LogManager.getLogger().error("setName", e); - } - } - - public static String getName(EntityLivingBase entity) { - if(!Enabled || !isPixelmon(entity)) - return ""; - try { - Method m = entity.getClass().getMethod("getName"); - return m.invoke(entity).toString(); - } catch (Exception e) { - LogManager.getLogger().error("getName", e); - } - return ""; - } + Class c = Class.forName("com.pixelmonmod.pixelmon.entities.pixelmon.Entity2HasModel"); + m = c.getDeclaredMethod("loadModel"); + m.setAccessible(true); + m.invoke(entity); + } catch (Exception e) { + LogManager.getLogger().error("setName", e); + } + } - - public static Object getModel(EntityLivingBase entity){ - try { - return getPixelmonModel.invoke(entity); - } catch (Exception e) { - LogManager.getLogger().error("getModel", e); - } - return null; - } + public static String getName(EntityLivingBase entity) { + if (!Enabled || !isPixelmon(entity)) + return ""; + try { + Method m = entity.getClass().getMethod("getName"); + return m.invoke(entity).toString(); + } catch (Exception e) { + LogManager.getLogger().error("getName", e); + } + return ""; + } - public static void debug(EntityLivingBase entity) { - if(!Enabled || !isPixelmon(entity)) - return; - try { - Method m = entity.getClass().getMethod("getModel"); - Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText((String) m.invoke(entity))); - } catch (Exception e) { - e.printStackTrace(); - } - } + public static Object getModel(EntityLivingBase entity) { + try { + return getPixelmonModel.invoke(entity); + } catch (Exception e) { + LogManager.getLogger().error("getModel", e); + } + return null; + } - public static boolean isTrainer(EntityLivingBase entity) { - if(!Enabled) - return false; - String s = EntityList.getEntityString(entity); - if(s == null) - return false; - return s.equals("pixelmon.Trainer"); - } - - public static boolean isBattling(EntityPlayerMP player) { - if(!Enabled) - return false; - try { - Class c = Class.forName("com.pixelmonmod.pixelmon.battles.BattleRegistry"); - Method m = c.getMethod("getBattle", EntityPlayer.class); - if(m.invoke(null, player) != null) - return false; - - return true; - } catch (Exception e) { - LogManager.getLogger().error("canBattle", e); - return false; - } - } - - public static boolean isBattling(EntityLivingBase trainer) { - if(!Enabled || !isTrainer(trainer)) - return false; - try { - Field f = trainer.getClass().getField("battleController"); - - return f.get(trainer) != null; - } catch (Exception e) { - LogManager.getLogger().error("canBattle", e); - return false; - } - } - public static boolean canBattle(EntityPlayerMP player, EntityNPCInterface npc) { - if(!Enabled || npc.advanced.job != EnumJobType.Spawner || isBattling(player)) - return false; - try { - JobSpawner spawner = (JobSpawner) npc.jobInterface; - if(spawner.isOnCooldown(player.getCommandSenderName())) - return false; - - Object ob = getPlayerStorage.invoke(PokeballManager, player); + public static void debug(EntityLivingBase entity) { + if (!Enabled || !isPixelmon(entity)) + return; + try { + Method m = entity.getClass().getMethod("getModel"); + Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText((String) m.invoke(entity))); + } catch (Exception e) { + e.printStackTrace(); + } + } - Method m = ob.getClass().getMethod("countAblePokemon"); - - if((Integer) m.invoke(ob) == 0) - return false; - - return true; - } catch (Exception e) { - LogManager.getLogger().error("canBattle", e); - return false; - } - } - - public static EntityTameable pixelmonFromNBT(NBTTagCompound compound, EntityPlayer player){ - if(!Enabled) - return null; - - try { - Object ob = getPlayerStorage.invoke(PokeballManager, player); - return (EntityTameable) ob.getClass().getMethod("sendOut", NBTTagCompound.class, World.class).invoke(ob, compound, player); - } - catch (Exception e) { - e.printStackTrace(); - } - return null; - } - - - public static NBTTagCompound getPartySlot(int i, EntityPlayer player){ - if(!Enabled) - return null; - - try { - Object ob = getPlayerStorage.invoke(PokeballManager, player); - NBTTagCompound[] party = (NBTTagCompound[]) ob.getClass().getFields()[0].get(ob); - return party[i]; - } - catch (Exception e) { - e.printStackTrace(); - } - return null; - } + public static boolean isTrainer(EntityLivingBase entity) { + if (!Enabled) + return false; + String s = EntityList.getEntityString(entity); + if (s == null) + return false; + return s.equals("pixelmon.Trainer"); + } - public static boolean startBattle(EntityPlayerMP player, EntityLivingBase trainer) { - if(!Enabled) - return false; - try { + public static boolean isBattling(EntityPlayerMP player) { + if (!Enabled) + return false; + try { + Class c = Class.forName("com.pixelmonmod.pixelmon.battles.BattleRegistry"); + Method m = c.getMethod("getBattle", EntityPlayer.class); + if (m.invoke(null, player) != null) + return false; - Object ob = getPlayerStorage.invoke(PokeballManager, player); + return true; + } catch (Exception e) { + LogManager.getLogger().error("canBattle", e); + return false; + } + } - Class c = ob.getClass(); + public static boolean isBattling(EntityLivingBase trainer) { + if (!Enabled || !isTrainer(trainer)) + return false; + try { + Field f = trainer.getClass().getField("battleController"); - Method m = c.getMethod("getFirstAblePokemon", World.class); - Entity pixelmon = (Entity) m.invoke(ob, player.worldObj); - Class cEntity = Class.forName("com.pixelmonmod.pixelmon.entities.pixelmon.EntityPixelmon"); - m = c.getMethod("EntityAlreadyExists", cEntity); - if(!(Boolean)m.invoke(ob, pixelmon)){ - m = cEntity.getMethod("releaseFromPokeball"); - pixelmon.setPositionAndRotation(player.posX, player.posY, player.posZ, player.rotationYaw, 0); - } + return f.get(trainer) != null; + } catch (Exception e) { + LogManager.getLogger().error("canBattle", e); + return false; + } + } - c = Class.forName("com.pixelmonmod.pixelmon.battles.controller.participants.TrainerParticipant"); - Object parTrainer = c.getConstructor(new Class[] {trainer.getClass(), EntityPlayer.class, int.class}).newInstance(trainer, player, 1); + public static boolean canBattle(EntityPlayerMP player, EntityNPCInterface npc) { + if (!Enabled || npc.advanced.job != EnumJobType.Spawner || isBattling(player)) + return false; + try { + JobSpawner spawner = (JobSpawner) npc.jobInterface; + if (spawner.isOnCooldown(player.getCommandSenderName())) + return false; - Object[] pixelmonArray = (Object[]) Array.newInstance(cEntity, 1); - pixelmonArray[0] = pixelmon; - - c = Class.forName("com.pixelmonmod.pixelmon.battles.controller.participants.PlayerParticipant"); - Object parPlayer = c.getConstructor(new Class[] {EntityPlayerMP.class, pixelmonArray.getClass()}).newInstance(player, pixelmonArray); - - cEntity = Class.forName("com.pixelmonmod.pixelmon.entities.pixelmon.Entity6CanBattle"); - c = Class.forName("com.pixelmonmod.pixelmon.battles.controller.participants.BattleParticipant"); - m = cEntity.getMethod("StartBattle", c, c); - m.invoke(pixelmon, parTrainer, parPlayer); - - return true; - } catch (Exception e) { - LogManager.getLogger().error("startBattle", e); - return false; - } - } + Object ob = getPlayerStorage.invoke(PokeballManager, player); - public static int countPCPixelmon(EntityPlayerMP player) { - try { - Object ob = getPlayerComputerStorage.invoke(player); - return (Integer) ob.getClass().getMethod("count").invoke(ob); - } catch (Exception e) { - e.printStackTrace(); - } - return 0; - } + Method m = ob.getClass().getMethod("countAblePokemon"); - public static String getAttackName(int id) { - try { - Object ob = attackByID.newInstance(id); - if(ob == null) - return null; - return getAttackName.get(baseAttack.get(ob)) + ""; - } - catch (Exception e) { - e.printStackTrace(); - } - return null; - } + if ((Integer) m.invoke(ob) == 0) + return false; - public static int getAttackID(String name) { - try { - Object ob = attackByName.newInstance(name); - if(ob == null) - return -1; - return getAttackName.getInt(baseAttack.get(ob)); - } - catch (Exception e) { - e.printStackTrace(); - } - return -1; - } + return true; + } catch (Exception e) { + LogManager.getLogger().error("canBattle", e); + return false; + } + } + + public static EntityTameable pixelmonFromNBT(NBTTagCompound compound, EntityPlayer player) { + if (!Enabled) + return null; + + try { + Object ob = getPlayerStorage.invoke(PokeballManager, player); + return (EntityTameable) ob.getClass().getMethod("sendOut", NBTTagCompound.class, World.class).invoke(ob, compound, player); + } catch (Exception e) { + e.printStackTrace(); + } + return null; + } + + + public static NBTTagCompound getPartySlot(int i, EntityPlayer player) { + if (!Enabled) + return null; + + try { + Object ob = getPlayerStorage.invoke(PokeballManager, player); + NBTTagCompound[] party = (NBTTagCompound[]) ob.getClass().getFields()[0].get(ob); + return party[i]; + } catch (Exception e) { + e.printStackTrace(); + } + return null; + } + + public static boolean startBattle(EntityPlayerMP player, EntityLivingBase trainer) { + if (!Enabled) + return false; + try { + + Object ob = getPlayerStorage.invoke(PokeballManager, player); + + Class c = ob.getClass(); + + Method m = c.getMethod("getFirstAblePokemon", World.class); + Entity pixelmon = (Entity) m.invoke(ob, player.worldObj); + Class cEntity = Class.forName("com.pixelmonmod.pixelmon.entities.pixelmon.EntityPixelmon"); + m = c.getMethod("EntityAlreadyExists", cEntity); + if (!(Boolean) m.invoke(ob, pixelmon)) { + m = cEntity.getMethod("releaseFromPokeball"); + pixelmon.setPositionAndRotation(player.posX, player.posY, player.posZ, player.rotationYaw, 0); + } + + c = Class.forName("com.pixelmonmod.pixelmon.battles.controller.participants.TrainerParticipant"); + Object parTrainer = c.getConstructor(new Class[]{trainer.getClass(), EntityPlayer.class, int.class}).newInstance(trainer, player, 1); + + Object[] pixelmonArray = (Object[]) Array.newInstance(cEntity, 1); + pixelmonArray[0] = pixelmon; + + c = Class.forName("com.pixelmonmod.pixelmon.battles.controller.participants.PlayerParticipant"); + Object parPlayer = c.getConstructor(new Class[]{EntityPlayerMP.class, pixelmonArray.getClass()}).newInstance(player, pixelmonArray); + + cEntity = Class.forName("com.pixelmonmod.pixelmon.entities.pixelmon.Entity6CanBattle"); + c = Class.forName("com.pixelmonmod.pixelmon.battles.controller.participants.BattleParticipant"); + m = cEntity.getMethod("StartBattle", c, c); + m.invoke(pixelmon, parTrainer, parPlayer); + + return true; + } catch (Exception e) { + LogManager.getLogger().error("startBattle", e); + return false; + } + } + + public static int countPCPixelmon(EntityPlayerMP player) { + try { + Object ob = getPlayerComputerStorage.invoke(player); + return (Integer) ob.getClass().getMethod("count").invoke(ob); + } catch (Exception e) { + e.printStackTrace(); + } + return 0; + } + + public static String getAttackName(int id) { + try { + Object ob = attackByID.newInstance(id); + if (ob == null) + return null; + return getAttackName.get(baseAttack.get(ob)) + ""; + } catch (Exception e) { + e.printStackTrace(); + } + return null; + } + + public static int getAttackID(String name) { + try { + Object ob = attackByName.newInstance(name); + if (ob == null) + return -1; + return getAttackName.getInt(baseAttack.get(ob)); + } catch (Exception e) { + e.printStackTrace(); + } + return -1; + } } diff --git a/src/main/java/noppes/npcs/config/ConfigClient.java b/src/main/java/noppes/npcs/config/ConfigClient.java index 58c6bff5b..c24a2e301 100644 --- a/src/main/java/noppes/npcs/config/ConfigClient.java +++ b/src/main/java/noppes/npcs/config/ConfigClient.java @@ -9,8 +9,7 @@ import org.apache.logging.log4j.Level; import java.io.File; -public class ConfigClient -{ +public class ConfigClient { public static Configuration config; public final static String GENERAL = "General"; @@ -21,13 +20,13 @@ public class ConfigClient /** - * General Properties + * General Properties **/ public static Property CacheLifeProperty; public static int CacheLife = 10; /** - * Visual Properties + * Visual Properties **/ public static Property EnableChatBubblesProperty; public static boolean EnableChatBubbles = true; @@ -51,7 +50,7 @@ public class ConfigClient public static boolean HideEffectsBar = false; /** - * Questing Properties + * Questing Properties **/ public static Property DialogSpeedProperty; public static int DialogSpeed = 10; @@ -94,12 +93,12 @@ public class ConfigClient public static int CompassOverlayWidth = 200; /** - * Texture Properties + * Texture Properties **/ public static boolean WoodTextures = false; /** - * Model Properties + * Model Properties **/ public static boolean LegacyCampfire = false; public static boolean LegacyBanner = false; @@ -116,12 +115,10 @@ public class ConfigClient public static boolean LegacyPedestal = false; public static boolean LegacyMailbox = false; - public static void init(File configFile) - { + public static void init(File configFile) { config = new Configuration(configFile); - try - { + try { config.load(); // Hud Quest Overlay settings @@ -243,7 +240,7 @@ public class ConfigClient LegacyMailbox = config.get(MODEL, "Legacy Mailbox Model", false).getBoolean(false); // Convert to Legacy - if(CustomNpcs.legacyExist){ + if (CustomNpcs.legacyExist) { EnableChatBubbles = LegacyConfig.EnableChatBubbles; EnableChatBubblesProperty.set(EnableChatBubbles); @@ -256,13 +253,9 @@ public class ConfigClient FontSize = LegacyConfig.FontSize; FontSizeProperty.set(FontSize); } - } - catch (Exception e) - { + } catch (Exception e) { FMLLog.log(Level.ERROR, e, "CNPC+ has had a problem loading its client configuration"); - } - finally - { + } finally { if (config.hasChanged()) { config.save(); } diff --git a/src/main/java/noppes/npcs/config/ConfigDebug.java b/src/main/java/noppes/npcs/config/ConfigDebug.java index 3ff3968e8..addc10a6d 100644 --- a/src/main/java/noppes/npcs/config/ConfigDebug.java +++ b/src/main/java/noppes/npcs/config/ConfigDebug.java @@ -10,14 +10,13 @@ import org.apache.logging.log4j.Level; import java.io.File; -public class ConfigDebug -{ +public class ConfigDebug { public static Configuration config; public final static String LOGGING = "Logging"; /** - * Logging Properties + * Logging Properties **/ public static Property PlayerLoggingProperty; public static boolean PlayerLogging = false; @@ -34,36 +33,34 @@ public class ConfigDebug public static Property ScriptLogIgnoreTypeProperty; public static String ScriptLogIgnoreType = "TICK"; - public static void init(File configFile) - { + public static void init(File configFile) { config = new Configuration(configFile); - try - { + try { config.load(); // Logging PlayerLoggingProperty = config.get(LOGGING, "Enable Player Logging", false, "Enables if Player Information (WAND-USE) should be printed to CustomNPCs Logs. IF on Server \n" + - "Logs will only be present SERVER-SIDE only in CustomNPCs-latest, -1, -2, and -3"); + "Logs will only be present SERVER-SIDE only in CustomNPCs-latest, -1, -2, and -3"); PlayerLogging = PlayerLoggingProperty.getBoolean(false); ScriptLoggingProperty = config.get(LOGGING, "Enable Script Logging", false, "Enables if Scripting Information should be printed to CustomNPCs Logs. IF on Server \n" + - "Logs will only be present SERVER-SIDE only in CustomNPCs-latest, -1, -2, and -3"); + "Logs will only be present SERVER-SIDE only in CustomNPCs-latest, -1, -2, and -3"); ScriptLogging = ScriptLoggingProperty.getBoolean(false); ScriptFrequencyProperty = config.get(LOGGING, "Script Log Frequency Limit", 20, "Amount of Messages marked as SPAM [5, 3000]. Lower Number means MORE accurate messages \n" + - "This frequency will determine if the log will print a line with [SPAM] to warn the console."); + "This frequency will determine if the log will print a line with [SPAM] to warn the console."); ScriptFrequency = ScriptFrequencyProperty.getInt(20); ScriptIgnoreTimeProperty = config.get(LOGGING, "Script Ignore Time Buffer", 2000, "IN Milliseconds 1s = 1000s. If a recent LOG of the same event is SENT within this threshold it will be ignored."); ScriptIgnoreTime = ScriptIgnoreTimeProperty.getInt(2000); ScriptLogIgnoreTypeProperty = config.get(LOGGING, "Script Type Ignore", "TICK", "Comma separated list of NPC Script Types that will omit these from the logs,\n" + - "INIT,TICK,INTERACT,DIALOG,DAMAGED,KILLED,ATTACK,TARGET,COLLIDE,KILLS,DIALOG_CLOSE,TIMER"); + "INIT,TICK,INTERACT,DIALOG,DAMAGED,KILLED,ATTACK,TARGET,COLLIDE,KILLS,DIALOG_CLOSE,TIMER"); ScriptLogIgnoreType = ScriptLogIgnoreTypeProperty.getString(); // Convert to Legacy - if(CustomNpcs.legacyExist) { + if (CustomNpcs.legacyExist) { PlayerLogging = LegacyConfig.PlayerLogging; PlayerLoggingProperty.set(PlayerLogging); @@ -93,8 +90,8 @@ public class ConfigDebug String[] ignoreTypes = ScriptLogIgnoreType.split(","); for (String s : ignoreTypes) { EnumScriptType type = EnumScriptType.valueOfIgnoreCase(s); - if(type != null){ - switch (type){ + if (type != null) { + switch (type) { case INIT: CustomNpcs.InitIgnore = true; break; @@ -136,17 +133,14 @@ public class ConfigDebug } } } - } catch (Exception ignored) {} - } - catch (Exception e) - { + } catch (Exception ignored) { + } + } catch (Exception e) { FMLLog.log(Level.ERROR, e, "CNPC+ has had a problem loading its debug configuration"); - } - finally - { + } finally { if (config.hasChanged()) { config.save(); } } } -} \ No newline at end of file +} diff --git a/src/main/java/noppes/npcs/config/ConfigItem.java b/src/main/java/noppes/npcs/config/ConfigItem.java index 6bf997152..b5fc4504f 100644 --- a/src/main/java/noppes/npcs/config/ConfigItem.java +++ b/src/main/java/noppes/npcs/config/ConfigItem.java @@ -8,18 +8,14 @@ import noppes.npcs.config.legacy.LegacyConfig; import org.apache.logging.log4j.Level; import java.io.File; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -public class ConfigItem -{ +public class ConfigItem { public static Configuration config; public final static String ALL = "All"; public final static String GUN = "Gun"; /** - * Item Properties + * Item Properties **/ public static Property DisableExtraBlockProperty; public static boolean DisableExtraBlock = false; @@ -31,16 +27,14 @@ public class ConfigItem public static int MachineGunTickSpeed = 6; /** - * Item Properties + * Item Properties **/ - public static void init(File configFile) - { + public static void init(File configFile) { config = new Configuration(configFile); - try - { + try { config.load(); // ITEMS @@ -57,7 +51,7 @@ public class ConfigItem MachineGunTickSpeed = config.get(GUN, "Machine Gun Fire Rate", 6, "How many ticks to shoot bullets at").getInt(6); // Convert to Legacy - if(CustomNpcs.legacyExist){ + if (CustomNpcs.legacyExist) { DisableExtraBlock = LegacyConfig.DisableExtraBlock; DisableExtraBlockProperty.set(DisableExtraBlock); @@ -67,13 +61,9 @@ public class ConfigItem GunsEnabled = LegacyConfig.GunsEnabled; GunsEnabledProperty.set(GunsEnabled); } - } - catch (Exception e) - { + } catch (Exception e) { FMLLog.log(Level.ERROR, e, "CNPC+ has had a problem loading its item configuration"); - } - finally - { + } finally { if (config.hasChanged()) { config.save(); } diff --git a/src/main/java/noppes/npcs/config/ConfigMain.java b/src/main/java/noppes/npcs/config/ConfigMain.java index d58fa0346..46c6aee63 100644 --- a/src/main/java/noppes/npcs/config/ConfigMain.java +++ b/src/main/java/noppes/npcs/config/ConfigMain.java @@ -12,8 +12,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; -public class ConfigMain -{ +public class ConfigMain { public static Configuration config; public final static String GENERAL = "General"; @@ -25,7 +24,7 @@ public class ConfigMain public final static String ITEM = "Item"; /** - * General Main Properties + * General Main Properties **/ public static Property EnableUpdateCheckerProperty; @@ -77,13 +76,13 @@ public class ConfigMain public static int DefaultMaxPartySize = 4; /** - * Attribute Properties + * Attribute Properties **/ public static boolean AttributesEnabled = true; public static int AttributesCriticalBoost = 100; /** - * Profile Properties + * Profile Properties **/ public static boolean ProfilesEnabled = true; public static boolean AllowProfileBackups = true; @@ -97,7 +96,7 @@ public class ConfigMain /** - * General NPC Properties + * General NPC Properties **/ public static Property OpsOnlyProperty; @@ -128,18 +127,16 @@ public class ConfigMain public static int HitBoxScaleMax = 15; /** - * Update Properties + * Update Properties **/ public static Property TrackedQuestUpdateFrequencyProperty; public static int TrackedQuestUpdateFrequency = 5; - public static void init(File configFile) - { + public static void init(File configFile) { config = new Configuration(configFile); - try - { + try { config.load(); // General @@ -257,7 +254,7 @@ public class ConfigMain AttributesCriticalBoost = config.get(ATTRIBUTES, "Critical Amount", 100, "The boost in damage received by achieving a critical hit. Takes an number so 100 is 100% extra damage").getInt(100); // Convert to Legacy - if(CustomNpcs.legacyExist){ + if (CustomNpcs.legacyExist) { EnableUpdateChecker = LegacyConfig.EnableUpdateChecker; EnableUpdateCheckerProperty.set(EnableUpdateChecker); @@ -320,7 +317,7 @@ public class ConfigMain NpcNavRange = 96; } - if(NpcSizeLimit < 1){ + if (NpcSizeLimit < 1) { NpcSizeLimit = 1; } @@ -331,13 +328,9 @@ public class ConfigMain if (SkinOverlayLimit < 0) { SkinOverlayLimit = 0; } - } - catch (Exception e) - { + } catch (Exception e) { FMLLog.log(Level.ERROR, e, "CNPC+ has had a problem loading its main configuration"); - } - finally - { + } finally { if (config.hasChanged()) { config.save(); } diff --git a/src/main/java/noppes/npcs/config/ConfigMixin.java b/src/main/java/noppes/npcs/config/ConfigMixin.java index 732980337..c9491fe0e 100644 --- a/src/main/java/noppes/npcs/config/ConfigMixin.java +++ b/src/main/java/noppes/npcs/config/ConfigMixin.java @@ -7,15 +7,14 @@ import org.apache.logging.log4j.Level; import java.io.File; -public class ConfigMixin -{ +public class ConfigMixin { public static Configuration config; public final static String CLIENT = "CLIENT"; public final static String GENERAL = "GENERAL"; /** - * General Properties + * General Properties **/ public static Property EntityRendererMixinProperty; public static boolean EntityRendererMixin = true; @@ -26,12 +25,10 @@ public class ConfigMixin public static Property FirstPersonAnimationMixinProperty; public static boolean FirstPersonAnimationMixin = true; - public static void init(File configFile) - { + public static void init(File configFile) { config = new Configuration(configFile); - try - { + try { config.load(); EntityRendererMixinProperty = config.get(CLIENT, "Entity Render Mixin", true, "Enables Overlay Mixins for Conflicts relating to Optifine or other Skin Renderers. If crashes occur, please disable."); @@ -46,13 +43,9 @@ public class ConfigMixin } else { FirstPersonAnimationMixin = false; } - } - catch (Exception e) - { + } catch (Exception e) { FMLLog.log(Level.ERROR, e, "CNPC+ has had a problem loading its mixin configuration"); - } - finally - { + } finally { if (config.hasChanged()) { config.save(); } diff --git a/src/main/java/noppes/npcs/config/ConfigScript.java b/src/main/java/noppes/npcs/config/ConfigScript.java index 57c6d434c..41804cdde 100644 --- a/src/main/java/noppes/npcs/config/ConfigScript.java +++ b/src/main/java/noppes/npcs/config/ConfigScript.java @@ -16,15 +16,14 @@ import java.util.Arrays; import java.util.HashSet; import java.util.UUID; -public class ConfigScript -{ +public class ConfigScript { public static Configuration config; public final static String GENERAL = "Scripting General"; public final static String CUSTOMIZATION = "Scripting Customization"; /** - * General Properties + * General Properties **/ public static Property ScriptingEnabledProperty; public static boolean ScriptingEnabled = true; @@ -42,7 +41,7 @@ public class ConfigScript public static boolean GlobalNPCScripts = false; /** - * Customization Properties + * Customization Properties **/ public static Property ScriptingECMA6Property; public static boolean ScriptingECMA6 = false; @@ -59,12 +58,10 @@ public class ConfigScript public static Property BannedClassesProperty; public final static HashSet BannedClasses = new HashSet<>(); - public static void init(File configFile) - { + public static void init(File configFile) { config = new Configuration(configFile); - try - { + try { config.load(); // General @@ -85,23 +82,23 @@ public class ConfigScript // Customization ScriptingECMA6Property = config.get(CUSTOMIZATION, "ECMA6 Scripting Language", false, - "Enables/Disables the use of the the ECMA6 Javascript standard instead of ECMA5.1." + - "\nEnabling this adds many more features to JS in scripts. Only use if on Java 8 or higher." + - "\nNot all ECMA 6 language is supported through this functionality."); + "Enables/Disables the use of the the ECMA6 Javascript standard instead of ECMA5.1." + + "\nEnabling this adds many more features to JS in scripts. Only use if on Java 8 or higher." + + "\nNot all ECMA 6 language is supported through this functionality."); ScriptingECMA6 = ScriptingECMA6Property.getBoolean(false); ExpandedScriptLimitProperty = config.get(CUSTOMIZATION, "Script Tag Limit", 2, - "If scripts are too long (>65535 characters), they normally won't be saved in NBT data.\n" + - "This config adds additional compound tags to scripts that need it, so you can store much larger scripts!\n" + - "Every additional compound tag adds 65535 more characters to your script length limit. Use incrementally, with caution."); + "If scripts are too long (>65535 characters), they normally won't be saved in NBT data.\n" + + "This config adds additional compound tags to scripts that need it, so you can store much larger scripts!\n" + + "Every additional compound tag adds 65535 more characters to your script length limit. Use incrementally, with caution."); ExpandedScriptLimit = ExpandedScriptLimitProperty.getInt(2); ScriptDevIDsProperty = config.get(CUSTOMIZATION, "Script Dev UUIDs", "", - "Comma separated list of player UUIDs that can see and edit scripts. If ScriptsOpsOnly is true,\n" + - "ops and players with these IDs can see and edit scripts. Example:\n" + - "b876ec32-e396-476b-a115-8438d83c67d4,069a79f4-44e9-4726-a5be-fca90e38aaf5,be951074-c7ea-4f02-a725-bf017bc88650\n" + - "Get a player's UUID from a site like NameMC or the API IPlayer.getUniqueID() function!\n" + - "If left empty and ScriptsOpsOnly is false, anyone can see and edit scripts with a scripter."); + "Comma separated list of player UUIDs that can see and edit scripts. If ScriptsOpsOnly is true,\n" + + "ops and players with these IDs can see and edit scripts. Example:\n" + + "b876ec32-e396-476b-a115-8438d83c67d4,069a79f4-44e9-4726-a5be-fca90e38aaf5,be951074-c7ea-4f02-a725-bf017bc88650\n" + + "Get a player's UUID from a site like NameMC or the API IPlayer.getUniqueID() function!\n" + + "If left empty and ScriptsOpsOnly is false, anyone can see and edit scripts with a scripter."); ScriptDevIDs = ScriptDevIDsProperty.getString(); EnableBannedClassesProperty = config.get(CUSTOMIZATION, "Enable Banned Classes", false, "Enables the Banned Classes Functionality"); @@ -113,7 +110,7 @@ public class ConfigScript "This is a feature ONLY AVAILABLE ON NASHORN."); // Convert to Legacy - if(CustomNpcs.legacyExist){ + if (CustomNpcs.legacyExist) { ScriptingEnabled = LegacyConfig.ScriptingEnabled; ScriptingEnabledProperty.set(ScriptingEnabled); @@ -148,20 +145,18 @@ public class ConfigScript for (String s : uuidStrings) { Developer.ScriptUser.add(UUID.fromString(s)); } - } catch (Exception ignored) {} + } catch (Exception ignored) { + } String bannedClassesString = BannedClassesProperty.getString(); try { BannedClasses.clear(); BannedClasses.addAll(Arrays.asList(bannedClassesString.split(","))); - } catch (Exception ignored) {} - } - catch (Exception e) - { + } catch (Exception ignored) { + } + } catch (Exception e) { FMLLog.log(Level.ERROR, e, "CNPC+ has had a problem loading its scripting configuration"); - } - finally - { + } finally { if (config.hasChanged()) { config.save(); } @@ -175,7 +170,7 @@ public class ConfigScript public static boolean canScript(EntityPlayer player, CustomNpcsPermissions.Permission perm) { boolean isOp = MinecraftServer.getServer().getConfigurationManager().func_152596_g(player.getGameProfile()); boolean scriptDev = isScriptDev(player); - if(ScriptOpsOnly){ + if (ScriptOpsOnly) { return isOp || scriptDev; } diff --git a/src/main/java/noppes/npcs/config/GlyphCache.java b/src/main/java/noppes/npcs/config/GlyphCache.java index e6565b6f3..fc4922be9 100644 --- a/src/main/java/noppes/npcs/config/GlyphCache.java +++ b/src/main/java/noppes/npcs/config/GlyphCache.java @@ -24,14 +24,12 @@ import java.util.*; * select the proper physical font to use (especially on less common Linux distributions). Once a pre-rendered glyph image is * cached, it will remain stored in an OpenGL texture for the entire lifetime of the application (StringCache depends on this * behavior). - * * @todo Should have a separate glyph cache and a separate smaller point size font for rendering the GUI at its smallest size * and for use in the F3 debug screen; may need some explicit argument in StringCache.renderString() to select the size * @todo Need to have a config file that allows overring the font search order by locale to properly support Traditional Chinese * hanzi, Simplified Chinese hanzi, Japanese kanji, and Korean hanja */ -public class GlyphCache -{ +public class GlyphCache { /** * The width in pixels of every texture used for caching pre-rendered glyph images. Used by GlyphCache when calculating * floating point 0.0-1.0 texture coordinates. Must be a power of two for mip-mapping to work. @@ -44,10 +42,14 @@ public class GlyphCache */ private static final int TEXTURE_HEIGHT = 256; - /** Initial width in pixels of the stringImage buffer used to extract individual glyph images. */ + /** + * Initial width in pixels of the stringImage buffer used to extract individual glyph images. + */ private static final int STRING_WIDTH = 256; - /** Initial height in pixels of the stringImage buffer used to extract individual glyph images. */ + /** + * Initial height in pixels of the stringImage buffer used to extract individual glyph images. + */ private static final int STRING_HEIGHT = 64; /** @@ -57,34 +59,52 @@ public class GlyphCache */ private static final int GLYPH_BORDER = 1; - /** Transparent (alpha zero) white background color for use with BufferedImage.clearRect(). */ + /** + * Transparent (alpha zero) white background color for use with BufferedImage.clearRect(). + */ private static Color BACK_COLOR = new Color(255, 255, 255, 0); - /** The point size at which every OpenType font is rendered. */ + /** + * The point size at which every OpenType font is rendered. + */ private int fontSize = 18; - /** If true, then enble anti-aliasing when rendering the font glyph */ + /** + * If true, then enble anti-aliasing when rendering the font glyph + */ private boolean antiAliasEnabled = false; - /** Temporary image for rendering a string to and then extracting the glyph images from. */ + /** + * Temporary image for rendering a string to and then extracting the glyph images from. + */ private BufferedImage stringImage; - /** The Graphics2D associated with stringImage and used for string drawing to extract the individual glyph shapes. */ + /** + * The Graphics2D associated with stringImage and used for string drawing to extract the individual glyph shapes. + */ private Graphics2D stringGraphics; - /** All font glyphs are packed inside this image and are then loaded from here into an OpenGL texture. */ + /** + * All font glyphs are packed inside this image and are then loaded from here into an OpenGL texture. + */ private BufferedImage glyphCacheImage = new BufferedImage(TEXTURE_WIDTH, TEXTURE_HEIGHT, BufferedImage.TYPE_INT_ARGB); - /** The Graphics2D associated with glyphCacheImage and used for bit blitting between stringImage. */ + /** + * The Graphics2D associated with glyphCacheImage and used for bit blitting between stringImage. + */ private Graphics2D glyphCacheGraphics = glyphCacheImage.createGraphics(); - /** Needed for all text layout operations that create GlyphVectors (maps point size to pixel size). */ + /** + * Needed for all text layout operations that create GlyphVectors (maps point size to pixel size). + */ private FontRenderContext fontRenderContext = glyphCacheGraphics.getFontRenderContext(); - /** Intermediate data array for use with textureImage.getRgb(). */ + /** + * Intermediate data array for use with textureImage.getRgb(). + */ private int imageData[] = new int[TEXTURE_WIDTH * TEXTURE_HEIGHT]; /** @@ -94,10 +114,14 @@ public class GlyphCache */ private IntBuffer imageBuffer = ByteBuffer.allocateDirect(4 * TEXTURE_WIDTH * TEXTURE_HEIGHT).order(ByteOrder.BIG_ENDIAN).asIntBuffer(); - /** A single integer direct buffer with native byte ordering used for returning values from glGenTextures(). */ + /** + * A single integer direct buffer with native byte ordering used for returning values from glGenTextures(). + */ private IntBuffer singleIntBuffer = GLAllocation.createDirectIntBuffer(1); - /** List of all available physical fonts on the system. Used by lookupFont() to find alternate fonts. */ + /** + * List of all available physical fonts on the system. Used by lookupFont() to find alternate fonts. + */ private List allFonts = Arrays.asList(GraphicsEnvironment.getLocalGraphicsEnvironment().getAllFonts()); /** @@ -109,7 +133,9 @@ public class GlyphCache protected List usedFonts = new ArrayList(); - /** ID of current OpenGL cache texture being used by cacheGlyphs() to store pre-rendered glyph images. */ + /** + * ID of current OpenGL cache texture being used by cacheGlyphs() to store pre-rendered glyph images. + */ private int textureName; /** @@ -143,44 +169,56 @@ public class GlyphCache private int cachePosY = GLYPH_BORDER; /** - * The height in pixels of the current line of glyphs getting written into the texture. This value determines by how much - * cachePosY will get incremented when the current horizontal line in the texture fills up. - */ + * The height in pixels of the current line of glyphs getting written into the texture. This value determines by how much + * cachePosY will get incremented when the current horizontal line in the texture fills up. + */ private int cacheLineHeight = 0; /** * This class holds information for a glyph about its pre-rendered image in an OpenGL texture. The texture coordinates in * this class are normalized in the standard 0.0 - 1.0 OpenGL range. */ - static class Entry - { - /** The OpenGL texture ID that contains this glyph image. */ + static class Entry { + /** + * The OpenGL texture ID that contains this glyph image. + */ public int textureName; - /** The width in pixels of the glyph image. */ + /** + * The width in pixels of the glyph image. + */ public int width; - /** The height in pixels of the glyph image. */ + /** + * The height in pixels of the glyph image. + */ public int height; - /** The horizontal texture coordinate of the upper-left corner. */ + /** + * The horizontal texture coordinate of the upper-left corner. + */ public float u1; - /** The vertical texture coordinate of the upper-left corner. */ + /** + * The vertical texture coordinate of the upper-left corner. + */ public float v1; - /** The horizontal texture coordinate of the lower-right corner. */ + /** + * The horizontal texture coordinate of the lower-right corner. + */ public float u2; - /** The vertical texture coordinate of the lower-right corner. */ + /** + * The vertical texture coordinate of the lower-right corner. + */ public float v2; } /** * A single instance of GlyphCache is allocated for internal use by the StringCache class. */ - public GlyphCache() - { + public GlyphCache() { /* Set background color for use with clearRect() */ glyphCacheGraphics.setBackground(BACK_COLOR); @@ -203,9 +241,8 @@ public class GlyphCache * @param name the new font name * @param size the new point size */ - void setDefaultFont(String name, int size, boolean antiAlias) - { - + void setDefaultFont(String name, int size, boolean antiAlias) { + //System.out.println("BetterFonts loading font \"" + name + "\""); usedFonts.clear(); usedFonts.add(new Font(name, Font.PLAIN, 72)); //size 1 > 72 @@ -214,43 +251,41 @@ public class GlyphCache antiAliasEnabled = antiAlias; setRenderingHints(); } - - void setCustomFont(ResourceLocation location, int size, boolean antiAlias) throws Exception { - InputStream stream = Minecraft.getMinecraft().getResourceManager().getResource(location).getInputStream(); - GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); - Font font = Font.createFont(Font.TRUETYPE_FONT, stream); - ge.registerFont(font); - font = font.deriveFont(Font.PLAIN, 72); + void setCustomFont(ResourceLocation location, int size, boolean antiAlias) throws Exception { + InputStream stream = Minecraft.getMinecraft().getResourceManager().getResource(location).getInputStream(); - usedFonts.clear(); - usedFonts.add(font); + GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); + Font font = Font.createFont(Font.TRUETYPE_FONT, stream); + ge.registerFont(font); + font = font.deriveFont(Font.PLAIN, 72); - fontSize = size; - antiAliasEnabled = antiAlias; - setRenderingHints(); - } - - int fontHeight(String s){ - Font font = lookupFont(s.toCharArray(), 0, s.length(), 0); - return (int)(font.getLineMetrics(s, this.fontRenderContext).getHeight()); + usedFonts.clear(); + usedFonts.add(font); + + fontSize = size; + antiAliasEnabled = antiAlias; + setRenderingHints(); + } + + int fontHeight(String s) { + Font font = lookupFont(s.toCharArray(), 0, s.length(), 0); + return (int) (font.getLineMetrics(s, this.fontRenderContext).getHeight()); } /** * Given a single OpenType font, perform full text layout and create a new GlyphVector for a string. * - * @param font the Font used to layout a GlyphVector for the string - * @param text the string to layout - * @param start the offset into text at which to start the layout - * @param limit the (offset + length) at which to stop performing the layout + * @param font the Font used to layout a GlyphVector for the string + * @param text the string to layout + * @param start the offset into text at which to start the layout + * @param limit the (offset + length) at which to stop performing the layout * @param layoutFlags either Font.LAYOUT_RIGHT_TO_LEFT or Font.LAYOUT_LEFT_TO_RIGHT * @return the newly created GlyphVector */ - GlyphVector layoutGlyphVector(Font font, char text[], int start, int limit, int layoutFlags) - { + GlyphVector layoutGlyphVector(Font font, char text[], int start, int limit, int layoutFlags) { /* Ensure this font is already in fontCache so it can be referenced by cacheGlyphs() later on */ - if(!fontCache.containsKey(font)) - { + if (!fontCache.containsKey(font)) { fontCache.put(font, fontCache.size()); } return font.layoutGlyphVector(fontRenderContext, text, start, limit, layoutFlags); @@ -260,22 +295,19 @@ public class GlyphCache * Find the first font in the system able to render at least one character from a given string. The function always tries searching first * in the fontCache (based on the request style). Failing that, it searches the usedFonts list followed by the allFonts[] array. * - * @param text the string to check against the font + * @param text the string to check against the font * @param start the offset into text at which to start checking characters for being supported by a font * @param limit the (offset + length) at which to stop checking characters * @param style combination of the Font.PLAIN, Font.BOLD, and Font.ITALIC to request a particular font style * @return an OpenType font capable of displaying at least the first character at the start position in text */ - Font lookupFont(char text[], int start, int limit, int style) - { + Font lookupFont(char text[], int start, int limit, int style) { /* Try using an already known base font; the first font in usedFonts list is the one set with setDefaultFont() */ Iterator iterator = usedFonts.iterator(); - while(iterator.hasNext()) - { + while (iterator.hasNext()) { /* Only use the font if it can layout at least the first character of the requested string range */ Font font = iterator.next(); - if(font.canDisplayUpTo(text, start, limit) != start) - { + if (font.canDisplayUpTo(text, start, limit) != start) { /* Return a font instance of the proper point size and style; usedFonts has only 1pt sized plain style fonts */ return font.deriveFont(style, fontSize); } @@ -283,12 +315,10 @@ public class GlyphCache /* If still not found, try searching through all fonts installed on the system for the first that can layout this string */ iterator = allFonts.iterator(); - while(iterator.hasNext()) - { + while (iterator.hasNext()) { /* Only use the font if it can layout at least the first character of the requested string range */ Font font = iterator.next(); - if(font.canDisplayUpTo(text, start, limit) != start) - { + if (font.canDisplayUpTo(text, start, limit) != start) { /* If found, add this font to the usedFonts list so it can be looked up faster next time */ //System.out.println("BetterFonts loading font \"" + font.getFontName() + "\""); usedFonts.add(font); @@ -311,12 +341,11 @@ public class GlyphCache * within the texture. This function assumes that any glyph lookup requests passed to it have been already cached by an earlier call * to cacheGlyphs(). * - * @param font the font to which this glyphCode belongs and which was used to pre-render the glyph image in cacheGlyphs() + * @param font the font to which this glyphCode belongs and which was used to pre-render the glyph image in cacheGlyphs() * @param glyphCode the font specific flyph code to lookup in the cache * @return the cache entry for this font/glyphCode pair */ - Entry lookupGlyph(Font font, int glyphCode) - { + Entry lookupGlyph(Font font, int glyphCode) { long fontKey = (long) fontCache.get(font) << 32; return glyphCache.get(fontKey | glyphCode); } @@ -325,17 +354,15 @@ public class GlyphCache * Given an OpenType font and a string, make sure that every glyph used by that string is pre-rendered into an OpenGL texture and cached * in the glyphCache map for later retrieval by lookupGlyph() * - * @param font the font used to create a GlyphVector for the string and to actually draw the individual glyphs - * @param text the string from which to cache glyph images - * @param start the offset into text at which to start caching glyphs - * @param limit the (offset + length) at which to stop caching glyphs + * @param font the font used to create a GlyphVector for the string and to actually draw the individual glyphs + * @param text the string from which to cache glyph images + * @param start the offset into text at which to start caching glyphs + * @param limit the (offset + length) at which to stop caching glyphs * @param layoutFlags either Font.LAYOUT_RIGHT_TO_LEFT or Font.LAYOUT_LEFT_TO_RIGHT; needed for weak bidirectional characters like - * parenthesis which are mapped to two different glyph codes depending on the surrounding text direction - * + * parenthesis which are mapped to two different glyph codes depending on the surrounding text direction * @todo May need a blank border of pixels around everything for mip-map/tri-linear filtering with Optifine */ - void cacheGlyphs(Font font, char text[], int start, int limit, int layoutFlags) - { + void cacheGlyphs(Font font, char text[], int start, int limit, int layoutFlags) { /* Create new GlyphVector so glyphs can be moved around (kerning workaround; see below) without affecting caller */ GlyphVector vector = layoutGlyphVector(font, text, start, limit, layoutFlags); @@ -349,12 +376,10 @@ public class GlyphCache Rectangle dirty = null; /* Total area within texture that needs to be updated with glTexSubImage2D() */ boolean vectorRendered = false; /* True if entire GlyphVector was rendered into stringImage */ - for(int index = 0; index < numGlyphs; index++) - { + for (int index = 0; index < numGlyphs; index++) { /* If this glyph code is already in glyphCache, then there is no reason to pre-render it again */ int glyphCode = vector.getGlyphCode(index); - if(glyphCache.containsKey(fontKey | glyphCode)) - { + if (glyphCache.containsKey(fontKey | glyphCode)) { continue; } @@ -365,8 +390,7 @@ public class GlyphCache * array of glyphcodes (and therefore render only a few glyphs at a time), this produces corrupted * Davengari glyphs under Windows 7. The vectorRendered flag will draw the string at most one time. */ - if(!vectorRendered) - { + if (!vectorRendered) { vectorRendered = true; /* @@ -375,8 +399,7 @@ public class GlyphCache * the entire string. The getGlyphPixelBounds() later on will return the new adjusted bounds * for the glyph. */ - for(int i = 0; i < numGlyphs; i++) - { + for (int i = 0; i < numGlyphs; i++) { Point2D pos = vector.getGlyphPosition(i); pos.setLocation(pos.getX() + 2 * i, pos.getY()); vector.setGlyphPosition(i, pos); @@ -391,8 +414,7 @@ public class GlyphCache vectorBounds = vector.getPixelBounds(fontRenderContext, 0, 0); /* Enlage the stringImage if it is too small to store the entire rendered string */ - if(stringImage == null || vectorBounds.width > stringImage.getWidth() || vectorBounds.height > stringImage.getHeight()) - { + if (stringImage == null || vectorBounds.width > stringImage.getWidth() || vectorBounds.height > stringImage.getHeight()) { int width = Math.max(vectorBounds.width, stringImage.getWidth()); int height = Math.max(vectorBounds.height, stringImage.getHeight()); allocateStringImage(width, height); @@ -414,8 +436,7 @@ public class GlyphCache Rectangle rect = vector.getGlyphPixelBounds(index, null, -vectorBounds.x, -vectorBounds.y); /* If the current line in cache image is full, then advance to the next line */ - if(cachePosX + rect.width + GLYPH_BORDER > TEXTURE_WIDTH) - { + if (cachePosX + rect.width + GLYPH_BORDER > TEXTURE_WIDTH) { cachePosX = GLYPH_BORDER; cachePosY += cacheLineHeight + GLYPH_BORDER; cacheLineHeight = 0; @@ -426,8 +447,7 @@ public class GlyphCache * (i.e. the dirty rectangle), allocate a new cache texture, and then continue storing glyph images to the * upper-left corner of the new texture. */ - if(cachePosY + rect.height + GLYPH_BORDER > TEXTURE_HEIGHT) - { + if (cachePosY + rect.height + GLYPH_BORDER > TEXTURE_HEIGHT) { updateTexture(dirty); dirty = null; @@ -438,8 +458,7 @@ public class GlyphCache } /* The tallest glyph on this line determines the total vertical advance in the texture */ - if(rect.height > cacheLineHeight) - { + if (rect.height > cacheLineHeight) { cacheLineHeight = rect.height; } @@ -483,12 +502,9 @@ public class GlyphCache * region than using the add(x, y) method to extend by a single point. Also note that creating the first * dirty rectangle here avoids having to deal with the special rules for empty/non-existent rectangles. */ - if(dirty == null) - { + if (dirty == null) { dirty = new Rectangle(cachePosX, cachePosY, rect.width, rect.height); - } - else - { + } else { dirty.add(rect); } @@ -504,21 +520,18 @@ public class GlyphCache * Update a portion of the current glyph cache texture using the contents of the glyphCacheImage with glTexSubImage2D(). * * @param dirty The rectangular region in glyphCacheImage that has changed and needs to be copied into the texture - * * @todo Add mip-mapping support here * @todo Test with bilinear texture interpolation and possibly add a 1 pixel transparent border around each glyph to avoid * bleedover when interpolation is active or add a small "fudge factor" to the UV coordinates like already n FontRenderer */ - private void updateTexture(Rectangle dirty) - { + private void updateTexture(Rectangle dirty) { /* Only update OpenGL texture if changes were made to the texture */ - if(dirty != null) - { + if (dirty != null) { /* Load imageBuffer with pixel data ready for transfer to OpenGL texture */ updateImageBuffer(dirty.x, dirty.y, dirty.width, dirty.height); GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureName); - + GL11.glTexSubImage2D(GL11.GL_TEXTURE_2D, 0, dirty.x, dirty.y, dirty.width, dirty.height, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, imageBuffer); } @@ -528,8 +541,7 @@ public class GlyphCache * Allocte and initialize a new BufferedImage and Graphics2D context for rendering strings into. May need to be called * at runtime to re-allocate a bigger BufferedImage if cacheGlyphs() is called with a very long string. */ - private void allocateStringImage(int width, int height) - { + private void allocateStringImage(int width, int height) { stringImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); stringGraphics = stringImage.createGraphics(); setRenderingHints(); @@ -549,8 +561,7 @@ public class GlyphCache * allocateStringImage() when expanding the size of the BufferedImage and from setDefaultFont() when changing current * configuration. */ - private void setRenderingHints() - { + private void setRenderingHints() { stringGraphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, antiAliasEnabled ? RenderingHints.VALUE_ANTIALIAS_ON : RenderingHints.VALUE_ANTIALIAS_OFF); stringGraphics.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, @@ -566,16 +577,15 @@ public class GlyphCache * * @todo use GL_ALPHA4 if anti-alias is turned off for even smaller textures */ - private void allocateGlyphCacheTexture() - { + private void allocateGlyphCacheTexture() { /* Initialize the background to all white but fully transparent. */ glyphCacheGraphics.clearRect(0, 0, TEXTURE_WIDTH, TEXTURE_HEIGHT); /* Allocate new OpenGL texure */ singleIntBuffer.clear(); - - GL11.glGenTextures(singleIntBuffer); - textureName = singleIntBuffer.get(0); + + GL11.glGenTextures(singleIntBuffer); + textureName = singleIntBuffer.get(0); /* Load imageBuffer with pixel data ready for transfer to OpenGL texture */ updateImageBuffer(0, 0, TEXTURE_WIDTH, TEXTURE_HEIGHT); @@ -597,19 +607,17 @@ public class GlyphCache * Copy pixel data from a region in glyphCacheImage into imageBuffer and prepare it for use with glText(Sub)Image2D(). This * function takes care of converting the ARGB format used with BufferedImage into the RGBA format used by OpenGL. * - * @param x the horizontal coordinate of the region's upper-left corner - * @param y the vertical coordinate of the region's upper-left corner - * @param width the width of the pixel region that will be copied into the buffer + * @param x the horizontal coordinate of the region's upper-left corner + * @param y the vertical coordinate of the region's upper-left corner + * @param width the width of the pixel region that will be copied into the buffer * @param height the height of the pixel region that will be copied into the buffer */ - private void updateImageBuffer(int x, int y, int width, int height) - { + private void updateImageBuffer(int x, int y, int width, int height) { /* Copy raw pixel data from BufferedImage to imageData array with one integer per pixel in 0xAARRGGBB form */ glyphCacheImage.getRGB(x, y, width, height, imageData, 0, width); /* Swizzle each color integer from Java's ARGB format to OpenGL's RGBA */ - for(int i = 0; i < width * height; i++) - { + for (int i = 0; i < width * height; i++) { int color = imageData[i]; imageData[i] = (color << 8) | (color >>> 24); } diff --git a/src/main/java/noppes/npcs/config/LoadConfiguration.java b/src/main/java/noppes/npcs/config/LoadConfiguration.java index 1b3310b96..9dc1b7cef 100644 --- a/src/main/java/noppes/npcs/config/LoadConfiguration.java +++ b/src/main/java/noppes/npcs/config/LoadConfiguration.java @@ -1,7 +1,5 @@ package noppes.npcs.config; -import net.minecraftforge.common.config.Property; - import java.io.File; public class LoadConfiguration { @@ -11,8 +9,7 @@ public class LoadConfiguration { public static File debugConfigFile; public static File clientConfigFile; - public static void init(String configpath) - { + public static void init(String configpath) { mainConfigFile = new File(configpath + "main.cfg"); itemConfigFile = new File(configpath + "item.cfg"); clientConfigFile = new File(configpath + "client.cfg"); diff --git a/src/main/java/noppes/npcs/config/StringCache.java b/src/main/java/noppes/npcs/config/StringCache.java index 7af59be79..263b480b9 100644 --- a/src/main/java/noppes/npcs/config/StringCache.java +++ b/src/main/java/noppes/npcs/config/StringCache.java @@ -17,144 +17,155 @@ import java.util.WeakHashMap; /** * @author https://github.com/secretdataz/BetterFonts -* The StringCache is the public interface for rendering of all Unicode strings using OpenType fonts. It caches the glyph layout -* of individual strings, and it uses a GlyphCache instance to cache the pre-rendered images for individual glyphs. Once a string -* and its glyph images are cached, the critical path in renderString() will draw the glyphs as fast as if using a bitmap font. -* Strings are cached using weak references through a two layer string cache. Strings that are no longer in use by Minecraft will -* be evicted from the cache, while the pre-rendered images of individual glyphs remains cached forever. The following diagram -* illustrates how this works: -* -*

-* String passed to Key object considers Entry object holds Each Glyph object GlyphCache.Entry stores
-* renderString(); all ASCII digits equal an array of Glyph belongs to only one the texture ID, image
-* mapped by weak to zero ('0'); objects which may Entry object; it has width/height and
-* weakRefCache mapped by weak not directly the glyph x/y pos normalized texture
-* to Key object stringCahe to Entry correspond to Unicode within the string coordinates.
-* chars in string
-* String("Fi1") ------------\ ---> Glyph("F") ----------> GlyphCache.Entry("F")
-* N:1 \ 1:1 1:N / N:1
-* String("Fi4") ------------> Key("Fi0") -------------> Entry("Fi0") -----+----> Glyph("i") ----------> GlyphCache.Entry("i")
-* \ N:1
-* ---> Glyph("0") -----\
-* ----> GlyphCache.Entry("0")
-* ---> Glyph("0") -----/
-* N:1 1:1 1:N / N:1
-* String("Be1") ------------> Key("Be0") -------------> Entry("Be0") -----+----> Glyph("e") ----------> GlyphCache.Entry("e")
-* \ N:1
-* ---> Glyph("B") ----------> GlyphCache.Entry("B")
-* 
-*/ -public class StringCache -{ - /** Vertical adjustment (in pixels * 2) to string position because Minecraft uses top of string instead of baseline */ + * The StringCache is the public interface for rendering of all Unicode strings using OpenType fonts. It caches the glyph layout + * of individual strings, and it uses a GlyphCache instance to cache the pre-rendered images for individual glyphs. Once a string + * and its glyph images are cached, the critical path in renderString() will draw the glyphs as fast as if using a bitmap font. + * Strings are cached using weak references through a two layer string cache. Strings that are no longer in use by Minecraft will + * be evicted from the cache, while the pre-rendered images of individual glyphs remains cached forever. The following diagram + * illustrates how this works: + * + *
+ * String passed to Key object considers Entry object holds Each Glyph object GlyphCache.Entry stores
+ * renderString(); all ASCII digits equal an array of Glyph belongs to only one the texture ID, image
+ * mapped by weak to zero ('0'); objects which may Entry object; it has width/height and
+ * weakRefCache mapped by weak not directly the glyph x/y pos normalized texture
+ * to Key object stringCahe to Entry correspond to Unicode within the string coordinates.
+ * chars in string
+ * String("Fi1") ------------\ ---> Glyph("F") ----------> GlyphCache.Entry("F")
+ * N:1 \ 1:1 1:N / N:1
+ * String("Fi4") ------------> Key("Fi0") -------------> Entry("Fi0") -----+----> Glyph("i") ----------> GlyphCache.Entry("i")
+ * \ N:1
+ * ---> Glyph("0") -----\
+ * ----> GlyphCache.Entry("0")
+ * ---> Glyph("0") -----/
+ * N:1 1:1 1:N / N:1
+ * String("Be1") ------------> Key("Be0") -------------> Entry("Be0") -----+----> Glyph("e") ----------> GlyphCache.Entry("e")
+ * \ N:1
+ * ---> Glyph("B") ----------> GlyphCache.Entry("B")
+ * 
+ */ +public class StringCache { + /** + * Vertical adjustment (in pixels * 2) to string position because Minecraft uses top of string instead of baseline + */ private static final int BASELINE_OFFSET = 7; - /** Offset from the string's baseline as which to draw the underline (in pixels) */ + /** + * Offset from the string's baseline as which to draw the underline (in pixels) + */ private static final int UNDERLINE_OFFSET = 1; - /** Thickness of the underline (in pixels) */ + /** + * Thickness of the underline (in pixels) + */ private static final int UNDERLINE_THICKNESS = 2; - /** Offset from the string's baseline as which to draw the strikethrough line (in pixels) */ + /** + * Offset from the string's baseline as which to draw the strikethrough line (in pixels) + */ private static final int STRIKETHROUGH_OFFSET = -6; - /** Thickness of the strikethrough line (in pixels) */ + /** + * Thickness of the strikethrough line (in pixels) + */ private static final int STRIKETHROUGH_THICKNESS = 2; - /** Reference to the unicode.FontRenderer class. Needed for creating GlyphVectors and retrieving glyph texture coordinates. */ + /** + * Reference to the unicode.FontRenderer class. Needed for creating GlyphVectors and retrieving glyph texture coordinates. + */ private GlyphCache glyphCache; /** -* Color codes from original FontRender class. First 16 entries are the primary chat colors; second 16 are darker versions -* used for drop shadows. -*/ + * Color codes from original FontRender class. First 16 entries are the primary chat colors; second 16 are darker versions + * used for drop shadows. + */ private int colorTable[]; /** -* A cache of recently seen strings to their fully layed-out state, complete with color changes and texture coordinates of -* all pre-rendered glyph images needed to display this string. The weakRefCache holds strong references to the Key -* objects used in this map. -*/ + * A cache of recently seen strings to their fully layed-out state, complete with color changes and texture coordinates of + * all pre-rendered glyph images needed to display this string. The weakRefCache holds strong references to the Key + * objects used in this map. + */ private WeakHashMap stringCache = new WeakHashMap(); /** -* Every String passed to the public renderString() function is added to this WeakHashMap. As long as As long as Minecraft -* continues to hold a strong reference to the String object (i.e. from TileEntitySign and ChatLine) passed here, the -* weakRefCache map will continue to hold a strong reference to the Key object that said strings all map to (multiple strings -* in weakRefCache can map to a single Key if those strings only differ by their ASCII digits). -*/ + * Every String passed to the public renderString() function is added to this WeakHashMap. As long as As long as Minecraft + * continues to hold a strong reference to the String object (i.e. from TileEntitySign and ChatLine) passed here, the + * weakRefCache map will continue to hold a strong reference to the Key object that said strings all map to (multiple strings + * in weakRefCache can map to a single Key if those strings only differ by their ASCII digits). + */ private WeakHashMap weakRefCache = new WeakHashMap(); /** -* Temporary Key object re-used for lookups with stringCache.get(). Using a temporary object like this avoids the overhead -* of allocating new objects in the critical rendering path. Of course, new Key objects are always created when adding -* a mapping to stringCache. -*/ + * Temporary Key object re-used for lookups with stringCache.get(). Using a temporary object like this avoids the overhead + * of allocating new objects in the critical rendering path. Of course, new Key objects are always created when adding + * a mapping to stringCache. + */ private Key lookupKey = new Key(); /** -* Pre-cached glyphs for the ASCII digits 0-9 (in that order). Used by renderString() to substiture digit glyphs on the fly -* as a performance boost. The speed up is most noticable on the F3 screen which rapidly displays lots of changing numbers. -* The 4 element array is index by the font style (combination of Font.PLAIN, Font.BOLD, and Font.ITALIC), and each of the -* nested elements is index by the digit value 0-9. -*/ + * Pre-cached glyphs for the ASCII digits 0-9 (in that order). Used by renderString() to substiture digit glyphs on the fly + * as a performance boost. The speed up is most noticable on the F3 screen which rapidly displays lots of changing numbers. + * The 4 element array is index by the font style (combination of Font.PLAIN, Font.BOLD, and Font.ITALIC), and each of the + * nested elements is index by the digit value 0-9. + */ private Glyph[][] digitGlyphs = new Glyph[4][]; - /** True if digitGlyphs[] has been assigned and cacheString() can begin replacing all digits with '0' in the string. */ + /** + * True if digitGlyphs[] has been assigned and cacheString() can begin replacing all digits with '0' in the string. + */ private boolean digitGlyphsReady = false; - /** If true, then enble GL_BLEND in renderString() so anti-aliasing font glyphs show up properly. */ + /** + * If true, then enble GL_BLEND in renderString() so anti-aliasing font glyphs show up properly. + */ private boolean antiAliasEnabled = false; /** -* Reference to the main Minecraft thread that created this GlyphCache object. Starting with Minecraft 1.3.1, it is possible -* for GlyphCache.cacheGlyphs() to be invoked from the TcpReaderThread while processing a chat packet and computing the width -* of the incoming chat text. Unfortunately, if cacheGlyphs() makes any OpenGL calls from any thread except the main one, -* it will crash LWJGL with a NullPointerException. By remembering the initial thread and comparing it later against -* Thread.currentThread(), the StringCache code can avoid calling cacheGlyphs() when it's not safe to do so. -*/ + * Reference to the main Minecraft thread that created this GlyphCache object. Starting with Minecraft 1.3.1, it is possible + * for GlyphCache.cacheGlyphs() to be invoked from the TcpReaderThread while processing a chat packet and computing the width + * of the incoming chat text. Unfortunately, if cacheGlyphs() makes any OpenGL calls from any thread except the main one, + * it will crash LWJGL with a NullPointerException. By remembering the initial thread and comparing it later against + * Thread.currentThread(), the StringCache code can avoid calling cacheGlyphs() when it's not safe to do so. + */ private Thread mainThread; - + public int fontHeight; /** -* Wraps a String and acts as the key into stringCache. The hashCode() and equals() methods consider all ASCII digits -* to be equal when hashing and comparing Key objects together. Therefore, Strings which only differ in their digits will -* be all hashed together into the same entry. The renderString() method will then substitute the correct digit glyph on -* the fly. This special digit handling gives a significant speedup on the F3 debug screen. -*/ - static private class Key - { + * Wraps a String and acts as the key into stringCache. The hashCode() and equals() methods consider all ASCII digits + * to be equal when hashing and comparing Key objects together. Therefore, Strings which only differ in their digits will + * be all hashed together into the same entry. The renderString() method will then substitute the correct digit glyph on + * the fly. This special digit handling gives a significant speedup on the F3 debug screen. + */ + static private class Key { /** -* A copy of the String which this Key is indexing. A copy is used to avoid creating a strong reference to the original -* passed into renderString(). When the original String is no longer needed by Minecraft, it will be garbage collected -* and the WeakHashMaps in StringCache will allow this Key object and its associated Entry object to be garbage -* collected as well. -*/ + * A copy of the String which this Key is indexing. A copy is used to avoid creating a strong reference to the original + * passed into renderString(). When the original String is no longer needed by Minecraft, it will be garbage collected + * and the WeakHashMaps in StringCache will allow this Key object and its associated Entry object to be garbage + * collected as well. + */ public String str; /** -* Computes a hash code on str in the same manner as the String class, except all ASCII digits hash as '0' -* -* @return the augmented hash code on str -*/ + * Computes a hash code on str in the same manner as the String class, except all ASCII digits hash as '0' + * + * @return the augmented hash code on str + */ @Override - public int hashCode() - { + public int hashCode() { int code = 0, length = str.length(); /* -* True if a section mark character was last seen. In this case, if the next character is a digit, it must -* not be considered equal to any other digit. This forces any string that differs in color codes only to -* have a separate entry in the StringCache. -*/ + * True if a section mark character was last seen. In this case, if the next character is a digit, it must + * not be considered equal to any other digit. This forces any string that differs in color codes only to + * have a separate entry in the StringCache. + */ boolean colorCode = false; - for (int index = 0; index < length; index++) - { + for (int index = 0; index < length; index++) { char c = str.charAt(index); - if(c >= '0' && c <= '9' && !colorCode) - { + if (c >= '0' && c <= '9' && !colorCode) { c = '0'; } code = (code * 31) + c; @@ -165,21 +176,19 @@ public class StringCache } /** -* Compare str against another object (specifically, the object's string representation as returned by toString). -* All ASCII digits are considered equal by this method, as long as they are at the same index within the string. -* -* @return true if the strings are the identical, or only differ in their ASCII digits -*/ + * Compare str against another object (specifically, the object's string representation as returned by toString). + * All ASCII digits are considered equal by this method, as long as they are at the same index within the string. + * + * @return true if the strings are the identical, or only differ in their ASCII digits + */ @Override - public boolean equals(Object o) - { + public boolean equals(Object o) { /* -* There seems to be a timing window inside WeakHashMap itself where a null object can be passed to this -* equals() method. Presumably it happens between computing a hash code for the weakly referenced Key object -* while it still exists and calling its equals() method after it was garbage collected. -*/ - if(o == null) - { + * There seems to be a timing window inside WeakHashMap itself where a null object can be passed to this + * equals() method. Presumably it happens between computing a hash code for the weakly referenced Key object + * while it still exists and calling its equals() method after it was garbage collected. + */ + if (o == null) { return false; } @@ -187,25 +196,22 @@ public class StringCache String other = o.toString(); int length = str.length(); - if(length != other.length()) - { + if (length != other.length()) { return false; } /* -* True if a section mark character was last seen. In this case, if the next character is a digit, it must -* not be considered equal to any other digit. This forces any string that differs in color codes only to -* have a separate entry in the StringCache. -*/ + * True if a section mark character was last seen. In this case, if the next character is a digit, it must + * not be considered equal to any other digit. This forces any string that differs in color codes only to + * have a separate entry in the StringCache. + */ boolean colorCode = false; - for(int index = 0; index < length; index++) - { + for (int index = 0; index < length; index++) { char c1 = str.charAt(index); char c2 = other.charAt(index); - if(c1 != c2 && (c1 < '0' || c1 > '9' || c2 < '0' || c2 > '9' || colorCode)) - { + if (c1 != c2 && (c1 < '0' || c1 > '9' || c2 < '0' || c2 > '9' || colorCode)) { return false; } colorCode = (c1 == '\u00A7'); @@ -215,137 +221,165 @@ public class StringCache } /** -* Returns the contained String object within this Key. -* -* @return the str object -*/ + * Returns the contained String object within this Key. + * + * @return the str object + */ @Override - public String toString() - { + public String toString() { return str; } } - /** This entry holds the layed out glyph positions for the cached string along with some relevant metadata. */ - static private class Entry - { - /** A weak reference back to the Key object in stringCache that maps to this Entry. */ + /** + * This entry holds the layed out glyph positions for the cached string along with some relevant metadata. + */ + static private class Entry { + /** + * A weak reference back to the Key object in stringCache that maps to this Entry. + */ public WeakReference keyRef; - /** The total horizontal advance (i.e. width) for this string in pixels. */ + /** + * The total horizontal advance (i.e. width) for this string in pixels. + */ public int advance; - /** Array of fully layed out glyphs for the string. Sorted by logical order of characters (i.e. glyph.stringIndex) */ + /** + * Array of fully layed out glyphs for the string. Sorted by logical order of characters (i.e. glyph.stringIndex) + */ public Glyph glyphs[]; - /** Array of color code locations from the original string */ + /** + * Array of color code locations from the original string + */ public ColorCode colors[]; - /** True if the string uses strikethrough or underlines anywhere and needs an extra pass in renderString() */ + /** + * True if the string uses strikethrough or underlines anywhere and needs an extra pass in renderString() + */ public boolean specialRender; } - /** Identifies the location and value of a single color code in the original string */ - static private class ColorCode implements Comparable - { - /** Bit flag used with renderStyle to request the underline style */ + /** + * Identifies the location and value of a single color code in the original string + */ + static private class ColorCode implements Comparable { + /** + * Bit flag used with renderStyle to request the underline style + */ public static final byte UNDERLINE = 1; - /** Bit flag used with renderStyle to request the strikethrough style */ + /** + * Bit flag used with renderStyle to request the strikethrough style + */ public static final byte STRIKETHROUGH = 2; - /** The index into the original string (i.e. with color codes) for the location of this color code. */ + /** + * The index into the original string (i.e. with color codes) for the location of this color code. + */ public int stringIndex; - /** The index into the stripped string (i.e. with no color codes) of where this color code would have appeared */ + /** + * The index into the stripped string (i.e. with no color codes) of where this color code would have appeared + */ public int stripIndex; - /** The numeric color code (i.e. index into the colorCode[] array); -1 to reset default color */ + /** + * The numeric color code (i.e. index into the colorCode[] array); -1 to reset default color + */ public byte colorCode; - /** Combination of Font.PLAIN, Font.BOLD, and Font.ITALIC specifying font specific syles */ + /** + * Combination of Font.PLAIN, Font.BOLD, and Font.ITALIC specifying font specific syles + */ public byte fontStyle; - /** Combination of UNDERLINE and STRIKETHROUGH flags specifying effects performed by renderString() */ + /** + * Combination of UNDERLINE and STRIKETHROUGH flags specifying effects performed by renderString() + */ public byte renderStyle; /** -* Performs numeric comparison on stripIndex. Allows binary search on ColorCode arrays in layoutStyle. -* -* @param i the Integer object being compared -* @return either -1, 0, or 1 if this < other, this == other, or this > other -*/ + * Performs numeric comparison on stripIndex. Allows binary search on ColorCode arrays in layoutStyle. + * + * @param i the Integer object being compared + * @return either -1, 0, or 1 if this < other, this == other, or this > other + */ @Override - public int compareTo(Integer i) - { + public int compareTo(Integer i) { return (stringIndex == i.intValue()) ? 0 : (stringIndex < i.intValue()) ? -1 : 1; } } /** -* Identifies a single glyph in the layed-out string. Includes a reference to a GlyphCache.Entry with the OpenGL texture ID -* and position of the pre-rendered glyph image, and includes the x/y pixel coordinates of where this glyph occurs within -* the string to which this Glyph object belongs. -*/ - static private class Glyph implements Comparable - { - /** The index into the original string (i.e. with color codes) for the character that generated this glyph. */ + * Identifies a single glyph in the layed-out string. Includes a reference to a GlyphCache.Entry with the OpenGL texture ID + * and position of the pre-rendered glyph image, and includes the x/y pixel coordinates of where this glyph occurs within + * the string to which this Glyph object belongs. + */ + static private class Glyph implements Comparable { + /** + * The index into the original string (i.e. with color codes) for the character that generated this glyph. + */ public int stringIndex; - /** Texture ID and position/size of the glyph's pre-rendered image within the cache texture. */ + /** + * Texture ID and position/size of the glyph's pre-rendered image within the cache texture. + */ public GlyphCache.Entry texture; - /** Glyph's horizontal position (in pixels) relative to the entire string's baseline */ + /** + * Glyph's horizontal position (in pixels) relative to the entire string's baseline + */ public int x; - /** Glyph's vertical position (in pixels) relative to the entire string's baseline */ + /** + * Glyph's vertical position (in pixels) relative to the entire string's baseline + */ public int y; - /** Glyph's horizontal advance (in pixels) used for strikethrough and underline effects */ + /** + * Glyph's horizontal advance (in pixels) used for strikethrough and underline effects + */ public int advance; /** -* Allows arrays of Glyph objects to be sorted. Performs numeric comparison on stringIndex. -* -* @param o the other Glyph object being compared with this one -* @return either -1, 0, or 1 if this < other, this == other, or this > other -*/ + * Allows arrays of Glyph objects to be sorted. Performs numeric comparison on stringIndex. + * + * @param o the other Glyph object being compared with this one + * @return either -1, 0, or 1 if this < other, this == other, or this > other + */ @Override - public int compareTo(Glyph o) - { + public int compareTo(Glyph o) { return (stringIndex == o.stringIndex) ? 0 : (stringIndex < o.stringIndex) ? -1 : 1; } } /** -* A single StringCache object is allocated by Minecraft's FontRenderer which forwards all string drawing and requests for -* string width to this class. -* -* @param colors 32 element array of RGBA colors corresponding to the 16 text color codes followed by 16 darker version of the -* color codes for use as drop shadows -*/ - public StringCache() - { + * A single StringCache object is allocated by Minecraft's FontRenderer which forwards all string drawing and requests for + * string width to this class. + * + * @param colors 32 element array of RGBA colors corresponding to the 16 text color codes followed by 16 darker version of the + * color codes for use as drop shadows + */ + public StringCache() { /* StringCache is created by the main game thread; remember it for later thread safety checks */ mainThread = Thread.currentThread(); glyphCache = new GlyphCache(); colorTable = new int[32]; - for (int i = 0; i < 32; ++i) - { + for (int i = 0; i < 32; ++i) { int j = (i >> 3 & 1) * 85; int k = (i >> 2 & 1) * 170 + j; int l = (i >> 1 & 1) * 170 + j; int i1 = (i >> 0 & 1) * 170 + j; - if (i == 6) - { + if (i == 6) { k += 85; } - if (Minecraft.getMinecraft().gameSettings.anaglyph) - { + if (Minecraft.getMinecraft().gameSettings.anaglyph) { int j1 = (k * 30 + l * 59 + i1 * 11) / 100; int k1 = (k * 30 + l * 70) / 100; int l1 = (k * 30 + i1 * 70) / 100; @@ -354,8 +388,7 @@ public class StringCache i1 = l1; } - if (i >= 16) - { + if (i >= 16) { k /= 4; l /= 4; i1 /= 4; @@ -369,15 +402,14 @@ public class StringCache } /** -* Change the default font used to pre-render glyph images. If this method is called at runtime, the string cache is flushed so that -* all visible strings will be immediately re-layed out using the new font selection. -* -* @param fontName the new font name -* @param fontSize the new point size -* @param antiAlias turn on anti aliasing -*/ - public void setDefaultFont(String fontName, int fontSize, boolean antiAlias) - { + * Change the default font used to pre-render glyph images. If this method is called at runtime, the string cache is flushed so that + * all visible strings will be immediately re-layed out using the new font selection. + * + * @param fontName the new font name + * @param fontSize the new point size + * @param antiAlias turn on anti aliasing + */ + public void setDefaultFont(String fontName, int fontSize, boolean antiAlias) { /* Change the font in the glyph cache and clear the string cache so all strings have to be re-layed out and re-rendered */ glyphCache.setDefaultFont(fontName, fontSize, antiAlias); antiAliasEnabled = antiAlias; @@ -388,13 +420,12 @@ public class StringCache cacheDightGlyphs(); updateHeight(); } - - public Font usedFont(){ - return glyphCache.usedFonts.get(0); + + public Font usedFont() { + return glyphCache.usedFonts.get(0); } - - public void setCustomFont(ResourceLocation resource, int fontSize, boolean antiAlias) throws Exception - { + + public void setCustomFont(ResourceLocation resource, int fontSize, boolean antiAlias) throws Exception { /* Change the font in the glyph cache and clear the string cache so all strings have to be re-layed out and re-rendered */ glyphCache.setCustomFont(resource, fontSize, antiAlias); antiAliasEnabled = antiAlias; @@ -405,29 +436,28 @@ public class StringCache cacheDightGlyphs(); updateHeight(); } - - public void updateHeight(){ + + public void updateHeight() { int height = 0; int minY = Integer.MAX_VALUE; int maxY = Integer.MIN_VALUE; - - for(Glyph g : cacheString("AaBbCcDdEeHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz").glyphs){ - if(g.texture.height > height) - height = g.texture.height; - if(g.y < minY) - minY = g.y; - if(g.y > maxY) - maxY = g.y; + + for (Glyph g : cacheString("AaBbCcDdEeHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz").glyphs) { + if (g.texture.height > height) + height = g.texture.height; + if (g.y < minY) + minY = g.y; + if (g.y > maxY) + maxY = g.y; } - fontHeight = (int) ((maxY + height) / 2.0F - minY / 2.0F ); + fontHeight = (int) ((maxY + height) / 2.0F - minY / 2.0F); } /** -* Pre-cache the ASCII digits to allow for fast glyph substitution. Called once from the constructor and called any time the font selection -* changes at runtime via setDefaultFont(). -*/ - private void cacheDightGlyphs() - { + * Pre-cache the ASCII digits to allow for fast glyph substitution. Called once from the constructor and called any time the font selection + * changes at runtime via setDefaultFont(). + */ + private void cacheDightGlyphs() { /* Need to cache each font style combination; the digitGlyphsReady = false disabled the normal glyph substitution mechanism */ digitGlyphsReady = false; digitGlyphs[Font.PLAIN] = cacheString("0123456789").glyphs; @@ -438,30 +468,27 @@ public class StringCache } /** -* Render a single-line string to the screen using the current OpenGL color. The (x,y) coordinates are of the uppet-left -* corner of the string's bounding box, rather than the baseline position as is typical with fonts. This function will also -* add the string to the cache so the next renderString() call with the same string is faster. -* -* @param str the string being rendered; it can contain color codes -* @param startX the x coordinate to draw at -* @param startY the y coordinate to draw at -* @param initialColor the initial RGBA color to use when drawing the string; embedded color codes can override the RGB component -* @param shadowFlag if true, color codes are replaces by a darker version used for drop shadows -* @return the total advance (horizontal distance) of this string -* -* @todo Add optional NumericShaper to replace ASCII digits with locale specific ones -* @todo Add support for the "k" code which randomly replaces letters on each render (used only by splash screen) -* @todo Pre-sort by texture to minimize binds; can store colors per glyph in string cache -* @todo Optimize the underline/strikethrough drawing to draw a single line for each run -*/ - public int renderString(String str, int startX, int startY, int initialColor, boolean shadowFlag) - { + * Render a single-line string to the screen using the current OpenGL color. The (x,y) coordinates are of the uppet-left + * corner of the string's bounding box, rather than the baseline position as is typical with fonts. This function will also + * add the string to the cache so the next renderString() call with the same string is faster. + * + * @param str the string being rendered; it can contain color codes + * @param startX the x coordinate to draw at + * @param startY the y coordinate to draw at + * @param initialColor the initial RGBA color to use when drawing the string; embedded color codes can override the RGB component + * @param shadowFlag if true, color codes are replaces by a darker version used for drop shadows + * @return the total advance (horizontal distance) of this string + * @todo Add optional NumericShaper to replace ASCII digits with locale specific ones + * @todo Add support for the "k" code which randomly replaces letters on each render (used only by splash screen) + * @todo Pre-sort by texture to minimize binds; can store colors per glyph in string cache + * @todo Optimize the underline/strikethrough drawing to draw a single line for each run + */ + public int renderString(String str, int startX, int startY, int initialColor, boolean shadowFlag) { /* Check for invalid arguments */ - if(str == null || str.isEmpty()) - { + if (str == null || str.isEmpty()) { return 0; } - + /* Make sure the entire string is cached before rendering and return its glyph representation */ Entry entry = cacheString(str); @@ -470,29 +497,28 @@ public class StringCache startY += BASELINE_OFFSET; /* Color currently selected by color code; reapplied to Tessellator instance after glBindTexture() */ - - if((initialColor >> 24 & 0xff) == 0) - initialColor += 0xFF000000; + + if ((initialColor >> 24 & 0xff) == 0) + initialColor += 0xFF000000; int color = initialColor; /* Track which texture is currently bound to minimize the number of glBindTexture() and Tessellator.draw() calls needed */ int boundTextureName = 0; /* -* This color change will have no effect on the actual text (since colors are included in the Tessellator vertex -* array), however GuiEditSign of all things depends on having the current color set to white when it renders its -* "Edit sign message:" text. Otherwise, the sign which is rendered underneath would look too dark. -*/ + * This color change will have no effect on the actual text (since colors are included in the Tessellator vertex + * array), however GuiEditSign of all things depends on having the current color set to white when it renders its + * "Edit sign message:" text. Otherwise, the sign which is rendered underneath would look too dark. + */ GL11.glTexEnvi(GL11.GL_TEXTURE_ENV, GL11.GL_TEXTURE_ENV_MODE, GL11.GL_MODULATE); //fixes black text GL11.glColor4f((color >> 16 & 0xff) / 255f, (color >> 8 & 0xff) / 255f, (color & 0xff) / 255f, 1); /* -* Enable GL_BLEND in case the font is drawn anti-aliased because Minecraft itself only enables blending for chat text -* (so it can fade out), but not GUI text or signs. Minecraft uses multiple blend functions so it has to be specified here -* as well for consistent blending. To reduce the overhead of OpenGL state changes and making native LWJGL calls, this -* function doesn't try to save/restore the blending state. Hopefully everything else that depends on blending in Minecraft -* will set its own state as needed. -*/ - if(antiAliasEnabled) - { + * Enable GL_BLEND in case the font is drawn anti-aliased because Minecraft itself only enables blending for chat text + * (so it can fade out), but not GUI text or signs. Minecraft uses multiple blend functions so it has to be specified here + * as well for consistent blending. To reduce the overhead of OpenGL state changes and making native LWJGL calls, this + * function doesn't try to save/restore the blending state. Hopefully everything else that depends on blending in Minecraft + * will set its own state as needed. + */ + if (antiAliasEnabled) { GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); } @@ -505,16 +531,14 @@ public class StringCache /* The currently active font syle is needed to select the proper ASCII digit style for fast replacement */ int fontStyle = Font.PLAIN; - for(int glyphIndex = 0, colorIndex = 0; glyphIndex < entry.glyphs.length; glyphIndex++) - { + for (int glyphIndex = 0, colorIndex = 0; glyphIndex < entry.glyphs.length; glyphIndex++) { /* -* If the original string had a color code at this glyph's position, then change the current GL color that gets added -* to the vertex array. Note that only the RGB component of the color is replaced by a color code; the alpha component -* of the original color passed into this function will remain. The while loop handles multiple consecutive color codes, -* in which case only the last such color code takes effect. -*/ - while(colorIndex < entry.colors.length && entry.glyphs[glyphIndex].stringIndex >= entry.colors[colorIndex].stringIndex) - { + * If the original string had a color code at this glyph's position, then change the current GL color that gets added + * to the vertex array. Note that only the RGB component of the color is replaced by a color code; the alpha component + * of the original color passed into this function will remain. The while loop handles multiple consecutive color codes, + * in which case only the last such color code takes effect. + */ + while (colorIndex < entry.colors.length && entry.glyphs[glyphIndex].stringIndex >= entry.colors[colorIndex].stringIndex) { color = applyColorCode(entry.colors[colorIndex].colorCode, initialColor, shadowFlag); fontStyle = entry.colors[colorIndex].fontStyle; colorIndex++; @@ -526,14 +550,13 @@ public class StringCache int glyphX = glyph.x; /* -* Replace ASCII digits in the string with their respective glyphs; strings differing by digits are only cached once. -* If the new replacement glyph has a different width than the original placeholder glyph (e.g. the '1' glyph is often -* narrower than other digits), re-center the new glyph over the placeholder's position to minimize the visual impact -* of the width mismatch. -*/ + * Replace ASCII digits in the string with their respective glyphs; strings differing by digits are only cached once. + * If the new replacement glyph has a different width than the original placeholder glyph (e.g. the '1' glyph is often + * narrower than other digits), re-center the new glyph over the placeholder's position to minimize the visual impact + * of the width mismatch. + */ char c = str.charAt(glyph.stringIndex); - if(c >= '0' && c <= '9') - { + if (c >= '0' && c <= '9') { int oldWidth = texture.width; texture = digitGlyphs[fontStyle][c - '0'].texture; int newWidth = texture.width; @@ -541,11 +564,11 @@ public class StringCache } /* -* Make sure the OpenGL texture storing this glyph's image is bound (if not already bound). All pending glyphs in the -* Tessellator's vertex array must be drawn before switching textures, otherwise they would erroneously use the new -* texture as well. -*/ - if(boundTextureName != texture.textureName) + * Make sure the OpenGL texture storing this glyph's image is bound (if not already bound). All pending glyphs in the + * Tessellator's vertex array must be drawn before switching textures, otherwise they would erroneously use the new + * texture as well. + */ + if (boundTextureName != texture.textureName) //if(true) { tessellator.draw(); @@ -571,8 +594,7 @@ public class StringCache tessellator.draw(); /* Draw strikethrough and underlines if the string uses them anywhere */ - if(entry.specialRender) - { + if (entry.specialRender) { int renderStyle = 0; /* Use initial color passed to renderString(); disable texturing to draw solid color lines */ @@ -581,15 +603,13 @@ public class StringCache tessellator.startDrawingQuads(); tessellator.setColorRGBA(color >> 16 & 0xff, color >> 8 & 0xff, color & 0xff, color >> 24 & 0xff); - for(int glyphIndex = 0, colorIndex = 0; glyphIndex < entry.glyphs.length; glyphIndex++) - { + for (int glyphIndex = 0, colorIndex = 0; glyphIndex < entry.glyphs.length; glyphIndex++) { /* -* If the original string had a color code at this glyph's position, then change the current GL color that gets added -* to the vertex array. The while loop handles multiple consecutive color codes, in which case only the last such -* color code takes effect. -*/ - while(colorIndex < entry.colors.length && entry.glyphs[glyphIndex].stringIndex >= entry.colors[colorIndex].stringIndex) - { + * If the original string had a color code at this glyph's position, then change the current GL color that gets added + * to the vertex array. The while loop handles multiple consecutive color codes, in which case only the last such + * color code takes effect. + */ + while (colorIndex < entry.colors.length && entry.glyphs[glyphIndex].stringIndex >= entry.colors[colorIndex].stringIndex) { color = applyColorCode(entry.colors[colorIndex].colorCode, initialColor, shadowFlag); renderStyle = entry.colors[colorIndex].renderStyle; colorIndex++; @@ -602,8 +622,7 @@ public class StringCache int glyphSpace = glyph.advance - glyph.texture.width; /* Draw underline under glyph if the style is enabled */ - if((renderStyle & ColorCode.UNDERLINE) != 0) - { + if ((renderStyle & ColorCode.UNDERLINE) != 0) { /* The divide by 2.0F is needed to align with the scaled GUI coordinate system; startX/startY are already scaled */ float x1 = startX + (glyph.x - glyphSpace) / 2.0F; float x2 = startX + (glyph.x + glyph.advance) / 2.0F; @@ -617,8 +636,7 @@ public class StringCache } /* Draw strikethrough in the middle of glyph if the style is enabled */ - if((renderStyle & ColorCode.STRIKETHROUGH) != 0) - { + if ((renderStyle & ColorCode.STRIKETHROUGH) != 0) { /* The divide by 2.0F is needed to align with the scaled GUI coordinate system; startX/startY are already scaled */ float x1 = startX + (glyph.x - glyphSpace) / 2.0F; float x2 = startX + (glyph.x + glyph.advance) / 2.0F; @@ -643,16 +661,14 @@ public class StringCache } /** -* Return the width of a string in pixels. Used for centering strings inside GUI buttons. -* -* @param str compute the width of this string -* @return the width in pixels (divided by 2; this matches the scaled coordinate system used by GUIs in Minecraft) -*/ - public int getStringWidth(String str) - { + * Return the width of a string in pixels. Used for centering strings inside GUI buttons. + * + * @param str compute the width of this string + * @return the width in pixels (divided by 2; this matches the scaled coordinate system used by GUIs in Minecraft) + */ + public int getStringWidth(String str) { /* Check for invalid arguments */ - if(str == null || str.isEmpty()) - { + if (str == null || str.isEmpty()) { return 0; } @@ -664,20 +680,18 @@ public class StringCache } /** -* Return the number of characters in a string that will completly fit inside the specified width when rendered, with -* or without prefering to break the line at whitespace instead of breaking in the middle of a word. This private provides -* the real implementation of both sizeStringToWidth() and trimStringToWidth(). -* -* @param str the String to analyze -* @param width the desired string width (in GUI coordinate system) -* @param breakAtSpaces set to prefer breaking line at spaces than in the middle of a word -* @return the number of characters from str that will fit inside width -*/ - private int sizeString(String str, int width, boolean breakAtSpaces) - { + * Return the number of characters in a string that will completly fit inside the specified width when rendered, with + * or without prefering to break the line at whitespace instead of breaking in the middle of a word. This private provides + * the real implementation of both sizeStringToWidth() and trimStringToWidth(). + * + * @param str the String to analyze + * @param width the desired string width (in GUI coordinate system) + * @param breakAtSpaces set to prefer breaking line at spaces than in the middle of a word + * @return the number of characters from str that will fit inside width + */ + private int sizeString(String str, int width, boolean breakAtSpaces) { /* Check for invalid arguments */ - if(str == null || str.isEmpty()) - { + if (str == null || str.isEmpty()) { return 0; } @@ -692,18 +706,13 @@ public class StringCache /* Add up the individual advance of each glyph until it exceeds the specified width */ int advance = 0, index = 0; - while(index < glyphs.length && advance <= width) - { + while (index < glyphs.length && advance <= width) { /* Keep track of spaces if breakAtSpaces it set */ - if(breakAtSpaces) - { + if (breakAtSpaces) { char c = str.charAt(glyphs[index].stringIndex); - if(c == ' ') - { + if (c == ' ') { wsIndex = index; - } - else if(c == '\n') - { + } else if (c == '\n') { wsIndex = index; break; } @@ -714,8 +723,7 @@ public class StringCache } /* Avoid splitting individual words if breakAtSpaces set; same test condition as in Minecraft's FontRenderer */ - if(index < glyphs.length && wsIndex != -1 && wsIndex < index) - { + if (index < glyphs.length && wsIndex != -1 && wsIndex < index) { index = wsIndex; } @@ -724,32 +732,29 @@ public class StringCache } /** -* Return the number of characters in a string that will completly fit inside the specified width when rendered. -* -* @param str the String to analyze -* @param width the desired string width (in GUI coordinate system) -* @return the number of characters from str that will fit inside width -*/ - public int sizeStringToWidth(String str, int width) - { + * Return the number of characters in a string that will completly fit inside the specified width when rendered. + * + * @param str the String to analyze + * @param width the desired string width (in GUI coordinate system) + * @return the number of characters from str that will fit inside width + */ + public int sizeStringToWidth(String str, int width) { return sizeString(str, width, true); } /** -* Trim a string so that it fits in the specified width when rendered, optionally reversing the string -* -* @param str the String to trim -* @param width the desired string width (in GUI coordinate system) -* @param reverse if true, the returned string will also be reversed -* @return the trimmed and optionally reversed string -*/ - public String trimStringToWidth(String str, int width, boolean reverse) - { + * Trim a string so that it fits in the specified width when rendered, optionally reversing the string + * + * @param str the String to trim + * @param width the desired string width (in GUI coordinate system) + * @param reverse if true, the returned string will also be reversed + * @return the trimmed and optionally reversed string + */ + public String trimStringToWidth(String str, int width, boolean reverse) { int length = sizeString(str, width, false); str = str.substring(0, length); - if(reverse) - { + if (reverse) { str = (new StringBuilder(str)).reverse().toString(); } @@ -757,19 +762,17 @@ public class StringCache } /** -* Apply a new vertex color to the Tessellator instance based on the numeric chat color code. Only the RGB component of the -* color is replaced by a color code; the alpha component of the original default color will remain. -* -* @param colorCode the chat color code as a number 0-15 or -1 to reset the default color -* @param color the default color used when the colorCode is -1 -* @param shadowFlag ir true, the color code will select a darker version of the color suitable for drop shadows -* @return the new RGBA color set by this function -*/ - private int applyColorCode(int colorCode, int color, boolean shadowFlag) - { + * Apply a new vertex color to the Tessellator instance based on the numeric chat color code. Only the RGB component of the + * color is replaced by a color code; the alpha component of the original default color will remain. + * + * @param colorCode the chat color code as a number 0-15 or -1 to reset the default color + * @param color the default color used when the colorCode is -1 + * @param shadowFlag ir true, the color code will select a darker version of the color suitable for drop shadows + * @return the new RGBA color set by this function + */ + private int applyColorCode(int colorCode, int color, boolean shadowFlag) { /* A -1 color code indicates a reset to the initial color passed into renderString() */ - if(colorCode != -1) - { + if (colorCode != -1) { colorCode = shadowFlag ? colorCode + 16 : colorCode; color = colorTable[colorCode] & 0xffffff | color & 0xff000000; } @@ -779,30 +782,28 @@ public class StringCache } /** -* Add a string to the string cache by perform full layout on it, remembering its glyph positions, and making sure that -* every font glyph used by the string is pre-rendering. If this string has already been cached, then simply return its -* existing Entry from the cahe. Note that for caching purposes, this method considers two strings to be identical if they -* only differ in their ASCII digits; the renderString() method performs fast glyph substitution based on the actual digits -* in the string at the time. -* -* @param str this String will be layed out and added to the cache (or looked up, if alraedy cached) -* @return the string's cache entry containing all the glyph positions -*/ - private Entry cacheString(String str) - { + * Add a string to the string cache by perform full layout on it, remembering its glyph positions, and making sure that + * every font glyph used by the string is pre-rendering. If this string has already been cached, then simply return its + * existing Entry from the cahe. Note that for caching purposes, this method considers two strings to be identical if they + * only differ in their ASCII digits; the renderString() method performs fast glyph substitution based on the actual digits + * in the string at the time. + * + * @param str this String will be layed out and added to the cache (or looked up, if alraedy cached) + * @return the string's cache entry containing all the glyph positions + */ + private Entry cacheString(String str) { /* -* New Key object allocated only if the string was not found in the StringCache using lookupKey. This variable must -* be outside the (entry == null) code block to have a temporary strong reference between the time when the Key is -* added to stringCache and added to weakRefCache. -*/ + * New Key object allocated only if the string was not found in the StringCache using lookupKey. This variable must + * be outside the (entry == null) code block to have a temporary strong reference between the time when the Key is + * added to stringCache and added to weakRefCache. + */ Key key; /* Either a newly created Entry object for the string, or the cached Entry if the string is already in the cache */ Entry entry = null; /* Don't perform a cache lookup from other threads because the stringCache is not synchronized */ - if(mainThread == Thread.currentThread()) - { + if (mainThread == Thread.currentThread()) { /* Re-use existing lookupKey to avoid allocation overhead on the critical rendering path */ lookupKey.str = str; @@ -811,8 +812,7 @@ public class StringCache } /* If string is not cached (or not on main thread) then layout the string */ - if(entry == null) - { + if (entry == null) { /* layoutGlyphVector() requires a char[] so create it here and pass it around to avoid duplication later on */ char text[] = str.toCharArray(); @@ -829,25 +829,23 @@ public class StringCache entry.glyphs = glyphList.toArray(entry.glyphs); /* -* Sort Glyph array by stringIndex so it can be compared during rendering to the already sorted ColorCode array. -* This will apply color codes in the string's logical character order and not the visual order on screen. -*/ + * Sort Glyph array by stringIndex so it can be compared during rendering to the already sorted ColorCode array. + * This will apply color codes in the string's logical character order and not the visual order on screen. + */ Arrays.sort(entry.glyphs); /* Do some post-processing on each Glyph object */ int colorIndex = 0, shift = 0; - for(int glyphIndex = 0; glyphIndex < entry.glyphs.length; glyphIndex++) - { + for (int glyphIndex = 0; glyphIndex < entry.glyphs.length; glyphIndex++) { Glyph glyph = entry.glyphs[glyphIndex]; /* -* Adjust the string index for each glyph to point into the original string with unstripped color codes. The while -* loop is necessary to handle multiple consecutive color codes with no visible glyphs between them. These new adjusted -* stringIndex can now be compared against the color stringIndex during rendering. It also allows lookups of ASCII -* digits in the original string for fast glyph replacement during rendering. -*/ - while(colorIndex < entry.colors.length && glyph.stringIndex + shift >= entry.colors[colorIndex].stringIndex) - { + * Adjust the string index for each glyph to point into the original string with unstripped color codes. The while + * loop is necessary to handle multiple consecutive color codes with no visible glyphs between them. These new adjusted + * stringIndex can now be compared against the color stringIndex during rendering. It also allows lookups of ASCII + * digits in the original string for fast glyph replacement during rendering. + */ + while (colorIndex < entry.colors.length && glyph.stringIndex + shift >= entry.colors[colorIndex].stringIndex) { shift += 2; colorIndex++; } @@ -855,11 +853,10 @@ public class StringCache } /* -* Do not actually cache the string when called from other threads because GlyphCache.cacheGlyphs() will not have been called -* and the cache entry does not contain any texture data needed for rendering. -*/ - if(mainThread == Thread.currentThread()) - { + * Do not actually cache the string when called from other threads because GlyphCache.cacheGlyphs() will not have been called + * and the cache entry does not contain any texture data needed for rendering. + */ + if (mainThread == Thread.currentThread()) { /* Wrap the string in a Key object (to change how ASCII digits are compared) and cache it along with the newly generated Entry */ key = new Key(); @@ -871,17 +868,15 @@ public class StringCache } /* Do not access weakRefCache from other threads since it is unsynchronized, and for a newly created entry, the keyRef is null */ - if(mainThread == Thread.currentThread()) - { + if (mainThread == Thread.currentThread()) { /* -* Add the String passed into this method to the stringWeakMap so it keeps the Key reference live as long as the String is in use. -* If an existing Entry was already found in the stringCache, it's possible that its Key has already been garbage collected. The -* code below checks for this to avoid adding (str, null) entries into weakRefCache. Note that if a new Key object was created, it -* will still be live because of the strong reference created by the "key" variable. -*/ + * Add the String passed into this method to the stringWeakMap so it keeps the Key reference live as long as the String is in use. + * If an existing Entry was already found in the stringCache, it's possible that its Key has already been garbage collected. The + * code below checks for this to avoid adding (str, null) entries into weakRefCache. Note that if a new Key object was created, it + * will still be live because of the strong reference created by the "key" variable. + */ Key oldKey = entry.keyRef.get(); - if(oldKey != null) - { + if (oldKey != null) { weakRefCache.put(str, oldKey); } lookupKey.str = null; @@ -892,17 +887,16 @@ public class StringCache } /** -* Remove all color codes from the string by shifting data in the text[] array over so it overwrites them. The value of each -* color code and its position (relative to the new stripped text[]) is also recorded in a separate array. The color codes must -* be removed for a font's context sensitive glyph substitution to work (like Arabic letter middle form). -* -* @param cacheEntry each color change in the string will add a new ColorCode object to this list -* @param str the string from which color codes will be stripped -* @param text on input it should be an identical copy of str; on output it will be string with all color codes removed -* @return the length of the new stripped string in text[]; actual text.length will not change because the array is not reallocated -*/ - private int stripColorCodes(Entry cacheEntry, String str, char text[]) - { + * Remove all color codes from the string by shifting data in the text[] array over so it overwrites them. The value of each + * color code and its position (relative to the new stripped text[]) is also recorded in a separate array. The color codes must + * be removed for a font's context sensitive glyph substitution to work (like Arabic letter middle form). + * + * @param cacheEntry each color change in the string will add a new ColorCode object to this list + * @param str the string from which color codes will be stripped + * @param text on input it should be an identical copy of str; on output it will be string with all color codes removed + * @return the length of the new stripped string in text[]; actual text.length will not change because the array is not reallocated + */ + private int stripColorCodes(Entry cacheEntry, String str, char text[]) { List colorList = new ArrayList(); int start = 0, shift = 0, next; @@ -911,20 +905,18 @@ public class StringCache byte colorCode = -1; /* Search for section mark characters indicating the start of a color code (but only if followed by at least one character) */ - while((next = str.indexOf('\u00A7', start)) != -1 && next + 1 < str.length()) - { + while ((next = str.indexOf('\u00A7', start)) != -1 && next + 1 < str.length()) { /* -* Remove the two char color code from text[] by shifting the remaining data in the array over on top of it. -* The "start" and "next" variables all contain offsets into the original unmodified "str" string. The "shift" -* variable keeps track of how many characters have been sripped so far, and it's used to compute offsets into -* the text[] array based on the start/next offsets in the original string. -*/ + * Remove the two char color code from text[] by shifting the remaining data in the array over on top of it. + * The "start" and "next" variables all contain offsets into the original unmodified "str" string. The "shift" + * variable keeps track of how many characters have been sripped so far, and it's used to compute offsets into + * the text[] array based on the start/next offsets in the original string. + */ System.arraycopy(text, next - shift + 2, text, next - shift, text.length - next - 2); /* Decode escape code used in the string and change current font style / color based on it */ int code = "0123456789abcdefklmnor".indexOf(Character.toLowerCase(str.charAt(next + 1))); - switch(code) - { + switch (code) { /* Random style; TODO: NOT IMPLEMENTED YET */ case 16: break; @@ -960,8 +952,7 @@ public class StringCache /* Otherwise, must be a color code or some other unsupported code */ default: - if(code >= 0 && code <= 15) - { + if (code >= 0 && code <= 15) { colorCode = (byte) code; fontStyle = Font.PLAIN; // This may be a bug in Minecraft's original FontRenderer renderStyle = 0; // This may be a bug in Minecraft's original FontRenderer @@ -992,53 +983,47 @@ public class StringCache } /** -* Split a string into contiguous LTR or RTL sections by applying the Unicode Bidirectional Algorithm. Calls layoutString() -* for each contiguous run to perform further analysis. -* -* @param glyphList will hold all new Glyph objects allocated by layoutFont() -* @param text the string to lay out -* @param start the offset into text at which to start the layout -* @param limit the (offset + length) at which to stop performing the layout -* @return the total advance (horizontal distance) of this string -*/ - private int layoutBidiString(List glyphList, char text[], int start, int limit, ColorCode colors[]) - { + * Split a string into contiguous LTR or RTL sections by applying the Unicode Bidirectional Algorithm. Calls layoutString() + * for each contiguous run to perform further analysis. + * + * @param glyphList will hold all new Glyph objects allocated by layoutFont() + * @param text the string to lay out + * @param start the offset into text at which to start the layout + * @param limit the (offset + length) at which to stop performing the layout + * @return the total advance (horizontal distance) of this string + */ + private int layoutBidiString(List glyphList, char text[], int start, int limit, ColorCode colors[]) { int advance = 0; /* Avoid performing full bidirectional analysis if text has no "strong" right-to-left characters */ - if(Bidi.requiresBidi(text, start, limit)) - { + if (Bidi.requiresBidi(text, start, limit)) { /* Note that while requiresBidi() uses start/limit the Bidi constructor uses start/length */ Bidi bidi = new Bidi(text, start, null, 0, limit - start, Bidi.DIRECTION_DEFAULT_LEFT_TO_RIGHT); /* If text is entirely right-to-left, then insert an EntryText node for the entire string */ - if(bidi.isRightToLeft()) - { + if (bidi.isRightToLeft()) { return layoutStyle(glyphList, text, start, limit, Font.LAYOUT_RIGHT_TO_LEFT, advance, colors); } /* Otherwise text has a mixture of LTR and RLT, and it requires full bidirectional analysis */ - else - { + else { int runCount = bidi.getRunCount(); byte levels[] = new byte[runCount]; Integer ranges[] = new Integer[runCount]; /* Reorder contiguous runs of text into their display order from left to right */ - for(int index = 0; index < runCount; index++) - { + for (int index = 0; index < runCount; index++) { levels[index] = (byte) bidi.getRunLevel(index); ranges[index] = new Integer(index); } Bidi.reorderVisually(levels, 0, ranges, 0, runCount); /* -* Every GlyphVector must be created on a contiguous run of left-to-right or right-to-left text. Keep track of -* the horizontal advance between each run of text, so that the glyphs in each run can be assigned a position relative -* to the start of the entire string and not just relative to that run. -*/ - for(int visualIndex = 0; visualIndex < runCount; visualIndex++) - { + * Every GlyphVector must be created on a contiguous run of left-to-right or right-to-left text. Keep track of + * the horizontal advance between each run of text, so that the glyphs in each run can be assigned a position relative + * to the start of the entire string and not just relative to that run. + */ + for (int visualIndex = 0; visualIndex < runCount; visualIndex++) { int logicalIndex = ranges[visualIndex]; /* An odd numbered level indicates right-to-left ordering */ @@ -1052,54 +1037,46 @@ public class StringCache } /* If text is entirely left-to-right, then insert an EntryText node for the entire string */ - else - { + else { return layoutStyle(glyphList, text, start, limit, Font.LAYOUT_LEFT_TO_RIGHT, advance, colors); } } - private int layoutStyle(List glyphList, char text[], int start, int limit, int layoutFlags, int advance, ColorCode colors[]) - { + private int layoutStyle(List glyphList, char text[], int start, int limit, int layoutFlags, int advance, ColorCode colors[]) { int currentFontStyle = Font.PLAIN; /* Find ColorCode object with stripIndex <= start; that will have the font style in effect at the beginning of this text run */ int colorIndex = Arrays.binarySearch(colors, start); /* -* If no exact match is found, Arrays.binarySearch() returns (-(insertion point) - 1) where the insertion point is the index -* of the first ColorCode with a stripIndex > start. In that case, colorIndex is adjusted to select the immediately preceding -* ColorCode whose stripIndex < start. -*/ - if(colorIndex < 0) - { + * If no exact match is found, Arrays.binarySearch() returns (-(insertion point) - 1) where the insertion point is the index + * of the first ColorCode with a stripIndex > start. In that case, colorIndex is adjusted to select the immediately preceding + * ColorCode whose stripIndex < start. + */ + if (colorIndex < 0) { colorIndex = -colorIndex - 2; } /* Break up the string into segments, where each segment has the same font style in use */ - while(start < limit) - { + while (start < limit) { int next = limit; /* In case of multiple consecutive color codes with the same stripIndex, select the last one which will have active font style */ - while(colorIndex >= 0 && colorIndex < (colors.length - 1) && colors[colorIndex].stripIndex == colors[colorIndex + 1].stripIndex) - { + while (colorIndex >= 0 && colorIndex < (colors.length - 1) && colors[colorIndex].stripIndex == colors[colorIndex + 1].stripIndex) { colorIndex++; } /* If an actual ColorCode object was found (colorIndex within the array), use its fontStyle for layout and render */ - if(colorIndex >= 0 && colorIndex < colors.length) - { + if (colorIndex >= 0 && colorIndex < colors.length) { currentFontStyle = colors[colorIndex].fontStyle; } /* -* Search for the next ColorCode that uses a different fontStyle than the current one. If found, the stripIndex of that -* new code is the split point where the string must be split into a separately styled segment. -*/ - while(++colorIndex < colors.length) - { - if(colors[colorIndex].fontStyle != currentFontStyle) - { + * Search for the next ColorCode that uses a different fontStyle than the current one. If found, the stripIndex of that + * new code is the split point where the string must be split into a separately styled segment. + */ + while (++colorIndex < colors.length) { + if (colors[colorIndex].fontStyle != currentFontStyle) { next = colors[colorIndex].stripIndex; break; } @@ -1114,61 +1091,53 @@ public class StringCache } /** -* Given a string that runs contiguously LTR or RTL, break it up into individual segments based on which fonts can render -* which characters in the string. Calls layoutFont() for each portion of the string that can be layed out with a single -* font. -* -* @param glyphList will hold all new Glyph objects allocated by layoutFont() -* @param text the string to lay out -* @param start the offset into text at which to start the layout -* @param limit the (offset + length) at which to stop performing the layout -* @param layoutFlags either Font.LAYOUT_RIGHT_TO_LEFT or Font.LAYOUT_LEFT_TO_RIGHT -* @param advance the horizontal advance (i.e. X position) returned by previous call to layoutString() -* @param style combination of Font.PLAIN, Font.BOLD, and Font.ITALIC to select a fonts with some specific style -* @return the advance (horizontal distance) of this string plus the advance passed in as an argument -* -* @todo Correctly handling RTL font selection requires scanning the sctring from RTL as well. -* @todo Use bitmap fonts as a fallback if no OpenType font could be found -*/ - private int layoutString(List glyphList, char text[], int start, int limit, int layoutFlags, int advance, int style) - { + * Given a string that runs contiguously LTR or RTL, break it up into individual segments based on which fonts can render + * which characters in the string. Calls layoutFont() for each portion of the string that can be layed out with a single + * font. + * + * @param glyphList will hold all new Glyph objects allocated by layoutFont() + * @param text the string to lay out + * @param start the offset into text at which to start the layout + * @param limit the (offset + length) at which to stop performing the layout + * @param layoutFlags either Font.LAYOUT_RIGHT_TO_LEFT or Font.LAYOUT_LEFT_TO_RIGHT + * @param advance the horizontal advance (i.e. X position) returned by previous call to layoutString() + * @param style combination of Font.PLAIN, Font.BOLD, and Font.ITALIC to select a fonts with some specific style + * @return the advance (horizontal distance) of this string plus the advance passed in as an argument + * @todo Correctly handling RTL font selection requires scanning the sctring from RTL as well. + * @todo Use bitmap fonts as a fallback if no OpenType font could be found + */ + private int layoutString(List glyphList, char text[], int start, int limit, int layoutFlags, int advance, int style) { /* -* Convert all digits in the string to a '0' before layout to ensure that any glyphs replaced on the fly will all have -* the same positions. Under Windows, Java's "SansSerif" logical font uses the "Arial" font for digits, in which the "1" -* digit is slightly narrower than all other digits. Checking the digitGlyphsReady flag prevents a chicken-and-egg -* problem where the digit glyphs have to be initially cached and the digitGlyphs[] array initialized without replacing -* every digit with '0'. -*/ - if(digitGlyphsReady) - { - for(int index = start; index < limit; index++) - { - if(text[index] >= '0' && text[index] <= '9') - { + * Convert all digits in the string to a '0' before layout to ensure that any glyphs replaced on the fly will all have + * the same positions. Under Windows, Java's "SansSerif" logical font uses the "Arial" font for digits, in which the "1" + * digit is slightly narrower than all other digits. Checking the digitGlyphsReady flag prevents a chicken-and-egg + * problem where the digit glyphs have to be initially cached and the digitGlyphs[] array initialized without replacing + * every digit with '0'. + */ + if (digitGlyphsReady) { + for (int index = start; index < limit; index++) { + if (text[index] >= '0' && text[index] <= '9') { text[index] = '0'; } } } /* Break the string up into segments, where each segment can be displayed using a single font */ - while(start < limit) - { + while (start < limit) { Font font = glyphCache.lookupFont(text, start, limit, style); int next = font.canDisplayUpTo(text, start, limit); /* canDisplayUpTo returns -1 if the entire string range is supported by this font */ - if(next == -1) - { + if (next == -1) { next = limit; } /* -* canDisplayUpTo() returns start if the starting character is not supported at all. In that case, draw just the -* one unsupported character (which will use the font's "missing glyph code"), then retry the lookup again at the -* next character after that. -*/ - if(next == start) - { + * canDisplayUpTo() returns start if the starting character is not supported at all. In that case, draw just the + * one unsupported character (which will use the font's "missing glyph code"), then retry the lookup again at the + * next character after that. + */ + if (next == start) { next++; } @@ -1180,30 +1149,27 @@ public class StringCache } /** -* Allocate new Glyph objects and add them to the glyph list. This sequence of Glyphs represents a portion of the -* string where all glyphs run contiguously in either LTR or RTL and come from the same physical/logical font. -* -* @param glyphList all newly created Glyph objects are added to this list -* @param text the string to layout -* @param start the offset into text at which to start the layout -* @param limit the (offset + length) at which to stop performing the layout -* @param layoutFlags either Font.LAYOUT_RIGHT_TO_LEFT or Font.LAYOUT_LEFT_TO_RIGHT -* @param advance the horizontal advance (i.e. X position) returned by previous call to layoutString() -* @param font the Font used to layout a GlyphVector for the string -* @return the advance (horizontal distance) of this string plus the advance passed in as an argument -* -* @todo need to ajust position of all glyphs if digits are present, by assuming every digit should be 0 in length -*/ - private int layoutFont(List glyphList, char text[], int start, int limit, int layoutFlags, int advance, Font font) - { + * Allocate new Glyph objects and add them to the glyph list. This sequence of Glyphs represents a portion of the + * string where all glyphs run contiguously in either LTR or RTL and come from the same physical/logical font. + * + * @param glyphList all newly created Glyph objects are added to this list + * @param text the string to layout + * @param start the offset into text at which to start the layout + * @param limit the (offset + length) at which to stop performing the layout + * @param layoutFlags either Font.LAYOUT_RIGHT_TO_LEFT or Font.LAYOUT_LEFT_TO_RIGHT + * @param advance the horizontal advance (i.e. X position) returned by previous call to layoutString() + * @param font the Font used to layout a GlyphVector for the string + * @return the advance (horizontal distance) of this string plus the advance passed in as an argument + * @todo need to ajust position of all glyphs if digits are present, by assuming every digit should be 0 in length + */ + private int layoutFont(List glyphList, char text[], int start, int limit, int layoutFlags, int advance, Font font) { /* -* Ensure that all glyphs used by the string are pre-rendered and cached in the texture. Only safe to do so from the -* main thread because cacheGlyphs() can crash LWJGL if it makes OpenGL calls from any other thread. In this case, -* cacheString() will also not insert the entry into the stringCache since it may be incomplete if lookupGlyph() -* returns null for any glyphs not yet stored in the glyph cache. -*/ - if(mainThread == Thread.currentThread()) - { + * Ensure that all glyphs used by the string are pre-rendered and cached in the texture. Only safe to do so from the + * main thread because cacheGlyphs() can crash LWJGL if it makes OpenGL calls from any other thread. In this case, + * cacheString() will also not insert the entry into the stringCache since it may be incomplete if lookupGlyph() + * returns null for any glyphs not yet stored in the glyph cache. + */ + if (mainThread == Thread.currentThread()) { glyphCache.cacheGlyphs(font, text, start, limit, layoutFlags); } @@ -1211,27 +1177,25 @@ public class StringCache GlyphVector vector = glyphCache.layoutGlyphVector(font, text, start, limit, layoutFlags); /* -* Extract all needed information for each glyph from the GlyphVector so it won't be needed for actual rendering. -* Note that initially, glyph.start holds the character index into the stripped text array. But after the entire -* string is layed out, this field will be adjusted on every Glyph object to correctly index the original unstripped -* string. -*/ + * Extract all needed information for each glyph from the GlyphVector so it won't be needed for actual rendering. + * Note that initially, glyph.start holds the character index into the stripped text array. But after the entire + * string is layed out, this field will be adjusted on every Glyph object to correctly index the original unstripped + * string. + */ Glyph glyph = null; int numGlyphs = vector.getNumGlyphs(); - for(int index = 0; index < numGlyphs; index++) - { + for (int index = 0; index < numGlyphs; index++) { Point position = vector.getGlyphPixelBounds(index, null, advance, 0).getLocation(); /* Compute horizontal advance for the previous glyph based on this glyph's position */ - if(glyph != null) - { + if (glyph != null) { glyph.advance = position.x - glyph.x; } /* -* Allocate a new glyph object and add to the glyphList. The glyph.stringIndex here is really like stripIndex but -* it will be corrected later to account for the color codes that have been stripped out. -*/ + * Allocate a new glyph object and add to the glyphList. The glyph.stringIndex here is really like stripIndex but + * it will be corrected later to account for the color codes that have been stripped out. + */ glyph = new Glyph(); glyph.stringIndex = start + vector.getGlyphCharIndex(index); glyph.texture = glyphCache.lookupGlyph(font, vector.getGlyphCode(index)); @@ -1242,8 +1206,7 @@ public class StringCache /* Compute the advance position of the last glyph (or only glyph) since it can't be done by the above loop */ advance += (int) vector.getGlyphPosition(numGlyphs).getX(); - if(glyph != null) - { + if (glyph != null) { glyph.advance = advance - glyph.x; } diff --git a/src/main/java/noppes/npcs/config/legacy/ConfigProp.java b/src/main/java/noppes/npcs/config/legacy/ConfigProp.java index adfac6e06..c232aa75d 100644 --- a/src/main/java/noppes/npcs/config/legacy/ConfigProp.java +++ b/src/main/java/noppes/npcs/config/legacy/ConfigProp.java @@ -8,7 +8,7 @@ import java.lang.annotation.Target; @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.FIELD) public @interface ConfigProp { - String name() default ""; + String name() default ""; - String info() default ""; + String info() default ""; } diff --git a/src/main/java/noppes/npcs/config/legacy/LegacyConfig.java b/src/main/java/noppes/npcs/config/legacy/LegacyConfig.java index 487e4cfd5..44b07f807 100644 --- a/src/main/java/noppes/npcs/config/legacy/LegacyConfig.java +++ b/src/main/java/noppes/npcs/config/legacy/LegacyConfig.java @@ -13,8 +13,8 @@ public class LegacyConfig { public static boolean ScriptingEnabled = true; @ConfigProp(info = "Enables/Disables the use of the the ECMA6 Javascript standard instead of ECMA5.1." + - "\nEnabling this adds many more features to JS in scripts. Only use if on Java 8 or higher." + - "\nNot all ECMA 6 language is supported through this functionality.") + "\nEnabling this adds many more features to JS in scripts. Only use if on Java 8 or higher." + + "\nNot all ECMA 6 language is supported through this functionality.") public static boolean ScriptingECMA6 = false; @ConfigProp(info = "Enables global player event scripts to be used in the scripter. You can still see and write code in the scripter, but these scripts won't run. True by default.") @@ -27,27 +27,27 @@ public class LegacyConfig { public static boolean GlobalNPCScripts = false; @ConfigProp(info = "If scripts are too long (>65535 characters), they normally won't be saved in NBT data.\n" + - "This config adds additional compound tags to scripts that need it, so you can store much larger scripts!\n" + - "Every additional compound tag adds 65535 more characters to your script length limit. Use incrementally, with caution.") + "This config adds additional compound tags to scripts that need it, so you can store much larger scripts!\n" + + "Every additional compound tag adds 65535 more characters to your script length limit. Use incrementally, with caution.") public static int ExpandedScriptLimit = 2; @ConfigProp(info = "Enables if Player Information (WAND-USE) should be printed to CustomNPCs Logs. IF on Server \n" + - "Logs will only be present SERVER-SIDE only in CustomNPCs-latest, -1, -2, and -3") + "Logs will only be present SERVER-SIDE only in CustomNPCs-latest, -1, -2, and -3") public static boolean PlayerLogging = false; @ConfigProp(info = "Enables if Scripting Information should be printed to CustomNPCs Logs. IF on Server \n" + - "Logs will only be present SERVER-SIDE only in CustomNPCs-latest, -1, -2, and -3") + "Logs will only be present SERVER-SIDE only in CustomNPCs-latest, -1, -2, and -3") public static boolean ScriptLogging = false; @ConfigProp(info = "Amount of Messages marked as SPAM [5, 3000]. Lower Number means MORE accurate messages \n" + - "This frequency will determine if the log will print a line with [SPAM] to warn the console.") + "This frequency will determine if the log will print a line with [SPAM] to warn the console.") public static int ScriptFrequency = 20; @ConfigProp(info = "IN Milliseconds 1s = 1000s. If a recent LOG of the same event is SENT within this threshold it will be ignored.") public static int ScriptIgnoreTime = 2000; @ConfigProp(info = "Comma separated list of NPC Script Types that will omit these from the logs,\n" + - "INIT,TICK,INTERACT,DIALOG,DAMAGED,KILLED,ATTACK,TARGET,COLLIDE,KILLS,DIALOG_CLOSE,TIMER") + "INIT,TICK,INTERACT,DIALOG,DAMAGED,KILLED,ATTACK,TARGET,COLLIDE,KILLS,DIALOG_CLOSE,TIMER") public static String ScriptLogIgnoreType = "TICK"; @ConfigProp(info = "Navigation search range for NPCs. Not recommended to increase if you have a slow pc or on a server. Minimum of 16, maximum of 96.") @@ -84,10 +84,10 @@ public class LegacyConfig { public static boolean ScriptOpsOnly = false; @ConfigProp(info = "Comma separated list of player UUIDs that can see and edit scripts. If ScriptsOpsOnly is true,\n" + - "ops and players with these IDs can see and edit scripts. Example:\n" + - "b876ec32-e396-476b-a115-8438d83c67d4,069a79f4-44e9-4726-a5be-fca90e38aaf5,be951074-c7ea-4f02-a725-bf017bc88650\n" + - "Get a player's UUID from a site like NameMC or the API IPlayer.getUniqueID() function!\n" + - "If left empty and ScriptsOpsOnly is false, anyone can see and edit scripts with a scripter.") + "ops and players with these IDs can see and edit scripts. Example:\n" + + "b876ec32-e396-476b-a115-8438d83c67d4,069a79f4-44e9-4726-a5be-fca90e38aaf5,be951074-c7ea-4f02-a725-bf017bc88650\n" + + "Get a player's UUID from a site like NameMC or the API IPlayer.getUniqueID() function!\n" + + "If left empty and ScriptsOpsOnly is false, anyone can see and edit scripts with a scripter.") public static String ScriptDevIDs = ""; @ConfigProp(info = "Default interact line. Leave empty to not have one") @@ -131,10 +131,10 @@ public class LegacyConfig { @ConfigProp(info = "Normal players can use soulstone on friendly npcs") public static boolean SoulStoneFriendlyNPCs = false; - @ConfigProp(info="When set to Minecraft it will use minecrafts font, when Default it will use OpenSans. Can only use fonts installed on your PC") + @ConfigProp(info = "When set to Minecraft it will use minecrafts font, when Default it will use OpenSans. Can only use fonts installed on your PC") public static String FontType = "Default"; - @ConfigProp(info="Font size for custom fonts (doesn't work with minecrafts font)") + @ConfigProp(info = "Font size for custom fonts (doesn't work with minecrafts font)") public static int FontSize = 18; @ConfigProp(info = "Enables Overlay Mixins for Conflicts relating to Optifine or other Skin Renderers. If crashes occur, please disable.") @@ -145,7 +145,7 @@ public class LegacyConfig { public static LegacyLoader Config; - public void init(){ + public void init() { MinecraftServer server = MinecraftServer.getServer(); String dir = ""; if (server != null) { diff --git a/src/main/java/noppes/npcs/config/legacy/LegacyLoader.java b/src/main/java/noppes/npcs/config/legacy/LegacyLoader.java index 87469c391..608824c08 100644 --- a/src/main/java/noppes/npcs/config/legacy/LegacyLoader.java +++ b/src/main/java/noppes/npcs/config/legacy/LegacyLoader.java @@ -8,140 +8,128 @@ import java.util.HashMap; import java.util.LinkedList; public class LegacyLoader { - private boolean updateFile = false; - private File dir; - private String fileName; - private Class configClass; - private LinkedList configFields; + private boolean updateFile = false; + private File dir; + private String fileName; + private Class configClass; + private LinkedList configFields; - public LegacyLoader(Class clss, File dir, String fileName){ - if(!dir.exists()) - dir.mkdir(); - this.dir = dir; - configClass = clss; - configFields = new LinkedList(); - this.fileName = fileName+".cfg"; - Field fields[] = configClass.getDeclaredFields(); - for (Field field : fields) { - if (field.isAnnotationPresent(ConfigProp.class)){ - configFields.add(field); - } - } - } - public void loadConfig() { - try { - File configFile = new File(dir,fileName); - HashMap types = new HashMap(); - for(Field field : configFields){ - ConfigProp prop = (ConfigProp)field.getAnnotation(ConfigProp.class); - types.put(!prop.name().isEmpty()? prop.name() : field.getName(), field); - } - if(configFile.exists()){ - HashMap properties = parseConfig(configFile,types); - for(String prop : properties.keySet()){ - Field field = types.get(prop); - Object obj = properties.get(prop); - if(!obj.equals(field.get(null))){ - field.set(null, obj); - } - } - for(String type : types.keySet()) - if(!properties.containsKey(type)) - updateFile = true; - } - else{ - updateFile = true; - } - } catch (Exception e) { - updateFile = true; - LogWriter.except(e); - } - if(updateFile){ - updateConfig(); - } - updateFile = false; - } - private HashMap parseConfig(File file, HashMap types) throws Exception { - HashMap config = new HashMap(); - BufferedReader reader = new BufferedReader(new FileReader(file)); - String strLine; - while ((strLine = reader.readLine()) != null) { - if(strLine.startsWith("#") || strLine.length() == 0) - continue; - int index = strLine.indexOf("="); - if(index <= 0 || index == strLine.length()){ - updateFile = true; - continue; - } - String name = strLine.substring(0, index); - String prop = strLine.substring(index+1); - if(!types.containsKey(name)){ - updateFile = true; - continue; - } - Object obj = null; - Class class2 = types.get(name).getType(); - if (class2.isAssignableFrom(java.lang.String.class)) - { - obj = prop; + public LegacyLoader(Class clss, File dir, String fileName) { + if (!dir.exists()) + dir.mkdir(); + this.dir = dir; + configClass = clss; + configFields = new LinkedList(); + this.fileName = fileName + ".cfg"; + Field fields[] = configClass.getDeclaredFields(); + for (Field field : fields) { + if (field.isAnnotationPresent(ConfigProp.class)) { + configFields.add(field); } - else if (class2.isAssignableFrom(Integer.TYPE)) - { - obj = Integer.valueOf(Integer.parseInt(prop)); - } - else if (class2.isAssignableFrom(Short.TYPE)) - { - obj = Short.valueOf(Short.parseShort(prop)); - } - else if (class2.isAssignableFrom(Byte.TYPE)) - { - obj = Byte.valueOf(Byte.parseByte(prop)); - } - else if (class2.isAssignableFrom(Boolean.TYPE)) - { - obj = Boolean.valueOf(Boolean.parseBoolean(prop)); - } - else if (class2.isAssignableFrom(Float.TYPE)) - { - obj = Float.valueOf(Float.parseFloat(prop)); - } - else if (class2.isAssignableFrom(Double.TYPE)) - { - obj = Double.valueOf(Double.parseDouble(prop)); - } - if(obj != null) - config.put(name, obj); - } - reader.close(); - return config; - } + } + } - public void updateConfig() { + public void loadConfig() { + try { + File configFile = new File(dir, fileName); + HashMap types = new HashMap(); + for (Field field : configFields) { + ConfigProp prop = (ConfigProp) field.getAnnotation(ConfigProp.class); + types.put(!prop.name().isEmpty() ? prop.name() : field.getName(), field); + } + if (configFile.exists()) { + HashMap properties = parseConfig(configFile, types); + for (String prop : properties.keySet()) { + Field field = types.get(prop); + Object obj = properties.get(prop); + if (!obj.equals(field.get(null))) { + field.set(null, obj); + } + } + for (String type : types.keySet()) + if (!properties.containsKey(type)) + updateFile = true; + } else { + updateFile = true; + } + } catch (Exception e) { + updateFile = true; + LogWriter.except(e); + } + if (updateFile) { + updateConfig(); + } + updateFile = false; + } + + private HashMap parseConfig(File file, HashMap types) throws Exception { + HashMap config = new HashMap(); + BufferedReader reader = new BufferedReader(new FileReader(file)); + String strLine; + while ((strLine = reader.readLine()) != null) { + if (strLine.startsWith("#") || strLine.length() == 0) + continue; + int index = strLine.indexOf("="); + if (index <= 0 || index == strLine.length()) { + updateFile = true; + continue; + } + String name = strLine.substring(0, index); + String prop = strLine.substring(index + 1); + if (!types.containsKey(name)) { + updateFile = true; + continue; + } + Object obj = null; + Class class2 = types.get(name).getType(); + if (class2.isAssignableFrom(java.lang.String.class)) { + obj = prop; + } else if (class2.isAssignableFrom(Integer.TYPE)) { + obj = Integer.valueOf(Integer.parseInt(prop)); + } else if (class2.isAssignableFrom(Short.TYPE)) { + obj = Short.valueOf(Short.parseShort(prop)); + } else if (class2.isAssignableFrom(Byte.TYPE)) { + obj = Byte.valueOf(Byte.parseByte(prop)); + } else if (class2.isAssignableFrom(Boolean.TYPE)) { + obj = Boolean.valueOf(Boolean.parseBoolean(prop)); + } else if (class2.isAssignableFrom(Float.TYPE)) { + obj = Float.valueOf(Float.parseFloat(prop)); + } else if (class2.isAssignableFrom(Double.TYPE)) { + obj = Double.valueOf(Double.parseDouble(prop)); + } + if (obj != null) + config.put(name, obj); + } + reader.close(); + return config; + } + + public void updateConfig() { File file = new File(dir, fileName); - try { - if(!file.exists()) - file.createNewFile(); - BufferedWriter out = new BufferedWriter(new FileWriter(file)); - for(Field field : configFields){ - ConfigProp prop = (ConfigProp)field.getAnnotation(ConfigProp.class); - if(prop.info().length() != 0) - out.write("#"+prop.info() + System.getProperty( "line.separator" )); - String name = !prop.name().isEmpty()? prop.name() : field.getName(); - try { - out.write(name + "=" + field.get(null).toString() + System.getProperty( "line.separator" )); - out.write(System.getProperty( "line.separator" )); - } catch (IllegalArgumentException e) { + try { + if (!file.exists()) + file.createNewFile(); + BufferedWriter out = new BufferedWriter(new FileWriter(file)); + for (Field field : configFields) { + ConfigProp prop = (ConfigProp) field.getAnnotation(ConfigProp.class); + if (prop.info().length() != 0) + out.write("#" + prop.info() + System.getProperty("line.separator")); + String name = !prop.name().isEmpty() ? prop.name() : field.getName(); + try { + out.write(name + "=" + field.get(null).toString() + System.getProperty("line.separator")); + out.write(System.getProperty("line.separator")); + } catch (IllegalArgumentException e) { - e.printStackTrace(); - } catch (IllegalAccessException e) { + e.printStackTrace(); + } catch (IllegalAccessException e) { - e.printStackTrace(); - } - } - out.close(); - } catch (IOException e) { + e.printStackTrace(); + } + } + out.close(); + } catch (IOException e) { - e.printStackTrace(); - } - } + e.printStackTrace(); + } + } } diff --git a/src/main/java/noppes/npcs/constants/AiMutex.java b/src/main/java/noppes/npcs/constants/AiMutex.java index 825d5d157..f9e8f0fc9 100644 --- a/src/main/java/noppes/npcs/constants/AiMutex.java +++ b/src/main/java/noppes/npcs/constants/AiMutex.java @@ -1,7 +1,7 @@ package noppes.npcs.constants; public class AiMutex { - public static byte PASSIVE = 1; //Usually ai which runs ones - public static byte LOOK = 2; //Used for ai which affect rotation - public static byte PATHING = 4; //Used for ai which runs during pathing + public static byte PASSIVE = 1; //Usually ai which runs ones + public static byte LOOK = 2; //Used for ai which affect rotation + public static byte PATHING = 4; //Used for ai which runs during pathing } diff --git a/src/main/java/noppes/npcs/constants/EnumAnimation.java b/src/main/java/noppes/npcs/constants/EnumAnimation.java index f738c9658..550f64dee 100644 --- a/src/main/java/noppes/npcs/constants/EnumAnimation.java +++ b/src/main/java/noppes/npcs/constants/EnumAnimation.java @@ -1,21 +1,21 @@ package noppes.npcs.constants; public enum EnumAnimation { - NONE,SITTING,LYING,SNEAKING,DANCING,AIMING,CRAWLING,HUG,CRY, WAVING, BOW; + NONE, SITTING, LYING, SNEAKING, DANCING, AIMING, CRAWLING, HUG, CRY, WAVING, BOW; + + public int getWalkingAnimation() { + if (this == SNEAKING) + return 1; + if (this == AIMING) + return 2; + if (this == DANCING) + return 3; + if (this == CRAWLING) + return 4; + if (this == HUG) + return 5; + return 0; + } - public int getWalkingAnimation() { - if(this == SNEAKING) - return 1; - if(this == AIMING) - return 2; - if(this == DANCING) - return 3; - if(this == CRAWLING) - return 4; - if(this == HUG) - return 5; - return 0; - } - } diff --git a/src/main/java/noppes/npcs/constants/EnumAnimationPart.java b/src/main/java/noppes/npcs/constants/EnumAnimationPart.java index d0a8fa919..e392d3b60 100644 --- a/src/main/java/noppes/npcs/constants/EnumAnimationPart.java +++ b/src/main/java/noppes/npcs/constants/EnumAnimationPart.java @@ -1,16 +1,17 @@ package noppes.npcs.constants; public enum EnumAnimationPart { - HEAD(0), - BODY(1), - RIGHT_ARM(2), - LEFT_ARM(3), - RIGHT_LEG(4), - LEFT_LEG(5), - FULL_MODEL(6); + HEAD(0), + BODY(1), + RIGHT_ARM(2), + LEFT_ARM(3), + RIGHT_LEG(4), + LEFT_LEG(5), + FULL_MODEL(6); - public int id; - EnumAnimationPart(int id) { - this.id = id; - } + public int id; + + EnumAnimationPart(int id) { + this.id = id; + } } diff --git a/src/main/java/noppes/npcs/constants/EnumAvailabilityDialog.java b/src/main/java/noppes/npcs/constants/EnumAvailabilityDialog.java index 3cd3b03e8..5394a5d49 100644 --- a/src/main/java/noppes/npcs/constants/EnumAvailabilityDialog.java +++ b/src/main/java/noppes/npcs/constants/EnumAvailabilityDialog.java @@ -1,5 +1,5 @@ package noppes.npcs.constants; public enum EnumAvailabilityDialog { - Always,After,Before + Always, After, Before } diff --git a/src/main/java/noppes/npcs/constants/EnumAvailabilityFaction.java b/src/main/java/noppes/npcs/constants/EnumAvailabilityFaction.java index 687afbccf..0c4dd62c5 100644 --- a/src/main/java/noppes/npcs/constants/EnumAvailabilityFaction.java +++ b/src/main/java/noppes/npcs/constants/EnumAvailabilityFaction.java @@ -1,5 +1,5 @@ package noppes.npcs.constants; public enum EnumAvailabilityFaction { - Friendly,Neutral,Hostile + Friendly, Neutral, Hostile } diff --git a/src/main/java/noppes/npcs/constants/EnumAvailabilityFactionType.java b/src/main/java/noppes/npcs/constants/EnumAvailabilityFactionType.java index 2b6f09d20..92de138e5 100644 --- a/src/main/java/noppes/npcs/constants/EnumAvailabilityFactionType.java +++ b/src/main/java/noppes/npcs/constants/EnumAvailabilityFactionType.java @@ -1,5 +1,5 @@ package noppes.npcs.constants; public enum EnumAvailabilityFactionType { - Always,Is,IsNot + Always, Is, IsNot } diff --git a/src/main/java/noppes/npcs/constants/EnumAvailabilityQuest.java b/src/main/java/noppes/npcs/constants/EnumAvailabilityQuest.java index c6f6ff6ec..2fb166819 100644 --- a/src/main/java/noppes/npcs/constants/EnumAvailabilityQuest.java +++ b/src/main/java/noppes/npcs/constants/EnumAvailabilityQuest.java @@ -1,5 +1,5 @@ package noppes.npcs.constants; public enum EnumAvailabilityQuest { - Always,After,Before,Active,NotActive,Acceptable,NotAcceptable + Always, After, Before, Active, NotActive, Acceptable, NotAcceptable } diff --git a/src/main/java/noppes/npcs/constants/EnumBannerVariant.java b/src/main/java/noppes/npcs/constants/EnumBannerVariant.java index 343d14c3f..ed3de2ea6 100644 --- a/src/main/java/noppes/npcs/constants/EnumBannerVariant.java +++ b/src/main/java/noppes/npcs/constants/EnumBannerVariant.java @@ -1,5 +1,5 @@ package noppes.npcs.constants; public enum EnumBannerVariant { - Normal, Curved, Pointy, Triangle, Torn + Normal, Curved, Pointy, Triangle, Torn } diff --git a/src/main/java/noppes/npcs/constants/EnumBardInstrument.java b/src/main/java/noppes/npcs/constants/EnumBardInstrument.java index aaf61d91d..17c4cf50a 100644 --- a/src/main/java/noppes/npcs/constants/EnumBardInstrument.java +++ b/src/main/java/noppes/npcs/constants/EnumBardInstrument.java @@ -1,5 +1,5 @@ package noppes.npcs.constants; public enum EnumBardInstrument { - None,Banjo,Violin,Guitar,Harp, FrenchHorn + None, Banjo, Violin, Guitar, Harp, FrenchHorn } diff --git a/src/main/java/noppes/npcs/constants/EnumCombatPolicy.java b/src/main/java/noppes/npcs/constants/EnumCombatPolicy.java index f94f8faaa..c3f3803f3 100644 --- a/src/main/java/noppes/npcs/constants/EnumCombatPolicy.java +++ b/src/main/java/noppes/npcs/constants/EnumCombatPolicy.java @@ -3,21 +3,22 @@ package noppes.npcs.constants; import java.util.ArrayList; public enum EnumCombatPolicy { - Flip("aicombat.flip"), - Brute("aicombat.brute"), - Stubborn("aicombat.stubborn"), - Tactical("aicombat.tactical"); + Flip("aicombat.flip"), + Brute("aicombat.brute"), + Stubborn("aicombat.stubborn"), + Tactical("aicombat.tactical"); - public final String name; + public final String name; - EnumCombatPolicy(String name){ - this.name = name; - } - public static String[] names(){ - ArrayList list = new ArrayList(); - for(EnumCombatPolicy e : values()) - list.add(e.name); - - return list.toArray(new String[list.size()]); - } + EnumCombatPolicy(String name) { + this.name = name; + } + + public static String[] names() { + ArrayList list = new ArrayList(); + for (EnumCombatPolicy e : values()) + list.add(e.name); + + return list.toArray(new String[list.size()]); + } } diff --git a/src/main/java/noppes/npcs/constants/EnumCompanionJobs.java b/src/main/java/noppes/npcs/constants/EnumCompanionJobs.java index 992735d8e..4e5b1f6ad 100644 --- a/src/main/java/noppes/npcs/constants/EnumCompanionJobs.java +++ b/src/main/java/noppes/npcs/constants/EnumCompanionJobs.java @@ -1,5 +1,5 @@ package noppes.npcs.constants; public enum EnumCompanionJobs { - NONE, SOLDIER, GUARD, FARMER, MINER, SHOP, ROBOT + NONE, SOLDIER, GUARD, FARMER, MINER, SHOP, ROBOT } diff --git a/src/main/java/noppes/npcs/constants/EnumCompanionStage.java b/src/main/java/noppes/npcs/constants/EnumCompanionStage.java index 2de73a186..0f47b8899 100644 --- a/src/main/java/noppes/npcs/constants/EnumCompanionStage.java +++ b/src/main/java/noppes/npcs/constants/EnumCompanionStage.java @@ -1,18 +1,19 @@ package noppes.npcs.constants; public enum EnumCompanionStage { - BABY(0, EnumAnimation.CRAWLING, "companion.baby"), - CHILD(72000, EnumAnimation.NONE, "companion.child"), - TEEN(180000, EnumAnimation.NONE, "companion.teenager"), - ADULT(324000, EnumAnimation.NONE, "companion.adult"), - FULLGROWN(450000, EnumAnimation.NONE, "companion.fullgrown"); - - public int matureAge; - public EnumAnimation animation; - public String name; - EnumCompanionStage(int age, EnumAnimation animation, String name){ - this.matureAge = age; - this.animation = animation; - this.name = name; - } + BABY(0, EnumAnimation.CRAWLING, "companion.baby"), + CHILD(72000, EnumAnimation.NONE, "companion.child"), + TEEN(180000, EnumAnimation.NONE, "companion.teenager"), + ADULT(324000, EnumAnimation.NONE, "companion.adult"), + FULLGROWN(450000, EnumAnimation.NONE, "companion.fullgrown"); + + public int matureAge; + public EnumAnimation animation; + public String name; + + EnumCompanionStage(int age, EnumAnimation animation, String name) { + this.matureAge = age; + this.animation = animation; + this.name = name; + } } diff --git a/src/main/java/noppes/npcs/constants/EnumCompanionTalent.java b/src/main/java/noppes/npcs/constants/EnumCompanionTalent.java index 0cc2f6996..673f7cae1 100644 --- a/src/main/java/noppes/npcs/constants/EnumCompanionTalent.java +++ b/src/main/java/noppes/npcs/constants/EnumCompanionTalent.java @@ -6,12 +6,13 @@ import net.minecraft.item.ItemStack; import noppes.npcs.CustomItems; public enum EnumCompanionTalent { - INVENTORY(CustomItems.satchel), ARMOR(Items.iron_chestplate), - SWORD(Items.diamond_sword), RANGED(Items.bow), - ACROBATS(Items.leather_boots), INTEL(CustomItems.letter); + INVENTORY(CustomItems.satchel), ARMOR(Items.iron_chestplate), + SWORD(Items.diamond_sword), RANGED(Items.bow), + ACROBATS(Items.leather_boots), INTEL(CustomItems.letter); - public ItemStack item; - private EnumCompanionTalent(Item item){ - this.item = new ItemStack(item); - } + public ItemStack item; + + private EnumCompanionTalent(Item item) { + this.item = new ItemStack(item); + } } diff --git a/src/main/java/noppes/npcs/constants/EnumDayTime.java b/src/main/java/noppes/npcs/constants/EnumDayTime.java index 9f319d79a..7540e8172 100644 --- a/src/main/java/noppes/npcs/constants/EnumDayTime.java +++ b/src/main/java/noppes/npcs/constants/EnumDayTime.java @@ -1,5 +1,5 @@ package noppes.npcs.constants; public enum EnumDayTime { - Always,Night,Day + Always, Night, Day } diff --git a/src/main/java/noppes/npcs/constants/EnumDiagramLayout.java b/src/main/java/noppes/npcs/constants/EnumDiagramLayout.java index 0db6f669a..2567d9f94 100644 --- a/src/main/java/noppes/npcs/constants/EnumDiagramLayout.java +++ b/src/main/java/noppes/npcs/constants/EnumDiagramLayout.java @@ -13,23 +13,24 @@ public enum EnumDiagramLayout { CHART("diagram.chart"); private String lang; - EnumDiagramLayout(String langName){ + + EnumDiagramLayout(String langName) { this.lang = langName; } - public String getLang(){ + public String getLang() { return lang; } - public static String[] names(){ + public static String[] names() { ArrayList list = new ArrayList(); - for(EnumDiagramLayout e : values()) + for (EnumDiagramLayout e : values()) list.add(e.lang); return list.toArray(new String[list.size()]); } - public boolean isManual(){ + public boolean isManual() { return this == CIRCULAR_MANUAL || this == SQUARE_MANUAL || this == TREE_MANUAL; } } diff --git a/src/main/java/noppes/npcs/constants/EnumGuiType.java b/src/main/java/noppes/npcs/constants/EnumGuiType.java index c35c619c0..efaa45ec3 100644 --- a/src/main/java/noppes/npcs/constants/EnumGuiType.java +++ b/src/main/java/noppes/npcs/constants/EnumGuiType.java @@ -1,68 +1,66 @@ package noppes.npcs.constants; -import noppes.npcs.scripted.ScriptBlock; - public enum EnumGuiType { - MainMenuDisplay, - MainMenuInv, - MainMenuStats, - ManageFactions, - ManageTags, + MainMenuDisplay, + MainMenuInv, + MainMenuStats, + ManageFactions, + ManageTags, ManageCustomForms, ManageCustomAuras, - ManageAnimations, - MainMenuAdvanced, - MainMenuGlobal, - PlayerBankSmall, - PlayerFollowerHire, - PlayerFollower, - SetupItemGiver, - SetupTrader, - SetupFollower, - PlayerTrader, - PlayerTransporter, - RedstoneBlock, - SetupTransporter, - ManageTransport, - ManageBanks, + ManageAnimations, + MainMenuAdvanced, + MainMenuGlobal, + PlayerBankSmall, + PlayerFollowerHire, + PlayerFollower, + SetupItemGiver, + SetupTrader, + SetupFollower, + PlayerTrader, + PlayerTransporter, + RedstoneBlock, + SetupTransporter, + ManageTransport, + ManageBanks, Cloner, - SetupBank, - ManageDialogs, - ManageQuests, + SetupBank, + ManageDialogs, + ManageQuests, PlayerCarpentryBench, PlayerAnvil, - QuestReward, - ManageRecipes, + QuestReward, + ManageRecipes, ManageEffects, - QuestItem, - NpcRemote, + QuestItem, + NpcRemote, GlobalRemote, - ScriptEvent, - MoneyBag, - MainMenuAI, - MovingPath, - PlayerBankUnlock, - PlayerBankUprade, - PlayerBankLarge, - MobSpawnerAdd, - PlayerMailbox, - PlayerMailman, - Waypoint, - MerchantAdd, - MobSpawnerMounter, - Crate, - NpcDimensions, - Border, - BigSign, - Script, - Companion, - CompanionInv, - CompanionTalent, - CompanionTrader, - ManageLinked, + ScriptEvent, + MoneyBag, + MainMenuAI, + MovingPath, + PlayerBankUnlock, + PlayerBankUprade, + PlayerBankLarge, + MobSpawnerAdd, + PlayerMailbox, + PlayerMailman, + Waypoint, + MerchantAdd, + MobSpawnerMounter, + Crate, + NpcDimensions, + Border, + BigSign, + Script, + Companion, + CompanionInv, + CompanionTalent, + CompanionTrader, + ManageLinked, ManageMagic, - CustomGui, - ScriptItem, - ScriptBlock, + CustomGui, + ScriptItem, + ScriptBlock, Paintbrush; } diff --git a/src/main/java/noppes/npcs/constants/EnumJobType.java b/src/main/java/noppes/npcs/constants/EnumJobType.java index 9c04256c7..dcc34db40 100644 --- a/src/main/java/noppes/npcs/constants/EnumJobType.java +++ b/src/main/java/noppes/npcs/constants/EnumJobType.java @@ -1,5 +1,5 @@ package noppes.npcs.constants; public enum EnumJobType { - None, Bard, Healer, Guard, ItemGiver, Follower, Spawner, Conversation, ChunkLoader + None, Bard, Healer, Guard, ItemGiver, Follower, Spawner, Conversation, ChunkLoader } diff --git a/src/main/java/noppes/npcs/constants/EnumMovingType.java b/src/main/java/noppes/npcs/constants/EnumMovingType.java index da0fae7cc..f8e7cdbf8 100644 --- a/src/main/java/noppes/npcs/constants/EnumMovingType.java +++ b/src/main/java/noppes/npcs/constants/EnumMovingType.java @@ -3,19 +3,21 @@ package noppes.npcs.constants; import java.util.ArrayList; public enum EnumMovingType { - Standing("ai.standing"), - Wandering("ai.wandering"), - MovingPath("ai.movingpath"); - - String name; - EnumMovingType(String name){ - this.name = name; - } - public static String[] names(){ - ArrayList list = new ArrayList(); - for(EnumMovingType e : values()) - list.add(e.name); - - return list.toArray(new String[list.size()]); - } + Standing("ai.standing"), + Wandering("ai.wandering"), + MovingPath("ai.movingpath"); + + String name; + + EnumMovingType(String name) { + this.name = name; + } + + public static String[] names() { + ArrayList list = new ArrayList(); + for (EnumMovingType e : values()) + list.add(e.name); + + return list.toArray(new String[list.size()]); + } } diff --git a/src/main/java/noppes/npcs/constants/EnumNavType.java b/src/main/java/noppes/npcs/constants/EnumNavType.java index bd7eb3808..354c4055a 100644 --- a/src/main/java/noppes/npcs/constants/EnumNavType.java +++ b/src/main/java/noppes/npcs/constants/EnumNavType.java @@ -3,23 +3,25 @@ package noppes.npcs.constants; import java.util.ArrayList; public enum EnumNavType { - Default("aitactics.rush"), - Dodge("aitactics.stagger"), - Surround("aitactics.orbit"), - HitNRun("aitactics.hitandrun"), - Ambush("aitactics.ambush"), - Stalk("aitactics.stalk"), - None("gui.none"); + Default("aitactics.rush"), + Dodge("aitactics.stagger"), + Surround("aitactics.orbit"), + HitNRun("aitactics.hitandrun"), + Ambush("aitactics.ambush"), + Stalk("aitactics.stalk"), + None("gui.none"); - String name; - EnumNavType(String name){ - this.name = name; - } - public static String[] names(){ - ArrayList list = new ArrayList(); - for(EnumNavType e : values()) - list.add(e.name); + String name; - return list.toArray(new String[list.size()]); - } + EnumNavType(String name) { + this.name = name; + } + + public static String[] names() { + ArrayList list = new ArrayList(); + for (EnumNavType e : values()) + list.add(e.name); + + return list.toArray(new String[list.size()]); + } } diff --git a/src/main/java/noppes/npcs/constants/EnumNpcToolMaterial.java b/src/main/java/noppes/npcs/constants/EnumNpcToolMaterial.java index 5a34c8d15..065228b3d 100644 --- a/src/main/java/noppes/npcs/constants/EnumNpcToolMaterial.java +++ b/src/main/java/noppes/npcs/constants/EnumNpcToolMaterial.java @@ -1,7 +1,6 @@ package noppes.npcs.constants; -public enum EnumNpcToolMaterial -{ +public enum EnumNpcToolMaterial { WOOD(0, 59, 2.0F, 0, 15), STONE(1, 131, 4.0F, 1, 5), BRONZE(2, 170, 5.0F, 2, 15), @@ -28,14 +27,17 @@ public enum EnumNpcToolMaterial */ private final float efficiencyOnProperMaterial; - /** Damage versus entities. */ + /** + * Damage versus entities. + */ private final int damageVsEntity; - /** Defines the natural enchantability factor of the material. */ + /** + * Defines the natural enchantability factor of the material. + */ private final int enchantability; - private EnumNpcToolMaterial(int par3, int par4, float par5, int par6, int par7) - { + private EnumNpcToolMaterial(int par3, int par4, float par5, int par6, int par7) { this.harvestLevel = par3; this.maxUses = par4; this.efficiencyOnProperMaterial = par5; @@ -46,40 +48,35 @@ public enum EnumNpcToolMaterial /** * The number of uses this material allows. (wood = 59, stone = 131, iron = 250, diamond = 1561, gold = 32) */ - public int getMaxUses() - { + public int getMaxUses() { return this.maxUses; } /** * The strength of this tool material against blocks which it is effective against. */ - public float getEfficiencyOnProperMaterial() - { + public float getEfficiencyOnProperMaterial() { return this.efficiencyOnProperMaterial; } /** * Damage versus entities. */ - public int getDamageVsEntity() - { + public int getDamageVsEntity() { return this.damageVsEntity; } /** * The level of material this tool can harvest (3 = DIAMOND, 2 = IRON, 1 = STONE, 0 = IRON/GOLD) */ - public int getHarvestLevel() - { + public int getHarvestLevel() { return this.harvestLevel; } /** * Return the natural enchantability factor of the material. */ - public int getEnchantability() - { + public int getEnchantability() { return this.enchantability; } } diff --git a/src/main/java/noppes/npcs/constants/EnumOptionType.java b/src/main/java/noppes/npcs/constants/EnumOptionType.java index 0adc92b9c..2b5fd97cf 100644 --- a/src/main/java/noppes/npcs/constants/EnumOptionType.java +++ b/src/main/java/noppes/npcs/constants/EnumOptionType.java @@ -1,6 +1,6 @@ package noppes.npcs.constants; public enum EnumOptionType { - QuitOption,DialogOption,Disabled,RoleOption,CommandBlock; + QuitOption, DialogOption, Disabled, RoleOption, CommandBlock; } diff --git a/src/main/java/noppes/npcs/constants/EnumParticleType.java b/src/main/java/noppes/npcs/constants/EnumParticleType.java index f80f58a9f..6b5dc8666 100644 --- a/src/main/java/noppes/npcs/constants/EnumParticleType.java +++ b/src/main/java/noppes/npcs/constants/EnumParticleType.java @@ -1,18 +1,19 @@ package noppes.npcs.constants; public enum EnumParticleType { - None(""), - Smoke("smoke"), - Portal("portal"), - Redstone("reddust"), - Lightning("magicCrit"), - LargeSmoke("largesmoke"), - Magic("witchMagic"), - Enchant("enchantmenttable"), - Crit("crit"); - - public String particleName; - EnumParticleType(String name){ - this.particleName = name; - } -} \ No newline at end of file + None(""), + Smoke("smoke"), + Portal("portal"), + Redstone("reddust"), + Lightning("magicCrit"), + LargeSmoke("largesmoke"), + Magic("witchMagic"), + Enchant("enchantmenttable"), + Crit("crit"); + + public String particleName; + + EnumParticleType(String name) { + this.particleName = name; + } +} diff --git a/src/main/java/noppes/npcs/constants/EnumPartyExchange.java b/src/main/java/noppes/npcs/constants/EnumPartyExchange.java index 64792f929..12fae8a53 100644 --- a/src/main/java/noppes/npcs/constants/EnumPartyExchange.java +++ b/src/main/java/noppes/npcs/constants/EnumPartyExchange.java @@ -3,21 +3,22 @@ package noppes.npcs.constants; import java.util.ArrayList; public enum EnumPartyExchange { - Leader("party.leader"), - All("party.all"), - Enrolled("party.enrolled"), + Leader("party.leader"), + All("party.all"), + Enrolled("party.enrolled"), Valid("party.valid"); - public final String name; + public final String name; - EnumPartyExchange(String name){ - this.name = name; - } - public static String[] names(){ - ArrayList list = new ArrayList(); - for(EnumPartyExchange e : values()) - list.add(e.name); + EnumPartyExchange(String name) { + this.name = name; + } - return list.toArray(new String[list.size()]); - } + public static String[] names() { + ArrayList list = new ArrayList(); + for (EnumPartyExchange e : values()) + list.add(e.name); + + return list.toArray(new String[list.size()]); + } } diff --git a/src/main/java/noppes/npcs/constants/EnumPartyObjectives.java b/src/main/java/noppes/npcs/constants/EnumPartyObjectives.java index 4563108a6..ce8f40b33 100644 --- a/src/main/java/noppes/npcs/constants/EnumPartyObjectives.java +++ b/src/main/java/noppes/npcs/constants/EnumPartyObjectives.java @@ -5,18 +5,19 @@ import java.util.ArrayList; public enum EnumPartyObjectives { Shared("party.shared"), All("party.all"), - Leader("party.leader"); + Leader("party.leader"); - public final String name; + public final String name; - EnumPartyObjectives(String name){ - this.name = name; - } - public static String[] names(){ - ArrayList list = new ArrayList(); - for(EnumPartyObjectives e : values()) - list.add(e.name); + EnumPartyObjectives(String name) { + this.name = name; + } - return list.toArray(new String[list.size()]); - } + public static String[] names() { + ArrayList list = new ArrayList(); + for (EnumPartyObjectives e : values()) + list.add(e.name); + + return list.toArray(new String[list.size()]); + } } diff --git a/src/main/java/noppes/npcs/constants/EnumPartyRequirements.java b/src/main/java/noppes/npcs/constants/EnumPartyRequirements.java index b98e587a9..a2977d81b 100644 --- a/src/main/java/noppes/npcs/constants/EnumPartyRequirements.java +++ b/src/main/java/noppes/npcs/constants/EnumPartyRequirements.java @@ -3,20 +3,21 @@ package noppes.npcs.constants; import java.util.ArrayList; public enum EnumPartyRequirements { - Leader("party.leader"), - All("party.all"), - Valid("party.valid"); + Leader("party.leader"), + All("party.all"), + Valid("party.valid"); - public final String name; + public final String name; - EnumPartyRequirements(String name){ - this.name = name; - } - public static String[] names(){ - ArrayList list = new ArrayList(); - for(EnumPartyRequirements e : values()) - list.add(e.name); + EnumPartyRequirements(String name) { + this.name = name; + } - return list.toArray(new String[list.size()]); - } + public static String[] names() { + ArrayList list = new ArrayList(); + for (EnumPartyRequirements e : values()) + list.add(e.name); + + return list.toArray(new String[list.size()]); + } } diff --git a/src/main/java/noppes/npcs/constants/EnumPlayerData.java b/src/main/java/noppes/npcs/constants/EnumPlayerData.java index 9514626b9..ef93f8127 100644 --- a/src/main/java/noppes/npcs/constants/EnumPlayerData.java +++ b/src/main/java/noppes/npcs/constants/EnumPlayerData.java @@ -1,5 +1,5 @@ package noppes.npcs.constants; public enum EnumPlayerData { - Players,Quest,Dialog,Transport,Bank,Factions,Magic + Players, Quest, Dialog, Transport, Bank, Factions, Magic } diff --git a/src/main/java/noppes/npcs/constants/EnumPotionType.java b/src/main/java/noppes/npcs/constants/EnumPotionType.java index 3d669c136..f6d5ad111 100644 --- a/src/main/java/noppes/npcs/constants/EnumPotionType.java +++ b/src/main/java/noppes/npcs/constants/EnumPotionType.java @@ -1,5 +1,5 @@ package noppes.npcs.constants; public enum EnumPotionType { - None, Fire, Poison, Hunger, Weakness, Slowness, Nausea, Blindness, Wither; + None, Fire, Poison, Hunger, Weakness, Slowness, Nausea, Blindness, Wither; } diff --git a/src/main/java/noppes/npcs/constants/EnumProfileSync.java b/src/main/java/noppes/npcs/constants/EnumProfileSync.java index 6702e08f7..9c0937525 100644 --- a/src/main/java/noppes/npcs/constants/EnumProfileSync.java +++ b/src/main/java/noppes/npcs/constants/EnumProfileSync.java @@ -4,18 +4,19 @@ import java.util.ArrayList; public enum EnumProfileSync { Individual("profile.individual"), - Shared("party.shared"); + Shared("party.shared"); - public final String name; + public final String name; - EnumProfileSync(String name){ - this.name = name; - } - public static String[] names(){ - ArrayList list = new ArrayList(); - for(EnumProfileSync e : values()) - list.add(e.name); + EnumProfileSync(String name) { + this.name = name; + } - return list.toArray(new String[list.size()]); - } + public static String[] names() { + ArrayList list = new ArrayList(); + for (EnumProfileSync e : values()) + list.add(e.name); + + return list.toArray(new String[list.size()]); + } } diff --git a/src/main/java/noppes/npcs/constants/EnumQuestCompletion.java b/src/main/java/noppes/npcs/constants/EnumQuestCompletion.java index 3441cc0d2..69ead517d 100644 --- a/src/main/java/noppes/npcs/constants/EnumQuestCompletion.java +++ b/src/main/java/noppes/npcs/constants/EnumQuestCompletion.java @@ -1,5 +1,5 @@ package noppes.npcs.constants; public enum EnumQuestCompletion { - Npc,Instant; + Npc, Instant; } diff --git a/src/main/java/noppes/npcs/constants/EnumQuestRepeat.java b/src/main/java/noppes/npcs/constants/EnumQuestRepeat.java index 7cb4ecac5..706afab01 100644 --- a/src/main/java/noppes/npcs/constants/EnumQuestRepeat.java +++ b/src/main/java/noppes/npcs/constants/EnumQuestRepeat.java @@ -1,5 +1,5 @@ package noppes.npcs.constants; public enum EnumQuestRepeat { - NONE, REPEATABLE, MCDAILY, MCWEEKLY, RLDAILY, RLWEEKLY, MCCUSTOM, RLCUSTOM; + NONE, REPEATABLE, MCDAILY, MCWEEKLY, RLDAILY, RLWEEKLY, MCCUSTOM, RLCUSTOM; } diff --git a/src/main/java/noppes/npcs/constants/EnumQuestType.java b/src/main/java/noppes/npcs/constants/EnumQuestType.java index 315fee0b8..72792ccab 100644 --- a/src/main/java/noppes/npcs/constants/EnumQuestType.java +++ b/src/main/java/noppes/npcs/constants/EnumQuestType.java @@ -1,5 +1,5 @@ package noppes.npcs.constants; public enum EnumQuestType { - Item, Dialog, Kill, Location, AreaKill, Manual; + Item, Dialog, Kill, Location, AreaKill, Manual; } diff --git a/src/main/java/noppes/npcs/constants/EnumScriptType.java b/src/main/java/noppes/npcs/constants/EnumScriptType.java index 170f8c0ff..14ce38f41 100644 --- a/src/main/java/noppes/npcs/constants/EnumScriptType.java +++ b/src/main/java/noppes/npcs/constants/EnumScriptType.java @@ -1,98 +1,98 @@ package noppes.npcs.constants; public enum EnumScriptType { - INIT("init"), - TICK("tick"), - INTERACT("interact"), - DIALOG("dialog"), - DAMAGED("damaged"), - KILLED("killed"), - ATTACK("attack"), - TARGET("target"), - COLLIDE("collide"), - KILLS("kills"), - DIALOG_CLOSE("dialogClose"), - TIMER("timer"), - TARGET_LOST("targetLost"), - PROJECTILE_TICK("projectileTick"), - PROJECTILE_IMPACT("projectileImpact"), + INIT("init"), + TICK("tick"), + INTERACT("interact"), + DIALOG("dialog"), + DAMAGED("damaged"), + KILLED("killed"), + ATTACK("attack"), + TARGET("target"), + COLLIDE("collide"), + KILLS("kills"), + DIALOG_CLOSE("dialogClose"), + TIMER("timer"), + TARGET_LOST("targetLost"), + PROJECTILE_TICK("projectileTick"), + PROJECTILE_IMPACT("projectileImpact"), - ATTACKED("attacked"), - ATTACK_MELEE("meleeAttack"), - ATTACK_SWING("meleeSwing"), + ATTACKED("attacked"), + ATTACK_MELEE("meleeAttack"), + ATTACK_SWING("meleeSwing"), RIGHT_CLICK("rightClick"), - ROLE("role"), - RANGED_CHARGE("rangedCharge"), - RANGED_LAUNCHED("rangedLaunched"), - CLICKED("clicked"), - FALLEN_UPON("fallenUpon"), - RAIN_FILLED("rainFilled"), - BROKEN("broken"), - HARVESTED("harvested"), - EXPLODED("exploded"), - NEIGHBOR_CHANGED("neighborChanged"), - REDSTONE("redstone"), - DOOR_TOGGLE("doorToggle"), - TOSS("toss"), - DROP("drop"), - CONTAINER_OPEN("containerOpen"), - CONTAINER_CLOSED("containerClosed"), - LOGIN("login"), - LOGOUT("logout"), - CHAT("chat"), - DAMAGED_ENTITY("damagedEntity"), - SPAWN("spawn"), - TOSSED("tossed"), - PICKEDUP("pickedUp"), - PICKUP("pickUp"), - LEVEL_UP("levelUp"), - KEY_PRESSED("keyPressed"), - QUEST_EVENT("questEvent"), - QUEST_START("questStart"), - QUEST_COMPLETED("questCompleted"), - QUEST_TURNIN("questTurnIn"), - FACTION_EVENT("factionEvent"), - FACTION_POINTS("factionPoints"), - DIALOG_EVENT("dialogEvent"), - DIALOG_OPEN("dialogOpen"), - DIALOG_OPTION("dialogOption"), - CUSTOM_CHEST_CLOSED("customChestClosed"), - CUSTOM_CHEST_CLICKED("customChestClicked"), - SCRIPT_COMMAND("scriptCommand"), - CUSTOM_GUI_EVENT("customGuiEvent"), - CUSTOM_GUI_CLOSED("customGuiClosed"), - CUSTOM_GUI_BUTTON("customGuiButton"), - CUSTOM_GUI_SLOT("customGuiSlot"), - CUSTOM_GUI_SLOT_CLICKED("customGuiSlotClicked"), - CUSTOM_GUI_SCROLL("customGuiScroll"), - CUSTOM_GUI_TEXTFIELD("customGuiTextfield"), - PICKUP_XP("pickupXP"), - MOUSE_CLICKED("mouseClicked"), - START_USING_ITEM("startItem"), - USING_ITEM("usingItem"), - STOP_USING_ITEM("stopItem"), - FINISH_USING_ITEM("finishItem"), + ROLE("role"), + RANGED_CHARGE("rangedCharge"), + RANGED_LAUNCHED("rangedLaunched"), + CLICKED("clicked"), + FALLEN_UPON("fallenUpon"), + RAIN_FILLED("rainFilled"), + BROKEN("broken"), + HARVESTED("harvested"), + EXPLODED("exploded"), + NEIGHBOR_CHANGED("neighborChanged"), + REDSTONE("redstone"), + DOOR_TOGGLE("doorToggle"), + TOSS("toss"), + DROP("drop"), + CONTAINER_OPEN("containerOpen"), + CONTAINER_CLOSED("containerClosed"), + LOGIN("login"), + LOGOUT("logout"), + CHAT("chat"), + DAMAGED_ENTITY("damagedEntity"), + SPAWN("spawn"), + TOSSED("tossed"), + PICKEDUP("pickedUp"), + PICKUP("pickUp"), + LEVEL_UP("levelUp"), + KEY_PRESSED("keyPressed"), + QUEST_EVENT("questEvent"), + QUEST_START("questStart"), + QUEST_COMPLETED("questCompleted"), + QUEST_TURNIN("questTurnIn"), + FACTION_EVENT("factionEvent"), + FACTION_POINTS("factionPoints"), + DIALOG_EVENT("dialogEvent"), + DIALOG_OPEN("dialogOpen"), + DIALOG_OPTION("dialogOption"), + CUSTOM_CHEST_CLOSED("customChestClosed"), + CUSTOM_CHEST_CLICKED("customChestClicked"), + SCRIPT_COMMAND("scriptCommand"), + CUSTOM_GUI_EVENT("customGuiEvent"), + CUSTOM_GUI_CLOSED("customGuiClosed"), + CUSTOM_GUI_BUTTON("customGuiButton"), + CUSTOM_GUI_SLOT("customGuiSlot"), + CUSTOM_GUI_SLOT_CLICKED("customGuiSlotClicked"), + CUSTOM_GUI_SCROLL("customGuiScroll"), + CUSTOM_GUI_TEXTFIELD("customGuiTextfield"), + PICKUP_XP("pickupXP"), + MOUSE_CLICKED("mouseClicked"), + START_USING_ITEM("startItem"), + USING_ITEM("usingItem"), + STOP_USING_ITEM("stopItem"), + FINISH_USING_ITEM("finishItem"), REPAIR_ITEM("repairItem"), BREAK_ITEM("breakItem"), - USE_HOE("useHoe"), - SLEEP("sleep"), - WAKE_UP("wakeUp"), - FILL_BUCKET("fillBucket"), - BONEMEAL("bonemeal"), - ACHIEVEMENT("achievement"), - FALL("fall"), - JUMP("jump"), - LIGHTNING("lightning"), - PLAYSOUND("playSound"), - RESPAWN("respawn"), - CHANGED_DIM("changedDim"), - BREAK_BLOCK("breakBlock"), - FORGE_EVENT("forgeEvent"), - FORGE_INIT("forgeInit"), - FORGE_ENTITY("forgeEntity"), - FORGE_WORLD("forgeWorld"), - CNPC_NATURAL_SPAWN("onCNPCNaturalSpawn"), - CUSTOM_ITEM_EVENT("customItemEvent"), + USE_HOE("useHoe"), + SLEEP("sleep"), + WAKE_UP("wakeUp"), + FILL_BUCKET("fillBucket"), + BONEMEAL("bonemeal"), + ACHIEVEMENT("achievement"), + FALL("fall"), + JUMP("jump"), + LIGHTNING("lightning"), + PLAYSOUND("playSound"), + RESPAWN("respawn"), + CHANGED_DIM("changedDim"), + BREAK_BLOCK("breakBlock"), + FORGE_EVENT("forgeEvent"), + FORGE_INIT("forgeInit"), + FORGE_ENTITY("forgeEntity"), + FORGE_WORLD("forgeWorld"), + CNPC_NATURAL_SPAWN("onCNPCNaturalSpawn"), + CUSTOM_ITEM_EVENT("customItemEvent"), PARTY_EVENT("partyEvent"), PARTY_QUEST_COMPLETED("partyQuestCompleted"), @@ -116,14 +116,14 @@ public enum EnumScriptType { PROFILE_REMOVE("profileRemove"), PROFILE_CREATE("profileCreate"); - public String function; + public String function; - public static EnumScriptType valueOfIgnoreCase(String channelName) { - channelName = channelName.toUpperCase(); - return valueOf(channelName); - } + public static EnumScriptType valueOfIgnoreCase(String channelName) { + channelName = channelName.toUpperCase(); + return valueOf(channelName); + } - private EnumScriptType(String function) { - this.function = function; - } + private EnumScriptType(String function) { + this.function = function; + } } diff --git a/src/main/java/noppes/npcs/constants/EnumStandingType.java b/src/main/java/noppes/npcs/constants/EnumStandingType.java index 60f3d315c..e32b194b3 100644 --- a/src/main/java/noppes/npcs/constants/EnumStandingType.java +++ b/src/main/java/noppes/npcs/constants/EnumStandingType.java @@ -1,5 +1,5 @@ package noppes.npcs.constants; public enum EnumStandingType { - RotateBody,NoRotation,Stalking,HeadRotation + RotateBody, NoRotation, Stalking, HeadRotation } diff --git a/src/main/java/noppes/npcs/constants/EnumTextureType.java b/src/main/java/noppes/npcs/constants/EnumTextureType.java index db500e2be..154818460 100644 --- a/src/main/java/noppes/npcs/constants/EnumTextureType.java +++ b/src/main/java/noppes/npcs/constants/EnumTextureType.java @@ -7,17 +7,18 @@ public enum EnumTextureType { ITEM("texture.item"); private String lang; - EnumTextureType(String langName){ + + EnumTextureType(String langName) { this.lang = langName; } - public String getLang(){ + public String getLang() { return lang; } - public static String[] names(){ + public static String[] names() { ArrayList list = new ArrayList(); - for(EnumTextureType e : values()) + for (EnumTextureType e : values()) list.add(e.lang); return list.toArray(new String[list.size()]); diff --git a/src/main/java/noppes/npcs/constants/MarkType.java b/src/main/java/noppes/npcs/constants/MarkType.java index 9beb217ec..ac260da63 100644 --- a/src/main/java/noppes/npcs/constants/MarkType.java +++ b/src/main/java/noppes/npcs/constants/MarkType.java @@ -1,11 +1,11 @@ package noppes.npcs.constants; public class MarkType { - public static final int NONE = 0; - public static final int QUESTION = 1; - public static final int EXCLAMATION = 2; - public static final int POINTER = 3; - public static final int SKULL = 4; - public static final int CROSS = 5; - public static final int STAR = 6; + public static final int NONE = 0; + public static final int QUESTION = 1; + public static final int EXCLAMATION = 2; + public static final int POINTER = 3; + public static final int SKULL = 4; + public static final int CROSS = 5; + public static final int STAR = 6; } diff --git a/src/main/java/noppes/npcs/containers/ContainerAnvilRepair.java b/src/main/java/noppes/npcs/containers/ContainerAnvilRepair.java index 4b46ccdfa..5118a27e9 100644 --- a/src/main/java/noppes/npcs/containers/ContainerAnvilRepair.java +++ b/src/main/java/noppes/npcs/containers/ContainerAnvilRepair.java @@ -109,7 +109,7 @@ public class ContainerAnvilRepair extends Container { ItemStack output = null; if (matchingRecipe != null) { - if(!matchingRecipe.availability.isAvailable(player)){ + if (!matchingRecipe.availability.isAvailable(player)) { return; } @@ -159,8 +159,6 @@ public class ContainerAnvilRepair extends Container { } - - // --- Sync Methods --- @Override public void addCraftingToCrafters(ICrafting listener) { @@ -199,15 +197,15 @@ public class ContainerAnvilRepair extends Container { @Override public boolean canInteractWith(EntityPlayer player) { - return player.getDistanceSq((double)this.posX + 0.5D, - (double)this.posY + 0.5D, - (double)this.posZ + 0.5D) <= 64.0D; + return player.getDistanceSq((double) this.posX + 0.5D, + (double) this.posY + 0.5D, + (double) this.posZ + 0.5D) <= 64.0D; } @Override public ItemStack transferStackInSlot(EntityPlayer player, int index) { ItemStack copy = null; - Slot slot = (Slot)this.inventorySlots.get(index); + Slot slot = (Slot) this.inventorySlots.get(index); if (slot != null && slot.getHasStack()) { ItemStack stack = slot.getStack(); copy = stack.copy(); diff --git a/src/main/java/noppes/npcs/containers/ContainerCarpentryBench.java b/src/main/java/noppes/npcs/containers/ContainerCarpentryBench.java index 0df035f26..ef5d3a9b3 100644 --- a/src/main/java/noppes/npcs/containers/ContainerCarpentryBench.java +++ b/src/main/java/noppes/npcs/containers/ContainerCarpentryBench.java @@ -11,8 +11,7 @@ import noppes.npcs.CustomItems; import noppes.npcs.controllers.RecipeController; import noppes.npcs.controllers.data.RecipeCarpentry; -public class ContainerCarpentryBench extends Container -{ +public class ContainerCarpentryBench extends Container { public InventoryCrafting craftMatrix = new InventoryCrafting(this, 4, 4); public IInventory craftResult = new InventoryCraftResult(); private EntityPlayer player; @@ -21,8 +20,7 @@ public class ContainerCarpentryBench extends Container private int posY; private int posZ; - public ContainerCarpentryBench(InventoryPlayer par1InventoryPlayer, World par2World, int par3, int par4, int par5) - { + public ContainerCarpentryBench(InventoryPlayer par1InventoryPlayer, World par2World, int par3, int par4, int par5) { this.worldObj = par2World; this.posX = par3; this.posY = par4; @@ -32,134 +30,108 @@ public class ContainerCarpentryBench extends Container int var6; int var7; - for (var6 = 0; var6 < 4; ++var6) - { - for (var7 = 0; var7 < 4; ++var7) - { + for (var6 = 0; var6 < 4; ++var6) { + for (var7 = 0; var7 < 4; ++var7) { this.addSlotToContainer(new Slot(this.craftMatrix, var7 + var6 * 4, 17 + var7 * 18, 14 + var6 * 18)); } } - for (var6 = 0; var6 < 3; ++var6) - { - for (var7 = 0; var7 < 9; ++var7) - { + for (var6 = 0; var6 < 3; ++var6) { + for (var7 = 0; var7 < 9; ++var7) { this.addSlotToContainer(new Slot(par1InventoryPlayer, var7 + var6 * 9 + 9, 8 + var7 * 18, 98 + var6 * 18)); } } - for (var6 = 0; var6 < 9; ++var6) - { + for (var6 = 0; var6 < 9; ++var6) { this.addSlotToContainer(new Slot(par1InventoryPlayer, var6, 8 + var6 * 18, 156)); } this.onCraftMatrixChanged(this.craftMatrix); } - public int getMetadata(){ - return worldObj.getBlockMetadata(posX, posY, posZ); + public int getMetadata() { + return worldObj.getBlockMetadata(posX, posY, posZ); } /** * Callback for when the crafting matrix is changed. */ @Override - public void onCraftMatrixChanged(IInventory par1IInventory) - { - if(!this.worldObj.isRemote){ - RecipeCarpentry recipe = RecipeController.Instance.findMatchingRecipe(this.craftMatrix); + public void onCraftMatrixChanged(IInventory par1IInventory) { + if (!this.worldObj.isRemote) { + RecipeCarpentry recipe = RecipeController.Instance.findMatchingRecipe(this.craftMatrix); - ItemStack item = null; - if(recipe != null && recipe.availability.isAvailable(player)){ - item = recipe.getCraftingResult(this.craftMatrix); - } + ItemStack item = null; + if (recipe != null && recipe.availability.isAvailable(player)) { + item = recipe.getCraftingResult(this.craftMatrix); + } - this.craftResult.setInventorySlotContents(0, item); - EntityPlayerMP plmp = (EntityPlayerMP) player; - plmp.playerNetServerHandler.sendPacket(new S2FPacketSetSlot(this.windowId, 0, item)); - } + this.craftResult.setInventorySlotContents(0, item); + EntityPlayerMP plmp = (EntityPlayerMP) player; + plmp.playerNetServerHandler.sendPacket(new S2FPacketSetSlot(this.windowId, 0, item)); + } } /** * Callback for when the crafting gui is closed. */ @Override - public void onContainerClosed(EntityPlayer par1EntityPlayer) - { + public void onContainerClosed(EntityPlayer par1EntityPlayer) { super.onContainerClosed(par1EntityPlayer); - if (!this.worldObj.isRemote) - { - for (int var2 = 0; var2 < 16; ++var2) - { + if (!this.worldObj.isRemote) { + for (int var2 = 0; var2 < 16; ++var2) { ItemStack var3 = this.craftMatrix.getStackInSlotOnClosing(var2); - if (var3 != null) - { + if (var3 != null) { par1EntityPlayer.dropPlayerItemWithRandomChoice(var3, false); } } } } + @Override - public boolean canInteractWith(EntityPlayer par1EntityPlayer) - { - return this.worldObj.getBlock(this.posX, this.posY, this.posZ) != CustomItems.carpentyBench ? false : par1EntityPlayer.getDistanceSq((double)this.posX + 0.5D, (double)this.posY + 0.5D, (double)this.posZ + 0.5D) <= 64.0D; + public boolean canInteractWith(EntityPlayer par1EntityPlayer) { + return this.worldObj.getBlock(this.posX, this.posY, this.posZ) != CustomItems.carpentyBench ? false : par1EntityPlayer.getDistanceSq((double) this.posX + 0.5D, (double) this.posY + 0.5D, (double) this.posZ + 0.5D) <= 64.0D; } /** * Called to transfer a stack from one inventory to the other eg. when shift clicking. */ @Override - public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int par1) - { + public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int par1) { ItemStack var2 = null; - Slot var3 = (Slot)this.inventorySlots.get(par1); + Slot var3 = (Slot) this.inventorySlots.get(par1); - if (var3 != null && var3.getHasStack()) - { + if (var3 != null && var3.getHasStack()) { ItemStack var4 = var3.getStack(); var2 = var4.copy(); - if (par1 == 0) - { - if (!this.mergeItemStack(var4, 17, 53, true)) - { + if (par1 == 0) { + if (!this.mergeItemStack(var4, 17, 53, true)) { return null; } var3.onSlotChange(var4, var2); - } - else if (par1 >= 17 && par1 < 44) - { - if (!this.mergeItemStack(var4, 44, 53, false)) - { + } else if (par1 >= 17 && par1 < 44) { + if (!this.mergeItemStack(var4, 44, 53, false)) { return null; } - } - else if (par1 >= 44 && par1 < 53) - { - if (!this.mergeItemStack(var4, 17, 44, false)) - { + } else if (par1 >= 44 && par1 < 53) { + if (!this.mergeItemStack(var4, 17, 44, false)) { return null; } - } - else if (!this.mergeItemStack(var4, 17, 53, false)) - { + } else if (!this.mergeItemStack(var4, 17, 53, false)) { return null; } - if (var4.stackSize == 0) - { - var3.putStack((ItemStack)null); - } - else - { + if (var4.stackSize == 0) { + var3.putStack((ItemStack) null); + } else { var3.onSlotChanged(); } - if (var4.stackSize == var2.stackSize) - { + if (var4.stackSize == var2.stackSize) { return null; } diff --git a/src/main/java/noppes/npcs/containers/ContainerCrate.java b/src/main/java/noppes/npcs/containers/ContainerCrate.java index 0dab25a35..7e0c6f7b1 100644 --- a/src/main/java/noppes/npcs/containers/ContainerCrate.java +++ b/src/main/java/noppes/npcs/containers/ContainerCrate.java @@ -6,83 +6,66 @@ import net.minecraft.inventory.IInventory; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; -public class ContainerCrate extends Container -{ +public class ContainerCrate extends Container { public IInventory lowerChestInventory; public IInventory upperChestInventory; private int numRows; - public ContainerCrate(IInventory par1IInventory, IInventory par2IInventory) - { + public ContainerCrate(IInventory par1IInventory, IInventory par2IInventory) { this.lowerChestInventory = par2IInventory; this.upperChestInventory = par1IInventory; this.numRows = 0; - if(par2IInventory != null && par1IInventory != null){ + if (par2IInventory != null && par1IInventory != null) { this.numRows = par2IInventory.getSizeInventory() / 9; par2IInventory.openInventory(); int i = (this.numRows - 4) * 18; int j; int k; - for (j = 0; j < this.numRows; ++j) - { - for (k = 0; k < 9; ++k) - { + for (j = 0; j < this.numRows; ++j) { + for (k = 0; k < 9; ++k) { this.addSlotToContainer(new Slot(par2IInventory, k + j * 9, 8 + k * 18, 18 + j * 18)); } } - for (j = 0; j < 3; ++j) - { - for (k = 0; k < 9; ++k) - { + for (j = 0; j < 3; ++j) { + for (k = 0; k < 9; ++k) { this.addSlotToContainer(new Slot(par1IInventory, k + j * 9 + 9, 8 + k * 18, 103 + j * 18 + i)); } } - for (j = 0; j < 9; ++j) - { + for (j = 0; j < 9; ++j) { this.addSlotToContainer(new Slot(par1IInventory, j, 8 + j * 18, 161 + i)); } } } - public boolean canInteractWith(EntityPlayer par1EntityPlayer) - { + public boolean canInteractWith(EntityPlayer par1EntityPlayer) { return this.lowerChestInventory.isUseableByPlayer(par1EntityPlayer); } /** * Called when a player shift-clicks on a slot. You must override this or you will crash when someone does that. */ - public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int par2) - { + public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int par2) { ItemStack itemstack = null; - Slot slot = (Slot)this.inventorySlots.get(par2); + Slot slot = (Slot) this.inventorySlots.get(par2); - if (slot != null && slot.getHasStack()) - { + if (slot != null && slot.getHasStack()) { ItemStack itemstack1 = slot.getStack(); itemstack = itemstack1.copy(); - if (par2 < this.numRows * 9) - { - if (!this.mergeItemStack(itemstack1, this.numRows * 9, this.inventorySlots.size(), true)) - { + if (par2 < this.numRows * 9) { + if (!this.mergeItemStack(itemstack1, this.numRows * 9, this.inventorySlots.size(), true)) { return null; } - } - else if (!this.mergeItemStack(itemstack1, 0, this.numRows * 9, false)) - { + } else if (!this.mergeItemStack(itemstack1, 0, this.numRows * 9, false)) { return null; } - if (itemstack1.stackSize == 0) - { - slot.putStack((ItemStack)null); - } - else - { + if (itemstack1.stackSize == 0) { + slot.putStack((ItemStack) null); + } else { slot.onSlotChanged(); } } @@ -93,8 +76,7 @@ public class ContainerCrate extends Container /** * Called when the container is closed. */ - public void onContainerClosed(EntityPlayer par1EntityPlayer) - { + public void onContainerClosed(EntityPlayer par1EntityPlayer) { super.onContainerClosed(par1EntityPlayer); this.lowerChestInventory.closeInventory(); } @@ -102,8 +84,7 @@ public class ContainerCrate extends Container /** * Return this chest container's lower chest inventory. */ - public IInventory getLowerChestInventory() - { + public IInventory getLowerChestInventory() { return this.lowerChestInventory; } } diff --git a/src/main/java/noppes/npcs/containers/ContainerCustomGui.java b/src/main/java/noppes/npcs/containers/ContainerCustomGui.java index 4064f6b30..414b32fbf 100644 --- a/src/main/java/noppes/npcs/containers/ContainerCustomGui.java +++ b/src/main/java/noppes/npcs/containers/ContainerCustomGui.java @@ -29,7 +29,7 @@ public class ContainerCustomGui extends Container { this.customGui = gui; - slotCount=0; + slotCount = 0; inventorySlots.clear(); if (this.customGui.getShowPlayerInv()) { this.addPlayerInventory(player, this.customGui.getPlayerInvX(), this.customGui.getPlayerInvY()); @@ -46,7 +46,7 @@ public class ContainerCustomGui extends Container { public ItemStack transferStackInSlot(EntityPlayer playerIn, int index) { ItemStack itemstack = null; - Slot slot = (Slot)this.inventorySlots.get(index); + Slot slot = (Slot) this.inventorySlots.get(index); if (slot != null && slot.getHasStack()) { ItemStack itemstack1 = slot.getStack(); itemstack = itemstack1.copy(); @@ -82,13 +82,13 @@ public class ContainerCustomGui extends Container { this.playerInvY = y; int row; - for(row = 0; row < 3; ++row) { - for(int col = 0; col < 9; ++col) { + for (row = 0; row < 3; ++row) { + for (int col = 0; col < 9; ++col) { this.addSlotToContainer(new Slot(player.inventory, col + row * 9 + 9, x + col * 18, y + row * 18)); } } - for(row = 0; row < 9; ++row) { + for (row = 0; row < 9; ++row) { this.addSlotToContainer(new Slot(player.inventory, row, x + row * 18, y + 58)); } } @@ -99,15 +99,15 @@ public class ContainerCustomGui extends Container { @Override public ItemStack slotClick(int slotId, int dragType, int clickTypeIn, EntityPlayer player) { - if(slotId < 0) + if (slotId < 0) return super.slotClick(slotId, dragType, clickTypeIn, player); - if(!player.worldObj.isRemote) { + if (!player.worldObj.isRemote) { IItemSlot slot = null; if (this.getSlot(slotId) instanceof CustomGuiSlot) { - slot = ((CustomGuiSlot)this.getSlot(slotId)).slot; + slot = ((CustomGuiSlot) this.getSlot(slotId)).slot; } - if(!EventHooks.onCustomGuiSlotClicked((IPlayer) NpcAPI.Instance().getIEntity(player), ((ContainerCustomGui)player.openContainer).customGui, slotId, slot, dragType, clickTypeIn)) { + if (!EventHooks.onCustomGuiSlotClicked((IPlayer) NpcAPI.Instance().getIEntity(player), ((ContainerCustomGui) player.openContainer).customGui, slotId, slot, dragType, clickTypeIn)) { ItemStack item = super.slotClick(slotId, dragType, clickTypeIn, player); @@ -157,5 +157,7 @@ public class ContainerCustomGui extends Container { // return null; } - public boolean canDragIntoSlot(Slot p_94531_1_) { return true; } + public boolean canDragIntoSlot(Slot p_94531_1_) { + return true; + } } diff --git a/src/main/java/noppes/npcs/containers/ContainerEmpty.java b/src/main/java/noppes/npcs/containers/ContainerEmpty.java index b1cc1d106..adc1c3df7 100644 --- a/src/main/java/noppes/npcs/containers/ContainerEmpty.java +++ b/src/main/java/noppes/npcs/containers/ContainerEmpty.java @@ -3,11 +3,11 @@ package noppes.npcs.containers; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.Container; -public class ContainerEmpty extends Container{ +public class ContainerEmpty extends Container { - @Override - public boolean canInteractWith(EntityPlayer var1) { - return false; - } + @Override + public boolean canInteractWith(EntityPlayer var1) { + return false; + } } diff --git a/src/main/java/noppes/npcs/containers/ContainerMail.java b/src/main/java/noppes/npcs/containers/ContainerMail.java index 27696f5a2..ff7e7b087 100644 --- a/src/main/java/noppes/npcs/containers/ContainerMail.java +++ b/src/main/java/noppes/npcs/containers/ContainerMail.java @@ -9,72 +9,59 @@ import noppes.npcs.controllers.data.PlayerMailData; import java.util.Iterator; -public class ContainerMail extends ContainerNpcInterface{ - public static PlayerMail staticmail = new PlayerMail(); - public PlayerMail mail = new PlayerMail(); - private boolean canEdit, canSend; +public class ContainerMail extends ContainerNpcInterface { + public static PlayerMail staticmail = new PlayerMail(); + public PlayerMail mail = new PlayerMail(); + private boolean canEdit, canSend; - public ContainerMail(EntityPlayer player, boolean canEdit, boolean canSend){ - super(player); - mail = staticmail; - staticmail = new PlayerMail(); - this.canEdit = canEdit; - this.canSend = canSend; - player.inventory.openInventory(); + public ContainerMail(EntityPlayer player, boolean canEdit, boolean canSend) { + super(player); + mail = staticmail; + staticmail = new PlayerMail(); + this.canEdit = canEdit; + this.canSend = canSend; + player.inventory.openInventory(); int k; - for (k = 0; k < 4; ++k) - { - this.addSlotToContainer(new SlotValid(mail, k , 179 + k * 24, 138, canEdit)); + for (k = 0; k < 4; ++k) { + this.addSlotToContainer(new SlotValid(mail, k, 179 + k * 24, 138, canEdit)); } - for (int j = 0; j < 3; ++j) - { - for (k = 0; k < 9; ++k) - { - this.addSlotToContainer(new Slot(player.inventory, k + j * 9 + 9, 28 + k * 18, 175 + j * 18 )); + for (int j = 0; j < 3; ++j) { + for (k = 0; k < 9; ++k) { + this.addSlotToContainer(new Slot(player.inventory, k + j * 9 + 9, 28 + k * 18, 175 + j * 18)); } } - for (int j = 0; j < 9; ++j) - { - this.addSlotToContainer(new Slot(player.inventory, j, 28 + j * 18, 230 )); + for (int j = 0; j < 9; ++j) { + this.addSlotToContainer(new Slot(player.inventory, j, 28 + j * 18, 230)); } } /** * Called when a player shift-clicks on a slot. You must override this or you will crash when someone does that. */ - public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int par2) - { + public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int par2) { ItemStack itemstack = null; - Slot slot = (Slot)this.inventorySlots.get(par2); + Slot slot = (Slot) this.inventorySlots.get(par2); - if (slot != null && slot.getHasStack()) - { + if (slot != null && slot.getHasStack()) { ItemStack itemstack1 = slot.getStack(); itemstack = itemstack1.copy(); - if (par2 < 4) - { - if (!this.mergeItemStack(itemstack1, 4, this.inventorySlots.size(), true)) - { + if (par2 < 4) { + if (!this.mergeItemStack(itemstack1, 4, this.inventorySlots.size(), true)) { return null; } - } - else if (!canEdit || !this.mergeItemStack(itemstack1, 0, 4, false)) - { + } else if (!canEdit || !this.mergeItemStack(itemstack1, 0, 4, false)) { return null; } - if (itemstack1.stackSize == 0) - { - slot.putStack((ItemStack)null); - } - else - { + if (itemstack1.stackSize == 0) { + slot.putStack((ItemStack) null); + } else { slot.onSlotChanged(); } } @@ -86,18 +73,18 @@ public class ContainerMail extends ContainerNpcInterface{ * Called when the container is closed. */ @Override - public void onContainerClosed(EntityPlayer player){ + public void onContainerClosed(EntityPlayer player) { super.onContainerClosed(player); - if(!canEdit && !player.worldObj.isRemote){ - PlayerMailData data = PlayerDataController.Instance.getPlayerData(player).mailData; - Iterator it = data.playermail.iterator(); - while(it.hasNext()){ - PlayerMail mail = it.next(); - if(mail.time == this.mail.time && mail.sender.equals(this.mail.sender)){ - mail.readNBT(this.mail.writeNBT()); - break; - } - } + if (!canEdit && !player.worldObj.isRemote) { + PlayerMailData data = PlayerDataController.Instance.getPlayerData(player).mailData; + Iterator it = data.playermail.iterator(); + while (it.hasNext()) { + PlayerMail mail = it.next(); + if (mail.time == this.mail.time && mail.sender.equals(this.mail.sender)) { + mail.readNBT(this.mail.writeNBT()); + break; + } + } } } diff --git a/src/main/java/noppes/npcs/containers/ContainerManageBanks.java b/src/main/java/noppes/npcs/containers/ContainerManageBanks.java index f95e11378..cceca6255 100644 --- a/src/main/java/noppes/npcs/containers/ContainerManageBanks.java +++ b/src/main/java/noppes/npcs/containers/ContainerManageBanks.java @@ -6,51 +6,46 @@ import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; import noppes.npcs.controllers.data.Bank; -public class ContainerManageBanks extends Container -{ - public Bank bank; - - public ContainerManageBanks(EntityPlayer player) - { - bank = new Bank(); - - for(int i = 0; i < 6; i++) - { - int x = 36; - int y = 38; - y += i * 22; - addSlotToContainer(new Slot(bank.currencyInventory, i, x, y)); - } - - for(int i = 0; i < 6; i++) - { - int x = 142; - int y = 38; - y += i * 22; - addSlotToContainer(new Slot(bank.upgradeInventory, i, x, y)); - } +public class ContainerManageBanks extends Container { + public Bank bank; - for(int j1 = 0; j1 < 9; j1++) - { - addSlotToContainer(new Slot(player.inventory, j1, 8 + j1 * 18, 171)); + public ContainerManageBanks(EntityPlayer player) { + bank = new Bank(); + + for (int i = 0; i < 6; i++) { + int x = 36; + int y = 38; + y += i * 22; + addSlotToContainer(new Slot(bank.currencyInventory, i, x, y)); + } + + for (int i = 0; i < 6; i++) { + int x = 142; + int y = 38; + y += i * 22; + addSlotToContainer(new Slot(bank.upgradeInventory, i, x, y)); + } + + for (int j1 = 0; j1 < 9; j1++) { + addSlotToContainer(new Slot(player.inventory, j1, 8 + j1 * 18, 171)); } } @Override - public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int i){ + public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int i) { return null; } - - @Override - public boolean canInteractWith(EntityPlayer entityplayer) { - return true; - } - public void setBank(Bank bank2) { - for(int i = 0; i< 6; i++){ - bank.currencyInventory.setInventorySlotContents(i, bank2.currencyInventory.getStackInSlot(i)); - bank.upgradeInventory.setInventorySlotContents(i, bank2.upgradeInventory.getStackInSlot(i)); - } - } + @Override + public boolean canInteractWith(EntityPlayer entityplayer) { + return true; + } + + public void setBank(Bank bank2) { + for (int i = 0; i < 6; i++) { + bank.currencyInventory.setInventorySlotContents(i, bank2.currencyInventory.getStackInSlot(i)); + bank.upgradeInventory.setInventorySlotContents(i, bank2.upgradeInventory.getStackInSlot(i)); + } + } } diff --git a/src/main/java/noppes/npcs/containers/ContainerManageRecipes.java b/src/main/java/noppes/npcs/containers/ContainerManageRecipes.java index 88a3c7851..b5af7d900 100644 --- a/src/main/java/noppes/npcs/containers/ContainerManageRecipes.java +++ b/src/main/java/noppes/npcs/containers/ContainerManageRecipes.java @@ -13,72 +13,67 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.Map; -public class ContainerManageRecipes extends Container -{ +public class ContainerManageRecipes extends Container { private InventoryBasic craftingMatrix; public RecipeCarpentry recipe; public RecipeAnvil recipeAnvil; public int size; public int width; private boolean init = false; - public ContainerManageRecipes(EntityPlayer player,int size) - { - this.size = size * size; - this.width = size; - craftingMatrix = new InventoryBasic("crafting", false, this.size + 1); - recipe = new RecipeCarpentry(""); + + public ContainerManageRecipes(EntityPlayer player, int size) { + this.size = size * size; + this.width = size; + craftingMatrix = new InventoryBasic("crafting", false, this.size + 1); + recipe = new RecipeCarpentry(""); recipeAnvil = new RecipeAnvil(); - if(width == 1){ - addSlotToContainer(new Slot(craftingMatrix,0,102,35)); - } - else { - addSlotToContainer(new Slot(craftingMatrix,0,87,61)); + if (width == 1) { + addSlotToContainer(new Slot(craftingMatrix, 0, 102, 35)); + } else { + addSlotToContainer(new Slot(craftingMatrix, 0, 87, 61)); } - for(int i = 0; i < size;i++){ - for(int j = 0; j < size;j++){ - addSlotToContainer(new Slot(craftingMatrix, i * width + j + 1,j*18 + 8, i*18 + 35)); - } - } + for (int i = 0; i < size; i++) { + for (int j = 0; j < size; j++) { + addSlotToContainer(new Slot(craftingMatrix, i * width + j + 1, j * 18 + 8, i * 18 + 35)); + } + } - for(int i1 = 0; i1 < 3; i1++) - { - for(int l1 = 0; l1 < 9; l1++) - { - addSlotToContainer(new Slot(player.inventory, l1 + i1 * 9 + 9, 8 + l1 * 18, 113 + i1 * 18)); + for (int i1 = 0; i1 < 3; i1++) { + for (int l1 = 0; l1 < 9; l1++) { + addSlotToContainer(new Slot(player.inventory, l1 + i1 * 9 + 9, 8 + l1 * 18, 113 + i1 * 18)); } } - for(int j1 = 0; j1 < 9; j1++) - { - addSlotToContainer(new Slot(player.inventory, j1, 8 + j1 * 18, 171)); + for (int j1 = 0; j1 < 9; j1++) { + addSlotToContainer(new Slot(player.inventory, j1, 8 + j1 * 18, 171)); } } @Override - public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int i) - { + public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int i) { return null; } - @Override - public boolean canInteractWith(EntityPlayer entityplayer) { - return true; - } - public void setRecipe(RecipeCarpentry recipe) { - craftingMatrix.setInventorySlotContents(0,recipe.getRecipeOutput()); - for(int i = 0; i < width;i++){ - for(int j = 0; j < width;j++){ - if(j >= recipe.recipeWidth) - craftingMatrix.setInventorySlotContents(i*width + j + 1,null); - else - craftingMatrix.setInventorySlotContents(i*width + j + 1, recipe.getCraftingItem(i * recipe.recipeWidth + j)); - } - } - this.recipe = recipe; - } + @Override + public boolean canInteractWith(EntityPlayer entityplayer) { + return true; + } + + public void setRecipe(RecipeCarpentry recipe) { + craftingMatrix.setInventorySlotContents(0, recipe.getRecipeOutput()); + for (int i = 0; i < width; i++) { + for (int j = 0; j < width; j++) { + if (j >= recipe.recipeWidth) + craftingMatrix.setInventorySlotContents(i * width + j + 1, null); + else + craftingMatrix.setInventorySlotContents(i * width + j + 1, recipe.getCraftingItem(i * recipe.recipeWidth + j)); + } + } + this.recipe = recipe; + } public void setRecipe(RecipeAnvil recipe) { if (recipe.itemToRepair != null) { @@ -99,11 +94,11 @@ public class ContainerManageRecipes extends Container this.recipeAnvil = recipe; } - public void saveRecipe(){ - if(width == 1){ + public void saveRecipe() { + if (width == 1) { ItemStack output = craftingMatrix.getStackInSlot(0); ItemStack repairMat = craftingMatrix.getStackInSlot(1); - if(output == null || repairMat == null){ + if (output == null || repairMat == null) { return; } @@ -117,7 +112,7 @@ public class ContainerManageRecipes extends Container } else { // Carpentry Recipe save (existing code) int nextChar = 0; - char[] chars = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P'}; + char[] chars = {'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P'}; Map nameMapping = new HashMap(); int firstRow = width, lastRow = 0, firstColumn = width, lastColumn = 0; boolean seenRow = false; diff --git a/src/main/java/noppes/npcs/containers/ContainerMerchantAdd.java b/src/main/java/noppes/npcs/containers/ContainerMerchantAdd.java index e1cdeb1f5..6fa9e4d8e 100644 --- a/src/main/java/noppes/npcs/containers/ContainerMerchantAdd.java +++ b/src/main/java/noppes/npcs/containers/ContainerMerchantAdd.java @@ -11,114 +11,97 @@ import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; import net.minecraft.world.World; -public class ContainerMerchantAdd extends ContainerNpcInterface -{ - /** Instance of Merchant. */ +public class ContainerMerchantAdd extends ContainerNpcInterface { + /** + * Instance of Merchant. + */ private IMerchant theMerchant; private InventoryBasic merchantInventory; - /** Instance of World. */ + /** + * Instance of World. + */ private final World theWorld; - public ContainerMerchantAdd(EntityPlayer player, IMerchant par2IMerchant, World par3World) - { - super(player); + public ContainerMerchantAdd(EntityPlayer player, IMerchant par2IMerchant, World par3World) { + super(player); this.theMerchant = par2IMerchant; this.theWorld = par3World; - this.merchantInventory = new InventoryBasic("", false,3); + this.merchantInventory = new InventoryBasic("", false, 3); this.addSlotToContainer(new Slot(this.merchantInventory, 0, 36, 53)); this.addSlotToContainer(new Slot(this.merchantInventory, 1, 62, 53)); this.addSlotToContainer(new Slot(this.merchantInventory, 2, 120, 53)); int i; - for (i = 0; i < 3; ++i) - { - for (int j = 0; j < 9; ++j) - { + for (i = 0; i < 3; ++i) { + for (int j = 0; j < 9; ++j) { this.addSlotToContainer(new Slot(player.inventory, j + i * 9 + 9, 8 + j * 18, 84 + i * 18)); } } - for (i = 0; i < 9; ++i) - { + for (i = 0; i < 9; ++i) { this.addSlotToContainer(new Slot(player.inventory, i, 8 + i * 18, 142)); } } - public void addCraftingToCrafters(ICrafting par1ICrafting) - { + public void addCraftingToCrafters(ICrafting par1ICrafting) { super.addCraftingToCrafters(par1ICrafting); } /** * Looks for changes made in the container, sends them to every listener. */ - public void detectAndSendChanges() - { + public void detectAndSendChanges() { super.detectAndSendChanges(); } /** * Callback for when the crafting matrix is changed. */ - public void onCraftMatrixChanged(IInventory par1IInventory) - { + public void onCraftMatrixChanged(IInventory par1IInventory) { //this.merchantInventory.resetRecipeAndSlots(); super.onCraftMatrixChanged(par1IInventory); } - public void setCurrentRecipeIndex(int par1) - { + public void setCurrentRecipeIndex(int par1) { //this.merchantInventory.setCurrentRecipeIndex(par1); } @SideOnly(Side.CLIENT) - public void updateProgressBar(int par1, int par2) {} + public void updateProgressBar(int par1, int par2) { + } /** * Called when a player shift-clicks on a slot. You must override this or you will crash when someone does that. */ - public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int par2) - { + public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int par2) { ItemStack itemstack = null; - Slot slot = (Slot)this.inventorySlots.get(par2); + Slot slot = (Slot) this.inventorySlots.get(par2); - if (slot != null && slot.getHasStack()) - { + if (slot != null && slot.getHasStack()) { ItemStack itemstack1 = slot.getStack(); itemstack = itemstack1.copy(); - if (par2 != 0 && par2 != 1 && par2 != 2) - { - if (par2 >= 3 && par2 < 30) - { - if (!this.mergeItemStack(itemstack1, 30, 39, false)) - { + if (par2 != 0 && par2 != 1 && par2 != 2) { + if (par2 >= 3 && par2 < 30) { + if (!this.mergeItemStack(itemstack1, 30, 39, false)) { return null; } - } - else if (par2 >= 30 && par2 < 39 && !this.mergeItemStack(itemstack1, 3, 30, false)) - { + } else if (par2 >= 30 && par2 < 39 && !this.mergeItemStack(itemstack1, 3, 30, false)) { return null; } - } - else if (!this.mergeItemStack(itemstack1, 3, 39, false)) - { + } else if (!this.mergeItemStack(itemstack1, 3, 39, false)) { return null; } - if (itemstack1.stackSize == 0) - { - slot.putStack((ItemStack)null); - } - else - { + if (itemstack1.stackSize == 0) { + slot.putStack((ItemStack) null); + } else { slot.onSlotChanged(); } - if (itemstack1.stackSize == itemstack.stackSize) - { + if (itemstack1.stackSize == itemstack.stackSize) { return null; } @@ -131,25 +114,21 @@ public class ContainerMerchantAdd extends ContainerNpcInterface /** * Called when the container is closed. */ - public void onContainerClosed(EntityPlayer par1EntityPlayer) - { + public void onContainerClosed(EntityPlayer par1EntityPlayer) { super.onContainerClosed(par1EntityPlayer); - this.theMerchant.setCustomer((EntityPlayer)null); + this.theMerchant.setCustomer((EntityPlayer) null); super.onContainerClosed(par1EntityPlayer); - if (!this.theWorld.isRemote) - { + if (!this.theWorld.isRemote) { ItemStack itemstack = this.merchantInventory.getStackInSlotOnClosing(0); - if (itemstack != null) - { + if (itemstack != null) { par1EntityPlayer.dropPlayerItemWithRandomChoice(itemstack, false); } itemstack = this.merchantInventory.getStackInSlotOnClosing(1); - if (itemstack != null) - { + if (itemstack != null) { par1EntityPlayer.dropPlayerItemWithRandomChoice(itemstack, false); } } diff --git a/src/main/java/noppes/npcs/containers/ContainerNPCBankInterface.java b/src/main/java/noppes/npcs/containers/ContainerNPCBankInterface.java index 31d8f2fb3..0e7bea6d1 100644 --- a/src/main/java/noppes/npcs/containers/ContainerNPCBankInterface.java +++ b/src/main/java/noppes/npcs/containers/ContainerNPCBankInterface.java @@ -8,97 +8,95 @@ import noppes.npcs.NpcMiscInventory; import noppes.npcs.controllers.PlayerDataController; import noppes.npcs.controllers.data.PlayerBankData; -public class ContainerNPCBankInterface extends ContainerNpcInterface -{ +public class ContainerNPCBankInterface extends ContainerNpcInterface { public InventoryNPC currencyMatrix; private EntityPlayer player; public SlotNpcBankCurrency currency; public int slot = 0; public int bankid; private PlayerBankData data; - public ContainerNPCBankInterface(EntityPlayer player, int slot, int bankid) - { - super(player); - this.bankid = bankid; - this.slot = slot; - this.player = player; - + + public ContainerNPCBankInterface(EntityPlayer player, int slot, int bankid) { + super(player); + this.bankid = bankid; + this.slot = slot; + this.player = player; + currencyMatrix = new InventoryNPC("currency", 1, this); - if(!isAvailable() || canBeUpgraded()){ - currency = new SlotNpcBankCurrency(this, currencyMatrix, 0, 80, 29); - addSlotToContainer(currency); + if (!isAvailable() || canBeUpgraded()) { + currency = new SlotNpcBankCurrency(this, currencyMatrix, 0, 80, 29); + addSlotToContainer(currency); } - + NpcMiscInventory items = new NpcMiscInventory(54); - if(!player.worldObj.isRemote){ - data = PlayerDataController.Instance.getBankData(player,bankid); - items = data.getBankOrDefault(bankid).itemSlots.get(slot); + if (!player.worldObj.isRemote) { + data = PlayerDataController.Instance.getBankData(player, bankid); + items = data.getBankOrDefault(bankid).itemSlots.get(slot); } - + int xOffset = xOffset(); - for (int j = 0; j < getRowNumber(); j++) - { - for (int i1 = 0; i1 < 9; i1++) - { - int id = i1 + j * 9; - addSlotToContainer(new Slot(items, id, 8 + i1 * 18, 17 + xOffset + j * 18)); - } - } - - if(isUpgraded()) - xOffset += 54; - for (int k = 0; k < 3; k++) - { - for (int j1 = 0; j1 < 9; j1++) - { - addSlotToContainer(new Slot(player.inventory, j1 + k * 9 + 9, 8 + j1 * 18, 86 + xOffset + k * 18)); + for (int j = 0; j < getRowNumber(); j++) { + for (int i1 = 0; i1 < 9; i1++) { + int id = i1 + j * 9; + addSlotToContainer(new Slot(items, id, 8 + i1 * 18, 17 + xOffset + j * 18)); } } - for (int l = 0; l < 9; l++) - { - addSlotToContainer(new Slot(player.inventory, l, 8 + l * 18, 144 + xOffset )); + if (isUpgraded()) + xOffset += 54; + for (int k = 0; k < 3; k++) { + for (int j1 = 0; j1 < 9; j1++) { + addSlotToContainer(new Slot(player.inventory, j1 + k * 9 + 9, 8 + j1 * 18, 86 + xOffset + k * 18)); + } + } + + for (int l = 0; l < 9; l++) { + addSlotToContainer(new Slot(player.inventory, l, 8 + l * 18, 144 + xOffset)); } } + public int getRowNumber() { - return 0; - } - public int xOffset(){ - return 0; - } - @Override - public void onCraftMatrixChanged(IInventory inv){ - - } - public boolean isAvailable(){ - return false; - } - public boolean isUpgraded(){ - return false; - } - public boolean canBeUpgraded(){ - return false; + return 0; } - public synchronized void setCurrency(ItemStack item){ + public int xOffset() { + return 0; + } + + @Override + public void onCraftMatrixChanged(IInventory inv) { + + } + + public boolean isAvailable() { + return false; + } + + public boolean isUpgraded() { + return false; + } + + public boolean canBeUpgraded() { + return false; + } + + public synchronized void setCurrency(ItemStack item) { currency.item = item; } @Override - public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int i) - { - return null; - } + public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int i) { + return null; + } + @Override - public void onContainerClosed(EntityPlayer entityplayer) - { + public void onContainerClosed(EntityPlayer entityplayer) { super.onContainerClosed(entityplayer); - if (!entityplayer.worldObj.isRemote){ + if (!entityplayer.worldObj.isRemote) { ItemStack var3 = this.currencyMatrix.getStackInSlot(0); currencyMatrix.setInventorySlotContents(0, null); - if (var3 != null) - { - entityplayer.dropPlayerItemWithRandomChoice(var3, false); + if (var3 != null) { + entityplayer.dropPlayerItemWithRandomChoice(var3, false); } } } diff --git a/src/main/java/noppes/npcs/containers/ContainerNPCBankLarge.java b/src/main/java/noppes/npcs/containers/ContainerNPCBankLarge.java index b3abfd21c..67a517cb2 100644 --- a/src/main/java/noppes/npcs/containers/ContainerNPCBankLarge.java +++ b/src/main/java/noppes/npcs/containers/ContainerNPCBankLarge.java @@ -2,21 +2,21 @@ package noppes.npcs.containers; import net.minecraft.entity.player.EntityPlayer; -public class ContainerNPCBankLarge extends ContainerNPCBankInterface -{ +public class ContainerNPCBankLarge extends ContainerNPCBankInterface { - public ContainerNPCBankLarge(EntityPlayer player, int slot, int bankid) - { - super(player,slot,bankid); + public ContainerNPCBankLarge(EntityPlayer player, int slot, int bankid) { + super(player, slot, bankid); } - - public boolean isUpgraded(){ - return true; + + public boolean isUpgraded() { + return true; } - public boolean isAvailable(){ - return true; + + public boolean isAvailable() { + return true; } + public int getRowNumber() { - return 6; - } + return 6; + } } diff --git a/src/main/java/noppes/npcs/containers/ContainerNPCBankSmall.java b/src/main/java/noppes/npcs/containers/ContainerNPCBankSmall.java index 9d4620fcc..ea835cd03 100644 --- a/src/main/java/noppes/npcs/containers/ContainerNPCBankSmall.java +++ b/src/main/java/noppes/npcs/containers/ContainerNPCBankSmall.java @@ -2,17 +2,17 @@ package noppes.npcs.containers; import net.minecraft.entity.player.EntityPlayer; -public class ContainerNPCBankSmall extends ContainerNPCBankInterface -{ +public class ContainerNPCBankSmall extends ContainerNPCBankInterface { - public ContainerNPCBankSmall(EntityPlayer player, int slot, int bankid) - { - super(player,slot,bankid); + public ContainerNPCBankSmall(EntityPlayer player, int slot, int bankid) { + super(player, slot, bankid); } - public boolean isAvailable(){ - return true; + + public boolean isAvailable() { + return true; } + public int getRowNumber() { - return 3; - } + return 3; + } } diff --git a/src/main/java/noppes/npcs/containers/ContainerNPCBankUnlock.java b/src/main/java/noppes/npcs/containers/ContainerNPCBankUnlock.java index ee7a09e90..eecbb422f 100644 --- a/src/main/java/noppes/npcs/containers/ContainerNPCBankUnlock.java +++ b/src/main/java/noppes/npcs/containers/ContainerNPCBankUnlock.java @@ -2,10 +2,8 @@ package noppes.npcs.containers; import net.minecraft.entity.player.EntityPlayer; -public class ContainerNPCBankUnlock extends ContainerNPCBankInterface -{ - public ContainerNPCBankUnlock(EntityPlayer player, int slot, int bankid) - { - super(player,slot,bankid); - } +public class ContainerNPCBankUnlock extends ContainerNPCBankInterface { + public ContainerNPCBankUnlock(EntityPlayer player, int slot, int bankid) { + super(player, slot, bankid); + } } diff --git a/src/main/java/noppes/npcs/containers/ContainerNPCBankUpgrade.java b/src/main/java/noppes/npcs/containers/ContainerNPCBankUpgrade.java index ae46c9d89..069731ab1 100644 --- a/src/main/java/noppes/npcs/containers/ContainerNPCBankUpgrade.java +++ b/src/main/java/noppes/npcs/containers/ContainerNPCBankUpgrade.java @@ -2,22 +2,24 @@ package noppes.npcs.containers; import net.minecraft.entity.player.EntityPlayer; -public class ContainerNPCBankUpgrade extends ContainerNPCBankInterface -{ - public ContainerNPCBankUpgrade(EntityPlayer player, int slot, int bankid) - { - super(player,slot,bankid); +public class ContainerNPCBankUpgrade extends ContainerNPCBankInterface { + public ContainerNPCBankUpgrade(EntityPlayer player, int slot, int bankid) { + super(player, slot, bankid); } - public boolean isAvailable(){ - return true; + + public boolean isAvailable() { + return true; } - public boolean canBeUpgraded(){ - return true; + + public boolean canBeUpgraded() { + return true; } - public int xOffset(){ - return 54; + + public int xOffset() { + return 54; } + public int getRowNumber() { - return 3; - } + return 3; + } } diff --git a/src/main/java/noppes/npcs/containers/ContainerNPCCompanion.java b/src/main/java/noppes/npcs/containers/ContainerNPCCompanion.java index aebbd004a..337ee4b6d 100644 --- a/src/main/java/noppes/npcs/containers/ContainerNPCCompanion.java +++ b/src/main/java/noppes/npcs/containers/ContainerNPCCompanion.java @@ -7,46 +7,46 @@ import noppes.npcs.constants.EnumCompanionTalent; import noppes.npcs.entity.EntityNPCInterface; import noppes.npcs.roles.RoleCompanion; -public class ContainerNPCCompanion extends ContainerNpcInterface{ +public class ContainerNPCCompanion extends ContainerNpcInterface { public InventoryNPC currencyMatrix; - public RoleCompanion role; + public RoleCompanion role; - public ContainerNPCCompanion(EntityNPCInterface npc,EntityPlayer player){ - super(player); - role = (RoleCompanion) npc.roleInterface; - for (int k = 0; k < 3; k++){ - for (int j1 = 0; j1 < 9; j1++){ - addSlotToContainer(new Slot(player.inventory, j1 + k * 9 + 9, 6 + j1 * 18, 87 + k * 18)); + public ContainerNPCCompanion(EntityNPCInterface npc, EntityPlayer player) { + super(player); + role = (RoleCompanion) npc.roleInterface; + for (int k = 0; k < 3; k++) { + for (int j1 = 0; j1 < 9; j1++) { + addSlotToContainer(new Slot(player.inventory, j1 + k * 9 + 9, 6 + j1 * 18, 87 + k * 18)); } } - for (int l = 0; l < 9; l++){ - addSlotToContainer(new Slot(player.inventory, l, 6 + l * 18, 145)); + for (int l = 0; l < 9; l++) { + addSlotToContainer(new Slot(player.inventory, l, 6 + l * 18, 145)); + } + + if (role.talents.containsKey(EnumCompanionTalent.INVENTORY)) { + int size = (role.getTalentLevel(EnumCompanionTalent.INVENTORY) + 1) * 2; + for (int i = 0; i < size; i++) { + addSlotToContainer(new Slot(role.inventory, i, 114 + i % 3 * 18, 8 + i / 3 * 18)); + } + } + if (role.getTalentLevel(EnumCompanionTalent.ARMOR) > 0) { + for (int l = 0; l < 4; l++) { + addSlotToContainer(new SlotCompanionArmor(role, npc.inventory, l, 6, 8 + l * 18, l)); + } + } + if (role.getTalentLevel(EnumCompanionTalent.SWORD) > 0) { + addSlotToContainer(new SlotCompanionWeapon(role, npc.inventory, 4, 79, 17)); } - - if(role.talents.containsKey(EnumCompanionTalent.INVENTORY)){ - int size = (role.getTalentLevel(EnumCompanionTalent.INVENTORY) + 1) * 2; - for(int i = 0; i < size; i++){ - addSlotToContainer(new Slot(role.inventory, i, 114 + i % 3 * 18, 8 + i / 3 * 18)); - } - } - if(role.getTalentLevel(EnumCompanionTalent.ARMOR) > 0){ - for(int l = 0; l < 4; l++){ - addSlotToContainer(new SlotCompanionArmor(role, npc.inventory, l, 6, 8 + l * 18,l)); - } - } - if(role.getTalentLevel(EnumCompanionTalent.SWORD) > 0){ - addSlotToContainer(new SlotCompanionWeapon(role, npc.inventory, 4, 79, 17)); - } } @Override - public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int i){ + public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int i) { return null; } - + @Override - public void onContainerClosed(EntityPlayer entityplayer){ + public void onContainerClosed(EntityPlayer entityplayer) { super.onContainerClosed(entityplayer); role.setStats(); } diff --git a/src/main/java/noppes/npcs/containers/ContainerNPCFollower.java b/src/main/java/noppes/npcs/containers/ContainerNPCFollower.java index 8e0a1168c..dedeed3c1 100644 --- a/src/main/java/noppes/npcs/containers/ContainerNPCFollower.java +++ b/src/main/java/noppes/npcs/containers/ContainerNPCFollower.java @@ -6,40 +6,35 @@ import net.minecraft.item.ItemStack; import noppes.npcs.entity.EntityNPCInterface; import noppes.npcs.roles.RoleFollower; -public class ContainerNPCFollower extends ContainerNpcInterface -{ +public class ContainerNPCFollower extends ContainerNpcInterface { public InventoryNPC currencyMatrix; - public RoleFollower role; + public RoleFollower role; - public ContainerNPCFollower(EntityNPCInterface npc,EntityPlayer player) - { - super(player); + public ContainerNPCFollower(EntityNPCInterface npc, EntityPlayer player) { + super(player); role = (RoleFollower) npc.roleInterface; - currencyMatrix = new InventoryNPC("currency", 1,this); - addSlotToContainer(new SlotNpcMercenaryCurrency(role,currencyMatrix, 0, 26, 9)); - - for(int j1 = 0; j1 < 9; j1++) - { - addSlotToContainer(new Slot(player.inventory, j1, 8 + j1 * 18, 142)); + currencyMatrix = new InventoryNPC("currency", 1, this); + addSlotToContainer(new SlotNpcMercenaryCurrency(role, currencyMatrix, 0, 26, 9)); + + for (int j1 = 0; j1 < 9; j1++) { + addSlotToContainer(new Slot(player.inventory, j1, 8 + j1 * 18, 142)); } } @Override - public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int i) - { + public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int i) { return null; } + @Override - public void onContainerClosed(EntityPlayer entityplayer) - { + public void onContainerClosed(EntityPlayer entityplayer) { super.onContainerClosed(entityplayer); - if (!entityplayer.worldObj.isRemote){ - ItemStack itemstack = currencyMatrix.getStackInSlotOnClosing(0); - if(itemstack != null && !entityplayer.worldObj.isRemote) - { - entityplayer.entityDropItem(itemstack,0f); - } + if (!entityplayer.worldObj.isRemote) { + ItemStack itemstack = currencyMatrix.getStackInSlotOnClosing(0); + if (itemstack != null && !entityplayer.worldObj.isRemote) { + entityplayer.entityDropItem(itemstack, 0f); + } } } diff --git a/src/main/java/noppes/npcs/containers/ContainerNPCFollowerHire.java b/src/main/java/noppes/npcs/containers/ContainerNPCFollowerHire.java index b623a28d5..bb454877a 100644 --- a/src/main/java/noppes/npcs/containers/ContainerNPCFollowerHire.java +++ b/src/main/java/noppes/npcs/containers/ContainerNPCFollowerHire.java @@ -1,6 +1,6 @@ // Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov. // Jad home page: http://www.kpdus.com/jad.html -// Decompiler options: packimports(3) braces deadcode fieldsfirst +// Decompiler options: packimports(3) braces deadcode fieldsfirst package noppes.npcs.containers; @@ -12,54 +12,47 @@ import noppes.npcs.entity.EntityNPCInterface; import noppes.npcs.roles.RoleFollower; // Referenced classes of package net.minecraft.src: -// Container, InventoryCrafting, InventoryCraftResult, SlotCrafting, -// InventoryPlayer, Slot, CraftingManager, IInventory, +// Container, InventoryCrafting, InventoryCraftResult, SlotCrafting, +// InventoryPlayer, Slot, CraftingManager, IInventory, // World, EntityPlayer, Block, ItemStack -public class ContainerNPCFollowerHire extends ContainerNpcInterface -{ +public class ContainerNPCFollowerHire extends ContainerNpcInterface { public InventoryBasic currencyMatrix; - public RoleFollower role; + public RoleFollower role; - public ContainerNPCFollowerHire(EntityNPCInterface npc,EntityPlayer player) - { - super(player); + public ContainerNPCFollowerHire(EntityNPCInterface npc, EntityPlayer player) { + super(player); role = (RoleFollower) npc.roleInterface; - currencyMatrix = new InventoryBasic("currency", false, 1); - addSlotToContainer(new SlotNpcMercenaryCurrency(role,currencyMatrix, 0, 44, 35)); - - for(int i1 = 0; i1 < 3; i1++) - { - for(int l1 = 0; l1 < 9; l1++) - { - addSlotToContainer(new Slot(player.inventory, l1 + i1 * 9 + 9, 8 + l1 * 18, 84 + i1 * 18)); + currencyMatrix = new InventoryBasic("currency", false, 1); + addSlotToContainer(new SlotNpcMercenaryCurrency(role, currencyMatrix, 0, 44, 35)); + + for (int i1 = 0; i1 < 3; i1++) { + for (int l1 = 0; l1 < 9; l1++) { + addSlotToContainer(new Slot(player.inventory, l1 + i1 * 9 + 9, 8 + l1 * 18, 84 + i1 * 18)); } } - for(int j1 = 0; j1 < 9; j1++) - { - addSlotToContainer(new Slot(player.inventory, j1, 8 + j1 * 18, 142)); + for (int j1 = 0; j1 < 9; j1++) { + addSlotToContainer(new Slot(player.inventory, j1, 8 + j1 * 18, 142)); } } @Override - public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int i) - { + public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int i) { return null; } + @Override - public void onContainerClosed(EntityPlayer entityplayer) - { + public void onContainerClosed(EntityPlayer entityplayer) { super.onContainerClosed(entityplayer); - if (!entityplayer.worldObj.isRemote){ - ItemStack itemstack = currencyMatrix.getStackInSlotOnClosing(0); - if(itemstack != null && !entityplayer.worldObj.isRemote) - { - entityplayer.entityDropItem(itemstack,0f); - } + if (!entityplayer.worldObj.isRemote) { + ItemStack itemstack = currencyMatrix.getStackInSlotOnClosing(0); + if (itemstack != null && !entityplayer.worldObj.isRemote) { + entityplayer.entityDropItem(itemstack, 0f); + } } } } diff --git a/src/main/java/noppes/npcs/containers/ContainerNPCFollowerSetup.java b/src/main/java/noppes/npcs/containers/ContainerNPCFollowerSetup.java index 3633bd8b1..40c5785bc 100644 --- a/src/main/java/noppes/npcs/containers/ContainerNPCFollowerSetup.java +++ b/src/main/java/noppes/npcs/containers/ContainerNPCFollowerSetup.java @@ -7,85 +7,65 @@ import net.minecraft.item.ItemStack; import noppes.npcs.entity.EntityNPCInterface; import noppes.npcs.roles.RoleFollower; -public class ContainerNPCFollowerSetup extends Container -{ - private RoleFollower role; +public class ContainerNPCFollowerSetup extends Container { + private RoleFollower role; - public ContainerNPCFollowerSetup(EntityNPCInterface npc,EntityPlayer player) - { + public ContainerNPCFollowerSetup(EntityNPCInterface npc, EntityPlayer player) { role = (RoleFollower) npc.roleInterface; - - for(int i1 = 0; i1 < 3; i1++) - addSlotToContainer(new Slot(role.inventory, i1, 44, 39 + i1 * 25)); - - for(int i1 = 0; i1 < 3; i1++) - { - for(int l1 = 0; l1 < 9; l1++) - { - addSlotToContainer(new Slot(player.inventory, l1 + i1 * 9 + 9, 8 + l1 * 18, 113 + i1 * 18)); + + for (int i1 = 0; i1 < 3; i1++) + addSlotToContainer(new Slot(role.inventory, i1, 44, 39 + i1 * 25)); + + for (int i1 = 0; i1 < 3; i1++) { + for (int l1 = 0; l1 < 9; l1++) { + addSlotToContainer(new Slot(player.inventory, l1 + i1 * 9 + 9, 8 + l1 * 18, 113 + i1 * 18)); } } - for(int j1 = 0; j1 < 9; j1++) - { - addSlotToContainer(new Slot(player.inventory, j1, 8 + j1 * 18, 171)); + for (int j1 = 0; j1 < 9; j1++) { + addSlotToContainer(new Slot(player.inventory, j1, 8 + j1 * 18, 171)); } } @Override - public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int i) - { + public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int i) { ItemStack itemstack = null; - Slot slot = (Slot)inventorySlots.get(i); - if(slot != null && slot.getHasStack()) - { + Slot slot = (Slot) inventorySlots.get(i); + if (slot != null && slot.getHasStack()) { ItemStack itemstack1 = slot.getStack(); itemstack = itemstack1.copy(); - if(i >= 0 && i < 3) - { - if(!mergeItemStack(itemstack1, 3, 38, true)) - { + if (i >= 0 && i < 3) { + if (!mergeItemStack(itemstack1, 3, 38, true)) { return null; } - } else - if(i >= 3 && i < 30) - { - if(!mergeItemStack(itemstack1, 30, 38, false)) - { + } else if (i >= 3 && i < 30) { + if (!mergeItemStack(itemstack1, 30, 38, false)) { return null; } - } else - if(i >= 30 && i < 38) - { - if(!mergeItemStack(itemstack1, 3, 29, false)) - { + } else if (i >= 30 && i < 38) { + if (!mergeItemStack(itemstack1, 3, 29, false)) { return null; } - } else - if(!mergeItemStack(itemstack1, 3, 38, false)) - { + } else if (!mergeItemStack(itemstack1, 3, 38, false)) { return null; } - if(itemstack1.stackSize == 0) - { + if (itemstack1.stackSize == 0) { slot.putStack(null); - } else - { + } else { slot.onSlotChanged(); } - if(itemstack1.stackSize != itemstack.stackSize) - { + if (itemstack1.stackSize != itemstack.stackSize) { slot.onPickupFromSlot(par1EntityPlayer, itemstack1); - } else - { + } else { return null; } } return itemstack; } - @Override - public boolean canInteractWith(EntityPlayer entityplayer) { - return true; - } + + @Override + public boolean canInteractWith(EntityPlayer entityplayer) { + return true; + } } diff --git a/src/main/java/noppes/npcs/containers/ContainerNPCInv.java b/src/main/java/noppes/npcs/containers/ContainerNPCInv.java index 00186b177..844861a30 100644 --- a/src/main/java/noppes/npcs/containers/ContainerNPCInv.java +++ b/src/main/java/noppes/npcs/containers/ContainerNPCInv.java @@ -6,40 +6,40 @@ import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; import noppes.npcs.entity.EntityNPCInterface; -public class ContainerNPCInv extends Container{ - public ContainerNPCInv(EntityNPCInterface npc,EntityPlayer player){ - for(int l = 0; l < 4; l++){ - addSlotToContainer(new SlotNPCArmor(npc.inventory, l, 9, 22 + l * 18,l)); +public class ContainerNPCInv extends Container { + public ContainerNPCInv(EntityNPCInterface npc, EntityPlayer player) { + for (int l = 0; l < 4; l++) { + addSlotToContainer(new SlotNPCArmor(npc.inventory, l, 9, 22 + l * 18, l)); } addSlotToContainer(new Slot(npc.inventory, 4, 81, 22)); addSlotToContainer(new Slot(npc.inventory, 5, 81, 40)); addSlotToContainer(new Slot(npc.inventory, 6, 81, 58)); - for(int c = 0; c < 4; c++) { + for (int c = 0; c < 4; c++) { for (int r = 0; r < 9; r++) { - addSlotToContainer(new Slot(npc.inventory, c*9 + r + 7, 191 + (c%2)*90, 16 + r * 21)); + addSlotToContainer(new Slot(npc.inventory, c * 9 + r + 7, 191 + (c % 2) * 90, 16 + r * 21)); } } - for(int i1 = 0; i1 < 3; i1++){ - for(int l1 = 0; l1 < 9; l1++){ - addSlotToContainer(new Slot(player.inventory, l1 + i1 * 9 + 9, l1 * 18 + 8, 113 + i1 * 18)); + for (int i1 = 0; i1 < 3; i1++) { + for (int l1 = 0; l1 < 9; l1++) { + addSlotToContainer(new Slot(player.inventory, l1 + i1 * 9 + 9, l1 * 18 + 8, 113 + i1 * 18)); } } - for(int j1 = 0; j1 < 9; j1++){ - addSlotToContainer(new Slot(player.inventory, j1, j1 * 18 + 8, 171)); + for (int j1 = 0; j1 < 9; j1++) { + addSlotToContainer(new Slot(player.inventory, j1, j1 * 18 + 8, 171)); } } @Override - public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int i){ + public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int i) { return null; } - - @Override - public boolean canInteractWith(EntityPlayer entityplayer) { - return true; - } + + @Override + public boolean canInteractWith(EntityPlayer entityplayer) { + return true; + } } diff --git a/src/main/java/noppes/npcs/containers/ContainerNPCTrader.java b/src/main/java/noppes/npcs/containers/ContainerNPCTrader.java index f6b936b46..71dcd6fa6 100644 --- a/src/main/java/noppes/npcs/containers/ContainerNPCTrader.java +++ b/src/main/java/noppes/npcs/containers/ContainerNPCTrader.java @@ -8,117 +8,117 @@ import noppes.npcs.entity.EntityNPCInterface; import noppes.npcs.roles.RoleTrader; -public class ContainerNPCTrader extends ContainerNpcInterface{ - public RoleTrader role; +public class ContainerNPCTrader extends ContainerNpcInterface { + public RoleTrader role; - public ContainerNPCTrader(EntityNPCInterface npc,EntityPlayer player){ - super(player); + public ContainerNPCTrader(EntityNPCInterface npc, EntityPlayer player) { + super(player); role = (RoleTrader) npc.roleInterface; - for(int i = 0; i < 18; i++){ - int x = 53; - x += i%3 * 72; - int y = 7; - y += i/3 * 21; + for (int i = 0; i < 18; i++) { + int x = 53; + x += i % 3 * 72; + int y = 7; + y += i / 3 * 21; - ItemStack item = role.inventoryCurrency.items.get(i); - ItemStack item2 = role.inventoryCurrency.items.get(i + 18); - if(item == null){ - item = item2; - item2 = null; - } - addSlotToContainer(new Slot(role.inventorySold, i, x, y)); + ItemStack item = role.inventoryCurrency.items.get(i); + ItemStack item2 = role.inventoryCurrency.items.get(i + 18); + if (item == null) { + item = item2; + item2 = null; + } + addSlotToContainer(new Slot(role.inventorySold, i, x, y)); } - for(int i1 = 0; i1 < 3; i1++){ - for(int l1 = 0; l1 < 9; l1++){ - addSlotToContainer(new Slot(player.inventory, l1 + i1 * 9 + 9, 32 + l1 * 18, 140 + i1 * 18)); + for (int i1 = 0; i1 < 3; i1++) { + for (int l1 = 0; l1 < 9; l1++) { + addSlotToContainer(new Slot(player.inventory, l1 + i1 * 9 + 9, 32 + l1 * 18, 140 + i1 * 18)); } } - for(int j1 = 0; j1 < 9; j1++){ - addSlotToContainer(new Slot(player.inventory, j1, 32 + j1 * 18, 198)); + for (int j1 = 0; j1 < 9; j1++) { + addSlotToContainer(new Slot(player.inventory, j1, 32 + j1 * 18, 198)); } } @Override - public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int i){ + public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int i) { return null; } + @Override - public ItemStack slotClick(int i, int j, int par3, EntityPlayer entityplayer){ - if(par3 == 6) - par3 = 0; - if(i < 0 || i >= 18) - return super.slotClick(i, j, par3, entityplayer); - if( j ==1 ) - return null; - Slot slot = (Slot)inventorySlots.get(i); - if(slot == null || slot.getStack() == null) - return null; + public ItemStack slotClick(int i, int j, int par3, EntityPlayer entityplayer) { + if (par3 == 6) + par3 = 0; + if (i < 0 || i >= 18) + return super.slotClick(i, j, par3, entityplayer); + if (j == 1) + return null; + Slot slot = (Slot) inventorySlots.get(i); + if (slot == null || slot.getStack() == null) + return null; ItemStack item = slot.getStack(); - if(!canGivePlayer(item, entityplayer)) - return null; - if(!canBuy(i, entityplayer)) - return null; - if (!isSlotEnabled(i, entityplayer)) - return null; + if (!canGivePlayer(item, entityplayer)) + return null; + if (!canBuy(i, entityplayer)) + return null; + if (!isSlotEnabled(i, entityplayer)) + return null; NoppesUtilPlayer.consumeItem(entityplayer, role.inventoryCurrency.getStackInSlot(i), role.ignoreDamage, role.ignoreNBT); NoppesUtilPlayer.consumeItem(entityplayer, role.inventoryCurrency.getStackInSlot(i + 18), role.ignoreDamage, role.ignoreNBT); ItemStack soldItem = item.copy(); givePlayer(soldItem, entityplayer); role.addPurchase(i, entityplayer.getDisplayName()); return soldItem; - - } - public boolean isSlotEnabled(int slot, EntityPlayer player) { - return role.isSlotEnabled(slot, player.getDisplayName()); - } - public boolean canBuy(int slot, EntityPlayer player) { - ItemStack currency = role.inventoryCurrency.getStackInSlot(slot); - ItemStack currency2 = role.inventoryCurrency.getStackInSlot(slot + 18); - if(currency == null && currency2 == null) - return true; - if(currency == null){ - currency = currency2; - currency2 = null; - } - if(NoppesUtilPlayer.compareItems(currency, currency2, role.ignoreDamage, role.ignoreNBT)){ - currency = currency.copy(); - currency.stackSize += currency2.stackSize; - currency2 = null; - } - if(currency2 == null ) - return NoppesUtilPlayer.compareItems(player, currency, role.ignoreDamage, role.ignoreNBT); - return NoppesUtilPlayer.compareItems(player, currency, role.ignoreDamage, role.ignoreNBT) && NoppesUtilPlayer.compareItems(player, currency2, role.ignoreDamage, role.ignoreNBT); - + } - private boolean canGivePlayer(ItemStack item,EntityPlayer entityplayer){//check Item being held with the mouse - ItemStack itemstack3 = entityplayer.inventory.getItemStack(); - if(itemstack3 == null){ - return true; + public boolean isSlotEnabled(int slot, EntityPlayer player) { + return role.isSlotEnabled(slot, player.getDisplayName()); + } + + public boolean canBuy(int slot, EntityPlayer player) { + ItemStack currency = role.inventoryCurrency.getStackInSlot(slot); + ItemStack currency2 = role.inventoryCurrency.getStackInSlot(slot + 18); + if (currency == null && currency2 == null) + return true; + if (currency == null) { + currency = currency2; + currency2 = null; } - else if(NoppesUtilPlayer.compareItems(itemstack3, item, false, false)){ + if (NoppesUtilPlayer.compareItems(currency, currency2, role.ignoreDamage, role.ignoreNBT)) { + currency = currency.copy(); + currency.stackSize += currency2.stackSize; + currency2 = null; + } + if (currency2 == null) + return NoppesUtilPlayer.compareItems(player, currency, role.ignoreDamage, role.ignoreNBT); + return NoppesUtilPlayer.compareItems(player, currency, role.ignoreDamage, role.ignoreNBT) && NoppesUtilPlayer.compareItems(player, currency2, role.ignoreDamage, role.ignoreNBT); + + } + + private boolean canGivePlayer(ItemStack item, EntityPlayer entityplayer) {//check Item being held with the mouse + ItemStack itemstack3 = entityplayer.inventory.getItemStack(); + if (itemstack3 == null) { + return true; + } else if (NoppesUtilPlayer.compareItems(itemstack3, item, false, false)) { int k1 = item.stackSize; - if(k1 > 0 && k1 + itemstack3.stackSize <= itemstack3.getMaxStackSize()) - { + if (k1 > 0 && k1 + itemstack3.stackSize <= itemstack3.getMaxStackSize()) { return true; } } return false; } - private void givePlayer(ItemStack item,EntityPlayer entityplayer){//set item bought to the held mouse item + + private void givePlayer(ItemStack item, EntityPlayer entityplayer) {//set item bought to the held mouse item ItemStack itemstack3 = entityplayer.inventory.getItemStack(); - if(itemstack3 == null){ - entityplayer.inventory.setItemStack(item); - } - else if(NoppesUtilPlayer.compareItems(itemstack3, item, false, false)){ + if (itemstack3 == null) { + entityplayer.inventory.setItemStack(item); + } else if (NoppesUtilPlayer.compareItems(itemstack3, item, false, false)) { int k1 = item.stackSize; - if(k1 > 0 && k1 + itemstack3.stackSize <= itemstack3.getMaxStackSize()) - { + if (k1 > 0 && k1 + itemstack3.stackSize <= itemstack3.getMaxStackSize()) { itemstack3.stackSize += k1; } } diff --git a/src/main/java/noppes/npcs/containers/ContainerNPCTraderSetup.java b/src/main/java/noppes/npcs/containers/ContainerNPCTraderSetup.java index 68e68131e..8209f22a8 100644 --- a/src/main/java/noppes/npcs/containers/ContainerNPCTraderSetup.java +++ b/src/main/java/noppes/npcs/containers/ContainerNPCTraderSetup.java @@ -7,45 +7,42 @@ import net.minecraft.item.ItemStack; import noppes.npcs.entity.EntityNPCInterface; import noppes.npcs.roles.RoleTrader; -public class ContainerNPCTraderSetup extends Container -{ - public RoleTrader role; +public class ContainerNPCTraderSetup extends Container { + public RoleTrader role; - public ContainerNPCTraderSetup(EntityNPCInterface npc,EntityPlayer player) - { + public ContainerNPCTraderSetup(EntityNPCInterface npc, EntityPlayer player) { role = (RoleTrader) npc.roleInterface; - - for(int i = 0; i < 18; i++) - { - int x = 7; - x += i%3 * 94; - int y = 15; - y += i/3 * 22; - addSlotToContainer(new Slot(role.inventoryCurrency, i + 18, x, y)); - addSlotToContainer(new Slot(role.inventoryCurrency, i, x + 18, y)); - addSlotToContainer(new Slot(role.inventorySold, i, x + 43, y)); - } + for (int i = 0; i < 18; i++) { + int x = 7; + x += i % 3 * 94; + int y = 15; + y += i / 3 * 22; + addSlotToContainer(new Slot(role.inventoryCurrency, i + 18, x, y)); + addSlotToContainer(new Slot(role.inventoryCurrency, i, x + 18, y)); + addSlotToContainer(new Slot(role.inventorySold, i, x + 43, y)); - for(int i1 = 0; i1 < 3; i1++){ - for(int l1 = 0; l1 < 9; l1++){ - addSlotToContainer(new Slot(player.inventory, l1 + i1 * 9 + 9, 48 + l1 * 18, 147 + i1 * 18)); + } + + for (int i1 = 0; i1 < 3; i1++) { + for (int l1 = 0; l1 < 9; l1++) { + addSlotToContainer(new Slot(player.inventory, l1 + i1 * 9 + 9, 48 + l1 * 18, 147 + i1 * 18)); } } - for(int j1 = 0; j1 < 9; j1++){ - addSlotToContainer(new Slot(player.inventory, j1, 48 + j1 * 18, 205)); + for (int j1 = 0; j1 < 9; j1++) { + addSlotToContainer(new Slot(player.inventory, j1, 48 + j1 * 18, 205)); } } @Override - public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int i) - { + public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int i) { return null; } - @Override - public boolean canInteractWith(EntityPlayer entityplayer) { - return true; - } + + @Override + public boolean canInteractWith(EntityPlayer entityplayer) { + return true; + } } diff --git a/src/main/java/noppes/npcs/containers/ContainerNpcInterface.java b/src/main/java/noppes/npcs/containers/ContainerNpcInterface.java index c58ae311c..8091481e6 100644 --- a/src/main/java/noppes/npcs/containers/ContainerNpcInterface.java +++ b/src/main/java/noppes/npcs/containers/ContainerNpcInterface.java @@ -6,27 +6,28 @@ import net.minecraft.util.MathHelper; import noppes.npcs.api.IContainer; import noppes.npcs.scripted.ScriptContainer; -public class ContainerNpcInterface extends Container{ - private int posX, posZ; - public EntityPlayer player; - public IContainer scriptContainer; +public class ContainerNpcInterface extends Container { + private int posX, posZ; + public EntityPlayer player; + public IContainer scriptContainer; - public ContainerNpcInterface(EntityPlayer player){ - posX = MathHelper.floor_double(player.posX); - posZ = MathHelper.floor_double(player.posZ); - player.motionX = 0; - player.motionZ = 0; - } - @Override - public boolean canInteractWith(EntityPlayer player) { + public ContainerNpcInterface(EntityPlayer player) { + posX = MathHelper.floor_double(player.posX); + posZ = MathHelper.floor_double(player.posZ); + player.motionX = 0; + player.motionZ = 0; + } + + @Override + public boolean canInteractWith(EntityPlayer player) { return !player.isDead && posX == MathHelper.floor_double(player.posX) && posZ == MathHelper.floor_double(player.posZ); - } + } - public static IContainer getOrCreateIContainer(ContainerNpcInterface container) { - if (container.scriptContainer != null) { - return container.scriptContainer; - } else { - return container.scriptContainer = new ScriptContainer(container); - } - } + public static IContainer getOrCreateIContainer(ContainerNpcInterface container) { + if (container.scriptContainer != null) { + return container.scriptContainer; + } else { + return container.scriptContainer = new ScriptContainer(container); + } + } } diff --git a/src/main/java/noppes/npcs/containers/ContainerNpcItemGiver.java b/src/main/java/noppes/npcs/containers/ContainerNpcItemGiver.java index d68420403..d10fdd70a 100644 --- a/src/main/java/noppes/npcs/containers/ContainerNpcItemGiver.java +++ b/src/main/java/noppes/npcs/containers/ContainerNpcItemGiver.java @@ -7,40 +7,34 @@ import net.minecraft.item.ItemStack; import noppes.npcs.entity.EntityNPCInterface; import noppes.npcs.roles.JobItemGiver; -public class ContainerNpcItemGiver extends Container -{ +public class ContainerNpcItemGiver extends Container { private JobItemGiver role; - public ContainerNpcItemGiver(EntityNPCInterface npc,EntityPlayer player) - { - this.role = (JobItemGiver) npc.jobInterface; - for(int j1 = 0; j1 < 9; j1++) - { - addSlotToContainer(new Slot(role.inventory, j1, 6 + j1 * 18, 90)); + public ContainerNpcItemGiver(EntityNPCInterface npc, EntityPlayer player) { + this.role = (JobItemGiver) npc.jobInterface; + for (int j1 = 0; j1 < 9; j1++) { + addSlotToContainer(new Slot(role.inventory, j1, 6 + j1 * 18, 90)); } - for(int i1 = 0; i1 < 3; i1++) - { - for(int l1 = 0; l1 < 9; l1++) - { - addSlotToContainer(new Slot(player.inventory, l1 + i1 * 9 + 9, 6 + l1 * 18, 116 + i1 * 18)); + for (int i1 = 0; i1 < 3; i1++) { + for (int l1 = 0; l1 < 9; l1++) { + addSlotToContainer(new Slot(player.inventory, l1 + i1 * 9 + 9, 6 + l1 * 18, 116 + i1 * 18)); } } - for(int j1 = 0; j1 < 9; j1++) - { - addSlotToContainer(new Slot(player.inventory, j1, 6 + j1 * 18, 174)); + for (int j1 = 0; j1 < 9; j1++) { + addSlotToContainer(new Slot(player.inventory, j1, 6 + j1 * 18, 174)); } } @Override - public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int i) - { + public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int i) { return null; } - @Override - public boolean canInteractWith(EntityPlayer entityplayer) { - return true; - } + + @Override + public boolean canInteractWith(EntityPlayer entityplayer) { + return true; + } } diff --git a/src/main/java/noppes/npcs/containers/ContainerNpcQuestReward.java b/src/main/java/noppes/npcs/containers/ContainerNpcQuestReward.java index af9199c31..3f1060ccb 100644 --- a/src/main/java/noppes/npcs/containers/ContainerNpcQuestReward.java +++ b/src/main/java/noppes/npcs/containers/ContainerNpcQuestReward.java @@ -8,34 +8,35 @@ import noppes.npcs.NoppesUtilServer; import noppes.npcs.client.gui.global.GuiNPCManageQuest; import noppes.npcs.controllers.data.Quest; -public class ContainerNpcQuestReward extends Container{ - public ContainerNpcQuestReward(EntityPlayer player){ - Quest quest = NoppesUtilServer.getEditingQuest(player); - if(player.worldObj.isRemote) - quest = GuiNPCManageQuest.quest; - for(int l = 0; l < 3; l++){ - for(int k1 = 0; k1 < 3; k1++){ - addSlotToContainer(new Slot(quest.rewardItems, k1 + l * 3, 105 + k1 * 18, 17 + l * 18)); - } - } - - for(int i1 = 0; i1 < 3; i1++){ - for(int l1 = 0; l1 < 9; l1++){ - addSlotToContainer(new Slot(player.inventory, l1 + i1 * 9 + 9, 8 + l1 * 18, 84 + i1 * 18)); +public class ContainerNpcQuestReward extends Container { + public ContainerNpcQuestReward(EntityPlayer player) { + Quest quest = NoppesUtilServer.getEditingQuest(player); + if (player.worldObj.isRemote) + quest = GuiNPCManageQuest.quest; + for (int l = 0; l < 3; l++) { + for (int k1 = 0; k1 < 3; k1++) { + addSlotToContainer(new Slot(quest.rewardItems, k1 + l * 3, 105 + k1 * 18, 17 + l * 18)); } } - for(int j1 = 0; j1 < 9; j1++){ - addSlotToContainer(new Slot(player.inventory, j1, 8 + j1 * 18, 142)); + for (int i1 = 0; i1 < 3; i1++) { + for (int l1 = 0; l1 < 9; l1++) { + addSlotToContainer(new Slot(player.inventory, l1 + i1 * 9 + 9, 8 + l1 * 18, 84 + i1 * 18)); + } + } + + for (int j1 = 0; j1 < 9; j1++) { + addSlotToContainer(new Slot(player.inventory, j1, 8 + j1 * 18, 142)); } } @Override - public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int i){ + public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int i) { return null; } - @Override - public boolean canInteractWith(EntityPlayer entityplayer) { - return true; - } + + @Override + public boolean canInteractWith(EntityPlayer entityplayer) { + return true; + } } diff --git a/src/main/java/noppes/npcs/containers/ContainerNpcQuestTypeItem.java b/src/main/java/noppes/npcs/containers/ContainerNpcQuestTypeItem.java index 797412633..bea7e9733 100644 --- a/src/main/java/noppes/npcs/containers/ContainerNpcQuestTypeItem.java +++ b/src/main/java/noppes/npcs/containers/ContainerNpcQuestTypeItem.java @@ -9,39 +9,34 @@ import noppes.npcs.client.gui.global.GuiNPCManageQuest; import noppes.npcs.controllers.data.Quest; import noppes.npcs.quests.QuestItem; -public class ContainerNpcQuestTypeItem extends Container -{ +public class ContainerNpcQuestTypeItem extends Container { - public ContainerNpcQuestTypeItem(EntityPlayer player) - { - Quest quest = NoppesUtilServer.getEditingQuest(player); - if(player.worldObj.isRemote) - quest = GuiNPCManageQuest.quest; - for(int i1 = 0; i1 < 3; i1++) - addSlotToContainer(new Slot(((QuestItem)quest.questInterface).items, i1, 44, 39 + i1 * 25)); - - for(int i1 = 0; i1 < 3; i1++) - { - for(int l1 = 0; l1 < 9; l1++) - { - addSlotToContainer(new Slot(player.inventory, l1 + i1 * 9 + 9, 8 + l1 * 18, 113 + i1 * 18)); + public ContainerNpcQuestTypeItem(EntityPlayer player) { + Quest quest = NoppesUtilServer.getEditingQuest(player); + if (player.worldObj.isRemote) + quest = GuiNPCManageQuest.quest; + for (int i1 = 0; i1 < 3; i1++) + addSlotToContainer(new Slot(((QuestItem) quest.questInterface).items, i1, 44, 39 + i1 * 25)); + + for (int i1 = 0; i1 < 3; i1++) { + for (int l1 = 0; l1 < 9; l1++) { + addSlotToContainer(new Slot(player.inventory, l1 + i1 * 9 + 9, 8 + l1 * 18, 113 + i1 * 18)); } } - for(int j1 = 0; j1 < 9; j1++) - { - addSlotToContainer(new Slot(player.inventory, j1, 8 + j1 * 18, 171)); + for (int j1 = 0; j1 < 9; j1++) { + addSlotToContainer(new Slot(player.inventory, j1, 8 + j1 * 18, 171)); } } @Override - public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int i) - { + public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int i) { return null; } - @Override - public boolean canInteractWith(EntityPlayer entityplayer) { - return true; - } + + @Override + public boolean canInteractWith(EntityPlayer entityplayer) { + return true; + } } diff --git a/src/main/java/noppes/npcs/containers/InventoryNPC.java b/src/main/java/noppes/npcs/containers/InventoryNPC.java index 4812bfed2..75215026a 100644 --- a/src/main/java/noppes/npcs/containers/InventoryNPC.java +++ b/src/main/java/noppes/npcs/containers/InventoryNPC.java @@ -6,110 +6,102 @@ import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; public class InventoryNPC - implements IInventory -{ + implements IInventory { private String inventoryTitle; private int slotsCount; private ItemStack inventoryContents[]; private Container con; - public InventoryNPC(String s, int i,Container con) - { - this.con = con; + public InventoryNPC(String s, int i, Container con) { + this.con = con; inventoryTitle = s; slotsCount = i; inventoryContents = new ItemStack[i]; } + @Override - public ItemStack getStackInSlot(int i) - { + public ItemStack getStackInSlot(int i) { return inventoryContents[i]; } @Override - public ItemStack decrStackSize(int i, int j) - { - if(inventoryContents[i] != null) - { - if(inventoryContents[i].stackSize <= j) - { + public ItemStack decrStackSize(int i, int j) { + if (inventoryContents[i] != null) { + if (inventoryContents[i].stackSize <= j) { ItemStack itemstack = inventoryContents[i]; inventoryContents[i] = null; //onInventoryChanged(); return itemstack; } ItemStack itemstack1 = inventoryContents[i].splitStack(j); - if(inventoryContents[i].stackSize == 0) - { + if (inventoryContents[i].stackSize == 0) { inventoryContents[i] = null; } //onInventoryChanged(); return itemstack1; - } else - { + } else { return null; } } @Override - public void setInventorySlotContents(int i, ItemStack itemstack) - { + public void setInventorySlotContents(int i, ItemStack itemstack) { inventoryContents[i] = itemstack; - if(itemstack != null && itemstack.stackSize > getInventoryStackLimit()) - { + if (itemstack != null && itemstack.stackSize > getInventoryStackLimit()) { itemstack.stackSize = getInventoryStackLimit(); } //onInventoryChanged(); } @Override - public int getSizeInventory() - { + public int getSizeInventory() { return slotsCount; } - + @Override - public int getInventoryStackLimit() - { + public int getInventoryStackLimit() { return 64; } @Override - public boolean isUseableByPlayer(EntityPlayer entityplayer) - { + public boolean isUseableByPlayer(EntityPlayer entityplayer) { return false; } - @Override - public ItemStack getStackInSlotOnClosing(int i) { - return null; - } - - @Override - public boolean isItemValidForSlot(int i, ItemStack itemstack) { - return true; - } - - @Override - public String getInventoryName() { + @Override + public ItemStack getStackInSlotOnClosing(int i) { + return null; + } + + @Override + public boolean isItemValidForSlot(int i, ItemStack itemstack) { + return true; + } + + @Override + public String getInventoryName() { return inventoryTitle; - } - @Override - public boolean hasCustomInventoryName() { - return true; - } - @Override - public void markDirty() { - con.onCraftMatrixChanged(this); - } - @Override - public void openInventory() { - - } - @Override - public void closeInventory() { - - } + } + + @Override + public boolean hasCustomInventoryName() { + return true; + } + + @Override + public void markDirty() { + con.onCraftMatrixChanged(this); + } + + @Override + public void openInventory() { + + } + + @Override + public void closeInventory() { + + } } diff --git a/src/main/java/noppes/npcs/containers/InventoryNpcTrader.java b/src/main/java/noppes/npcs/containers/InventoryNpcTrader.java index ddcc68d01..398fc895a 100644 --- a/src/main/java/noppes/npcs/containers/InventoryNpcTrader.java +++ b/src/main/java/noppes/npcs/containers/InventoryNpcTrader.java @@ -5,101 +5,91 @@ import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; public class InventoryNpcTrader - implements IInventory -{ + implements IInventory { private String inventoryTitle; private int slotsCount; private ItemStack inventoryContents[]; private ContainerNPCTrader con; - public InventoryNpcTrader(String s, int i,ContainerNPCTrader con) - { - this.con = con; + public InventoryNpcTrader(String s, int i, ContainerNPCTrader con) { + this.con = con; inventoryTitle = s; slotsCount = i; inventoryContents = new ItemStack[i]; } - - public ItemStack getStackInSlot(int i) - { + + public ItemStack getStackInSlot(int i) { ItemStack toBuy = inventoryContents[i]; - if(toBuy == null) - return null; - + if (toBuy == null) + return null; + return ItemStack.copyItemStack(toBuy); } - public ItemStack decrStackSize(int i, int j) - { - if(inventoryContents[i] != null) - { + public ItemStack decrStackSize(int i, int j) { + if (inventoryContents[i] != null) { ItemStack itemstack = inventoryContents[i]; - return ItemStack.copyItemStack(itemstack); - } else - { + return ItemStack.copyItemStack(itemstack); + } else { return null; } } - public void setInventorySlotContents(int i, ItemStack itemstack) - { - if(itemstack != null) - inventoryContents[i] = itemstack.copy(); + public void setInventorySlotContents(int i, ItemStack itemstack) { + if (itemstack != null) + inventoryContents[i] = itemstack.copy(); markDirty(); - + } - public int getSizeInventory() - { + public int getSizeInventory() { return slotsCount; } - public int getInventoryStackLimit() - { + public int getInventoryStackLimit() { return 64; } - public boolean isUseableByPlayer(EntityPlayer entityplayer) - { + public boolean isUseableByPlayer(EntityPlayer entityplayer) { return true; } - @Override - public ItemStack getStackInSlotOnClosing(int i) { - return null; - } + @Override + public ItemStack getStackInSlotOnClosing(int i) { + return null; + } - @Override - public boolean isItemValidForSlot(int i, ItemStack itemstack) { - return true; - } + @Override + public boolean isItemValidForSlot(int i, ItemStack itemstack) { + return true; + } - @Override - public String getInventoryName() { + @Override + public String getInventoryName() { return inventoryTitle; - } + } - @Override - public boolean hasCustomInventoryName() { - return true; - } + @Override + public boolean hasCustomInventoryName() { + return true; + } - @Override - public void markDirty() { - con.onCraftMatrixChanged(this); - } + @Override + public void markDirty() { + con.onCraftMatrixChanged(this); + } - @Override - public void openInventory() { - } + @Override + public void openInventory() { + } - @Override - public void closeInventory() { - } + @Override + public void closeInventory() { + } } diff --git a/src/main/java/noppes/npcs/containers/SlotCompanionArmor.java b/src/main/java/noppes/npcs/containers/SlotCompanionArmor.java index 021d95906..09e1fb7b5 100644 --- a/src/main/java/noppes/npcs/containers/SlotCompanionArmor.java +++ b/src/main/java/noppes/npcs/containers/SlotCompanionArmor.java @@ -8,35 +8,35 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; import noppes.npcs.roles.RoleCompanion; -class SlotCompanionArmor extends Slot{ +class SlotCompanionArmor extends Slot { final int armorType; final RoleCompanion role; - public SlotCompanionArmor(RoleCompanion role, IInventory iinventory, int id, int x, int y, int type){ + public SlotCompanionArmor(RoleCompanion role, IInventory iinventory, int id, int x, int y, int type) { super(iinventory, id, x, y); armorType = type; this.role = role; } - @Override - public int getSlotStackLimit() { - return 1; - } + @Override + public int getSlotStackLimit() { + return 1; + } - @Override - public IIcon getBackgroundIconIndex() { - return ItemArmor.func_94602_b(this.armorType); - } + @Override + public IIcon getBackgroundIconIndex() { + return ItemArmor.func_94602_b(this.armorType); + } - @Override - public boolean isItemValid(ItemStack itemstack) { - if (itemstack.getItem() instanceof ItemArmor && role.canWearArmor(itemstack)) - return ((ItemArmor) itemstack.getItem()).armorType == armorType; - - if (itemstack.getItem() instanceof ItemBlock) - return armorType == 0; - - return false; - } + @Override + public boolean isItemValid(ItemStack itemstack) { + if (itemstack.getItem() instanceof ItemArmor && role.canWearArmor(itemstack)) + return ((ItemArmor) itemstack.getItem()).armorType == armorType; + + if (itemstack.getItem() instanceof ItemBlock) + return armorType == 0; + + return false; + } } diff --git a/src/main/java/noppes/npcs/containers/SlotCompanionWeapon.java b/src/main/java/noppes/npcs/containers/SlotCompanionWeapon.java index 7d5257f5d..237d6aa9f 100644 --- a/src/main/java/noppes/npcs/containers/SlotCompanionWeapon.java +++ b/src/main/java/noppes/npcs/containers/SlotCompanionWeapon.java @@ -5,22 +5,22 @@ import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; import noppes.npcs.roles.RoleCompanion; -class SlotCompanionWeapon extends Slot{ +class SlotCompanionWeapon extends Slot { final RoleCompanion role; - public SlotCompanionWeapon(RoleCompanion role, IInventory iinventory, int id, int x, int y){ + public SlotCompanionWeapon(RoleCompanion role, IInventory iinventory, int id, int x, int y) { super(iinventory, id, x, y); this.role = role; } - @Override - public int getSlotStackLimit() { - return 1; - } + @Override + public int getSlotStackLimit() { + return 1; + } - @Override - public boolean isItemValid(ItemStack itemstack) { - return role.canWearSword(itemstack); - } + @Override + public boolean isItemValid(ItemStack itemstack) { + return role.canWearSword(itemstack); + } } diff --git a/src/main/java/noppes/npcs/containers/SlotNPCArmor.java b/src/main/java/noppes/npcs/containers/SlotNPCArmor.java index 290304cfe..b193d853a 100644 --- a/src/main/java/noppes/npcs/containers/SlotNPCArmor.java +++ b/src/main/java/noppes/npcs/containers/SlotNPCArmor.java @@ -7,41 +7,33 @@ import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; -class SlotNPCArmor extends Slot -{ +class SlotNPCArmor extends Slot { final int armorType; /* synthetic field */ - SlotNPCArmor(IInventory iinventory, int i, int j, int k, int l) - { + SlotNPCArmor(IInventory iinventory, int i, int j, int k, int l) { super(iinventory, i, j, k); armorType = l; } @Override - public int getSlotStackLimit() - { + public int getSlotStackLimit() { return 1; } @Override - public IIcon getBackgroundIconIndex() - { + public IIcon getBackgroundIconIndex() { return ItemArmor.func_94602_b(this.armorType); } @Override - public boolean isItemValid(ItemStack itemstack) - { - if(itemstack.getItem() instanceof ItemArmor) - { - return ((ItemArmor)itemstack.getItem()).armorType == armorType; + public boolean isItemValid(ItemStack itemstack) { + if (itemstack.getItem() instanceof ItemArmor) { + return ((ItemArmor) itemstack.getItem()).armorType == armorType; } - if(itemstack.getItem() instanceof ItemBlock) - { + if (itemstack.getItem() instanceof ItemBlock) { return armorType == 0; - } else - { + } else { return false; } } diff --git a/src/main/java/noppes/npcs/containers/SlotNpcBankCurrency.java b/src/main/java/noppes/npcs/containers/SlotNpcBankCurrency.java index 0443a9910..de0e38bcb 100644 --- a/src/main/java/noppes/npcs/containers/SlotNpcBankCurrency.java +++ b/src/main/java/noppes/npcs/containers/SlotNpcBankCurrency.java @@ -4,31 +4,27 @@ import net.minecraft.inventory.IInventory; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; -public class SlotNpcBankCurrency extends Slot -{ +public class SlotNpcBankCurrency extends Slot { - public ItemStack item; + public ItemStack item; - public SlotNpcBankCurrency(ContainerNPCBankInterface containerplayer, IInventory iinventory, int i, int j, int k) - { + public SlotNpcBankCurrency(ContainerNPCBankInterface containerplayer, IInventory iinventory, int i, int j, int k) { super(iinventory, i, j, k); } @Override - public int getSlotStackLimit() - { + public int getSlotStackLimit() { return 64; } @Override - public boolean isItemValid(ItemStack itemstack) - { - if(item == null) - return false; - if(item.getItem() == itemstack.getItem()){ - if(!item.getHasSubtypes() || item.getItemDamage() == itemstack.getItemDamage()) - return true; - } - return false; + public boolean isItemValid(ItemStack itemstack) { + if (item == null) + return false; + if (item.getItem() == itemstack.getItem()) { + if (!item.getHasSubtypes() || item.getItemDamage() == itemstack.getItemDamage()) + return true; + } + return false; } } diff --git a/src/main/java/noppes/npcs/containers/SlotNpcMercenaryCurrency.java b/src/main/java/noppes/npcs/containers/SlotNpcMercenaryCurrency.java index 57d779cad..6b04c2999 100644 --- a/src/main/java/noppes/npcs/containers/SlotNpcMercenaryCurrency.java +++ b/src/main/java/noppes/npcs/containers/SlotNpcMercenaryCurrency.java @@ -6,35 +6,31 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import noppes.npcs.roles.RoleFollower; -class SlotNpcMercenaryCurrency extends Slot -{ +class SlotNpcMercenaryCurrency extends Slot { - RoleFollower role; /* synthetic field */ + RoleFollower role; /* synthetic field */ - public SlotNpcMercenaryCurrency(RoleFollower role, IInventory inv, int i, int j, int k) - { + public SlotNpcMercenaryCurrency(RoleFollower role, IInventory inv, int i, int j, int k) { super(inv, i, j, k); this.role = role; } @Override - public int getSlotStackLimit() - { + public int getSlotStackLimit() { return 64; } @Override - public boolean isItemValid(ItemStack itemstack) - { - Item item = itemstack.getItem(); - for(ItemStack is : role.inventory.items.values()){ - if(item == is.getItem()){ - if(itemstack.getHasSubtypes() && itemstack.getItemDamage() != is.getItemDamage()) - continue; - return true; - } - } + public boolean isItemValid(ItemStack itemstack) { + Item item = itemstack.getItem(); + for (ItemStack is : role.inventory.items.values()) { + if (item == is.getItem()) { + if (itemstack.getHasSubtypes() && itemstack.getItemDamage() != is.getItemDamage()) + continue; + return true; + } + } return false; - + } } diff --git a/src/main/java/noppes/npcs/containers/SlotNpcTraderItems.java b/src/main/java/noppes/npcs/containers/SlotNpcTraderItems.java index e7142972a..107440b30 100644 --- a/src/main/java/noppes/npcs/containers/SlotNpcTraderItems.java +++ b/src/main/java/noppes/npcs/containers/SlotNpcTraderItems.java @@ -4,34 +4,30 @@ import net.minecraft.inventory.IInventory; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; -class SlotNpcTraderItems extends Slot -{ +class SlotNpcTraderItems extends Slot { - public SlotNpcTraderItems( IInventory iinventory, int i, int j, int k) - { + public SlotNpcTraderItems(IInventory iinventory, int i, int j, int k) { super(iinventory, i, j, k); } - public void onPickupFromSlot(ItemStack itemstack) - { - if(itemstack == null) - return; - if(getStack() == null) - return; - if(itemstack.getItem() != getStack().getItem()) - return; - itemstack.stackSize--; + + public void onPickupFromSlot(ItemStack itemstack) { + if (itemstack == null) + return; + if (getStack() == null) + return; + if (itemstack.getItem() != getStack().getItem()) + return; + itemstack.stackSize--; //onSlotChanged(); } - public int getSlotStackLimit() - { + public int getSlotStackLimit() { return 64; } - public boolean isItemValid(ItemStack itemstack) - { + public boolean isItemValid(ItemStack itemstack) { return false; - + } } diff --git a/src/main/java/noppes/npcs/containers/SlotValid.java b/src/main/java/noppes/npcs/containers/SlotValid.java index 4099a56ef..2dae715ee 100644 --- a/src/main/java/noppes/npcs/containers/SlotValid.java +++ b/src/main/java/noppes/npcs/containers/SlotValid.java @@ -4,19 +4,19 @@ import net.minecraft.inventory.IInventory; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; -public class SlotValid extends Slot{ - private boolean canPutIn = true; +public class SlotValid extends Slot { + private boolean canPutIn = true; - public SlotValid(IInventory par1iInventory, int par2, int par3, int par4) { - super(par1iInventory, par2, par3, par4); - } - - public SlotValid(IInventory par1iInventory, int par2, int par3, int par4, boolean bo) { - super(par1iInventory, par2, par3, par4); - canPutIn = bo; - } - - public boolean isItemValid(ItemStack par1ItemStack){ + public SlotValid(IInventory par1iInventory, int par2, int par3, int par4) { + super(par1iInventory, par2, par3, par4); + } + + public SlotValid(IInventory par1iInventory, int par2, int par3, int par4, boolean bo) { + super(par1iInventory, par2, par3, par4); + canPutIn = bo; + } + + public boolean isItemValid(ItemStack par1ItemStack) { return canPutIn && inventory.isItemValidForSlot(0, par1ItemStack); } } diff --git a/src/main/java/noppes/npcs/controllers/AnimationController.java b/src/main/java/noppes/npcs/controllers/AnimationController.java index d9fe1ff35..a25947cfe 100644 --- a/src/main/java/noppes/npcs/controllers/AnimationController.java +++ b/src/main/java/noppes/npcs/controllers/AnimationController.java @@ -30,11 +30,11 @@ public class AnimationController implements IAnimationHandler { load(); } - public static AnimationController getInstance(){ + public static AnimationController getInstance() { return Instance; } - public void load(){ + public void load() { bootOrder = new HashMap<>(); animations = new HashMap<>(); LogWriter.info("Loading animations..."); @@ -43,7 +43,7 @@ public class AnimationController implements IAnimationHandler { LogWriter.info("Done loading animations."); } - private void loadAnimations(){ + private void loadAnimations() { animations.clear(); File dir = getDir(); @@ -58,28 +58,28 @@ public class AnimationController implements IAnimationHandler { animation.readFromNBT(NBTJsonUtil.LoadFile(file)); animation.name = file.getName().substring(0, file.getName().length() - 5); - if(animation.id == -1){ + if (animation.id == -1) { animation.id = getUnusedId(); } int originalID = animation.id; int setID = animation.id; - while (bootOrder.containsKey(setID) || animations.containsKey(setID)){ - if(bootOrder.containsKey(setID)) - if(bootOrder.get(setID).equals(animation.name)) + while (bootOrder.containsKey(setID) || animations.containsKey(setID)) { + if (bootOrder.containsKey(setID)) + if (bootOrder.get(setID).equals(animation.name)) break; setID++; } animation.id = setID; - if(originalID != setID){ + if (originalID != setID) { LogWriter.info("Found Animation ID Mismatch: " + animation.name + ", New ID: " + setID); animation.save(); } animations.put(animation.id, animation); - } catch(Exception e) { + } catch (Exception e) { LogWriter.error("Error loading: " + file.getAbsolutePath(), e); } } @@ -92,10 +92,10 @@ public class AnimationController implements IAnimationHandler { return new File(CustomNpcs.getWorldSaveDirectory(), "animations"); } - public int getUnusedId(){ - if(lastUsedID == 0){ - for(int catid : animations.keySet()){ - if(catid > lastUsedID) + public int getUnusedId() { + if (lastUsedID == 0) { + for (int catid : animations.keySet()) { + if (catid > lastUsedID) lastUsedID = catid; } @@ -104,16 +104,15 @@ public class AnimationController implements IAnimationHandler { return lastUsedID; } - public IAnimation saveAnimation(IAnimation animation){ - if(animation.getID() < 0){ + public IAnimation saveAnimation(IAnimation animation) { + if (animation.getID() < 0) { animation.setID(getUnusedId()); - while(hasName(animation.getName())) + while (hasName(animation.getName())) animation.setName(animation.getName() + "_"); - } - else{ + } else { Animation existing = animations.get(animation.getID()); - if(existing != null && !existing.name.equals(animation.getName())) - while(hasName(animation.getName())) + if (existing != null && !existing.name.equals(animation.getName())) + while (hasName(animation.getName())) animation.setName(animation.getName() + "_"); } @@ -124,15 +123,15 @@ public class AnimationController implements IAnimationHandler { // Save Animation File File dir = this.getDir(); - if(!dir.exists()) + if (!dir.exists()) dir.mkdirs(); File file = new File(dir, animation.getName() + ".json_new"); - File file2 = new File(dir, animation.getName() + ".json"); + File file2 = new File(dir, animation.getName() + ".json"); try { - NBTJsonUtil.SaveFile(file, ((Animation)animation).writeToNBT()); - if(file2.exists()) + NBTJsonUtil.SaveFile(file, ((Animation) animation).writeToNBT()); + if (file2.exists()) file2.delete(); file.renameTo(file2); } catch (Exception e) { @@ -142,24 +141,24 @@ public class AnimationController implements IAnimationHandler { } public boolean hasName(String newName) { - if(newName.trim().isEmpty()) + if (newName.trim().isEmpty()) return true; - for(Animation animation : animations.values()) - if(animation.name.equals(newName)) + for (Animation animation : animations.values()) + if (animation.name.equals(newName)) return true; return false; } public void delete(String name) { - Animation delete = getAnimationFromName(name); - if(delete != null){ + Animation delete = getAnimationFromName(name); + if (delete != null) { Animation foundAnimation = this.animations.remove(delete.getID()); - if(foundAnimation != null && foundAnimation.name != null){ + if (foundAnimation != null && foundAnimation.name != null) { File dir = this.getDir(); for (File file : dir.listFiles()) { if (!file.isFile() || !file.getName().endsWith(".json")) continue; - if (file.getName().equals(foundAnimation.name+".json")) { + if (file.getName().equals(foundAnimation.name + ".json")) { file.delete(); break; } @@ -171,16 +170,16 @@ public class AnimationController implements IAnimationHandler { } public void delete(int id) { - if(!this.animations.containsKey(id)) + if (!this.animations.containsKey(id)) return; Animation foundAnimation = this.animations.remove(id); - if(foundAnimation != null && foundAnimation.name != null){ + if (foundAnimation != null && foundAnimation.name != null) { File dir = this.getDir(); for (File file : dir.listFiles()) { if (!file.isFile() || !file.getName().endsWith(".json")) continue; - if (file.getName().equals(foundAnimation.name+".json")) { + if (file.getName().equals(foundAnimation.name + ".json")) { file.delete(); break; } @@ -207,9 +206,9 @@ public class AnimationController implements IAnimationHandler { return animations.toArray(new IAnimation[0]); } - public Animation getAnimationFromName(String animation){ - for (Map.Entry entryAnimation : AnimationController.getInstance().animations.entrySet()){ - if (entryAnimation.getValue().name.equalsIgnoreCase(animation)){ + public Animation getAnimationFromName(String animation) { + for (Map.Entry entryAnimation : AnimationController.getInstance().animations.entrySet()) { + if (entryAnimation.getValue().name.equalsIgnoreCase(animation)) { return entryAnimation.getValue(); } } @@ -219,7 +218,7 @@ public class AnimationController implements IAnimationHandler { public String[] getNames() { String[] names = new String[animations.size()]; int i = 0; - for(Animation animation : animations.values()){ + for (Animation animation : animations.values()) { names[i] = animation.name.toLowerCase(); i++; } @@ -231,37 +230,38 @@ public class AnimationController implements IAnimationHandler { //////////////////////////////////////////////////////// // ANIMATION MAP - public File getMapDir(){ + public File getMapDir() { File dir = CustomNpcs.getWorldSaveDirectory(); - if(!dir.exists()) + if (!dir.exists()) dir.mkdir(); return dir; } - public void readAnimationMap(){ + public void readAnimationMap() { bootOrder.clear(); try { File file = new File(getMapDir(), "animations.dat"); - if(file.exists()){ + if (file.exists()) { loadAnimationMapFile(file); } } catch (Exception e) { try { File file = new File(getMapDir(), "animations.dat_old"); - if(file.exists()){ + if (file.exists()) { loadAnimationMapFile(file); } - } catch (Exception ignored) {} + } catch (Exception ignored) { + } } } - public NBTTagCompound writeMapNBT(){ + public NBTTagCompound writeMapNBT() { NBTTagCompound nbt = new NBTTagCompound(); NBTTagList animationList = new NBTTagList(); - for(Integer key: animations.keySet()){ + for (Integer key : animations.keySet()) { Animation animation = animations.get(key); - if(!animation.getName().isEmpty()){ + if (!animation.getName().isEmpty()) { NBTTagCompound animationCompound = new NBTTagCompound(); animationCompound.setString("Name", animation.getName()); animationCompound.setInteger("ID", key); @@ -273,11 +273,10 @@ public class AnimationController implements IAnimationHandler { return nbt; } - public void readMapNBT(NBTTagCompound compound){ + public void readMapNBT(NBTTagCompound compound) { NBTTagList list = compound.getTagList("Animations", 10); - if(list != null){ - for(int i = 0; i < list.tagCount(); i++) - { + if (list != null) { + for (int i = 0; i < list.tagCount(); i++) { NBTTagCompound nbttagcompound = list.getCompoundTagAt(i); String animationName = nbttagcompound.getString("Name"); Integer key = nbttagcompound.getInteger("ID"); @@ -292,30 +291,27 @@ public class AnimationController implements IAnimationHandler { var1.close(); } - public void readAnimationMap(DataInputStream stream) throws IOException{ + public void readAnimationMap(DataInputStream stream) throws IOException { NBTTagCompound nbtCompound = CompressedStreamTools.read(stream); this.readMapNBT(nbtCompound); } - public void saveAnimationMap(){ + public void saveAnimationMap() { try { File saveDir = getMapDir(); File file = new File(saveDir, "animations.dat_new"); File file1 = new File(saveDir, "animations.dat_old"); File file2 = new File(saveDir, "animations.dat"); CompressedStreamTools.writeCompressed(this.writeMapNBT(), new FileOutputStream(file)); - if(file1.exists()) - { + if (file1.exists()) { file1.delete(); } file2.renameTo(file1); - if(file2.exists()) - { + if (file2.exists()) { file2.delete(); } file.renameTo(file2); - if(file.exists()) - { + if (file.exists()) { file.delete(); } } catch (Exception e) { diff --git a/src/main/java/noppes/npcs/controllers/BankController.java b/src/main/java/noppes/npcs/controllers/BankController.java index 37154930f..ddc258859 100644 --- a/src/main/java/noppes/npcs/controllers/BankController.java +++ b/src/main/java/noppes/npcs/controllers/BankController.java @@ -13,152 +13,153 @@ import java.io.IOException; import java.util.HashMap; public class BankController { - public HashMap banks; - private String filePath = ""; + public HashMap banks; + private String filePath = ""; - private static BankController instance; - - public BankController(){ - instance = this; - banks = new HashMap(); - loadBanks(); + private static BankController instance; - if(banks.isEmpty()) - { - Bank bank = new Bank(); - bank.id = 0; - bank.name = "Default Bank"; - for(int i = 0;i < 6;i++) - bank.slotTypes.put(i, 0); - - banks.put(bank.id, bank); - } - } - public static BankController getInstance(){ - if(newInstance()){ - instance = new BankController(); - } - return instance; - } - - private static boolean newInstance() { - if(instance == null) - return true; - File file = CustomNpcs.getWorldSaveDirectory(); - if(file == null) - return false; - if(!instance.filePath.equals(file.getAbsolutePath())){ - return true; - } - - return false; - } - - private void loadBanks(){ - File saveDir = CustomNpcs.getWorldSaveDirectory(); - if(saveDir == null) - return; + public BankController() { + instance = this; + banks = new HashMap(); + loadBanks(); - filePath = saveDir.getAbsolutePath(); - - try { - File file = new File(saveDir, "bank.dat"); - if(file.exists()){ - loadBanks(file); - } - } catch (Exception e) { - try { - File file = new File(saveDir, "bank.dat_old"); - if(file.exists()){ - loadBanks(file); - } - - } catch (Exception ee) { - } - } - } - private void loadBanks(File file) throws IOException{ - loadBanks(CompressedStreamTools.readCompressed(new FileInputStream(file))); - } - - public void loadBanks(NBTTagCompound nbttagcompound1) throws IOException{ - HashMap banks = new HashMap(); - NBTTagList list = nbttagcompound1.getTagList("Data", 10); - if(list != null){ - for(int i = 0; i < list.tagCount(); i++) - { - NBTTagCompound nbttagcompound = list.getCompoundTagAt(i); - Bank bank = new Bank(); - bank.readEntityFromNBT(nbttagcompound); - banks.put(bank.id,bank); - } + if (banks.isEmpty()) { + Bank bank = new Bank(); + bank.id = 0; + bank.name = "Default Bank"; + for (int i = 0; i < 6; i++) + bank.slotTypes.put(i, 0); + + banks.put(bank.id, bank); } - this.banks = banks; - } + } - public NBTTagCompound getNBT(){ + public static BankController getInstance() { + if (newInstance()) { + instance = new BankController(); + } + return instance; + } + + private static boolean newInstance() { + if (instance == null) + return true; + File file = CustomNpcs.getWorldSaveDirectory(); + if (file == null) + return false; + if (!instance.filePath.equals(file.getAbsolutePath())) { + return true; + } + + return false; + } + + private void loadBanks() { + File saveDir = CustomNpcs.getWorldSaveDirectory(); + if (saveDir == null) + return; + + filePath = saveDir.getAbsolutePath(); + + try { + File file = new File(saveDir, "bank.dat"); + if (file.exists()) { + loadBanks(file); + } + } catch (Exception e) { + try { + File file = new File(saveDir, "bank.dat_old"); + if (file.exists()) { + loadBanks(file); + } + + } catch (Exception ee) { + } + } + } + + private void loadBanks(File file) throws IOException { + loadBanks(CompressedStreamTools.readCompressed(new FileInputStream(file))); + } + + public void loadBanks(NBTTagCompound nbttagcompound1) throws IOException { + HashMap banks = new HashMap(); + NBTTagList list = nbttagcompound1.getTagList("Data", 10); + if (list != null) { + for (int i = 0; i < list.tagCount(); i++) { + NBTTagCompound nbttagcompound = list.getCompoundTagAt(i); + Bank bank = new Bank(); + bank.readEntityFromNBT(nbttagcompound); + banks.put(bank.id, bank); + } + } + this.banks = banks; + } + + public NBTTagCompound getNBT() { NBTTagList list = new NBTTagList(); - for(Bank bank : banks.values()){ + for (Bank bank : banks.values()) { NBTTagCompound nbtfactions = new NBTTagCompound(); bank.writeEntityToNBT(nbtfactions); - list.appendTag(nbtfactions); + list.appendTag(nbtfactions); } NBTTagCompound nbttagcompound = new NBTTagCompound(); nbttagcompound.setTag("Data", list); return nbttagcompound; - } - public Bank getBank(int bankId) { - Bank bank = banks.get(bankId); - if(bank != null) - return bank; - return banks.values().iterator().next(); - } - public void saveBanks(){ - try { - File saveDir = CustomNpcs.getWorldSaveDirectory(); + } + + public Bank getBank(int bankId) { + Bank bank = banks.get(bankId); + if (bank != null) + return bank; + return banks.values().iterator().next(); + } + + public void saveBanks() { + try { + File saveDir = CustomNpcs.getWorldSaveDirectory(); File file = new File(saveDir, "bank.dat_new"); File file1 = new File(saveDir, "bank.dat_old"); File file2 = new File(saveDir, "bank.dat"); CompressedStreamTools.writeCompressed(getNBT(), new FileOutputStream(file)); - if(file1.exists()) - { + if (file1.exists()) { file1.delete(); } file2.renameTo(file1); - if(file2.exists()) - { + if (file2.exists()) { file2.delete(); } file.renameTo(file2); - if(file.exists()) - { + if (file.exists()) { file.delete(); } - } catch (Exception e) { - e.printStackTrace(); - } - } - public void saveBank(Bank bank) { - if(bank.id < 0){ - bank.id = getUnusedId(); - } - banks.put(bank.id, bank); - saveBanks(); - } - - public int getUnusedId(){ - int id = 0; - while(true){ - if(!banks.containsKey(id)) - return id; - id++; - } - } - public void removeBank(int bank) { - if(bank < 0 || banks.size() <= 1) - return; - banks.remove(bank); - saveBanks(); - } + } catch (Exception e) { + e.printStackTrace(); + } + } + + public void saveBank(Bank bank) { + if (bank.id < 0) { + bank.id = getUnusedId(); + } + banks.put(bank.id, bank); + saveBanks(); + } + + public int getUnusedId() { + int id = 0; + while (true) { + if (!banks.containsKey(id)) + return id; + id++; + } + } + + public void removeBank(int bank) { + if (bank < 0 || banks.size() <= 1) + return; + banks.remove(bank); + saveBanks(); + } } diff --git a/src/main/java/noppes/npcs/controllers/ChunkController.java b/src/main/java/noppes/npcs/controllers/ChunkController.java index 4bd97427d..32ad23bf1 100644 --- a/src/main/java/noppes/npcs/controllers/ChunkController.java +++ b/src/main/java/noppes/npcs/controllers/ChunkController.java @@ -17,73 +17,75 @@ import java.util.HashMap; import java.util.Iterator; import java.util.List; -public class ChunkController implements LoadingCallback{ - public static ChunkController Instance; - - public HashMap tickets = new HashMap(); - - public ChunkController(){ - Instance = this; - } +public class ChunkController implements LoadingCallback { + public static ChunkController Instance; - public void clear(){ - tickets = new HashMap(); - } + public HashMap tickets = new HashMap(); - public Ticket getTicket(EntityNPCInterface npc) { - Ticket ticket = tickets.get(npc); - if(ticket != null) - return ticket; - if(size() >= ConfigMain.ChunkLoaders) - return null; - ticket = ForgeChunkManager.requestTicket(CustomNpcs.instance, npc.worldObj, Type.ENTITY); - if(ticket == null) - return null; - ticket.bindEntity(npc); - ticket.setChunkListDepth(6); - tickets.put(npc, ticket); - return null; - } + public ChunkController() { + Instance = this; + } - public void deleteNPC(EntityNPCInterface npc) { - Ticket ticket = tickets.get(npc); - if(ticket != null){ - tickets.remove(npc); - ForgeChunkManager.releaseTicket(ticket); - } - } + public void clear() { + tickets = new HashMap(); + } - @Override - public void ticketsLoaded(List tickets, World world) { - for(Ticket ticket : tickets){ - if(!(ticket.getEntity() instanceof EntityNPCInterface)) - continue; - EntityNPCInterface npc = (EntityNPCInterface) ticket.getEntity(); - if(npc.advanced.job == EnumJobType.ChunkLoader && !tickets.contains(npc)){ - this.tickets.put(npc, ticket); - double x = npc.posX / 16; - double z = npc.posZ / 16; - - ForgeChunkManager.forceChunk(ticket, new ChunkCoordIntPair(MathHelper.floor_double(x), MathHelper.floor_double(z))); - ForgeChunkManager.forceChunk(ticket, new ChunkCoordIntPair(MathHelper.ceiling_double_int(x), MathHelper.ceiling_double_int(z))); - ForgeChunkManager.forceChunk(ticket, new ChunkCoordIntPair(MathHelper.floor_double(x), MathHelper.ceiling_double_int(z))); - ForgeChunkManager.forceChunk(ticket, new ChunkCoordIntPair(MathHelper.ceiling_double_int(x), MathHelper.floor_double(z))); - } - } - } - public int size() { - return tickets.size(); - } - public void unload(int toRemove) { - Iterator ite = tickets.keySet().iterator(); - int i = 0; - while(ite.hasNext()){ - if(i >= toRemove) - return; - Entity entity = ite.next(); - ForgeChunkManager.releaseTicket(tickets.get(entity)); - ite.remove(); - i++; - } - } + public Ticket getTicket(EntityNPCInterface npc) { + Ticket ticket = tickets.get(npc); + if (ticket != null) + return ticket; + if (size() >= ConfigMain.ChunkLoaders) + return null; + ticket = ForgeChunkManager.requestTicket(CustomNpcs.instance, npc.worldObj, Type.ENTITY); + if (ticket == null) + return null; + ticket.bindEntity(npc); + ticket.setChunkListDepth(6); + tickets.put(npc, ticket); + return null; + } + + public void deleteNPC(EntityNPCInterface npc) { + Ticket ticket = tickets.get(npc); + if (ticket != null) { + tickets.remove(npc); + ForgeChunkManager.releaseTicket(ticket); + } + } + + @Override + public void ticketsLoaded(List tickets, World world) { + for (Ticket ticket : tickets) { + if (!(ticket.getEntity() instanceof EntityNPCInterface)) + continue; + EntityNPCInterface npc = (EntityNPCInterface) ticket.getEntity(); + if (npc.advanced.job == EnumJobType.ChunkLoader && !tickets.contains(npc)) { + this.tickets.put(npc, ticket); + double x = npc.posX / 16; + double z = npc.posZ / 16; + + ForgeChunkManager.forceChunk(ticket, new ChunkCoordIntPair(MathHelper.floor_double(x), MathHelper.floor_double(z))); + ForgeChunkManager.forceChunk(ticket, new ChunkCoordIntPair(MathHelper.ceiling_double_int(x), MathHelper.ceiling_double_int(z))); + ForgeChunkManager.forceChunk(ticket, new ChunkCoordIntPair(MathHelper.floor_double(x), MathHelper.ceiling_double_int(z))); + ForgeChunkManager.forceChunk(ticket, new ChunkCoordIntPair(MathHelper.ceiling_double_int(x), MathHelper.floor_double(z))); + } + } + } + + public int size() { + return tickets.size(); + } + + public void unload(int toRemove) { + Iterator ite = tickets.keySet().iterator(); + int i = 0; + while (ite.hasNext()) { + if (i >= toRemove) + return; + Entity entity = ite.next(); + ForgeChunkManager.releaseTicket(tickets.get(entity)); + ite.remove(); + i++; + } + } } diff --git a/src/main/java/noppes/npcs/controllers/CustomEffectController.java b/src/main/java/noppes/npcs/controllers/CustomEffectController.java index f3fcf0ae7..6f2f33046 100644 --- a/src/main/java/noppes/npcs/controllers/CustomEffectController.java +++ b/src/main/java/noppes/npcs/controllers/CustomEffectController.java @@ -41,7 +41,7 @@ public class CustomEffectController implements ICustomEffectHandler { private int lastUsedID = 0; public ConcurrentHashMap> playerEffects = new ConcurrentHashMap<>(); - public CustomEffectController(){ + public CustomEffectController() { HashMap customEffects = new HashMap<>(); registerEffectMap(0, customEffects); } @@ -54,7 +54,7 @@ public class CustomEffectController implements ICustomEffectHandler { indexMapper.put(index, (HashMap) effectHashMap); } - public HashMap getCustomEffects(){ + public HashMap getCustomEffects() { return indexMapper.get(0); } @@ -349,8 +349,8 @@ public class CustomEffectController implements ICustomEffectHandler { saveEffectLoadMap(); } - public HashMap getEffectMap(int index){ - if(indexMapper.containsKey(index)){ + public HashMap getEffectMap(int index) { + if (indexMapper.containsKey(index)) { return getEffectMap(index); } return null; @@ -413,7 +413,8 @@ public class CustomEffectController implements ICustomEffectHandler { if (file.exists()) { loadCustomEffectMap(file); } - } catch (Exception ignored) {} + } catch (Exception ignored) { + } } } diff --git a/src/main/java/noppes/npcs/controllers/CustomGuiController.java b/src/main/java/noppes/npcs/controllers/CustomGuiController.java index 2e1423820..5c8b6d582 100644 --- a/src/main/java/noppes/npcs/controllers/CustomGuiController.java +++ b/src/main/java/noppes/npcs/controllers/CustomGuiController.java @@ -28,14 +28,14 @@ public class CustomGuiController { public static void openGui(IPlayer player, ScriptGui gui) { EntityPlayerMP entityPlayerMP = (EntityPlayerMP) player.getMCEntity(); entityPlayerMP.openGui(CustomNpcs.instance, EnumGuiType.CustomGui.ordinal(), player.getWorld().getMCWorld(), gui.getSlots().size(), 0, 0); - ((ContainerCustomGui)((EntityPlayerMP)player.getMCEntity()).openContainer).setGui(gui, (EntityPlayer)player.getMCEntity()); - GuiDataPacket.sendGuiData((EntityPlayerMP)player.getMCEntity(), gui.toNBT()); + ((ContainerCustomGui) ((EntityPlayerMP) player.getMCEntity()).openContainer).setGui(gui, (EntityPlayer) player.getMCEntity()); + GuiDataPacket.sendGuiData((EntityPlayerMP) player.getMCEntity(), gui.toNBT()); } public static boolean updateGui(IPlayer player, ScriptGui gui) { - if (((EntityPlayerMP)player.getMCEntity()).openContainer instanceof ContainerCustomGui) { - ((ContainerCustomGui)((EntityPlayerMP)player.getMCEntity()).openContainer).setGui(gui, (EntityPlayer)player.getMCEntity()); - GuiDataPacket.sendGuiData((EntityPlayerMP)player.getMCEntity(), gui.toNBT()); + if (((EntityPlayerMP) player.getMCEntity()).openContainer instanceof ContainerCustomGui) { + ((ContainerCustomGui) ((EntityPlayerMP) player.getMCEntity()).openContainer).setGui(gui, (EntityPlayer) player.getMCEntity()); + GuiDataPacket.sendGuiData((EntityPlayerMP) player.getMCEntity(), gui.toNBT()); return true; } else { return false; @@ -43,11 +43,11 @@ public class CustomGuiController { } public static void openOverlay(IPlayer player, ScriptOverlay gui) { - PacketHandler.Instance.sendToPlayer(new ScriptOverlayDataPacket(gui.toNBT()), (EntityPlayerMP)player.getMCEntity()); + PacketHandler.Instance.sendToPlayer(new ScriptOverlayDataPacket(gui.toNBT()), (EntityPlayerMP) player.getMCEntity()); } public static boolean updateOverlay(IPlayer player, ScriptOverlay gui) { - PacketHandler.Instance.sendToPlayer(new ScriptOverlayDataPacket(gui.toNBT()), (EntityPlayerMP)player.getMCEntity()); + PacketHandler.Instance.sendToPlayer(new ScriptOverlayDataPacket(gui.toNBT()), (EntityPlayerMP) player.getMCEntity()); return true; } @@ -56,17 +56,17 @@ public class CustomGuiController { if (!(player.openContainer instanceof ContainerCustomGui)) { return false; } else { - return ((ContainerCustomGui)player.openContainer).customGui.getID() == event.gui.getID(); + return ((ContainerCustomGui) player.openContainer).customGui.getID() == event.gui.getID(); } } public static IItemStack[] getSlotContents(EntityPlayer player) { IItemStack[] slotContents = new IItemStack[0]; if (player.openContainer instanceof ContainerCustomGui) { - ContainerCustomGui container = (ContainerCustomGui)player.openContainer; + ContainerCustomGui container = (ContainerCustomGui) player.openContainer; slotContents = new IItemStack[container.guiInventory.getSizeInventory()]; - for(int i = 0; i < container.guiInventory.getSizeInventory(); ++i) { + for (int i = 0; i < container.guiInventory.getSizeInventory(); ++i) { slotContents[i] = NpcAPI.Instance().getIItemStack(container.guiInventory.getStackInSlot(i)); } } @@ -94,7 +94,7 @@ public class CustomGuiController { public static boolean onSlotClick(CustomGuiEvent.SlotClickEvent event) { EntityPlayer player = (EntityPlayer) event.player.getMCEntity(); - if(checkGui(event) && getOpenGui(player).getScriptHandler()!=null) { + if (checkGui(event) && getOpenGui(player).getScriptHandler() != null) { (getOpenGui(player).getScriptHandler()).callScript(EnumScriptType.CUSTOM_GUI_SLOT_CLICKED, event); } return NpcAPI.EVENT_BUS.post(event); @@ -127,7 +127,7 @@ public class CustomGuiController { } public static ScriptGui getOpenGui(EntityPlayer player) { - return player.openContainer instanceof ContainerCustomGui ? ((ContainerCustomGui)player.openContainer).customGui : null; + return player.openContainer instanceof ContainerCustomGui ? ((ContainerCustomGui) player.openContainer).customGui : null; } public static String[] readScrollSelection(ByteBuf buffer) { @@ -135,7 +135,7 @@ public class CustomGuiController { NBTTagList list = ByteBufUtils.readNBT(buffer).getTagList("selection", 8); String[] selection = new String[list.tagCount()]; - for(int i = 0; i < list.tagCount(); ++i) { + for (int i = 0; i < list.tagCount(); ++i) { selection[i] = list.getStringTagAt(i); } diff --git a/src/main/java/noppes/npcs/controllers/DialogController.java b/src/main/java/noppes/npcs/controllers/DialogController.java index a892f934c..3faf29b62 100644 --- a/src/main/java/noppes/npcs/controllers/DialogController.java +++ b/src/main/java/noppes/npcs/controllers/DialogController.java @@ -22,318 +22,317 @@ import java.io.FileInputStream; import java.util.*; public class DialogController implements IDialogHandler { - public HashMap categoriesSync = new HashMap(); - public HashMap categories = new HashMap(); - public HashMap dialogs = new HashMap(); - public static DialogController Instance = new DialogController();; + public HashMap categoriesSync = new HashMap(); + public HashMap categories = new HashMap(); + public HashMap dialogs = new HashMap(); + public static DialogController Instance = new DialogController(); + ; - private int lastUsedDialogID = 0; - private int lastUsedCatID = 0; + private int lastUsedDialogID = 0; + private int lastUsedCatID = 0; - public DialogController(){ - Instance = this; - } + public DialogController() { + Instance = this; + } - public void load(){ - LogWriter.info("Loading Dialogs"); - loadCategories(); - LogWriter.info("Done loading Dialogs"); - } + public void load() { + LogWriter.info("Loading Dialogs"); + loadCategories(); + LogWriter.info("Done loading Dialogs"); + } - private void loadCategories(){ - categories.clear(); - dialogs.clear(); + private void loadCategories() { + categories.clear(); + dialogs.clear(); - lastUsedCatID = 0; - lastUsedDialogID = 0; + lastUsedCatID = 0; + lastUsedDialogID = 0; - try { - File file = new File(CustomNpcs.getWorldSaveDirectory(), "dialog.dat"); - if(file.exists()){ - loadCategoriesOld(file); - file.delete(); - file = new File(CustomNpcs.getWorldSaveDirectory(), "dialog.dat_old"); - if(file.exists()) - file.delete(); - return; - } - } catch (Exception e) { - LogWriter.except(e); - } + try { + File file = new File(CustomNpcs.getWorldSaveDirectory(), "dialog.dat"); + if (file.exists()) { + loadCategoriesOld(file); + file.delete(); + file = new File(CustomNpcs.getWorldSaveDirectory(), "dialog.dat_old"); + if (file.exists()) + file.delete(); + return; + } + } catch (Exception e) { + LogWriter.except(e); + } - File dir = getDir(); - if(!dir.exists()){ - dir.mkdir(); - loadDefaultDialogs(); - } - else{ - for(File file : dir.listFiles()){ - if(!file.isDirectory()) - continue; - DialogCategory category = loadCategoryDir(file); - Iterator ite = category.dialogs.keySet().iterator(); - while(ite.hasNext()){ - int id = ite.next(); - if(id > lastUsedDialogID) - lastUsedDialogID = id; - Dialog dialog = category.dialogs.get(id); - if(dialogs.containsKey(id)){ - LogWriter.error("Duplicate id " + dialog.id + " from category " + category.title); - ite.remove(); - } - else{ - dialogs.put(id, dialog); - } - } - lastUsedCatID++; - category.id = lastUsedCatID; - categories.put(category.id, category); - } - } - } + File dir = getDir(); + if (!dir.exists()) { + dir.mkdir(); + loadDefaultDialogs(); + } else { + for (File file : dir.listFiles()) { + if (!file.isDirectory()) + continue; + DialogCategory category = loadCategoryDir(file); + Iterator ite = category.dialogs.keySet().iterator(); + while (ite.hasNext()) { + int id = ite.next(); + if (id > lastUsedDialogID) + lastUsedDialogID = id; + Dialog dialog = category.dialogs.get(id); + if (dialogs.containsKey(id)) { + LogWriter.error("Duplicate id " + dialog.id + " from category " + category.title); + ite.remove(); + } else { + dialogs.put(id, dialog); + } + } + lastUsedCatID++; + category.id = lastUsedCatID; + categories.put(category.id, category); + } + } + } - private DialogCategory loadCategoryDir(File dir) { - DialogCategory category = new DialogCategory(); - category.title = dir.getName(); - for(File file : dir.listFiles()){ - if(!file.isFile() || !file.getName().endsWith(".json")) - continue; - try{ - Dialog dialog = new Dialog(); - dialog.id = Integer.parseInt(file.getName().substring(0, file.getName().length() - 5)); - dialog.readNBTPartial(NBTJsonUtil.LoadFile(file)); - category.dialogs.put(dialog.id, dialog); - dialog.category = category; + private DialogCategory loadCategoryDir(File dir) { + DialogCategory category = new DialogCategory(); + category.title = dir.getName(); + for (File file : dir.listFiles()) { + if (!file.isFile() || !file.getName().endsWith(".json")) + continue; + try { + Dialog dialog = new Dialog(); + dialog.id = Integer.parseInt(file.getName().substring(0, file.getName().length() - 5)); + dialog.readNBTPartial(NBTJsonUtil.LoadFile(file)); + category.dialogs.put(dialog.id, dialog); + dialog.category = category; if (dialog.text != null && dialog.text.length() > 15000) { LogWriter.error("Extremely big dialog loaded: [ID: " + dialog.id + "] Title: " + dialog.title + " (Length: " + dialog.text.length() + " chars)"); } - } - catch(Exception e){ - LogWriter.error("Error loading: " + file.getAbsolutePath(), e); - } - } - return category; - } + } catch (Exception e) { + LogWriter.error("Error loading: " + file.getAbsolutePath(), e); + } + } + return category; + } - private void loadCategoriesOld(File file) throws Exception{ - File dir = getDir(); - if(!dir.exists()){ - dir.mkdir(); - } + private void loadCategoriesOld(File file) throws Exception { + File dir = getDir(); + if (!dir.exists()) { + dir.mkdir(); + } NBTTagCompound nbttagcompound1 = CompressedStreamTools.readCompressed(new FileInputStream(file)); NBTTagList list = nbttagcompound1.getTagList("Data", 10); - if(list == null) - return; + if (list == null) + return; - for(int i = 0; i < list.tagCount(); i++){ + for (int i = 0; i < list.tagCount(); i++) { DialogCategory category = new DialogCategory(); category.readNBT(list.getCompoundTagAt(i)); saveCategory(category); Iterator> ita = category.dialogs.entrySet().iterator(); - while(ita.hasNext()){ - Map.Entry entry = ita.next(); - Dialog dialog = entry.getValue(); - dialog.id = entry.getKey(); - dialog.category = category; - if(dialogs.containsKey(dialog.id)) - ita.remove(); - else{ - saveDialog(category.id, dialog); - } + while (ita.hasNext()) { + Map.Entry entry = ita.next(); + Dialog dialog = entry.getValue(); + dialog.id = entry.getKey(); + dialog.category = category; + if (dialogs.containsKey(dialog.id)) + ita.remove(); + else { + saveDialog(category.id, dialog); + } } } - } + } - private void loadDefaultDialogs() { - DialogCategory cat = new DialogCategory(); - cat.id = lastUsedCatID++; - cat.title = "Villager"; + private void loadDefaultDialogs() { + DialogCategory cat = new DialogCategory(); + cat.id = lastUsedCatID++; + cat.title = "Villager"; - Dialog dia1 = new Dialog(); - dia1.id = 1; - dia1.category = cat; - dia1.title = "Start"; - dia1.text = "Hello {player}, "+'\n'+'\n'+"Welcome to our village. I hope you enjoy your stay"; + Dialog dia1 = new Dialog(); + dia1.id = 1; + dia1.category = cat; + dia1.title = "Start"; + dia1.text = "Hello {player}, " + '\n' + '\n' + "Welcome to our village. I hope you enjoy your stay"; - Dialog dia2 = new Dialog(); - dia2.id = 2; - dia2.category = cat; - dia2.title = "Ask about village"; - dia2.text = "This village has been around for ages. Enjoy your stay here."; + Dialog dia2 = new Dialog(); + dia2.id = 2; + dia2.category = cat; + dia2.title = "Ask about village"; + dia2.text = "This village has been around for ages. Enjoy your stay here."; - Dialog dia3 = new Dialog(); - dia3.id = 3; - dia3.category = cat; - dia3.title = "Who are you"; - dia3.text = "I'm a villager here. I have lived in this village my whole life."; + Dialog dia3 = new Dialog(); + dia3.id = 3; + dia3.category = cat; + dia3.title = "Who are you"; + dia3.text = "I'm a villager here. I have lived in this village my whole life."; - cat.dialogs.put(dia1.id, dia1); - cat.dialogs.put(dia2.id, dia2); - cat.dialogs.put(dia3.id, dia3); + cat.dialogs.put(dia1.id, dia1); + cat.dialogs.put(dia2.id, dia2); + cat.dialogs.put(dia3.id, dia3); - DialogOption option = new DialogOption(); - option.title = "Tell me something about this village"; - option.dialogId = 2; - option.optionType = EnumOptionType.DialogOption; + DialogOption option = new DialogOption(); + option.title = "Tell me something about this village"; + option.dialogId = 2; + option.optionType = EnumOptionType.DialogOption; - DialogOption option2 = new DialogOption(); - option2.title = "Who are you?"; - option2.dialogId = 3; - option2.optionType = EnumOptionType.DialogOption; + DialogOption option2 = new DialogOption(); + option2.title = "Who are you?"; + option2.dialogId = 3; + option2.optionType = EnumOptionType.DialogOption; - DialogOption option3 = new DialogOption(); - option3.title = "Goodbye"; - option3.optionType = EnumOptionType.QuitOption; + DialogOption option3 = new DialogOption(); + option3.title = "Goodbye"; + option3.optionType = EnumOptionType.QuitOption; - dia1.options.put(0, option2); - dia1.options.put(1, option); - dia1.options.put(2, option3); + dia1.options.put(0, option2); + dia1.options.put(1, option); + dia1.options.put(2, option3); - DialogOption option4 = new DialogOption(); - option4.title = "Back"; - option4.dialogId = 1; + DialogOption option4 = new DialogOption(); + option4.title = "Back"; + option4.dialogId = 1; - dia2.options.put(1, option4); - dia3.options.put(1, option4); - lastUsedDialogID = 3; - saveCategory(cat); - saveDialog(cat.id, dia1); - saveDialog(cat.id, dia2); - saveDialog(cat.id, dia3); - } + dia2.options.put(1, option4); + dia3.options.put(1, option4); + lastUsedDialogID = 3; + saveCategory(cat); + saveDialog(cat.id, dia1); + saveDialog(cat.id, dia2); + saveDialog(cat.id, dia3); + } - public void saveCategory(DialogCategory category){ - category.title = NoppesStringUtils.cleanFileName(category.title); - if(categories.containsKey(category.id)){ - DialogCategory currentCategory = categories.get(category.id); - if(!currentCategory.title.equals(category.title)){ - while(containsCategoryName(category.title)) - category.title += "_"; - File newdir = new File(getDir(), category.title); - File olddir = new File(getDir(), currentCategory.title); - if(newdir.exists()) - return; - if(!olddir.renameTo(newdir)) - return; - } - category.dialogs = currentCategory.dialogs; - } - else{ - if(category.id < 0){ - lastUsedCatID++; - category.id = lastUsedCatID; - } - while(containsCategoryName(category.title)) - category.title += "_"; - File dir = new File(getDir(), category.title); - if(!dir.exists()) - dir.mkdirs(); - } - categories.put(category.id, category); + public void saveCategory(DialogCategory category) { + category.title = NoppesStringUtils.cleanFileName(category.title); + if (categories.containsKey(category.id)) { + DialogCategory currentCategory = categories.get(category.id); + if (!currentCategory.title.equals(category.title)) { + while (containsCategoryName(category.title)) + category.title += "_"; + File newdir = new File(getDir(), category.title); + File olddir = new File(getDir(), currentCategory.title); + if (newdir.exists()) + return; + if (!olddir.renameTo(newdir)) + return; + } + category.dialogs = currentCategory.dialogs; + } else { + if (category.id < 0) { + lastUsedCatID++; + category.id = lastUsedCatID; + } + while (containsCategoryName(category.title)) + category.title += "_"; + File dir = new File(getDir(), category.title); + if (!dir.exists()) + dir.mkdirs(); + } + categories.put(category.id, category); SyncController.syncUpdate(EnumSyncType.DIALOG_CATEGORY, -1, SyncController.updateDialogCat(category)); - } + } - public void removeCategory(int category){ - DialogCategory cat = categories.get(category); - if(cat == null) - return; - File dir = new File(getDir(), cat.title); - if(!dir.delete()) - return; - for(int dia : cat.dialogs.keySet()) - dialogs.remove(dia); - categories.remove(category); + public void removeCategory(int category) { + DialogCategory cat = categories.get(category); + if (cat == null) + return; + File dir = new File(getDir(), cat.title); + if (!dir.delete()) + return; + for (int dia : cat.dialogs.keySet()) + dialogs.remove(dia); + categories.remove(category); SyncController.syncRemove(EnumSyncType.DIALOG_CATEGORY, category); } - private boolean containsCategoryName(String name) { - name = name.toLowerCase(); - for(DialogCategory cat : categories.values()){ - if(cat.title.toLowerCase().equals(name)) - return true; - } - return false; - } - private boolean containsDialogName(DialogCategory category, Dialog dialog) { - for(Dialog dia : category.dialogs.values()){ - if(dia.id != dialog.id && dia.title.equalsIgnoreCase(dialog.title)) - return true; - } - return false; - } - public Dialog saveDialog(int categoryId, Dialog dialog){ - DialogCategory category = categories.get(categoryId); - if(category == null) - return dialog; - dialog.category = category; + private boolean containsCategoryName(String name) { + name = name.toLowerCase(); + for (DialogCategory cat : categories.values()) { + if (cat.title.toLowerCase().equals(name)) + return true; + } + return false; + } - while(containsDialogName(dialog.category, dialog)){ - dialog.title = dialog.title + "_"; - } - if(dialog.id < 0){ - lastUsedDialogID++; - dialog.id = lastUsedDialogID; - } + private boolean containsDialogName(DialogCategory category, Dialog dialog) { + for (Dialog dia : category.dialogs.values()) { + if (dia.id != dialog.id && dia.title.equalsIgnoreCase(dialog.title)) + return true; + } + return false; + } - dialogs.put(dialog.id, dialog); - category.dialogs.put(dialog.id, dialog); + public Dialog saveDialog(int categoryId, Dialog dialog) { + DialogCategory category = categories.get(categoryId); + if (category == null) + return dialog; + dialog.category = category; - File dir = new File(getDir(), category.title); - if(!dir.exists()) - dir.mkdirs(); + while (containsDialogName(dialog.category, dialog)) { + dialog.title = dialog.title + "_"; + } + if (dialog.id < 0) { + lastUsedDialogID++; + dialog.id = lastUsedDialogID; + } - File file = new File(dir, dialog.id + ".json_new"); - File file2 = new File(dir, dialog.id + ".json"); + dialogs.put(dialog.id, dialog); + category.dialogs.put(dialog.id, dialog); - try { + File dir = new File(getDir(), category.title); + if (!dir.exists()) + dir.mkdirs(); + + File file = new File(dir, dialog.id + ".json_new"); + File file2 = new File(dir, dialog.id + ".json"); + + try { NBTTagCompound compound = dialog.writeToNBTPartial(new NBTTagCompound()); - NBTJsonUtil.SaveFile(file, compound); - if(file2.exists()) - file2.delete(); - file.renameTo(file2); + NBTJsonUtil.SaveFile(file, compound); + if (file2.exists()) + file2.delete(); + file.renameTo(file2); SyncController.syncUpdate(EnumSyncType.DIALOG, category.id, dialog.writeToNBT(new NBTTagCompound())); - } catch (Exception e) { - LogWriter.except(e); - } - return dialog; - } + } catch (Exception e) { + LogWriter.except(e); + } + return dialog; + } - public void removeDialog(Dialog dialog) { - DialogCategory category = dialog.category; - File file = new File(new File(getDir(), category.title), dialog.id + ".json"); - if(!file.delete()) - return; - category.dialogs.remove(dialog.id); - dialogs.remove(dialog.id); + public void removeDialog(Dialog dialog) { + DialogCategory category = dialog.category; + File file = new File(new File(getDir(), category.title), dialog.id + ".json"); + if (!file.delete()) + return; + category.dialogs.remove(dialog.id); + dialogs.remove(dialog.id); SyncController.syncRemove(EnumSyncType.DIALOG, dialog.id); - } + } - private File getDir(){ - return new File(CustomNpcs.getWorldSaveDirectory(), "dialogs"); - } + private File getDir() { + return new File(CustomNpcs.getWorldSaveDirectory(), "dialogs"); + } - public boolean hasDialog(int dialogId) { - return dialogs.containsKey(dialogId); - } + public boolean hasDialog(int dialogId) { + return dialogs.containsKey(dialogId); + } - public Map getScroll() { - Map map = new HashMap(); - for(DialogCategory category : categories.values()){ - map.put(category.title, category.id); - } - return map; - } + public Map getScroll() { + Map map = new HashMap(); + for (DialogCategory category : categories.values()) { + map.put(category.title, category.id); + } + return map; + } - public List categories() { - return new ArrayList(this.categories.values()); - } + public List categories() { + return new ArrayList(this.categories.values()); + } - public IDialog get(int id) { - return (IDialog)this.dialogs.get(id); - } + public IDialog get(int id) { + return (IDialog) this.dialogs.get(id); + } } diff --git a/src/main/java/noppes/npcs/controllers/FactionController.java b/src/main/java/noppes/npcs/controllers/FactionController.java index 9ab4b6311..995fddd13 100644 --- a/src/main/java/noppes/npcs/controllers/FactionController.java +++ b/src/main/java/noppes/npcs/controllers/FactionController.java @@ -19,218 +19,218 @@ import java.util.Map; import java.util.zip.GZIPInputStream; public class FactionController implements IFactionHandler { - public HashMap factionsSync = new HashMap(); - public HashMap factions; + public HashMap factionsSync = new HashMap(); + public HashMap factions; - private static FactionController instance = new FactionController(); + private static FactionController instance = new FactionController(); - private int lastUsedID = 0; + private int lastUsedID = 0; - public FactionController(){ - instance = this; - factions = new HashMap(); - } + public FactionController() { + instance = this; + factions = new HashMap(); + } - public static FactionController getInstance(){ - return instance; - } + public static FactionController getInstance() { + return instance; + } - public Faction getFaction(int faction) { - return factions.get(faction); - } + public Faction getFaction(int faction) { + return factions.get(faction); + } - public void load(){ + public void load() { factions = new HashMap(); lastUsedID = 0; - File saveDir = CustomNpcs.getWorldSaveDirectory(); - if(saveDir == null){ - return; - } - try { - File file = new File(saveDir, "factions.dat"); - if(file.exists()){ - loadFactionsFile(file); - } - } catch (Exception e) { - try { - File file = new File(saveDir, "factions.dat_old"); - if(file.exists()){ - loadFactionsFile(file); - } - - } catch (Exception ee) { - } - } - - if(factions.isEmpty()){ - factions.put(0,new Faction(0,"Friendly", 0x00DD00, 2000)); - factions.put(1,new Faction(1,"Neutral", 0xF2DD00, 1000)); - factions.put(2,new Faction(2,"Aggressive", 0xDD0000, 0)); + File saveDir = CustomNpcs.getWorldSaveDirectory(); + if (saveDir == null) { + return; } - } + try { + File file = new File(saveDir, "factions.dat"); + if (file.exists()) { + loadFactionsFile(file); + } + } catch (Exception e) { + try { + File file = new File(saveDir, "factions.dat_old"); + if (file.exists()) { + loadFactionsFile(file); + } - private void loadFactionsFile(File file) throws IOException{ - DataInputStream var1 = new DataInputStream(new BufferedInputStream(new GZIPInputStream(new FileInputStream(file)))); - loadFactions(var1); - var1.close(); - } + } catch (Exception ee) { + } + } - public void loadFactions(DataInputStream stream) throws IOException{ - HashMap factions = new HashMap(); - NBTTagCompound nbttagcompound1 = CompressedStreamTools.read(stream); - lastUsedID = nbttagcompound1.getInteger("lastID"); - NBTTagList list = nbttagcompound1.getTagList("NPCFactions", 10); + if (factions.isEmpty()) { + factions.put(0, new Faction(0, "Friendly", 0x00DD00, 2000)); + factions.put(1, new Faction(1, "Neutral", 0xF2DD00, 1000)); + factions.put(2, new Faction(2, "Aggressive", 0xDD0000, 0)); + } + } - if(list != null){ - for(int i = 0; i < list.tagCount(); i++) - { - NBTTagCompound nbttagcompound = list.getCompoundTagAt(i); - Faction faction = new Faction(); - faction.readNBT(nbttagcompound); - factions.put(faction.id,faction); - } - } - this.factions = factions; - } - public NBTTagCompound getNBT(){ - NBTTagList list = new NBTTagList(); - for(int slot : factions.keySet()){ - Faction faction = factions.get(slot); - NBTTagCompound nbtfactions = new NBTTagCompound(); - faction.writeNBT(nbtfactions); - list.appendTag(nbtfactions); - } - NBTTagCompound nbttagcompound = new NBTTagCompound(); - nbttagcompound.setInteger("lastID", lastUsedID); - nbttagcompound.setTag("NPCFactions", list); - return nbttagcompound; - } - public void saveFactions(){ - try { - File saveDir = CustomNpcs.getWorldSaveDirectory(); - File file = new File(saveDir, "factions.dat_new"); - File file1 = new File(saveDir, "factions.dat_old"); - File file2 = new File(saveDir, "factions.dat"); - CompressedStreamTools.writeCompressed(getNBT(), new FileOutputStream(file)); - if(file1.exists()) - { - file1.delete(); - } - file2.renameTo(file1); - if(file2.exists()) - { - file2.delete(); - } - file.renameTo(file2); - if(file.exists()) - { - file.delete(); - } - } catch (Exception e) { - LogWriter.except(e); - } - } + private void loadFactionsFile(File file) throws IOException { + DataInputStream var1 = new DataInputStream(new BufferedInputStream(new GZIPInputStream(new FileInputStream(file)))); + loadFactions(var1); + var1.close(); + } - public Faction get(int faction) { - return factions.get(faction); - } + public void loadFactions(DataInputStream stream) throws IOException { + HashMap factions = new HashMap(); + NBTTagCompound nbttagcompound1 = CompressedStreamTools.read(stream); + lastUsedID = nbttagcompound1.getInteger("lastID"); + NBTTagList list = nbttagcompound1.getTagList("NPCFactions", 10); - public List list() { - return new ArrayList(this.factions.values()); - } + if (list != null) { + for (int i = 0; i < list.tagCount(); i++) { + NBTTagCompound nbttagcompound = list.getCompoundTagAt(i); + Faction faction = new Faction(); + faction.readNBT(nbttagcompound); + factions.put(faction.id, faction); + } + } + this.factions = factions; + } - public void saveFaction(Faction faction) { + public NBTTagCompound getNBT() { + NBTTagList list = new NBTTagList(); + for (int slot : factions.keySet()) { + Faction faction = factions.get(slot); + NBTTagCompound nbtfactions = new NBTTagCompound(); + faction.writeNBT(nbtfactions); + list.appendTag(nbtfactions); + } + NBTTagCompound nbttagcompound = new NBTTagCompound(); + nbttagcompound.setInteger("lastID", lastUsedID); + nbttagcompound.setTag("NPCFactions", list); + return nbttagcompound; + } - if(faction.id < 0){ - faction.id = getUnusedId(); - while(hasName(faction.name)) - faction.name += "_"; - } - else{ - Faction existing = factions.get(faction.id); - if(existing != null && !existing.name.equals(faction.name)) - while(hasName(faction.name)) - faction.name += "_"; - } - factions.remove(faction.id); - factions.put(faction.id, faction); + public void saveFactions() { + try { + File saveDir = CustomNpcs.getWorldSaveDirectory(); + File file = new File(saveDir, "factions.dat_new"); + File file1 = new File(saveDir, "factions.dat_old"); + File file2 = new File(saveDir, "factions.dat"); + CompressedStreamTools.writeCompressed(getNBT(), new FileOutputStream(file)); + if (file1.exists()) { + file1.delete(); + } + file2.renameTo(file1); + if (file2.exists()) { + file2.delete(); + } + file.renameTo(file2); + if (file.exists()) { + file.delete(); + } + } catch (Exception e) { + LogWriter.except(e); + } + } + + public Faction get(int faction) { + return factions.get(faction); + } + + public List list() { + return new ArrayList(this.factions.values()); + } + + public void saveFaction(Faction faction) { + + if (faction.id < 0) { + faction.id = getUnusedId(); + while (hasName(faction.name)) + faction.name += "_"; + } else { + Faction existing = factions.get(faction.id); + if (existing != null && !existing.name.equals(faction.name)) + while (hasName(faction.name)) + faction.name += "_"; + } + factions.remove(faction.id); + factions.put(faction.id, faction); NBTTagCompound facCompound = new NBTTagCompound(); faction.writeNBT(facCompound); SyncController.syncUpdate(EnumSyncType.FACTION, -1, facCompound); - saveFactions(); - } + saveFactions(); + } - public Faction create(Faction faction) { - this.saveFaction(faction); - return faction; - } + public Faction create(Faction faction) { + this.saveFaction(faction); + return faction; + } - public Faction create(String name, int color) { - Faction faction = new Faction(); - faction.name = name; - faction.color = color; - this.saveFaction(faction); - return faction; - } + public Faction create(String name, int color) { + Faction faction = new Faction(); + faction.name = name; + faction.color = color; + this.saveFaction(faction); + return faction; + } - public int getUnusedId(){ - if(lastUsedID == 0){ - for(int catid : factions.keySet()) - if(catid > lastUsedID) - lastUsedID = catid; - } - lastUsedID++; - return lastUsedID; - } - public IFaction delete(int id) { - if (id >= 0 && this.factions.size() > 1) { - Faction faction = (Faction)this.factions.remove(id); - saveFactions(); - if (faction == null) { - return null; - } else { - this.saveFactions(); - faction.id = -1; + public int getUnusedId() { + if (lastUsedID == 0) { + for (int catid : factions.keySet()) + if (catid > lastUsedID) + lastUsedID = catid; + } + lastUsedID++; + return lastUsedID; + } + + public IFaction delete(int id) { + if (id >= 0 && this.factions.size() > 1) { + Faction faction = (Faction) this.factions.remove(id); + saveFactions(); + if (faction == null) { + return null; + } else { + this.saveFactions(); + faction.id = -1; SyncController.syncRemove(EnumSyncType.FACTION, id); - return faction; - } - } else { - return null; - } - } + return faction; + } + } else { + return null; + } + } - public int getFirstFactionId() { - return factions.keySet().iterator().next(); - } - public Faction getFirstFaction() { - return factions.values().iterator().next(); - } - public boolean hasName(String newName) { - if(newName.trim().isEmpty()) - return true; - for(Faction faction : factions.values()) - if(faction.name.equals(newName)) - return true; - return false; - } + public int getFirstFactionId() { + return factions.keySet().iterator().next(); + } - public Faction getFactionFromName(String factioname){ - for (Map.Entryentryfaction:FactionController.getInstance().factions.entrySet()){ - if (entryfaction.getValue().name.equalsIgnoreCase(factioname)){ - return entryfaction.getValue(); - } - } - return null; - } + public Faction getFirstFaction() { + return factions.values().iterator().next(); + } - public String[] getNames() { - String[] names = new String[factions.size()]; - int i = 0; - for(Faction faction : factions.values()){ - names[i] = faction.name.toLowerCase(); - i++; - } - return names; - } + public boolean hasName(String newName) { + if (newName.trim().isEmpty()) + return true; + for (Faction faction : factions.values()) + if (faction.name.equals(newName)) + return true; + return false; + } + + public Faction getFactionFromName(String factioname) { + for (Map.Entry entryfaction : FactionController.getInstance().factions.entrySet()) { + if (entryfaction.getValue().name.equalsIgnoreCase(factioname)) { + return entryfaction.getValue(); + } + } + return null; + } + + public String[] getNames() { + String[] names = new String[factions.size()]; + int i = 0; + for (Faction faction : factions.values()) { + names[i] = faction.name.toLowerCase(); + i++; + } + return names; + } } diff --git a/src/main/java/noppes/npcs/controllers/GlobalDataController.java b/src/main/java/noppes/npcs/controllers/GlobalDataController.java index efb1e0417..49a5c2e9b 100644 --- a/src/main/java/noppes/npcs/controllers/GlobalDataController.java +++ b/src/main/java/noppes/npcs/controllers/GlobalDataController.java @@ -11,38 +11,40 @@ import java.io.FileOutputStream; import static noppes.npcs.util.CustomNPCsThreader.customNPCThread; public class GlobalDataController { - public static GlobalDataController Instance; - private int itemGiverId = 0; + public static GlobalDataController Instance; + private int itemGiverId = 0; - public GlobalDataController(){ - Instance = this; - load(); - } + public GlobalDataController() { + Instance = this; + load(); + } - private void load(){ - File saveDir = CustomNpcs.getWorldSaveDirectory(); - try { - File file = new File(saveDir, "global.dat"); - if(file.exists()){ - loadData(file); - } - } catch (Exception e) { - try { - File file = new File(saveDir, "global.dat_old"); - if(file.exists()){ - loadData(file); - } + private void load() { + File saveDir = CustomNpcs.getWorldSaveDirectory(); + try { + File file = new File(saveDir, "global.dat"); + if (file.exists()) { + loadData(file); + } + } catch (Exception e) { + try { + File file = new File(saveDir, "global.dat_old"); + if (file.exists()) { + loadData(file); + } - } catch (Exception ee) { - ee.printStackTrace(); - } - } - } - private void loadData(File file) throws Exception { + } catch (Exception ee) { + ee.printStackTrace(); + } + } + } + + private void loadData(File file) throws Exception { NBTTagCompound nbttagcompound1 = CompressedStreamTools.readCompressed(new FileInputStream(file)); itemGiverId = nbttagcompound1.getInteger("itemGiverId"); - } - public void saveData(){ + } + + public void saveData() { customNPCThread.execute(() -> { try { File saveDir = CustomNpcs.getWorldSaveDirectory(); @@ -54,28 +56,26 @@ public class GlobalDataController { File file1 = new File(saveDir, "global.dat_old"); File file2 = new File(saveDir, "global.dat"); CompressedStreamTools.writeCompressed(nbttagcompound, new FileOutputStream(file)); - if(file1.exists()) - { + if (file1.exists()) { file1.delete(); } file2.renameTo(file1); - if(file2.exists()) - { + if (file2.exists()) { file2.delete(); } file.renameTo(file2); - if(file.exists()) - { + if (file.exists()) { file.delete(); } } catch (Exception e) { e.printStackTrace(); } }); - } - public int incrementItemGiverId(){ - itemGiverId++; + } + + public int incrementItemGiverId() { + itemGiverId++; saveData(); - return itemGiverId; - } + return itemGiverId; + } } diff --git a/src/main/java/noppes/npcs/controllers/LinkedItemController.java b/src/main/java/noppes/npcs/controllers/LinkedItemController.java index 117f497b5..efd4b0bd9 100644 --- a/src/main/java/noppes/npcs/controllers/LinkedItemController.java +++ b/src/main/java/noppes/npcs/controllers/LinkedItemController.java @@ -25,7 +25,8 @@ public class LinkedItemController { private HashMap bootOrder; - private LinkedItemController() {} + private LinkedItemController() { + } public static LinkedItemController getInstance() { if (Instance == null) { @@ -33,6 +34,7 @@ public class LinkedItemController { } return Instance; } + public LinkedItem createItem(String name) { return new LinkedItem(name); } @@ -90,7 +92,7 @@ public class LinkedItemController { //////////////////////////////////////////////////////// //////////////////////////////////////////////////////// - public void load(){ + public void load() { bootOrder = new HashMap<>(); linkedItems = new HashMap<>(); LogWriter.info("Loading linked items..."); @@ -99,7 +101,7 @@ public class LinkedItemController { LogWriter.info("Done loading linked items."); } - private void loadLinkedItems(){ + private void loadLinkedItems() { linkedItems.clear(); File dir = getDir(); @@ -114,28 +116,28 @@ public class LinkedItemController { linkedItem.readFromNBT(NBTJsonUtil.LoadFile(file)); linkedItem.name = file.getName().substring(0, file.getName().length() - 5); - if(linkedItem.id == -1){ + if (linkedItem.id == -1) { linkedItem.id = getUnusedId(); } int originalID = linkedItem.id; int setID = linkedItem.id; - while (bootOrder.containsKey(setID) || linkedItems.containsKey(setID)){ - if(bootOrder.containsKey(setID)) - if(bootOrder.get(setID).equals(linkedItem.name)) + while (bootOrder.containsKey(setID) || linkedItems.containsKey(setID)) { + if (bootOrder.containsKey(setID)) + if (bootOrder.get(setID).equals(linkedItem.name)) break; setID++; } linkedItem.id = setID; - if(originalID != setID){ + if (originalID != setID) { LogWriter.info("Found Linked Item ID Mismatch: " + linkedItem.name + ", New ID: " + setID); linkedItem.save(); } linkedItems.put(linkedItem.id, linkedItem); - } catch(Exception e) { + } catch (Exception e) { LogWriter.error("Error loading: " + file.getAbsolutePath(), e); } } @@ -148,10 +150,10 @@ public class LinkedItemController { return new File(CustomNpcs.getWorldSaveDirectory(), "linkeditems"); } - public int getUnusedId(){ - if(lastUsedID == 0){ - for(int catid : linkedItems.keySet()){ - if(catid > lastUsedID) + public int getUnusedId() { + if (lastUsedID == 0) { + for (int catid : linkedItems.keySet()) { + if (catid > lastUsedID) lastUsedID = catid; } @@ -161,15 +163,15 @@ public class LinkedItemController { } public boolean hasName(String newName) { - if(newName.trim().isEmpty()) + if (newName.trim().isEmpty()) return true; - for(LinkedItem linkedItem : linkedItems.values()) - if(linkedItem.name.equals(newName)) + for (LinkedItem linkedItem : linkedItems.values()) + if (linkedItem.name.equals(newName)) return true; return false; } - public ILinkedItem saveLinkedItem(ILinkedItem linkedItem){ + public ILinkedItem saveLinkedItem(ILinkedItem linkedItem) { if (linkedItem.getId() < 0) { linkedItem.setId(getUnusedId()); while (hasName(linkedItem.getName())) @@ -185,15 +187,15 @@ public class LinkedItemController { // Save Linked Item File File dir = this.getDir(); - if(!dir.exists()) + if (!dir.exists()) dir.mkdirs(); File file = new File(dir, linkedItem.getName() + ".json_new"); - File file2 = new File(dir, linkedItem.getName() + ".json"); + File file2 = new File(dir, linkedItem.getName() + ".json"); try { - NBTJsonUtil.SaveFile(file, ((LinkedItem)linkedItem).writeToNBT(true)); - if(file2.exists()) + NBTJsonUtil.SaveFile(file, ((LinkedItem) linkedItem).writeToNBT(true)); + if (file2.exists()) file2.delete(); file.renameTo(file2); } catch (Exception e) { @@ -243,37 +245,38 @@ public class LinkedItemController { //////////////////////////////////////////////////////// // LINKED ITEMS MAP - public File getMapDir(){ + public File getMapDir() { File dir = CustomNpcs.getWorldSaveDirectory(); - if(!dir.exists()) + if (!dir.exists()) dir.mkdir(); return dir; } - public void readLinkedMap(){ + public void readLinkedMap() { bootOrder.clear(); try { File file = new File(getMapDir(), "linkeditems.dat"); - if(file.exists()){ + if (file.exists()) { loadLinkedMap(file); } } catch (Exception e) { try { File file = new File(getMapDir(), "linkeditems.dat_old"); - if(file.exists()){ + if (file.exists()) { loadLinkedMap(file); } - } catch (Exception ignored) {} + } catch (Exception ignored) { + } } } - public NBTTagCompound writeMapNBT(){ + public NBTTagCompound writeMapNBT() { NBTTagCompound nbt = new NBTTagCompound(); NBTTagList linkedList = new NBTTagList(); - for(Integer key: linkedItems.keySet()){ + for (Integer key : linkedItems.keySet()) { LinkedItem linkedItem = linkedItems.get(key); - if(!linkedItem.getName().isEmpty()){ + if (!linkedItem.getName().isEmpty()) { NBTTagCompound linkedCompound = new NBTTagCompound(); linkedCompound.setString("Name", linkedItem.getName()); linkedCompound.setInteger("ID", key); @@ -285,11 +288,10 @@ public class LinkedItemController { return nbt; } - public void readMapNBT(NBTTagCompound compound){ + public void readMapNBT(NBTTagCompound compound) { NBTTagList list = compound.getTagList("LinkedItems", 10); - if(list != null){ - for(int i = 0; i < list.tagCount(); i++) - { + if (list != null) { + for (int i = 0; i < list.tagCount(); i++) { NBTTagCompound nbttagcompound = list.getCompoundTagAt(i); String linkedName = nbttagcompound.getString("Name"); Integer key = nbttagcompound.getInteger("ID"); @@ -304,30 +306,27 @@ public class LinkedItemController { var1.close(); } - public void readLinkedMap(DataInputStream stream) throws IOException{ + public void readLinkedMap(DataInputStream stream) throws IOException { NBTTagCompound nbtCompound = CompressedStreamTools.read(stream); this.readMapNBT(nbtCompound); } - public void saveLinkedItemsMap(){ + public void saveLinkedItemsMap() { try { File saveDir = getMapDir(); File file = new File(saveDir, "linkeditems.dat_new"); File file1 = new File(saveDir, "linkeditems.dat_old"); File file2 = new File(saveDir, "linkeditems.dat"); CompressedStreamTools.writeCompressed(this.writeMapNBT(), new FileOutputStream(file)); - if(file1.exists()) - { + if (file1.exists()) { file1.delete(); } file2.renameTo(file1); - if(file2.exists()) - { + if (file2.exists()) { file2.delete(); } file.renameTo(file2); - if(file.exists()) - { + if (file.exists()) { file.delete(); } } catch (Exception e) { diff --git a/src/main/java/noppes/npcs/controllers/LinkedNpcController.java b/src/main/java/noppes/npcs/controllers/LinkedNpcController.java index b16f54e5a..8873f256f 100644 --- a/src/main/java/noppes/npcs/controllers/LinkedNpcController.java +++ b/src/main/java/noppes/npcs/controllers/LinkedNpcController.java @@ -16,182 +16,183 @@ import java.util.Iterator; import java.util.List; public class LinkedNpcController { - public static LinkedNpcController Instance; - public List list = new ArrayList(); + public static LinkedNpcController Instance; + public List list = new ArrayList(); - public LinkedNpcController(){ - Instance = this; - load(); - } - private void load(){ - try { - loadNpcs(); - } catch (Exception e) { - LogWriter.except(e); - } - } + public LinkedNpcController() { + Instance = this; + load(); + } - public File getDir(){ - File dir = new File(CustomNpcs.getWorldSaveDirectory(), "linkednpcs"); - if(!dir.exists()) - dir.mkdir(); - return dir; - } + private void load() { + try { + loadNpcs(); + } catch (Exception e) { + LogWriter.except(e); + } + } - private void loadNpcs(){ - LogWriter.info("Loading Linked Npcs"); - File dir = getDir(); - if(dir.exists()){ - List list = new ArrayList(); - for(File file : dir.listFiles()){ - if(file.getName().endsWith(".json")){ - try{ - NBTTagCompound compound = NBTJsonUtil.LoadFile(file);; - LinkedData linked = new LinkedData(); - linked.setNBT(compound); - list.add(linked); - } - catch(Exception e){ - LogWriter.error("Error loading: " + file.getAbsolutePath(), e); - } - } - } + public File getDir() { + File dir = new File(CustomNpcs.getWorldSaveDirectory(), "linkednpcs"); + if (!dir.exists()) + dir.mkdir(); + return dir; + } - this.list = list; - } - LogWriter.info("Done loading Linked Npcs"); - } + private void loadNpcs() { + LogWriter.info("Loading Linked Npcs"); + File dir = getDir(); + if (dir.exists()) { + List list = new ArrayList(); + for (File file : dir.listFiles()) { + if (file.getName().endsWith(".json")) { + try { + NBTTagCompound compound = NBTJsonUtil.LoadFile(file); + ; + LinkedData linked = new LinkedData(); + linked.setNBT(compound); + list.add(linked); + } catch (Exception e) { + LogWriter.error("Error loading: " + file.getAbsolutePath(), e); + } + } + } - public void save(){ - for(LinkedData npc : list){ - try { - saveNpc(npc); - } catch (IOException e) { - LogWriter.except(e); - } - } - } + this.list = list; + } + LogWriter.info("Done loading Linked Npcs"); + } - private void saveNpc(LinkedData npc) throws IOException { - File file = new File(getDir(), npc.name + ".json_new"); + public void save() { + for (LinkedData npc : list) { + try { + saveNpc(npc); + } catch (IOException e) { + LogWriter.except(e); + } + } + } + + private void saveNpc(LinkedData npc) throws IOException { + File file = new File(getDir(), npc.name + ".json_new"); File file1 = new File(getDir(), npc.name + ".json"); - try{ - NBTJsonUtil.SaveFile(file, npc.getNBT()); - if(file1.exists()){ - file1.delete(); - } - file.renameTo(file1); + try { + NBTJsonUtil.SaveFile(file, npc.getNBT()); + if (file1.exists()) { + file1.delete(); + } + file.renameTo(file1); - } catch (JsonException e) { - LogWriter.except(e); - } - } + } catch (JsonException e) { + LogWriter.except(e); + } + } - public static class LinkedData{ - public String name = "LinkedNpc"; - public long time = 0; - public NBTTagCompound data = new NBTTagCompound(); + public static class LinkedData { + public String name = "LinkedNpc"; + public long time = 0; + public NBTTagCompound data = new NBTTagCompound(); - public LinkedData(){ - time = System.currentTimeMillis(); - } + public LinkedData() { + time = System.currentTimeMillis(); + } - public void setNBT(NBTTagCompound compound){ - name = compound.getString("LinkedName"); - data = compound.getCompoundTag("NPCData"); - } + public void setNBT(NBTTagCompound compound) { + name = compound.getString("LinkedName"); + data = compound.getCompoundTag("NPCData"); + } - public NBTTagCompound getNBT(){ - NBTTagCompound compound = new NBTTagCompound(); - compound.setString("LinkedName", name); - compound.setTag("NPCData", data); - return compound; - } - } + public NBTTagCompound getNBT() { + NBTTagCompound compound = new NBTTagCompound(); + compound.setString("LinkedName", name); + compound.setTag("NPCData", data); + return compound; + } + } - public void loadNpcData(EntityNPCInterface npc) { - if(npc.linkedName.isEmpty()) - return; - LinkedData data = getData(npc.linkedName); - if(data == null){ - npc.linkedLast = 0; - npc.linkedName = ""; - npc.linkedData = null; - } - else{ - npc.linkedData = data; - if(npc.posX == 0 && npc.posY == 0 && npc.posZ == 0) - return; - npc.linkedLast = data.time; - List points = npc.ais.getMovingPath(); + public void loadNpcData(EntityNPCInterface npc) { + if (npc.linkedName.isEmpty()) + return; + LinkedData data = getData(npc.linkedName); + if (data == null) { + npc.linkedLast = 0; + npc.linkedName = ""; + npc.linkedData = null; + } else { + npc.linkedData = data; + if (npc.posX == 0 && npc.posY == 0 && npc.posZ == 0) + return; + npc.linkedLast = data.time; + List points = npc.ais.getMovingPath(); - NBTTagCompound compound = NBTTags.NBTMerge(readNpcData(npc), data.data); + NBTTagCompound compound = NBTTags.NBTMerge(readNpcData(npc), data.data); - npc.display.readToNBT(compound); - npc.stats.readToNBT(compound); - npc.advanced.readToNBT(compound); - npc.inventory.readEntityFromNBT(compound); - if(compound.hasKey("ModelData")) - ((EntityCustomNpc)npc).modelData.readFromNBT(compound.getCompoundTag("ModelData")); + npc.display.readToNBT(compound); + npc.stats.readToNBT(compound); + npc.advanced.readToNBT(compound); + npc.inventory.readEntityFromNBT(compound); + if (compound.hasKey("ModelData")) + ((EntityCustomNpc) npc).modelData.readFromNBT(compound.getCompoundTag("ModelData")); - npc.ais.readToNBT(compound); - npc.transform.readToNBT(compound); - npc.ais.setMovingPath(points); - npc.updateClient = true; - } - } + npc.ais.readToNBT(compound); + npc.transform.readToNBT(compound); + npc.ais.setMovingPath(points); + npc.updateClient = true; + } + } - private void cleanTags(NBTTagCompound compound){ - compound.removeTag("MovingPathNew"); - } + private void cleanTags(NBTTagCompound compound) { + compound.removeTag("MovingPathNew"); + } - public LinkedData getData(String name){ - for(LinkedData data : list){ - if(data.name.equalsIgnoreCase(name)) - return data; - } - return null; - } + public LinkedData getData(String name) { + for (LinkedData data : list) { + if (data.name.equalsIgnoreCase(name)) + return data; + } + return null; + } - private NBTTagCompound readNpcData(EntityNPCInterface npc){ - NBTTagCompound compound = new NBTTagCompound(); - npc.display.writeToNBT(compound); - npc.inventory.writeEntityToNBT(compound); - npc.stats.writeToNBT(compound); - npc.ais.writeToNBT(compound); - npc.advanced.writeToNBT(compound); - npc.transform.writeToNBT(compound); - compound.setTag("ModelData", ((EntityCustomNpc)npc).modelData.writeToNBT()); - return compound; - } + private NBTTagCompound readNpcData(EntityNPCInterface npc) { + NBTTagCompound compound = new NBTTagCompound(); + npc.display.writeToNBT(compound); + npc.inventory.writeEntityToNBT(compound); + npc.stats.writeToNBT(compound); + npc.ais.writeToNBT(compound); + npc.advanced.writeToNBT(compound); + npc.transform.writeToNBT(compound); + compound.setTag("ModelData", ((EntityCustomNpc) npc).modelData.writeToNBT()); + return compound; + } - public void saveNpcData(EntityNPCInterface npc) { - NBTTagCompound compound = readNpcData(npc); - cleanTags(compound); + public void saveNpcData(EntityNPCInterface npc) { + NBTTagCompound compound = readNpcData(npc); + cleanTags(compound); - if(npc.linkedData.data.equals(compound)) - return; + if (npc.linkedData.data.equals(compound)) + return; - npc.linkedData.data = compound; - npc.linkedData.time = System.currentTimeMillis(); - save(); - } - public void removeData(String name) { - Iterator ita = list.iterator(); - while(ita.hasNext()){ - if(ita.next().name.equalsIgnoreCase(name)) - ita.remove(); - } - save(); - } + npc.linkedData.data = compound; + npc.linkedData.time = System.currentTimeMillis(); + save(); + } - public void addData(String name){ - if(getData(name) != null || name.isEmpty()) - return; + public void removeData(String name) { + Iterator ita = list.iterator(); + while (ita.hasNext()) { + if (ita.next().name.equalsIgnoreCase(name)) + ita.remove(); + } + save(); + } - LinkedData data = new LinkedData(); - data.name = name; - list.add(data); - save(); - } + public void addData(String name) { + if (getData(name) != null || name.isEmpty()) + return; + + LinkedData data = new LinkedData(); + data.name = name; + list.add(data); + save(); + } } diff --git a/src/main/java/noppes/npcs/controllers/MagicController.java b/src/main/java/noppes/npcs/controllers/MagicController.java index f87c8ddd6..606006dec 100644 --- a/src/main/java/noppes/npcs/controllers/MagicController.java +++ b/src/main/java/noppes/npcs/controllers/MagicController.java @@ -10,15 +10,10 @@ import noppes.npcs.CustomItems; import noppes.npcs.CustomNpcs; import noppes.npcs.LogWriter; import noppes.npcs.controllers.data.Magic; -import noppes.npcs.controllers.data.MagicCycle; import noppes.npcs.controllers.data.MagicAssociation; +import noppes.npcs.controllers.data.MagicCycle; -import java.io.BufferedInputStream; -import java.io.DataInputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.IOException; +import java.io.*; import java.util.HashMap; import java.util.zip.GZIPInputStream; @@ -70,27 +65,28 @@ public class MagicController { if (file.exists()) { loadMagicFile(file); } - } catch (Exception ee) { } + } catch (Exception ee) { + } } if (magics.isEmpty() && cycles.isEmpty()) { // Create default magics - Magic earth = new Magic(getUnusedId(), "Earth", 0x00DD00); + Magic earth = new Magic(getUnusedId(), "Earth", 0x00DD00); earth.setItem(new ItemStack(CustomItems.earthElement)); - Magic water = new Magic(getUnusedId(), "Water", 0xF2DD00); + Magic water = new Magic(getUnusedId(), "Water", 0xF2DD00); water.setItem(new ItemStack(CustomItems.waterElement)); - Magic fire = new Magic(getUnusedId(), "Fire", 0xDD0000); + Magic fire = new Magic(getUnusedId(), "Fire", 0xDD0000); fire.setItem(new ItemStack(CustomItems.spellFire)); - Magic air = new Magic(getUnusedId(), "Air", 0xDD0000); + Magic air = new Magic(getUnusedId(), "Air", 0xDD0000); air.setItem(new ItemStack(CustomItems.airElement)); - Magic dark = new Magic(getUnusedId(), "Dark", 0xDD0000); + Magic dark = new Magic(getUnusedId(), "Dark", 0xDD0000); dark.setItem(new ItemStack(CustomItems.spellDark)); - Magic holy = new Magic(getUnusedId(), "Holy", 0xDD0000); + Magic holy = new Magic(getUnusedId(), "Holy", 0xDD0000); holy.setItem(new ItemStack(CustomItems.spellHoly)); Magic nature = new Magic(getUnusedId(), "Nature", 0xDD0000); @@ -332,7 +328,7 @@ public class MagicController { return; Magic magic = magics.get(magicId); - if(magic == null) + if (magic == null) return; MagicAssociation assoc = new MagicAssociation(); diff --git a/src/main/java/noppes/npcs/controllers/PartyController.java b/src/main/java/noppes/npcs/controllers/PartyController.java index 2247ce631..dfb71eb91 100644 --- a/src/main/java/noppes/npcs/controllers/PartyController.java +++ b/src/main/java/noppes/npcs/controllers/PartyController.java @@ -35,7 +35,8 @@ public class PartyController implements IPartyHandler { private HashMap parties = new HashMap<>(); - private PartyController() {} + private PartyController() { + } public static PartyController Instance() { if (Instance == null) { @@ -51,16 +52,16 @@ public class PartyController implements IPartyHandler { } @Override - public IParty createParty(IPlayer player){ - if(player == null) + public IParty createParty(IPlayer player) { + if (player == null) return null; - if(player.getMCEntity() == null) + if (player.getMCEntity() == null) return null; EntityPlayer entityPlayer = (EntityPlayer) player.getMCEntity(); PlayerData playerData = PlayerDataController.Instance.getPlayerData(entityPlayer); - if(playerData.partyUUID != null) + if (playerData.partyUUID != null) return getParty(playerData.partyUUID); Party party = new Party(); @@ -71,16 +72,16 @@ public class PartyController implements IPartyHandler { } @Override - public void disbandParty(IPlayer player){ - if(player == null) + public void disbandParty(IPlayer player) { + if (player == null) return; - if(player.getMCEntity() == null) + if (player.getMCEntity() == null) return; EntityPlayer entityPlayer = (EntityPlayer) player.getMCEntity(); PlayerData playerData = PlayerDataController.Instance.getPlayerData(entityPlayer); - if(playerData.partyUUID != null) + if (playerData.partyUUID != null) disbandParty(playerData.partyUUID); return; @@ -95,20 +96,19 @@ public class PartyController implements IPartyHandler { if (party != null) { PartyEvent.PartyDisbandEvent partyEvent = new PartyEvent.PartyDisbandEvent(party, party.getQuest()); EventHooks.onPartyDisband(partyEvent); - for (UUID uuid: party.getPlayerUUIDs()) { + for (UUID uuid : party.getPlayerUUIDs()) { EntityPlayer player = NoppesUtilServer.getPlayer(uuid); PlayerData playerData; - if(player != null){ + if (player != null) { playerData = PlayerDataController.Instance.getPlayerData(player); - } - else { + } else { playerData = PlayerDataController.Instance.getPlayerDataCache(uuid.toString()); } - if(playerData != null){ + if (playerData != null) { playerData.partyUUID = null; - if(player != null){ + if (player != null) { sendInviteData((EntityPlayerMP) player); - AchievementPacket.sendAchievement((EntityPlayerMP) player, true, "party.disbandAlert", ""); + AchievementPacket.sendAchievement((EntityPlayerMP) player, true, "party.disbandAlert", ""); ChatAlertPacket.sendChatAlert((EntityPlayerMP) player, "\u00A7c", "party.disbandMessage", "!"); } } @@ -117,41 +117,41 @@ public class PartyController implements IPartyHandler { } } - public void sendKickMessages(Party party, EntityPlayer kickPlayer, String kickPlayerName){ - if(party == null) + public void sendKickMessages(Party party, EntityPlayer kickPlayer, String kickPlayerName) { + if (party == null) return; - for(String name : party.getPlayerNames()){ + for (String name : party.getPlayerNames()) { EntityPlayer playerMP = NoppesUtilServer.getPlayerByName(name); - if(playerMP != null){ - AchievementPacket.sendAchievement((EntityPlayerMP) playerMP, true, "party.kickOtherAlert", kickPlayerName); + if (playerMP != null) { + AchievementPacket.sendAchievement((EntityPlayerMP) playerMP, true, "party.kickOtherAlert", kickPlayerName); ChatAlertPacket.sendChatAlert((EntityPlayerMP) playerMP, "\u00A7e", kickPlayerName, " \u00A74", "party.kickOtherChat", "!"); } } - if(kickPlayer != null){ - AchievementPacket.sendAchievement((EntityPlayerMP) kickPlayer, true, "party.kickYouAlert", ""); + if (kickPlayer != null) { + AchievementPacket.sendAchievement((EntityPlayerMP) kickPlayer, true, "party.kickYouAlert", ""); ChatAlertPacket.sendChatAlert((EntityPlayerMP) kickPlayer, "\u00A74", "party.kickYouChat", "!"); } } - public void sendLeavingMessages(Party party, EntityPlayer leavingPlayer){ - if(leavingPlayer == null || party == null) + public void sendLeavingMessages(Party party, EntityPlayer leavingPlayer) { + if (leavingPlayer == null || party == null) return; - for(String name : party.getPlayerNames()){ + for (String name : party.getPlayerNames()) { EntityPlayer playerMP = NoppesUtilServer.getPlayerByName(name); - if(playerMP != null){ - AchievementPacket.sendAchievement((EntityPlayerMP) playerMP, true, "party.leaveOtherAlert", leavingPlayer.getCommandSenderName()); + if (playerMP != null) { + AchievementPacket.sendAchievement((EntityPlayerMP) playerMP, true, "party.leaveOtherAlert", leavingPlayer.getCommandSenderName()); ChatAlertPacket.sendChatAlert((EntityPlayerMP) playerMP, "\u00A7e", leavingPlayer.getCommandSenderName(), " \u00A7c", "party.leaveOtherChat", "!"); } } - AchievementPacket.sendAchievement((EntityPlayerMP) leavingPlayer, true, "party.leaveYouAlert", ""); + AchievementPacket.sendAchievement((EntityPlayerMP) leavingPlayer, true, "party.leaveYouAlert", ""); ChatAlertPacket.sendChatAlert((EntityPlayerMP) leavingPlayer, "\u00A7c", "party.leaveYouChat", "!"); } - public void pingPartyUpdate(Party party){ - if(party == null) + public void pingPartyUpdate(Party party) { + if (party == null) return; NBTTagCompound compound = party.writeToNBT(); @@ -164,24 +164,24 @@ public class PartyController implements IPartyHandler { list.appendTag(new NBTTagString(s)); } compound.setTag("QuestProgress", list); - if(quest.completion == EnumQuestCompletion.Npc && quest.questInterface.isPartyCompleted(party)) { + if (quest.completion == EnumQuestCompletion.Npc && quest.questInterface.isPartyCompleted(party)) { compound.setString("QuestCompleteWith", quest.completerNpc); } } - for(String name : party.getPlayerNames()){ + for (String name : party.getPlayerNames()) { EntityPlayer playerMP = NoppesUtilServer.getPlayerByName(name); - if(playerMP != null){ + if (playerMP != null) { PlayerData playerData = PlayerDataController.Instance.getPlayerData(playerMP); - if(playerData != null){ + if (playerData != null) { PartyDataPacket.sendPartyData((EntityPlayerMP) playerMP, compound); } } } } - public void pingPartyQuestObjectiveUpdate(Party party){ - if(party == null) + public void pingPartyQuestObjectiveUpdate(Party party) { + if (party == null) return; NBTTagCompound compound = new NBTTagCompound(); @@ -195,16 +195,16 @@ public class PartyController implements IPartyHandler { list.appendTag(new NBTTagString(s)); } compound.setTag("QuestProgress", list); - if(quest.completion == EnumQuestCompletion.Npc && quest.questInterface.isPartyCompleted(party)) { + if (quest.completion == EnumQuestCompletion.Npc && quest.questInterface.isPartyCompleted(party)) { compound.setString("QuestCompleteWith", quest.completerNpc); } } - for(String name : party.getPlayerNames()){ + for (String name : party.getPlayerNames()) { EntityPlayer playerMP = NoppesUtilServer.getPlayerByName(name); - if(playerMP != null){ + if (playerMP != null) { PlayerData playerData = PlayerDataController.Instance.getPlayerData(playerMP); - if(playerData != null){ + if (playerData != null) { PartyDataPacket.sendPartyData((EntityPlayerMP) playerMP, compound); } } @@ -230,11 +230,11 @@ public class PartyController implements IPartyHandler { public boolean checkQuestCompletion(Party party, EnumQuestType type) { QuestData questData = party.getQuestData(); - if(questData != null){ - if(questData.quest.type == type || type == null){ - QuestInterface inter = questData.quest.questInterface; - if(inter.isPartyCompleted(party)){ - if((!questData.isCompleted && questData.quest.completion == EnumQuestCompletion.Npc) || questData.quest.instantPartyComplete(party)){ + if (questData != null) { + if (questData.quest.type == type || type == null) { + QuestInterface inter = questData.quest.questInterface; + if (inter.isPartyCompleted(party)) { + if ((!questData.isCompleted && questData.quest.completion == EnumQuestCompletion.Npc) || questData.quest.instantPartyComplete(party)) { questData.isCompleted = true; if (questData.quest.completion == EnumQuestCompletion.Npc) { EventHooks.onPartyFinished(party, questData.quest); @@ -252,7 +252,7 @@ public class PartyController implements IPartyHandler { EntityPlayer playerMP = NoppesUtilServer.getPlayerByName(name); if (playerMP != null) { PlayerData playerData = PlayerDataController.Instance.getPlayerData(playerMP); - if(playerData != null){ + if (playerData != null) { if (playerData.questData.getTrackedQuest() != null && questData.quest.getId() == playerData.questData.getTrackedQuest().getId()) { NoppesUtilPlayer.sendPartyTrackedQuestData((EntityPlayerMP) playerMP, party); } diff --git a/src/main/java/noppes/npcs/controllers/PlayerDataController.java b/src/main/java/noppes/npcs/controllers/PlayerDataController.java index 3c666cff6..ca113e13a 100644 --- a/src/main/java/noppes/npcs/controllers/PlayerDataController.java +++ b/src/main/java/noppes/npcs/controllers/PlayerDataController.java @@ -31,556 +31,548 @@ import java.util.zip.GZIPInputStream; import static noppes.npcs.util.CustomNPCsThreader.customNPCThread; public class PlayerDataController { - public static PlayerDataController Instance; - public HashMap nameUUIDs; - private final CacheHashMap> playerDataCache = new CacheHashMap<>(60 * 60 * 1000); + public static PlayerDataController Instance; + public HashMap nameUUIDs; + private final CacheHashMap> playerDataCache = new CacheHashMap<>(60 * 60 * 1000); - public PlayerDataController(){ - Instance = this; - File dir = getSaveDir(); + public PlayerDataController() { + Instance = this; + File dir = getSaveDir(); - LogWriter.info("Loading PlayerData..."); - // If no PlayerData MAP - Load PlayerData to create PlayerData Map - if(!getPlayerDataMap()){ - LogWriter.info("Generating PlayerData map file..."); - File[] files = dir.listFiles(); // Get an array of all files in the directory - HashMap map = new HashMap(); - if(files != null){ - int length = files.length; - if(length != 0){ - if(length > 100){ - LogWriter.info("Found " + length + " PlayerData files... This may take a few minutes"); - } - int tenPercent = (int) ((double) length * 0.1); - int progress = 0; - // Load the files in parallel using a stream - for(int i = 0; i < length; i++){ - File file = files[i]; - if(file.isDirectory() || (!file.getName().endsWith(".json") && !file.getName().endsWith(".dat"))) - continue; - try { - if(file.getName().endsWith(".json")){ - NBTTagCompound compound = NBTJsonUtil.LoadFile(file); - if(compound.hasKey("PlayerName")){ - map.put(compound.getString("PlayerName"), file.getName().substring(0, file.getName().length() - 5)); - } - } - if(file.getName().endsWith(".dat")){ - NBTTagCompound compound = NBTJsonUtil.loadNBTData(file); - if(compound.hasKey("PlayerName")){ - map.put(compound.getString("PlayerName"), file.getName().substring(0, file.getName().length() - 4)); - } - } - } catch (Exception e) { - LogWriter.error("Error loading: " + file.getAbsolutePath(), e); - } - if(tenPercent != 0 ){ - if(progress != 100){ - if (i % tenPercent == 0) { - progress += 10; - LogWriter.info("Creating PlayerMap: Progress: " + progress + "%"); - } - } - } - } - } - } - nameUUIDs = map; - savePlayerDataMap(); - } + LogWriter.info("Loading PlayerData..."); + // If no PlayerData MAP - Load PlayerData to create PlayerData Map + if (!getPlayerDataMap()) { + LogWriter.info("Generating PlayerData map file..."); + File[] files = dir.listFiles(); // Get an array of all files in the directory + HashMap map = new HashMap(); + if (files != null) { + int length = files.length; + if (length != 0) { + if (length > 100) { + LogWriter.info("Found " + length + " PlayerData files... This may take a few minutes"); + } + int tenPercent = (int) ((double) length * 0.1); + int progress = 0; + // Load the files in parallel using a stream + for (int i = 0; i < length; i++) { + File file = files[i]; + if (file.isDirectory() || (!file.getName().endsWith(".json") && !file.getName().endsWith(".dat"))) + continue; + try { + if (file.getName().endsWith(".json")) { + NBTTagCompound compound = NBTJsonUtil.LoadFile(file); + if (compound.hasKey("PlayerName")) { + map.put(compound.getString("PlayerName"), file.getName().substring(0, file.getName().length() - 5)); + } + } + if (file.getName().endsWith(".dat")) { + NBTTagCompound compound = NBTJsonUtil.loadNBTData(file); + if (compound.hasKey("PlayerName")) { + map.put(compound.getString("PlayerName"), file.getName().substring(0, file.getName().length() - 4)); + } + } + } catch (Exception e) { + LogWriter.error("Error loading: " + file.getAbsolutePath(), e); + } + if (tenPercent != 0) { + if (progress != 100) { + if (i % tenPercent == 0) { + progress += 10; + LogWriter.info("Creating PlayerMap: Progress: " + progress + "%"); + } + } + } + } + } + } + nameUUIDs = map; + savePlayerDataMap(); + } - LogWriter.info("Done loading PlayerData"); - } + LogWriter.info("Done loading PlayerData"); + } - public boolean getPlayerDataMap(){ - try { - File file = new File(CustomNpcs.getWorldSaveDirectory(), "playerdatamap.dat"); - if(file.exists()){ - loadPlayerDataMap(file); - return true; - } - } catch (Exception e) { - LogWriter.except(e); - } - try { - File file = new File(CustomNpcs.getWorldSaveDirectory(), "playerdatamap.dat_old"); - if(file.exists()){ - loadPlayerDataMap(file); - return true; - } - } catch (Exception e2) { - LogWriter.except(e2); - } + public boolean getPlayerDataMap() { + try { + File file = new File(CustomNpcs.getWorldSaveDirectory(), "playerdatamap.dat"); + if (file.exists()) { + loadPlayerDataMap(file); + return true; + } + } catch (Exception e) { + LogWriter.except(e); + } + try { + File file = new File(CustomNpcs.getWorldSaveDirectory(), "playerdatamap.dat_old"); + if (file.exists()) { + loadPlayerDataMap(file); + return true; + } + } catch (Exception e2) { + LogWriter.except(e2); + } - return false; - } + return false; + } - private void loadPlayerDataMap(File file) throws IOException { - DataInputStream var1 = new DataInputStream(new BufferedInputStream(new GZIPInputStream(new FileInputStream(file)))); - loadPlayerDatasMap(var1); - var1.close(); - } + private void loadPlayerDataMap(File file) throws IOException { + DataInputStream var1 = new DataInputStream(new BufferedInputStream(new GZIPInputStream(new FileInputStream(file)))); + loadPlayerDatasMap(var1); + var1.close(); + } - public void loadPlayerDatasMap(DataInputStream stream) throws IOException{ - NBTTagCompound nbttagcompound = CompressedStreamTools.read(stream); - readNBT(nbttagcompound); - } + public void loadPlayerDatasMap(DataInputStream stream) throws IOException { + NBTTagCompound nbttagcompound = CompressedStreamTools.read(stream); + readNBT(nbttagcompound); + } - public synchronized void savePlayerDataMap(){ - customNPCThread.execute(() -> { - try { - File saveDir = CustomNpcs.getWorldSaveDirectory(); - File file = new File(saveDir, "playerdatamap.dat_new"); - File file1 = new File(saveDir, "playerdatamap.dat_old"); - File file2 = new File(saveDir, "playerdatamap.dat"); - CompressedStreamTools.writeCompressed(writeNBT(), new FileOutputStream(file)); - if(file1.exists()) - { - file1.delete(); - } - file2.renameTo(file1); - if(file2.exists()) - { - file2.delete(); - } - file.renameTo(file2); - if(file.exists()) - { - file.delete(); - } - } catch (Exception e) { - LogWriter.except(e); - } - }); - } + public synchronized void savePlayerDataMap() { + customNPCThread.execute(() -> { + try { + File saveDir = CustomNpcs.getWorldSaveDirectory(); + File file = new File(saveDir, "playerdatamap.dat_new"); + File file1 = new File(saveDir, "playerdatamap.dat_old"); + File file2 = new File(saveDir, "playerdatamap.dat"); + CompressedStreamTools.writeCompressed(writeNBT(), new FileOutputStream(file)); + if (file1.exists()) { + file1.delete(); + } + file2.renameTo(file1); + if (file2.exists()) { + file2.delete(); + } + file.renameTo(file2); + if (file.exists()) { + file.delete(); + } + } catch (Exception e) { + LogWriter.except(e); + } + }); + } - public File getSaveDir(){ - try{ - File file = new File(CustomNpcs.getWorldSaveDirectory(),"playerdata"); - if(!file.exists()) - file.mkdir(); - return file; - } - catch (Exception e) { - e.printStackTrace(); - return null; - } - } + public File getSaveDir() { + try { + File file = new File(CustomNpcs.getWorldSaveDirectory(), "playerdata"); + if (!file.exists()) + file.mkdir(); + return file; + } catch (Exception e) { + e.printStackTrace(); + return null; + } + } - public File getNewSaveDir(){ - try{ - File file = new File(CustomNpcs.getWorldSaveDirectory(),"playerdata_new"); - if(file.exists()){ - return null; - } - file.mkdir(); - return file; - } - catch (Exception e) { - e.printStackTrace(); - return null; - } - } + public File getNewSaveDir() { + try { + File file = new File(CustomNpcs.getWorldSaveDirectory(), "playerdata_new"); + if (file.exists()) { + return null; + } + file.mkdir(); + return file; + } catch (Exception e) { + e.printStackTrace(); + return null; + } + } - public NBTTagCompound loadPlayerDataOld(String player){ - File saveDir = getSaveDir(); - String filename = player; - if(filename.isEmpty()) - filename = "noplayername"; - filename += ".dat"; - try { - File file = new File(saveDir, filename); - if(file.exists()){ - NBTTagCompound comp = CompressedStreamTools.readCompressed(new FileInputStream(file)); - file.delete(); - file = new File(saveDir, filename+"_old"); - if(file.exists()) - file.delete(); - return comp; - } - } catch (Exception e) { - LogWriter.except(e); - } - try { - File file = new File(saveDir, filename+"_old"); - if(file.exists()){ - return CompressedStreamTools.readCompressed(new FileInputStream(file)); - } + public NBTTagCompound loadPlayerDataOld(String player) { + File saveDir = getSaveDir(); + String filename = player; + if (filename.isEmpty()) + filename = "noplayername"; + filename += ".dat"; + try { + File file = new File(saveDir, filename); + if (file.exists()) { + NBTTagCompound comp = CompressedStreamTools.readCompressed(new FileInputStream(file)); + file.delete(); + file = new File(saveDir, filename + "_old"); + if (file.exists()) + file.delete(); + return comp; + } + } catch (Exception e) { + LogWriter.except(e); + } + try { + File file = new File(saveDir, filename + "_old"); + if (file.exists()) { + return CompressedStreamTools.readCompressed(new FileInputStream(file)); + } - } catch (Exception e) { - LogWriter.except(e); - } + } catch (Exception e) { + LogWriter.except(e); + } - return new NBTTagCompound(); - } + return new NBTTagCompound(); + } - public NBTTagCompound loadPlayerData(String player){ - File saveDir = getSaveDir(); - String filename = player; - if(filename.isEmpty()) - filename = "noplayername"; + public NBTTagCompound loadPlayerData(String player) { + File saveDir = getSaveDir(); + String filename = player; + if (filename.isEmpty()) + filename = "noplayername"; - if(ConfigMain.DatFormat){ - filename += ".dat"; - } else { - filename += ".json"; - } - try { - File file = new File(saveDir, filename); - if(file.exists()){ - if(ConfigMain.DatFormat){ - return NBTJsonUtil.loadNBTData(file); - } else { - return NBTJsonUtil.LoadFile(file); - } - } - } catch (Exception e) { - LogWriter.error("Error loading: " + filename, e); - } + if (ConfigMain.DatFormat) { + filename += ".dat"; + } else { + filename += ".json"; + } + try { + File file = new File(saveDir, filename); + if (file.exists()) { + if (ConfigMain.DatFormat) { + return NBTJsonUtil.loadNBTData(file); + } else { + return NBTJsonUtil.LoadFile(file); + } + } + } catch (Exception e) { + LogWriter.error("Error loading: " + filename, e); + } - return new NBTTagCompound(); - } + return new NBTTagCompound(); + } public void putPlayerDataCache(final String uuid, final PlayerData playerCompound) { - synchronized (playerDataCache) { - playerDataCache.put(uuid, new CacheHashMap.CachedObject<>(playerCompound)); - } - } + synchronized (playerDataCache) { + playerDataCache.put(uuid, new CacheHashMap.CachedObject<>(playerCompound)); + } + } - public PlayerData getPlayerDataCache(final String uuid) { - synchronized (playerDataCache) { - if (!playerDataCache.containsKey(uuid)) { - return null; - } - return playerDataCache.get(uuid).getObject(); - } - } + public PlayerData getPlayerDataCache(final String uuid) { + synchronized (playerDataCache) { + if (!playerDataCache.containsKey(uuid)) { + return null; + } + return playerDataCache.get(uuid).getObject(); + } + } - public void removePlayerDataCache(final String uuid) { - synchronized (playerDataCache) { - playerDataCache.remove(uuid); - } - } + public void removePlayerDataCache(final String uuid) { + synchronized (playerDataCache) { + playerDataCache.remove(uuid); + } + } - public void clearCache() { - synchronized (playerDataCache) { - playerDataCache.clear(); - } - } + public void clearCache() { + synchronized (playerDataCache) { + playerDataCache.clear(); + } + } - public PlayerBankData getBankData(EntityPlayer player, int bankId) { - Bank bank = BankController.getInstance().getBank(bankId); - PlayerBankData data = getPlayerData(player).bankData; - if(!data.hasBank(bank.id)){ - data.loadNew(bank.id); - } - return data; - } + public PlayerBankData getBankData(EntityPlayer player, int bankId) { + Bank bank = BankController.getInstance().getBank(bankId); + PlayerBankData data = getPlayerData(player).bankData; + if (!data.hasBank(bank.id)) { + data.loadNew(bank.id); + } + return data; + } - public ArrayList getAllPlayerData() { - ArrayList playerDataList = new ArrayList<>(); - List list = MinecraftServer.getServer().getConfigurationManager().playerEntityList; - for (Object o : list) { - if (o instanceof EntityPlayer) { - playerDataList.add(this.getPlayerData((EntityPlayer)o)); - } - } - return playerDataList; - } + public ArrayList getAllPlayerData() { + ArrayList playerDataList = new ArrayList<>(); + List list = MinecraftServer.getServer().getConfigurationManager().playerEntityList; + for (Object o : list) { + if (o instanceof EntityPlayer) { + playerDataList.add(this.getPlayerData((EntityPlayer) o)); + } + } + return playerDataList; + } - public PlayerData getPlayerData(EntityPlayer player){ - PlayerData data = getPlayerDataCache(player.getUniqueID().toString()); - if(data != null){ + public PlayerData getPlayerData(EntityPlayer player) { + PlayerData data = getPlayerDataCache(player.getUniqueID().toString()); + if (data != null) { data.player = player; - return data; - } + return data; + } - data = (PlayerData) player.getExtendedProperties("CustomNpcsData"); - if(data == null){ - player.registerExtendedProperties("CustomNpcsData", data = new PlayerData()); - data.player = player; - data.load(); - } + data = (PlayerData) player.getExtendedProperties("CustomNpcsData"); + if (data == null) { + player.registerExtendedProperties("CustomNpcsData", data = new PlayerData()); + data.player = player; + data.load(); + } data.player = player; - return data; - } + return data; + } - public static EntityPlayer getPlayerFromUUID(UUID uuid) { - MinecraftServer server = MinecraftServer.getServer(); - if (server != null) { - for (Object playerObj : server.getConfigurationManager().playerEntityList) { - if (playerObj instanceof EntityPlayer) { - EntityPlayer player = (EntityPlayer) playerObj; - if (player.getUniqueID().equals(uuid)) { - return player; - } - } - } - } - return null; - } + public static EntityPlayer getPlayerFromUUID(UUID uuid) { + MinecraftServer server = MinecraftServer.getServer(); + if (server != null) { + for (Object playerObj : server.getConfigurationManager().playerEntityList) { + if (playerObj instanceof EntityPlayer) { + EntityPlayer player = (EntityPlayer) playerObj; + if (player.getUniqueID().equals(uuid)) { + return player; + } + } + } + } + return null; + } - public String hasPlayer(String username) { - for(String name : nameUUIDs.keySet()){ - if(name.equalsIgnoreCase(username)) - return name; - } + public String hasPlayer(String username) { + for (String name : nameUUIDs.keySet()) { + if (name.equalsIgnoreCase(username)) + return name; + } - return ""; - } + return ""; + } public String getPlayerUUIDFromName(String username) { - for(String name : nameUUIDs.keySet()){ - if(name.equalsIgnoreCase(username)) + for (String name : nameUUIDs.keySet()) { + if (name.equalsIgnoreCase(username)) return nameUUIDs.get(name); } return ""; } - public PlayerData getDataFromUsername(String username){ - EntityPlayer player = MinecraftServer.getServer().getConfigurationManager().func_152612_a(username); - PlayerData data = null; - if(player == null){ - for(String name : nameUUIDs.keySet()){ - if(name.equalsIgnoreCase(username)){ - data = new PlayerData(); - data.setNBT(PlayerDataController.Instance.loadPlayerData(nameUUIDs.get(name))); - break; - } - } - } - else - data = PlayerDataController.Instance.getPlayerData(player); + public PlayerData getDataFromUsername(String username) { + EntityPlayer player = MinecraftServer.getServer().getConfigurationManager().func_152612_a(username); + PlayerData data = null; + if (player == null) { + for (String name : nameUUIDs.keySet()) { + if (name.equalsIgnoreCase(username)) { + data = new PlayerData(); + data.setNBT(PlayerDataController.Instance.loadPlayerData(nameUUIDs.get(name))); + break; + } + } + } else + data = PlayerDataController.Instance.getPlayerData(player); - return data; - } + return data; + } - public void addPlayerMessage(String username, PlayerMail mail) { - mail.time = System.currentTimeMillis(); + public void addPlayerMessage(String username, PlayerMail mail) { + mail.time = System.currentTimeMillis(); - EntityPlayer player = MinecraftServer.getServer().getConfigurationManager().func_152612_a(username); - PlayerData data = getDataFromUsername(username); - data.mailData.playermail.add(mail.copy()); - data.save(); - } + EntityPlayer player = MinecraftServer.getServer().getConfigurationManager().func_152612_a(username); + PlayerData data = getDataFromUsername(username); + data.mailData.playermail.add(mail.copy()); + data.save(); + } - public List getPlayersData(ICommandSender sender, String username){ - ArrayList list = new ArrayList(); - EntityPlayerMP[] players = PlayerSelector.matchPlayers(sender, username); - if(players == null || players.length == 0){ - PlayerData data = PlayerDataController.Instance.getDataFromUsername(username); - if(data != null) - list.add(data); - } - else{ - for(EntityPlayer player : players){ - list.add(PlayerDataController.Instance.getPlayerData(player)); - } - } + public List getPlayersData(ICommandSender sender, String username) { + ArrayList list = new ArrayList(); + EntityPlayerMP[] players = PlayerSelector.matchPlayers(sender, username); + if (players == null || players.length == 0) { + PlayerData data = PlayerDataController.Instance.getDataFromUsername(username); + if (data != null) + list.add(data); + } else { + for (EntityPlayer player : players) { + list.add(PlayerDataController.Instance.getPlayerData(player)); + } + } - return list; - } + return list; + } - public void putPlayerMap(String playerName, String uuid) { - nameUUIDs.put(playerName, uuid); - savePlayerDataMap(); - } + public void putPlayerMap(String playerName, String uuid) { + nameUUIDs.put(playerName, uuid); + savePlayerDataMap(); + } - public boolean hasMail(EntityPlayer player) { - return getPlayerData(player).mailData.hasMail(); - } - public void readNBT(NBTTagCompound compound){ - this.nameUUIDs = new HashMap(); - NBTTagList list = compound.getTagList("PlayerDataMap", 10); - if(list != null){ - for(int i = 0; i < list.tagCount(); i++) - { - NBTTagCompound nbttagcompound = list.getCompoundTagAt(i); - String playerName = nbttagcompound.getString("Name"); - String uuid = nbttagcompound.getString("UUID"); - nameUUIDs.put(playerName, uuid); - } - } - } + public boolean hasMail(EntityPlayer player) { + return getPlayerData(player).mailData.hasMail(); + } - public NBTTagCompound writeNBT(){ - NBTTagCompound nbt = new NBTTagCompound(); - NBTTagList playerList = new NBTTagList(); - for(String key: nameUUIDs.keySet()){ - NBTTagCompound playerCompound = new NBTTagCompound(); - playerCompound.setString("Name", key); - playerCompound.setString("UUID", nameUUIDs.get(key)); - playerList.appendTag(playerCompound); + public void readNBT(NBTTagCompound compound) { + this.nameUUIDs = new HashMap(); + NBTTagList list = compound.getTagList("PlayerDataMap", 10); + if (list != null) { + for (int i = 0; i < list.tagCount(); i++) { + NBTTagCompound nbttagcompound = list.getCompoundTagAt(i); + String playerName = nbttagcompound.getString("Name"); + String uuid = nbttagcompound.getString("UUID"); + nameUUIDs.put(playerName, uuid); + } + } + } - } - nbt.setTag("PlayerDataMap", playerList); - return nbt; - } + public NBTTagCompound writeNBT() { + NBTTagCompound nbt = new NBTTagCompound(); + NBTTagList playerList = new NBTTagList(); + for (String key : nameUUIDs.keySet()) { + NBTTagCompound playerCompound = new NBTTagCompound(); + playerCompound.setString("Name", key); + playerCompound.setString("UUID", nameUUIDs.get(key)); + playerList.appendTag(playerCompound); - public void generatePlayerMap(EntityPlayerMP sender){ - ExecutorService executor = Executors.newSingleThreadExecutor(); - executor.execute(() -> { - if(sender != null){ - LogWriter.info("PlayerMap regeneration queued by " + sender.getCommandSenderName()); - sender.addChatMessage(new ChatComponentText("You have initiated PlayerMap regeneration")); - } - nameUUIDs.clear(); + } + nbt.setTag("PlayerDataMap", playerList); + return nbt; + } - File dir = getSaveDir(); - LogWriter.info("Generating PlayerData map file..."); - File[] files = dir.listFiles(); // Get an array of all files in the directory - HashMap map = new HashMap(); - if(files != null){ - int length = files.length; - if(length != 0){ - if(length > 100){ - LogWriter.info("Found " + length + " PlayerData files... This may take a few minutes"); - } - int tenPercent = (int) ((double) length * 0.1); - int progress = 0; - // Load the files in parallel using a stream - for(int i = 0; i < length; i++){ - File file = files[i]; - if(file.isDirectory() || (!file.getName().endsWith(".json") && !file.getName().endsWith(".dat"))) - continue; - try { - if(file.getName().endsWith(".json")){ - NBTTagCompound compound = NBTJsonUtil.LoadFile(file); - if(compound.hasKey("PlayerName")){ - map.put(compound.getString("PlayerName"), file.getName().substring(0, file.getName().length() - 5)); - } - } - if(file.getName().endsWith(".dat")){ - NBTTagCompound compound = NBTJsonUtil.loadNBTData(file); - if(compound.hasKey("PlayerName")){ - map.put(compound.getString("PlayerName"), file.getName().substring(0, file.getName().length() - 4)); - } - } - } catch (Exception e) { - LogWriter.error("Error loading: " + file.getAbsolutePath(), e); - } - if(tenPercent != 0 ){ - if(progress != 100){ - if (i % tenPercent == 0) { - progress += 10; - LogWriter.info("Creating PlayerMap: Progress: " + progress + "%"); - } - } - } - } - } - } - nameUUIDs = map; - savePlayerDataMap(); - if(sender != null){ - sender.addChatMessage(new ChatComponentText("PlayerMap regeneration complete")); - } - }); + public void generatePlayerMap(EntityPlayerMP sender) { + ExecutorService executor = Executors.newSingleThreadExecutor(); + executor.execute(() -> { + if (sender != null) { + LogWriter.info("PlayerMap regeneration queued by " + sender.getCommandSenderName()); + sender.addChatMessage(new ChatComponentText("You have initiated PlayerMap regeneration")); + } + nameUUIDs.clear(); - executor.shutdown(); - } + File dir = getSaveDir(); + LogWriter.info("Generating PlayerData map file..."); + File[] files = dir.listFiles(); // Get an array of all files in the directory + HashMap map = new HashMap(); + if (files != null) { + int length = files.length; + if (length != 0) { + if (length > 100) { + LogWriter.info("Found " + length + " PlayerData files... This may take a few minutes"); + } + int tenPercent = (int) ((double) length * 0.1); + int progress = 0; + // Load the files in parallel using a stream + for (int i = 0; i < length; i++) { + File file = files[i]; + if (file.isDirectory() || (!file.getName().endsWith(".json") && !file.getName().endsWith(".dat"))) + continue; + try { + if (file.getName().endsWith(".json")) { + NBTTagCompound compound = NBTJsonUtil.LoadFile(file); + if (compound.hasKey("PlayerName")) { + map.put(compound.getString("PlayerName"), file.getName().substring(0, file.getName().length() - 5)); + } + } + if (file.getName().endsWith(".dat")) { + NBTTagCompound compound = NBTJsonUtil.loadNBTData(file); + if (compound.hasKey("PlayerName")) { + map.put(compound.getString("PlayerName"), file.getName().substring(0, file.getName().length() - 4)); + } + } + } catch (Exception e) { + LogWriter.error("Error loading: " + file.getAbsolutePath(), e); + } + if (tenPercent != 0) { + if (progress != 100) { + if (i % tenPercent == 0) { + progress += 10; + LogWriter.info("Creating PlayerMap: Progress: " + progress + "%"); + } + } + } + } + } + } + nameUUIDs = map; + savePlayerDataMap(); + if (sender != null) { + sender.addChatMessage(new ChatComponentText("PlayerMap regeneration complete")); + } + }); - public void convertPlayerFiles(final EntityPlayerMP sender, final boolean type){ - ExecutorService executor = Executors.newSingleThreadExecutor(); - executor.execute(() -> { - String fileType; - if(type){ - fileType = ".dat"; - } - else { - fileType = ".json"; - } + executor.shutdown(); + } - if(sender != null){ - LogWriter.info("PlayerData Conversion queued by " + sender.getCommandSenderName()); - sender.addChatMessage(new ChatComponentText("PlayerData Conversion to " + fileType + " format")); - } + public void convertPlayerFiles(final EntityPlayerMP sender, final boolean type) { + ExecutorService executor = Executors.newSingleThreadExecutor(); + executor.execute(() -> { + String fileType; + if (type) { + fileType = ".dat"; + } else { + fileType = ".json"; + } - File dir = getSaveDir(); - LogWriter.info("Converting PlayerData to " + fileType + " format"); - File[] files = dir.listFiles(); // Get an array of all files in the directory - if(files != null){ - int length = files.length; - if(length != 0){ - if(length > 100){ - LogWriter.info("Found " + length + " PlayerData files... This may take a few minutes"); - } - int tenPercent = (int) ((double) length * 0.1); - int progress = 0; - File saveDir = PlayerDataController.Instance.getNewSaveDir(); - if(saveDir == null){ - if(sender != null){ - sender.addChatMessage(new ChatComponentText("playerdata_new folder already exists please delete it or rename it")); - } - LogWriter.error("playerdata_new folder already exists please delete it or rename it"); - return; - } - // Load the files in parallel using a stream - for(int i = 0; i < length; i++){ - File file = files[i]; - if(file.isDirectory() || (!file.getName().endsWith(".json") && !file.getName().endsWith(".dat"))) - continue; - try { - String filename = "error"; - boolean valid = false; - NBTTagCompound compound = new NBTTagCompound(); - if(type){ - if(file.getName().endsWith(".json")){ - compound = NBTJsonUtil.LoadFile(file); - if(compound.hasKey("PlayerName")) { - filename = file.getName().substring(0, file.getName().length() - 5); - valid = true; - } - } - } else { - if(file.getName().endsWith(".dat")){ - compound = NBTJsonUtil.loadNBTData(file); - if(compound.hasKey("PlayerName")){ - filename = file.getName().substring(0, file.getName().length() - 4); - valid = true; - } - } - } - if(valid){ - try { - File newFile = new File(saveDir, filename + "_new" + fileType); - File oldFile = new File(saveDir, filename + fileType); - if(type){ - CompressedStreamTools.writeCompressed(compound, new FileOutputStream(newFile)); - } else { - NBTJsonUtil.SaveFile(newFile, compound); - } - if(oldFile.exists()){ - oldFile.delete(); - } - newFile.renameTo(oldFile); - } catch (Exception e) { - LogWriter.except(e); - } - } - } catch (Exception e) { - LogWriter.error("Error loading: " + file.getAbsolutePath(), e); - } - if(tenPercent != 0 ){ - if(progress != 100){ - if (i % tenPercent == 0) { - progress += 10; - LogWriter.info("Converting PlayerData: Progress: " + progress + "%"); - } - } - } - } - } - } - if(sender != null){ - sender.addChatMessage(new ChatComponentText("PlayerData Conversion complete")); - } - LogWriter.info("PlayerData Converted - Please rename the playerdata_new folder to playerdata"); - }); + if (sender != null) { + LogWriter.info("PlayerData Conversion queued by " + sender.getCommandSenderName()); + sender.addChatMessage(new ChatComponentText("PlayerData Conversion to " + fileType + " format")); + } - executor.shutdown(); - } + File dir = getSaveDir(); + LogWriter.info("Converting PlayerData to " + fileType + " format"); + File[] files = dir.listFiles(); // Get an array of all files in the directory + if (files != null) { + int length = files.length; + if (length != 0) { + if (length > 100) { + LogWriter.info("Found " + length + " PlayerData files... This may take a few minutes"); + } + int tenPercent = (int) ((double) length * 0.1); + int progress = 0; + File saveDir = PlayerDataController.Instance.getNewSaveDir(); + if (saveDir == null) { + if (sender != null) { + sender.addChatMessage(new ChatComponentText("playerdata_new folder already exists please delete it or rename it")); + } + LogWriter.error("playerdata_new folder already exists please delete it or rename it"); + return; + } + // Load the files in parallel using a stream + for (int i = 0; i < length; i++) { + File file = files[i]; + if (file.isDirectory() || (!file.getName().endsWith(".json") && !file.getName().endsWith(".dat"))) + continue; + try { + String filename = "error"; + boolean valid = false; + NBTTagCompound compound = new NBTTagCompound(); + if (type) { + if (file.getName().endsWith(".json")) { + compound = NBTJsonUtil.LoadFile(file); + if (compound.hasKey("PlayerName")) { + filename = file.getName().substring(0, file.getName().length() - 5); + valid = true; + } + } + } else { + if (file.getName().endsWith(".dat")) { + compound = NBTJsonUtil.loadNBTData(file); + if (compound.hasKey("PlayerName")) { + filename = file.getName().substring(0, file.getName().length() - 4); + valid = true; + } + } + } + if (valid) { + try { + File newFile = new File(saveDir, filename + "_new" + fileType); + File oldFile = new File(saveDir, filename + fileType); + if (type) { + CompressedStreamTools.writeCompressed(compound, new FileOutputStream(newFile)); + } else { + NBTJsonUtil.SaveFile(newFile, compound); + } + if (oldFile.exists()) { + oldFile.delete(); + } + newFile.renameTo(oldFile); + } catch (Exception e) { + LogWriter.except(e); + } + } + } catch (Exception e) { + LogWriter.error("Error loading: " + file.getAbsolutePath(), e); + } + if (tenPercent != 0) { + if (progress != 100) { + if (i % tenPercent == 0) { + progress += 10; + LogWriter.info("Converting PlayerData: Progress: " + progress + "%"); + } + } + } + } + } + } + if (sender != null) { + sender.addChatMessage(new ChatComponentText("PlayerData Conversion complete")); + } + LogWriter.info("PlayerData Converted - Please rename the playerdata_new folder to playerdata"); + }); + + executor.shutdown(); + } } diff --git a/src/main/java/noppes/npcs/controllers/PlayerQuestController.java b/src/main/java/noppes/npcs/controllers/PlayerQuestController.java index f7d38a3b3..e08203136 100644 --- a/src/main/java/noppes/npcs/controllers/PlayerQuestController.java +++ b/src/main/java/noppes/npcs/controllers/PlayerQuestController.java @@ -23,86 +23,54 @@ import java.util.Vector; public class PlayerQuestController { - public static boolean hasActiveQuests(EntityPlayer player){ - PlayerQuestData data = PlayerData.get(player).questData; - return !data.activeQuests.isEmpty(); - } - - public static boolean isQuestActive(EntityPlayer player, int quest){ - PlayerQuestData data = PlayerData.get(player).questData; - return data.activeQuests.containsKey(quest); - } - - public static boolean isQuestFinished(EntityPlayer player, int questid){ - PlayerQuestData data = PlayerData.get(player).questData; - return data.finishedQuests.containsKey(questid); - } - - public static void addActiveQuest(QuestData questData, EntityPlayer player) { - PlayerData playerData = PlayerData.get(player); - PlayerQuestData data = playerData.questData; - if(canQuestBeAccepted(questData.quest, player)){ - if (EventHooks.onQuestStarted(player, questData.quest)) { - return; - } - - data.activeQuests.put(questData.quest.id,questData); - if (questData.sendAlerts) { - AchievementPacket.sendAchievement((EntityPlayerMP) player, false, "quest.newquest", questData.quest.title); - ChatAlertPacket.sendChatAlert((EntityPlayerMP) player, "quest.newquest", ": ", questData.quest.title); - } - playerData.updateClient = true; - } else { - long timeUntilRepeat = questData.quest.getTimeUntilRepeat(player); - if (timeUntilRepeat > 0 && questData.quest.getIsRepeatable() && questData.quest.repeat != EnumQuestRepeat.NONE && questData.quest.repeat != EnumQuestRepeat.REPEATABLE) { - String timeString = NoppesUtilServer.millisToTime(timeUntilRepeat); - String message = "You have " + timeString + " left until you can repeat this quest."; - player.addChatMessage(new ChatComponentTranslation(NoppesStringUtils.formatText(message,player))); - } - } - } - - public static void setQuestFinished(Quest quest, EntityPlayer player){ - PlayerData playerdata = PlayerData.get(player); - PlayerQuestData data = playerdata.questData; - QuestData questData = data.activeQuests.get(quest.id); - data.activeQuests.remove(quest.id); - setQuestFinishedUtil(player, quest, data); - if(quest.repeat != EnumQuestRepeat.NONE && quest.type == EnumQuestType.Dialog){ - QuestDialog questdialog = (QuestDialog) quest.questInterface; - for(int dialog : questdialog.dialogs.values()){ - playerdata.dialogData.dialogsRead.remove(dialog); - } - } - if (questData != null && questData.sendAlerts) { - AchievementPacket.sendAchievement((EntityPlayerMP) player, false, "quest.completed", questData.quest.title); - ChatAlertPacket.sendChatAlert((EntityPlayerMP) player, "quest.completed", ": ", questData.quest.title); - } - playerdata.updateClient = true; - } - - public static void setQuestFinishedUtil(EntityPlayer player, Quest quest, PlayerQuestData questData){ - long completeTime; - if(quest.repeat == EnumQuestRepeat.RLDAILY || quest.repeat == EnumQuestRepeat.RLWEEKLY || quest.repeat == EnumQuestRepeat.RLCUSTOM){ - completeTime = System.currentTimeMillis(); - questData.finishedQuests.put(quest.id, completeTime); - } else { - completeTime = player.worldObj.getTotalWorldTime(); - questData.finishedQuests.put(quest.id, completeTime); - } - - if(ConfigMain.ProfilesEnabled && quest.profileOptions.enableOptions && quest.profileOptions.completeControl == EnumProfileSync.Shared) - ProfileController.Instance.shareQuestCompletion(player, quest.id, completeTime); + public static boolean hasActiveQuests(EntityPlayer player) { + PlayerQuestData data = PlayerData.get(player).questData; + return !data.activeQuests.isEmpty(); } - public static void setQuestPartyFinished(Quest quest, EntityPlayer player, QuestData questData ){ + public static boolean isQuestActive(EntityPlayer player, int quest) { + PlayerQuestData data = PlayerData.get(player).questData; + return data.activeQuests.containsKey(quest); + } + + public static boolean isQuestFinished(EntityPlayer player, int questid) { + PlayerQuestData data = PlayerData.get(player).questData; + return data.finishedQuests.containsKey(questid); + } + + public static void addActiveQuest(QuestData questData, EntityPlayer player) { + PlayerData playerData = PlayerData.get(player); + PlayerQuestData data = playerData.questData; + if (canQuestBeAccepted(questData.quest, player)) { + if (EventHooks.onQuestStarted(player, questData.quest)) { + return; + } + + data.activeQuests.put(questData.quest.id, questData); + if (questData.sendAlerts) { + AchievementPacket.sendAchievement((EntityPlayerMP) player, false, "quest.newquest", questData.quest.title); + ChatAlertPacket.sendChatAlert((EntityPlayerMP) player, "quest.newquest", ": ", questData.quest.title); + } + playerData.updateClient = true; + } else { + long timeUntilRepeat = questData.quest.getTimeUntilRepeat(player); + if (timeUntilRepeat > 0 && questData.quest.getIsRepeatable() && questData.quest.repeat != EnumQuestRepeat.NONE && questData.quest.repeat != EnumQuestRepeat.REPEATABLE) { + String timeString = NoppesUtilServer.millisToTime(timeUntilRepeat); + String message = "You have " + timeString + " left until you can repeat this quest."; + player.addChatMessage(new ChatComponentTranslation(NoppesStringUtils.formatText(message, player))); + } + } + } + + public static void setQuestFinished(Quest quest, EntityPlayer player) { PlayerData playerdata = PlayerData.get(player); PlayerQuestData data = playerdata.questData; + QuestData questData = data.activeQuests.get(quest.id); data.activeQuests.remove(quest.id); setQuestFinishedUtil(player, quest, data); - if(quest.repeat != EnumQuestRepeat.NONE && quest.type == EnumQuestType.Dialog){ + if (quest.repeat != EnumQuestRepeat.NONE && quest.type == EnumQuestType.Dialog) { QuestDialog questdialog = (QuestDialog) quest.questInterface; - for(int dialog : questdialog.dialogs.values()){ + for (int dialog : questdialog.dialogs.values()) { playerdata.dialogData.dialogsRead.remove(dialog); } } @@ -113,48 +81,77 @@ public class PlayerQuestController { playerdata.updateClient = true; } - public static boolean canQuestBeAccepted(Quest quest, EntityPlayer player){ - if(quest == null) - return false; + public static void setQuestFinishedUtil(EntityPlayer player, Quest quest, PlayerQuestData questData) { + long completeTime; + if (quest.repeat == EnumQuestRepeat.RLDAILY || quest.repeat == EnumQuestRepeat.RLWEEKLY || quest.repeat == EnumQuestRepeat.RLCUSTOM) { + completeTime = System.currentTimeMillis(); + questData.finishedQuests.put(quest.id, completeTime); + } else { + completeTime = player.worldObj.getTotalWorldTime(); + questData.finishedQuests.put(quest.id, completeTime); + } - PlayerData playerData = PlayerData.get(player); - if(playerData == null) + if (ConfigMain.ProfilesEnabled && quest.profileOptions.enableOptions && quest.profileOptions.completeControl == EnumProfileSync.Shared) + ProfileController.Instance.shareQuestCompletion(player, quest.id, completeTime); + } + + public static void setQuestPartyFinished(Quest quest, EntityPlayer player, QuestData questData) { + PlayerData playerdata = PlayerData.get(player); + PlayerQuestData data = playerdata.questData; + data.activeQuests.remove(quest.id); + setQuestFinishedUtil(player, quest, data); + if (quest.repeat != EnumQuestRepeat.NONE && quest.type == EnumQuestType.Dialog) { + QuestDialog questdialog = (QuestDialog) quest.questInterface; + for (int dialog : questdialog.dialogs.values()) { + playerdata.dialogData.dialogsRead.remove(dialog); + } + } + if (questData != null && questData.sendAlerts) { + AchievementPacket.sendAchievement((EntityPlayerMP) player, false, "quest.completed", questData.quest.title); + ChatAlertPacket.sendChatAlert((EntityPlayerMP) player, "quest.completed", ": ", questData.quest.title); + } + playerdata.updateClient = true; + } + + public static boolean canQuestBeAccepted(Quest quest, EntityPlayer player) { + if (quest == null) return false; - PlayerQuestData data = playerData.questData; - if(data.activeQuests.containsKey(quest.id)) - return false; + PlayerData playerData = PlayerData.get(player); + if (playerData == null) + return false; - if(!data.finishedQuests.containsKey(quest.id) || quest.repeat == EnumQuestRepeat.REPEATABLE) - return true; - if(quest.repeat == EnumQuestRepeat.NONE) - return false; + PlayerQuestData data = playerData.questData; + if (data.activeQuests.containsKey(quest.id)) + return false; - long questTime = data.finishedQuests.get(quest.id); + if (!data.finishedQuests.containsKey(quest.id) || quest.repeat == EnumQuestRepeat.REPEATABLE) + return true; + if (quest.repeat == EnumQuestRepeat.NONE) + return false; - if(quest.repeat == EnumQuestRepeat.MCDAILY){ - return player.worldObj.getTotalWorldTime() - questTime >= 24000; - } - else if(quest.repeat == EnumQuestRepeat.MCWEEKLY){ - return player.worldObj.getTotalWorldTime() - questTime >= 168000; - } - else if(quest.repeat == EnumQuestRepeat.RLDAILY){ - return System.currentTimeMillis() - questTime >= 86400000; - } - else if(quest.repeat == EnumQuestRepeat.RLWEEKLY){ - return System.currentTimeMillis() - questTime >= 604800000; - } - return false; - } - public static Vector getActiveQuests(EntityPlayer player) - { - Vector quests = new Vector(); - PlayerQuestData data = PlayerData.get(player).questData; - for(QuestData questdata: data.activeQuests.values()){ - if(questdata.quest == null) - continue; - quests.add(questdata.quest); - } - return quests; - } + long questTime = data.finishedQuests.get(quest.id); + + if (quest.repeat == EnumQuestRepeat.MCDAILY) { + return player.worldObj.getTotalWorldTime() - questTime >= 24000; + } else if (quest.repeat == EnumQuestRepeat.MCWEEKLY) { + return player.worldObj.getTotalWorldTime() - questTime >= 168000; + } else if (quest.repeat == EnumQuestRepeat.RLDAILY) { + return System.currentTimeMillis() - questTime >= 86400000; + } else if (quest.repeat == EnumQuestRepeat.RLWEEKLY) { + return System.currentTimeMillis() - questTime >= 604800000; + } + return false; + } + + public static Vector getActiveQuests(EntityPlayer player) { + Vector quests = new Vector(); + PlayerQuestData data = PlayerData.get(player).questData; + for (QuestData questdata : data.activeQuests.values()) { + if (questdata.quest == null) + continue; + quests.add(questdata.quest); + } + return quests; + } } diff --git a/src/main/java/noppes/npcs/controllers/QuestController.java b/src/main/java/noppes/npcs/controllers/QuestController.java index 3b5616e4d..5987b3a44 100644 --- a/src/main/java/noppes/npcs/controllers/QuestController.java +++ b/src/main/java/noppes/npcs/controllers/QuestController.java @@ -21,243 +21,242 @@ import java.io.FileInputStream; import java.util.*; public class QuestController implements IQuestHandler { - public HashMap categoriesSync = new HashMap(); - public HashMap categories = new HashMap(); - public HashMap quests = new HashMap(); + public HashMap categoriesSync = new HashMap(); + public HashMap categories = new HashMap(); + public HashMap quests = new HashMap(); public HashMap sharedQuests = new HashMap<>(); - public static QuestController Instance = new QuestController();; + public static QuestController Instance = new QuestController(); + ; - private int lastUsedCatID = 0; - private int lastUsedQuestID = 0; + private int lastUsedCatID = 0; + private int lastUsedQuestID = 0; - public QuestController(){ - Instance = this; - } + public QuestController() { + Instance = this; + } - public void load(){ - categories.clear(); - quests.clear(); + public void load() { + categories.clear(); + quests.clear(); - lastUsedCatID = 0; - lastUsedQuestID = 0; + lastUsedCatID = 0; + lastUsedQuestID = 0; - try { - File file = new File(CustomNpcs.getWorldSaveDirectory(), "quests.dat"); - if(file.exists()){ - loadCategoriesOld(file); - file.delete(); - file = new File(CustomNpcs.getWorldSaveDirectory(), "quests.dat_old"); - if(file.exists()) - file.delete(); - return; - } - } catch (Exception e) { + try { + File file = new File(CustomNpcs.getWorldSaveDirectory(), "quests.dat"); + if (file.exists()) { + loadCategoriesOld(file); + file.delete(); + file = new File(CustomNpcs.getWorldSaveDirectory(), "quests.dat_old"); + if (file.exists()) + file.delete(); + return; + } + } catch (Exception e) { - } + } - File dir = getDir(); - if(!dir.exists()){ - dir.mkdir(); - } - else{ - for(File file : dir.listFiles()){ - if(!file.isDirectory()) - continue; - QuestCategory category = loadCategoryDir(file); - Iterator ite = category.quests.keySet().iterator(); - while(ite.hasNext()){ - int id = ite.next(); - if(id > lastUsedQuestID) - lastUsedQuestID = id; - Quest quest = category.quests.get(id); - if(quests.containsKey(id)){ - LogWriter.error("Duplicate id " + quest.id + " from category " + category.title); - ite.remove(); - } - else{ - quests.put(id, quest); - if(quest.profileOptions.enableOptions && quest.profileOptions.completeControl == EnumProfileSync.Shared){ + File dir = getDir(); + if (!dir.exists()) { + dir.mkdir(); + } else { + for (File file : dir.listFiles()) { + if (!file.isDirectory()) + continue; + QuestCategory category = loadCategoryDir(file); + Iterator ite = category.quests.keySet().iterator(); + while (ite.hasNext()) { + int id = ite.next(); + if (id > lastUsedQuestID) + lastUsedQuestID = id; + Quest quest = category.quests.get(id); + if (quests.containsKey(id)) { + LogWriter.error("Duplicate id " + quest.id + " from category " + category.title); + ite.remove(); + } else { + quests.put(id, quest); + if (quest.profileOptions.enableOptions && quest.profileOptions.completeControl == EnumProfileSync.Shared) { sharedQuests.put(id, quest); } - } - } - lastUsedCatID++; - category.id = lastUsedCatID; - categories.put(category.id, category); - } - } - } - private QuestCategory loadCategoryDir(File dir) { - QuestCategory category = new QuestCategory(); - category.title = dir.getName(); - for(File file : dir.listFiles()){ - if(!file.isFile() || !file.getName().endsWith(".json")) - continue; - try{ - Quest quest = new Quest(); - quest.id = Integer.parseInt(file.getName().substring(0, file.getName().length() - 5)); - quest.readNBTPartial(NBTJsonUtil.LoadFile(file)); - category.quests.put(quest.id, quest); - quest.category = category; - } - catch(Exception e){ - LogWriter.error("Error loading: " + file.getAbsolutePath(), e); - } - } - return category; - } - private void loadCategoriesOld(File file) throws Exception{ - File dir = getDir(); - if(!dir.exists()){ - dir.mkdir(); - } + } + } + lastUsedCatID++; + category.id = lastUsedCatID; + categories.put(category.id, category); + } + } + } + + private QuestCategory loadCategoryDir(File dir) { + QuestCategory category = new QuestCategory(); + category.title = dir.getName(); + for (File file : dir.listFiles()) { + if (!file.isFile() || !file.getName().endsWith(".json")) + continue; + try { + Quest quest = new Quest(); + quest.id = Integer.parseInt(file.getName().substring(0, file.getName().length() - 5)); + quest.readNBTPartial(NBTJsonUtil.LoadFile(file)); + category.quests.put(quest.id, quest); + quest.category = category; + } catch (Exception e) { + LogWriter.error("Error loading: " + file.getAbsolutePath(), e); + } + } + return category; + } + + private void loadCategoriesOld(File file) throws Exception { + File dir = getDir(); + if (!dir.exists()) { + dir.mkdir(); + } NBTTagCompound nbttagcompound1 = CompressedStreamTools.readCompressed(new FileInputStream(file)); lastUsedCatID = nbttagcompound1.getInteger("lastID"); lastUsedQuestID = nbttagcompound1.getInteger("lastQuestID"); NBTTagList list = nbttagcompound1.getTagList("Data", 10); - if(list != null){ - for(int i = 0; i < list.tagCount(); i++) - { - QuestCategory category = new QuestCategory(); - category.readNBT(list.getCompoundTagAt(i)); - categories.put(category.id,category); - saveCategory(category); + if (list != null) { + for (int i = 0; i < list.tagCount(); i++) { + QuestCategory category = new QuestCategory(); + category.readNBT(list.getCompoundTagAt(i)); + categories.put(category.id, category); + saveCategory(category); Iterator> ita = category.quests.entrySet().iterator(); - while(ita.hasNext()){ - Map.Entry entry = ita.next(); - Quest quest = entry.getValue(); - quest.id = entry.getKey(); - quest.category = category; - if(quests.containsKey(quest.id)) - ita.remove(); - else{ - saveQuest(category.id, quest); - } + while (ita.hasNext()) { + Map.Entry entry = ita.next(); + Quest quest = entry.getValue(); + quest.id = entry.getKey(); + quest.category = category; + if (quests.containsKey(quest.id)) + ita.remove(); + else { + saveQuest(category.id, quest); + } } - } + } } - } + } - public void removeCategory(int category){ - QuestCategory cat = categories.get(category); - if(cat == null) - return; - File dir = new File(getDir(), cat.title); - if(!dir.delete()) - return; - for(int dia : cat.quests.keySet()) - quests.remove(dia); - categories.remove(category); + public void removeCategory(int category) { + QuestCategory cat = categories.get(category); + if (cat == null) + return; + File dir = new File(getDir(), cat.title); + if (!dir.delete()) + return; + for (int dia : cat.quests.keySet()) + quests.remove(dia); + categories.remove(category); SyncController.syncRemove(EnumSyncType.QUEST_CATEGORY, category); - } + } - public void saveCategory(QuestCategory category){ - category.title = NoppesStringUtils.cleanFileName(category.title); - if(categories.containsKey(category.id)){ - QuestCategory currentCategory = categories.get(category.id); - if(!currentCategory.title.equals(category.title)){ - while(containsCategoryName(category.title)) - category.title += "_"; - File newdir = new File(getDir(), category.title); - File olddir = new File(getDir(), currentCategory.title); - if(newdir.exists()) - return; - if(!olddir.renameTo(newdir)) - return; - } - category.quests = currentCategory.quests; - } - else{ - if(category.id < 0){ - lastUsedCatID++; - category.id = lastUsedCatID; - } - while(containsCategoryName(category.title)) - category.title += "_"; - File dir = new File(getDir(), category.title); - if(!dir.exists()) - dir.mkdirs(); - } - categories.put(category.id, category); + public void saveCategory(QuestCategory category) { + category.title = NoppesStringUtils.cleanFileName(category.title); + if (categories.containsKey(category.id)) { + QuestCategory currentCategory = categories.get(category.id); + if (!currentCategory.title.equals(category.title)) { + while (containsCategoryName(category.title)) + category.title += "_"; + File newdir = new File(getDir(), category.title); + File olddir = new File(getDir(), currentCategory.title); + if (newdir.exists()) + return; + if (!olddir.renameTo(newdir)) + return; + } + category.quests = currentCategory.quests; + } else { + if (category.id < 0) { + lastUsedCatID++; + category.id = lastUsedCatID; + } + while (containsCategoryName(category.title)) + category.title += "_"; + File dir = new File(getDir(), category.title); + if (!dir.exists()) + dir.mkdirs(); + } + categories.put(category.id, category); SyncController.syncUpdate(EnumSyncType.QUEST_CATEGORY, -1, SyncController.updateQuestCat(category)); } - private boolean containsCategoryName(String name) { - name = name.toLowerCase(); - for(QuestCategory cat : categories.values()){ - if(cat.title.toLowerCase().equals(name)) - return true; - } - return false; - } - private boolean containsQuestName(QuestCategory category, Quest quest) { - for(Quest q : category.quests.values()){ - if(q.id != quest.id && q.title.equalsIgnoreCase(quest.title)) - return true; - } - return false; - } + private boolean containsCategoryName(String name) { + name = name.toLowerCase(); + for (QuestCategory cat : categories.values()) { + if (cat.title.toLowerCase().equals(name)) + return true; + } + return false; + } - public void saveQuest(int categoryID, Quest quest){ - QuestCategory category = categories.get(categoryID); - if(category == null) - return; - quest.category = category; + private boolean containsQuestName(QuestCategory category, Quest quest) { + for (Quest q : category.quests.values()) { + if (q.id != quest.id && q.title.equalsIgnoreCase(quest.title)) + return true; + } + return false; + } - while(containsQuestName(quest.category, quest)){ - quest.title = quest.title + "_"; - } + public void saveQuest(int categoryID, Quest quest) { + QuestCategory category = categories.get(categoryID); + if (category == null) + return; + quest.category = category; - if(quest.id < 0){ - lastUsedQuestID++; - quest.id = lastUsedQuestID; - } + while (containsQuestName(quest.category, quest)) { + quest.title = quest.title + "_"; + } - quests.put(quest.id, quest); - category.quests.put(quest.id, quest); + if (quest.id < 0) { + lastUsedQuestID++; + quest.id = lastUsedQuestID; + } + + quests.put(quest.id, quest); + category.quests.put(quest.id, quest); sharedQuests.remove(quest.id); - if(quest.profileOptions.enableOptions && quest.profileOptions.completeControl == EnumProfileSync.Shared){ + if (quest.profileOptions.enableOptions && quest.profileOptions.completeControl == EnumProfileSync.Shared) { sharedQuests.put(quest.id, quest); } - File dir = new File(getDir(), category.title); - if(!dir.exists()) - dir.mkdirs(); + File dir = new File(getDir(), category.title); + if (!dir.exists()) + dir.mkdirs(); - File file = new File(dir, quest.id + ".json_new"); - File file2 = new File(dir, quest.id + ".json"); + File file = new File(dir, quest.id + ".json_new"); + File file2 = new File(dir, quest.id + ".json"); - try { - NBTJsonUtil.SaveFile(file, quest.writeToNBTPartial(new NBTTagCompound())); - if(file2.exists()) - file2.delete(); - file.renameTo(file2); + try { + NBTJsonUtil.SaveFile(file, quest.writeToNBTPartial(new NBTTagCompound())); + if (file2.exists()) + file2.delete(); + file.renameTo(file2); SyncController.syncUpdate(EnumSyncType.QUEST, category.id, quest.writeToNBT(new NBTTagCompound())); - } catch (Exception e) { - e.printStackTrace(); - } - } + } catch (Exception e) { + e.printStackTrace(); + } + } - public void removeQuest(Quest quest) { - File file = new File(new File(getDir(), quest.category.title), quest.id + ".json"); - if(!file.delete()) - return; - quests.remove(quest.id); - quest.category.quests.remove(quest.id); - } + public void removeQuest(Quest quest) { + File file = new File(new File(getDir(), quest.category.title), quest.id + ".json"); + if (!file.delete()) + return; + quests.remove(quest.id); + quest.category.quests.remove(quest.id); + } - private File getDir(){ - return new File(CustomNpcs.getWorldSaveDirectory(), "quests"); - } + private File getDir() { + return new File(CustomNpcs.getWorldSaveDirectory(), "quests"); + } - public List categories() { - return new ArrayList(this.categories.values()); - } + public List categories() { + return new ArrayList(this.categories.values()); + } - public IQuest get(int id) { - return (IQuest)this.quests.get(id); - } + public IQuest get(int id) { + return (IQuest) this.quests.get(id); + } } diff --git a/src/main/java/noppes/npcs/controllers/RecipeController.java b/src/main/java/noppes/npcs/controllers/RecipeController.java index 39894ce4d..77d877b40 100644 --- a/src/main/java/noppes/npcs/controllers/RecipeController.java +++ b/src/main/java/noppes/npcs/controllers/RecipeController.java @@ -22,99 +22,99 @@ import java.io.IOException; import java.util.*; public class RecipeController implements IRecipeHandler { - private static Collection prevRecipes; + private static Collection prevRecipes; public HashMap globalRecipes = new HashMap(); - public HashMap carpentryRecipes = new HashMap(); + public HashMap carpentryRecipes = new HashMap(); public HashMap anvilRecipes = new HashMap(); public static RecipeController Instance; - public static final int version = 1; - public int nextId = 1; + public static final int version = 1; + public int nextId = 1; public int nextAnvilId = 1; - public static HashMap syncRecipes = new HashMap(); + public static HashMap syncRecipes = new HashMap(); public static HashMap syncAnvilRecipes = new HashMap(); - public RecipeController(){ - Instance = this; - } - public void load(){ - loadCategories(); - reloadGlobalRecipes(globalRecipes); - } + public RecipeController() { + Instance = this; + } - public static void reloadGlobalRecipes(HashMap globalRecipes){ - List list = CraftingManager.getInstance().getRecipeList(); - if(prevRecipes != null){ - list.removeAll(prevRecipes); - } + public void load() { + loadCategories(); + reloadGlobalRecipes(globalRecipes); + } - prevRecipes = new HashSet(); - for(RecipeCarpentry recipe : globalRecipes.values()){ - if(recipe.isValid()) - prevRecipes.add(recipe); - } - list.addAll(prevRecipes); - } + public static void reloadGlobalRecipes(HashMap globalRecipes) { + List list = CraftingManager.getInstance().getRecipeList(); + if (prevRecipes != null) { + list.removeAll(prevRecipes); + } - private void loadCategories(){ - File saveDir = CustomNpcs.getWorldSaveDirectory(); - try { - File file = new File(saveDir, "recipes.dat"); - if(file.exists()){ - loadCategories(file); - } - else{ - globalRecipes.clear(); - carpentryRecipes.clear(); + prevRecipes = new HashSet(); + for (RecipeCarpentry recipe : globalRecipes.values()) { + if (recipe.isValid()) + prevRecipes.add(recipe); + } + list.addAll(prevRecipes); + } + + private void loadCategories() { + File saveDir = CustomNpcs.getWorldSaveDirectory(); + try { + File file = new File(saveDir, "recipes.dat"); + if (file.exists()) { + loadCategories(file); + } else { + globalRecipes.clear(); + carpentryRecipes.clear(); anvilRecipes.clear(); - loadDefaultRecipes(-1); - } - } catch (Exception e) { - e.printStackTrace(); - try { - File file = new File(saveDir, "recipes.dat_old"); - if(file.exists()){ - loadCategories(file); - } - } catch (Exception ee) { - e.printStackTrace(); - } - } - } - private void loadDefaultRecipes(int i) { - if(i == version) - return; - RecipesDefault.loadDefaultRecipes(i); - saveCategories(); - } + loadDefaultRecipes(-1); + } + } catch (Exception e) { + e.printStackTrace(); + try { + File file = new File(saveDir, "recipes.dat_old"); + if (file.exists()) { + loadCategories(file); + } + } catch (Exception ee) { + e.printStackTrace(); + } + } + } - private void loadCategories(File file) throws Exception{ + private void loadDefaultRecipes(int i) { + if (i == version) + return; + RecipesDefault.loadDefaultRecipes(i); + saveCategories(); + } + + private void loadCategories(File file) throws Exception { NBTTagCompound nbttagcompound1 = CompressedStreamTools.readCompressed(new FileInputStream(file)); nextId = nbttagcompound1.getInteger("LastId"); nextAnvilId = nbttagcompound1.getInteger("LastAnvilId"); NBTTagList list = nbttagcompound1.getTagList("Data", 10); - HashMap globalRecipes = new HashMap(); - HashMap carpentryRecipes = new HashMap(); - HashMap anvilRecipes = new HashMap(); - if(list != null){ - for(int i = 0; i < list.tagCount(); i++) - { + HashMap globalRecipes = new HashMap(); + HashMap carpentryRecipes = new HashMap(); + HashMap anvilRecipes = new HashMap(); + if (list != null) { + for (int i = 0; i < list.tagCount(); i++) { NBTTagCompound compound = list.getCompoundTagAt(i); - if(compound.hasKey("IsAnvil")){ + if (compound.hasKey("IsAnvil")) { RecipeAnvil anvil = RecipeAnvil.read(compound); anvilRecipes.put(anvil.id, anvil); - if(anvil.id > nextAnvilId) + if (anvil.id > nextAnvilId) nextAnvilId = anvil.id; } else { RecipeCarpentry recipe = RecipeCarpentry.read(compound); - if(recipe.isGlobal) - globalRecipes.put(recipe.id,recipe); + if (recipe.isGlobal) + globalRecipes.put(recipe.id, recipe); else - carpentryRecipes.put(recipe.id,recipe); - if(recipe.id > nextId) + carpentryRecipes.put(recipe.id, recipe); + if (recipe.id > nextId) nextId = recipe.id; } } @@ -122,110 +122,107 @@ public class RecipeController implements IRecipeHandler { this.carpentryRecipes = carpentryRecipes; this.globalRecipes = globalRecipes; this.anvilRecipes = anvilRecipes; - loadDefaultRecipes(nbttagcompound1.getInteger("Version")); - } - private void saveCategories(){ - try { - File saveDir = CustomNpcs.getWorldSaveDirectory(); - NBTTagList list = new NBTTagList(); - for(RecipeCarpentry recipe : globalRecipes.values()){ - list.appendTag(recipe.writeNBT()); - } - for(RecipeCarpentry recipe : carpentryRecipes.values()){ - list.appendTag(recipe.writeNBT()); - } - for(RecipeAnvil recipe : anvilRecipes.values()){ + loadDefaultRecipes(nbttagcompound1.getInteger("Version")); + } + + private void saveCategories() { + try { + File saveDir = CustomNpcs.getWorldSaveDirectory(); + NBTTagList list = new NBTTagList(); + for (RecipeCarpentry recipe : globalRecipes.values()) { list.appendTag(recipe.writeNBT()); } - NBTTagCompound nbttagcompound = new NBTTagCompound(); - nbttagcompound.setTag("Data", list); - nbttagcompound.setInteger("LastId", nextId); + for (RecipeCarpentry recipe : carpentryRecipes.values()) { + list.appendTag(recipe.writeNBT()); + } + for (RecipeAnvil recipe : anvilRecipes.values()) { + list.appendTag(recipe.writeNBT()); + } + NBTTagCompound nbttagcompound = new NBTTagCompound(); + nbttagcompound.setTag("Data", list); + nbttagcompound.setInteger("LastId", nextId); nbttagcompound.setInteger("LastAnvilId", nextAnvilId); - nbttagcompound.setInteger("Version", version); + nbttagcompound.setInteger("Version", version); File file = new File(saveDir, "recipes.dat_new"); File file1 = new File(saveDir, "recipes.dat_old"); File file2 = new File(saveDir, "recipes.dat"); CompressedStreamTools.writeCompressed(nbttagcompound, new FileOutputStream(file)); - if(file1.exists()) - { + if (file1.exists()) { file1.delete(); } file2.renameTo(file1); - if(file2.exists()) - { + if (file2.exists()) { file2.delete(); } file.renameTo(file2); - if(file.exists()) - { + if (file.exists()) { file.delete(); } - } catch (Exception e) { - e.printStackTrace(); - } - } - - public RecipeCarpentry findMatchingRecipe(InventoryCrafting par1InventoryCrafting){ - for(RecipeCarpentry recipe : carpentryRecipes.values()){ - if(recipe.isValid() && recipe.matches(par1InventoryCrafting,null)) - return recipe; - } - return null; + } catch (Exception e) { + e.printStackTrace(); + } } - public RecipeCarpentry getRecipe(int id) { - if(globalRecipes.containsKey(id)) - return globalRecipes.get(id); - if(carpentryRecipes.containsKey(id)) - return carpentryRecipes.get(id); - return null; - } + public RecipeCarpentry findMatchingRecipe(InventoryCrafting par1InventoryCrafting) { + for (RecipeCarpentry recipe : carpentryRecipes.values()) { + if (recipe.isValid() && recipe.matches(par1InventoryCrafting, null)) + return recipe; + } + return null; + } + + public RecipeCarpentry getRecipe(int id) { + if (globalRecipes.containsKey(id)) + return globalRecipes.get(id); + if (carpentryRecipes.containsKey(id)) + return carpentryRecipes.get(id); + return null; + } public RecipeAnvil getAnvilRecipe(int id) { - if(anvilRecipes.containsKey(id)) + if (anvilRecipes.containsKey(id)) return anvilRecipes.get(id); return null; } - public RecipeCarpentry saveRecipe(NBTTagCompound compound) throws IOException { - RecipeCarpentry recipe = RecipeCarpentry.read(compound); + public RecipeCarpentry saveRecipe(NBTTagCompound compound) throws IOException { + RecipeCarpentry recipe = RecipeCarpentry.read(compound); - RecipeCarpentry current = getRecipe(recipe.id); - if(current != null && !current.name.equals(recipe.name)){ - while(containsRecipeName(recipe.name)) - recipe.name += "_"; - } + RecipeCarpentry current = getRecipe(recipe.id); + if (current != null && !current.name.equals(recipe.name)) { + while (containsRecipeName(recipe.name)) + recipe.name += "_"; + } - if(recipe.id == -1){ - recipe.id = getUniqueId(); - while(containsRecipeName(recipe.name)) - recipe.name += "_"; - } - if(recipe.isGlobal){ - carpentryRecipes.remove(recipe.id); - globalRecipes.put(recipe.id, recipe); - } - else{ - globalRecipes.remove(recipe.id); - carpentryRecipes.put(recipe.id, recipe); - } - saveCategories(); - reloadGlobalRecipes(globalRecipes); - return recipe; - } + if (recipe.id == -1) { + recipe.id = getUniqueId(); + while (containsRecipeName(recipe.name)) + recipe.name += "_"; + } + if (recipe.isGlobal) { + carpentryRecipes.remove(recipe.id); + globalRecipes.put(recipe.id, recipe); + } else { + globalRecipes.remove(recipe.id); + carpentryRecipes.put(recipe.id, recipe); + } + saveCategories(); + reloadGlobalRecipes(globalRecipes); + return recipe; + } public RecipeAnvil saveAnvilRecipe(NBTTagCompound compound) throws IOException { RecipeAnvil recipe = RecipeAnvil.read(compound); RecipeAnvil current = getAnvilRecipe(recipe.id); - if(current != null && !current.name.equals(recipe.name)){ - while(containsAnvilRecipeName(recipe.name)) + if (current != null && !current.name.equals(recipe.name)) { + while (containsAnvilRecipeName(recipe.name)) recipe.name += "_"; } - if(recipe.id == -1){ + if (recipe.id == -1) { recipe.id = getUniqueAnvilId(); - while(containsAnvilRecipeName(recipe.name)) + while (containsAnvilRecipeName(recipe.name)) recipe.name += "_"; } @@ -234,74 +231,74 @@ public class RecipeController implements IRecipeHandler { return recipe; } - private int getUniqueId() { - return nextId++; - } + private int getUniqueId() { + return nextId++; + } private int getUniqueAnvilId() { return nextAnvilId++; } - private boolean containsRecipeName(String name) { - name = name.toLowerCase(); - for(RecipeCarpentry recipe : globalRecipes.values()){ - if(recipe.name.toLowerCase().equals(name)) - return true; - } - for(RecipeCarpentry recipe : carpentryRecipes.values()){ - if(recipe.name.toLowerCase().equals(name)) - return true; - } - return false; - } - - private boolean containsAnvilRecipeName(String name) { + private boolean containsRecipeName(String name) { name = name.toLowerCase(); - for(RecipeAnvil recipe : anvilRecipes.values()){ - if(recipe.name.toLowerCase().equals(name)) + for (RecipeCarpentry recipe : globalRecipes.values()) { + if (recipe.name.toLowerCase().equals(name)) + return true; + } + for (RecipeCarpentry recipe : carpentryRecipes.values()) { + if (recipe.name.toLowerCase().equals(name)) return true; } return false; } - public RecipeCarpentry delete(int id) { - RecipeCarpentry recipe = getRecipe(id); - if(recipe == null) + private boolean containsAnvilRecipeName(String name) { + name = name.toLowerCase(); + for (RecipeAnvil recipe : anvilRecipes.values()) { + if (recipe.name.toLowerCase().equals(name)) + return true; + } + return false; + } + + public RecipeCarpentry delete(int id) { + RecipeCarpentry recipe = getRecipe(id); + if (recipe == null) return null; - RecipeCarpentry globalRecipe = globalRecipes.remove(recipe.id); - if(globalRecipe != null) + RecipeCarpentry globalRecipe = globalRecipes.remove(recipe.id); + if (globalRecipe != null) SyncController.syncAllWorkbenchRecipes(); RecipeCarpentry carpentry = carpentryRecipes.remove(recipe.id); - if(carpentry != null) + if (carpentry != null) SyncController.syncAllCarpentryRecipes(); - saveCategories(); - reloadGlobalRecipes(globalRecipes); - return recipe; - } + saveCategories(); + reloadGlobalRecipes(globalRecipes); + return recipe; + } public RecipeAnvil deleteAnvil(int id) { RecipeAnvil recipe = getAnvilRecipe(id); - if(recipe == null) + if (recipe == null) return null; RecipeAnvil anvilRecipe = anvilRecipes.remove(recipe.id); - if(anvilRecipe != null) + if (anvilRecipe != null) SyncController.syncAllAnvilRecipes(); saveCategories(); return recipe; } - public void addRecipe(RecipeCarpentry recipeCarpentry) { - recipeCarpentry.id = getUniqueId(); - if(!recipeCarpentry.isGlobal) - RecipeController.Instance.carpentryRecipes.put(recipeCarpentry.id, recipeCarpentry); - else{ - RecipeController.Instance.globalRecipes.put(recipeCarpentry.id, recipeCarpentry); - } - } + public void addRecipe(RecipeCarpentry recipeCarpentry) { + recipeCarpentry.id = getUniqueId(); + if (!recipeCarpentry.isGlobal) + RecipeController.Instance.carpentryRecipes.put(recipeCarpentry.id, recipeCarpentry); + else { + RecipeController.Instance.globalRecipes.put(recipeCarpentry.id, recipeCarpentry); + } + } public void addAnvilRecipe(RecipeAnvil recipeAnvil) { recipeAnvil.id = getUniqueAnvilId(); @@ -309,14 +306,14 @@ public class RecipeController implements IRecipeHandler { } @Override - public List getGlobalList() { - return new ArrayList(this.globalRecipes.values()); - } + public List getGlobalList() { + return new ArrayList(this.globalRecipes.values()); + } @Override - public List getCarpentryList() { - return new ArrayList(this.carpentryRecipes.values()); - } + public List getCarpentryList() { + return new ArrayList(this.carpentryRecipes.values()); + } @Override public List getAnvilList() { @@ -326,40 +323,40 @@ public class RecipeController implements IRecipeHandler { } @Override - public void addRecipe(String name, boolean global, ItemStack result, Object... objects) { - RecipeCarpentry recipe = new RecipeCarpentry(name); - recipe.isGlobal = global; - recipe = RecipeCarpentry.saveRecipe(recipe, result, objects); + public void addRecipe(String name, boolean global, ItemStack result, Object... objects) { + RecipeCarpentry recipe = new RecipeCarpentry(name); + recipe.isGlobal = global; + recipe = RecipeCarpentry.saveRecipe(recipe, result, objects); - try { - this.saveRecipe(recipe.writeNBT()); - } catch (Exception var7) { - var7.printStackTrace(); - } - } + try { + this.saveRecipe(recipe.writeNBT()); + } catch (Exception var7) { + var7.printStackTrace(); + } + } @Override - public void addRecipe(String name, boolean global, ItemStack result, int width, int height, ItemStack... objects) { - ArrayList list = new ArrayList<>(); - int var9 = objects.length; + public void addRecipe(String name, boolean global, ItemStack result, int width, int height, ItemStack... objects) { + ArrayList list = new ArrayList<>(); + int var9 = objects.length; - for(int var10 = 0; var10 < var9; ++var10) { - ItemStack item = objects[var10]; - if (item.stackSize > 0) { - list.add(item); - } - } + for (int var10 = 0; var10 < var9; ++var10) { + ItemStack item = objects[var10]; + if (item.stackSize > 0) { + list.add(item); + } + } - RecipeCarpentry recipe = new RecipeCarpentry(width, height, list.toArray(new ItemStack[0]), result); - recipe.isGlobal = global; - recipe.name = name; + RecipeCarpentry recipe = new RecipeCarpentry(width, height, list.toArray(new ItemStack[0]), result); + recipe.isGlobal = global; + recipe.name = name; - try { - this.saveRecipe(recipe.writeNBT()); - } catch (IOException var12) { - var12.printStackTrace(); - } - } + try { + this.saveRecipe(recipe.writeNBT()); + } catch (IOException var12) { + var12.printStackTrace(); + } + } @Override public void addAnvilRecipe(String name, boolean global, ItemStack itemToRepair, ItemStack repairMaterial, int xpCost, float repairPercentage) { diff --git a/src/main/java/noppes/npcs/controllers/ScriptContainer.java b/src/main/java/noppes/npcs/controllers/ScriptContainer.java index 8ed7045d3..bb2ef4500 100644 --- a/src/main/java/noppes/npcs/controllers/ScriptContainer.java +++ b/src/main/java/noppes/npcs/controllers/ScriptContainer.java @@ -44,8 +44,8 @@ public class ScriptContainer { String prevScript = this.script; this.script = compound.getString("Script"); for (int i = 0; i < ConfigScript.ExpandedScriptLimit; i++) { - if (compound.hasKey("ExpandedScript"+i)) { - this.script += compound.getString("ExpandedScript"+i); + if (compound.hasKey("ExpandedScript" + i)) { + this.script += compound.getString("ExpandedScript" + i); } else { break; } @@ -91,18 +91,18 @@ public class ScriptContainer { } private String getFullCode() { - if(!this.evaluated) { + if (!this.evaluated) { this.fullscript = this.script; - if(!this.fullscript.isEmpty()) { + if (!this.fullscript.isEmpty()) { this.fullscript = this.fullscript + "\n"; } Iterator var1 = this.scripts.iterator(); - while(var1.hasNext()) { - String loc = (String)var1.next(); - String code = (String)ScriptController.Instance.scripts.get(loc); - if(code != null && !code.isEmpty()) { + while (var1.hasNext()) { + String loc = (String) var1.next(); + String code = (String) ScriptController.Instance.scripts.get(loc); + if (code != null && !code.isEmpty()) { this.fullscript = this.fullscript + code + "\n"; } } @@ -112,17 +112,17 @@ public class ScriptContainer { return this.fullscript; } - public void run(ScriptEngine engine){ + public void run(ScriptEngine engine) { StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); this.engine.getContext().setWriter(pw); this.engine.getContext().setErrorWriter(pw); try { - if(compScript == null && engine instanceof Compilable) - compScript = ((Compilable)engine).compile(getFullCode()); + if (compScript == null && engine instanceof Compilable) + compScript = ((Compilable) engine).compile(getFullCode()); - if(compScript != null){ + if (compScript != null) { compScript.eval(engine.getContext()); } else { engine.eval(getFullCode()); @@ -138,21 +138,21 @@ public class ScriptContainer { } public void run(EnumScriptType type, Event event) { - if(!ConfigScript.ScriptingEnabled) + if (!ConfigScript.ScriptingEnabled) return; - this.run((String)type.function, (Object)event); + this.run((String) type.function, (Object) event); } public void run(String type, Object event) { - if(!ConfigScript.ScriptingEnabled || errored || !hasCode() || unknownFunctions.contains(type)) + if (!ConfigScript.ScriptingEnabled || errored || !hasCode() || unknownFunctions.contains(type)) return; this.setEngine(handler.getLanguage()); - if(engine == null) + if (engine == null) return; - if(ScriptController.Instance.lastLoaded > this.lastCreated){ + if (ScriptController.Instance.lastLoaded > this.lastCreated) { this.lastCreated = ScriptController.Instance.lastLoaded; evaluated = false; } @@ -168,39 +168,36 @@ public class ScriptContainer { engine.getContext().setErrorWriter(pw); engine.put("API", NpcAPI.Instance()); - HashMap engineEntries = new HashMap<>(NpcAPI.engineObjects); - for (Map.Entry objectEntry : engineEntries.entrySet()) { - engine.put(objectEntry.getKey(),objectEntry.getValue()); + HashMap engineEntries = new HashMap<>(NpcAPI.engineObjects); + for (Map.Entry objectEntry : engineEntries.entrySet()) { + engine.put(objectEntry.getKey(), objectEntry.getValue()); } try { - if(!evaluated){ + if (!evaluated) { engine.eval(getFullCode()); evaluated = true; } - if(engine.getFactory().getLanguageName().equals("lua")){ + if (engine.getFactory().getLanguageName().equals("lua")) { Object ob = engine.get(type); - if(ob != null){ - if(luaCoerce == null){ + if (ob != null) { + if (luaCoerce == null) { luaCoerce = Class.forName("org.luaj.vm2.lib.jse.CoerceJavaToLua").getMethod("coerce", Object.class); luaCall = ob.getClass().getMethod("call", Class.forName("org.luaj.vm2.LuaValue")); } luaCall.invoke(ob, luaCoerce.invoke(null, event)); - } - else{ + } else { unknownFunctions.add(type); } - } - else{ - ((Invocable)engine).invokeFunction(type, event); + } else { + ((Invocable) engine).invokeFunction(type, event); } } catch (NoSuchMethodException e) { unknownFunctions.add(type); } catch (Throwable e) { errored = true; e.printStackTrace(pw); - } - finally { + } finally { appendConsole(sw.getBuffer().toString().trim()); pw.close(); Current = null; @@ -212,12 +209,12 @@ public class ScriptContainer { if (message != null && !message.isEmpty()) { long time = System.currentTimeMillis(); if (this.console.containsKey(time)) { - message = (String)this.console.get(time) + "\n" + message; + message = (String) this.console.get(time) + "\n" + message; } this.console.put(time, message); - while(this.console.size() > 40) { + while (this.console.size() > 40) { this.console.remove(this.console.firstKey()); } } @@ -228,7 +225,7 @@ public class ScriptContainer { } public boolean hasCode() { - if(!scripts.isEmpty()) + if (!scripts.isEmpty()) return true; return !this.getFullCode().isEmpty(); } diff --git a/src/main/java/noppes/npcs/controllers/ScriptController.java b/src/main/java/noppes/npcs/controllers/ScriptController.java index 4217f8668..a1603a78e 100644 --- a/src/main/java/noppes/npcs/controllers/ScriptController.java +++ b/src/main/java/noppes/npcs/controllers/ScriptController.java @@ -34,152 +34,153 @@ import static noppes.npcs.util.CustomNPCsThreader.customNPCThread; public class ScriptController { - public static ScriptController Instance; - public static boolean HasStart = false; - private final ScriptEngineManager manager; - private ScriptEngineFactory nashornFactory; - public Map languages = new HashMap(); - public Map scripts = new HashMap(); - public long lastLoaded = 0; - public File dir; - public NBTTagCompound compound = new NBTTagCompound(); + public static ScriptController Instance; + public static boolean HasStart = false; + private final ScriptEngineManager manager; + private ScriptEngineFactory nashornFactory; + public Map languages = new HashMap(); + public Map scripts = new HashMap(); + public long lastLoaded = 0; + public File dir; + public NBTTagCompound compound = new NBTTagCompound(); - public boolean shouldSave = false; - public PlayerDataScript playerScripts = new PlayerDataScript((EntityPlayer)null); - public long lastPlayerUpdate = 0L; + public boolean shouldSave = false; + public PlayerDataScript playerScripts = new PlayerDataScript((EntityPlayer) null); + public long lastPlayerUpdate = 0L; - public ForgeDataScript forgeScripts = new ForgeDataScript(); - public long lastForgeUpdate = 0L; + public ForgeDataScript forgeScripts = new ForgeDataScript(); + public long lastForgeUpdate = 0L; - public GlobalNPCDataScript globalNpcScripts = new GlobalNPCDataScript((EntityNPCInterface) null); - public long lastGlobalNpcUpdate = 0L; + public GlobalNPCDataScript globalNpcScripts = new GlobalNPCDataScript((EntityNPCInterface) null); + public long lastGlobalNpcUpdate = 0L; - public ScriptController(){ - Instance = this; - manager = new ScriptEngineManager(); - if(!ConfigScript.ScriptingEnabled) - return; - LogWriter.info("Script Engines Available:"); + public ScriptController() { + Instance = this; + manager = new ScriptEngineManager(); + if (!ConfigScript.ScriptingEnabled) + return; + LogWriter.info("Script Engines Available:"); - ScriptEngine engine = manager.getEngineByName("nashorn"); - if (engine != null) { - this.nashornFactory = engine.getFactory(); - } + ScriptEngine engine = manager.getEngineByName("nashorn"); + if (engine != null) { + this.nashornFactory = engine.getFactory(); + } - for(ScriptEngineFactory fac : manager.getEngineFactories()){ - if(fac.getExtensions().isEmpty()) - continue; + for (ScriptEngineFactory fac : manager.getEngineFactories()) { + if (fac.getExtensions().isEmpty()) + continue; - ScriptEngine scriptEngine = fac.getScriptEngine(); - try { - scriptEngine.put("$RunTest",null); - String ext = "." + fac.getExtensions().get(0).toLowerCase(); - LogWriter.info("Engine " + fac.getEngineName() + " running " + fac.getLanguageName() + " with extension: " + ext); - languages.put(fac.getLanguageName(), ext); - } catch (Exception ignored) {} - } - } + ScriptEngine scriptEngine = fac.getScriptEngine(); + try { + scriptEngine.put("$RunTest", null); + String ext = "." + fac.getExtensions().get(0).toLowerCase(); + LogWriter.info("Engine " + fac.getEngineName() + " running " + fac.getLanguageName() + " with extension: " + ext); + languages.put(fac.getLanguageName(), ext); + } catch (Exception ignored) { + } + } + } - private File forgeScriptsFile() { - return new File(this.dir, "forge_scripts.json"); - } + private File forgeScriptsFile() { + return new File(this.dir, "forge_scripts.json"); + } - public boolean loadForgeScripts() { - this.forgeScripts.clear(); - File file = this.forgeScriptsFile(); + public boolean loadForgeScripts() { + this.forgeScripts.clear(); + File file = this.forgeScriptsFile(); - try { - if(!file.exists()) { - return false; - } else { - this.forgeScripts.readFromNBT(NBTJsonUtil.LoadFile(file)); - return true; - } - } catch (Exception var3) { - LogWriter.error("Error loading: " + file.getAbsolutePath(), var3); - return false; - } - } + try { + if (!file.exists()) { + return false; + } else { + this.forgeScripts.readFromNBT(NBTJsonUtil.LoadFile(file)); + return true; + } + } catch (Exception var3) { + LogWriter.error("Error loading: " + file.getAbsolutePath(), var3); + return false; + } + } - public void saveForgeScripts() { - File file = this.forgeScriptsFile(); - try { - NBTJsonUtil.SaveFile(file, this.forgeScripts.writeToNBT(new NBTTagCompound())); - this.forgeScripts.lastInited = -1L; - } catch (IOException | JsonException var4) { - var4.printStackTrace(); - } - } + public void saveForgeScripts() { + File file = this.forgeScriptsFile(); + try { + NBTJsonUtil.SaveFile(file, this.forgeScripts.writeToNBT(new NBTTagCompound())); + this.forgeScripts.lastInited = -1L; + } catch (IOException | JsonException var4) { + var4.printStackTrace(); + } + } - private File playerScriptsFile() { - return new File(dir, "player_scripts.json"); - } + private File playerScriptsFile() { + return new File(dir, "player_scripts.json"); + } - private File npcScriptsFile() { - return new File(dir, "npc_scripts.json"); - } + private File npcScriptsFile() { + return new File(dir, "npc_scripts.json"); + } - public boolean loadPlayerScripts() { - this.playerScripts.clear(); - File file = this.playerScriptsFile(); + public boolean loadPlayerScripts() { + this.playerScripts.clear(); + File file = this.playerScriptsFile(); - try { - if(!file.exists()) { - return false; - } else { - this.playerScripts.readFromNBT(NBTJsonUtil.LoadFile(file)); - shouldSave = false; - return true; - } - } catch (Exception var3) { - LogWriter.error("Error loading: " + file.getAbsolutePath(), var3); - return false; - } - } + try { + if (!file.exists()) { + return false; + } else { + this.playerScripts.readFromNBT(NBTJsonUtil.LoadFile(file)); + shouldSave = false; + return true; + } + } catch (Exception var3) { + LogWriter.error("Error loading: " + file.getAbsolutePath(), var3); + return false; + } + } - public void savePlayerScripts() { - File file = this.playerScriptsFile(); - try { - NBTJsonUtil.SaveFile(file, this.playerScripts.writeToNBT(new NBTTagCompound())); - this.playerScripts.lastInited = -1L; - } catch (IOException | JsonException var4) { - var4.printStackTrace(); - } - } + public void savePlayerScripts() { + File file = this.playerScriptsFile(); + try { + NBTJsonUtil.SaveFile(file, this.playerScripts.writeToNBT(new NBTTagCompound())); + this.playerScripts.lastInited = -1L; + } catch (IOException | JsonException var4) { + var4.printStackTrace(); + } + } - public boolean loadGlobalNPCScripts() { - this.globalNpcScripts.clear(); - File file = this.npcScriptsFile(); + public boolean loadGlobalNPCScripts() { + this.globalNpcScripts.clear(); + File file = this.npcScriptsFile(); - try { - if(!file.exists()) { - return false; - } else { - this.globalNpcScripts.readFromNBT(NBTJsonUtil.LoadFile(file)); - shouldSave = false; - return true; - } - } catch (Exception var3) { - LogWriter.error("Error loading: " + file.getAbsolutePath(), var3); - return false; - } - } + try { + if (!file.exists()) { + return false; + } else { + this.globalNpcScripts.readFromNBT(NBTJsonUtil.LoadFile(file)); + shouldSave = false; + return true; + } + } catch (Exception var3) { + LogWriter.error("Error loading: " + file.getAbsolutePath(), var3); + return false; + } + } - public void saveGlobalNpcScripts() { - File file = this.npcScriptsFile(); - try { - NBTJsonUtil.SaveFile(file, this.globalNpcScripts.writeToNBT(new NBTTagCompound())); - this.globalNpcScripts.lastInited = -1L; - } catch (IOException | JsonException var4) { - var4.printStackTrace(); - } - } + public void saveGlobalNpcScripts() { + File file = this.npcScriptsFile(); + try { + NBTJsonUtil.SaveFile(file, this.globalNpcScripts.writeToNBT(new NBTTagCompound())); + this.globalNpcScripts.lastInited = -1L; + } catch (IOException | JsonException var4) { + var4.printStackTrace(); + } + } - public synchronized void saveForgeScriptsSync(){ + public synchronized void saveForgeScriptsSync() { customNPCThread.execute(this::saveForgeScripts); } - public synchronized void savePlayerScriptsSync(){ + public synchronized void savePlayerScriptsSync() { customNPCThread.execute(() -> { File file = this.playerScriptsFile(); try { @@ -191,86 +192,88 @@ public class ScriptController { }); } - public synchronized void saveGlobalScriptsSync(){ + public synchronized void saveGlobalScriptsSync() { customNPCThread.execute(this::saveGlobalNpcScripts); } - public void loadCategories(){ - dir = new File(CustomNpcs.getWorldSaveDirectory(), "scripts"); - if(!dir.exists()) - dir.mkdir(); - if(!getSavedFile().exists()) - shouldSave = true; - new ScriptWorld(null).clearTempData(); - scripts.clear(); - for(String language : languages.keySet()){ - String ext = languages.get(language); - File scriptDir = new File(dir,language.toLowerCase()); - if(!scriptDir.exists()) - scriptDir.mkdir(); - else - loadDir(scriptDir, "", ext); - } - lastLoaded = System.currentTimeMillis(); - } - private void loadDir(File dir, String name, String ext){ - for(File file : dir.listFiles()){ - String filename = name + file.getName().toLowerCase(); - if(file.isDirectory()){ - loadDir(file, filename + "/", ext); - continue; - } - if(!filename.endsWith(ext)) - continue; - try { - scripts.put(filename, readFile(file)); - } catch (IOException e) { - e.printStackTrace(); - } - } - } - public boolean loadStoredData(){ - loadCategories(); - File file = getSavedFile(); - try { - if(!file.exists()) - return false; - this.compound = NBTJsonUtil.LoadFile(file); - shouldSave = false; - } - catch (Exception e) { - LogWriter.error("Error loading: " + file.getAbsolutePath(), e); - return false; - } - return true; - } + public void loadCategories() { + dir = new File(CustomNpcs.getWorldSaveDirectory(), "scripts"); + if (!dir.exists()) + dir.mkdir(); + if (!getSavedFile().exists()) + shouldSave = true; + new ScriptWorld(null).clearTempData(); + scripts.clear(); + for (String language : languages.keySet()) { + String ext = languages.get(language); + File scriptDir = new File(dir, language.toLowerCase()); + if (!scriptDir.exists()) + scriptDir.mkdir(); + else + loadDir(scriptDir, "", ext); + } + lastLoaded = System.currentTimeMillis(); + } - private File getSavedFile(){ - return new File(dir, "world_data.json"); - } + private void loadDir(File dir, String name, String ext) { + for (File file : dir.listFiles()) { + String filename = name + file.getName().toLowerCase(); + if (file.isDirectory()) { + loadDir(file, filename + "/", ext); + continue; + } + if (!filename.endsWith(ext)) + continue; + try { + scripts.put(filename, readFile(file)); + } catch (IOException e) { + e.printStackTrace(); + } + } + } - private String readFile(File file) throws IOException { - BufferedReader br = new BufferedReader(new FileReader(file)); - try { - StringBuilder sb = new StringBuilder(); - String line = br.readLine(); + public boolean loadStoredData() { + loadCategories(); + File file = getSavedFile(); + try { + if (!file.exists()) + return false; + this.compound = NBTJsonUtil.LoadFile(file); + shouldSave = false; + } catch (Exception e) { + LogWriter.error("Error loading: " + file.getAbsolutePath(), e); + return false; + } + return true; + } - while (line != null) { - sb.append(line); - sb.append("\n"); - line = br.readLine(); - } - return sb.toString(); - } finally { - br.close(); - } - } + private File getSavedFile() { + return new File(dir, "world_data.json"); + } - private static final List nashornNames = immutableList("nashorn", "Nashorn", "js", "JS", "JavaScript", "javascript", "ECMAScript", "ecmascript"); - public ScriptEngine getEngineByName(String language) { - if (nashornNames.contains(language) && this.nashornFactory != null) { + private String readFile(File file) throws IOException { + BufferedReader br = new BufferedReader(new FileReader(file)); + try { + StringBuilder sb = new StringBuilder(); + String line = br.readLine(); + + while (line != null) { + sb.append(line); + sb.append("\n"); + line = br.readLine(); + } + return sb.toString(); + } finally { + br.close(); + } + } + + private static final List nashornNames = immutableList("nashorn", "Nashorn", "js", "JS", "JavaScript", "javascript", "ECMAScript", "ecmascript"); + + public ScriptEngine getEngineByName(String language) { + if (nashornNames.contains(language) && this.nashornFactory != null) { ScriptEngine scriptEngine; - if(ConfigScript.EnableBannedClasses){ + if (ConfigScript.EnableBannedClasses) { try { ClassFilter filter = s -> { for (String className : ConfigScript.BannedClasses) { @@ -288,55 +291,55 @@ public class ScriptController { } else { scriptEngine = this.nashornFactory.getScriptEngine(); } - scriptEngine.setBindings(this.manager.getBindings(), ScriptContext.GLOBAL_SCOPE); - return scriptEngine; - } - return manager.getEngineByName(language); - } - private static List immutableList(String... elements) { - return Collections.unmodifiableList(Arrays.asList(elements)); - } + scriptEngine.setBindings(this.manager.getBindings(), ScriptContext.GLOBAL_SCOPE); + return scriptEngine; + } + return manager.getEngineByName(language); + } - public NBTTagList nbtLanguages() { - NBTTagList list = new NBTTagList(); - for(String language : languages.keySet()){ - NBTTagCompound compound = new NBTTagCompound(); - NBTTagList scripts = new NBTTagList(); - for(String script : getScripts(language)){ - scripts.appendTag(new NBTTagString(script)); - } - compound.setTag("Scripts", scripts); - compound.setString("Language", language); - list.appendTag(compound); - } - return list; - } + private static List immutableList(String... elements) { + return Collections.unmodifiableList(Arrays.asList(elements)); + } - private List getScripts(String language){ - List list = new ArrayList(); - String ext = languages.get(language); - if(ext == null) - return list; - for(String script : scripts.keySet()){ - if(script.endsWith(ext)){ - list.add(script); - } - } - return list; - } + public NBTTagList nbtLanguages() { + NBTTagList list = new NBTTagList(); + for (String language : languages.keySet()) { + NBTTagCompound compound = new NBTTagCompound(); + NBTTagList scripts = new NBTTagList(); + for (String script : getScripts(language)) { + scripts.appendTag(new NBTTagString(script)); + } + compound.setTag("Scripts", scripts); + compound.setString("Language", language); + list.appendTag(compound); + } + return list; + } - @SubscribeEvent - public void invoke(WorldEvent.Save event){ - if(!shouldSave || event.world.isRemote || event.world != MinecraftServer.getServer().worldServers[0]) - return; + private List getScripts(String language) { + List list = new ArrayList(); + String ext = languages.get(language); + if (ext == null) + return list; + for (String script : scripts.keySet()) { + if (script.endsWith(ext)) { + list.add(script); + } + } + return list; + } - try { - NBTJsonUtil.SaveFile(getSavedFile(), compound); - } - catch (Exception e) { - LogWriter.except(e); - } + @SubscribeEvent + public void invoke(WorldEvent.Save event) { + if (!shouldSave || event.world.isRemote || event.world != MinecraftServer.getServer().worldServers[0]) + return; - shouldSave = false; - } + try { + NBTJsonUtil.SaveFile(getSavedFile(), compound); + } catch (Exception e) { + LogWriter.except(e); + } + + shouldSave = false; + } } diff --git a/src/main/java/noppes/npcs/controllers/ScriptEntityData.java b/src/main/java/noppes/npcs/controllers/ScriptEntityData.java index 1daef1b56..b772300ff 100644 --- a/src/main/java/noppes/npcs/controllers/ScriptEntityData.java +++ b/src/main/java/noppes/npcs/controllers/ScriptEntityData.java @@ -6,21 +6,22 @@ import net.minecraft.world.World; import net.minecraftforge.common.IExtendedEntityProperties; import noppes.npcs.api.entity.IEntity; -public class ScriptEntityData implements IExtendedEntityProperties{ - public IEntity base; - public ScriptEntityData(IEntity base){ - this.base = base; - } +public class ScriptEntityData implements IExtendedEntityProperties { + public IEntity base; - @Override - public void saveNBTData(NBTTagCompound compound) { - } + public ScriptEntityData(IEntity base) { + this.base = base; + } - @Override - public void loadNBTData(NBTTagCompound compound) { - } + @Override + public void saveNBTData(NBTTagCompound compound) { + } - @Override - public void init(Entity entity, World world) { - } + @Override + public void loadNBTData(NBTTagCompound compound) { + } + + @Override + public void init(Entity entity, World world) { + } } diff --git a/src/main/java/noppes/npcs/controllers/ServerCloneController.java b/src/main/java/noppes/npcs/controllers/ServerCloneController.java index 61f889b6d..95c932943 100644 --- a/src/main/java/noppes/npcs/controllers/ServerCloneController.java +++ b/src/main/java/noppes/npcs/controllers/ServerCloneController.java @@ -25,337 +25,336 @@ import java.io.FileInputStream; import java.util.*; public class ServerCloneController implements ICloneHandler { - public static ServerCloneController Instance; + public static ServerCloneController Instance; - public ServerCloneController(){ - loadClones(); - } + public ServerCloneController() { + loadClones(); + } - private void loadClones(){ - try { - File dir = new File(getDir(), ".."); - File file = new File(dir, "clonednpcs.dat"); - if(file.exists()){ - Map> clones = loadOldClones(file); - file.delete(); - file = new File(dir, "clonednpcs.dat_old"); - if(file.exists()) - file.delete(); + private void loadClones() { + try { + File dir = new File(getDir(), ".."); + File file = new File(dir, "clonednpcs.dat"); + if (file.exists()) { + Map> clones = loadOldClones(file); + file.delete(); + file = new File(dir, "clonednpcs.dat_old"); + if (file.exists()) + file.delete(); - for(int tab : clones.keySet()){ - Map map = clones.get(tab); - for(String name: map.keySet()){ - saveClone(tab, name, map.get(name)); - } - } - } - } catch (Exception e) { - LogWriter.except(e); - } - } + for (int tab : clones.keySet()) { + Map map = clones.get(tab); + for (String name : map.keySet()) { + saveClone(tab, name, map.get(name)); + } + } + } + } catch (Exception e) { + LogWriter.except(e); + } + } - public File getDir(){ - File dir = new File(CustomNpcs.getWorldSaveDirectory(), "clones"); - if(!dir.exists()) - dir.mkdir(); - return dir; - } + public File getDir() { + File dir = new File(CustomNpcs.getWorldSaveDirectory(), "clones"); + if (!dir.exists()) + dir.mkdir(); + return dir; + } - private Map> loadOldClones(File file) throws Exception{ - Map> clones = new HashMap>(); - NBTTagCompound nbttagcompound1 = CompressedStreamTools.readCompressed(new FileInputStream(file)); - NBTTagList list = nbttagcompound1.getTagList("Data", 10); - if(list == null){ - return clones; - } - for(int i = 0; i < list.tagCount(); i++) - { - NBTTagCompound compound = list.getCompoundTagAt(i); - if(!compound.hasKey("ClonedTab")){ - compound.setInteger("ClonedTab", 1); - } + private Map> loadOldClones(File file) throws Exception { + Map> clones = new HashMap>(); + NBTTagCompound nbttagcompound1 = CompressedStreamTools.readCompressed(new FileInputStream(file)); + NBTTagList list = nbttagcompound1.getTagList("Data", 10); + if (list == null) { + return clones; + } + for (int i = 0; i < list.tagCount(); i++) { + NBTTagCompound compound = list.getCompoundTagAt(i); + if (!compound.hasKey("ClonedTab")) { + compound.setInteger("ClonedTab", 1); + } - Map tab = clones.get(compound.getInteger("ClonedTab")); - if(tab == null) - clones.put(compound.getInteger("ClonedTab"), tab = new HashMap()); + Map tab = clones.get(compound.getInteger("ClonedTab")); + if (tab == null) + clones.put(compound.getInteger("ClonedTab"), tab = new HashMap()); - String name = compound.getString("ClonedName"); - int number = 1; - while(tab.containsKey(name)){ - number++; - name = String.format("%s%s", compound.getString("ClonedName"), number); - } - compound.removeTag("ClonedName"); - compound.removeTag("ClonedTab"); - compound.removeTag("ClonedDate"); - cleanTags(compound); - tab.put(name, compound); - } - return clones; - } + String name = compound.getString("ClonedName"); + int number = 1; + while (tab.containsKey(name)) { + number++; + name = String.format("%s%s", compound.getString("ClonedName"), number); + } + compound.removeTag("ClonedName"); + compound.removeTag("ClonedTab"); + compound.removeTag("ClonedDate"); + cleanTags(compound); + tab.put(name, compound); + } + return clones; + } - public NBTTagCompound getCloneData(ICommandSender player, String name, int tab) { - File file = new File(new File(getDir(), tab + ""), name + ".json"); - if(!file.exists()){ - if(player != null) - player.addChatMessage(new ChatComponentText("Could not find clone file")); - return null; - } - try { - return NBTJsonUtil.LoadFile(file); - } catch (Exception e) { - LogWriter.error("Error loading: " + file.getAbsolutePath(), e); - if(player != null) - player.addChatMessage(new ChatComponentText(e.getMessage())); - } - return null; - } + public NBTTagCompound getCloneData(ICommandSender player, String name, int tab) { + File file = new File(new File(getDir(), tab + ""), name + ".json"); + if (!file.exists()) { + if (player != null) + player.addChatMessage(new ChatComponentText("Could not find clone file")); + return null; + } + try { + return NBTJsonUtil.LoadFile(file); + } catch (Exception e) { + LogWriter.error("Error loading: " + file.getAbsolutePath(), e); + if (player != null) + player.addChatMessage(new ChatComponentText(e.getMessage())); + } + return null; + } - public void saveClone(int tab, String name, NBTTagCompound compound){ - try { - File dir = new File(getDir(), tab + ""); - if(!dir.exists()) - dir.mkdir(); - String filename = name + ".json"; + public void saveClone(int tab, String name, NBTTagCompound compound) { + try { + File dir = new File(getDir(), tab + ""); + if (!dir.exists()) + dir.mkdir(); + String filename = name + ".json"; - File file = new File(dir, filename + "_new"); - File file2 = new File(dir, filename); - NBTJsonUtil.SaveFile(file, compound); - addToTagMap(compound, name, tab); - if(file2.exists()){ - file2.delete(); - } - file.renameTo(file2); - } catch (Exception e) { - LogWriter.except(e); - } - } - public List getClones(int tab){ - List list = new ArrayList(); - File dir = new File(getDir(), tab + ""); - if(!dir.exists() || !dir.isDirectory()) - return list; - for(String file : dir.list()){ - if(file.endsWith(".json")) - list.add(file.substring(0, file.length() - 5)); - } - return list; - } + File file = new File(dir, filename + "_new"); + File file2 = new File(dir, filename); + NBTJsonUtil.SaveFile(file, compound); + addToTagMap(compound, name, tab); + if (file2.exists()) { + file2.delete(); + } + file.renameTo(file2); + } catch (Exception e) { + LogWriter.except(e); + } + } - public List getClonesDate(int tab){ - List list = new ArrayList(); - File dir = new File(getDir(), tab + ""); - if(!dir.exists() || !dir.isDirectory()) - return list; - File[] files = dir.listFiles(); - Arrays.sort(files, new Comparator(){ - public int compare(File f1, File f2) - { - return Long.compare(f1.lastModified(), f2.lastModified()); - } - }); + public List getClones(int tab) { + List list = new ArrayList(); + File dir = new File(getDir(), tab + ""); + if (!dir.exists() || !dir.isDirectory()) + return list; + for (String file : dir.list()) { + if (file.endsWith(".json")) + list.add(file.substring(0, file.length() - 5)); + } + return list; + } - for(File file : files){ - String fileName = file.getName(); - if(fileName.endsWith(".json")) - list.add(fileName.substring(0, fileName.length() - 5)); - } - return list; - } + public List getClonesDate(int tab) { + List list = new ArrayList(); + File dir = new File(getDir(), tab + ""); + if (!dir.exists() || !dir.isDirectory()) + return list; + File[] files = dir.listFiles(); + Arrays.sort(files, new Comparator() { + public int compare(File f1, File f2) { + return Long.compare(f1.lastModified(), f2.lastModified()); + } + }); - public boolean removeClone(String name, int tab){ - File file = new File(new File(getDir(), tab + ""), name + ".json"); - if(!file.exists()) - return false; - file.delete(); - removeFromTagMap(name, tab); - return true; - } + for (File file : files) { + String fileName = file.getName(); + if (fileName.endsWith(".json")) + list.add(fileName.substring(0, fileName.length() - 5)); + } + return list; + } - public String addClone(NBTTagCompound nbttagcompound, String name, int tab) { - cleanTags(nbttagcompound); - saveClone(tab, name, nbttagcompound); - return name; - } + public boolean removeClone(String name, int tab) { + File file = new File(new File(getDir(), tab + ""), name + ".json"); + if (!file.exists()) + return false; + file.delete(); + removeFromTagMap(name, tab); + return true; + } - public String addClone(NBTTagCompound nbttagcompound, String name, int tab, NBTTagCompound tempTags) { - cleanTagList(nbttagcompound, tempTags); - cleanTags(nbttagcompound); - saveClone(tab, name, nbttagcompound); - return name; - } + public String addClone(NBTTagCompound nbttagcompound, String name, int tab) { + cleanTags(nbttagcompound); + saveClone(tab, name, nbttagcompound); + return name; + } - public NBTTagCompound cleanTagList(NBTTagCompound nbttagcompound, NBTTagCompound tempTags){ - HashSet tagUUIDs = new HashSet(); - if(nbttagcompound.hasKey("TagUUIDs")){ - NBTTagList nbtTagList = nbttagcompound.getTagList("TagUUIDs",8); - for (int i = 0; i < nbtTagList.tagCount(); i++) { - tagUUIDs.add(UUID.fromString(nbtTagList.getStringTagAt(i))); - } + public String addClone(NBTTagCompound nbttagcompound, String name, int tab, NBTTagCompound tempTags) { + cleanTagList(nbttagcompound, tempTags); + cleanTags(nbttagcompound); + saveClone(tab, name, nbttagcompound); + return name; + } - nbttagcompound.removeTag("TagUUIDs"); - } - if(tempTags.hasKey("TempTagUUIDs")){ - NBTTagList nbtTagList = tempTags.getTagList("TempTagUUIDs",8); - for (int i = 0; i < nbtTagList.tagCount(); i++) { - tagUUIDs.add(UUID.fromString(nbtTagList.getStringTagAt(i))); - } + public NBTTagCompound cleanTagList(NBTTagCompound nbttagcompound, NBTTagCompound tempTags) { + HashSet tagUUIDs = new HashSet(); + if (nbttagcompound.hasKey("TagUUIDs")) { + NBTTagList nbtTagList = nbttagcompound.getTagList("TagUUIDs", 8); + for (int i = 0; i < nbtTagList.tagCount(); i++) { + tagUUIDs.add(UUID.fromString(nbtTagList.getStringTagAt(i))); + } - tempTags.removeTag("TempTagUUIDs"); - } + nbttagcompound.removeTag("TagUUIDs"); + } + if (tempTags.hasKey("TempTagUUIDs")) { + NBTTagList nbtTagList = tempTags.getTagList("TempTagUUIDs", 8); + for (int i = 0; i < nbtTagList.tagCount(); i++) { + tagUUIDs.add(UUID.fromString(nbtTagList.getStringTagAt(i))); + } - if(tagUUIDs.size() > 0){ - NBTTagList nbtTagList = new NBTTagList(); - for (UUID uuid : tagUUIDs) { - nbtTagList.appendTag(new NBTTagString(uuid.toString())); - } - nbttagcompound.setTag("TagUUIDs", nbtTagList); - } + tempTags.removeTag("TempTagUUIDs"); + } - return nbttagcompound; - } + if (tagUUIDs.size() > 0) { + NBTTagList nbtTagList = new NBTTagList(); + for (UUID uuid : tagUUIDs) { + nbtTagList.appendTag(new NBTTagString(uuid.toString())); + } + nbttagcompound.setTag("TagUUIDs", nbtTagList); + } - public boolean addToTagMap(NBTTagCompound nbttagcompound, String name, int tab){ - HashSet tagUUIDs = new HashSet(); - if(nbttagcompound.hasKey("TagUUIDs")){ - NBTTagList nbtTagList = nbttagcompound.getTagList("TagUUIDs",8); - for (int i = 0; i < nbtTagList.tagCount(); i++) { - tagUUIDs.add(UUID.fromString(nbtTagList.getStringTagAt(i))); - } - } + return nbttagcompound; + } + + public boolean addToTagMap(NBTTagCompound nbttagcompound, String name, int tab) { + HashSet tagUUIDs = new HashSet(); + if (nbttagcompound.hasKey("TagUUIDs")) { + NBTTagList nbtTagList = nbttagcompound.getTagList("TagUUIDs", 8); + for (int i = 0; i < nbtTagList.tagCount(); i++) { + tagUUIDs.add(UUID.fromString(nbtTagList.getStringTagAt(i))); + } + } TagMap tagMap = ServerTagMapController.Instance.getTagMap(tab); - if(!tagUUIDs.isEmpty()){ - tagMap.putClone(name, tagUUIDs); - } - else { + if (!tagUUIDs.isEmpty()) { + tagMap.putClone(name, tagUUIDs); + } else { tagMap.removeClone(name); } ServerTagMapController.Instance.saveTagMap(tagMap); return true; - } + } - public boolean removeFromTagMap(String name, int tab){ - TagMap tagMap = ServerTagMapController.Instance.getTagMap(tab); - if(tagMap.removeClone(name)){ - ServerTagMapController.Instance.saveTagMap(tagMap); - return true; - } - return false; - } + public boolean removeFromTagMap(String name, int tab) { + TagMap tagMap = ServerTagMapController.Instance.getTagMap(tab); + if (tagMap.removeClone(name)) { + ServerTagMapController.Instance.saveTagMap(tagMap); + return true; + } + return false; + } - public void cleanTags(NBTTagCompound nbttagcompound){ - if(nbttagcompound.hasKey("ItemGiverId")) - nbttagcompound.setInteger("ItemGiverId", 0); - if(nbttagcompound.hasKey("TransporterId")) - nbttagcompound.setInteger("TransporterId", -1); + public void cleanTags(NBTTagCompound nbttagcompound) { + if (nbttagcompound.hasKey("ItemGiverId")) + nbttagcompound.setInteger("ItemGiverId", 0); + if (nbttagcompound.hasKey("TransporterId")) + nbttagcompound.setInteger("TransporterId", -1); - nbttagcompound.removeTag("StartPosNew"); - nbttagcompound.removeTag("StartPos"); - nbttagcompound.removeTag("MovingPathNew"); - nbttagcompound.removeTag("Pos"); - nbttagcompound.removeTag("Riding"); + nbttagcompound.removeTag("StartPosNew"); + nbttagcompound.removeTag("StartPos"); + nbttagcompound.removeTag("MovingPathNew"); + nbttagcompound.removeTag("Pos"); + nbttagcompound.removeTag("Riding"); - if(!nbttagcompound.hasKey("ModRev")) - nbttagcompound.setInteger("ModRev", 1); + if (!nbttagcompound.hasKey("ModRev")) + nbttagcompound.setInteger("ModRev", 1); - if(nbttagcompound.hasKey("TransformRole")){ - NBTTagCompound adv = nbttagcompound.getCompoundTag("TransformRole"); - adv.setInteger("TransporterId", -1); - nbttagcompound.setTag("TransformRole", adv); - } + if (nbttagcompound.hasKey("TransformRole")) { + NBTTagCompound adv = nbttagcompound.getCompoundTag("TransformRole"); + adv.setInteger("TransporterId", -1); + nbttagcompound.setTag("TransformRole", adv); + } - if(nbttagcompound.hasKey("TransformJob")){ - NBTTagCompound adv = nbttagcompound.getCompoundTag("TransformJob"); - adv.setInteger("ItemGiverId", 0); - nbttagcompound.setTag("TransformJob", adv); - } + if (nbttagcompound.hasKey("TransformJob")) { + NBTTagCompound adv = nbttagcompound.getCompoundTag("TransformJob"); + adv.setInteger("ItemGiverId", 0); + nbttagcompound.setTag("TransformJob", adv); + } - if(nbttagcompound.hasKey("TransformAI")){ - NBTTagCompound adv = nbttagcompound.getCompoundTag("TransformAI"); - adv.removeTag("StartPosNew"); - adv.removeTag("StartPos"); - adv.removeTag("MovingPathNew"); - nbttagcompound.setTag("TransformAI", adv); - } - } + if (nbttagcompound.hasKey("TransformAI")) { + NBTTagCompound adv = nbttagcompound.getCompoundTag("TransformAI"); + adv.removeTag("StartPosNew"); + adv.removeTag("StartPos"); + adv.removeTag("MovingPathNew"); + nbttagcompound.setTag("TransformAI", adv); + } + } - public IEntity spawn(double x, double y, double z, int tab, String name, IWorld world, boolean ignoreProtection) { - NBTTagCompound compound = this.getCloneData((ICommandSender)null, name, tab); - if (compound == null) { - throw new CustomNPCsException("Unknown clone tab:" + tab + " name:" + name, new Object[0]); - } else { - Entity entity; - if (!ignoreProtection) { - entity = NoppesUtilServer.spawnCloneWithProtection(compound, (int) x, (int) y, (int) z, world.getMCWorld()); - } else { - entity = NoppesUtilServer.spawnClone(compound, (int) x, (int) y, (int) z, world.getMCWorld()); - } - return entity == null ? null : NpcAPI.Instance().getIEntity(entity); - } - } + public IEntity spawn(double x, double y, double z, int tab, String name, IWorld world, boolean ignoreProtection) { + NBTTagCompound compound = this.getCloneData((ICommandSender) null, name, tab); + if (compound == null) { + throw new CustomNPCsException("Unknown clone tab:" + tab + " name:" + name, new Object[0]); + } else { + Entity entity; + if (!ignoreProtection) { + entity = NoppesUtilServer.spawnCloneWithProtection(compound, (int) x, (int) y, (int) z, world.getMCWorld()); + } else { + entity = NoppesUtilServer.spawnClone(compound, (int) x, (int) y, (int) z, world.getMCWorld()); + } + return entity == null ? null : NpcAPI.Instance().getIEntity(entity); + } + } - public IEntity spawn(IPos pos, int tab, String name, IWorld world, boolean ignoreProtection) { - return this.spawn(pos.getX(),pos.getY(),pos.getZ(),tab,name,world,ignoreProtection); - } + public IEntity spawn(IPos pos, int tab, String name, IWorld world, boolean ignoreProtection) { + return this.spawn(pos.getX(), pos.getY(), pos.getZ(), tab, name, world, ignoreProtection); + } - public IEntity spawn(double x, double y, double z, int tab, String name, IWorld world) { - return spawn(x, y, z, tab, name, world, true); - } + public IEntity spawn(double x, double y, double z, int tab, String name, IWorld world) { + return spawn(x, y, z, tab, name, world, true); + } - public IEntity spawn(IPos pos, int tab, String name, IWorld world) { - return this.spawn(pos.getX(),pos.getY(),pos.getZ(),tab,name,world); - } + public IEntity spawn(IPos pos, int tab, String name, IWorld world) { + return this.spawn(pos.getX(), pos.getY(), pos.getZ(), tab, name, world); + } - public IEntity[] getTab(int tab, IWorld world) { - File dir = new File(getDir(), tab + ""); - if (!dir.exists() || !dir.isDirectory() || dir.listFiles() == null) { - return new IEntity[]{}; - } + public IEntity[] getTab(int tab, IWorld world) { + File dir = new File(getDir(), tab + ""); + if (!dir.exists() || !dir.isDirectory() || dir.listFiles() == null) { + return new IEntity[]{}; + } - ArrayList arrayList = new ArrayList<>(); + ArrayList arrayList = new ArrayList<>(); - try { - for (File file : dir.listFiles()) { - if (file.getName().endsWith(".json")) { - NBTTagCompound compound = NBTJsonUtil.LoadFile(file); - Instance.cleanTags(compound); - Entity entity = EntityList.createEntityFromNBT(compound, world.getMCWorld()); - arrayList.add(entity == null ? null : NpcAPI.Instance().getIEntity(entity)); - } - } - } catch (Exception ignored) {} + try { + for (File file : dir.listFiles()) { + if (file.getName().endsWith(".json")) { + NBTTagCompound compound = NBTJsonUtil.LoadFile(file); + Instance.cleanTags(compound); + Entity entity = EntityList.createEntityFromNBT(compound, world.getMCWorld()); + arrayList.add(entity == null ? null : NpcAPI.Instance().getIEntity(entity)); + } + } + } catch (Exception ignored) { + } - return arrayList.toArray(new IEntity[]{}); - } + return arrayList.toArray(new IEntity[]{}); + } - public IEntity get(int tab, String name, IWorld world) { - NBTTagCompound compound = this.getCloneData((ICommandSender)null, name, tab); - if (compound == null) { - throw new CustomNPCsException("Unknown clone tab:" + tab + " name:" + name, new Object[0]); - } else { - Instance.cleanTags(compound); - Entity entity = EntityList.createEntityFromNBT(compound, world.getMCWorld()); - return entity == null ? null : NpcAPI.Instance().getIEntity(entity); - } - } + public IEntity get(int tab, String name, IWorld world) { + NBTTagCompound compound = this.getCloneData((ICommandSender) null, name, tab); + if (compound == null) { + throw new CustomNPCsException("Unknown clone tab:" + tab + " name:" + name, new Object[0]); + } else { + Instance.cleanTags(compound); + Entity entity = EntityList.createEntityFromNBT(compound, world.getMCWorld()); + return entity == null ? null : NpcAPI.Instance().getIEntity(entity); + } + } public boolean has(int tab, String name) { - NBTTagCompound compound = this.getCloneData((ICommandSender)null, name, tab); + NBTTagCompound compound = this.getCloneData((ICommandSender) null, name, tab); return compound != null; } public void set(int tab, String name, IEntity entity) { - NBTTagCompound compound = new NBTTagCompound(); - if (!entity.getMCEntity().writeMountToNBT(compound)) - throw new CustomNPCsException("Cannot save dead entities", new Object[0]); + NBTTagCompound compound = new NBTTagCompound(); + if (!entity.getMCEntity().writeMountToNBT(compound)) + throw new CustomNPCsException("Cannot save dead entities", new Object[0]); this.cleanTags(compound); this.saveClone(tab, name, compound); - } + } - public void remove(int tab, String name) { - this.removeClone(name, tab); - } + public void remove(int tab, String name) { + this.removeClone(name, tab); + } } diff --git a/src/main/java/noppes/npcs/controllers/ServerTagMapController.java b/src/main/java/noppes/npcs/controllers/ServerTagMapController.java index e5a1b21e7..886fdfcfe 100644 --- a/src/main/java/noppes/npcs/controllers/ServerTagMapController.java +++ b/src/main/java/noppes/npcs/controllers/ServerTagMapController.java @@ -10,78 +10,77 @@ import java.io.*; import java.util.zip.GZIPInputStream; public class ServerTagMapController { - public static ServerTagMapController Instance; - public TagMap tagMap; + public static ServerTagMapController Instance; + public TagMap tagMap; - public ServerTagMapController(){} + public ServerTagMapController() { + } - public File getDir(){ - File dir = new File(CustomNpcs.getWorldSaveDirectory(), "clones"); - if(!dir.exists()) - dir.mkdir(); - return dir; - } + public File getDir() { + File dir = new File(CustomNpcs.getWorldSaveDirectory(), "clones"); + if (!dir.exists()) + dir.mkdir(); + return dir; + } - public File getCloneTabDir(int tab){ - File dir = new File(getDir(), tab + ""); - if(!dir.exists()) - dir.mkdir(); - return dir; - } + public File getCloneTabDir(int tab) { + File dir = new File(getDir(), tab + ""); + if (!dir.exists()) + dir.mkdir(); + return dir; + } - public TagMap getTagMap(int tab){ - this.tagMap = new TagMap(tab); - try { - File file = new File(getCloneTabDir(tab), "___tagmap.dat"); - if(file.exists()){ - loadTagMapFile(file); - } - } catch (Exception e) { - try { - File file = new File(getCloneTabDir(tab), "___tagmap.dat_old"); - if(file.exists()){ - loadTagMapFile(file); - } - } catch (Exception ignored) {} - } - return this.tagMap; - } + public TagMap getTagMap(int tab) { + this.tagMap = new TagMap(tab); + try { + File file = new File(getCloneTabDir(tab), "___tagmap.dat"); + if (file.exists()) { + loadTagMapFile(file); + } + } catch (Exception e) { + try { + File file = new File(getCloneTabDir(tab), "___tagmap.dat_old"); + if (file.exists()) { + loadTagMapFile(file); + } + } catch (Exception ignored) { + } + } + return this.tagMap; + } - private void loadTagMapFile(File file) throws IOException { - DataInputStream var1 = new DataInputStream(new BufferedInputStream(new GZIPInputStream(new FileInputStream(file)))); - loadTagMaps(var1); - var1.close(); - } + private void loadTagMapFile(File file) throws IOException { + DataInputStream var1 = new DataInputStream(new BufferedInputStream(new GZIPInputStream(new FileInputStream(file)))); + loadTagMaps(var1); + var1.close(); + } - public void loadTagMaps(DataInputStream stream) throws IOException{ - NBTTagCompound nbtCompound = CompressedStreamTools.read(stream); - this.tagMap.readNBT(nbtCompound); - } + public void loadTagMaps(DataInputStream stream) throws IOException { + NBTTagCompound nbtCompound = CompressedStreamTools.read(stream); + this.tagMap.readNBT(nbtCompound); + } - public void saveTagMap(TagMap tagMap){ - try { - File saveDir = getCloneTabDir(tagMap.cloneTab); - File file = new File(saveDir, "___tagmap.dat_new"); - File file1 = new File(saveDir, "___tagmap.dat_old"); - File file2 = new File(saveDir, "___tagmap.dat"); - CompressedStreamTools.writeCompressed(tagMap.writeNBT(), new FileOutputStream(file)); - if(file1.exists()) - { - file1.delete(); - } - file2.renameTo(file1); - if(file2.exists()) - { - file2.delete(); - } - file.renameTo(file2); - if(file.exists()) - { - file.delete(); - } - } catch (Exception e) { - LogWriter.except(e); - } - } + public void saveTagMap(TagMap tagMap) { + try { + File saveDir = getCloneTabDir(tagMap.cloneTab); + File file = new File(saveDir, "___tagmap.dat_new"); + File file1 = new File(saveDir, "___tagmap.dat_old"); + File file2 = new File(saveDir, "___tagmap.dat"); + CompressedStreamTools.writeCompressed(tagMap.writeNBT(), new FileOutputStream(file)); + if (file1.exists()) { + file1.delete(); + } + file2.renameTo(file1); + if (file2.exists()) { + file2.delete(); + } + file.renameTo(file2); + if (file.exists()) { + file.delete(); + } + } catch (Exception e) { + LogWriter.except(e); + } + } } diff --git a/src/main/java/noppes/npcs/controllers/SpawnController.java b/src/main/java/noppes/npcs/controllers/SpawnController.java index 1f26a9733..1608825f5 100644 --- a/src/main/java/noppes/npcs/controllers/SpawnController.java +++ b/src/main/java/noppes/npcs/controllers/SpawnController.java @@ -15,219 +15,218 @@ import java.util.*; import java.util.zip.GZIPInputStream; public class SpawnController implements INaturalSpawnsHandler { - public HashMap> biomes = new HashMap>() ; - public ArrayList data = new ArrayList(); - public Random random = new Random(); - - public static SpawnController Instance; + public HashMap> biomes = new HashMap>(); + public ArrayList data = new ArrayList(); + public Random random = new Random(); - private int lastUsedID = 0; - - public SpawnController(){ - Instance = this; - loadData(); - } + public static SpawnController Instance; - private void loadData(){ + private int lastUsedID = 0; - File saveDir = CustomNpcs.getWorldSaveDirectory(); - if(saveDir == null){ - return; - } - try { - File file = new File(saveDir, "spawns.dat"); - if(file.exists()){ - loadDataFile(file); - } - } catch (Exception e) { - try { - File file = new File(saveDir, "spawns.dat_old"); - if(file.exists()){ - loadDataFile(file); - } - - } catch (Exception ee) { - } - } - } + public SpawnController() { + Instance = this; + loadData(); + } - private void loadDataFile(File file) throws IOException{ + private void loadData() { + + File saveDir = CustomNpcs.getWorldSaveDirectory(); + if (saveDir == null) { + return; + } + try { + File file = new File(saveDir, "spawns.dat"); + if (file.exists()) { + loadDataFile(file); + } + } catch (Exception e) { + try { + File file = new File(saveDir, "spawns.dat_old"); + if (file.exists()) { + loadDataFile(file); + } + + } catch (Exception ee) { + } + } + } + + private void loadDataFile(File file) throws IOException { DataInputStream var1 = new DataInputStream(new BufferedInputStream(new GZIPInputStream(new FileInputStream(file)))); - loadData(var1); - var1.close(); - } + loadData(var1); + var1.close(); + } - public void loadData(DataInputStream stream) throws IOException{ - ArrayList data = new ArrayList(); + public void loadData(DataInputStream stream) throws IOException { + ArrayList data = new ArrayList(); NBTTagCompound nbttagcompound1 = CompressedStreamTools.read(stream); lastUsedID = nbttagcompound1.getInteger("lastID"); NBTTagList nbtlist = nbttagcompound1.getTagList("NPCSpawnData", 10); - if(nbtlist != null){ - for(int i = 0; i < nbtlist.tagCount(); i++) - { - NBTTagCompound nbttagcompound = nbtlist.getCompoundTagAt(i); - SpawnData spawn = new SpawnData(); - spawn.readNBT(nbttagcompound); - data.add(spawn); - } - } - this.data = data; - fillBiomeData(); - } - public NBTTagCompound getNBT(){ + if (nbtlist != null) { + for (int i = 0; i < nbtlist.tagCount(); i++) { + NBTTagCompound nbttagcompound = nbtlist.getCompoundTagAt(i); + SpawnData spawn = new SpawnData(); + spawn.readNBT(nbttagcompound); + data.add(spawn); + } + } + this.data = data; + fillBiomeData(); + } + + public NBTTagCompound getNBT() { NBTTagList list = new NBTTagList(); - for(SpawnData spawn : data){ + for (SpawnData spawn : data) { NBTTagCompound nbtfactions = new NBTTagCompound(); spawn.writeNBT(nbtfactions); - list.appendTag(nbtfactions); + list.appendTag(nbtfactions); } NBTTagCompound nbttagcompound = new NBTTagCompound(); nbttagcompound.setInteger("lastID", lastUsedID); nbttagcompound.setTag("NPCSpawnData", list); return nbttagcompound; - } - public void saveData(){ - try { - File saveDir = CustomNpcs.getWorldSaveDirectory(); + } + + public void saveData() { + try { + File saveDir = CustomNpcs.getWorldSaveDirectory(); File file = new File(saveDir, "spawns.dat_new"); File file1 = new File(saveDir, "spawns.dat_old"); File file2 = new File(saveDir, "spawns.dat"); CompressedStreamTools.writeCompressed(getNBT(), new FileOutputStream(file)); - if(file1.exists()) - { + if (file1.exists()) { file1.delete(); } file2.renameTo(file1); - if(file2.exists()) - { + if (file2.exists()) { file2.delete(); } file.renameTo(file2); - if(file.exists()) - { + if (file.exists()) { file.delete(); } - } catch (Exception e) { - LogWriter.except(e); - } - } + } catch (Exception e) { + LogWriter.except(e); + } + } - public SpawnData getSpawnData(int id) { - for(SpawnData spawn : data) - if(spawn.id == id) - return spawn; - return null; - } + public SpawnData getSpawnData(int id) { + for (SpawnData spawn : data) + if (spawn.id == id) + return spawn; + return null; + } - public void saveSpawnData(SpawnData spawn) { - if(spawn.id < 0) - spawn.id = getUnusedId(); - SpawnData original = getSpawnData(spawn.id); - if(original == null) - data.add(spawn); - else{ - original.readNBT(spawn.writeNBT(new NBTTagCompound())); - } - fillBiomeData(); - saveData(); - } - - private void fillBiomeData(){ - HashMap> biomes = new HashMap>() ; - for(SpawnData spawn : data){ - for(String s : spawn.biomes){ - List list = biomes.get(s); - if(list == null) - biomes.put(s, (list = new ArrayList())); - list.add(spawn); - } - } - this.biomes = biomes; - } - - public int getUnusedId(){ - lastUsedID++; - return lastUsedID; - } - public void removeSpawnData(int id) { - ArrayList data = new ArrayList(); - - for(SpawnData spawn : this.data){ - if(spawn.id == id) - continue; + public void saveSpawnData(SpawnData spawn) { + if (spawn.id < 0) + spawn.id = getUnusedId(); + SpawnData original = getSpawnData(spawn.id); + if (original == null) data.add(spawn); - } - this.data = data; + else { + original.readNBT(spawn.writeNBT(new NBTTagCompound())); + } + fillBiomeData(); + saveData(); + } - fillBiomeData(); - saveData(); - } - - public List getSpawnList(String biome) { - return biomes.get(biome); - } + private void fillBiomeData() { + HashMap> biomes = new HashMap>(); + for (SpawnData spawn : data) { + for (String s : spawn.biomes) { + List list = biomes.get(s); + if (list == null) + biomes.put(s, (list = new ArrayList())); + list.add(spawn); + } + } + this.biomes = biomes; + } - public SpawnData getRandomSpawnData(String biome, int dimensionId) { - List biomeList = getSpawnList(biome); - if (biomeList == null) - return null; + public int getUnusedId() { + lastUsedID++; + return lastUsedID; + } - ArrayList list = new ArrayList<>(); - for (SpawnData data : biomeList) { - if (data.dimensions.contains(dimensionId)) { - list.add(data); - } - } - if(list.isEmpty()) - return null; + public void removeSpawnData(int id) { + ArrayList data = new ArrayList(); - return (SpawnData) WeightedRandom.getRandomItem(this.random, list); - } + for (SpawnData spawn : this.data) { + if (spawn.id == id) + continue; + data.add(spawn); + } + this.data = data; - public Map getScroll() { - Map map = new HashMap(); - for(SpawnData spawn : data){ - map.put(spawn.name, spawn.id); - } - return map; - } + fillBiomeData(); + saveData(); + } - public void save() { - for (SpawnData spawn : this.data) { - if (spawn.id < 0) { - spawn.id = getUnusedId(); - } - SpawnData original = getSpawnData(spawn.id); - if (original == null) { - this.data.add(spawn); - } else { - original.readNBT(spawn.writeNBT(new NBTTagCompound())); - } - } + public List getSpawnList(String biome) { + return biomes.get(biome); + } - this.fillBiomeData(); - this.saveData(); - } + public SpawnData getRandomSpawnData(String biome, int dimensionId) { + List biomeList = getSpawnList(biome); + if (biomeList == null) + return null; - public INaturalSpawn[] getSpawns() { - return data.toArray(new INaturalSpawn[]{}); - } + ArrayList list = new ArrayList<>(); + for (SpawnData data : biomeList) { + if (data.dimensions.contains(dimensionId)) { + list.add(data); + } + } + if (list.isEmpty()) + return null; - public INaturalSpawn[] getSpawns(String biome) { - return getSpawnList(biome).toArray(new INaturalSpawn[]{}); - } + return (SpawnData) WeightedRandom.getRandomItem(this.random, list); + } - public void addSpawn(INaturalSpawn spawn) { - ((SpawnData) spawn).id = 0; - this.saveSpawnData((SpawnData) spawn); - } + public Map getScroll() { + Map map = new HashMap(); + for (SpawnData spawn : data) { + map.put(spawn.name, spawn.id); + } + return map; + } - public void removeSpawn(INaturalSpawn spawn) { - this.removeSpawnData(((SpawnData) spawn).id); - } + public void save() { + for (SpawnData spawn : this.data) { + if (spawn.id < 0) { + spawn.id = getUnusedId(); + } + SpawnData original = getSpawnData(spawn.id); + if (original == null) { + this.data.add(spawn); + } else { + original.readNBT(spawn.writeNBT(new NBTTagCompound())); + } + } - public INaturalSpawn createSpawn() { - return new SpawnData(); - } + this.fillBiomeData(); + this.saveData(); + } + + public INaturalSpawn[] getSpawns() { + return data.toArray(new INaturalSpawn[]{}); + } + + public INaturalSpawn[] getSpawns(String biome) { + return getSpawnList(biome).toArray(new INaturalSpawn[]{}); + } + + public void addSpawn(INaturalSpawn spawn) { + ((SpawnData) spawn).id = 0; + this.saveSpawnData((SpawnData) spawn); + } + + public void removeSpawn(INaturalSpawn spawn) { + this.removeSpawnData(((SpawnData) spawn).id); + } + + public INaturalSpawn createSpawn() { + return new SpawnData(); + } } diff --git a/src/main/java/noppes/npcs/controllers/TagController.java b/src/main/java/noppes/npcs/controllers/TagController.java index fde4ff890..14fd6b066 100644 --- a/src/main/java/noppes/npcs/controllers/TagController.java +++ b/src/main/java/noppes/npcs/controllers/TagController.java @@ -14,218 +14,214 @@ import java.util.*; import java.util.zip.GZIPInputStream; public class TagController implements ITagHandler { - public HashMap tags; - private static TagController instance; + public HashMap tags; + private static TagController instance; - private int lastUsedID = 0; + private int lastUsedID = 0; - public TagController(){ - instance = this; - tags = new HashMap(); - loadTags(); + public TagController() { + instance = this; + tags = new HashMap(); + loadTags(); // if(tags.isEmpty()){ // // TO-DO // tags.put(0,new Faction(0,"Friendly", 0x00DD00, 2000)); // tags.put(1,new Faction(1,"Neutral", 0xF2DD00, 1000)); // tags.put(2,new Faction(2,"Aggressive", 0xDD0000, 0)); // } - } - public static TagController getInstance(){ - return instance; - } + } - private void loadTags(){ + public static TagController getInstance() { + return instance; + } - File saveDir = CustomNpcs.getWorldSaveDirectory(); - if(saveDir == null){ - return; - } - try { - File file = new File(saveDir, "tags.dat"); - if(file.exists()){ - loadTagsFile(file); - } - } catch (Exception e) { - try { - File file = new File(saveDir, "tags.dat_old"); - if(file.exists()){ - loadTagsFile(file); - } + private void loadTags() { - } catch (Exception ee) { - } - } - } + File saveDir = CustomNpcs.getWorldSaveDirectory(); + if (saveDir == null) { + return; + } + try { + File file = new File(saveDir, "tags.dat"); + if (file.exists()) { + loadTagsFile(file); + } + } catch (Exception e) { + try { + File file = new File(saveDir, "tags.dat_old"); + if (file.exists()) { + loadTagsFile(file); + } - private void loadTagsFile(File file) throws IOException{ - DataInputStream var1 = new DataInputStream(new BufferedInputStream(new GZIPInputStream(new FileInputStream(file)))); - loadTags(var1); - var1.close(); - } + } catch (Exception ee) { + } + } + } - public void loadTags(DataInputStream stream) throws IOException{ - HashMap tags = new HashMap(); - HashMap tagUUIDs = new HashMap(); - NBTTagCompound nbttagcompound1 = CompressedStreamTools.read(stream); - lastUsedID = nbttagcompound1.getInteger("lastID"); - NBTTagList list = nbttagcompound1.getTagList("NPCTags", 10); + private void loadTagsFile(File file) throws IOException { + DataInputStream var1 = new DataInputStream(new BufferedInputStream(new GZIPInputStream(new FileInputStream(file)))); + loadTags(var1); + var1.close(); + } - if(list != null){ - for(int i = 0; i < list.tagCount(); i++) - { - NBTTagCompound nbttagcompound = list.getCompoundTagAt(i); - Tag tag = new Tag(); - tag.readNBT(nbttagcompound); - tags.put(tag.id,tag); - tagUUIDs.put(tag.uuid, tag.id); - } - } - this.tags = tags; - } + public void loadTags(DataInputStream stream) throws IOException { + HashMap tags = new HashMap(); + HashMap tagUUIDs = new HashMap(); + NBTTagCompound nbttagcompound1 = CompressedStreamTools.read(stream); + lastUsedID = nbttagcompound1.getInteger("lastID"); + NBTTagList list = nbttagcompound1.getTagList("NPCTags", 10); - public NBTTagCompound getNBT(){ - NBTTagList list = new NBTTagList(); - for(int slot : tags.keySet()){ - Tag tag = tags.get(slot); - NBTTagCompound nbtfactions = new NBTTagCompound(); - tag.writeNBT(nbtfactions); - list.appendTag(nbtfactions); - } - NBTTagCompound nbttagcompound = new NBTTagCompound(); - nbttagcompound.setInteger("lastID", lastUsedID); - nbttagcompound.setTag("NPCTags", list); - return nbttagcompound; - } + if (list != null) { + for (int i = 0; i < list.tagCount(); i++) { + NBTTagCompound nbttagcompound = list.getCompoundTagAt(i); + Tag tag = new Tag(); + tag.readNBT(nbttagcompound); + tags.put(tag.id, tag); + tagUUIDs.put(tag.uuid, tag.id); + } + } + this.tags = tags; + } - public void saveTags(){ - try { - File saveDir = CustomNpcs.getWorldSaveDirectory(); - File file = new File(saveDir, "tags.dat_new"); - File file1 = new File(saveDir, "tags.dat_old"); - File file2 = new File(saveDir, "tags.dat"); - CompressedStreamTools.writeCompressed(getNBT(), new FileOutputStream(file)); - if(file1.exists()) - { - file1.delete(); - } - file2.renameTo(file1); - if(file2.exists()) - { - file2.delete(); - } - file.renameTo(file2); - if(file.exists()) - { - file.delete(); - } - } catch (Exception e) { - LogWriter.except(e); - } - } + public NBTTagCompound getNBT() { + NBTTagList list = new NBTTagList(); + for (int slot : tags.keySet()) { + Tag tag = tags.get(slot); + NBTTagCompound nbtfactions = new NBTTagCompound(); + tag.writeNBT(nbtfactions); + list.appendTag(nbtfactions); + } + NBTTagCompound nbttagcompound = new NBTTagCompound(); + nbttagcompound.setInteger("lastID", lastUsedID); + nbttagcompound.setTag("NPCTags", list); + return nbttagcompound; + } - public Tag get(int tagSlot) { - return tags.get(tagSlot); - } + public void saveTags() { + try { + File saveDir = CustomNpcs.getWorldSaveDirectory(); + File file = new File(saveDir, "tags.dat_new"); + File file1 = new File(saveDir, "tags.dat_old"); + File file2 = new File(saveDir, "tags.dat"); + CompressedStreamTools.writeCompressed(getNBT(), new FileOutputStream(file)); + if (file1.exists()) { + file1.delete(); + } + file2.renameTo(file1); + if (file2.exists()) { + file2.delete(); + } + file.renameTo(file2); + if (file.exists()) { + file.delete(); + } + } catch (Exception e) { + LogWriter.except(e); + } + } - public List list() { - return new ArrayList(this.tags.values()); - } + public Tag get(int tagSlot) { + return tags.get(tagSlot); + } - public void saveTag(Tag tag) { + public List list() { + return new ArrayList(this.tags.values()); + } - if(tag.id < 0){ - tag.id = getUnusedId(); - while(hasName(tag.name)) - tag.name += "_"; - } - else{ - Tag existing = tags.get(tag.id); - if(existing != null && !existing.name.equals(tag.name)) - while(hasName(tag.name)) - tag.name += "_"; - } - tags.remove(tag.id); - tags.put(tag.id, tag); - saveTags(); - } + public void saveTag(Tag tag) { - public Tag create(Tag tag) { - this.saveTag(tag); - return tag; - } + if (tag.id < 0) { + tag.id = getUnusedId(); + while (hasName(tag.name)) + tag.name += "_"; + } else { + Tag existing = tags.get(tag.id); + if (existing != null && !existing.name.equals(tag.name)) + while (hasName(tag.name)) + tag.name += "_"; + } + tags.remove(tag.id); + tags.put(tag.id, tag); + saveTags(); + } - public Tag create(String name, int color) { - Tag tag = new Tag(); - tag.name = name; - tag.color = color; - this.saveTag(tag); - return tag; - } + public Tag create(Tag tag) { + this.saveTag(tag); + return tag; + } - public int getUnusedId(){ - if(lastUsedID == 0){ - for(int catid : tags.keySet()) - if(catid > lastUsedID) - lastUsedID = catid; - } - lastUsedID++; - return lastUsedID; - } + public Tag create(String name, int color) { + Tag tag = new Tag(); + tag.name = name; + tag.color = color; + this.saveTag(tag); + return tag; + } - public ITag delete(int id) { - if (id >= 0 && this.tags.size() > 1) { - Tag tag = (Tag)this.tags.remove(id); - saveTags(); - if (tag == null) { - return null; - } else { - this.saveTags(); - tag.id = -1; - return tag; - } - } else { - return null; - } - } + public int getUnusedId() { + if (lastUsedID == 0) { + for (int catid : tags.keySet()) + if (catid > lastUsedID) + lastUsedID = catid; + } + lastUsedID++; + return lastUsedID; + } - public boolean hasName(String newName) { - if(newName.trim().isEmpty()) - return true; - for(Tag tag : tags.values()) - if(tag.name.equals(newName)) - return true; - return false; - } + public ITag delete(int id) { + if (id >= 0 && this.tags.size() > 1) { + Tag tag = (Tag) this.tags.remove(id); + saveTags(); + if (tag == null) { + return null; + } else { + this.saveTags(); + tag.id = -1; + return tag; + } + } else { + return null; + } + } - public Tag getTagFromName(String tagname){ - for (Map.Entry entryTag: TagController.getInstance().tags.entrySet()){ - if (entryTag.getValue().name.equalsIgnoreCase(tagname)){ - return entryTag.getValue(); - } - } - return null; - } + public boolean hasName(String newName) { + if (newName.trim().isEmpty()) + return true; + for (Tag tag : tags.values()) + if (tag.name.equals(newName)) + return true; + return false; + } - public Tag getTagFromUUID(UUID uuid){ - for (Map.Entry entryTag: TagController.getInstance().tags.entrySet()){ - if (entryTag.getValue().uuid.equals(uuid)) { - return entryTag.getValue(); - } - } - return null; - } + public Tag getTagFromName(String tagname) { + for (Map.Entry entryTag : TagController.getInstance().tags.entrySet()) { + if (entryTag.getValue().name.equalsIgnoreCase(tagname)) { + return entryTag.getValue(); + } + } + return null; + } - public String[] getNames() { - String[] names = new String[tags.size()]; - int i = 0; - for(Tag tag : tags.values()){ - names[i] = tag.name.toLowerCase(); - i++; - } - return names; - } + public Tag getTagFromUUID(UUID uuid) { + for (Map.Entry entryTag : TagController.getInstance().tags.entrySet()) { + if (entryTag.getValue().uuid.equals(uuid)) { + return entryTag.getValue(); + } + } + return null; + } - public HashSet getAllTags(){ - return new HashSet(this.tags.values()); - } + public String[] getNames() { + String[] names = new String[tags.size()]; + int i = 0; + for (Tag tag : tags.values()) { + names[i] = tag.name.toLowerCase(); + i++; + } + return names; + } + + public HashSet getAllTags() { + return new HashSet(this.tags.values()); + } } diff --git a/src/main/java/noppes/npcs/controllers/TransportController.java b/src/main/java/noppes/npcs/controllers/TransportController.java index 1d76c6167..bebcb09cb 100644 --- a/src/main/java/noppes/npcs/controllers/TransportController.java +++ b/src/main/java/noppes/npcs/controllers/TransportController.java @@ -22,276 +22,284 @@ import java.util.HashMap; import java.util.Map; public class TransportController implements ITransportHandler { - private HashMap locations = new HashMap(); - public HashMap categories = new HashMap(); + private HashMap locations = new HashMap(); + public HashMap categories = new HashMap(); - private int lastUsedID = 0; - - private static TransportController instance; - public TransportController(){ - instance = this; - loadCategories(); - if(categories.isEmpty()){ - TransportCategory cat = new TransportCategory(); - cat.id = 1; - cat.title = "Default"; - categories.put(cat.id, cat); - } - } - private void loadCategories(){ - File saveDir = CustomNpcs.getWorldSaveDirectory(); - if(saveDir == null) - return; - try { - File file = new File(saveDir, "transport.dat"); - if(!file.exists()){ - return; - } - loadCategories(file); - } catch (IOException e) { - try { - File file = new File(saveDir, "transport.dat_old"); - if(!file.exists()){ - return; - } - loadCategories(file); - - } catch (IOException ee) { - } - } - } + private int lastUsedID = 0; - public void loadCategories(File file) throws IOException{ - HashMap locations = new HashMap(); - HashMap categories = new HashMap(); + private static TransportController instance; + + public TransportController() { + instance = this; + loadCategories(); + if (categories.isEmpty()) { + TransportCategory cat = new TransportCategory(); + cat.id = 1; + cat.title = "Default"; + categories.put(cat.id, cat); + } + } + + private void loadCategories() { + File saveDir = CustomNpcs.getWorldSaveDirectory(); + if (saveDir == null) + return; + try { + File file = new File(saveDir, "transport.dat"); + if (!file.exists()) { + return; + } + loadCategories(file); + } catch (IOException e) { + try { + File file = new File(saveDir, "transport.dat_old"); + if (!file.exists()) { + return; + } + loadCategories(file); + + } catch (IOException ee) { + } + } + } + + public void loadCategories(File file) throws IOException { + HashMap locations = new HashMap(); + HashMap categories = new HashMap(); NBTTagCompound nbttagcompound1 = CompressedStreamTools.readCompressed(new FileInputStream(file)); lastUsedID = nbttagcompound1.getInteger("lastID"); NBTTagList list = nbttagcompound1.getTagList("NPCTransportCategories", 10); - if(list == null){ - return; + if (list == null) { + return; } - for(int i = 0; i < list.tagCount(); i++) - { - TransportCategory category = new TransportCategory(); - NBTTagCompound compound = list.getCompoundTagAt(i); - category.readNBT(compound); - - for(TransportLocation location : category.locations.values()) - locations.put(location.id,location); - + for (int i = 0; i < list.tagCount(); i++) { + TransportCategory category = new TransportCategory(); + NBTTagCompound compound = list.getCompoundTagAt(i); + category.readNBT(compound); + + for (TransportLocation location : category.locations.values()) + locations.put(location.id, location); + categories.put(category.id, category); } this.locations = locations; this.categories = categories; - } - - public NBTTagCompound getNBT(){ + } + + public NBTTagCompound getNBT() { NBTTagList list = new NBTTagList(); - for(TransportCategory category : categories.values()){ - NBTTagCompound compound = new NBTTagCompound(); - category.writeNBT(compound); - list.appendTag(compound); + for (TransportCategory category : categories.values()) { + NBTTagCompound compound = new NBTTagCompound(); + category.writeNBT(compound); + list.appendTag(compound); } NBTTagCompound nbttagcompound = new NBTTagCompound(); nbttagcompound.setInteger("lastID", lastUsedID); nbttagcompound.setTag("NPCTransportCategories", list); return nbttagcompound; - } - - public void saveCategories(){ - try { - File saveDir = CustomNpcs.getWorldSaveDirectory(); + } + + public void saveCategories() { + try { + File saveDir = CustomNpcs.getWorldSaveDirectory(); File file = new File(saveDir, "transport.dat_new"); File file1 = new File(saveDir, "transport.dat_old"); File file2 = new File(saveDir, "transport.dat"); CompressedStreamTools.writeCompressed(getNBT(), new FileOutputStream(file)); - if(file1.exists()) - { + if (file1.exists()) { file1.delete(); } file2.renameTo(file1); - if(file2.exists()) - { + if (file2.exists()) { file2.delete(); } file.renameTo(file2); - if(file.exists()) - { + if (file.exists()) { file.delete(); } - } catch (Exception e) { - LogWriter.except(e); - } - } - public TransportLocation getTransport(int transportId) { - return locations.get(transportId); - } - public TransportLocation getTransport(String name) { - for(TransportLocation loc : locations.values()){ - if(loc.name.equals(name)) - return loc; - } - - return null; - } - public int getUniqueIdLocation() { - if(lastUsedID == 0){ - for(int catid : locations.keySet()) - if(catid > lastUsedID) - lastUsedID = catid; - } - lastUsedID++; - return lastUsedID; - } - private int getUniqueIdCategory() { - int id = 0; - for(int catid : categories.keySet()) - if(catid > id) - id = catid; - id++; - return id; - } - public void setLocation(TransportLocation location) { - if(locations.containsKey(location.id)){ - for(TransportCategory cat : categories.values()) - cat.locations.remove(location.id); - } - locations.put(location.id, location); - location.category.locations.put(location.id, location); - } - public TransportLocation removeLocation(int location) { - TransportLocation loc = locations.get(location); - if(loc == null) - return null; - loc.category.locations.remove(location); - locations.remove(location); - - saveCategories(); - return loc; - } - private boolean containsCategoryName(String name) { - name = name.toLowerCase(); - for(TransportCategory cat : categories.values()){ - if(cat.title.toLowerCase().equals(name)) - return true; - } - return false; - } - public void saveCategory(String name, int id){ - if(id < 0){ - id = getUniqueIdCategory(); - } - if(categories.containsKey(id)){ - TransportCategory category = categories.get(id); - if(!category.title.equals(name)){ - while(containsCategoryName(name)) - name += "_"; - categories.get(id).title = name; - } - } - else{ - while(containsCategoryName(name)) - name += "_"; - TransportCategory category = new TransportCategory(); - category.id = id; - category.title = name; - categories.put(id, category); - } - saveCategories(); - } - public void removeCategory(int id){ - if(categories.size() == 1) - return; - TransportCategory cat = categories.get(id); - if(cat == null) - return; - for(int i : cat.locations.keySet()) - locations.remove(i); - categories.remove(id); - - saveCategories(); - } - public boolean containsLocationName(String name) { - name = name.toLowerCase(); - for(TransportLocation loc : locations.values()){ - if(loc.name.toLowerCase().equals(name)) - return true; - } - return false; - } - public static TransportController getInstance(){ - return instance; - } + } catch (Exception e) { + LogWriter.except(e); + } + } - public TransportLocation saveLocation(int categoryId, TransportLocation location){ - TransportCategory category = categories.get(categoryId); - if(category == null) - return null; - location.category = category; - if(location.id < 0 || !locations.get(location.id).name.equals(location.name)){ - while(containsLocationName(location.name)) - location.name += "_"; - } - if(location.id < 0) - location.id = getUniqueIdLocation(); + public TransportLocation getTransport(int transportId) { + return locations.get(transportId); + } - category.locations.put(location.id, location); - locations.put(location.id, location); - saveCategories(); + public TransportLocation getTransport(String name) { + for (TransportLocation loc : locations.values()) { + if (loc.name.equals(name)) + return loc; + } - return location; - } + return null; + } - public TransportLocation saveLocation(int categoryId, NBTTagCompound compound, EntityNPCInterface npc){ - TransportCategory category = categories.get(categoryId); - if(category == null || npc.advanced.role != EnumRoleType.Transporter) - return null; - RoleTransporter role = (RoleTransporter) npc.roleInterface; - TransportLocation location = new TransportLocation(); - location.readNBT(compound); - location.category = category; - if(role.hasTransport()) - location.id = role.transportId; - if(location.id < 0 || !locations.get(location.id).name.equals(location.name)){ - while(containsLocationName(location.name)) - location.name += "_"; - } - if(location.id < 0) - location.id = getUniqueIdLocation(); - - category.locations.put(location.id, location); - locations.put(location.id, location); - saveCategories(); - - return location; - } + public int getUniqueIdLocation() { + if (lastUsedID == 0) { + for (int catid : locations.keySet()) + if (catid > lastUsedID) + lastUsedID = catid; + } + lastUsedID++; + return lastUsedID; + } - public ITransportCategory[] categories() { - return (new ArrayList<>(categories.values())).toArray(new ITransportCategory[0]); - } + private int getUniqueIdCategory() { + int id = 0; + for (int catid : categories.keySet()) + if (catid > id) + id = catid; + id++; + return id; + } - public void createCategory(String title) { - this.saveCategory(title, -1); - } + public void setLocation(TransportLocation location) { + if (locations.containsKey(location.id)) { + for (TransportCategory cat : categories.values()) + cat.locations.remove(location.id); + } + locations.put(location.id, location); + location.category.locations.put(location.id, location); + } - public ITransportCategory getCategory(String title) { - TransportCategory category = null; - for (TransportCategory c : categories.values()) { - if (c.title.equals(title)) { - category = c; - break; - } - } + public TransportLocation removeLocation(int location) { + TransportLocation loc = locations.get(location); + if (loc == null) + return null; + loc.category.locations.remove(location); + locations.remove(location); - return category; - } + saveCategories(); + return loc; + } - public void removeCategory(String title) { - for (Map.Entry entry : categories.entrySet()) { - if (entry.getValue().title.equals(title)) { - categories.remove(entry.getKey()); - break; - } - } - } + private boolean containsCategoryName(String name) { + name = name.toLowerCase(); + for (TransportCategory cat : categories.values()) { + if (cat.title.toLowerCase().equals(name)) + return true; + } + return false; + } + + public void saveCategory(String name, int id) { + if (id < 0) { + id = getUniqueIdCategory(); + } + if (categories.containsKey(id)) { + TransportCategory category = categories.get(id); + if (!category.title.equals(name)) { + while (containsCategoryName(name)) + name += "_"; + categories.get(id).title = name; + } + } else { + while (containsCategoryName(name)) + name += "_"; + TransportCategory category = new TransportCategory(); + category.id = id; + category.title = name; + categories.put(id, category); + } + saveCategories(); + } + + public void removeCategory(int id) { + if (categories.size() == 1) + return; + TransportCategory cat = categories.get(id); + if (cat == null) + return; + for (int i : cat.locations.keySet()) + locations.remove(i); + categories.remove(id); + + saveCategories(); + } + + public boolean containsLocationName(String name) { + name = name.toLowerCase(); + for (TransportLocation loc : locations.values()) { + if (loc.name.toLowerCase().equals(name)) + return true; + } + return false; + } + + public static TransportController getInstance() { + return instance; + } + + public TransportLocation saveLocation(int categoryId, TransportLocation location) { + TransportCategory category = categories.get(categoryId); + if (category == null) + return null; + location.category = category; + if (location.id < 0 || !locations.get(location.id).name.equals(location.name)) { + while (containsLocationName(location.name)) + location.name += "_"; + } + if (location.id < 0) + location.id = getUniqueIdLocation(); + + category.locations.put(location.id, location); + locations.put(location.id, location); + saveCategories(); + + return location; + } + + public TransportLocation saveLocation(int categoryId, NBTTagCompound compound, EntityNPCInterface npc) { + TransportCategory category = categories.get(categoryId); + if (category == null || npc.advanced.role != EnumRoleType.Transporter) + return null; + RoleTransporter role = (RoleTransporter) npc.roleInterface; + TransportLocation location = new TransportLocation(); + location.readNBT(compound); + location.category = category; + if (role.hasTransport()) + location.id = role.transportId; + if (location.id < 0 || !locations.get(location.id).name.equals(location.name)) { + while (containsLocationName(location.name)) + location.name += "_"; + } + if (location.id < 0) + location.id = getUniqueIdLocation(); + + category.locations.put(location.id, location); + locations.put(location.id, location); + saveCategories(); + + return location; + } + + public ITransportCategory[] categories() { + return (new ArrayList<>(categories.values())).toArray(new ITransportCategory[0]); + } + + public void createCategory(String title) { + this.saveCategory(title, -1); + } + + public ITransportCategory getCategory(String title) { + TransportCategory category = null; + for (TransportCategory c : categories.values()) { + if (c.title.equals(title)) { + category = c; + break; + } + } + + return category; + } + + public void removeCategory(String title) { + for (Map.Entry entry : categories.entrySet()) { + if (entry.getValue().title.equals(title)) { + categories.remove(entry.getKey()); + break; + } + } + } } diff --git a/src/main/java/noppes/npcs/controllers/data/Animation.java b/src/main/java/noppes/npcs/controllers/data/Animation.java index 5197a0242..b60f9ad4d 100644 --- a/src/main/java/noppes/npcs/controllers/data/Animation.java +++ b/src/main/java/noppes/npcs/controllers/data/Animation.java @@ -34,14 +34,15 @@ public class Animation implements IAnimation { //Client-sided public boolean paused; - public Animation(){} + public Animation() { + } - public Animation(int id, String name){ + public Animation(int id, String name) { this.name = name; this.id = id; } - public Animation(int id, String name, float speed, byte smooth){ + public Animation(int id, String name, float speed, byte smooth) { this.name = name; this.speed = speed; this.smooth = smooth; @@ -174,11 +175,10 @@ public class Animation implements IAnimation { return time; } - public void readFromNBT(NBTTagCompound compound){ - if(compound.hasKey("ID")){ + public void readFromNBT(NBTTagCompound compound) { + if (compound.hasKey("ID")) { id = compound.getInteger("ID"); - } - else if (AnimationController.Instance != null) { + } else if (AnimationController.Instance != null) { id = AnimationController.Instance.getUnusedId(); } @@ -206,16 +206,16 @@ public class Animation implements IAnimation { this.currentFrameTime = compound.getInteger("CurrentFrameTime"); } - public NBTTagCompound writeToNBT(){ + public NBTTagCompound writeToNBT() { NBTTagCompound compound = new NBTTagCompound(); compound.setInteger("ID", id); compound.setString("Name", name); compound.setFloat("Speed", speed); compound.setByte("Smooth", smooth); - compound.setInteger("Loop",loop); + compound.setInteger("Loop", loop); NBTTagList list = new NBTTagList(); - for(Frame frame : frames){ + for (Frame frame : frames) { NBTTagCompound item = frame.writeToNBT(); list.appendTag(item); } @@ -284,9 +284,9 @@ public class Animation implements IAnimation { this.currentFrameTime = time; Frame frame = (Frame) this.currentFrame(); - if(frame != null){ + if (frame != null) { for (EnumAnimationPart part : EnumAnimationPart.values()) { - if(part != null){ + if (part != null) { if (frame.frameParts.containsKey(part)) { frame.frameParts.get(part).jumpToCurrentFrame(); } diff --git a/src/main/java/noppes/npcs/controllers/data/AnimationData.java b/src/main/java/noppes/npcs/controllers/data/AnimationData.java index 8987c71f6..681a403b1 100644 --- a/src/main/java/noppes/npcs/controllers/data/AnimationData.java +++ b/src/main/java/noppes/npcs/controllers/data/AnimationData.java @@ -41,7 +41,7 @@ public class AnimationData implements IAnimationData { public int finishedTime = -1; public int finishedFrame = -1; - public AnimationData(Object parent){ + public AnimationData(Object parent) { this.parent = parent; } @@ -56,7 +56,7 @@ public class AnimationData implements IAnimationData { if (entity instanceof EntityPlayerMP) { return PlayerData.get((EntityPlayer) entity).animationData; } else if (entity instanceof EntityNPCInterface) { - return ((EntityNPCInterface)entity).display.animationData; + return ((EntityNPCInterface) entity).display.animationData; } else { return null; } @@ -72,7 +72,7 @@ public class AnimationData implements IAnimationData { public EntityLivingBase getMCEntity() { if (this.parent instanceof DataDisplay) { - return ((DataDisplay) this.parent).npc; + return ((DataDisplay) this.parent).npc; } else { if (this.parent instanceof PlayerData) { return ((PlayerData) this.parent).player; @@ -90,7 +90,7 @@ public class AnimationData implements IAnimationData { EntityLivingBase sendingEntity = parent instanceof PlayerData ? ((PlayerData) parent).player : parent instanceof DataDisplay ? ((DataDisplay) parent).npc : null; float range = parent instanceof PlayerData ? 160 : 60; if (sendingEntity != null) { - if(sendingEntity.dimension != sendingEntity.worldObj.provider.dimensionId) + if (sendingEntity.dimension != sendingEntity.worldObj.provider.dimensionId) sendingEntity.dimension = sendingEntity.worldObj.provider.dimensionId; this.animatingTime = 0; @@ -137,7 +137,7 @@ public class AnimationData implements IAnimationData { return false; if (this.parent instanceof DataDisplay) { - EntityNPCInterface npc = ((DataDisplay)this.parent).npc; + EntityNPCInterface npc = ((DataDisplay) this.parent).npc; if (!npc.isEntityAlive()) return false; @@ -152,7 +152,7 @@ public class AnimationData implements IAnimationData { if (!player.isEntityAlive()) return false; - boolean moving = Math.sqrt(player.motionX*player.motionX + player.motionY*player.motionY + player.motionZ*player.motionZ) != 0.0D; + boolean moving = Math.sqrt(player.motionX * player.motionX + player.motionY * player.motionY + player.motionZ * player.motionZ) != 0.0D; return animation.whileAttacking && player.getLastAttackerTime() - player.ticksExisted < 20 || animation.whileMoving && moving || animation.whileStanding && !moving; } diff --git a/src/main/java/noppes/npcs/controllers/data/Availability.java b/src/main/java/noppes/npcs/controllers/data/Availability.java index fcb6d778b..ffc59bd3f 100644 --- a/src/main/java/noppes/npcs/controllers/data/Availability.java +++ b/src/main/java/noppes/npcs/controllers/data/Availability.java @@ -20,115 +20,114 @@ import java.util.ArrayList; import java.util.List; public class Availability implements ICompatibilty, IAvailability { - public int version = VersionCompatibility.ModRev; + public int version = VersionCompatibility.ModRev; - public EnumAvailabilityDialog dialogAvailable = EnumAvailabilityDialog.Always; - public EnumAvailabilityDialog dialog2Available = EnumAvailabilityDialog.Always; - public EnumAvailabilityDialog dialog3Available = EnumAvailabilityDialog.Always; - public EnumAvailabilityDialog dialog4Available = EnumAvailabilityDialog.Always; - public int dialogId = -1; - public int dialog2Id = -1; - public int dialog3Id = -1; - public int dialog4Id = -1; + public EnumAvailabilityDialog dialogAvailable = EnumAvailabilityDialog.Always; + public EnumAvailabilityDialog dialog2Available = EnumAvailabilityDialog.Always; + public EnumAvailabilityDialog dialog3Available = EnumAvailabilityDialog.Always; + public EnumAvailabilityDialog dialog4Available = EnumAvailabilityDialog.Always; + public int dialogId = -1; + public int dialog2Id = -1; + public int dialog3Id = -1; + public int dialog4Id = -1; - public EnumAvailabilityQuest questAvailable = EnumAvailabilityQuest.Always; - public EnumAvailabilityQuest quest2Available = EnumAvailabilityQuest.Always; - public EnumAvailabilityQuest quest3Available = EnumAvailabilityQuest.Always; - public EnumAvailabilityQuest quest4Available = EnumAvailabilityQuest.Always; - public int questId = -1; - public int quest2Id = -1; - public int quest3Id = -1; - public int quest4Id = -1; + public EnumAvailabilityQuest questAvailable = EnumAvailabilityQuest.Always; + public EnumAvailabilityQuest quest2Available = EnumAvailabilityQuest.Always; + public EnumAvailabilityQuest quest3Available = EnumAvailabilityQuest.Always; + public EnumAvailabilityQuest quest4Available = EnumAvailabilityQuest.Always; + public int questId = -1; + public int quest2Id = -1; + public int quest3Id = -1; + public int quest4Id = -1; - public EnumDayTime daytime = EnumDayTime.Always; + public EnumDayTime daytime = EnumDayTime.Always; - public int factionId = -1; - public int faction2Id = -1; + public int factionId = -1; + public int faction2Id = -1; - public EnumAvailabilityFactionType factionAvailable = EnumAvailabilityFactionType.Always; - public EnumAvailabilityFactionType faction2Available = EnumAvailabilityFactionType.Always; + public EnumAvailabilityFactionType factionAvailable = EnumAvailabilityFactionType.Always; + public EnumAvailabilityFactionType faction2Available = EnumAvailabilityFactionType.Always; - public EnumAvailabilityFaction factionStance = EnumAvailabilityFaction.Friendly; - public EnumAvailabilityFaction faction2Stance = EnumAvailabilityFaction.Friendly; + public EnumAvailabilityFaction factionStance = EnumAvailabilityFaction.Friendly; + public EnumAvailabilityFaction faction2Stance = EnumAvailabilityFaction.Friendly; - public int minPlayerLevel = 0; + public int minPlayerLevel = 0; - public void readFromNBT(NBTTagCompound compound) - { - version = compound.getInteger("ModRev"); - VersionCompatibility.CheckAvailabilityCompatibility(this, compound); + public void readFromNBT(NBTTagCompound compound) { + version = compound.getInteger("ModRev"); + VersionCompatibility.CheckAvailabilityCompatibility(this, compound); - dialogAvailable = EnumAvailabilityDialog.values()[compound.getInteger("AvailabilityDialog")]; - dialog2Available = EnumAvailabilityDialog.values()[compound.getInteger("AvailabilityDialog2")]; - dialog3Available = EnumAvailabilityDialog.values()[compound.getInteger("AvailabilityDialog3")]; - dialog4Available = EnumAvailabilityDialog.values()[compound.getInteger("AvailabilityDialog4")]; + dialogAvailable = EnumAvailabilityDialog.values()[compound.getInteger("AvailabilityDialog")]; + dialog2Available = EnumAvailabilityDialog.values()[compound.getInteger("AvailabilityDialog2")]; + dialog3Available = EnumAvailabilityDialog.values()[compound.getInteger("AvailabilityDialog3")]; + dialog4Available = EnumAvailabilityDialog.values()[compound.getInteger("AvailabilityDialog4")]; - dialogId = compound.getInteger("AvailabilityDialogId"); - dialog2Id = compound.getInteger("AvailabilityDialog2Id"); - dialog3Id = compound.getInteger("AvailabilityDialog3Id"); - dialog4Id = compound.getInteger("AvailabilityDialog4Id"); + dialogId = compound.getInteger("AvailabilityDialogId"); + dialog2Id = compound.getInteger("AvailabilityDialog2Id"); + dialog3Id = compound.getInteger("AvailabilityDialog3Id"); + dialog4Id = compound.getInteger("AvailabilityDialog4Id"); - questAvailable = EnumAvailabilityQuest.values()[compound.getInteger("AvailabilityQuest")]; - quest2Available = EnumAvailabilityQuest.values()[compound.getInteger("AvailabilityQuest2")]; - quest3Available = EnumAvailabilityQuest.values()[compound.getInteger("AvailabilityQuest3")]; - quest4Available = EnumAvailabilityQuest.values()[compound.getInteger("AvailabilityQuest4")]; + questAvailable = EnumAvailabilityQuest.values()[compound.getInteger("AvailabilityQuest")]; + quest2Available = EnumAvailabilityQuest.values()[compound.getInteger("AvailabilityQuest2")]; + quest3Available = EnumAvailabilityQuest.values()[compound.getInteger("AvailabilityQuest3")]; + quest4Available = EnumAvailabilityQuest.values()[compound.getInteger("AvailabilityQuest4")]; - questId = compound.getInteger("AvailabilityQuestId"); - quest2Id = compound.getInteger("AvailabilityQuest2Id"); - quest3Id = compound.getInteger("AvailabilityQuest3Id"); - quest4Id = compound.getInteger("AvailabilityQuest4Id"); + questId = compound.getInteger("AvailabilityQuestId"); + quest2Id = compound.getInteger("AvailabilityQuest2Id"); + quest3Id = compound.getInteger("AvailabilityQuest3Id"); + quest4Id = compound.getInteger("AvailabilityQuest4Id"); - setFactionAvailability(compound.getInteger("AvailabilityFaction")); - setFactionAvailabilityStance(compound.getInteger("AvailabilityFactionStance")); + setFactionAvailability(compound.getInteger("AvailabilityFaction")); + setFactionAvailabilityStance(compound.getInteger("AvailabilityFactionStance")); - setFaction2Availability(compound.getInteger("AvailabilityFaction2")); - setFaction2AvailabilityStance(compound.getInteger("AvailabilityFaction2Stance")); + setFaction2Availability(compound.getInteger("AvailabilityFaction2")); + setFaction2AvailabilityStance(compound.getInteger("AvailabilityFaction2Stance")); - factionId = compound.getInteger("AvailabilityFactionId"); - faction2Id = compound.getInteger("AvailabilityFaction2Id"); + factionId = compound.getInteger("AvailabilityFactionId"); + faction2Id = compound.getInteger("AvailabilityFaction2Id"); - daytime = EnumDayTime.values()[compound.getInteger("AvailabilityDayTime")]; + daytime = EnumDayTime.values()[compound.getInteger("AvailabilityDayTime")]; - minPlayerLevel = compound.getInteger("AvailabilityMinPlayerLevel"); + minPlayerLevel = compound.getInteger("AvailabilityMinPlayerLevel"); } - public NBTTagCompound writeToNBT(NBTTagCompound compound){ - compound.setInteger("ModRev", version); + public NBTTagCompound writeToNBT(NBTTagCompound compound) { + compound.setInteger("ModRev", version); - compound.setInteger("AvailabilityDialog", dialogAvailable.ordinal()); - compound.setInteger("AvailabilityDialog2", dialog2Available.ordinal()); - compound.setInteger("AvailabilityDialog3", dialog3Available.ordinal()); - compound.setInteger("AvailabilityDialog4", dialog4Available.ordinal()); + compound.setInteger("AvailabilityDialog", dialogAvailable.ordinal()); + compound.setInteger("AvailabilityDialog2", dialog2Available.ordinal()); + compound.setInteger("AvailabilityDialog3", dialog3Available.ordinal()); + compound.setInteger("AvailabilityDialog4", dialog4Available.ordinal()); - compound.setInteger("AvailabilityDialogId", dialogId); - compound.setInteger("AvailabilityDialog2Id", dialog2Id); - compound.setInteger("AvailabilityDialog3Id", dialog3Id); - compound.setInteger("AvailabilityDialog4Id", dialog4Id); + compound.setInteger("AvailabilityDialogId", dialogId); + compound.setInteger("AvailabilityDialog2Id", dialog2Id); + compound.setInteger("AvailabilityDialog3Id", dialog3Id); + compound.setInteger("AvailabilityDialog4Id", dialog4Id); - compound.setInteger("AvailabilityQuest", questAvailable.ordinal()); - compound.setInteger("AvailabilityQuest2", quest2Available.ordinal()); - compound.setInteger("AvailabilityQuest3", quest3Available.ordinal()); - compound.setInteger("AvailabilityQuest4", quest4Available.ordinal()); + compound.setInteger("AvailabilityQuest", questAvailable.ordinal()); + compound.setInteger("AvailabilityQuest2", quest2Available.ordinal()); + compound.setInteger("AvailabilityQuest3", quest3Available.ordinal()); + compound.setInteger("AvailabilityQuest4", quest4Available.ordinal()); - compound.setInteger("AvailabilityQuestId", questId); - compound.setInteger("AvailabilityQuest2Id", quest2Id); - compound.setInteger("AvailabilityQuest3Id", quest3Id); - compound.setInteger("AvailabilityQuest4Id", quest4Id); + compound.setInteger("AvailabilityQuestId", questId); + compound.setInteger("AvailabilityQuest2Id", quest2Id); + compound.setInteger("AvailabilityQuest3Id", quest3Id); + compound.setInteger("AvailabilityQuest4Id", quest4Id); - compound.setInteger("AvailabilityFaction", factionAvailable.ordinal()); - compound.setInteger("AvailabilityFactionStance", factionStance.ordinal()); + compound.setInteger("AvailabilityFaction", factionAvailable.ordinal()); + compound.setInteger("AvailabilityFactionStance", factionStance.ordinal()); - compound.setInteger("AvailabilityFactionId", factionId); + compound.setInteger("AvailabilityFactionId", factionId); - compound.setInteger("AvailabilityFaction2", faction2Available.ordinal()); - compound.setInteger("AvailabilityFaction2Stance", faction2Stance.ordinal()); + compound.setInteger("AvailabilityFaction2", faction2Available.ordinal()); + compound.setInteger("AvailabilityFaction2Stance", faction2Stance.ordinal()); - compound.setInteger("AvailabilityFaction2Id", faction2Id); + compound.setInteger("AvailabilityFaction2Id", faction2Id); - compound.setInteger("AvailabilityDayTime", daytime.ordinal()); - compound.setInteger("AvailabilityMinPlayerLevel", minPlayerLevel); - return compound; + compound.setInteger("AvailabilityDayTime", daytime.ordinal()); + compound.setInteger("AvailabilityMinPlayerLevel", minPlayerLevel); + return compound; } public boolean isDefault() { @@ -155,58 +154,62 @@ public class Availability implements ICompatibilty, IAvailability { minPlayerLevel == 0; } - public void setFactionAvailability(int value) { - factionAvailable = EnumAvailabilityFactionType.values()[value]; - } - public void setFaction2Availability(int value) { - faction2Available = EnumAvailabilityFactionType.values()[value]; - } - public void setFactionAvailabilityStance(int integer) { - factionStance = EnumAvailabilityFaction.values()[integer]; - } - public void setFaction2AvailabilityStance(int integer) { - faction2Stance = EnumAvailabilityFaction.values()[integer]; - } - public boolean isAvailable(EntityPlayer player){ - if(daytime == EnumDayTime.Day){ - long time = player.worldObj.getWorldTime() % 24000; - if(time > 12000) - return false; - } - if(daytime == EnumDayTime.Night){ - long time = player.worldObj.getWorldTime() % 24000; - if(time < 12000) - return false; - } + public void setFactionAvailability(int value) { + factionAvailable = EnumAvailabilityFactionType.values()[value]; + } - if(!dialogAvailable(dialogId, dialogAvailable, player)) - return false; - if(!dialogAvailable(dialog2Id, dialog2Available, player)) - return false; - if(!dialogAvailable(dialog3Id, dialog3Available, player)) - return false; - if(!dialogAvailable(dialog4Id, dialog4Available, player)) - return false; + public void setFaction2Availability(int value) { + faction2Available = EnumAvailabilityFactionType.values()[value]; + } - if(!questAvailable(questId, questAvailable, player)) - return false; - if(!questAvailable(quest2Id, quest2Available, player)) - return false; - if(!questAvailable(quest3Id, quest3Available, player)) - return false; - if(!questAvailable(quest4Id, quest4Available, player)) - return false; + public void setFactionAvailabilityStance(int integer) { + factionStance = EnumAvailabilityFaction.values()[integer]; + } - if(!factionAvailable(factionId, factionStance, factionAvailable, player)) - return false; - if(!factionAvailable(faction2Id, faction2Stance, faction2Available, player)) - return false; + public void setFaction2AvailabilityStance(int integer) { + faction2Stance = EnumAvailabilityFaction.values()[integer]; + } - if(player.experienceLevel < minPlayerLevel) - return false; + public boolean isAvailable(EntityPlayer player) { + if (daytime == EnumDayTime.Day) { + long time = player.worldObj.getWorldTime() % 24000; + if (time > 12000) + return false; + } + if (daytime == EnumDayTime.Night) { + long time = player.worldObj.getWorldTime() % 24000; + if (time < 12000) + return false; + } - return true; - } + if (!dialogAvailable(dialogId, dialogAvailable, player)) + return false; + if (!dialogAvailable(dialog2Id, dialog2Available, player)) + return false; + if (!dialogAvailable(dialog3Id, dialog3Available, player)) + return false; + if (!dialogAvailable(dialog4Id, dialog4Available, player)) + return false; + + if (!questAvailable(questId, questAvailable, player)) + return false; + if (!questAvailable(quest2Id, quest2Available, player)) + return false; + if (!questAvailable(quest3Id, quest3Available, player)) + return false; + if (!questAvailable(quest4Id, quest4Available, player)) + return false; + + if (!factionAvailable(factionId, factionStance, factionAvailable, player)) + return false; + if (!factionAvailable(faction2Id, faction2Stance, faction2Available, player)) + return false; + + if (player.experienceLevel < minPlayerLevel) + return false; + + return true; + } @SideOnly(Side.CLIENT) public List isAvailableText(EntityPlayer player) { @@ -266,241 +269,243 @@ public class Availability implements ICompatibilty, IAvailability { return errors; } - private boolean factionAvailable(int id, EnumAvailabilityFaction stance, EnumAvailabilityFactionType available, EntityPlayer player) { - if(available == EnumAvailabilityFactionType.Always) - return true; + private boolean factionAvailable(int id, EnumAvailabilityFaction stance, EnumAvailabilityFactionType available, EntityPlayer player) { + if (available == EnumAvailabilityFactionType.Always) + return true; - Faction faction = FactionController.getInstance().get(id); - if(faction == null) - return true; + Faction faction = FactionController.getInstance().get(id); + if (faction == null) + return true; - PlayerFactionData data = PlayerData.get(player).factionData; - int points = data.getFactionPoints(id); + PlayerFactionData data = PlayerData.get(player).factionData; + int points = data.getFactionPoints(id); - EnumAvailabilityFaction current = EnumAvailabilityFaction.Neutral; - if(faction.neutralPoints >= points) - current = EnumAvailabilityFaction.Hostile; - if(faction.friendlyPoints < points) - current = EnumAvailabilityFaction.Friendly; + EnumAvailabilityFaction current = EnumAvailabilityFaction.Neutral; + if (faction.neutralPoints >= points) + current = EnumAvailabilityFaction.Hostile; + if (faction.friendlyPoints < points) + current = EnumAvailabilityFaction.Friendly; - if(available == EnumAvailabilityFactionType.Is && stance == current){ - return true; - } - if(available == EnumAvailabilityFactionType.IsNot && stance != current){ - return true; - } + if (available == EnumAvailabilityFactionType.Is && stance == current) { + return true; + } + if (available == EnumAvailabilityFactionType.IsNot && stance != current) { + return true; + } - return false; - } + return false; + } - public boolean dialogAvailable(int id, EnumAvailabilityDialog en, EntityPlayer player){ - if(player == null) + public boolean dialogAvailable(int id, EnumAvailabilityDialog en, EntityPlayer player) { + if (player == null) return false; - if(en == EnumAvailabilityDialog.Always) - return true; + if (en == EnumAvailabilityDialog.Always) + return true; PlayerData data = PlayerData.get(player); - if(data == null) + if (data == null) return false; - boolean hasRead = data.dialogData.dialogsRead.contains(id); - if(hasRead && en == EnumAvailabilityDialog.After) - return true; - else if(!hasRead && en == EnumAvailabilityDialog.Before) - return true; - return false; - } + boolean hasRead = data.dialogData.dialogsRead.contains(id); + if (hasRead && en == EnumAvailabilityDialog.After) + return true; + else if (!hasRead && en == EnumAvailabilityDialog.Before) + return true; + return false; + } - public boolean questAvailable(int id, EnumAvailabilityQuest en, EntityPlayer player){ - if(en == EnumAvailabilityQuest.Always) - return true; - else if(en == EnumAvailabilityQuest.After && PlayerQuestController.isQuestFinished(player, id)) - return true; - else if(en == EnumAvailabilityQuest.Before && !PlayerQuestController.isQuestFinished(player, id)) - return true; - else if(en == EnumAvailabilityQuest.Active && PlayerQuestController.isQuestActive(player, id)) - return true; - else if(en == EnumAvailabilityQuest.NotActive && !PlayerQuestController.isQuestActive(player, id)) - return true; - else if(en == EnumAvailabilityQuest.Acceptable || en == EnumAvailabilityQuest.NotAcceptable){ + public boolean questAvailable(int id, EnumAvailabilityQuest en, EntityPlayer player) { + if (en == EnumAvailabilityQuest.Always) + return true; + else if (en == EnumAvailabilityQuest.After && PlayerQuestController.isQuestFinished(player, id)) + return true; + else if (en == EnumAvailabilityQuest.Before && !PlayerQuestController.isQuestFinished(player, id)) + return true; + else if (en == EnumAvailabilityQuest.Active && PlayerQuestController.isQuestActive(player, id)) + return true; + else if (en == EnumAvailabilityQuest.NotActive && !PlayerQuestController.isQuestActive(player, id)) + return true; + else if (en == EnumAvailabilityQuest.Acceptable || en == EnumAvailabilityQuest.NotAcceptable) { Quest quest = QuestController.Instance.quests.get(id); - if(quest == null) + if (quest == null) return true; boolean result = PlayerQuestController.canQuestBeAccepted(quest, player); return (result && en == EnumAvailabilityQuest.Acceptable) || (!result && en == EnumAvailabilityQuest.NotAcceptable); } - return false; - } - @Override - public int getVersion() { - return version; - } - @Override - public void setVersion(int version) { - this.version = version; - } + return false; + } - public boolean isAvailable(IPlayer player) { - return this.isAvailable((EntityPlayer)player.getMCEntity()); - } + @Override + public int getVersion() { + return version; + } - public int getDaytime() { - return this.daytime.ordinal(); - } + @Override + public void setVersion(int version) { + this.version = version; + } - public void setDaytime(int type) { - this.daytime = EnumDayTime.values()[MathHelper.clamp_int(type, 0, 2)]; - } + public boolean isAvailable(IPlayer player) { + return this.isAvailable((EntityPlayer) player.getMCEntity()); + } - public int getMinPlayerLevel() { - return this.minPlayerLevel; - } + public int getDaytime() { + return this.daytime.ordinal(); + } - public void setMinPlayerLevel(int level) { - this.minPlayerLevel = level; - } + public void setDaytime(int type) { + this.daytime = EnumDayTime.values()[MathHelper.clamp_int(type, 0, 2)]; + } - public int getDialog(int i) { - if (i < 0 || i > 3) { - throw new CustomNPCsException(i + " isnt between 0 and 3", new Object[0]); - } else if (i == 0) { - return this.dialogId; - } else if (i == 1) { - return this.dialog2Id; - } else { - return i == 2 ? this.dialog3Id : this.dialog4Id; - } - } + public int getMinPlayerLevel() { + return this.minPlayerLevel; + } - public void setDialog(int i, int id, int type) { - if (i < 0 || i > 3) { - throw new CustomNPCsException(i + " isnt between 0 and 3", new Object[0]); - } else { - EnumAvailabilityDialog e = EnumAvailabilityDialog.values()[MathHelper.clamp_int(type, 0, 2)]; - if (i == 0) { - this.dialogId = id; - this.dialogAvailable = e; - } else if (i == 1) { - this.dialog2Id = id; - this.dialog2Available = e; - } else if (i == 2) { - this.dialog3Id = id; - this.dialog3Available = e; - } else if (i == 3) { - this.dialog4Id = id; - this.dialog4Available = e; - } + public void setMinPlayerLevel(int level) { + this.minPlayerLevel = level; + } - } - } + public int getDialog(int i) { + if (i < 0 || i > 3) { + throw new CustomNPCsException(i + " isnt between 0 and 3", new Object[0]); + } else if (i == 0) { + return this.dialogId; + } else if (i == 1) { + return this.dialog2Id; + } else { + return i == 2 ? this.dialog3Id : this.dialog4Id; + } + } - public void removeDialog(int i) { - if (i < 0 || i > 3) { - throw new CustomNPCsException(i + " isnt between 0 and 3", new Object[0]); - } else { - if (i == 0) { - this.dialogId = -1; - this.dialogAvailable = EnumAvailabilityDialog.Always; - } else if (i == 1) { - this.dialog2Id = -1; - this.dialog2Available = EnumAvailabilityDialog.Always; - } else if (i == 2) { - this.dialog3Id = -1; - this.dialog3Available = EnumAvailabilityDialog.Always; - } else if (i == 3) { - this.dialog4Id = -1; - this.dialog4Available = EnumAvailabilityDialog.Always; - } + public void setDialog(int i, int id, int type) { + if (i < 0 || i > 3) { + throw new CustomNPCsException(i + " isnt between 0 and 3", new Object[0]); + } else { + EnumAvailabilityDialog e = EnumAvailabilityDialog.values()[MathHelper.clamp_int(type, 0, 2)]; + if (i == 0) { + this.dialogId = id; + this.dialogAvailable = e; + } else if (i == 1) { + this.dialog2Id = id; + this.dialog2Available = e; + } else if (i == 2) { + this.dialog3Id = id; + this.dialog3Available = e; + } else if (i == 3) { + this.dialog4Id = id; + this.dialog4Available = e; + } - } - } + } + } - public int getQuest(int i) { - if (i < 0 || i > 3) { - throw new CustomNPCsException(i + " isnt between 0 and 3", new Object[0]); - } else if (i == 0) { - return this.questId; - } else if (i == 1) { - return this.quest2Id; - } else { - return i == 2 ? this.quest3Id : this.quest4Id; - } - } + public void removeDialog(int i) { + if (i < 0 || i > 3) { + throw new CustomNPCsException(i + " isnt between 0 and 3", new Object[0]); + } else { + if (i == 0) { + this.dialogId = -1; + this.dialogAvailable = EnumAvailabilityDialog.Always; + } else if (i == 1) { + this.dialog2Id = -1; + this.dialog2Available = EnumAvailabilityDialog.Always; + } else if (i == 2) { + this.dialog3Id = -1; + this.dialog3Available = EnumAvailabilityDialog.Always; + } else if (i == 3) { + this.dialog4Id = -1; + this.dialog4Available = EnumAvailabilityDialog.Always; + } - public void setQuest(int i, int id, int type) { - if (i < 0 || i > 3) { - throw new CustomNPCsException(i + " isnt between 0 and 3", new Object[0]); - } else { - EnumAvailabilityQuest e = EnumAvailabilityQuest.values()[MathHelper.clamp_int(type, 0, 5)]; - if (i == 0) { - this.questId = id; - this.questAvailable = e; - } else if (i == 1) { - this.quest2Id = id; - this.quest2Available = e; - } else if (i == 2) { - this.quest3Id = id; - this.quest3Available = e; - } else if (i == 3) { - this.quest4Id = id; - this.quest4Available = e; - } + } + } - } - } + public int getQuest(int i) { + if (i < 0 || i > 3) { + throw new CustomNPCsException(i + " isnt between 0 and 3", new Object[0]); + } else if (i == 0) { + return this.questId; + } else if (i == 1) { + return this.quest2Id; + } else { + return i == 2 ? this.quest3Id : this.quest4Id; + } + } - public void removeQuest(int i) { - if (i < 0 || i > 3) { - throw new CustomNPCsException(i + " isnt between 0 and 3", new Object[0]); - } else { - if (i == 0) { - this.questId = -1; - this.questAvailable = EnumAvailabilityQuest.Always; - } else if (i == 1) { - this.quest2Id = -1; - this.quest2Available = EnumAvailabilityQuest.Always; - } else if (i == 2) { - this.quest3Id = -1; - this.quest3Available = EnumAvailabilityQuest.Always; - } else if (i == 3) { - this.quest4Id = -1; - this.quest4Available = EnumAvailabilityQuest.Always; - } + public void setQuest(int i, int id, int type) { + if (i < 0 || i > 3) { + throw new CustomNPCsException(i + " isnt between 0 and 3", new Object[0]); + } else { + EnumAvailabilityQuest e = EnumAvailabilityQuest.values()[MathHelper.clamp_int(type, 0, 5)]; + if (i == 0) { + this.questId = id; + this.questAvailable = e; + } else if (i == 1) { + this.quest2Id = id; + this.quest2Available = e; + } else if (i == 2) { + this.quest3Id = id; + this.quest3Available = e; + } else if (i == 3) { + this.quest4Id = id; + this.quest4Available = e; + } - } - } + } + } - public void setFaction(int i, int id, int type, int stance) { - if (i < 0 || i > 1) { - throw new CustomNPCsException(i + " isnt between 0 and 1", new Object[0]); - } else { - EnumAvailabilityFactionType e = EnumAvailabilityFactionType.values()[MathHelper.clamp_int(type, 0, 2)]; - EnumAvailabilityFaction ee = EnumAvailabilityFaction.values()[MathHelper.clamp_int(stance, 0, 2)]; - if (i == 0) { - this.factionId = id; - this.factionAvailable = e; - this.factionStance = ee; - } else if (i == 1) { - this.faction2Id = id; - this.faction2Available = e; - this.faction2Stance = ee; - } + public void removeQuest(int i) { + if (i < 0 || i > 3) { + throw new CustomNPCsException(i + " isnt between 0 and 3", new Object[0]); + } else { + if (i == 0) { + this.questId = -1; + this.questAvailable = EnumAvailabilityQuest.Always; + } else if (i == 1) { + this.quest2Id = -1; + this.quest2Available = EnumAvailabilityQuest.Always; + } else if (i == 2) { + this.quest3Id = -1; + this.quest3Available = EnumAvailabilityQuest.Always; + } else if (i == 3) { + this.quest4Id = -1; + this.quest4Available = EnumAvailabilityQuest.Always; + } - } - } + } + } - public void removeFaction(int i) { - if (i < 0 || i > 1) { - throw new CustomNPCsException(i + " isnt between 0 and 1", new Object[0]); - } else { - if (i == 0) { - this.factionId = -1; - this.factionAvailable = EnumAvailabilityFactionType.Always; - this.factionStance = EnumAvailabilityFaction.Friendly; - } else if (i == 1) { - this.faction2Id = -1; - this.faction2Available = EnumAvailabilityFactionType.Always; - this.faction2Stance = EnumAvailabilityFaction.Friendly; - } + public void setFaction(int i, int id, int type, int stance) { + if (i < 0 || i > 1) { + throw new CustomNPCsException(i + " isnt between 0 and 1", new Object[0]); + } else { + EnumAvailabilityFactionType e = EnumAvailabilityFactionType.values()[MathHelper.clamp_int(type, 0, 2)]; + EnumAvailabilityFaction ee = EnumAvailabilityFaction.values()[MathHelper.clamp_int(stance, 0, 2)]; + if (i == 0) { + this.factionId = id; + this.factionAvailable = e; + this.factionStance = ee; + } else if (i == 1) { + this.faction2Id = id; + this.faction2Available = e; + this.faction2Stance = ee; + } - } - } + } + } + + public void removeFaction(int i) { + if (i < 0 || i > 1) { + throw new CustomNPCsException(i + " isnt between 0 and 1", new Object[0]); + } else { + if (i == 0) { + this.factionId = -1; + this.factionAvailable = EnumAvailabilityFactionType.Always; + this.factionStance = EnumAvailabilityFaction.Friendly; + } else if (i == 1) { + this.faction2Id = -1; + this.faction2Available = EnumAvailabilityFactionType.Always; + this.faction2Stance = EnumAvailabilityFaction.Friendly; + } + + } + } } diff --git a/src/main/java/noppes/npcs/controllers/data/Bank.java b/src/main/java/noppes/npcs/controllers/data/Bank.java index fd0d4a906..957223da7 100644 --- a/src/main/java/noppes/npcs/controllers/data/Bank.java +++ b/src/main/java/noppes/npcs/controllers/data/Bank.java @@ -8,56 +8,57 @@ import java.util.HashMap; public class Bank { - public int id = -1; - public String name = ""; - public HashMap slotTypes; - public int startSlots = 1; - public int maxSlots = 6; - public NpcMiscInventory currencyInventory; - public NpcMiscInventory upgradeInventory; - public Bank(){ - slotTypes = new HashMap(); - currencyInventory = new NpcMiscInventory(6); - upgradeInventory = new NpcMiscInventory(6); - for(int i = 0; i < 6; i++) - slotTypes.put(i, 0); - } - - public void writeEntityToNBT(NBTTagCompound nbttagcompound) { - nbttagcompound.setInteger("BankID", id); - nbttagcompound.setTag("BankCurrency", currencyInventory.getToNBT()); - nbttagcompound.setTag("BankUpgrade", upgradeInventory.getToNBT()); - nbttagcompound.setString("Username", name); - nbttagcompound.setInteger("MaxSlots", maxSlots); - nbttagcompound.setInteger("StartSlots", startSlots); - nbttagcompound.setTag("BankTypes", NBTTags.nbtIntegerIntegerMap(slotTypes)); - } + public int id = -1; + public String name = ""; + public HashMap slotTypes; + public int startSlots = 1; + public int maxSlots = 6; + public NpcMiscInventory currencyInventory; + public NpcMiscInventory upgradeInventory; - public void readEntityFromNBT(NBTTagCompound nbttagcompound) { - id = nbttagcompound.getInteger("BankID"); + public Bank() { + slotTypes = new HashMap(); + currencyInventory = new NpcMiscInventory(6); + upgradeInventory = new NpcMiscInventory(6); + for (int i = 0; i < 6; i++) + slotTypes.put(i, 0); + } + + public void writeEntityToNBT(NBTTagCompound nbttagcompound) { + nbttagcompound.setInteger("BankID", id); + nbttagcompound.setTag("BankCurrency", currencyInventory.getToNBT()); + nbttagcompound.setTag("BankUpgrade", upgradeInventory.getToNBT()); + nbttagcompound.setString("Username", name); + nbttagcompound.setInteger("MaxSlots", maxSlots); + nbttagcompound.setInteger("StartSlots", startSlots); + nbttagcompound.setTag("BankTypes", NBTTags.nbtIntegerIntegerMap(slotTypes)); + } + + public void readEntityFromNBT(NBTTagCompound nbttagcompound) { + id = nbttagcompound.getInteger("BankID"); name = nbttagcompound.getString("Username"); startSlots = nbttagcompound.getInteger("StartSlots"); maxSlots = nbttagcompound.getInteger("MaxSlots"); slotTypes = NBTTags.getIntegerIntegerMap(nbttagcompound.getTagList("BankTypes", 10)); - currencyInventory.setFromNBT(nbttagcompound.getCompoundTag("BankCurrency")); - upgradeInventory.setFromNBT(nbttagcompound.getCompoundTag("BankUpgrade")); - } - - public boolean isUpgraded(int slot){ - return slotTypes.get(slot) != null && slotTypes.get(slot) == 2; - } + currencyInventory.setFromNBT(nbttagcompound.getCompoundTag("BankCurrency")); + upgradeInventory.setFromNBT(nbttagcompound.getCompoundTag("BankUpgrade")); + } - public boolean canBeUpgraded(int slot) { - if(upgradeInventory.getStackInSlot(slot) == null) - return false; - return slotTypes.get(slot) == null || slotTypes.get(slot) == 0; - } + public boolean isUpgraded(int slot) { + return slotTypes.get(slot) != null && slotTypes.get(slot) == 2; + } - public int getMaxSlots() { - for(int i = 0; i < maxSlots; i++){ - if(currencyInventory.getStackInSlot(i) == null && i > startSlots-1) - return i; - } - return maxSlots; - } + public boolean canBeUpgraded(int slot) { + if (upgradeInventory.getStackInSlot(slot) == null) + return false; + return slotTypes.get(slot) == null || slotTypes.get(slot) == 0; + } + + public int getMaxSlots() { + for (int i = 0; i < maxSlots; i++) { + if (currencyInventory.getStackInSlot(i) == null && i > startSlots - 1) + return i; + } + return maxSlots; + } } diff --git a/src/main/java/noppes/npcs/controllers/data/BankData.java b/src/main/java/noppes/npcs/controllers/data/BankData.java index d08001f18..585a85a70 100644 --- a/src/main/java/noppes/npcs/controllers/data/BankData.java +++ b/src/main/java/noppes/npcs/controllers/data/BankData.java @@ -18,103 +18,105 @@ import noppes.npcs.entity.EntityNPCInterface; import java.util.HashMap; public class BankData { - public HashMap itemSlots; - public HashMap upgradedSlots; - public int unlockedSlots = 0; - public int bankId = -1; + public HashMap itemSlots; + public HashMap upgradedSlots; + public int unlockedSlots = 0; + public int bankId = -1; - public BankData(){ - itemSlots = new HashMap(); - upgradedSlots = new HashMap(); + public BankData() { + itemSlots = new HashMap(); + upgradedSlots = new HashMap(); - for(int i = 0; i < 6; i++){ - itemSlots.put(i, new NpcMiscInventory(54)); - upgradedSlots.put(i, false); - } - } - public void readNBT(NBTTagCompound nbttagcompound) { - bankId = nbttagcompound.getInteger("DataBankId"); + for (int i = 0; i < 6; i++) { + itemSlots.put(i, new NpcMiscInventory(54)); + upgradedSlots.put(i, false); + } + } + + public void readNBT(NBTTagCompound nbttagcompound) { + bankId = nbttagcompound.getInteger("DataBankId"); unlockedSlots = nbttagcompound.getInteger("UnlockedSlots"); itemSlots = getItemSlots(nbttagcompound.getTagList("BankInv", 10)); upgradedSlots = NBTTags.getBooleanList(nbttagcompound.getTagList("UpdatedSlots", 10)); - } - private HashMap getItemSlots(NBTTagList tagList) { - HashMap list = new HashMap(); - for(int i = 0; i < tagList.tagCount(); i++) - { + } + + private HashMap getItemSlots(NBTTagList tagList) { + HashMap list = new HashMap(); + for (int i = 0; i < tagList.tagCount(); i++) { NBTTagCompound nbttagcompound = tagList.getCompoundTagAt(i); int slot = nbttagcompound.getInteger("Slot"); NpcMiscInventory inv = new NpcMiscInventory(54); inv.setFromNBT(nbttagcompound.getCompoundTag("BankItems")); list.put(slot, inv); } - return list; - } - public void writeNBT(NBTTagCompound nbttagcompound) { - nbttagcompound.setInteger("DataBankId", bankId); - nbttagcompound.setInteger("UnlockedSlots", unlockedSlots); - nbttagcompound.setTag("UpdatedSlots", NBTTags.nbtBooleanList(upgradedSlots)); - nbttagcompound.setTag("BankInv", nbtItemSlots(itemSlots)); - } - private NBTTagList nbtItemSlots(HashMap items) { - NBTTagList list = new NBTTagList(); - for(int slot: items.keySet()){ - NBTTagCompound nbttagcompound = new NBTTagCompound(); - nbttagcompound.setInteger("Slot", slot); + return list; + } - nbttagcompound.setTag("BankItems",items.get(slot).getToNBT()); - list.appendTag(nbttagcompound); - } - return list; - } - public boolean isUpgraded(Bank bank, int slot) { - if(bank.isUpgraded(slot)) - return true; - return bank.canBeUpgraded(slot) && upgradedSlots.get(slot); - } + public void writeNBT(NBTTagCompound nbttagcompound) { + nbttagcompound.setInteger("DataBankId", bankId); + nbttagcompound.setInteger("UnlockedSlots", unlockedSlots); + nbttagcompound.setTag("UpdatedSlots", NBTTags.nbtBooleanList(upgradedSlots)); + nbttagcompound.setTag("BankInv", nbtItemSlots(itemSlots)); + } - public void openBankGui(final EntityPlayer player, EntityNPCInterface npc, int bankId, int slot) { - final Bank bank = BankController.getInstance().getBank(bankId); + private NBTTagList nbtItemSlots(HashMap items) { + NBTTagList list = new NBTTagList(); + for (int slot : items.keySet()) { + NBTTagCompound nbttagcompound = new NBTTagCompound(); + nbttagcompound.setInteger("Slot", slot); - if(bank.getMaxSlots() <= slot) - return; + nbttagcompound.setTag("BankItems", items.get(slot).getToNBT()); + list.appendTag(nbttagcompound); + } + return list; + } - if(bank.startSlots > unlockedSlots) - unlockedSlots = bank.startSlots; + public boolean isUpgraded(Bank bank, int slot) { + if (bank.isUpgraded(slot)) + return true; + return bank.canBeUpgraded(slot) && upgradedSlots.get(slot); + } - ItemStack currency = null; - if(unlockedSlots <= slot){ - currency = bank.currencyInventory.getStackInSlot(slot); - NoppesUtilServer.sendOpenGui(player, EnumGuiType.PlayerBankUnlock, npc, slot, bank.id, 0); - } - else if(isUpgraded(bank,slot)){ - NoppesUtilServer.sendOpenGui(player, EnumGuiType.PlayerBankLarge, npc, slot, bank.id, 0); - } - else if(bank.canBeUpgraded(slot)){ - currency = bank.upgradeInventory.getStackInSlot(slot); - NoppesUtilServer.sendOpenGui(player, EnumGuiType.PlayerBankUprade, npc, slot, bank.id, 0); - } - else{ - NoppesUtilServer.sendOpenGui(player, EnumGuiType.PlayerBankSmall, npc, slot, bank.id, 0); - } - final ItemStack item = currency; - NBTTagCompound compound = new NBTTagCompound(); - compound.setInteger("MaxSlots", bank.getMaxSlots()); - compound.setInteger("UnlockedSlots", unlockedSlots); - if (item != null) { - compound.setTag("Currency", NoppesUtilServer.writeItem(item, new NBTTagCompound())); - ContainerNPCBankInterface container = getContainer(player); - if (container != null) - container.setCurrency(item); - } + public void openBankGui(final EntityPlayer player, EntityNPCInterface npc, int bankId, int slot) { + final Bank bank = BankController.getInstance().getBank(bankId); + + if (bank.getMaxSlots() <= slot) + return; + + if (bank.startSlots > unlockedSlots) + unlockedSlots = bank.startSlots; + + ItemStack currency = null; + if (unlockedSlots <= slot) { + currency = bank.currencyInventory.getStackInSlot(slot); + NoppesUtilServer.sendOpenGui(player, EnumGuiType.PlayerBankUnlock, npc, slot, bank.id, 0); + } else if (isUpgraded(bank, slot)) { + NoppesUtilServer.sendOpenGui(player, EnumGuiType.PlayerBankLarge, npc, slot, bank.id, 0); + } else if (bank.canBeUpgraded(slot)) { + currency = bank.upgradeInventory.getStackInSlot(slot); + NoppesUtilServer.sendOpenGui(player, EnumGuiType.PlayerBankUprade, npc, slot, bank.id, 0); + } else { + NoppesUtilServer.sendOpenGui(player, EnumGuiType.PlayerBankSmall, npc, slot, bank.id, 0); + } + final ItemStack item = currency; + NBTTagCompound compound = new NBTTagCompound(); + compound.setInteger("MaxSlots", bank.getMaxSlots()); + compound.setInteger("UnlockedSlots", unlockedSlots); + if (item != null) { + compound.setTag("Currency", NoppesUtilServer.writeItem(item, new NBTTagCompound())); + ContainerNPCBankInterface container = getContainer(player); + if (container != null) + container.setCurrency(item); + } GuiDataPacket.sendGuiData((EntityPlayerMP) player, compound); - } - private ContainerNPCBankInterface getContainer(EntityPlayer player){ - Container con = player.openContainer; - if(con == null || !(con instanceof ContainerNPCBankInterface)) - return null; + } - return (ContainerNPCBankInterface) con; - } + private ContainerNPCBankInterface getContainer(EntityPlayer player) { + Container con = player.openContainer; + if (con == null || !(con instanceof ContainerNPCBankInterface)) + return null; + + return (ContainerNPCBankInterface) con; + } } diff --git a/src/main/java/noppes/npcs/controllers/data/CustomEffect.java b/src/main/java/noppes/npcs/controllers/data/CustomEffect.java index 75591a8c5..6c9eb45e8 100644 --- a/src/main/java/noppes/npcs/controllers/data/CustomEffect.java +++ b/src/main/java/noppes/npcs/controllers/data/CustomEffect.java @@ -35,7 +35,8 @@ public class CustomEffect implements ICustomEffect { public int index = 0; - public CustomEffect() {} + public CustomEffect() { + } public CustomEffect(int id) { this.id = id; @@ -298,6 +299,7 @@ public class CustomEffect implements ICustomEffect { public EffectScript getScriptHandler() { return CustomEffectController.getInstance().customEffectScriptHandlers.get(this.id); } + public void setScriptHandler(EffectScript handler) { CustomEffectController.getInstance().customEffectScriptHandlers.put(this.id, handler); } @@ -305,7 +307,7 @@ public class CustomEffect implements ICustomEffect { public EffectScript getOrCreateScriptHandler() { EffectScript data = getScriptHandler(); if (data == null) - setScriptHandler(data =new EffectScript()); + setScriptHandler(data = new EffectScript()); return data; } diff --git a/src/main/java/noppes/npcs/controllers/data/DataScript.java b/src/main/java/noppes/npcs/controllers/data/DataScript.java index d1530f63d..f27b83990 100644 --- a/src/main/java/noppes/npcs/controllers/data/DataScript.java +++ b/src/main/java/noppes/npcs/controllers/data/DataScript.java @@ -30,279 +30,280 @@ import javax.script.ScriptEngine; import java.util.*; public class DataScript implements INpcScriptHandler { - public List eventScripts = new ArrayList<>(); + public List eventScripts = new ArrayList<>(); - private HashMap scripts = new HashMap<>(); - private final static EntityType entities = new EntityType(); - private final static JobType jobs = new JobType(); - private final static RoleType roles = new RoleType(); + private HashMap scripts = new HashMap<>(); + private final static EntityType entities = new EntityType(); + private final static JobType jobs = new JobType(); + private final static RoleType roles = new RoleType(); - public String scriptLanguage = "ECMAScript"; - private EntityNPCInterface npc; - public boolean enabled = false; + public String scriptLanguage = "ECMAScript"; + private EntityNPCInterface npc; + public boolean enabled = false; - public ICustomNpc dummyNpc; - public IWorld dummyWorld; - public boolean clientNeedsUpdate = false; - public boolean aiNeedsUpdate = false; - public boolean hasInited = false; + public ICustomNpc dummyNpc; + public IWorld dummyWorld; + public boolean clientNeedsUpdate = false; + public boolean aiNeedsUpdate = false; + public boolean hasInited = false; - public DataScript(EntityNPCInterface npc) { - for (int i = 0; i < 15; i++) { - this.setNPCScript(i, new ScriptContainer(this)); - } + public DataScript(EntityNPCInterface npc) { + for (int i = 0; i < 15; i++) { + this.setNPCScript(i, new ScriptContainer(this)); + } - this.npc = npc; - if (npc.wrappedNPC == null) { - npc.wrappedNPC = new ScriptNpc(this.npc); - } - dummyNpc = npc.wrappedNPC; + this.npc = npc; + if (npc.wrappedNPC == null) { + npc.wrappedNPC = new ScriptNpc(this.npc); + } + dummyNpc = npc.wrappedNPC; - if(npc.worldObj instanceof WorldServer) - dummyWorld = NpcAPI.Instance().getIWorld((WorldServer) npc.worldObj);//new ScriptWorld((WorldServer) npc.worldObj); - } + if (npc.worldObj instanceof WorldServer) + dummyWorld = NpcAPI.Instance().getIWorld((WorldServer) npc.worldObj);//new ScriptWorld((WorldServer) npc.worldObj); + } - public void readFromNBT(NBTTagCompound compound) { - scripts = readScript(compound.getTagList("ScriptsContainers", 10)); - this.scriptLanguage = compound.getString("ScriptLanguage"); - if (!ScriptController.Instance.languages.containsKey(scriptLanguage)) { - if (!ScriptController.Instance.languages.isEmpty()) { - this.scriptLanguage = (String) ScriptController.Instance.languages.keySet().toArray()[0]; - } else { - this.scriptLanguage = "ECMAScript"; - } - } + public void readFromNBT(NBTTagCompound compound) { + scripts = readScript(compound.getTagList("ScriptsContainers", 10)); + this.scriptLanguage = compound.getString("ScriptLanguage"); + if (!ScriptController.Instance.languages.containsKey(scriptLanguage)) { + if (!ScriptController.Instance.languages.isEmpty()) { + this.scriptLanguage = (String) ScriptController.Instance.languages.keySet().toArray()[0]; + } else { + this.scriptLanguage = "ECMAScript"; + } + } - enabled = compound.getBoolean("ScriptEnabled"); - } + enabled = compound.getBoolean("ScriptEnabled"); + } - public void readEventsFromNBT(NBTTagCompound compound) { - eventScripts = NBTTags.GetScript(compound,this); - } + public void readEventsFromNBT(NBTTagCompound compound) { + eventScripts = NBTTags.GetScript(compound, this); + } - public NBTTagCompound writeToNBT(NBTTagCompound compound) { - compound.setTag("ScriptsContainers", writeScript(scripts)); - compound.setString("ScriptLanguage", scriptLanguage); - compound.setBoolean("ScriptEnabled", enabled); - return compound; - } + public NBTTagCompound writeToNBT(NBTTagCompound compound) { + compound.setTag("ScriptsContainers", writeScript(scripts)); + compound.setString("ScriptLanguage", scriptLanguage); + compound.setBoolean("ScriptEnabled", enabled); + return compound; + } - public NBTTagCompound writeEventsToNBT(NBTTagCompound compound) { - compound.setInteger("TotalScripts",this.eventScripts.size()); - for (int i = 0; i < this.eventScripts.size(); i++) { - compound.setTag("Tab"+i,this.eventScripts.get(i).writeToNBT(new NBTTagCompound())); - } - return compound; - } + public NBTTagCompound writeEventsToNBT(NBTTagCompound compound) { + compound.setInteger("TotalScripts", this.eventScripts.size()); + for (int i = 0; i < this.eventScripts.size(); i++) { + compound.setTag("Tab" + i, this.eventScripts.get(i).writeToNBT(new NBTTagCompound())); + } + return compound; + } - private HashMap readScript(NBTTagList list){ - HashMap scripts = new HashMap<>(); - for (int i = 0; i < 15; i++) { - scripts.put(EnumScriptType.values()[i], new ScriptContainer(this)); - } + private HashMap readScript(NBTTagList list) { + HashMap scripts = new HashMap<>(); + for (int i = 0; i < 15; i++) { + scripts.put(EnumScriptType.values()[i], new ScriptContainer(this)); + } - for(int i = 0; i < list.tagCount(); i++){ - NBTTagCompound compoundd = list.getCompoundTagAt(i); - ScriptContainer script = new ScriptContainer(this); - script.readFromNBT(compoundd); - if (script.hasCode() || npc.isRemote()) { - scripts.put(EnumScriptType.values()[compoundd.getInteger("Type")], script); - } - } - return scripts; - } + for (int i = 0; i < list.tagCount(); i++) { + NBTTagCompound compoundd = list.getCompoundTagAt(i); + ScriptContainer script = new ScriptContainer(this); + script.readFromNBT(compoundd); + if (script.hasCode() || npc.isRemote()) { + scripts.put(EnumScriptType.values()[compoundd.getInteger("Type")], script); + } + } + return scripts; + } - private NBTTagList writeScript(HashMap scripts){ - NBTTagList list = new NBTTagList(); - for (Map.Entry entry : scripts.entrySet()) { - NBTTagCompound tagCompound = new NBTTagCompound(); - ScriptContainer container = entry.getValue(); - if (container.hasCode()) { - tagCompound.setInteger("Type", entry.getKey().ordinal()); - container.writeToNBT(tagCompound); - list.appendTag(tagCompound); - } - } - return list; - } + private NBTTagList writeScript(HashMap scripts) { + NBTTagList list = new NBTTagList(); + for (Map.Entry entry : scripts.entrySet()) { + NBTTagCompound tagCompound = new NBTTagCompound(); + ScriptContainer container = entry.getValue(); + if (container.hasCode()) { + tagCompound.setInteger("Type", entry.getKey().ordinal()); + container.writeToNBT(tagCompound); + list.appendTag(tagCompound); + } + } + return list; + } - public boolean callScript(EnumScriptType type, Event event, Object... obs){ - if(aiNeedsUpdate){ - npc.updateAI = true; - aiNeedsUpdate = false; - } - if(clientNeedsUpdate){ - npc.updateClient = true; - clientNeedsUpdate = false; - } - if(!isEnabled()) - return false; + public boolean callScript(EnumScriptType type, Event event, Object... obs) { + if (aiNeedsUpdate) { + npc.updateAI = true; + aiNeedsUpdate = false; + } + if (clientNeedsUpdate) { + npc.updateClient = true; + clientNeedsUpdate = false; + } + if (!isEnabled()) + return false; - if(!hasInited && !npc.isRemote() && type != EnumScriptType.INIT){ - hasInited = true; - for (ScriptContainer scriptContainer : this.eventScripts) { - scriptContainer.errored = false; - } - EventHooks.onNPCInit(this.npc); - } + if (!hasInited && !npc.isRemote() && type != EnumScriptType.INIT) { + hasInited = true; + for (ScriptContainer scriptContainer : this.eventScripts) { + scriptContainer.errored = false; + } + EventHooks.onNPCInit(this.npc); + } - for (ScriptContainer script : this.eventScripts) { - script.run(type, event); - } + for (ScriptContainer script : this.eventScripts) { + script.run(type, event); + } - ScriptContainer script = scripts.get(type); - if(script == null || script.errored || !script.hasCode()) - return false; + ScriptContainer script = scripts.get(type); + if (script == null || script.errored || !script.hasCode()) + return false; - script.setEngine(this.getLanguage()); - if(script.engine == null) - return false; + script.setEngine(this.getLanguage()); + if (script.engine == null) + return false; - for(int i = 0; i + 1 < obs.length; i += 2){ - Object ob = obs[i + 1]; - if(ob instanceof Entity) - ob = NpcAPI.Instance().getIEntity((Entity)ob); - script.engine.put(obs[i].toString(), ob); - } - if(ConfigDebug.ScriptLogging && FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER){ - if(obs.length > 1 && obs[1] == null){ - LogWriter.postScriptLog(npc.field_110179_h, type, String.format("[%s] NPC %s (%s, %s, %s)", ((String)type.function).toUpperCase(), npc.display.name, (int)npc.posX, (int)npc.posY, (int)npc.posZ)); - } else { - LogWriter.postScriptLog(npc.field_110179_h, type, String.format("[%s] NPC %s (%s, %s, %s) | Objects: %s", ((String)type.function).toUpperCase(), npc.display.name, (int)npc.posX, (int)npc.posY, (int)npc.posZ, Arrays.toString(obs))); - } - } - return callScript(script, event); - } + for (int i = 0; i + 1 < obs.length; i += 2) { + Object ob = obs[i + 1]; + if (ob instanceof Entity) + ob = NpcAPI.Instance().getIEntity((Entity) ob); + script.engine.put(obs[i].toString(), ob); + } + if (ConfigDebug.ScriptLogging && FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER) { + if (obs.length > 1 && obs[1] == null) { + LogWriter.postScriptLog(npc.field_110179_h, type, String.format("[%s] NPC %s (%s, %s, %s)", ((String) type.function).toUpperCase(), npc.display.name, (int) npc.posX, (int) npc.posY, (int) npc.posZ)); + } else { + LogWriter.postScriptLog(npc.field_110179_h, type, String.format("[%s] NPC %s (%s, %s, %s) | Objects: %s", ((String) type.function).toUpperCase(), npc.display.name, (int) npc.posX, (int) npc.posY, (int) npc.posZ, Arrays.toString(obs))); + } + } + return callScript(script, event); + } - private boolean callScript(ScriptContainer script, Event event){ - ScriptEngine engine = script.engine; - engine.put("npc", dummyNpc); - engine.put("world", dummyWorld); - engine.put("event", event); - engine.put("API", NpcAPI.Instance()); - engine.put("EntityType", entities); - engine.put("RoleType", roles); - engine.put("JobType", jobs); - for (Map.Entry engineObjects : NpcAPI.engineObjects.entrySet()) { - engine.put(engineObjects.getKey(),engineObjects.getValue()); - } - script.run(engine); + private boolean callScript(ScriptContainer script, Event event) { + ScriptEngine engine = script.engine; + engine.put("npc", dummyNpc); + engine.put("world", dummyWorld); + engine.put("event", event); + engine.put("API", NpcAPI.Instance()); + engine.put("EntityType", entities); + engine.put("RoleType", roles); + engine.put("JobType", jobs); + for (Map.Entry engineObjects : NpcAPI.engineObjects.entrySet()) { + engine.put(engineObjects.getKey(), engineObjects.getValue()); + } + script.run(engine); - if(clientNeedsUpdate){ - npc.updateClient = true; - clientNeedsUpdate = false; - } - if(aiNeedsUpdate){ - npc.updateAI = true; - aiNeedsUpdate = false; - } - return event.isCanceled(); - } + if (clientNeedsUpdate) { + npc.updateClient = true; + clientNeedsUpdate = false; + } + if (aiNeedsUpdate) { + npc.updateAI = true; + aiNeedsUpdate = false; + } + return event.isCanceled(); + } - public boolean isEnabled(){ - return enabled && ScriptController.HasStart && !npc.worldObj.isRemote && !scripts.isEmpty() && ConfigScript.ScriptingEnabled; - } + public boolean isEnabled() { + return enabled && ScriptController.HasStart && !npc.worldObj.isRemote && !scripts.isEmpty() && ConfigScript.ScriptingEnabled; + } - public Map getOldConsoleText() { - Map map = new TreeMap<>(); + public Map getOldConsoleText() { + Map map = new TreeMap<>(); - for (Map.Entry entry : scripts.entrySet()) { - for (Map.Entry consoleEntry : entry.getValue().console.entrySet()) { - map.put(consoleEntry.getKey(), " tab " + entry.getKey().ordinal() + ":\n" + consoleEntry.getValue()); - } - } + for (Map.Entry entry : scripts.entrySet()) { + for (Map.Entry consoleEntry : entry.getValue().console.entrySet()) { + map.put(consoleEntry.getKey(), " tab " + entry.getKey().ordinal() + ":\n" + consoleEntry.getValue()); + } + } - return map; - } + return map; + } - public Map getConsoleText() { - TreeMap map = new TreeMap<>(); - int tab = 0; - for (ScriptContainer script : this.getScripts()) { - ++tab; + public Map getConsoleText() { + TreeMap map = new TreeMap<>(); + int tab = 0; + for (ScriptContainer script : this.getScripts()) { + ++tab; - for (Map.Entry longStringEntry : script.console.entrySet()) { - map.put(longStringEntry.getKey(), " tab " + tab + ":\n" + longStringEntry.getValue()); - } - } - return map; - } + for (Map.Entry longStringEntry : script.console.entrySet()) { + map.put(longStringEntry.getKey(), " tab " + tab + ":\n" + longStringEntry.getValue()); + } + } + return map; + } - public void clearConsole() { - for (ScriptContainer script : this.getScripts()) { - script.console.clear(); - } - } + public void clearConsole() { + for (ScriptContainer script : this.getScripts()) { + script.console.clear(); + } + } - @Override - public void callScript(EnumScriptType type, Event event) { - callScript(type, event, "$$IGNORED$$", null); - } + @Override + public void callScript(EnumScriptType type, Event event) { + callScript(type, event, "$$IGNORED$$", null); + } - @Override - public void callScript(String hookName, Event event) { - try { - EnumScriptType enumScriptType = EnumScriptType.valueOf(hookName); - this.callScript(enumScriptType, event); - } catch (IllegalArgumentException ignored) {} - } + @Override + public void callScript(String hookName, Event event) { + try { + EnumScriptType enumScriptType = EnumScriptType.valueOf(hookName); + this.callScript(enumScriptType, event); + } catch (IllegalArgumentException ignored) { + } + } - public boolean isClient() { - return this.npc.isRemote(); - } + public boolean isClient() { + return this.npc.isRemote(); + } - public boolean getEnabled() { - return this.enabled; - } + public boolean getEnabled() { + return this.enabled; + } - public void setEnabled(boolean bo) { - this.enabled = bo; - } + public void setEnabled(boolean bo) { + this.enabled = bo; + } - public String getLanguage() { - return this.scriptLanguage; - } + public String getLanguage() { + return this.scriptLanguage; + } - public void setLanguage(String lang) { - this.scriptLanguage = lang; - } + public void setLanguage(String lang) { + this.scriptLanguage = lang; + } - public void setScripts(List list) { - this.eventScripts = list; - } + public void setScripts(List list) { + this.eventScripts = list; + } - public List getScripts() { - return this.eventScripts; - } + public List getScripts() { + return this.eventScripts; + } - public String noticeString() { - //BlockPos pos = this.npc.func_180425_c(); - //return MoreObjects.toStringHelper(this.npc).add("x", pos.func_177958_n()).add("y", pos.func_177956_o()).add("z", pos.func_177952_p()).toString(); - return ""; - } + public String noticeString() { + //BlockPos pos = this.npc.func_180425_c(); + //return MoreObjects.toStringHelper(this.npc).add("x", pos.func_177958_n()).add("y", pos.func_177956_o()).add("z", pos.func_177952_p()).toString(); + return ""; + } - public void setWorld(World world) { - if(world instanceof WorldServer) - dummyWorld = new ScriptWorld((WorldServer) world); - } + public void setWorld(World world) { + if (world instanceof WorldServer) + dummyWorld = new ScriptWorld((WorldServer) world); + } - public ScriptContainer getNPCScript(EnumScriptType scriptType) { - return this.scripts.get(scriptType); - } + public ScriptContainer getNPCScript(EnumScriptType scriptType) { + return this.scripts.get(scriptType); + } - public ScriptContainer getNPCScript(int ordinal) { - return this.getNPCScript(EnumScriptType.values()[ordinal]); - } + public ScriptContainer getNPCScript(int ordinal) { + return this.getNPCScript(EnumScriptType.values()[ordinal]); + } - public void setNPCScript(EnumScriptType scriptType, ScriptContainer container) { - this.scripts.put(scriptType, container); - } + public void setNPCScript(EnumScriptType scriptType, ScriptContainer container) { + this.scripts.put(scriptType, container); + } - public void setNPCScript(int ordinal, ScriptContainer container) { - this.setNPCScript(EnumScriptType.values()[ordinal], container); - } + public void setNPCScript(int ordinal, ScriptContainer container) { + this.setNPCScript(EnumScriptType.values()[ordinal], container); + } - public Collection getNPCScripts() { - return this.scripts.values(); - } + public Collection getNPCScripts() { + return this.scripts.values(); + } } diff --git a/src/main/java/noppes/npcs/controllers/data/DataTransform.java b/src/main/java/noppes/npcs/controllers/data/DataTransform.java index 37a0571f0..16b2cc766 100644 --- a/src/main/java/noppes/npcs/controllers/data/DataTransform.java +++ b/src/main/java/noppes/npcs/controllers/data/DataTransform.java @@ -11,229 +11,230 @@ import noppes.npcs.entity.EntityNPCInterface; import java.util.Set; public class DataTransform { - public NBTTagCompound display; - public NBTTagCompound ai; - public NBTTagCompound advanced; - public NBTTagCompound inv; - public NBTTagCompound stats; - public NBTTagCompound role; - public NBTTagCompound job; + public NBTTagCompound display; + public NBTTagCompound ai; + public NBTTagCompound advanced; + public NBTTagCompound inv; + public NBTTagCompound stats; + public NBTTagCompound role; + public NBTTagCompound job; - public boolean hasDisplay, hasAi, hasAdvanced, hasInv, hasStats, hasRole, hasJob, isActive; + public boolean hasDisplay, hasAi, hasAdvanced, hasInv, hasStats, hasRole, hasJob, isActive; - private EntityNPCInterface npc; + private EntityNPCInterface npc; - public boolean editingModus = false; + public boolean editingModus = false; - public DataTransform(EntityNPCInterface npc){ - this.npc = npc; - } + public DataTransform(EntityNPCInterface npc) { + this.npc = npc; + } public NBTTagCompound writeToNBT(NBTTagCompound compound) { - compound.setBoolean("TransformIsActive", isActive); - writeOptions(compound); - if(hasDisplay) - compound.setTag("TransformDisplay", display); - if(hasAi) - compound.setTag("TransformAI", ai); - if(hasAdvanced) - compound.setTag("TransformAdvanced", advanced); - if(hasInv) - compound.setTag("TransformInv", inv); - if(hasStats) - compound.setTag("TransformStats", stats); - if(hasRole) - compound.setTag("TransformRole", role); - if(hasJob) - compound.setTag("TransformJob", job); + compound.setBoolean("TransformIsActive", isActive); + writeOptions(compound); + if (hasDisplay) + compound.setTag("TransformDisplay", display); + if (hasAi) + compound.setTag("TransformAI", ai); + if (hasAdvanced) + compound.setTag("TransformAdvanced", advanced); + if (hasInv) + compound.setTag("TransformInv", inv); + if (hasStats) + compound.setTag("TransformStats", stats); + if (hasRole) + compound.setTag("TransformRole", role); + if (hasJob) + compound.setTag("TransformJob", job); - return compound; + return compound; } - public NBTTagCompound writeOptions(NBTTagCompound compound) { - compound.setBoolean("TransformHasDisplay", hasDisplay); - compound.setBoolean("TransformHasAI", hasAi); - compound.setBoolean("TransformHasAdvanced", hasAdvanced); - compound.setBoolean("TransformHasInv", hasInv); - compound.setBoolean("TransformHasStats", hasStats); - compound.setBoolean("TransformHasRole", hasRole); - compound.setBoolean("TransformHasJob", hasJob); - compound.setBoolean("TransformEditingModus", editingModus); - return compound; - } + public NBTTagCompound writeOptions(NBTTagCompound compound) { + compound.setBoolean("TransformHasDisplay", hasDisplay); + compound.setBoolean("TransformHasAI", hasAi); + compound.setBoolean("TransformHasAdvanced", hasAdvanced); + compound.setBoolean("TransformHasInv", hasInv); + compound.setBoolean("TransformHasStats", hasStats); + compound.setBoolean("TransformHasRole", hasRole); + compound.setBoolean("TransformHasJob", hasJob); + compound.setBoolean("TransformEditingModus", editingModus); + return compound; + } public void readToNBT(NBTTagCompound compound) { - isActive = compound.getBoolean("TransformIsActive"); - readOptions(compound); - display = hasDisplay?compound.getCompoundTag("TransformDisplay"): getDisplay(); - ai = hasAi?compound.getCompoundTag("TransformAI"): npc.ais.writeToNBT(new NBTTagCompound()); - advanced = hasAdvanced?compound.getCompoundTag("TransformAdvanced"): getAdvanced(); - inv = hasInv?compound.getCompoundTag("TransformInv"): npc.inventory.writeEntityToNBT(new NBTTagCompound()); - stats = hasStats?compound.getCompoundTag("TransformStats"): npc.stats.writeToNBT(new NBTTagCompound()); - job = hasJob?compound.getCompoundTag("TransformJob"): getJob(); - role = hasRole?compound.getCompoundTag("TransformRole"): getRole(); + isActive = compound.getBoolean("TransformIsActive"); + readOptions(compound); + display = hasDisplay ? compound.getCompoundTag("TransformDisplay") : getDisplay(); + ai = hasAi ? compound.getCompoundTag("TransformAI") : npc.ais.writeToNBT(new NBTTagCompound()); + advanced = hasAdvanced ? compound.getCompoundTag("TransformAdvanced") : getAdvanced(); + inv = hasInv ? compound.getCompoundTag("TransformInv") : npc.inventory.writeEntityToNBT(new NBTTagCompound()); + stats = hasStats ? compound.getCompoundTag("TransformStats") : npc.stats.writeToNBT(new NBTTagCompound()); + job = hasJob ? compound.getCompoundTag("TransformJob") : getJob(); + role = hasRole ? compound.getCompoundTag("TransformRole") : getRole(); } public NBTTagCompound getJob() { - NBTTagCompound compound = new NBTTagCompound(); + NBTTagCompound compound = new NBTTagCompound(); compound.setInteger("NpcJob", npc.advanced.job.ordinal()); if (npc.advanced.job != EnumJobType.None && npc.jobInterface != null) { npc.jobInterface.writeToNBT(compound); } - return compound; - } + return compound; + } + public NBTTagCompound getRole() { - NBTTagCompound compound = new NBTTagCompound(); + NBTTagCompound compound = new NBTTagCompound(); compound.setInteger("Role", npc.advanced.role.ordinal()); if (npc.advanced.role != EnumRoleType.None && npc.roleInterface != null) { npc.roleInterface.writeToNBT(compound); } - return compound; - } + return compound; + } public NBTTagCompound getDisplay() { - NBTTagCompound compound = npc.display.writeToNBT(new NBTTagCompound()); - if(npc instanceof EntityCustomNpc){ - compound.setTag("ModelData", ((EntityCustomNpc)npc).modelData.writeToNBT()); - } + NBTTagCompound compound = npc.display.writeToNBT(new NBTTagCompound()); + if (npc instanceof EntityCustomNpc) { + compound.setTag("ModelData", ((EntityCustomNpc) npc).modelData.writeToNBT()); + } - return compound; + return compound; } public NBTTagCompound getAdvanced() { - EnumJobType jopType = npc.advanced.job; - EnumRoleType roleType = npc.advanced.role; + EnumJobType jopType = npc.advanced.job; + EnumRoleType roleType = npc.advanced.role; - npc.advanced.job = EnumJobType.None; - npc.advanced.role = EnumRoleType.None; + npc.advanced.job = EnumJobType.None; + npc.advanced.role = EnumRoleType.None; - NBTTagCompound compound = npc.advanced.writeToNBT(new NBTTagCompound()); - compound.removeTag("Role"); - compound.removeTag("NpcJob"); + NBTTagCompound compound = npc.advanced.writeToNBT(new NBTTagCompound()); + compound.removeTag("Role"); + compound.removeTag("NpcJob"); - npc.advanced.job = jopType; - npc.advanced.role = roleType; + npc.advanced.job = jopType; + npc.advanced.role = roleType; - return compound; - } - - - public void readOptions(NBTTagCompound compound){ - boolean hadDisplay = hasDisplay; - boolean hadAI = hasAi; - boolean hadAdvanced = hasAdvanced; - boolean hadInv = hasInv; - boolean hadStats = hasStats; - boolean hadRole = hasRole; - boolean hadJob = hasJob; - - hasDisplay = compound.getBoolean("TransformHasDisplay"); - hasAi = compound.getBoolean("TransformHasAI"); - hasAdvanced = compound.getBoolean("TransformHasAdvanced"); - hasInv = compound.getBoolean("TransformHasInv"); - hasStats = compound.getBoolean("TransformHasStats"); - hasRole = compound.getBoolean("TransformHasRole"); - hasJob = compound.getBoolean("TransformHasJob"); - editingModus = compound.getBoolean("TransformEditingModus"); - - if(hasDisplay && !hadDisplay){ - display = getDisplay(); - } - if(hasAi && !hadAI) - ai = npc.ais.writeToNBT(new NBTTagCompound()); - if(hasStats && !hadStats) - stats = npc.stats.writeToNBT(new NBTTagCompound()); - if(hasInv && !hadInv) - inv = npc.inventory.writeEntityToNBT(new NBTTagCompound()); - if(hasAdvanced && !hadAdvanced) - advanced = getAdvanced(); - if(hasJob && !hadJob) - job = getJob(); - if(hasRole && !hadRole) - role = getRole(); - } - - public boolean isValid(){ - return hasAdvanced || hasAi || hasDisplay || hasInv || hasStats || hasJob || hasRole; + return compound; } - public NBTTagCompound processAdvanced(NBTTagCompound compoundAdv, - NBTTagCompound compoundRole, NBTTagCompound compoundJob) { + public void readOptions(NBTTagCompound compound) { + boolean hadDisplay = hasDisplay; + boolean hadAI = hasAi; + boolean hadAdvanced = hasAdvanced; + boolean hadInv = hasInv; + boolean hadStats = hasStats; + boolean hadRole = hasRole; + boolean hadJob = hasJob; - if(hasAdvanced) - compoundAdv = advanced; - if(hasRole) - compoundRole = role; - if(hasJob) - compoundJob = job; + hasDisplay = compound.getBoolean("TransformHasDisplay"); + hasAi = compound.getBoolean("TransformHasAI"); + hasAdvanced = compound.getBoolean("TransformHasAdvanced"); + hasInv = compound.getBoolean("TransformHasInv"); + hasStats = compound.getBoolean("TransformHasStats"); + hasRole = compound.getBoolean("TransformHasRole"); + hasJob = compound.getBoolean("TransformHasJob"); + editingModus = compound.getBoolean("TransformEditingModus"); - Set names = compoundRole.func_150296_c(); - for(String name : names) - compoundAdv.setTag(name, compoundRole.getTag(name)); + if (hasDisplay && !hadDisplay) { + display = getDisplay(); + } + if (hasAi && !hadAI) + ai = npc.ais.writeToNBT(new NBTTagCompound()); + if (hasStats && !hadStats) + stats = npc.stats.writeToNBT(new NBTTagCompound()); + if (hasInv && !hadInv) + inv = npc.inventory.writeEntityToNBT(new NBTTagCompound()); + if (hasAdvanced && !hadAdvanced) + advanced = getAdvanced(); + if (hasJob && !hadJob) + job = getJob(); + if (hasRole && !hadRole) + role = getRole(); + } - names = compoundJob.func_150296_c(); - for(String name : names) - compoundAdv.setTag(name, compoundJob.getTag(name)); + public boolean isValid() { + return hasAdvanced || hasAi || hasDisplay || hasInv || hasStats || hasJob || hasRole; + } - return compoundAdv; - } - public void transform(boolean isActive){ - if(this.isActive == isActive) - return; - if(hasDisplay){ - NBTTagCompound compound = getDisplay(); - npc.display.readToNBT(NBTTags.NBTMerge(compound, display)); - if(npc instanceof EntityCustomNpc){ - ((EntityCustomNpc)npc).modelData.readFromNBT(NBTTags.NBTMerge(compound.getCompoundTag("ModelData"), display.getCompoundTag("ModelData"))); - } - display = compound; - } - if(hasStats){ - NBTTagCompound compound = npc.stats.writeToNBT(new NBTTagCompound()); - npc.stats.readToNBT(NBTTags.NBTMerge(compound, stats)); - stats = compound; - } - if(hasAdvanced || hasJob || hasRole){ - NBTTagCompound compoundAdv = getAdvanced(); - NBTTagCompound compoundRole = getRole(); - NBTTagCompound compoundJob = getJob(); + public NBTTagCompound processAdvanced(NBTTagCompound compoundAdv, + NBTTagCompound compoundRole, NBTTagCompound compoundJob) { - NBTTagCompound compound = processAdvanced(compoundAdv, compoundRole, compoundJob); - npc.advanced.readToNBT(compound); - if (npc.advanced.role != EnumRoleType.None && npc.roleInterface != null) - npc.roleInterface.readFromNBT(NBTTags.NBTMerge(compoundRole, compound)); - if (npc.advanced.job != EnumJobType.None && npc.jobInterface != null) - npc.jobInterface.readFromNBT(NBTTags.NBTMerge(compoundJob, compound)); + if (hasAdvanced) + compoundAdv = advanced; + if (hasRole) + compoundRole = role; + if (hasJob) + compoundJob = job; - if(hasAdvanced) - advanced = compoundAdv; - if(hasRole) - role = compoundRole; - if(hasJob) - job = compoundJob; - } - if(hasAi){ - NBTTagCompound compound = npc.ais.writeToNBT(new NBTTagCompound()); - npc.ais.readToNBT(NBTTags.NBTMerge(compound, ai)); - ai = compound; - npc.setCurrentAnimation(EnumAnimation.NONE); - } - if(hasInv){ - NBTTagCompound compound = npc.inventory.writeEntityToNBT(new NBTTagCompound()); - npc.inventory.readEntityFromNBT(NBTTags.NBTMerge(compound, inv)); - inv = compound; - } - npc.updateHitbox(); - npc.updateAI = true; - this.isActive = isActive; - npc.updateClient = true; - } + Set names = compoundRole.func_150296_c(); + for (String name : names) + compoundAdv.setTag(name, compoundRole.getTag(name)); + + names = compoundJob.func_150296_c(); + for (String name : names) + compoundAdv.setTag(name, compoundJob.getTag(name)); + + return compoundAdv; + } + + public void transform(boolean isActive) { + if (this.isActive == isActive) + return; + if (hasDisplay) { + NBTTagCompound compound = getDisplay(); + npc.display.readToNBT(NBTTags.NBTMerge(compound, display)); + if (npc instanceof EntityCustomNpc) { + ((EntityCustomNpc) npc).modelData.readFromNBT(NBTTags.NBTMerge(compound.getCompoundTag("ModelData"), display.getCompoundTag("ModelData"))); + } + display = compound; + } + if (hasStats) { + NBTTagCompound compound = npc.stats.writeToNBT(new NBTTagCompound()); + npc.stats.readToNBT(NBTTags.NBTMerge(compound, stats)); + stats = compound; + } + if (hasAdvanced || hasJob || hasRole) { + NBTTagCompound compoundAdv = getAdvanced(); + NBTTagCompound compoundRole = getRole(); + NBTTagCompound compoundJob = getJob(); + + NBTTagCompound compound = processAdvanced(compoundAdv, compoundRole, compoundJob); + npc.advanced.readToNBT(compound); + if (npc.advanced.role != EnumRoleType.None && npc.roleInterface != null) + npc.roleInterface.readFromNBT(NBTTags.NBTMerge(compoundRole, compound)); + if (npc.advanced.job != EnumJobType.None && npc.jobInterface != null) + npc.jobInterface.readFromNBT(NBTTags.NBTMerge(compoundJob, compound)); + + if (hasAdvanced) + advanced = compoundAdv; + if (hasRole) + role = compoundRole; + if (hasJob) + job = compoundJob; + } + if (hasAi) { + NBTTagCompound compound = npc.ais.writeToNBT(new NBTTagCompound()); + npc.ais.readToNBT(NBTTags.NBTMerge(compound, ai)); + ai = compound; + npc.setCurrentAnimation(EnumAnimation.NONE); + } + if (hasInv) { + NBTTagCompound compound = npc.inventory.writeEntityToNBT(new NBTTagCompound()); + npc.inventory.readEntityFromNBT(NBTTags.NBTMerge(compound, inv)); + inv = compound; + } + npc.updateHitbox(); + npc.updateAI = true; + this.isActive = isActive; + npc.updateClient = true; + } } diff --git a/src/main/java/noppes/npcs/controllers/data/Dialog.java b/src/main/java/noppes/npcs/controllers/data/Dialog.java index 763247ccb..ebb18c11c 100644 --- a/src/main/java/noppes/npcs/controllers/data/Dialog.java +++ b/src/main/java/noppes/npcs/controllers/data/Dialog.java @@ -17,549 +17,583 @@ import java.util.HashMap; import java.util.List; public class Dialog implements ICompatibilty, IDialog { - public int version = VersionCompatibility.ModRev; - public int id = -1; - public String title = ""; - public String text = ""; - public int quest = -1; - public DialogCategory category; - public HashMap options = new HashMap(); - public Availability availability = new Availability(); - public FactionOptions factionOptions = new FactionOptions(); - public String sound; - public String command = ""; - public PlayerMail mail = new PlayerMail(); + public int version = VersionCompatibility.ModRev; + public int id = -1; + public String title = ""; + public String text = ""; + public int quest = -1; + public DialogCategory category; + public HashMap options = new HashMap(); + public Availability availability = new Availability(); + public FactionOptions factionOptions = new FactionOptions(); + public String sound; + public String command = ""; + public PlayerMail mail = new PlayerMail(); - public int color = 0xe0e0e0; - public int titleColor = 0xe0e0e0; + public int color = 0xe0e0e0; + public int titleColor = 0xe0e0e0; - public boolean hideNPC = false; - public boolean showWheel = false; - public boolean disableEsc = false; - public boolean darkenScreen = true; - public boolean showOptionLine = true; + public boolean hideNPC = false; + public boolean showWheel = false; + public boolean disableEsc = false; + public boolean darkenScreen = true; + public boolean showOptionLine = true; - //0 - Bottom, 1 - Top, 2 - Center [Unimplemented] - public byte alignment = 0; + //0 - Bottom, 1 - Top, 2 - Center [Unimplemented] + public byte alignment = 0; - public boolean renderGradual = false; - public boolean showPreviousBlocks = true; + public boolean renderGradual = false; + public boolean showPreviousBlocks = true; - public String textSound = "minecraft:random.wood_click"; - public float textPitch = 1.0F; + public String textSound = "minecraft:random.wood_click"; + public float textPitch = 1.0F; - public int textWidth = 300; - public int textHeight = 400; + public int textWidth = 300; + public int textHeight = 400; - public int titlePos; - public int textOffsetX, textOffsetY; - public int titleOffsetX, titleOffsetY; + public int titlePos; + public int textOffsetX, textOffsetY; + public int titleOffsetX, titleOffsetY; - public int optionSpaceX, optionSpaceY; - public int optionOffsetX, optionOffsetY; + public int optionSpaceX, optionSpaceY; + public int optionOffsetX, optionOffsetY; - public float npcScale = 1.0F; - public int npcOffsetX, npcOffsetY; + public float npcScale = 1.0F; + public int npcOffsetX, npcOffsetY; - public HashMap dialogImages = new HashMap<>(); - - public boolean hasDialogs(EntityPlayer player) { - for(DialogOption option: options.values()) - if(option != null && option.optionType == EnumOptionType.DialogOption && option.hasDialog() && option.isAvailable(player)) - return true; - return false; - } + public HashMap dialogImages = new HashMap<>(); - public void readNBT(NBTTagCompound compound) { - id = compound.getInteger("DialogId"); - readNBTPartial(compound); - } - public void readNBTPartial(NBTTagCompound compound) { - version = compound.getInteger("ModRev"); - VersionCompatibility.CheckAvailabilityCompatibility(this, compound); - - title = compound.getString("DialogTitle"); - text = compound.getString("DialogText"); - quest = compound.getInteger("DialogQuest"); - sound = compound.getString("DialogSound"); - command = compound.getString("DialogCommand"); - mail.readNBT(compound.getCompoundTag("DialogMail")); + public boolean hasDialogs(EntityPlayer player) { + for (DialogOption option : options.values()) + if (option != null && option.optionType == EnumOptionType.DialogOption && option.hasDialog() && option.isAvailable(player)) + return true; + return false; + } - hideNPC = compound.getBoolean("DialogHideNPC"); - if(compound.hasKey("DialogShowWheel")) - showWheel = compound.getBoolean("DialogShowWheel"); - else - showWheel = true; - disableEsc = compound.getBoolean("DialogDisableEsc"); + public void readNBT(NBTTagCompound compound) { + id = compound.getInteger("DialogId"); + readNBTPartial(compound); + } - if(compound.hasKey("DialogDarkScreen")) { - darkenScreen = compound.getBoolean("DialogDarkScreen"); - } - else { - darkenScreen = true; - } + public void readNBTPartial(NBTTagCompound compound) { + version = compound.getInteger("ModRev"); + VersionCompatibility.CheckAvailabilityCompatibility(this, compound); - alignment = compound.getByte("DialogAlignment"); + title = compound.getString("DialogTitle"); + text = compound.getString("DialogText"); + quest = compound.getInteger("DialogQuest"); + sound = compound.getString("DialogSound"); + command = compound.getString("DialogCommand"); + mail.readNBT(compound.getCompoundTag("DialogMail")); + + hideNPC = compound.getBoolean("DialogHideNPC"); + if (compound.hasKey("DialogShowWheel")) + showWheel = compound.getBoolean("DialogShowWheel"); + else + showWheel = true; + disableEsc = compound.getBoolean("DialogDisableEsc"); + + if (compound.hasKey("DialogDarkScreen")) { + darkenScreen = compound.getBoolean("DialogDarkScreen"); + } else { + darkenScreen = true; + } + + alignment = compound.getByte("DialogAlignment"); - NBTTagList options = compound.getTagList("Options", 10); - HashMap newoptions = new HashMap(); - for(int iii = 0; iii < options.tagCount();iii++){ + NBTTagList options = compound.getTagList("Options", 10); + HashMap newoptions = new HashMap(); + for (int iii = 0; iii < options.tagCount(); iii++) { NBTTagCompound option = options.getCompoundTagAt(iii); int opslot = option.getInteger("OptionSlot"); DialogOption dia = new DialogOption(); dia.readNBT(option.getCompoundTag("Option")); newoptions.put(opslot, dia); - } - this.options = newoptions; + } + this.options = newoptions; - NBTTagList images = compound.getTagList("Images", 10); - HashMap newImages = new HashMap<>(); - for(int i = 0; i < images.tagCount(); i++){ - NBTTagCompound imageCompound = images.getCompoundTagAt(i); - int id = imageCompound.getInteger("ID"); - DialogImage image = new DialogImage(id); - image.readNBT(imageCompound); - newImages.put(id, image); - } - this.dialogImages = newImages; + NBTTagList images = compound.getTagList("Images", 10); + HashMap newImages = new HashMap<>(); + for (int i = 0; i < images.tagCount(); i++) { + NBTTagCompound imageCompound = images.getCompoundTagAt(i); + int id = imageCompound.getInteger("ID"); + DialogImage image = new DialogImage(id); + image.readNBT(imageCompound); + newImages.put(id, image); + } + this.dialogImages = newImages; - color = compound.getInteger("Color"); - titleColor = compound.getInteger("TitleColor"); - renderGradual = compound.getBoolean("RenderGradual"); - showPreviousBlocks = compound.getBoolean("PreviousBlocks"); - showOptionLine = compound.getBoolean("ShowOptionLine"); - textSound = compound.getString("TextSound"); - textPitch = compound.getFloat("TextPitch"); - textWidth = compound.getInteger("TextWidth"); - textHeight = compound.getInteger("TextHeight"); - textOffsetX = compound.getInteger("TextOffsetX"); - textOffsetY = compound.getInteger("TextOffsetY"); - titlePos = compound.getInteger("TitlePos"); - titleOffsetX = compound.getInteger("TitleOffsetX"); - titleOffsetY = compound.getInteger("TitleOffsetY"); - optionOffsetX = compound.getInteger("OptionOffsetX"); - optionOffsetY = compound.getInteger("OptionOffsetY"); - optionSpaceX = compound.getInteger("OptionSpaceX"); - optionSpaceY = compound.getInteger("OptionSpaceY"); - npcScale = compound.getFloat("NPCScale"); - npcOffsetX = compound.getInteger("NPCOffsetX"); - npcOffsetY = compound.getInteger("NPCOffsetY"); + color = compound.getInteger("Color"); + titleColor = compound.getInteger("TitleColor"); + renderGradual = compound.getBoolean("RenderGradual"); + showPreviousBlocks = compound.getBoolean("PreviousBlocks"); + showOptionLine = compound.getBoolean("ShowOptionLine"); + textSound = compound.getString("TextSound"); + textPitch = compound.getFloat("TextPitch"); + textWidth = compound.getInteger("TextWidth"); + textHeight = compound.getInteger("TextHeight"); + textOffsetX = compound.getInteger("TextOffsetX"); + textOffsetY = compound.getInteger("TextOffsetY"); + titlePos = compound.getInteger("TitlePos"); + titleOffsetX = compound.getInteger("TitleOffsetX"); + titleOffsetY = compound.getInteger("TitleOffsetY"); + optionOffsetX = compound.getInteger("OptionOffsetX"); + optionOffsetY = compound.getInteger("OptionOffsetY"); + optionSpaceX = compound.getInteger("OptionSpaceX"); + optionSpaceY = compound.getInteger("OptionSpaceY"); + npcScale = compound.getFloat("NPCScale"); + npcOffsetX = compound.getInteger("NPCOffsetX"); + npcOffsetY = compound.getInteger("NPCOffsetY"); - if (!compound.hasKey("PreviousBlocks")) - showPreviousBlocks = true; - if (!compound.hasKey("TextSound")) - textSound = "minecraft:random.wood_click"; - if (!compound.hasKey("TextPitch")) - textPitch = 1.0F; - if (!compound.hasKey("TextWidth")) - textWidth = 300; - if (!compound.hasKey("TextHeight")) - textHeight = 400; - if (!compound.hasKey("ShowOptionLine")) - showOptionLine = true; - if (!compound.hasKey("NPCScale")) - npcScale = 1.0F; - if (!compound.hasKey("Color")) - color = 0xe0e0e0; - if (!compound.hasKey("TitleColor")) - titleColor = 0xe0e0e0; + if (!compound.hasKey("PreviousBlocks")) + showPreviousBlocks = true; + if (!compound.hasKey("TextSound")) + textSound = "minecraft:random.wood_click"; + if (!compound.hasKey("TextPitch")) + textPitch = 1.0F; + if (!compound.hasKey("TextWidth")) + textWidth = 300; + if (!compound.hasKey("TextHeight")) + textHeight = 400; + if (!compound.hasKey("ShowOptionLine")) + showOptionLine = true; + if (!compound.hasKey("NPCScale")) + npcScale = 1.0F; + if (!compound.hasKey("Color")) + color = 0xe0e0e0; + if (!compound.hasKey("TitleColor")) + titleColor = 0xe0e0e0; - availability.readFromNBT(compound); - factionOptions.readFromNBT(compound); - } + availability.readFromNBT(compound); + factionOptions.readFromNBT(compound); + } - public NBTTagCompound writeToNBT(NBTTagCompound compound) { - compound.setInteger("DialogId", id); - return writeToNBTPartial(compound); - } - - public NBTTagCompound writeToNBTPartial(NBTTagCompound compound) { - compound.setString("DialogTitle", title); - compound.setString("DialogText", text); - compound.setInteger("DialogQuest", quest); - compound.setString("DialogCommand", command); - compound.setTag("DialogMail", mail.writeNBT()); - compound.setBoolean("DialogHideNPC", hideNPC); - compound.setBoolean("DialogShowWheel", showWheel); - compound.setBoolean("DialogDisableEsc", disableEsc); + public NBTTagCompound writeToNBT(NBTTagCompound compound) { + compound.setInteger("DialogId", id); + return writeToNBTPartial(compound); + } - compound.setBoolean("DialogDarkScreen", darkenScreen); - compound.setByte("DialogAlignment", alignment); + public NBTTagCompound writeToNBTPartial(NBTTagCompound compound) { + compound.setString("DialogTitle", title); + compound.setString("DialogText", text); + compound.setInteger("DialogQuest", quest); + compound.setString("DialogCommand", command); + compound.setTag("DialogMail", mail.writeNBT()); + compound.setBoolean("DialogHideNPC", hideNPC); + compound.setBoolean("DialogShowWheel", showWheel); + compound.setBoolean("DialogDisableEsc", disableEsc); - if(sound != null && !sound.isEmpty()) - compound.setString("DialogSound", sound); + compound.setBoolean("DialogDarkScreen", darkenScreen); + compound.setByte("DialogAlignment", alignment); - NBTTagList options = new NBTTagList(); - for(int opslot : this.options.keySet()){ - NBTTagCompound listcompound = new NBTTagCompound(); - listcompound.setInteger("OptionSlot", opslot); - listcompound.setTag("Option", this.options.get(opslot).writeNBT()); - options.appendTag(listcompound); - } - compound.setTag("Options", options); - - availability.writeToNBT(compound); - factionOptions.writeToNBT(compound); - compound.setInteger("ModRev", version); + if (sound != null && !sound.isEmpty()) + compound.setString("DialogSound", sound); - compound.setInteger("Color", color); - compound.setInteger("TitleColor", titleColor); - compound.setBoolean("RenderGradual", renderGradual); - compound.setBoolean("PreviousBlocks", showPreviousBlocks); - compound.setBoolean("ShowOptionLine", showOptionLine); - compound.setString("TextSound", textSound); - compound.setFloat("TextPitch", textPitch); - compound.setInteger("TextWidth", textWidth); - compound.setInteger("TextHeight", textHeight); - compound.setInteger("TextOffsetX", textOffsetX); - compound.setInteger("TextOffsetY", textOffsetY); - compound.setInteger("TitlePos", titlePos); - compound.setInteger("TitleOffsetX", titleOffsetX); - compound.setInteger("TitleOffsetY", titleOffsetY); - compound.setInteger("OptionOffsetX", optionOffsetX); - compound.setInteger("OptionOffsetY", optionOffsetY); - compound.setInteger("OptionSpaceX", optionSpaceX); - compound.setInteger("OptionSpaceY", optionSpaceY); - compound.setFloat("NPCScale", npcScale); - compound.setInteger("NPCOffsetX", npcOffsetX); - compound.setInteger("NPCOffsetY", npcOffsetY); + NBTTagList options = new NBTTagList(); + for (int opslot : this.options.keySet()) { + NBTTagCompound listcompound = new NBTTagCompound(); + listcompound.setInteger("OptionSlot", opslot); + listcompound.setTag("Option", this.options.get(opslot).writeNBT()); + options.appendTag(listcompound); + } + compound.setTag("Options", options); - NBTTagList images = new NBTTagList(); - for (IDialogImage dialogImage : dialogImages.values()) { - NBTTagCompound imageCompound = ((DialogImage) dialogImage).writeToNBT(new NBTTagCompound()); - images.appendTag(imageCompound); - } - compound.setTag("Images",images); + availability.writeToNBT(compound); + factionOptions.writeToNBT(compound); + compound.setInteger("ModRev", version); - return compound; - } + compound.setInteger("Color", color); + compound.setInteger("TitleColor", titleColor); + compound.setBoolean("RenderGradual", renderGradual); + compound.setBoolean("PreviousBlocks", showPreviousBlocks); + compound.setBoolean("ShowOptionLine", showOptionLine); + compound.setString("TextSound", textSound); + compound.setFloat("TextPitch", textPitch); + compound.setInteger("TextWidth", textWidth); + compound.setInteger("TextHeight", textHeight); + compound.setInteger("TextOffsetX", textOffsetX); + compound.setInteger("TextOffsetY", textOffsetY); + compound.setInteger("TitlePos", titlePos); + compound.setInteger("TitleOffsetX", titleOffsetX); + compound.setInteger("TitleOffsetY", titleOffsetY); + compound.setInteger("OptionOffsetX", optionOffsetX); + compound.setInteger("OptionOffsetY", optionOffsetY); + compound.setInteger("OptionSpaceX", optionSpaceX); + compound.setInteger("OptionSpaceY", optionSpaceY); + compound.setFloat("NPCScale", npcScale); + compound.setInteger("NPCOffsetX", npcOffsetX); + compound.setInteger("NPCOffsetY", npcOffsetY); - public boolean hasQuest() { - return getQuest() != null; - } + NBTTagList images = new NBTTagList(); + for (IDialogImage dialogImage : dialogImages.values()) { + NBTTagCompound imageCompound = ((DialogImage) dialogImage).writeToNBT(new NBTTagCompound()); + images.appendTag(imageCompound); + } + compound.setTag("Images", images); - public boolean hasOtherOptions() { - for(DialogOption option: options.values()) - if(option != null && option.optionType != EnumOptionType.Disabled) - return true; - return false; - } - - public Dialog copy(EntityPlayer player) { - Dialog dialog = new Dialog(); - dialog.id = id; - dialog.text = text; - dialog.title = title; - dialog.category = category; - dialog.quest = quest; - dialog.sound = sound; - dialog.mail = mail; - dialog.command = command; - dialog.color = color; - dialog.titleColor = titleColor; - dialog.hideNPC = hideNPC; - dialog.showWheel = showWheel; - dialog.disableEsc = disableEsc; - dialog.darkenScreen = darkenScreen; - dialog.renderGradual = renderGradual; - dialog.showPreviousBlocks = showPreviousBlocks; - dialog.showOptionLine = showOptionLine; - dialog.alignment = alignment; - dialog.textSound = textSound; - dialog.textPitch = textPitch; - dialog.textWidth = textWidth; - dialog.textHeight = textHeight; - dialog.textOffsetX = textOffsetX; - dialog.textOffsetY = textOffsetY; - dialog.titlePos = titlePos; - dialog.titleOffsetX = titleOffsetX; - dialog.titleOffsetY = titleOffsetY; - dialog.optionOffsetX = optionOffsetX; - dialog.optionOffsetY = optionOffsetY; - dialog.optionSpaceX = optionSpaceX; - dialog.optionSpaceY = optionSpaceY; - dialog.npcScale = npcScale; - dialog.npcOffsetX = npcOffsetX; - dialog.npcOffsetY = npcOffsetY; - dialog.dialogImages = dialogImages; - - for(int slot : options.keySet()){ - DialogOption option = options.get(slot); - if(option.optionType == EnumOptionType.DialogOption && (!option.hasDialog() || !option.isAvailable(player))) - continue; - dialog.options.put(slot, option); - } - return dialog; - } - @Override - public int getVersion() { - return version; - } - @Override - public void setVersion(int version) { - this.version = version; - } + return compound; + } - public int getId() { - return this.id; - } + public boolean hasQuest() { + return getQuest() != null; + } - public String getName() { - return this.title; - } + public boolean hasOtherOptions() { + for (DialogOption option : options.values()) + if (option != null && option.optionType != EnumOptionType.Disabled) + return true; + return false; + } - public List getOptions() { - return new ArrayList(this.options.values()); - } + public Dialog copy(EntityPlayer player) { + Dialog dialog = new Dialog(); + dialog.id = id; + dialog.text = text; + dialog.title = title; + dialog.category = category; + dialog.quest = quest; + dialog.sound = sound; + dialog.mail = mail; + dialog.command = command; + dialog.color = color; + dialog.titleColor = titleColor; + dialog.hideNPC = hideNPC; + dialog.showWheel = showWheel; + dialog.disableEsc = disableEsc; + dialog.darkenScreen = darkenScreen; + dialog.renderGradual = renderGradual; + dialog.showPreviousBlocks = showPreviousBlocks; + dialog.showOptionLine = showOptionLine; + dialog.alignment = alignment; + dialog.textSound = textSound; + dialog.textPitch = textPitch; + dialog.textWidth = textWidth; + dialog.textHeight = textHeight; + dialog.textOffsetX = textOffsetX; + dialog.textOffsetY = textOffsetY; + dialog.titlePos = titlePos; + dialog.titleOffsetX = titleOffsetX; + dialog.titleOffsetY = titleOffsetY; + dialog.optionOffsetX = optionOffsetX; + dialog.optionOffsetY = optionOffsetY; + dialog.optionSpaceX = optionSpaceX; + dialog.optionSpaceY = optionSpaceY; + dialog.npcScale = npcScale; + dialog.npcOffsetX = npcOffsetX; + dialog.npcOffsetY = npcOffsetY; + dialog.dialogImages = dialogImages; - public IDialogOption getOption(int slot) { - IDialogOption option = (IDialogOption)this.options.get(slot); - if (option == null) { - throw new CustomNPCsException("There is no DialogOption for slot: " + slot, new Object[0]); - } else { - return option; - } - } + for (int slot : options.keySet()) { + DialogOption option = options.get(slot); + if (option.optionType == EnumOptionType.DialogOption && (!option.hasDialog() || !option.isAvailable(player))) + continue; + dialog.options.put(slot, option); + } + return dialog; + } - public IAvailability getAvailability() { - return this.availability; - } + @Override + public int getVersion() { + return version; + } - public IDialogCategory getCategory() { - return this.category; - } + @Override + public void setVersion(int version) { + this.version = version; + } - public void save() { - DialogController.Instance.saveDialog(this.category.id, this); - } + public int getId() { + return this.id; + } - public void setName(String name) { - this.title = name; - } + public String getName() { + return this.title; + } - public String getText() { - return this.text; - } + public List getOptions() { + return new ArrayList(this.options.values()); + } - public void setText(String text) { - this.text = text; - } + public IDialogOption getOption(int slot) { + IDialogOption option = (IDialogOption) this.options.get(slot); + if (option == null) { + throw new CustomNPCsException("There is no DialogOption for slot: " + slot, new Object[0]); + } else { + return option; + } + } - public void setQuest(IQuest quest) { - if (quest == null) { - this.quest = -1; - } else { - if (quest.getId() < 0) { - throw new CustomNPCsException("Quest id is lower than 0", new Object[0]); - } + public IAvailability getAvailability() { + return this.availability; + } - this.quest = quest.getId(); - } + public IDialogCategory getCategory() { + return this.category; + } - } + public void save() { + DialogController.Instance.saveDialog(this.category.id, this); + } - public Quest getQuest() { - return QuestController.Instance == null ? null : (Quest)QuestController.Instance.quests.get(this.quest); - } + public void setName(String name) { + this.title = name; + } - public String getCommand() { - return this.command; - } + public String getText() { + return this.text; + } - public void setCommand(String command) { - this.command = command; - } + public void setText(String text) { + this.text = text; + } - public void setDarkenScreen(boolean darkenScreen) { - this.darkenScreen = darkenScreen; - } - public boolean getDarkenScreen() { - return this.darkenScreen; - } + public void setQuest(IQuest quest) { + if (quest == null) { + this.quest = -1; + } else { + if (quest.getId() < 0) { + throw new CustomNPCsException("Quest id is lower than 0", new Object[0]); + } - public void setDisableEsc(boolean disableEsc) { - this.disableEsc = disableEsc; - } - public boolean getDisableEsc() { - return this.disableEsc; - } + this.quest = quest.getId(); + } - public void setShowWheel(boolean showWheel) { - this.showWheel = showWheel; - } - public boolean getShowWheel() { - return this.showWheel; - } + } - public void setHideNPC(boolean hideNPC) { - this.hideNPC = hideNPC; - } - public boolean getHideNPC() { - return this.hideNPC; - } + public Quest getQuest() { + return QuestController.Instance == null ? null : (Quest) QuestController.Instance.quests.get(this.quest); + } - public void setSound(String sound) { - this.sound = sound; - } - public String getSound() { - return this.sound; - } + public String getCommand() { + return this.command; + } - public void setColor(int color) { - this.color = color; - } - public int getColor() { - return this.color; - } + public void setCommand(String command) { + this.command = command; + } - public void setTitleColor(int titleColor) { - this.titleColor = titleColor; - } - public int getTitleColor() { - return titleColor; - } + public void setDarkenScreen(boolean darkenScreen) { + this.darkenScreen = darkenScreen; + } - public void renderGradual(boolean gradual) { - this.renderGradual = gradual; - } - public boolean renderGradual() { - return renderGradual; - } + public boolean getDarkenScreen() { + return this.darkenScreen; + } - public void showPreviousBlocks(boolean show) { - this.showPreviousBlocks = show; - } - public boolean showPreviousBlocks() { - return showPreviousBlocks; - } + public void setDisableEsc(boolean disableEsc) { + this.disableEsc = disableEsc; + } - public void showOptionLine(boolean show) { - this.showOptionLine = show; - } - public boolean showOptionLine() { - return showOptionLine; - } + public boolean getDisableEsc() { + return this.disableEsc; + } - public void setTextSound(String textSound) { - this.textSound = textSound; - } - public String getTextSound() { - return textSound; - } + public void setShowWheel(boolean showWheel) { + this.showWheel = showWheel; + } - public void setTextPitch(float textPitch) { - this.textPitch = textPitch; - } - public float getTextPitch() { - return textPitch; - } + public boolean getShowWheel() { + return this.showWheel; + } - public void setTitlePos(int pos) { - this.titlePos = pos; - } - public int getTitlePos() { - return this.titlePos; - } + public void setHideNPC(boolean hideNPC) { + this.hideNPC = hideNPC; + } - public void setNPCScale(float scale) { - this.npcScale = scale; - } - public float getNpcScale() { - return npcScale; - } + public boolean getHideNPC() { + return this.hideNPC; + } - public void setNpcOffset(int offsetX, int offsetY) { - this.npcOffsetX = offsetX; - this.npcOffsetY = offsetY; - } - public int getNpcOffsetX() { - return npcOffsetX; - } - public int getNpcOffsetY() { - return npcOffsetY; - } + public void setSound(String sound) { + this.sound = sound; + } - public void textWidthHeight(int textWidth, int textHeight) { - this.textWidth = textWidth; - this.textHeight = textHeight; - } - public int getTextWidth() { - return textWidth; - } - public int setTextHeight() { - return textHeight; - } + public String getSound() { + return this.sound; + } - public void setTextOffset(int offsetX, int offsetY) { - this.textOffsetX = offsetX; - this.textOffsetY = offsetY; - } - public int getTextOffsetX() { - return textOffsetX; - } - public int getTextOffsetY() { - return textOffsetY; - } + public void setColor(int color) { + this.color = color; + } - public void setTitleOffset(int offsetX, int offsetY) { - this.titleOffsetX = offsetX; - this.titleOffsetY = offsetY; - } - public int getTitleOffsetX() { - return titleOffsetX; - } - public int getTitleOffsetY() { - return titleOffsetY; - } + public int getColor() { + return this.color; + } - public void setOptionOffset(int offsetX, int offsetY) { - this.optionOffsetX = offsetX; - this.optionOffsetY = offsetY; - } - public int getOptionOffsetX() { - return optionOffsetX; - } - public int getOptionOffsetY() { - return optionOffsetY; - } + public void setTitleColor(int titleColor) { + this.titleColor = titleColor; + } - public void setOptionSpacing(int spaceX, int spaceY) { - this.optionSpaceX = spaceX; - this.optionSpaceY = spaceY; - } - public int getOptionSpaceX() { - return optionSpaceX; - } - public int getOptionSpaceY() { - return optionSpaceY; - } + public int getTitleColor() { + return titleColor; + } - public void addImage(int id, IDialogImage image) { - if (dialogImages.size() >= ConfigMain.DialogImageLimit) { - return; - } + public void renderGradual(boolean gradual) { + this.renderGradual = gradual; + } - ((DialogImage) image).id = id; - dialogImages.put(id, image); - } - public IDialogImage getImage(int id) { - return dialogImages.get(id); - } - public IDialogImage createImage() { - return new DialogImage(); - } - public IDialogImage[] getImages() { - return (new ArrayList<>(dialogImages.values())).toArray(new IDialogImage[0]); - } - public boolean hasImage(int id) { - return dialogImages.containsKey(id); - } - public void removeImage(int id) { - dialogImages.remove(id); - } - public void clearImages() { - dialogImages.clear(); - } + public boolean renderGradual() { + return renderGradual; + } + + public void showPreviousBlocks(boolean show) { + this.showPreviousBlocks = show; + } + + public boolean showPreviousBlocks() { + return showPreviousBlocks; + } + + public void showOptionLine(boolean show) { + this.showOptionLine = show; + } + + public boolean showOptionLine() { + return showOptionLine; + } + + public void setTextSound(String textSound) { + this.textSound = textSound; + } + + public String getTextSound() { + return textSound; + } + + public void setTextPitch(float textPitch) { + this.textPitch = textPitch; + } + + public float getTextPitch() { + return textPitch; + } + + public void setTitlePos(int pos) { + this.titlePos = pos; + } + + public int getTitlePos() { + return this.titlePos; + } + + public void setNPCScale(float scale) { + this.npcScale = scale; + } + + public float getNpcScale() { + return npcScale; + } + + public void setNpcOffset(int offsetX, int offsetY) { + this.npcOffsetX = offsetX; + this.npcOffsetY = offsetY; + } + + public int getNpcOffsetX() { + return npcOffsetX; + } + + public int getNpcOffsetY() { + return npcOffsetY; + } + + public void textWidthHeight(int textWidth, int textHeight) { + this.textWidth = textWidth; + this.textHeight = textHeight; + } + + public int getTextWidth() { + return textWidth; + } + + public int setTextHeight() { + return textHeight; + } + + public void setTextOffset(int offsetX, int offsetY) { + this.textOffsetX = offsetX; + this.textOffsetY = offsetY; + } + + public int getTextOffsetX() { + return textOffsetX; + } + + public int getTextOffsetY() { + return textOffsetY; + } + + public void setTitleOffset(int offsetX, int offsetY) { + this.titleOffsetX = offsetX; + this.titleOffsetY = offsetY; + } + + public int getTitleOffsetX() { + return titleOffsetX; + } + + public int getTitleOffsetY() { + return titleOffsetY; + } + + public void setOptionOffset(int offsetX, int offsetY) { + this.optionOffsetX = offsetX; + this.optionOffsetY = offsetY; + } + + public int getOptionOffsetX() { + return optionOffsetX; + } + + public int getOptionOffsetY() { + return optionOffsetY; + } + + public void setOptionSpacing(int spaceX, int spaceY) { + this.optionSpaceX = spaceX; + this.optionSpaceY = spaceY; + } + + public int getOptionSpaceX() { + return optionSpaceX; + } + + public int getOptionSpaceY() { + return optionSpaceY; + } + + public void addImage(int id, IDialogImage image) { + if (dialogImages.size() >= ConfigMain.DialogImageLimit) { + return; + } + + ((DialogImage) image).id = id; + dialogImages.put(id, image); + } + + public IDialogImage getImage(int id) { + return dialogImages.get(id); + } + + public IDialogImage createImage() { + return new DialogImage(); + } + + public IDialogImage[] getImages() { + return (new ArrayList<>(dialogImages.values())).toArray(new IDialogImage[0]); + } + + public boolean hasImage(int id) { + return dialogImages.containsKey(id); + } + + public void removeImage(int id) { + dialogImages.remove(id); + } + + public void clearImages() { + dialogImages.clear(); + } } diff --git a/src/main/java/noppes/npcs/controllers/data/DialogCategory.java b/src/main/java/noppes/npcs/controllers/data/DialogCategory.java index 7bac90e68..dd99c3137 100644 --- a/src/main/java/noppes/npcs/controllers/data/DialogCategory.java +++ b/src/main/java/noppes/npcs/controllers/data/DialogCategory.java @@ -11,42 +11,41 @@ import java.util.List; public class DialogCategory implements IDialogCategory { - public int id = -1; - public String title = ""; - public HashMap dialogs; + public int id = -1; + public String title = ""; + public HashMap dialogs; - public DialogCategory(){ - dialogs = new HashMap(); - } + public DialogCategory() { + dialogs = new HashMap(); + } - public void readNBT(NBTTagCompound compound){ + public void readNBT(NBTTagCompound compound) { id = compound.getInteger("Slot"); title = compound.getString("Title"); NBTTagList dialogsList = compound.getTagList("Dialogs", 10); - if(dialogsList != null){ - for(int ii = 0; ii < dialogsList.tagCount(); ii++) - { - Dialog dialog = new Dialog(); - dialog.category = this; - NBTTagCompound comp = dialogsList.getCompoundTagAt(ii); - dialog.readNBT(comp); - dialog.id = comp.getInteger("DialogId"); - dialogs.put(dialog.id, dialog); + if (dialogsList != null) { + for (int ii = 0; ii < dialogsList.tagCount(); ii++) { + Dialog dialog = new Dialog(); + dialog.category = this; + NBTTagCompound comp = dialogsList.getCompoundTagAt(ii); + dialog.readNBT(comp); + dialog.id = comp.getInteger("DialogId"); + dialogs.put(dialog.id, dialog); } } - } + } - public NBTTagCompound writeNBT(NBTTagCompound dialogCat) { + public NBTTagCompound writeNBT(NBTTagCompound dialogCat) { dialogCat.setInteger("Slot", id); dialogCat.setString("Title", title); NBTTagList dialogs = new NBTTagList(); - for(Dialog dialog : this.dialogs.values()){ - dialogs.appendTag(dialog.writeToNBT(new NBTTagCompound())); + for (Dialog dialog : this.dialogs.values()) { + dialogs.appendTag(dialog.writeToNBT(new NBTTagCompound())); } dialogCat.setTag("Dialogs", dialogs); return dialogCat; - } + } public NBTTagCompound writeSmallNBT(NBTTagCompound dialogCat) { dialogCat.setInteger("Slot", id); @@ -54,27 +53,27 @@ public class DialogCategory implements IDialogCategory { return dialogCat; } - public void readSmallNBT(NBTTagCompound compound){ + public void readSmallNBT(NBTTagCompound compound) { id = compound.getInteger("Slot"); title = compound.getString("Title"); } - public List dialogs() { - return new ArrayList(this.dialogs.values()); - } + public List dialogs() { + return new ArrayList(this.dialogs.values()); + } - public String getName() { - return this.title; - } + public String getName() { + return this.title; + } - public IDialog create() { - Dialog dialog = new Dialog(); - dialog.category = this; - return dialog; - } + public IDialog create() { + Dialog dialog = new Dialog(); + dialog.category = this; + return dialog; + } - @Override - public int getId() { - return this.id; - } + @Override + public int getId() { + return this.id; + } } diff --git a/src/main/java/noppes/npcs/controllers/data/DialogOption.java b/src/main/java/noppes/npcs/controllers/data/DialogOption.java index d1e8899c3..4e45c3c73 100644 --- a/src/main/java/noppes/npcs/controllers/data/DialogOption.java +++ b/src/main/java/noppes/npcs/controllers/data/DialogOption.java @@ -6,57 +6,57 @@ import noppes.npcs.constants.EnumOptionType; import noppes.npcs.controllers.DialogController; public class DialogOption { - public int dialogId = -1; - public String title = "Talk"; - public EnumOptionType optionType = EnumOptionType.DialogOption; - public int optionColor = 0xe0e0e0; - public String command = ""; - - public void readNBT(NBTTagCompound compound) { - if(compound == null) - return; - title = compound.getString("Title"); - dialogId = compound.getInteger("Dialog"); - optionColor = compound.getInteger("DialogColor"); - optionType = EnumOptionType.values()[compound.getInteger("OptionType")]; - command = compound.getString("DialogCommand"); - if(optionColor == 0){ - optionColor = 0xe0e0e0; - } - } + public int dialogId = -1; + public String title = "Talk"; + public EnumOptionType optionType = EnumOptionType.DialogOption; + public int optionColor = 0xe0e0e0; + public String command = ""; - public NBTTagCompound writeNBT() { - NBTTagCompound compound = new NBTTagCompound(); - compound.setString("Title", title); - compound.setInteger("OptionType", optionType.ordinal()); - compound.setInteger("Dialog", dialogId); - compound.setInteger("DialogColor", optionColor); - compound.setString("DialogCommand", command); - return compound; - } - + public void readNBT(NBTTagCompound compound) { + if (compound == null) + return; + title = compound.getString("Title"); + dialogId = compound.getInteger("Dialog"); + optionColor = compound.getInteger("DialogColor"); + optionType = EnumOptionType.values()[compound.getInteger("OptionType")]; + command = compound.getString("DialogCommand"); + if (optionColor == 0) { + optionColor = 0xe0e0e0; + } + } - public boolean hasDialog(){ - if(dialogId <= 0) - return false; - if(!DialogController.Instance.hasDialog(dialogId)){ - dialogId = -1; - return false; - } - return true; - } + public NBTTagCompound writeNBT() { + NBTTagCompound compound = new NBTTagCompound(); + compound.setString("Title", title); + compound.setInteger("OptionType", optionType.ordinal()); + compound.setInteger("Dialog", dialogId); + compound.setInteger("DialogColor", optionColor); + compound.setString("DialogCommand", command); + return compound; + } - public Dialog getDialog() { - if(!hasDialog()) - return null; - return DialogController.Instance.dialogs.get(dialogId); - } - public boolean isAvailable(EntityPlayer player) { - Dialog dialog = getDialog(); - if(dialog == null) - return false; - - return dialog.availability.isAvailable(player); - } + public boolean hasDialog() { + if (dialogId <= 0) + return false; + if (!DialogController.Instance.hasDialog(dialogId)) { + dialogId = -1; + return false; + } + return true; + } + + public Dialog getDialog() { + if (!hasDialog()) + return null; + return DialogController.Instance.dialogs.get(dialogId); + } + + public boolean isAvailable(EntityPlayer player) { + Dialog dialog = getDialog(); + if (dialog == null) + return false; + + return dialog.availability.isAvailable(player); + } } diff --git a/src/main/java/noppes/npcs/controllers/data/EffectScript.java b/src/main/java/noppes/npcs/controllers/data/EffectScript.java index f27232554..2fbd7d0ab 100644 --- a/src/main/java/noppes/npcs/controllers/data/EffectScript.java +++ b/src/main/java/noppes/npcs/controllers/data/EffectScript.java @@ -114,14 +114,14 @@ public class EffectScript implements INpcScriptHandler { int tab = 0; Iterator var3 = this.getScripts().iterator(); - while(var3.hasNext()) { - ScriptContainer script = (ScriptContainer)var3.next(); + while (var3.hasNext()) { + ScriptContainer script = (ScriptContainer) var3.next(); ++tab; Iterator var5 = script.console.entrySet().iterator(); - while(var5.hasNext()) { - Map.Entry longStringEntry = (Map.Entry)var5.next(); - map.put(longStringEntry.getKey(), " tab " + tab + ":\n" + (String)longStringEntry.getValue()); + while (var5.hasNext()) { + Map.Entry longStringEntry = (Map.Entry) var5.next(); + map.put(longStringEntry.getKey(), " tab " + tab + ":\n" + (String) longStringEntry.getValue()); } } @@ -132,8 +132,8 @@ public class EffectScript implements INpcScriptHandler { public void clearConsole() { Iterator var1 = this.getScripts().iterator(); - while(var1.hasNext()) { - ScriptContainer script = (ScriptContainer)var1.next(); + while (var1.hasNext()) { + ScriptContainer script = (ScriptContainer) var1.next(); script.console.clear(); } } @@ -170,6 +170,7 @@ public class EffectScript implements INpcScriptHandler { OnRemove("onRemove"); public final String function; + ScriptType(String functionName) { this.function = functionName; } diff --git a/src/main/java/noppes/npcs/controllers/data/Faction.java b/src/main/java/noppes/npcs/controllers/data/Faction.java index 6b9f39903..d8d38ca1e 100644 --- a/src/main/java/noppes/npcs/controllers/data/Faction.java +++ b/src/main/java/noppes/npcs/controllers/data/Faction.java @@ -15,42 +15,44 @@ import java.util.ArrayList; import java.util.HashSet; public class Faction implements IFaction { - public String name = ""; - public int color = Integer.parseInt("FF00", 16); + public String name = ""; + public int color = Integer.parseInt("FF00", 16); - public HashSet attackFactions; - public int id = -1; + public HashSet attackFactions; + public int id = -1; - public int neutralPoints = 500; - public int friendlyPoints = 1500; + public int neutralPoints = 500; + public int friendlyPoints = 1500; - public int defaultPoints = 1000; + public int defaultPoints = 1000; - public boolean hideFaction = false; - public boolean getsAttacked = false; + public boolean hideFaction = false; + public boolean getsAttacked = false; public boolean isPassive = false; - public Faction(){ - attackFactions = new HashSet(); - } + public Faction() { + attackFactions = new HashSet(); + } - public Faction(int id, String name,int color, int defaultPoints){ - this.name = name; - this.color = color; - this.defaultPoints = defaultPoints; - this.id = id; - attackFactions = new HashSet(); - } - public static String formatName(String name){ - name = name.toLowerCase().trim(); - return name.substring(0, 1).toUpperCase() + name.substring(1); - } - public void readNBT(NBTTagCompound compound){ + public Faction(int id, String name, int color, int defaultPoints) { + this.name = name; + this.color = color; + this.defaultPoints = defaultPoints; + this.id = id; + attackFactions = new HashSet(); + } + + public static String formatName(String name) { + name = name.toLowerCase().trim(); + return name.substring(0, 1).toUpperCase() + name.substring(1); + } + + public void readNBT(NBTTagCompound compound) { name = compound.getString("Name"); color = compound.getInteger("Color"); id = compound.getInteger("Slot"); - neutralPoints= compound.getInteger("NeutralPoints"); + neutralPoints = compound.getInteger("NeutralPoints"); friendlyPoints = compound.getInteger("FriendlyPoints"); defaultPoints = compound.getInteger("DefaultPoints"); @@ -59,126 +61,131 @@ public class Faction implements IFaction { isPassive = compound.getBoolean("IsPassive"); attackFactions = NBTTags.getIntegerSet(compound.getTagList("AttackFactions", 10)); - } - public void writeNBT(NBTTagCompound compound){ - compound.setInteger("Slot", id); - compound.setString("Name", name); - compound.setInteger("Color", color); + } - compound.setInteger("NeutralPoints", neutralPoints); - compound.setInteger("FriendlyPoints", friendlyPoints); - compound.setInteger("DefaultPoints", defaultPoints); + public void writeNBT(NBTTagCompound compound) { + compound.setInteger("Slot", id); + compound.setString("Name", name); + compound.setInteger("Color", color); - compound.setBoolean("HideFaction", hideFaction); - compound.setBoolean("GetsAttacked", getsAttacked); + compound.setInteger("NeutralPoints", neutralPoints); + compound.setInteger("FriendlyPoints", friendlyPoints); + compound.setInteger("DefaultPoints", defaultPoints); + + compound.setBoolean("HideFaction", hideFaction); + compound.setBoolean("GetsAttacked", getsAttacked); compound.setBoolean("IsPassive", isPassive); - compound.setTag("AttackFactions", NBTTags.nbtIntegerSet(attackFactions)); - } + compound.setTag("AttackFactions", NBTTags.nbtIntegerSet(attackFactions)); + } - public boolean isFriendlyToPlayer(EntityPlayer player) { - PlayerFactionData data = PlayerDataController.Instance.getPlayerData(player).factionData; - return data.getFactionPoints(id) >= friendlyPoints; - } + public boolean isFriendlyToPlayer(EntityPlayer player) { + PlayerFactionData data = PlayerDataController.Instance.getPlayerData(player).factionData; + return data.getFactionPoints(id) >= friendlyPoints; + } - public boolean isAggressiveToPlayer(EntityPlayer player) { - PlayerFactionData data = PlayerDataController.Instance.getPlayerData(player).factionData; - return data.getFactionPoints(id) < neutralPoints; - } + public boolean isAggressiveToPlayer(EntityPlayer player) { + PlayerFactionData data = PlayerDataController.Instance.getPlayerData(player).factionData; + return data.getFactionPoints(id) < neutralPoints; + } - public boolean isNeutralToPlayer(EntityPlayer player) { - PlayerFactionData data = PlayerDataController.Instance.getPlayerData(player).factionData; - int points = data.getFactionPoints(id); - return points >= neutralPoints && points < friendlyPoints; - } + public boolean isNeutralToPlayer(EntityPlayer player) { + PlayerFactionData data = PlayerDataController.Instance.getPlayerData(player).factionData; + int points = data.getFactionPoints(id); + return points >= neutralPoints && points < friendlyPoints; + } - public boolean isAggressiveToNpc(EntityNPCInterface entity) { - return attackFactions.contains(entity.faction.id); - } + public boolean isAggressiveToNpc(EntityNPCInterface entity) { + return attackFactions.contains(entity.faction.id); + } - public int getId() { - return this.id; - } + public int getId() { + return this.id; + } - public String getName() { - return this.name; - } + public String getName() { + return this.name; + } - public void setName(String name) { this.name = name; } + public void setName(String name) { + this.name = name; + } - public void setDefaultPoints(int points) { - this.defaultPoints = points; - } + public void setDefaultPoints(int points) { + this.defaultPoints = points; + } - public int getDefaultPoints() { - return this.defaultPoints; - } + public int getDefaultPoints() { + return this.defaultPoints; + } - public void setFriendlyPoints(int points) { - this.friendlyPoints = points; - } + public void setFriendlyPoints(int points) { + this.friendlyPoints = points; + } - public int getFriendlyPoints() { - return this.friendlyPoints; - } + public int getFriendlyPoints() { + return this.friendlyPoints; + } - public void setNeutralPoints(int points) { - this.neutralPoints = points; - } + public void setNeutralPoints(int points) { + this.neutralPoints = points; + } - public int getNeutralPoints() { - return this.neutralPoints; - } + public int getNeutralPoints() { + return this.neutralPoints; + } - public void setColor(int color) { this.color = color; } + public void setColor(int color) { + this.color = color; + } - public int getColor() { - return this.color; - } + public int getColor() { + return this.color; + } - public int playerStatus(IPlayer player) { - IPlayerFactionData data = player.getData().getFactionData(); - int points = data.getPoints(this.id); - if (points >= this.friendlyPoints) { - return 1; - } else { - return points < this.neutralPoints ? -1 : 0; - } - } + public int playerStatus(IPlayer player) { + IPlayerFactionData data = player.getData().getFactionData(); + int points = data.getPoints(this.id); + if (points >= this.friendlyPoints) { + return 1; + } else { + return points < this.neutralPoints ? -1 : 0; + } + } - public boolean isAggressiveToNpc(ICustomNpc npc) { - return this.attackFactions.contains(npc.getFaction().getId()); - } + public boolean isAggressiveToNpc(ICustomNpc npc) { + return this.attackFactions.contains(npc.getFaction().getId()); + } - public boolean isEnemyFaction(IFaction faction) { - return this.attackFactions.contains(faction.getId()); - } + public boolean isEnemyFaction(IFaction faction) { + return this.attackFactions.contains(faction.getId()); + } - public IFaction[] getEnemyFactions() { - ArrayList enemyFactions = new ArrayList<>(); + public IFaction[] getEnemyFactions() { + ArrayList enemyFactions = new ArrayList<>(); - for (int id : this.attackFactions) { - enemyFactions.add(FactionController.getInstance().get(id)); - } + for (int id : this.attackFactions) { + enemyFactions.add(FactionController.getInstance().get(id)); + } - return enemyFactions.toArray(new IFaction[]{}); - } + return enemyFactions.toArray(new IFaction[]{}); + } - public void addEnemyFaction(IFaction faction) { - this.attackFactions.add(faction.getId()); - } + public void addEnemyFaction(IFaction faction) { + this.attackFactions.add(faction.getId()); + } - public void removeEnemyFaction(IFaction faction) { - this.attackFactions.remove(faction.getId()); - } + public void removeEnemyFaction(IFaction faction) { + this.attackFactions.remove(faction.getId()); + } - public boolean getIsHidden() { - return this.hideFaction; - } + public boolean getIsHidden() { + return this.hideFaction; + } - public void setIsHidden(boolean bo) { - this.hideFaction = bo; - } + public void setIsHidden(boolean bo) { + this.hideFaction = bo; + } public boolean isPassive() { return isPassive; @@ -189,26 +196,26 @@ public class Faction implements IFaction { } public boolean attackedByMobs() { - return this.getsAttacked; - } + return this.getsAttacked; + } - public void setAttackedByMobs(boolean bo) { - this.getsAttacked = bo; - } + public void setAttackedByMobs(boolean bo) { + this.getsAttacked = bo; + } - public void save() { - FactionController.getInstance().saveFaction(this); - } + public void save() { + FactionController.getInstance().saveFaction(this); + } - public boolean isFriendlyToPlayer(IPlayer player) { - return this.isFriendlyToPlayer((EntityPlayer) player.getMCEntity()); - } + public boolean isFriendlyToPlayer(IPlayer player) { + return this.isFriendlyToPlayer((EntityPlayer) player.getMCEntity()); + } - public boolean isNeutralToPlayer(IPlayer player) { - return this.isNeutralToPlayer((EntityPlayer) player.getMCEntity()); - } + public boolean isNeutralToPlayer(IPlayer player) { + return this.isNeutralToPlayer((EntityPlayer) player.getMCEntity()); + } - public boolean isAggressiveToPlayer(IPlayer player) { - return this.isAggressiveToPlayer((EntityPlayer) player.getMCEntity()); - } + public boolean isAggressiveToPlayer(IPlayer player) { + return this.isAggressiveToPlayer((EntityPlayer) player.getMCEntity()); + } } diff --git a/src/main/java/noppes/npcs/controllers/data/FactionOptions.java b/src/main/java/noppes/npcs/controllers/data/FactionOptions.java index 3e72fd18c..e80537f07 100644 --- a/src/main/java/noppes/npcs/controllers/data/FactionOptions.java +++ b/src/main/java/noppes/npcs/controllers/data/FactionOptions.java @@ -8,62 +8,64 @@ import noppes.npcs.controllers.PlayerDataController; public class FactionOptions { - public boolean decreaseFactionPoints = false; - public boolean decreaseFaction2Points = false; + public boolean decreaseFactionPoints = false; + public boolean decreaseFaction2Points = false; - public int factionId = -1; - public int faction2Id = -1; - - public int factionPoints = 100; - public int faction2Points = 100; - - public void readFromNBT(NBTTagCompound compound) - { - factionId = compound.getInteger("OptionFactions1"); - faction2Id = compound.getInteger("OptionFactions2"); + public int factionId = -1; + public int faction2Id = -1; - decreaseFactionPoints = compound.getBoolean("DecreaseFaction1Points"); - decreaseFaction2Points = compound.getBoolean("DecreaseFaction2Points"); + public int factionPoints = 100; + public int faction2Points = 100; - factionPoints = compound.getInteger("OptionFaction1Points"); - faction2Points = compound.getInteger("OptionFaction2Points"); + public void readFromNBT(NBTTagCompound compound) { + factionId = compound.getInteger("OptionFactions1"); + faction2Id = compound.getInteger("OptionFactions2"); + + decreaseFactionPoints = compound.getBoolean("DecreaseFaction1Points"); + decreaseFaction2Points = compound.getBoolean("DecreaseFaction2Points"); + + factionPoints = compound.getInteger("OptionFaction1Points"); + faction2Points = compound.getInteger("OptionFaction2Points"); } - public NBTTagCompound writeToNBT(NBTTagCompound par1NBTTagCompound) - { - par1NBTTagCompound.setInteger("OptionFactions1", factionId); - par1NBTTagCompound.setInteger("OptionFactions2", faction2Id); - - par1NBTTagCompound.setInteger("OptionFaction1Points", factionPoints); - par1NBTTagCompound.setInteger("OptionFaction2Points", faction2Points); - par1NBTTagCompound.setBoolean("DecreaseFaction1Points", decreaseFactionPoints); - par1NBTTagCompound.setBoolean("DecreaseFaction2Points", decreaseFaction2Points); - return par1NBTTagCompound; + public NBTTagCompound writeToNBT(NBTTagCompound par1NBTTagCompound) { + par1NBTTagCompound.setInteger("OptionFactions1", factionId); + par1NBTTagCompound.setInteger("OptionFactions2", faction2Id); + + par1NBTTagCompound.setInteger("OptionFaction1Points", factionPoints); + par1NBTTagCompound.setInteger("OptionFaction2Points", faction2Points); + + par1NBTTagCompound.setBoolean("DecreaseFaction1Points", decreaseFactionPoints); + par1NBTTagCompound.setBoolean("DecreaseFaction2Points", decreaseFaction2Points); + return par1NBTTagCompound; } - public boolean hasFaction(int id) { - return factionId == id || faction2Id == id; - } - public void addPoints(EntityPlayer player) { - if(factionId < 0 && faction2Id < 0) - return; - PlayerFactionData data = PlayerDataController.Instance.getPlayerData(player).factionData; - if(factionId >= 0 && factionPoints > 0) - addPoints(player, data, factionId, decreaseFactionPoints, factionPoints); - if(faction2Id >= 0 && faction2Points> 0) - addPoints(player, data, faction2Id, decreaseFaction2Points, faction2Points); - } - private void addPoints(EntityPlayer player, PlayerFactionData data, int factionId, boolean decrease, int points) { - Faction faction = FactionController.getInstance().get(factionId); - if(faction == null) - return; + public boolean hasFaction(int id) { + return factionId == id || faction2Id == id; + } - if(!faction.hideFaction){ - String message = decrease?"faction.decreasepoints":"faction.increasepoints"; - player.addChatMessage(new ChatComponentTranslation(message, faction.name, points)); - } - - data.increasePoints(factionId, decrease?-points:points,player); - - } + public void addPoints(EntityPlayer player) { + if (factionId < 0 && faction2Id < 0) + return; + + PlayerFactionData data = PlayerDataController.Instance.getPlayerData(player).factionData; + if (factionId >= 0 && factionPoints > 0) + addPoints(player, data, factionId, decreaseFactionPoints, factionPoints); + if (faction2Id >= 0 && faction2Points > 0) + addPoints(player, data, faction2Id, decreaseFaction2Points, faction2Points); + } + + private void addPoints(EntityPlayer player, PlayerFactionData data, int factionId, boolean decrease, int points) { + Faction faction = FactionController.getInstance().get(factionId); + if (faction == null) + return; + + if (!faction.hideFaction) { + String message = decrease ? "faction.decreasepoints" : "faction.increasepoints"; + player.addChatMessage(new ChatComponentTranslation(message, faction.name, points)); + } + + data.increasePoints(factionId, decrease ? -points : points, player); + + } } diff --git a/src/main/java/noppes/npcs/controllers/data/ForgeDataScript.java b/src/main/java/noppes/npcs/controllers/data/ForgeDataScript.java index d301aaa79..dde123aae 100644 --- a/src/main/java/noppes/npcs/controllers/data/ForgeDataScript.java +++ b/src/main/java/noppes/npcs/controllers/data/ForgeDataScript.java @@ -33,7 +33,7 @@ public class ForgeDataScript implements INpcScriptHandler { if (compound.hasKey("Scripts")) { this.scripts = NBTTags.GetScriptOld(compound.getTagList("Scripts", 10), this); } else { - this.scripts = NBTTags.GetScript(compound,this); + this.scripts = NBTTags.GetScript(compound, this); } this.scriptLanguage = compound.getString("ScriptLanguage"); if (!ScriptController.Instance.languages.containsKey(scriptLanguage)) { @@ -47,9 +47,9 @@ public class ForgeDataScript implements INpcScriptHandler { } public NBTTagCompound writeToNBT(NBTTagCompound compound) { - compound.setInteger("TotalScripts",this.scripts.size()); + compound.setInteger("TotalScripts", this.scripts.size()); for (int i = 0; i < this.scripts.size(); i++) { - compound.setTag("Tab"+i,this.scripts.get(i).writeToNBT(new NBTTagCompound())); + compound.setTag("Tab" + i, this.scripts.get(i).writeToNBT(new NBTTagCompound())); } compound.setString("ScriptLanguage", this.scriptLanguage); compound.setBoolean("ScriptEnabled", this.enabled); @@ -62,7 +62,7 @@ public class ForgeDataScript implements INpcScriptHandler { } public void callScript(String type, Event event) { - if(this.isEnabled()) { + if (this.isEnabled()) { if (ScriptController.Instance.lastLoaded > this.lastInited || ScriptController.Instance.lastForgeUpdate > this.lastForgeUpdate) { this.lastInited = ScriptController.Instance.lastLoaded; this.lastForgeUpdate = ScriptController.Instance.lastForgeUpdate; @@ -77,7 +77,7 @@ public class ForgeDataScript implements INpcScriptHandler { } for (ScriptContainer script : this.scripts) { - if(script == null || script.errored || !script.hasCode() ) + if (script == null || script.errored || !script.hasCode()) continue; script.run(type, event); diff --git a/src/main/java/noppes/npcs/controllers/data/Frame.java b/src/main/java/noppes/npcs/controllers/data/Frame.java index ffdaad93d..4294b9cf3 100644 --- a/src/main/java/noppes/npcs/controllers/data/Frame.java +++ b/src/main/java/noppes/npcs/controllers/data/Frame.java @@ -12,7 +12,7 @@ import java.util.Map; public class Frame implements IFrame { public Animation parent; - public HashMap frameParts = new HashMap<>(); + public HashMap frameParts = new HashMap<>(); public int duration = 0; boolean customized = false; @@ -22,7 +22,8 @@ public class Frame implements IFrame { private int colorMarker = 0xFFFFFF; private String comment = ""; - public Frame(){} + public Frame() { + } public Frame(int duration) { this.duration = duration; @@ -35,7 +36,7 @@ public class Frame implements IFrame { this.customized = true; } - public HashMap getFrameMap() { + public HashMap getFrameMap() { return frameParts; } @@ -44,14 +45,15 @@ public class Frame implements IFrame { } public IFrame addPart(IFramePart partConfig) { - this.frameParts.put(((FramePart)partConfig).getPart(),(FramePart) partConfig); + this.frameParts.put(((FramePart) partConfig).getPart(), (FramePart) partConfig); return this; } public IFrame removePart(String partName) { try { this.frameParts.remove(EnumAnimationPart.valueOf(partName)); - } catch (IllegalArgumentException ignored) {} + } catch (IllegalArgumentException ignored) { + } return this; } @@ -119,7 +121,7 @@ public class Frame implements IFrame { this.comment = comment; } - public void readFromNBT(NBTTagCompound compound){ + public void readFromNBT(NBTTagCompound compound) { duration = compound.getInteger("Duration"); if (compound.hasKey("ColorMarker")) { this.setColorMarker(compound.getInteger("ColorMarker")); @@ -129,11 +131,11 @@ public class Frame implements IFrame { } // Customized = TRUE if Speed or Smooth Exist - if(compound.hasKey("Speed")){ + if (compound.hasKey("Speed")) { customized = true; speed = compound.getFloat("Speed"); } - if(compound.hasKey("Smooth")){ + if (compound.hasKey("Smooth")) { customized = true; smooth = compound.getByte("Smooth"); } @@ -143,7 +145,7 @@ public class Frame implements IFrame { this.smooth = parent.smooth; } - HashMap frameParts = new HashMap<>(); + HashMap frameParts = new HashMap<>(); NBTTagList list = compound.getTagList("FrameParts", 10); for (int i = 0; i < list.tagCount(); i++) { NBTTagCompound item = list.getCompoundTagAt(i); @@ -153,24 +155,24 @@ public class Frame implements IFrame { framePart.smooth = this.smooth; framePart.speed = this.speed; } - frameParts.put(framePart.part,framePart); + frameParts.put(framePart.part, framePart); } this.frameParts = frameParts; } - public NBTTagCompound writeToNBT(){ + public NBTTagCompound writeToNBT() { NBTTagCompound compound = new NBTTagCompound(); compound.setInteger("Duration", duration); compound.setInteger("ColorMarker", this.colorMarker); compound.setString("Comment", this.comment); - if(customized){ + if (customized) { compound.setFloat("Speed", speed); compound.setByte("Smooth", smooth); } NBTTagList list = new NBTTagList(); - for(FramePart framePart : frameParts.values()){ + for (FramePart framePart : frameParts.values()) { NBTTagCompound item = framePart.writeToNBT(); list.appendTag(item); } @@ -180,9 +182,9 @@ public class Frame implements IFrame { public Frame copy() { Frame frame = new Frame(this.duration); - HashMap frameParts = this.frameParts; - for (Map.Entry entry : frameParts.entrySet()) { - frame.frameParts.put(entry.getKey(),entry.getValue().copy()); + HashMap frameParts = this.frameParts; + for (Map.Entry entry : frameParts.entrySet()) { + frame.frameParts.put(entry.getKey(), entry.getValue().copy()); } frame.parent = this.parent; frame.duration = this.duration; diff --git a/src/main/java/noppes/npcs/controllers/data/FramePart.java b/src/main/java/noppes/npcs/controllers/data/FramePart.java index 2baa7b341..15490dd7e 100644 --- a/src/main/java/noppes/npcs/controllers/data/FramePart.java +++ b/src/main/java/noppes/npcs/controllers/data/FramePart.java @@ -8,232 +8,234 @@ import noppes.npcs.client.ClientEventHandler; import noppes.npcs.constants.EnumAnimationPart; public class FramePart implements IFramePart { - public Animation parent; - public EnumAnimationPart part; - public float[] rotation = {0, 0, 0}; - public float[] pivot = {0, 0, 0}; + public Animation parent; + public EnumAnimationPart part; + public float[] rotation = {0, 0, 0}; + public float[] pivot = {0, 0, 0}; - boolean customized = false; + boolean customized = false; - public float speed = 1.0F; - //0 - Interpolated, 1 - Linear, 2 - None - public byte smooth = 0; + public float speed = 1.0F; + //0 - Interpolated, 1 - Linear, 2 - None + public byte smooth = 0; - //Client-sided fields (unsaved) - public float[] prevRotations = {0,0,0}; - public float[] prevPivots = {0,0,0}; - public float partialRotationTick; - public float partialPivotTick; + //Client-sided fields (unsaved) + public float[] prevRotations = {0, 0, 0}; + public float[] prevPivots = {0, 0, 0}; + public float partialRotationTick; + public float partialPivotTick; - public FramePart(){} + public FramePart() { + } - public FramePart(EnumAnimationPart part){ - this.part = part; - } + public FramePart(EnumAnimationPart part) { + this.part = part; + } - public EnumAnimationPart getPart() { - return part; - } + public EnumAnimationPart getPart() { + return part; + } - public String getName() { - return part.name(); - } + public String getName() { + return part.name(); + } - public int getPartId() { - return part.id; - } + public int getPartId() { + return part.id; + } - public void setPart(EnumAnimationPart part) { - this.part = part; - } + public void setPart(EnumAnimationPart part) { + this.part = part; + } - public IFramePart setPart(String name) { - try { - this.setPart(EnumAnimationPart.valueOf(name)); - } catch (IllegalArgumentException ignored) {} - return this; - } + public IFramePart setPart(String name) { + try { + this.setPart(EnumAnimationPart.valueOf(name)); + } catch (IllegalArgumentException ignored) { + } + return this; + } - public IFramePart setPart(int partId) { - for (EnumAnimationPart enumPart : EnumAnimationPart.values()) { - if (enumPart.id == partId) { - this.setPart(enumPart); - break; - } - } - return this; - } + public IFramePart setPart(int partId) { + for (EnumAnimationPart enumPart : EnumAnimationPart.values()) { + if (enumPart.id == partId) { + this.setPart(enumPart); + break; + } + } + return this; + } - public float[] getRotations() { - return rotation; - } + public float[] getRotations() { + return rotation; + } - public IFramePart setRotations(float[] rotation) { - this.rotation = rotation; - return this; - } + public IFramePart setRotations(float[] rotation) { + this.rotation = rotation; + return this; + } - public float[] getPivots() { - return pivot; - } + public float[] getPivots() { + return pivot; + } - public IFramePart setPivots(float[] pivot) { - this.pivot = pivot; - return this; - } + public IFramePart setPivots(float[] pivot) { + this.pivot = pivot; + return this; + } - public boolean isCustomized() { - return customized; - } + public boolean isCustomized() { + return customized; + } - public IFramePart setCustomized(boolean customized) { - this.customized = customized; - return this; - } + public IFramePart setCustomized(boolean customized) { + this.customized = customized; + return this; + } - public float getSpeed() { - return speed; - } + public float getSpeed() { + return speed; + } - public IFramePart setSpeed(float speed) { - this.speed = speed; - return this; - } + public IFramePart setSpeed(float speed) { + this.speed = speed; + return this; + } - public byte isSmooth() { - return smooth; - } + public byte isSmooth() { + return smooth; + } - public IFramePart setSmooth(byte smooth) { - this.smooth = smooth; - return this; - } + public IFramePart setSmooth(byte smooth) { + this.smooth = smooth; + return this; + } - public void readFromNBT(NBTTagCompound compound){ - part = EnumAnimationPart.valueOf(compound.getString("Part")); - for (int i = 0; i < 3; i++) { - rotation[i] = compound.getFloat("Rotation" + i); - } - for (int i = 0; i < 3; i++) { - pivot[i] = compound.getFloat("Pivot" + i); - } + public void readFromNBT(NBTTagCompound compound) { + part = EnumAnimationPart.valueOf(compound.getString("Part")); + for (int i = 0; i < 3; i++) { + rotation[i] = compound.getFloat("Rotation" + i); + } + for (int i = 0; i < 3; i++) { + pivot[i] = compound.getFloat("Pivot" + i); + } - // Customized = TRUE if Speed or Smooth Exist - if(compound.hasKey("Speed")){ - customized = true; - speed = compound.getFloat("Speed"); - } - if(compound.hasKey("Smooth")){ - customized = true; - smooth = compound.getByte("Smooth"); - } - } + // Customized = TRUE if Speed or Smooth Exist + if (compound.hasKey("Speed")) { + customized = true; + speed = compound.getFloat("Speed"); + } + if (compound.hasKey("Smooth")) { + customized = true; + smooth = compound.getByte("Smooth"); + } + } - public NBTTagCompound writeToNBT(){ - NBTTagCompound compound = new NBTTagCompound(); - compound.setString("Part", part.toString()); - for (int i = 0; i < 3; i++) { - compound.setFloat("Rotation" + i, rotation[i]); - } - for (int i = 0; i < 3; i++) { - compound.setFloat("Pivot" + i, pivot[i]); - } + public NBTTagCompound writeToNBT() { + NBTTagCompound compound = new NBTTagCompound(); + compound.setString("Part", part.toString()); + for (int i = 0; i < 3; i++) { + compound.setFloat("Rotation" + i, rotation[i]); + } + for (int i = 0; i < 3; i++) { + compound.setFloat("Pivot" + i, pivot[i]); + } - if(customized){ - compound.setFloat("Speed", speed); - compound.setByte("Smooth", smooth); - } + if (customized) { + compound.setFloat("Speed", speed); + compound.setByte("Smooth", smooth); + } - return compound; - } + return compound; + } - public FramePart copy() { - FramePart part = new FramePart(this.part); - part.rotation = new float[]{this.rotation[0],this.rotation[1],this.rotation[2]}; - part.pivot = new float[]{this.pivot[0],this.pivot[1],this.pivot[2]}; - part.customized = this.customized; - part.speed = this.speed; - part.smooth = this.smooth; - return part; - } + public FramePart copy() { + FramePart part = new FramePart(this.part); + part.rotation = new float[]{this.rotation[0], this.rotation[1], this.rotation[2]}; + part.pivot = new float[]{this.pivot[0], this.pivot[1], this.pivot[2]}; + part.customized = this.customized; + part.speed = this.speed; + part.smooth = this.smooth; + return part; + } - @SideOnly(Side.CLIENT) - public void interpolateAngles() { - if (parent != null && parent.paused) - return; + @SideOnly(Side.CLIENT) + public void interpolateAngles() { + if (parent != null && parent.paused) + return; - float pi = (float) Math.PI / 180; - if (this.smooth == 2) { - this.prevRotations[0] = this.rotation[0] * pi; - this.prevRotations[1] = this.rotation[1] * pi; - this.prevRotations[2] = this.rotation[2] * pi; - } else if (this.partialRotationTick != ClientEventHandler.partialRenderTick) { - this.partialRotationTick = ClientEventHandler.partialRenderTick; - if (this.smooth == 0) { - this.prevRotations[0] = (this.rotation[0] * pi - this.prevRotations[0]) * Math.abs(this.speed) / 10f + this.prevRotations[0]; - this.prevRotations[1] = (this.rotation[1] * pi - this.prevRotations[1]) * Math.abs(this.speed) / 10f + this.prevRotations[1]; - this.prevRotations[2] = (this.rotation[2] * pi - this.prevRotations[2]) * Math.abs(this.speed) / 10f + this.prevRotations[2]; - } else { - int directionX = Float.compare(this.rotation[0] * pi, this.prevRotations[0]); - this.prevRotations[0] += directionX * this.speed / 10f; - this.prevRotations[0] = directionX == 1 ? - Math.min(this.rotation[0] * pi, this.prevRotations[0]) : Math.max(this.rotation[0] * pi, this.prevRotations[0]); - int directionY = Float.compare(this.rotation[1] * pi, this.prevRotations[1]); - this.prevRotations[1] += directionY * this.speed / 10f; - this.prevRotations[1] = directionY == 1 ? - Math.min(this.rotation[1] * pi, this.prevRotations[1]) : Math.max(this.rotation[1] * pi, this.prevRotations[1]); - int directionZ = Float.compare(this.rotation[2] * pi, this.prevRotations[2]); - this.prevRotations[2] += directionZ * this.speed / 10f; - this.prevRotations[2] = directionZ == 1 ? - Math.min(this.rotation[2] * pi, this.prevRotations[2]) : Math.max(this.rotation[2] * pi, this.prevRotations[2]); - } - } - } + float pi = (float) Math.PI / 180; + if (this.smooth == 2) { + this.prevRotations[0] = this.rotation[0] * pi; + this.prevRotations[1] = this.rotation[1] * pi; + this.prevRotations[2] = this.rotation[2] * pi; + } else if (this.partialRotationTick != ClientEventHandler.partialRenderTick) { + this.partialRotationTick = ClientEventHandler.partialRenderTick; + if (this.smooth == 0) { + this.prevRotations[0] = (this.rotation[0] * pi - this.prevRotations[0]) * Math.abs(this.speed) / 10f + this.prevRotations[0]; + this.prevRotations[1] = (this.rotation[1] * pi - this.prevRotations[1]) * Math.abs(this.speed) / 10f + this.prevRotations[1]; + this.prevRotations[2] = (this.rotation[2] * pi - this.prevRotations[2]) * Math.abs(this.speed) / 10f + this.prevRotations[2]; + } else { + int directionX = Float.compare(this.rotation[0] * pi, this.prevRotations[0]); + this.prevRotations[0] += directionX * this.speed / 10f; + this.prevRotations[0] = directionX == 1 ? + Math.min(this.rotation[0] * pi, this.prevRotations[0]) : Math.max(this.rotation[0] * pi, this.prevRotations[0]); + int directionY = Float.compare(this.rotation[1] * pi, this.prevRotations[1]); + this.prevRotations[1] += directionY * this.speed / 10f; + this.prevRotations[1] = directionY == 1 ? + Math.min(this.rotation[1] * pi, this.prevRotations[1]) : Math.max(this.rotation[1] * pi, this.prevRotations[1]); + int directionZ = Float.compare(this.rotation[2] * pi, this.prevRotations[2]); + this.prevRotations[2] += directionZ * this.speed / 10f; + this.prevRotations[2] = directionZ == 1 ? + Math.min(this.rotation[2] * pi, this.prevRotations[2]) : Math.max(this.rotation[2] * pi, this.prevRotations[2]); + } + } + } - @SideOnly(Side.CLIENT) - public void interpolateOffset() { - if (parent != null && parent.paused) - return; + @SideOnly(Side.CLIENT) + public void interpolateOffset() { + if (parent != null && parent.paused) + return; - if (this.smooth == 2) { - this.prevPivots[0] = this.pivot[0]; - this.prevPivots[1] = this.pivot[1]; - this.prevPivots[2] = this.pivot[2]; - } else if (this.partialPivotTick != ClientEventHandler.partialRenderTick) { - this.partialPivotTick = ClientEventHandler.partialRenderTick; - if (this.smooth == 0) { - this.prevPivots[0] = (this.pivot[0] - this.prevPivots[0]) * Math.abs(this.speed) / 10f + this.prevPivots[0]; - this.prevPivots[1] = (this.pivot[1] - this.prevPivots[1]) * Math.abs(this.speed) / 10f + this.prevPivots[1]; - this.prevPivots[2] = (this.pivot[2] - this.prevPivots[2]) * Math.abs(this.speed) / 10f + this.prevPivots[2]; - } else { - int directionX = Float.compare(this.pivot[0], this.prevPivots[0]); - this.prevPivots[0] += directionX * this.speed / 10f; - this.prevPivots[0] = directionX == 1 ? - Math.min(this.pivot[0],this.prevPivots[0]) : Math.max(this.pivot[0],this.prevPivots[0]); - int directionY = Float.compare(this.pivot[1], this.prevPivots[1]); - this.prevPivots[1] += directionY * this.speed / 10f; - this.prevPivots[1] = directionY == 1 ? - Math.min(this.pivot[1],this.prevPivots[1]) : Math.max(this.pivot[1],this.prevPivots[1]); - int directionZ = Float.compare(this.pivot[2], this.prevPivots[2]); - this.prevPivots[2] += directionZ * this.speed / 10f; - this.prevPivots[2] = directionZ == 1 ? - Math.min(this.pivot[2],this.prevPivots[2]) : Math.max(this.pivot[2],this.prevPivots[2]); - } - } - } + if (this.smooth == 2) { + this.prevPivots[0] = this.pivot[0]; + this.prevPivots[1] = this.pivot[1]; + this.prevPivots[2] = this.pivot[2]; + } else if (this.partialPivotTick != ClientEventHandler.partialRenderTick) { + this.partialPivotTick = ClientEventHandler.partialRenderTick; + if (this.smooth == 0) { + this.prevPivots[0] = (this.pivot[0] - this.prevPivots[0]) * Math.abs(this.speed) / 10f + this.prevPivots[0]; + this.prevPivots[1] = (this.pivot[1] - this.prevPivots[1]) * Math.abs(this.speed) / 10f + this.prevPivots[1]; + this.prevPivots[2] = (this.pivot[2] - this.prevPivots[2]) * Math.abs(this.speed) / 10f + this.prevPivots[2]; + } else { + int directionX = Float.compare(this.pivot[0], this.prevPivots[0]); + this.prevPivots[0] += directionX * this.speed / 10f; + this.prevPivots[0] = directionX == 1 ? + Math.min(this.pivot[0], this.prevPivots[0]) : Math.max(this.pivot[0], this.prevPivots[0]); + int directionY = Float.compare(this.pivot[1], this.prevPivots[1]); + this.prevPivots[1] += directionY * this.speed / 10f; + this.prevPivots[1] = directionY == 1 ? + Math.min(this.pivot[1], this.prevPivots[1]) : Math.max(this.pivot[1], this.prevPivots[1]); + int directionZ = Float.compare(this.pivot[2], this.prevPivots[2]); + this.prevPivots[2] += directionZ * this.speed / 10f; + this.prevPivots[2] = directionZ == 1 ? + Math.min(this.pivot[2], this.prevPivots[2]) : Math.max(this.pivot[2], this.prevPivots[2]); + } + } + } - @SideOnly(Side.CLIENT) - public void jumpToCurrentFrame() { - this.partialRotationTick = ClientEventHandler.partialRenderTick; - this.partialPivotTick = ClientEventHandler.partialRenderTick; + @SideOnly(Side.CLIENT) + public void jumpToCurrentFrame() { + this.partialRotationTick = ClientEventHandler.partialRenderTick; + this.partialPivotTick = ClientEventHandler.partialRenderTick; - this.prevPivots[0] = this.pivot[0]; - this.prevPivots[1] = this.pivot[1]; - this.prevPivots[2] = this.pivot[2]; + this.prevPivots[0] = this.pivot[0]; + this.prevPivots[1] = this.pivot[1]; + this.prevPivots[2] = this.pivot[2]; - float pi = (float) Math.PI / 180; - this.prevRotations[0] = this.rotation[0] * pi; - this.prevRotations[1] = this.rotation[1] * pi; - this.prevRotations[2] = this.rotation[2] * pi; - } + float pi = (float) Math.PI / 180; + this.prevRotations[0] = this.rotation[0] * pi; + this.prevRotations[1] = this.rotation[1] * pi; + this.prevRotations[2] = this.rotation[2] * pi; + } } diff --git a/src/main/java/noppes/npcs/controllers/data/GlobalNPCDataScript.java b/src/main/java/noppes/npcs/controllers/data/GlobalNPCDataScript.java index 60dd3e503..c1a468279 100644 --- a/src/main/java/noppes/npcs/controllers/data/GlobalNPCDataScript.java +++ b/src/main/java/noppes/npcs/controllers/data/GlobalNPCDataScript.java @@ -27,18 +27,20 @@ public class GlobalNPCDataScript implements INpcScriptHandler { public boolean enabled = false; public GlobalNPCDataScript(EntityNPCInterface npc) { - if(npc != null) { + if (npc != null) { this.npc = npc; } } + public void clear() { this.scripts = new ArrayList(); } + public void readFromNBT(NBTTagCompound compound) { if (compound.hasKey("Scripts")) { this.scripts = NBTTags.GetScriptOld(compound.getTagList("Scripts", 10), this); } else { - this.scripts = NBTTags.GetScript(compound,this); + this.scripts = NBTTags.GetScript(compound, this); } this.scriptLanguage = compound.getString("ScriptLanguage"); if (!ScriptController.Instance.languages.containsKey(scriptLanguage)) { @@ -50,10 +52,11 @@ public class GlobalNPCDataScript implements INpcScriptHandler { } this.enabled = compound.getBoolean("ScriptEnabled"); } + public NBTTagCompound writeToNBT(NBTTagCompound compound) { - compound.setInteger("TotalScripts",this.scripts.size()); + compound.setInteger("TotalScripts", this.scripts.size()); for (int i = 0; i < this.scripts.size(); i++) { - compound.setTag("Tab"+i,this.scripts.get(i).writeToNBT(new NBTTagCompound())); + compound.setTag("Tab" + i, this.scripts.get(i).writeToNBT(new NBTTagCompound())); } compound.setString("ScriptLanguage", this.scriptLanguage); compound.setBoolean("ScriptEnabled", this.enabled); @@ -81,7 +84,7 @@ public class GlobalNPCDataScript implements INpcScriptHandler { } for (ScriptContainer script : this.scripts) { - if(script == null || script.errored || !script.hasCode() ) + if (script == null || script.errored || !script.hasCode()) continue; script.run(hookName, event); @@ -92,32 +95,40 @@ public class GlobalNPCDataScript implements INpcScriptHandler { public boolean isClient() { return this.npc.isClientWorld(); } + public boolean getEnabled() { return this.enabled; } + public void setEnabled(boolean bo) { this.enabled = bo; } + public String getLanguage() { return this.scriptLanguage; } + public void setLanguage(String lang) { this.scriptLanguage = lang; } + public void setScripts(List list) { this.scripts = list; } + public List getScripts() { return this.scripts; } + public String noticeString() { - if(this.npc == null) { + if (this.npc == null) { return "Global script"; } else { BlockPos pos = new BlockPos(this.npc); return GlobalNPCDataScript.toStringHelper(this.npc).add("x", pos.getX()).add("y", pos.getY()).add("z", pos.getZ()).toString(); } } + public ICustomNpc getNpc() { if (this.npcAPI == null) { this.npcAPI = (ICustomNpc) NpcAPI.Instance().getIEntity(this.npc); @@ -150,6 +161,7 @@ public class GlobalNPCDataScript implements INpcScriptHandler { private GlobalNPCDataScript.ToStringHelper.ValueHolder holderTail; private boolean omitNullValues; private boolean omitEmptyValues; + private ToStringHelper(String className) { this.holderHead = new GlobalNPCDataScript.ToStringHelper.ValueHolder(); this.holderTail = this.holderHead; @@ -157,81 +169,98 @@ public class GlobalNPCDataScript implements INpcScriptHandler { this.omitEmptyValues = false; this.className = (String) Preconditions.checkNotNull(className); } + public GlobalNPCDataScript.ToStringHelper omitNullValues() { this.omitNullValues = true; return this; } + public GlobalNPCDataScript.ToStringHelper add(String name, @CheckForNull Object value) { return this.addHolder(name, value); } + public GlobalNPCDataScript.ToStringHelper add(String name, boolean value) { return this.addUnconditionalHolder(name, String.valueOf(value)); } + public GlobalNPCDataScript.ToStringHelper add(String name, char value) { return this.addUnconditionalHolder(name, String.valueOf(value)); } + public GlobalNPCDataScript.ToStringHelper add(String name, double value) { return this.addUnconditionalHolder(name, String.valueOf(value)); } + public GlobalNPCDataScript.ToStringHelper add(String name, float value) { return this.addUnconditionalHolder(name, String.valueOf(value)); } + public GlobalNPCDataScript.ToStringHelper add(String name, int value) { return this.addUnconditionalHolder(name, String.valueOf(value)); } + public GlobalNPCDataScript.ToStringHelper add(String name, long value) { return this.addUnconditionalHolder(name, String.valueOf(value)); } + public GlobalNPCDataScript.ToStringHelper addValue(@CheckForNull Object value) { return this.addHolder(value); } + public GlobalNPCDataScript.ToStringHelper addValue(boolean value) { return this.addUnconditionalHolder(String.valueOf(value)); } + public GlobalNPCDataScript.ToStringHelper addValue(char value) { return this.addUnconditionalHolder(String.valueOf(value)); } + public GlobalNPCDataScript.ToStringHelper addValue(double value) { return this.addUnconditionalHolder(String.valueOf(value)); } + public GlobalNPCDataScript.ToStringHelper addValue(float value) { return this.addUnconditionalHolder(String.valueOf(value)); } + public GlobalNPCDataScript.ToStringHelper addValue(int value) { return this.addUnconditionalHolder(String.valueOf(value)); } + public GlobalNPCDataScript.ToStringHelper addValue(long value) { return this.addUnconditionalHolder(String.valueOf(value)); } + private static boolean isEmpty(Object value) { if (value instanceof CharSequence) { - return ((CharSequence)value).length() == 0; + return ((CharSequence) value).length() == 0; } else if (value instanceof Collection) { - return ((Collection)value).isEmpty(); + return ((Collection) value).isEmpty(); } else if (value instanceof Map) { - return ((Map)value).isEmpty(); + return ((Map) value).isEmpty(); } else if (value instanceof Optional) { - return !((Optional)value).isPresent(); + return !((Optional) value).isPresent(); } else if (value instanceof OptionalInt) { - return !((OptionalInt)value).isPresent(); + return !((OptionalInt) value).isPresent(); } else if (value instanceof OptionalLong) { - return !((OptionalLong)value).isPresent(); + return !((OptionalLong) value).isPresent(); } else if (value instanceof OptionalDouble) { - return !((OptionalDouble)value).isPresent(); + return !((OptionalDouble) value).isPresent(); } else if (value instanceof com.google.common.base.Optional) { - return !((com.google.common.base.Optional)value).isPresent(); + return !((com.google.common.base.Optional) value).isPresent(); } else if (value.getClass().isArray()) { return Array.getLength(value) == 0; } else { return false; } } + public String toString() { boolean omitNullValuesSnapshot = this.omitNullValues; boolean omitEmptyValuesSnapshot = this.omitEmptyValues; String nextSeparator = ""; StringBuilder builder = (new StringBuilder(32)).append(this.className).append('{'); - for(GlobalNPCDataScript.ToStringHelper.ValueHolder valueHolder = this.holderHead.next; valueHolder != null; valueHolder = valueHolder.next) { + for (GlobalNPCDataScript.ToStringHelper.ValueHolder valueHolder = this.holderHead.next; valueHolder != null; valueHolder = valueHolder.next) { Object value = valueHolder.value; if (!(valueHolder instanceof GlobalNPCDataScript.ToStringHelper.UnconditionalValueHolder)) { if (value == null) { @@ -257,43 +286,51 @@ public class GlobalNPCDataScript implements INpcScriptHandler { } return builder.append('}').toString(); } + private GlobalNPCDataScript.ToStringHelper.ValueHolder addHolder() { GlobalNPCDataScript.ToStringHelper.ValueHolder valueHolder = new GlobalNPCDataScript.ToStringHelper.ValueHolder(); this.holderTail = this.holderTail.next = valueHolder; return valueHolder; } + private GlobalNPCDataScript.ToStringHelper addHolder(@CheckForNull Object value) { GlobalNPCDataScript.ToStringHelper.ValueHolder valueHolder = this.addHolder(); valueHolder.value = value; return this; } + private GlobalNPCDataScript.ToStringHelper addHolder(String name, @CheckForNull Object value) { GlobalNPCDataScript.ToStringHelper.ValueHolder valueHolder = this.addHolder(); valueHolder.value = value; - valueHolder.name = (String)Preconditions.checkNotNull(name); + valueHolder.name = (String) Preconditions.checkNotNull(name); return this; } + private GlobalNPCDataScript.ToStringHelper.UnconditionalValueHolder addUnconditionalHolder() { GlobalNPCDataScript.ToStringHelper.UnconditionalValueHolder valueHolder = new GlobalNPCDataScript.ToStringHelper.UnconditionalValueHolder(); this.holderTail = this.holderTail.next = valueHolder; return valueHolder; } + private GlobalNPCDataScript.ToStringHelper addUnconditionalHolder(Object value) { GlobalNPCDataScript.ToStringHelper.UnconditionalValueHolder valueHolder = this.addUnconditionalHolder(); valueHolder.value = value; return this; } + private GlobalNPCDataScript.ToStringHelper addUnconditionalHolder(String name, Object value) { GlobalNPCDataScript.ToStringHelper.UnconditionalValueHolder valueHolder = this.addUnconditionalHolder(); valueHolder.value = value; - valueHolder.name = (String)Preconditions.checkNotNull(name); + valueHolder.name = (String) Preconditions.checkNotNull(name); return this; } + private static final class UnconditionalValueHolder extends GlobalNPCDataScript.ToStringHelper.ValueHolder { private UnconditionalValueHolder() { super(); } } + private static class ValueHolder { @CheckForNull String name; @@ -301,10 +338,12 @@ public class GlobalNPCDataScript implements INpcScriptHandler { Object value; @CheckForNull GlobalNPCDataScript.ToStringHelper.ValueHolder next; + private ValueHolder() { } } } + public static GlobalNPCDataScript.ToStringHelper toStringHelper(Object self) { return new GlobalNPCDataScript.ToStringHelper(self.getClass().getSimpleName()); } diff --git a/src/main/java/noppes/npcs/controllers/data/HitboxData.java b/src/main/java/noppes/npcs/controllers/data/HitboxData.java index e4bdfe274..4d2f0263b 100644 --- a/src/main/java/noppes/npcs/controllers/data/HitboxData.java +++ b/src/main/java/noppes/npcs/controllers/data/HitboxData.java @@ -11,12 +11,12 @@ public class HitboxData { public NBTTagCompound writeToNBT(NBTTagCompound nbttagcompound) { nbttagcompound.setBoolean("HitboxEnabled", hitboxEnabled); - if(hitboxEnabled) { - if(widthScale > ConfigMain.HitBoxScaleMax) + if (hitboxEnabled) { + if (widthScale > ConfigMain.HitBoxScaleMax) widthScale = ConfigMain.HitBoxScaleMax; nbttagcompound.setFloat("HitboxWidthScale", widthScale); - if(heightScale > ConfigMain.HitBoxScaleMax) + if (heightScale > ConfigMain.HitBoxScaleMax) heightScale = ConfigMain.HitBoxScaleMax; nbttagcompound.setFloat("HitboxHeightScale", heightScale); } @@ -25,13 +25,13 @@ public class HitboxData { public void readFromNBT(NBTTagCompound nbttagcompound) { hitboxEnabled = nbttagcompound.getBoolean("HitboxEnabled"); - if(hitboxEnabled) { + if (hitboxEnabled) { widthScale = nbttagcompound.getFloat("HitboxWidthScale"); - if(widthScale > ConfigMain.HitBoxScaleMax) + if (widthScale > ConfigMain.HitBoxScaleMax) widthScale = ConfigMain.HitBoxScaleMax; heightScale = nbttagcompound.getFloat("HitboxHeightScale"); - if(heightScale > ConfigMain.HitBoxScaleMax) + if (heightScale > ConfigMain.HitBoxScaleMax) heightScale = ConfigMain.HitBoxScaleMax; } } diff --git a/src/main/java/noppes/npcs/controllers/data/IScriptBlockHandler.java b/src/main/java/noppes/npcs/controllers/data/IScriptBlockHandler.java index ffe7e77e2..62d03c116 100644 --- a/src/main/java/noppes/npcs/controllers/data/IScriptBlockHandler.java +++ b/src/main/java/noppes/npcs/controllers/data/IScriptBlockHandler.java @@ -2,7 +2,7 @@ package noppes.npcs.controllers.data; import noppes.npcs.api.IBlock; -public interface IScriptBlockHandler extends INpcScriptHandler{ +public interface IScriptBlockHandler extends INpcScriptHandler { public IBlock getBlock(); } diff --git a/src/main/java/noppes/npcs/controllers/data/InnDoorData.java b/src/main/java/noppes/npcs/controllers/data/InnDoorData.java index 18397afc8..3a9e89984 100644 --- a/src/main/java/noppes/npcs/controllers/data/InnDoorData.java +++ b/src/main/java/noppes/npcs/controllers/data/InnDoorData.java @@ -1,7 +1,7 @@ package noppes.npcs.controllers.data; public class InnDoorData { - public int x = 0; - public int y = 0; - public int z = 0; + public int x = 0; + public int y = 0; + public int z = 0; } diff --git a/src/main/java/noppes/npcs/controllers/data/Line.java b/src/main/java/noppes/npcs/controllers/data/Line.java index 7385516fc..9571e6f92 100644 --- a/src/main/java/noppes/npcs/controllers/data/Line.java +++ b/src/main/java/noppes/npcs/controllers/data/Line.java @@ -8,66 +8,67 @@ import noppes.npcs.api.handler.data.ILine; public class Line implements ILine { - public Line(){ - - } - public Line(String text){ - this.text = text; - } + public Line() { - public String text = ""; - public String sound = ""; - public boolean hideText = false; - - public ILine copy() { - Line line = new Line(text); - line.sound = sound; - line.hideText = hideText; - return line; - } - - public ILine formatTarget(EntityLivingBase entity) { - if(entity == null) - return this; - Line line = (Line) copy(); - if(entity instanceof EntityPlayer) - line.text = line.text.replace("@target", ((EntityPlayer) entity).getDisplayName()); - else - line.text = line.text.replace("@target", entity.getCommandSenderName()); - return line; - } + } - public ILine formatTarget(IEntityLivingBase entityLivingBase) { - return this.formatTarget(entityLivingBase.getMCEntity()); - } + public Line(String text) { + this.text = text; + } - @Override - public String getText() { - return this.text; - } + public String text = ""; + public String sound = ""; + public boolean hideText = false; - @Override - public void setText(String text) { - this.text = text; - } + public ILine copy() { + Line line = new Line(text); + line.sound = sound; + line.hideText = hideText; + return line; + } - @Override - public String getSound() { - return this.sound; - } + public ILine formatTarget(EntityLivingBase entity) { + if (entity == null) + return this; + Line line = (Line) copy(); + if (entity instanceof EntityPlayer) + line.text = line.text.replace("@target", ((EntityPlayer) entity).getDisplayName()); + else + line.text = line.text.replace("@target", entity.getCommandSenderName()); + return line; + } - @Override - public void setSound(String sound) { - this.sound = sound; - } + public ILine formatTarget(IEntityLivingBase entityLivingBase) { + return this.formatTarget(entityLivingBase.getMCEntity()); + } - @Override - public void hideText(boolean hide) { - this.hideText = hide; - } + @Override + public String getText() { + return this.text; + } - @Override - public boolean hideText() { - return this.hideText; - } + @Override + public void setText(String text) { + this.text = text; + } + + @Override + public String getSound() { + return this.sound; + } + + @Override + public void setSound(String sound) { + this.sound = sound; + } + + @Override + public void hideText(boolean hide) { + this.hideText = hide; + } + + @Override + public boolean hideText() { + return this.hideText; + } } diff --git a/src/main/java/noppes/npcs/controllers/data/Lines.java b/src/main/java/noppes/npcs/controllers/data/Lines.java index c8ffeb6e0..a103532a0 100644 --- a/src/main/java/noppes/npcs/controllers/data/Lines.java +++ b/src/main/java/noppes/npcs/controllers/data/Lines.java @@ -11,88 +11,86 @@ import java.util.List; import java.util.Random; public class Lines implements ILines { - private static final Random random = new Random(); - private int lastLine = -1; + private static final Random random = new Random(); + private int lastLine = -1; - public HashMap lines = new HashMap(); + public HashMap lines = new HashMap(); - public NBTTagCompound writeToNBT() { - NBTTagCompound compound = new NBTTagCompound(); + public NBTTagCompound writeToNBT() { + NBTTagCompound compound = new NBTTagCompound(); NBTTagList nbttaglist = new NBTTagList(); - for(int slot : lines.keySet()) - { - Line line = lines.get(slot); + for (int slot : lines.keySet()) { + Line line = lines.get(slot); NBTTagCompound nbttagcompound = new NBTTagCompound(); nbttagcompound.setInteger("Slot", slot); nbttagcompound.setString("Line", line.text); nbttagcompound.setString("Song", line.sound); - + nbttaglist.appendTag(nbttagcompound); } - - compound.setTag("Lines", nbttaglist); - return compound; - } - public void readNBT(NBTTagCompound compound) { - NBTTagList nbttaglist = compound.getTagList("Lines", 10); + compound.setTag("Lines", nbttaglist); + return compound; + } - HashMap map = new HashMap(); - for(int i = 0; i < nbttaglist.tagCount(); i++) - { + public void readNBT(NBTTagCompound compound) { + NBTTagList nbttaglist = compound.getTagList("Lines", 10); + + HashMap map = new HashMap(); + for (int i = 0; i < nbttaglist.tagCount(); i++) { NBTTagCompound nbttagcompound = nbttaglist.getCompoundTagAt(i); Line line = new Line(); line.text = nbttagcompound.getString("Line"); line.sound = nbttagcompound.getString("Song"); - + map.put(nbttagcompound.getInteger("Slot"), line); } lines = map; - } + } - public ILine createLine(String text) { - return new Line(text); - } + public ILine createLine(String text) { + return new Line(text); + } - public ILine getLine(boolean isRandom) { - if(lines.isEmpty()) - return null; - if(isRandom){ - List lines = new ArrayList(this.lines.values()); - return lines.get(random.nextInt(lines.size())); - } - lastLine++; - while(true){ - lastLine %= 8; - Line line = lines.get(lastLine); - if(line != null) - return line.copy(); - lastLine++; - } - } + public ILine getLine(boolean isRandom) { + if (lines.isEmpty()) + return null; + if (isRandom) { + List lines = new ArrayList(this.lines.values()); + return lines.get(random.nextInt(lines.size())); + } + lastLine++; + while (true) { + lastLine %= 8; + Line line = lines.get(lastLine); + if (line != null) + return line.copy(); + lastLine++; + } + } - public ILine getLine(int lineIndex) { - return lines.get(lineIndex); - } + public ILine getLine(int lineIndex) { + return lines.get(lineIndex); + } - public void setLine(int lineIndex, ILine line) { - lines.put(lineIndex, (Line) line); - } + public void setLine(int lineIndex, ILine line) { + lines.put(lineIndex, (Line) line); + } - public void removeLine(int lineIndex) { - lines.remove(lineIndex); - } + public void removeLine(int lineIndex) { + lines.remove(lineIndex); + } - public void clear() { - lines.clear(); - } + public void clear() { + lines.clear(); + } - public boolean isEmpty() { - return lines.isEmpty(); - } + public boolean isEmpty() { + return lines.isEmpty(); + } - public Integer[] getKeys() { - return lines.keySet().toArray(new Integer[0]); - } + public Integer[] getKeys() { + return lines.keySet().toArray(new Integer[0]); + } } diff --git a/src/main/java/noppes/npcs/controllers/data/LinkedItem.java b/src/main/java/noppes/npcs/controllers/data/LinkedItem.java index 9acf2be16..6144dc480 100644 --- a/src/main/java/noppes/npcs/controllers/data/LinkedItem.java +++ b/src/main/java/noppes/npcs/controllers/data/LinkedItem.java @@ -52,8 +52,8 @@ public class LinkedItem implements ILinkedItem { compound.setTag("Display", this.display.writeToNBT()); - compound.setDouble("DurabilityValue",this.durabilityValue); - compound.setInteger("MaxStackSize",this.stackSize); + compound.setDouble("DurabilityValue", this.durabilityValue); + compound.setInteger("MaxStackSize", this.stackSize); compound.setBoolean("IsTool", this.isTool); compound.setBoolean("IsNormalItem", this.isNormalItem); @@ -248,7 +248,7 @@ public class LinkedItem implements ILinkedItem { public LinkedItemScript getOrCreateScriptHandler() { LinkedItemScript data = getScriptHandler(); if (data == null) - setScriptHandler(data =new LinkedItemScript()); + setScriptHandler(data = new LinkedItemScript()); return data; } } diff --git a/src/main/java/noppes/npcs/controllers/data/LinkedItemScript.java b/src/main/java/noppes/npcs/controllers/data/LinkedItemScript.java index c88b880e2..64c3dd7ff 100644 --- a/src/main/java/noppes/npcs/controllers/data/LinkedItemScript.java +++ b/src/main/java/noppes/npcs/controllers/data/LinkedItemScript.java @@ -108,14 +108,14 @@ public class LinkedItemScript implements INpcScriptHandler { int tab = 0; Iterator var3 = this.getScripts().iterator(); - while(var3.hasNext()) { - ScriptContainer script = (ScriptContainer)var3.next(); + while (var3.hasNext()) { + ScriptContainer script = (ScriptContainer) var3.next(); ++tab; Iterator var5 = script.console.entrySet().iterator(); - while(var5.hasNext()) { - Map.Entry longStringEntry = (Map.Entry)var5.next(); - map.put(longStringEntry.getKey(), " tab " + tab + ":\n" + (String)longStringEntry.getValue()); + while (var5.hasNext()) { + Map.Entry longStringEntry = (Map.Entry) var5.next(); + map.put(longStringEntry.getKey(), " tab " + tab + ":\n" + (String) longStringEntry.getValue()); } } @@ -126,8 +126,8 @@ public class LinkedItemScript implements INpcScriptHandler { public void clearConsole() { Iterator var1 = this.getScripts().iterator(); - while(var1.hasNext()) { - ScriptContainer script = (ScriptContainer)var1.next(); + while (var1.hasNext()) { + ScriptContainer script = (ScriptContainer) var1.next(); script.console.clear(); } } diff --git a/src/main/java/noppes/npcs/controllers/data/Magic.java b/src/main/java/noppes/npcs/controllers/data/Magic.java index 6e1dc98a2..d641f935c 100644 --- a/src/main/java/noppes/npcs/controllers/data/Magic.java +++ b/src/main/java/noppes/npcs/controllers/data/Magic.java @@ -24,7 +24,8 @@ public class Magic implements IMagic { public String iconTexture = ""; public Map interactions = new HashMap<>(); - public Magic() {} + public Magic() { + } public Magic(int id, String name, int color) { this.name = name; @@ -46,7 +47,7 @@ public class Magic implements IMagic { type = EnumTextureType.values()[compound.getInteger("Type")]; iconTexture = compound.getString("IconTexture"); - if(type == EnumTextureType.ITEM && !iconTexture.isEmpty()){ + if (type == EnumTextureType.ITEM && !iconTexture.isEmpty()) { String[] parts = iconTexture.split(":"); if (parts.length == 2) { String modID = parts[0]; @@ -57,9 +58,9 @@ public class Magic implements IMagic { } interactions.clear(); - if(compound.hasKey("Interactions")) { + if (compound.hasKey("Interactions")) { NBTTagList interactionsList = compound.getTagList("Interactions", 10); - for (int i = 0; i < interactionsList.tagCount(); i++){ + for (int i = 0; i < interactionsList.tagCount(); i++) { NBTTagCompound interactionTag = interactionsList.getCompoundTagAt(i); int magicId = interactionTag.getInteger("MagicID"); float percentage = interactionTag.getFloat("Percentage"); @@ -76,7 +77,7 @@ public class Magic implements IMagic { compound.setString("IconTexture", iconTexture); compound.setInteger("Type", type.ordinal()); NBTTagList interactionsList = new NBTTagList(); - for (Map.Entry entry : interactions.entrySet()){ + for (Map.Entry entry : interactions.entrySet()) { NBTTagCompound interactionTag = new NBTTagCompound(); interactionTag.setInteger("MagicID", entry.getKey()); interactionTag.setFloat("Percentage", entry.getValue()); @@ -84,7 +85,7 @@ public class Magic implements IMagic { } compound.setTag("Interactions", interactionsList); - if(type == EnumTextureType.ITEM && !iconTexture.isEmpty()){ + if (type == EnumTextureType.ITEM && !iconTexture.isEmpty()) { String[] parts = iconTexture.split(":"); if (parts.length == 2) { String modID = parts[0]; @@ -130,7 +131,7 @@ public class Magic implements IMagic { public void setItem(ItemStack item) { GameRegistry.UniqueIdentifier identifier = GameRegistry.findUniqueIdentifierFor(item.getItem()); - if(identifier != null){ + if (identifier != null) { this.item = item; this.type = EnumTextureType.ITEM; this.iconTexture = identifier.modId + ":" + identifier.name; diff --git a/src/main/java/noppes/npcs/controllers/data/MagicCycle.java b/src/main/java/noppes/npcs/controllers/data/MagicCycle.java index 70ae2e2e1..2e7ea8004 100644 --- a/src/main/java/noppes/npcs/controllers/data/MagicCycle.java +++ b/src/main/java/noppes/npcs/controllers/data/MagicCycle.java @@ -16,7 +16,9 @@ public class MagicCycle { public String displayName = ""; public EnumDiagramLayout layout = EnumDiagramLayout.CIRCULAR; public HashMap associations = new HashMap<>(); - public MagicCycle() {} + + public MagicCycle() { + } public void readNBT(NBTTagCompound compound) { id = compound.getInteger("ID"); diff --git a/src/main/java/noppes/npcs/controllers/data/MagicData.java b/src/main/java/noppes/npcs/controllers/data/MagicData.java index 5cd46da42..c6365daa1 100644 --- a/src/main/java/noppes/npcs/controllers/data/MagicData.java +++ b/src/main/java/noppes/npcs/controllers/data/MagicData.java @@ -19,7 +19,7 @@ public class MagicData implements IMagicData { public void readToNBT(NBTTagCompound compound) { NBTTagCompound magicData = compound.getCompoundTag("MagicData"); magics.clear(); - if(magicData == null) + if (magicData == null) return; for (Object key : magicData.func_150296_c()) { int i = Integer.parseInt((String) key); diff --git a/src/main/java/noppes/npcs/controllers/data/MarkData.java b/src/main/java/noppes/npcs/controllers/data/MarkData.java index 15f89ddda..f4d3c87c5 100644 --- a/src/main/java/noppes/npcs/controllers/data/MarkData.java +++ b/src/main/java/noppes/npcs/controllers/data/MarkData.java @@ -19,49 +19,49 @@ import java.util.List; public class MarkData implements IExtendedEntityProperties { private static final String CNPCMARK = "cnpcmark"; - private EntityLivingBase entity; + private EntityLivingBase entity; - public List marks = new ArrayList(); + public List marks = new ArrayList(); - public void setNBT(NBTTagCompound compound){ - List marks = new ArrayList(); - NBTTagList list = compound.getTagList("marks", 10); - for(int i = 0; i < list.tagCount(); i++){ - NBTTagCompound c = list.getCompoundTagAt(i); - Mark m = new Mark(); - m.type = c.getInteger("type"); - m.color = c.getInteger("color"); - m.availability.readFromNBT(c.getCompoundTag("availability")); - marks.add(m); - } - this.marks = marks; - } + public void setNBT(NBTTagCompound compound) { + List marks = new ArrayList(); + NBTTagList list = compound.getTagList("marks", 10); + for (int i = 0; i < list.tagCount(); i++) { + NBTTagCompound c = list.getCompoundTagAt(i); + Mark m = new Mark(); + m.type = c.getInteger("type"); + m.color = c.getInteger("color"); + m.availability.readFromNBT(c.getCompoundTag("availability")); + marks.add(m); + } + this.marks = marks; + } - public NBTTagCompound getNBT() { - NBTTagCompound compound = new NBTTagCompound(); - NBTTagList list = new NBTTagList(); - for(Mark m : marks){ - NBTTagCompound c = new NBTTagCompound(); - c.setInteger("type", m.type); - c.setInteger("color", m.color); - c.setTag("availability", m.availability.writeToNBT(new NBTTagCompound())); - list.appendTag(c); - } - compound.setTag("marks", list); - return compound; - } + public NBTTagCompound getNBT() { + NBTTagCompound compound = new NBTTagCompound(); + NBTTagList list = new NBTTagList(); + for (Mark m : marks) { + NBTTagCompound c = new NBTTagCompound(); + c.setInteger("type", m.type); + c.setInteger("color", m.color); + c.setTag("availability", m.availability.writeToNBT(new NBTTagCompound())); + list.appendTag(c); + } + compound.setTag("marks", list); + return compound; + } public static boolean has(EntityLivingBase entity) { return entity.getExtendedProperties(CNPCMARK) != null; } - public static MarkData get(EntityNPCInterface npc){ - if(!MarkData.has(npc)){ + public static MarkData get(EntityNPCInterface npc) { + if (!MarkData.has(npc)) { npc.registerExtendedProperties(CNPCMARK, new MarkData()); } MarkData data = (MarkData) npc.getExtendedProperties(CNPCMARK); - if(data.entity == null){ + if (data.entity == null) { data.entity = npc; data.setNBT(npc.getEntityData().getCompoundTag(CNPCMARK)); } @@ -96,48 +96,50 @@ public class MarkData implements IExtendedEntityProperties { } @Override - public void loadNBTData(NBTTagCompound compound) {} + public void loadNBTData(NBTTagCompound compound) { + } @Override - public void init(Entity entity, World world) {} + public void init(Entity entity, World world) { + } public void syncClients() { PacketHandler.Instance.sendToAll(new MarkDataPacket(entity.getEntityId(), getNBT())); } public class Mark implements IMark { - public int type = MarkType.NONE; - public Availability availability = new Availability(); - public int color = 0xFFED51; + public int type = MarkType.NONE; + public Availability availability = new Availability(); + public int color = 0xFFED51; - @Override - public IAvailability getAvailability() { - return availability; - } + @Override + public IAvailability getAvailability() { + return availability; + } - @Override - public int getColor() { - return color; - } + @Override + public int getColor() { + return color; + } - @Override - public void setColor(int color) { - this.color = color; - } + @Override + public void setColor(int color) { + this.color = color; + } - @Override - public int getType() { - return type; - } + @Override + public int getType() { + return type; + } - @Override - public void setType(int type) { - this.type = type; - } + @Override + public void setType(int type) { + this.type = type; + } - @Override - public void update() { - MarkData.this.syncClients(); - } - } + @Override + public void update() { + MarkData.this.syncClients(); + } + } } diff --git a/src/main/java/noppes/npcs/controllers/data/Party.java b/src/main/java/noppes/npcs/controllers/data/Party.java index d5475a438..fc347d8ee 100644 --- a/src/main/java/noppes/npcs/controllers/data/Party.java +++ b/src/main/java/noppes/npcs/controllers/data/Party.java @@ -93,8 +93,8 @@ public class Party implements IParty { } public EnumPartyObjectives getObjectiveRequirement() { - if(getQuestData() != null){ - if(getQuestData().quest != null){ + if (getQuestData() != null) { + if (getQuestData().quest != null) { return getQuestData().quest.partyOptions.objectiveRequirement; } } @@ -114,7 +114,7 @@ public class Party implements IParty { public boolean addPlayer(EntityPlayer player) { if (player == null) return false; - if(partyMembers.containsKey(player.getUniqueID())){ + if (partyMembers.containsKey(player.getUniqueID())) { return false; } @@ -130,12 +130,12 @@ public class Party implements IParty { if (player == null) return false; UUID uuid = player.getUniqueID(); - if(partyMembers.containsKey(uuid)){ + if (partyMembers.containsKey(uuid)) { partyMembers.remove(uuid); partyOrder.remove(uuid); - if(uuid.equals(partyLeader)){ - if(partyMembers.size() > 0){ + if (uuid.equals(partyLeader)) { + if (partyMembers.size() > 0) { partyLeader = partyOrder.get(0); } } @@ -151,11 +151,11 @@ public class Party implements IParty { public boolean removePlayer(UUID uuid) { if (uuid == null) return false; - if(partyMembers.containsKey(uuid)){ + if (partyMembers.containsKey(uuid)) { partyMembers.remove(uuid); partyOrder.remove(uuid); - if(uuid.equals(partyLeader)){ - if(!partyMembers.isEmpty()){ + if (uuid.equals(partyLeader)) { + if (!partyMembers.isEmpty()) { partyLeader = partyOrder.get(0); } } @@ -179,12 +179,12 @@ public class Party implements IParty { @Override public boolean addPlayer(IPlayer player) { - return player != null && this.addPlayer((EntityPlayerMP)player.getMCEntity()); + return player != null && this.addPlayer((EntityPlayerMP) player.getMCEntity()); } @Override public boolean removePlayer(IPlayer player) { - return player != null && this.removePlayer((EntityPlayerMP)player.getMCEntity()); + return player != null && this.removePlayer((EntityPlayerMP) player.getMCEntity()); } public boolean hasPlayer(EntityPlayer player) { @@ -193,16 +193,16 @@ public class Party implements IParty { @Override public boolean hasPlayer(IPlayer player) { - if(player == null) + if (player == null) return false; - EntityPlayer entityPlayer = (EntityPlayer)player.getMCEntity(); + EntityPlayer entityPlayer = (EntityPlayer) player.getMCEntity(); return partyMembers.containsKey(entityPlayer.getUniqueID()); } @Override public boolean hasPlayer(String playerName) { UUID uuid = getUUID(playerName); - if (uuid == null){ + if (uuid == null) { return false; } return partyMembers.containsKey(uuid); @@ -221,13 +221,13 @@ public class Party implements IParty { } } - public boolean setLeader(EntityPlayer player){ + public boolean setLeader(EntityPlayer player) { UUID uuid = player.getUniqueID(); - if(partyLeader != null && partyLeader.equals(uuid)){ + if (partyLeader != null && partyLeader.equals(uuid)) { return false; } - if(!partyMembers.containsKey(uuid)){ + if (!partyMembers.containsKey(uuid)) { return false; } @@ -274,7 +274,7 @@ public class Party implements IParty { // Called when Set Quest is Called @Override - public boolean validateQuest(int questID, boolean sendLeaderMessages){ + public boolean validateQuest(int questID, boolean sendLeaderMessages) { IQuest quest = QuestController.Instance.get(questID); if (quest == null) { return false; @@ -304,7 +304,7 @@ public class Party implements IParty { EnumPartyRequirements partyRequirements = EnumPartyRequirements.values()[partyReq]; if (partyRequirements == EnumPartyRequirements.Leader) { boolean leaderBool = isValidLeaderQuest(leader, questID); - if(!leaderBool){ + if (!leaderBool) { sendInfoMessage(leader, "\u00A7cYou are invalid for this quest", sendLeaderMessages); } return leaderBool; @@ -355,7 +355,7 @@ public class Party implements IParty { } private void sendInfoMessage(EntityPlayer player, String message, boolean send) { - if(!send) + if (!send) return; player.addChatMessage(new ChatComponentText(String.format("\u00A7c%s", message))); @@ -376,12 +376,13 @@ public class Party implements IParty { try { BufferedReader in = new BufferedReader(new InputStreamReader(new URL("https://api.mojang.com/users/profiles/minecraft/" + name).openStream())); String uuidString; - uuidString = (((JsonObject)new JsonParser().parse(in)).get("id")).toString().replaceAll("\"", ""); + uuidString = (((JsonObject) new JsonParser().parse(in)).get("id")).toString().replaceAll("\"", ""); uuidString = uuidString.replaceAll("(\\w{8})(\\w{4})(\\w{4})(\\w{4})(\\w{12})", "$1-$2-$3-$4-$5"); in.close(); uuid = UUID.fromString(uuidString); - } catch (Exception ignored) {} + } catch (Exception ignored) { + } return uuid; } @@ -441,14 +442,14 @@ public class Party implements IParty { } @Override - public void updateQuestObjectiveData(){ + public void updateQuestObjectiveData() { if (FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER) { PartyController.Instance().pingPartyQuestObjectiveUpdate(this); } } @Override - public void updatePartyData(){ + public void updatePartyData() { if (FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER) { PartyController.Instance().pingPartyUpdate(this); } diff --git a/src/main/java/noppes/npcs/controllers/data/PartyOptions.java b/src/main/java/noppes/npcs/controllers/data/PartyOptions.java index 18e44c83b..7fb46a717 100644 --- a/src/main/java/noppes/npcs/controllers/data/PartyOptions.java +++ b/src/main/java/noppes/npcs/controllers/data/PartyOptions.java @@ -10,123 +10,120 @@ import noppes.npcs.constants.EnumPartyRequirements; import java.util.Vector; public class PartyOptions implements IPartyOptions { - public boolean allowParty = false; + public boolean allowParty = false; public boolean onlyParty = false; public EnumPartyRequirements partyRequirements = EnumPartyRequirements.Leader; public EnumPartyExchange rewardControl = EnumPartyExchange.Leader; - public EnumPartyExchange completeFor = EnumPartyExchange.Leader; + public EnumPartyExchange completeFor = EnumPartyExchange.Leader; public EnumPartyExchange executeCommand = EnumPartyExchange.Leader; public EnumPartyObjectives objectiveRequirement = EnumPartyObjectives.Shared; public int minPartySize = ConfigMain.DefaultMinPartySize; - public int maxPartySize = ConfigMain.DefaultMaxPartySize; + public int maxPartySize = ConfigMain.DefaultMaxPartySize; - public void readFromNBT(NBTTagCompound compound) - { - // Party Management - allowParty = compound.getBoolean("AllowParty"); - if(allowParty){ + public void readFromNBT(NBTTagCompound compound) { + // Party Management + allowParty = compound.getBoolean("AllowParty"); + if (allowParty) { onlyParty = compound.getBoolean("OnlyParty"); - partyRequirements = EnumPartyRequirements.values()[compound.getInteger("PartyRequirements")]; - rewardControl = EnumPartyExchange.values()[compound.getInteger("RewardControl")]; - completeFor = EnumPartyExchange.values()[compound.getInteger("CompleteFor")]; + partyRequirements = EnumPartyRequirements.values()[compound.getInteger("PartyRequirements")]; + rewardControl = EnumPartyExchange.values()[compound.getInteger("RewardControl")]; + completeFor = EnumPartyExchange.values()[compound.getInteger("CompleteFor")]; executeCommand = EnumPartyExchange.values()[compound.getInteger("ExecuteCommand")]; minPartySize = compound.getInteger("MinPartySize"); - maxPartySize = compound.getInteger("MaxPartySize"); + maxPartySize = compound.getInteger("MaxPartySize"); objectiveRequirement = EnumPartyObjectives.values()[compound.getInteger("ObjectiveRequirement")]; - } - else { - if(compound.hasKey("OnlyParty")){ + } else { + if (compound.hasKey("OnlyParty")) { compound.removeTag("OnlyParty"); } - if(compound.hasKey("PartyRequirements")){ - compound.removeTag("PartyRequirements"); - } - if(compound.hasKey("RewardControl")){ - compound.removeTag("RewardControl"); - } - if(compound.hasKey("CompleteFor")){ - compound.removeTag("CompleteFor"); - } - if(compound.hasKey("ExecuteCommand")){ + if (compound.hasKey("PartyRequirements")) { + compound.removeTag("PartyRequirements"); + } + if (compound.hasKey("RewardControl")) { + compound.removeTag("RewardControl"); + } + if (compound.hasKey("CompleteFor")) { + compound.removeTag("CompleteFor"); + } + if (compound.hasKey("ExecuteCommand")) { compound.removeTag("ExecuteCommand"); } - if(compound.hasKey("MinPartySize")){ + if (compound.hasKey("MinPartySize")) { compound.removeTag("MinPartySize"); } - if(compound.hasKey("MaxPartySize")){ - compound.removeTag("MaxPartySize"); - } - if(compound.hasKey("ObjectiveRequirement")){ + if (compound.hasKey("MaxPartySize")) { + compound.removeTag("MaxPartySize"); + } + if (compound.hasKey("ObjectiveRequirement")) { compound.removeTag("ObjectiveRequirement"); } onlyParty = false; partyRequirements = EnumPartyRequirements.Leader; - rewardControl = EnumPartyExchange.Leader; - completeFor = EnumPartyExchange.Leader; + rewardControl = EnumPartyExchange.Leader; + completeFor = EnumPartyExchange.Leader; executeCommand = EnumPartyExchange.Leader; minPartySize = ConfigMain.DefaultMinPartySize; - maxPartySize = ConfigMain.DefaultMaxPartySize; + maxPartySize = ConfigMain.DefaultMaxPartySize; objectiveRequirement = EnumPartyObjectives.Shared; - } + } } - public NBTTagCompound writeToNBT() - { - NBTTagCompound compound = new NBTTagCompound(); - compound.setBoolean("AllowParty", allowParty); - if(allowParty){ + + public NBTTagCompound writeToNBT() { + NBTTagCompound compound = new NBTTagCompound(); + compound.setBoolean("AllowParty", allowParty); + if (allowParty) { compound.setBoolean("OnlyParty", onlyParty); - compound.setInteger("PartyRequirements", partyRequirements.ordinal()); - compound.setInteger("RewardControl", rewardControl.ordinal()); - compound.setInteger("CompleteFor", completeFor.ordinal()); + compound.setInteger("PartyRequirements", partyRequirements.ordinal()); + compound.setInteger("RewardControl", rewardControl.ordinal()); + compound.setInteger("CompleteFor", completeFor.ordinal()); compound.setInteger("ExecuteCommand", executeCommand.ordinal()); compound.setInteger("MinPartySize", minPartySize); - compound.setInteger("MaxPartySize", maxPartySize); + compound.setInteger("MaxPartySize", maxPartySize); compound.setInteger("ObjectiveRequirement", objectiveRequirement.ordinal()); - } - else { - if(compound.hasKey("OnlyParty")){ + } else { + if (compound.hasKey("OnlyParty")) { compound.removeTag("OnlyParty"); } - if(compound.hasKey("PartyRequirements")){ - compound.removeTag("PartyRequirements"); - } - if(compound.hasKey("RewardControl")){ - compound.removeTag("RewardControl"); - } - if(compound.hasKey("CompleteFor")){ - compound.removeTag("CompleteFor"); - } - if(compound.hasKey("ExecuteCommand")){ + if (compound.hasKey("PartyRequirements")) { + compound.removeTag("PartyRequirements"); + } + if (compound.hasKey("RewardControl")) { + compound.removeTag("RewardControl"); + } + if (compound.hasKey("CompleteFor")) { + compound.removeTag("CompleteFor"); + } + if (compound.hasKey("ExecuteCommand")) { compound.removeTag("ExecuteCommand"); } - if(compound.hasKey("MinPartySize")){ + if (compound.hasKey("MinPartySize")) { compound.removeTag("MinPartySize"); } - if(compound.hasKey("MaxPartySize")){ - compound.removeTag("MaxPartySize"); - } - if(compound.hasKey("ObjectiveRequirement")){ + if (compound.hasKey("MaxPartySize")) { + compound.removeTag("MaxPartySize"); + } + if (compound.hasKey("ObjectiveRequirement")) { compound.removeTag("ObjectiveRequirement"); } - } + } - return compound; + return compound; } @Override - public boolean isAllowParty() { - return allowParty; - } + public boolean isAllowParty() { + return allowParty; + } @Override - public void setAllowParty(boolean allowParty) { - this.allowParty = allowParty; - } + public void setAllowParty(boolean allowParty) { + this.allowParty = allowParty; + } @Override public boolean isOnlyParty() { @@ -139,43 +136,43 @@ public class PartyOptions implements IPartyOptions { } @Override - public int getPartyRequirements() { - return partyRequirements.ordinal(); - } + public int getPartyRequirements() { + return partyRequirements.ordinal(); + } @Override - public void setPartyRequirements(int partyReq) { - if (partyReq < 0 || partyReq >= EnumPartyRequirements.values().length) { - return; - } - this.partyRequirements = EnumPartyRequirements.values()[partyReq]; - } + public void setPartyRequirements(int partyReq) { + if (partyReq < 0 || partyReq >= EnumPartyRequirements.values().length) { + return; + } + this.partyRequirements = EnumPartyRequirements.values()[partyReq]; + } @Override - public int getRewardControl() { - return rewardControl.ordinal(); - } + public int getRewardControl() { + return rewardControl.ordinal(); + } @Override - public void setRewardControl(int rewardCon) { - if (rewardCon < 0 || rewardCon >= EnumPartyExchange.values().length) { - return; - } - this.rewardControl = EnumPartyExchange.values()[rewardCon]; - } + public void setRewardControl(int rewardCon) { + if (rewardCon < 0 || rewardCon >= EnumPartyExchange.values().length) { + return; + } + this.rewardControl = EnumPartyExchange.values()[rewardCon]; + } @Override - public int getCompleteFor() { - return completeFor.ordinal(); - } + public int getCompleteFor() { + return completeFor.ordinal(); + } @Override - public void setCompleteFor(int compFor) { - if (compFor < 0 || compFor >= EnumPartyExchange.values().length) { - return; - } - this.completeFor = EnumPartyExchange.values()[compFor]; - } + public void setCompleteFor(int compFor) { + if (compFor < 0 || compFor >= EnumPartyExchange.values().length) { + return; + } + this.completeFor = EnumPartyExchange.values()[compFor]; + } @Override public int getExecuteCommandFor() { @@ -210,31 +207,31 @@ public class PartyOptions implements IPartyOptions { @Override public void setMinPartySize(int newSize) { - if(newSize < 1) + if (newSize < 1) newSize = 1; - if(newSize > maxPartySize) + if (newSize > maxPartySize) newSize = maxPartySize; minPartySize = newSize; } @Override - public int getMaxPartySize() { - return maxPartySize; - } + public int getMaxPartySize() { + return maxPartySize; + } - @Override - public void setMaxPartySize(int newSize) { - if(newSize < minPartySize) + @Override + public void setMaxPartySize(int newSize) { + if (newSize < minPartySize) newSize = minPartySize; - maxPartySize = newSize; - } + maxPartySize = newSize; + } public Vector getPartyOptionsList() { Vector vec = new Vector(); - if(onlyParty){ + if (onlyParty) { vec.add("party.only" + ":" + "gui.yes"); } vec.add("party.partyRequirements" + ":" + partyRequirements.name); diff --git a/src/main/java/noppes/npcs/controllers/data/PlayerBankData.java b/src/main/java/noppes/npcs/controllers/data/PlayerBankData.java index 41fed1fbb..1c68ee862 100644 --- a/src/main/java/noppes/npcs/controllers/data/PlayerBankData.java +++ b/src/main/java/noppes/npcs/controllers/data/PlayerBankData.java @@ -8,58 +8,60 @@ import noppes.npcs.controllers.BankController; import java.util.HashMap; public class PlayerBankData implements IPlayerBankData { - private final PlayerData parent; - public HashMap banks; + private final PlayerData parent; + public HashMap banks; - public PlayerBankData(PlayerData parent){ - banks = new HashMap(); - this.parent = parent; - } - - public void loadNBTData(NBTTagCompound compound) { - HashMap banks = new HashMap(); + public PlayerBankData(PlayerData parent) { + banks = new HashMap(); + this.parent = parent; + } + + public void loadNBTData(NBTTagCompound compound) { + HashMap banks = new HashMap(); NBTTagList list = compound.getTagList("BankData", 10); - if(list == null){ - return; + if (list == null) { + return; } - for(int i = 0; i < list.tagCount(); i++) - { + for (int i = 0; i < list.tagCount(); i++) { NBTTagCompound nbttagcompound = list.getCompoundTagAt(i); - BankData data = new BankData(); + BankData data = new BankData(); data.readNBT(nbttagcompound); banks.put(data.bankId, data); } this.banks = banks; - } + } - public void saveNBTData(NBTTagCompound playerData){ - NBTTagList list = new NBTTagList(); - for(BankData data : banks.values()){ - NBTTagCompound nbttagcompound = new NBTTagCompound(); - data.writeNBT(nbttagcompound); - list.appendTag(nbttagcompound); - } - playerData.setTag("BankData", list); - } - + public void saveNBTData(NBTTagCompound playerData) { + NBTTagList list = new NBTTagList(); + for (BankData data : banks.values()) { + NBTTagCompound nbttagcompound = new NBTTagCompound(); + data.writeNBT(nbttagcompound); + list.appendTag(nbttagcompound); + } + playerData.setTag("BankData", list); + } - public BankData getBank(int bankId) { - return banks.get(bankId); - } - public BankData getBankOrDefault(int bankId) { - BankData data = banks.get(bankId); - if(data != null) - return data; - Bank bank = BankController.getInstance().getBank(bankId); - return banks.get(bank.id); - } - public boolean hasBank(int bank) { - return banks.containsKey(bank); - } - public void loadNew(int bank) { - BankData data = new BankData(); - data.bankId = bank; - banks.put(bank, data); - - } + + public BankData getBank(int bankId) { + return banks.get(bankId); + } + + public BankData getBankOrDefault(int bankId) { + BankData data = banks.get(bankId); + if (data != null) + return data; + Bank bank = BankController.getInstance().getBank(bankId); + return banks.get(bank.id); + } + + public boolean hasBank(int bank) { + return banks.containsKey(bank); + } + + public void loadNew(int bank) { + BankData data = new BankData(); + data.bankId = bank; + banks.put(bank, data); + + } } diff --git a/src/main/java/noppes/npcs/controllers/data/PlayerData.java b/src/main/java/noppes/npcs/controllers/data/PlayerData.java index cdce29272..f8eda5914 100644 --- a/src/main/java/noppes/npcs/controllers/data/PlayerData.java +++ b/src/main/java/noppes/npcs/controllers/data/PlayerData.java @@ -38,43 +38,43 @@ import java.util.HashSet; import java.util.UUID; public class PlayerData implements IExtendedEntityProperties, IPlayerData { - public PlayerDialogData dialogData = new PlayerDialogData(this); - public PlayerBankData bankData = new PlayerBankData(this); - public PlayerQuestData questData = new PlayerQuestData(this); - public PlayerTransportData transportData = new PlayerTransportData(this); - public PlayerFactionData factionData = new PlayerFactionData(this); - public PlayerItemGiverData itemgiverData = new PlayerItemGiverData(this); - public PlayerMailData mailData = new PlayerMailData(this); - public AnimationData animationData = new AnimationData(this); + public PlayerDialogData dialogData = new PlayerDialogData(this); + public PlayerBankData bankData = new PlayerBankData(this); + public PlayerQuestData questData = new PlayerQuestData(this); + public PlayerTransportData transportData = new PlayerTransportData(this); + public PlayerFactionData factionData = new PlayerFactionData(this); + public PlayerItemGiverData itemgiverData = new PlayerItemGiverData(this); + public PlayerMailData mailData = new PlayerMailData(this); + public AnimationData animationData = new AnimationData(this); public PlayerEffectData effectData = new PlayerEffectData(this); - public DataTimers timers = new DataTimers(this); - public DataSkinOverlays skinOverlays = new DataSkinOverlays(this); + public DataTimers timers = new DataTimers(this); + public DataSkinOverlays skinOverlays = new DataSkinOverlays(this); public MagicData magicData = new MagicData(); - public EntityNPCInterface editingNpc; - public NBTTagCompound cloned; + public EntityNPCInterface editingNpc; + public NBTTagCompound cloned; - public UUID partyUUID = null; - private final HashSet partyInvites = new HashSet<>(); + public UUID partyUUID = null; + private final HashSet partyInvites = new HashSet<>(); - public EntityPlayer player; + public EntityPlayer player; - public String playername = ""; - public String uuid = ""; + public String playername = ""; + public String uuid = ""; - private EntityNPCInterface activeCompanion = null; - public int companionID = 0; + private EntityNPCInterface activeCompanion = null; + public int companionID = 0; - public boolean isGUIOpen = false; + public boolean isGUIOpen = false; public boolean hadInteract = true; public boolean updateClient = false; - public ScreenSize screenSize = new ScreenSize(-1,-1); + public ScreenSize screenSize = new ScreenSize(-1, -1); public int profileSlot = 0; - public void onLogin() { + public void onLogin() { // Continue playing animation for self when re-logging AnimationData animationData = this.animationData; if (animationData != null && animationData.isClientAnimating()) { @@ -92,57 +92,57 @@ public class PlayerData implements IExtendedEntityProperties, IPlayerData { } } - public void onLogout() { - this.partyInvites.clear(); - } + public void onLogout() { + this.partyInvites.clear(); + } - @Override - public void saveNBTData(NBTTagCompound nbtTagCompound) { - } + @Override + public void saveNBTData(NBTTagCompound nbtTagCompound) { + } - @Override - public void loadNBTData(NBTTagCompound compound) { - } + @Override + public void loadNBTData(NBTTagCompound compound) { + } - public void setNBT(NBTTagCompound data){ - dialogData.loadNBTData(data); - bankData.loadNBTData(data); - questData.loadNBTData(data); - transportData.loadNBTData(data); - factionData.loadNBTData(data); - itemgiverData.loadNBTData(data); - mailData.loadNBTData(data); - timers.readFromNBT(data); - skinOverlays.readFromNBT(data); - animationData.readFromNBT(data); + public void setNBT(NBTTagCompound data) { + dialogData.loadNBTData(data); + bankData.loadNBTData(data); + questData.loadNBTData(data); + transportData.loadNBTData(data); + factionData.loadNBTData(data); + itemgiverData.loadNBTData(data); + mailData.loadNBTData(data); + timers.readFromNBT(data); + skinOverlays.readFromNBT(data); + animationData.readFromNBT(data); effectData.readFromNBT(data); magicData.readToNBT(data); - if(player != null){ - playername = player.getCommandSenderName(); - uuid = player.getPersistentID().toString(); - } - else{ - playername = data.getString("PlayerName"); - uuid = data.getString("UUID"); - } - companionID = data.getInteger("PlayerCompanionId"); + if (player != null) { + playername = player.getCommandSenderName(); + uuid = player.getPersistentID().toString(); + } else { + playername = data.getString("PlayerName"); + uuid = data.getString("UUID"); + } + companionID = data.getInteger("PlayerCompanionId"); profileSlot = data.getInteger("ProfileSlot"); - if(data.hasKey("PlayerCompanion") && !hasCompanion()){ - EntityCustomNpc npc = new EntityCustomNpc(player.worldObj); - npc.readEntityFromNBT(data.getCompoundTag("PlayerCompanion")); - npc.setPosition(player.posX, player.posY, player.posZ); - if(npc.advanced.role == EnumRoleType.Companion){ - setCompanion(npc); - ((RoleCompanion)npc.roleInterface).setSitting(false); - player.worldObj.spawnEntityInWorld(npc); - } - } - isGUIOpen = data.getBoolean("isGUIOpen"); + if (data.hasKey("PlayerCompanion") && !hasCompanion()) { + EntityCustomNpc npc = new EntityCustomNpc(player.worldObj); + npc.readEntityFromNBT(data.getCompoundTag("PlayerCompanion")); + npc.setPosition(player.posX, player.posY, player.posZ); + if (npc.advanced.role == EnumRoleType.Companion) { + setCompanion(npc); + ((RoleCompanion) npc.roleInterface).setSitting(false); + player.worldObj.spawnEntityInWorld(npc); + } + } + isGUIOpen = data.getBoolean("isGUIOpen"); DBCAddon.instance.readFromNBT(this, data); - } + } + public NBTTagCompound getNBT() { - if(player != null){ + if (player != null) { playername = player.getCommandSenderName(); uuid = player.getPersistentID().toString(); } @@ -163,19 +163,19 @@ public class PlayerData implements IExtendedEntityProperties, IPlayerData { compound.setString("PlayerName", playername); compound.setString("UUID", uuid); compound.setInteger("PlayerCompanionId", companionID); - compound.setBoolean("isGUIOpen",isGUIOpen); + compound.setBoolean("isGUIOpen", isGUIOpen); compound.setInteger("ProfileSlot", profileSlot); - if(hasCompanion()){ + if (hasCompanion()) { NBTTagCompound nbt = new NBTTagCompound(); - if(activeCompanion.writeToNBTOptional(nbt)) + if (activeCompanion.writeToNBTOptional(nbt)) compound.setTag("PlayerCompanion", nbt); } DBCAddon.instance.writeToNBT(this, compound); return compound; } - public NBTTagCompound getSyncNBT(){ + public NBTTagCompound getSyncNBT() { NBTTagCompound compound = new NBTTagCompound(); dialogData.saveNBTData(compound); questData.saveNBTData(compound); @@ -183,24 +183,24 @@ public class PlayerData implements IExtendedEntityProperties, IPlayerData { return compound; } - public void setSyncNBT(NBTTagCompound data){ + public void setSyncNBT(NBTTagCompound data) { dialogData.loadNBTData(data); questData.loadNBTData(data); factionData.loadNBTData(data); } - public NBTTagCompound getPlayerEffects(){ + public NBTTagCompound getPlayerEffects() { NBTTagCompound compound = new NBTTagCompound(); effectData.writeToNBT(compound); return compound; } - public void setPlayerEffects(NBTTagCompound data){ + public void setPlayerEffects(NBTTagCompound data) { effectData.readFromNBT(data); } public NBTTagCompound getSyncNBTFull() { - if(player != null){ + if (player != null) { playername = player.getCommandSenderName(); uuid = player.getPersistentID().toString(); } @@ -217,114 +217,113 @@ public class PlayerData implements IExtendedEntityProperties, IPlayerData { return compound; } - public void setSyncNBTFull(NBTTagCompound data){ + public void setSyncNBTFull(NBTTagCompound data) { dialogData.loadNBTData(data); bankData.loadNBTData(data); questData.loadNBTData(data); transportData.loadNBTData(data); factionData.loadNBTData(data); mailData.loadNBTData(data); - if(player != null){ + if (player != null) { playername = player.getCommandSenderName(); uuid = player.getPersistentID().toString(); - } - else{ + } else { playername = data.getString("PlayerName"); uuid = data.getString("UUID"); } DBCAddon.instance.readFromNBT(this, data); } - public void getDBCSync(NBTTagCompound compound){ + public void getDBCSync(NBTTagCompound compound) { DBCAddon.instance.writeToNBT(this, compound); } - public void setDBCSync(NBTTagCompound data){ + public void setDBCSync(NBTTagCompound data) { DBCAddon.instance.readFromNBT(this, data); } - @Override - public void init(Entity entity, World world) { + @Override + public void init(Entity entity, World world) { - } + } - public void setGUIOpen(boolean bool) { - this.isGUIOpen = bool; - } + public void setGUIOpen(boolean bool) { + this.isGUIOpen = bool; + } - public boolean getGUIOpen() { - return this.isGUIOpen; - } + public boolean getGUIOpen() { + return this.isGUIOpen; + } - public ScreenSize getScreenSize(){ - return screenSize; - } + public ScreenSize getScreenSize() { + return screenSize; + } - public void setScreenSize(ScreenSize size){ - screenSize = size; - } + public void setScreenSize(ScreenSize size) { + screenSize = size; + } - public boolean hasCompanion(){ - return activeCompanion != null && !activeCompanion.isDead; - } + public boolean hasCompanion() { + return activeCompanion != null && !activeCompanion.isDead; + } - public void setCompanion(EntityNPCInterface npc) { - if(npc != null && npc.advanced.role != EnumRoleType.Companion)//shouldnt happen - return; - companionID++; - activeCompanion = npc; - if(npc != null) - ((RoleCompanion)npc.roleInterface).companionID = companionID; - save(); - } + public void setCompanion(EntityNPCInterface npc) { + if (npc != null && npc.advanced.role != EnumRoleType.Companion)//shouldnt happen + return; + companionID++; + activeCompanion = npc; + if (npc != null) + ((RoleCompanion) npc.roleInterface).companionID = companionID; + save(); + } - public void updateCompanion(World world) { - if(!hasCompanion() || world == activeCompanion.worldObj) - return; - RoleCompanion role = (RoleCompanion) activeCompanion.roleInterface; - role.owner = player; - if(!role.isFollowing()) - return; - NBTTagCompound nbt = new NBTTagCompound(); - activeCompanion.writeToNBTOptional(nbt); - activeCompanion.isDead = true; + public void updateCompanion(World world) { + if (!hasCompanion() || world == activeCompanion.worldObj) + return; + RoleCompanion role = (RoleCompanion) activeCompanion.roleInterface; + role.owner = player; + if (!role.isFollowing()) + return; + NBTTagCompound nbt = new NBTTagCompound(); + activeCompanion.writeToNBTOptional(nbt); + activeCompanion.isDead = true; - EntityCustomNpc npc = new EntityCustomNpc(world); - npc.readEntityFromNBT(nbt); - npc.setPosition(player.posX, player.posY, player.posZ); - setCompanion(npc); - ((RoleCompanion)npc.roleInterface).setSitting(false); - world.spawnEntityInWorld(npc); - } + EntityCustomNpc npc = new EntityCustomNpc(world); + npc.readEntityFromNBT(nbt); + npc.setPosition(player.posX, player.posY, player.posZ); + setCompanion(npc); + ((RoleCompanion) npc.roleInterface).setSitting(false); + world.spawnEntityInWorld(npc); + } - public void inviteToParty(Party party) { - if (party != null && this.partyUUID == null && !this.partyInvites.contains(party.getPartyUUID())) { - this.partyInvites.add(party.getPartyUUID()); + public void inviteToParty(Party party) { + if (party != null && this.partyUUID == null && !this.partyInvites.contains(party.getPartyUUID())) { + this.partyInvites.add(party.getPartyUUID()); AchievementPacket.sendAchievement((EntityPlayerMP) player, true, "party.inviteAlert", party.getPartyLeader().getCommandSenderName()); ChatAlertPacket.sendChatAlert((EntityPlayerMP) player, "\u00A7a", "party.inviteChat", " ", party.getPartyLeader().getCommandSenderName(), "!"); - } - } + } + } - public void ignoreInvite(UUID uuid) { - if (uuid != null) { - this.partyInvites.remove(uuid); - PartyInvitePacket.sendInviteData((EntityPlayerMP) player); - } - } + public void ignoreInvite(UUID uuid) { + if (uuid != null) { + this.partyInvites.remove(uuid); + PartyInvitePacket.sendInviteData((EntityPlayerMP) player); + } + } - public void acceptInvite(UUID uuid) { - if (uuid != null) { - this.partyInvites.remove(uuid); - Party party = PartyController.Instance().getParty(uuid); - if(party != null){ + public void acceptInvite(UUID uuid) { + if (uuid != null) { + this.partyInvites.remove(uuid); + Party party = PartyController.Instance().getParty(uuid); + if (party != null) { if (!party.getIsLocked()) { party.addPlayer(player); PartyController.Instance().pingPartyUpdate(party); } } - } - } + } + } public Party getPlayerParty() { if (partyUUID != null) { @@ -333,100 +332,100 @@ public class PlayerData implements IExtendedEntityProperties, IPlayerData { return null; } - public HashSet getPartyInvites() { - return (HashSet) this.partyInvites.clone(); - } + public HashSet getPartyInvites() { + return (HashSet) this.partyInvites.clone(); + } - public void setCompanion(ICustomNpc npc) { - this.setCompanion((EntityNPCInterface) npc.getMCEntity()); - } + public void setCompanion(ICustomNpc npc) { + this.setCompanion((EntityNPCInterface) npc.getMCEntity()); + } - public ICustomNpc getCompanion() { - return (ICustomNpc) NpcAPI.Instance().getIEntity(activeCompanion); - } + public ICustomNpc getCompanion() { + return (ICustomNpc) NpcAPI.Instance().getIEntity(activeCompanion); + } - public int getCompanionID() { - return companionID; - } + public int getCompanionID() { + return companionID; + } - public IPlayerDialogData getDialogData() { - return dialogData; - } + public IPlayerDialogData getDialogData() { + return dialogData; + } - public IPlayerBankData getBankData() { - return bankData; - } + public IPlayerBankData getBankData() { + return bankData; + } - public IPlayerQuestData getQuestData() { - return questData; - } + public IPlayerQuestData getQuestData() { + return questData; + } - public IPlayerTransportData getTransportData() { - return transportData; - } + public IPlayerTransportData getTransportData() { + return transportData; + } - public IPlayerFactionData getFactionData() { - return factionData; - } + public IPlayerFactionData getFactionData() { + return factionData; + } - public IPlayerItemGiverData getItemGiverData() { - return itemgiverData; - } + public IPlayerItemGiverData getItemGiverData() { + return itemgiverData; + } - public IPlayerMailData getMailData() { - return mailData; - } + public IPlayerMailData getMailData() { + return mailData; + } - public synchronized void save() { + public synchronized void save() { // Don't Save this is a Modification of a Profile's PlayerData Profile profile = ProfileController.Instance.getProfile(UUID.fromString(uuid)); - if(profile != null && profile.currentSlotId != this.profileSlot){ + if (profile != null && profile.currentSlotId != this.profileSlot) { ProfileController.Instance.saveOffline(profile, UUID.fromString(uuid)); return; } - final NBTTagCompound compound = getNBT(); - final String filename; - if(ConfigMain.DatFormat){ - filename = uuid + ".dat"; - } else { - filename = uuid + ".json"; - } - PlayerDataController.Instance.putPlayerMap(playername, uuid); - PlayerDataController.Instance.putPlayerDataCache(uuid, this); - CustomNPCsThreader.customNPCThread.execute(() -> { - try { - File saveDir = PlayerDataController.Instance.getSaveDir(); - File file = new File(saveDir, filename + "_new"); - File file1 = new File(saveDir, filename); - if(ConfigMain.DatFormat){ - CompressedStreamTools.writeCompressed(compound, new FileOutputStream(file)); - } else { - NBTJsonUtil.SaveFile(file, compound); - } - if(file1.exists()){ - file1.delete(); - } - file.renameTo(file1); - } catch (Exception e) { - LogWriter.except(e); - } - }); - } + final NBTTagCompound compound = getNBT(); + final String filename; + if (ConfigMain.DatFormat) { + filename = uuid + ".dat"; + } else { + filename = uuid + ".json"; + } + PlayerDataController.Instance.putPlayerMap(playername, uuid); + PlayerDataController.Instance.putPlayerDataCache(uuid, this); + CustomNPCsThreader.customNPCThread.execute(() -> { + try { + File saveDir = PlayerDataController.Instance.getSaveDir(); + File file = new File(saveDir, filename + "_new"); + File file1 = new File(saveDir, filename); + if (ConfigMain.DatFormat) { + CompressedStreamTools.writeCompressed(compound, new FileOutputStream(file)); + } else { + NBTJsonUtil.SaveFile(file, compound); + } + if (file1.exists()) { + file1.delete(); + } + file.renameTo(file1); + } catch (Exception e) { + LogWriter.except(e); + } + }); + } - public void load() { - NBTTagCompound data = PlayerDataController.Instance.loadPlayerData(player.getPersistentID().toString()); - if(data.hasNoTags()){ - data = PlayerDataController.Instance.loadPlayerDataOld(player.getCommandSenderName()); - } - if(data.hasNoTags()){ + public void load() { + NBTTagCompound data = PlayerDataController.Instance.loadPlayerData(player.getPersistentID().toString()); + if (data.hasNoTags()) { + data = PlayerDataController.Instance.loadPlayerDataOld(player.getCommandSenderName()); + } + if (data.hasNoTags()) { data = getNBT(); } - setNBT(data); - } + setNBT(data); + } public static PlayerData get(EntityPlayer player) { - if(player.worldObj.isRemote) + if (player.worldObj.isRemote) return CustomNpcs.proxy.getPlayerData(player); return PlayerDataController.Instance.getPlayerData(player); diff --git a/src/main/java/noppes/npcs/controllers/data/PlayerDataScript.java b/src/main/java/noppes/npcs/controllers/data/PlayerDataScript.java index 041f81068..f593bcab5 100644 --- a/src/main/java/noppes/npcs/controllers/data/PlayerDataScript.java +++ b/src/main/java/noppes/npcs/controllers/data/PlayerDataScript.java @@ -29,18 +29,20 @@ public class PlayerDataScript implements INpcScriptHandler { public boolean enabled = false; public PlayerDataScript(EntityPlayer player) { - if(player != null) { + if (player != null) { this.player = player; } } + public void clear() { this.scripts = new ArrayList(); } + public void readFromNBT(NBTTagCompound compound) { if (compound.hasKey("Scripts")) { this.scripts = NBTTags.GetScriptOld(compound.getTagList("Scripts", 10), this); } else { - this.scripts = NBTTags.GetScript(compound,this); + this.scripts = NBTTags.GetScript(compound, this); } this.scriptLanguage = compound.getString("ScriptLanguage"); if (!ScriptController.Instance.languages.containsKey(scriptLanguage)) { @@ -52,10 +54,11 @@ public class PlayerDataScript implements INpcScriptHandler { } this.enabled = compound.getBoolean("ScriptEnabled"); } + public NBTTagCompound writeToNBT(NBTTagCompound compound) { - compound.setInteger("TotalScripts",this.scripts.size()); + compound.setInteger("TotalScripts", this.scripts.size()); for (int i = 0; i < this.scripts.size(); i++) { - compound.setTag("Tab"+i,this.scripts.get(i).writeToNBT(new NBTTagCompound())); + compound.setTag("Tab" + i, this.scripts.get(i).writeToNBT(new NBTTagCompound())); } compound.setString("ScriptLanguage", this.scriptLanguage); compound.setBoolean("ScriptEnabled", this.enabled); @@ -82,13 +85,13 @@ public class PlayerDataScript implements INpcScriptHandler { } if (!Objects.equals(hookName, EnumScriptType.INIT.function)) { - noppes.npcs.scripted.event.PlayerEvent playerEvent = (noppes.npcs.scripted.event.PlayerEvent)event; + noppes.npcs.scripted.event.PlayerEvent playerEvent = (noppes.npcs.scripted.event.PlayerEvent) event; EventHooks.onPlayerInit(this, playerEvent.player); } } for (ScriptContainer script : this.scripts) { - if(script == null || script.errored || !script.hasCode() ) + if (script == null || script.errored || !script.hasCode()) continue; script.run(hookName, event); @@ -99,33 +102,41 @@ public class PlayerDataScript implements INpcScriptHandler { public boolean isClient() { return this.player != null && this.player.isClientWorld(); } + public boolean getEnabled() { return ScriptController.Instance.playerScripts.enabled; } + public void setEnabled(boolean bo) { ScriptController.Instance.playerScripts.enabled = bo; this.enabled = bo; } + public String getLanguage() { return ScriptController.Instance.playerScripts.scriptLanguage; } + public void setLanguage(String lang) { this.scriptLanguage = lang; } + public void setScripts(List list) { this.scripts = list; } + public List getScripts() { return this.scripts; } + public String noticeString() { - if(this.player == null) { + if (this.player == null) { return "Global script"; } else { BlockPos pos = new BlockPos(this.player); return PlayerDataScript.toStringHelper(this.player).add("x", pos.getX()).add("y", pos.getY()).add("z", pos.getZ()).toString(); } } + public IPlayer getPlayer() { if (this.playerAPI == null) { this.playerAPI = (IPlayer) NpcAPI.Instance().getIEntity(this.player); @@ -158,6 +169,7 @@ public class PlayerDataScript implements INpcScriptHandler { private PlayerDataScript.ToStringHelper.ValueHolder holderTail; private boolean omitNullValues; private boolean omitEmptyValues; + private ToStringHelper(String className) { this.holderHead = new PlayerDataScript.ToStringHelper.ValueHolder(); this.holderTail = this.holderHead; @@ -165,81 +177,98 @@ public class PlayerDataScript implements INpcScriptHandler { this.omitEmptyValues = false; this.className = (String) Preconditions.checkNotNull(className); } + public PlayerDataScript.ToStringHelper omitNullValues() { this.omitNullValues = true; return this; } + public PlayerDataScript.ToStringHelper add(String name, @CheckForNull Object value) { return this.addHolder(name, value); } + public PlayerDataScript.ToStringHelper add(String name, boolean value) { return this.addUnconditionalHolder(name, String.valueOf(value)); } + public PlayerDataScript.ToStringHelper add(String name, char value) { return this.addUnconditionalHolder(name, String.valueOf(value)); } + public PlayerDataScript.ToStringHelper add(String name, double value) { return this.addUnconditionalHolder(name, String.valueOf(value)); } + public PlayerDataScript.ToStringHelper add(String name, float value) { return this.addUnconditionalHolder(name, String.valueOf(value)); } + public PlayerDataScript.ToStringHelper add(String name, int value) { return this.addUnconditionalHolder(name, String.valueOf(value)); } + public PlayerDataScript.ToStringHelper add(String name, long value) { return this.addUnconditionalHolder(name, String.valueOf(value)); } + public PlayerDataScript.ToStringHelper addValue(@CheckForNull Object value) { return this.addHolder(value); } + public PlayerDataScript.ToStringHelper addValue(boolean value) { return this.addUnconditionalHolder(String.valueOf(value)); } + public PlayerDataScript.ToStringHelper addValue(char value) { return this.addUnconditionalHolder(String.valueOf(value)); } + public PlayerDataScript.ToStringHelper addValue(double value) { return this.addUnconditionalHolder(String.valueOf(value)); } + public PlayerDataScript.ToStringHelper addValue(float value) { return this.addUnconditionalHolder(String.valueOf(value)); } + public PlayerDataScript.ToStringHelper addValue(int value) { return this.addUnconditionalHolder(String.valueOf(value)); } + public PlayerDataScript.ToStringHelper addValue(long value) { return this.addUnconditionalHolder(String.valueOf(value)); } + private static boolean isEmpty(Object value) { if (value instanceof CharSequence) { - return ((CharSequence)value).length() == 0; + return ((CharSequence) value).length() == 0; } else if (value instanceof Collection) { - return ((Collection)value).isEmpty(); + return ((Collection) value).isEmpty(); } else if (value instanceof Map) { - return ((Map)value).isEmpty(); + return ((Map) value).isEmpty(); } else if (value instanceof Optional) { - return !((Optional)value).isPresent(); + return !((Optional) value).isPresent(); } else if (value instanceof OptionalInt) { - return !((OptionalInt)value).isPresent(); + return !((OptionalInt) value).isPresent(); } else if (value instanceof OptionalLong) { - return !((OptionalLong)value).isPresent(); + return !((OptionalLong) value).isPresent(); } else if (value instanceof OptionalDouble) { - return !((OptionalDouble)value).isPresent(); + return !((OptionalDouble) value).isPresent(); } else if (value instanceof com.google.common.base.Optional) { - return !((com.google.common.base.Optional)value).isPresent(); + return !((com.google.common.base.Optional) value).isPresent(); } else if (value.getClass().isArray()) { return Array.getLength(value) == 0; } else { return false; } } + public String toString() { boolean omitNullValuesSnapshot = this.omitNullValues; boolean omitEmptyValuesSnapshot = this.omitEmptyValues; String nextSeparator = ""; StringBuilder builder = (new StringBuilder(32)).append(this.className).append('{'); - for(PlayerDataScript.ToStringHelper.ValueHolder valueHolder = this.holderHead.next; valueHolder != null; valueHolder = valueHolder.next) { + for (PlayerDataScript.ToStringHelper.ValueHolder valueHolder = this.holderHead.next; valueHolder != null; valueHolder = valueHolder.next) { Object value = valueHolder.value; if (!(valueHolder instanceof PlayerDataScript.ToStringHelper.UnconditionalValueHolder)) { if (value == null) { @@ -265,43 +294,51 @@ public class PlayerDataScript implements INpcScriptHandler { } return builder.append('}').toString(); } + private PlayerDataScript.ToStringHelper.ValueHolder addHolder() { PlayerDataScript.ToStringHelper.ValueHolder valueHolder = new PlayerDataScript.ToStringHelper.ValueHolder(); this.holderTail = this.holderTail.next = valueHolder; return valueHolder; } + private PlayerDataScript.ToStringHelper addHolder(@CheckForNull Object value) { PlayerDataScript.ToStringHelper.ValueHolder valueHolder = this.addHolder(); valueHolder.value = value; return this; } + private PlayerDataScript.ToStringHelper addHolder(String name, @CheckForNull Object value) { PlayerDataScript.ToStringHelper.ValueHolder valueHolder = this.addHolder(); valueHolder.value = value; - valueHolder.name = (String)Preconditions.checkNotNull(name); + valueHolder.name = (String) Preconditions.checkNotNull(name); return this; } + private PlayerDataScript.ToStringHelper.UnconditionalValueHolder addUnconditionalHolder() { PlayerDataScript.ToStringHelper.UnconditionalValueHolder valueHolder = new PlayerDataScript.ToStringHelper.UnconditionalValueHolder(); this.holderTail = this.holderTail.next = valueHolder; return valueHolder; } + private PlayerDataScript.ToStringHelper addUnconditionalHolder(Object value) { PlayerDataScript.ToStringHelper.UnconditionalValueHolder valueHolder = this.addUnconditionalHolder(); valueHolder.value = value; return this; } + private PlayerDataScript.ToStringHelper addUnconditionalHolder(String name, Object value) { PlayerDataScript.ToStringHelper.UnconditionalValueHolder valueHolder = this.addUnconditionalHolder(); valueHolder.value = value; - valueHolder.name = (String)Preconditions.checkNotNull(name); + valueHolder.name = (String) Preconditions.checkNotNull(name); return this; } + private static final class UnconditionalValueHolder extends PlayerDataScript.ToStringHelper.ValueHolder { private UnconditionalValueHolder() { super(); } } + private static class ValueHolder { @CheckForNull String name; @@ -309,10 +346,12 @@ public class PlayerDataScript implements INpcScriptHandler { Object value; @CheckForNull PlayerDataScript.ToStringHelper.ValueHolder next; + private ValueHolder() { } } } + public static PlayerDataScript.ToStringHelper toStringHelper(Object self) { return new PlayerDataScript.ToStringHelper(self.getClass().getSimpleName()); } diff --git a/src/main/java/noppes/npcs/controllers/data/PlayerDialogData.java b/src/main/java/noppes/npcs/controllers/data/PlayerDialogData.java index acf39a090..09e461061 100644 --- a/src/main/java/noppes/npcs/controllers/data/PlayerDialogData.java +++ b/src/main/java/noppes/npcs/controllers/data/PlayerDialogData.java @@ -7,50 +7,49 @@ import noppes.npcs.api.handler.IPlayerDialogData; import java.util.HashSet; public class PlayerDialogData implements IPlayerDialogData { - private final PlayerData parent; - public HashSet dialogsRead = new HashSet(); + private final PlayerData parent; + public HashSet dialogsRead = new HashSet(); - public PlayerDialogData(PlayerData parent) { - this.parent = parent; - } - - public void loadNBTData(NBTTagCompound compound) { - HashSet dialogsRead = new HashSet(); - if(compound == null) - return; + public PlayerDialogData(PlayerData parent) { + this.parent = parent; + } + + public void loadNBTData(NBTTagCompound compound) { + HashSet dialogsRead = new HashSet(); + if (compound == null) + return; NBTTagList list = compound.getTagList("DialogData", 10); - if(list == null){ - return; + if (list == null) { + return; } - for(int i = 0; i < list.tagCount(); i++) - { + for (int i = 0; i < list.tagCount(); i++) { NBTTagCompound nbttagcompound = list.getCompoundTagAt(i); dialogsRead.add(nbttagcompound.getInteger("Dialog")); } this.dialogsRead = dialogsRead; - } + } - public void saveNBTData(NBTTagCompound compound) { - NBTTagList list = new NBTTagList(); - for(int dia : dialogsRead){ - NBTTagCompound nbttagcompound = new NBTTagCompound(); - nbttagcompound.setInteger("Dialog", dia); - list.appendTag(nbttagcompound); - } - - compound.setTag("DialogData", list); - } + public void saveNBTData(NBTTagCompound compound) { + NBTTagList list = new NBTTagList(); + for (int dia : dialogsRead) { + NBTTagCompound nbttagcompound = new NBTTagCompound(); + nbttagcompound.setInteger("Dialog", dia); + list.appendTag(nbttagcompound); + } - public boolean hasReadDialog(int id) { - return dialogsRead.contains(id); - } + compound.setTag("DialogData", list); + } - public void readDialog(int id) { - dialogsRead.add(id); - } + public boolean hasReadDialog(int id) { + return dialogsRead.contains(id); + } - public void unreadDialog(int id) { - dialogsRead.remove(id); - } + public void readDialog(int id) { + dialogsRead.add(id); + } + + public void unreadDialog(int id) { + dialogsRead.remove(id); + } } diff --git a/src/main/java/noppes/npcs/controllers/data/PlayerEffect.java b/src/main/java/noppes/npcs/controllers/data/PlayerEffect.java index 45aa535f3..38ea0afd8 100644 --- a/src/main/java/noppes/npcs/controllers/data/PlayerEffect.java +++ b/src/main/java/noppes/npcs/controllers/data/PlayerEffect.java @@ -51,7 +51,7 @@ public class PlayerEffect implements IPlayerEffect { @Override public String getName() { CustomEffect effect = CustomEffectController.getInstance().get(this.id, this.index); - if(effect != null) + if (effect != null) return effect.getName(); return "UNKNOWN"; @@ -61,7 +61,7 @@ public class PlayerEffect implements IPlayerEffect { public void performEffect(IPlayer player) { if (player != null && player.getMCEntity() != null && player.getMCEntity() instanceof EntityPlayer) { CustomEffect effect = CustomEffectController.getInstance().get(this.id, this.index); - if(effect != null) + if (effect != null) effect.onTick((EntityPlayer) player.getMCEntity(), this); } } diff --git a/src/main/java/noppes/npcs/controllers/data/PlayerEffectData.java b/src/main/java/noppes/npcs/controllers/data/PlayerEffectData.java index 93f69483f..98c025317 100644 --- a/src/main/java/noppes/npcs/controllers/data/PlayerEffectData.java +++ b/src/main/java/noppes/npcs/controllers/data/PlayerEffectData.java @@ -12,7 +12,7 @@ public class PlayerEffectData { private final PlayerData parent; private ConcurrentHashMap effects = new ConcurrentHashMap<>(); - public PlayerEffectData(PlayerData playerData){ + public PlayerEffectData(PlayerData playerData) { this.parent = playerData; } diff --git a/src/main/java/noppes/npcs/controllers/data/PlayerFactionData.java b/src/main/java/noppes/npcs/controllers/data/PlayerFactionData.java index 6ddeb8f12..b65ff8548 100644 --- a/src/main/java/noppes/npcs/controllers/data/PlayerFactionData.java +++ b/src/main/java/noppes/npcs/controllers/data/PlayerFactionData.java @@ -14,96 +14,95 @@ import noppes.npcs.scripted.event.FactionEvent; import java.util.HashMap; public class PlayerFactionData implements IPlayerFactionData { - private final PlayerData parent; - public HashMap factionData = new HashMap(); + private final PlayerData parent; + public HashMap factionData = new HashMap(); - public PlayerFactionData() { - parent = null; - } + public PlayerFactionData() { + parent = null; + } - public PlayerFactionData(PlayerData parent) { - this.parent = parent; - } + public PlayerFactionData(PlayerData parent) { + this.parent = parent; + } - public void loadNBTData(NBTTagCompound compound) { - HashMap factionData = new HashMap(); - if(compound == null) - return; + public void loadNBTData(NBTTagCompound compound) { + HashMap factionData = new HashMap(); + if (compound == null) + return; NBTTagList list = compound.getTagList("FactionData", 10); - if(list == null){ - return; + if (list == null) { + return; } - for(int i = 0; i < list.tagCount(); i++) - { + for (int i = 0; i < list.tagCount(); i++) { NBTTagCompound nbttagcompound = list.getCompoundTagAt(i); - factionData.put(nbttagcompound.getInteger("Faction"),nbttagcompound.getInteger("Points")); + factionData.put(nbttagcompound.getInteger("Faction"), nbttagcompound.getInteger("Points")); } this.factionData = factionData; - } + } - public void saveNBTData(NBTTagCompound compound) { - NBTTagList list = new NBTTagList(); - for(int faction : factionData.keySet()){ - NBTTagCompound nbttagcompound = new NBTTagCompound(); - nbttagcompound.setInteger("Faction", faction); - nbttagcompound.setInteger("Points", factionData.get(faction)); - list.appendTag(nbttagcompound); - } - - compound.setTag("FactionData", list); - } + public void saveNBTData(NBTTagCompound compound) { + NBTTagList list = new NBTTagList(); + for (int faction : factionData.keySet()) { + NBTTagCompound nbttagcompound = new NBTTagCompound(); + nbttagcompound.setInteger("Faction", faction); + nbttagcompound.setInteger("Points", factionData.get(faction)); + list.appendTag(nbttagcompound); + } - public int getFactionPoints(int id) { - if(!factionData.containsKey(id)){ - Faction faction = FactionController.getInstance().get(id); - factionData.put(id, faction == null? -1 : faction.defaultPoints); - } - return factionData.get(id); - } + compound.setTag("FactionData", list); + } - public void increasePoints(int factionId, int points, EntityPlayer player) { - if (EventHooks.onFactionPoints(new FactionEvent.FactionPoints((IPlayer) NpcAPI.Instance().getIEntity((EntityPlayerMP) player), FactionController.getInstance().get(factionId), points < 0, points))) - return; + public int getFactionPoints(int id) { + if (!factionData.containsKey(id)) { + Faction faction = FactionController.getInstance().get(id); + factionData.put(id, faction == null ? -1 : faction.defaultPoints); + } + return factionData.get(id); + } - if(!factionData.containsKey(factionId)){ - Faction faction = FactionController.getInstance().get(factionId); - factionData.put(factionId, faction == null? -1 : faction.defaultPoints); - } - factionData.put(factionId, factionData.get(factionId) + points); - } - - public NBTTagCompound getPlayerGuiData(){ - NBTTagCompound compound = new NBTTagCompound(); - saveNBTData(compound); - - NBTTagList list = new NBTTagList(); - for(int id : factionData.keySet()){ - Faction faction = FactionController.getInstance().get(id); - if(faction == null || faction.hideFaction) - continue; - NBTTagCompound com = new NBTTagCompound(); - faction.writeNBT(com); - list.appendTag(com); - } - compound.setTag("FactionList", list); - - return compound; - } + public void increasePoints(int factionId, int points, EntityPlayer player) { + if (EventHooks.onFactionPoints(new FactionEvent.FactionPoints((IPlayer) NpcAPI.Instance().getIEntity((EntityPlayerMP) player), FactionController.getInstance().get(factionId), points < 0, points))) + return; - public int getPoints(int id) { - return this.getFactionPoints(id); - } + if (!factionData.containsKey(factionId)) { + Faction faction = FactionController.getInstance().get(factionId); + factionData.put(factionId, faction == null ? -1 : faction.defaultPoints); + } + factionData.put(factionId, factionData.get(factionId) + points); + } - public void addPoints(int id, int points) { - if (parent != null) { - this.increasePoints(id, points, parent.player); - } - } + public NBTTagCompound getPlayerGuiData() { + NBTTagCompound compound = new NBTTagCompound(); + saveNBTData(compound); - public void setPoints(int id, int points) { - if (parent != null) { - increasePoints(id, points-getFactionPoints(id), parent.player); - } - } + NBTTagList list = new NBTTagList(); + for (int id : factionData.keySet()) { + Faction faction = FactionController.getInstance().get(id); + if (faction == null || faction.hideFaction) + continue; + NBTTagCompound com = new NBTTagCompound(); + faction.writeNBT(com); + list.appendTag(com); + } + compound.setTag("FactionList", list); + + return compound; + } + + public int getPoints(int id) { + return this.getFactionPoints(id); + } + + public void addPoints(int id, int points) { + if (parent != null) { + this.increasePoints(id, points, parent.player); + } + } + + public void setPoints(int id, int points) { + if (parent != null) { + increasePoints(id, points - getFactionPoints(id), parent.player); + } + } } diff --git a/src/main/java/noppes/npcs/controllers/data/PlayerItemGiverData.java b/src/main/java/noppes/npcs/controllers/data/PlayerItemGiverData.java index 7fe97102e..7913f5106 100644 --- a/src/main/java/noppes/npcs/controllers/data/PlayerItemGiverData.java +++ b/src/main/java/noppes/npcs/controllers/data/PlayerItemGiverData.java @@ -9,51 +9,55 @@ import noppes.npcs.roles.JobItemGiver; import java.util.HashMap; public class PlayerItemGiverData implements IPlayerItemGiverData { - private final PlayerData parent; - private HashMap itemgivers = new HashMap(); - private HashMap chained = new HashMap(); + private final PlayerData parent; + private HashMap itemgivers = new HashMap(); + private HashMap chained = new HashMap(); - public PlayerItemGiverData(PlayerData parent) { - this.parent = parent; - } + public PlayerItemGiverData(PlayerData parent) { + this.parent = parent; + } - public void loadNBTData(NBTTagCompound compound) { - chained = NBTTags.getIntegerIntegerMap(compound.getTagList("ItemGiverChained", 10)); - itemgivers = NBTTags.getIntegerLongMap(compound.getTagList("ItemGiversList", 10)); - } + public void loadNBTData(NBTTagCompound compound) { + chained = NBTTags.getIntegerIntegerMap(compound.getTagList("ItemGiverChained", 10)); + itemgivers = NBTTags.getIntegerLongMap(compound.getTagList("ItemGiversList", 10)); + } - public void saveNBTData(NBTTagCompound compound) { - compound.setTag("ItemGiverChained", NBTTags.nbtIntegerIntegerMap(chained)); - compound.setTag("ItemGiversList", NBTTags.nbtIntegerLongMap(itemgivers)); - } - public boolean hasInteractedBefore(JobItemGiver jobItemGiver) { - return itemgivers.containsKey(jobItemGiver.itemGiverId); - } + public void saveNBTData(NBTTagCompound compound) { + compound.setTag("ItemGiverChained", NBTTags.nbtIntegerIntegerMap(chained)); + compound.setTag("ItemGiversList", NBTTags.nbtIntegerLongMap(itemgivers)); + } - public long getTime(JobItemGiver jobItemGiver){ - return itemgivers.get(jobItemGiver.itemGiverId); - } - public void setTime(JobItemGiver jobItemGiver, long day) { - itemgivers.put(jobItemGiver.itemGiverId, day); - } - public int getItemIndex(JobItemGiver jobItemGiver) { - if(chained.containsKey(jobItemGiver.itemGiverId)) - return chained.get(jobItemGiver.itemGiverId); - return 0; - } - public void setItemIndex(JobItemGiver jobItemGiver, int i) { - chained.put(jobItemGiver.itemGiverId, i); - } + public boolean hasInteractedBefore(JobItemGiver jobItemGiver) { + return itemgivers.containsKey(jobItemGiver.itemGiverId); + } - public long getTime(IJobItemGiver jobItemGiver){ - return itemgivers.get(((JobItemGiver) jobItemGiver).itemGiverId); - } + public long getTime(JobItemGiver jobItemGiver) { + return itemgivers.get(jobItemGiver.itemGiverId); + } - public void setTime(IJobItemGiver jobItemGiver, long day) { - itemgivers.put(((JobItemGiver) jobItemGiver).itemGiverId, day); - } + public void setTime(JobItemGiver jobItemGiver, long day) { + itemgivers.put(jobItemGiver.itemGiverId, day); + } - public boolean hasInteractedBefore(IJobItemGiver jobItemGiver) { - return itemgivers.containsKey(((JobItemGiver) jobItemGiver).itemGiverId); - } + public int getItemIndex(JobItemGiver jobItemGiver) { + if (chained.containsKey(jobItemGiver.itemGiverId)) + return chained.get(jobItemGiver.itemGiverId); + return 0; + } + + public void setItemIndex(JobItemGiver jobItemGiver, int i) { + chained.put(jobItemGiver.itemGiverId, i); + } + + public long getTime(IJobItemGiver jobItemGiver) { + return itemgivers.get(((JobItemGiver) jobItemGiver).itemGiverId); + } + + public void setTime(IJobItemGiver jobItemGiver, long day) { + itemgivers.put(((JobItemGiver) jobItemGiver).itemGiverId, day); + } + + public boolean hasInteractedBefore(IJobItemGiver jobItemGiver) { + return itemgivers.containsKey(((JobItemGiver) jobItemGiver).itemGiverId); + } } diff --git a/src/main/java/noppes/npcs/controllers/data/PlayerMail.java b/src/main/java/noppes/npcs/controllers/data/PlayerMail.java index a35cb23d3..5be90d257 100644 --- a/src/main/java/noppes/npcs/controllers/data/PlayerMail.java +++ b/src/main/java/noppes/npcs/controllers/data/PlayerMail.java @@ -15,292 +15,275 @@ import noppes.npcs.scripted.NpcAPI; import java.util.ArrayList; public class PlayerMail implements IInventory, IPlayerMail { - public String subject = ""; - public String sender = ""; - public NBTTagCompound message = new NBTTagCompound(); - public long time = 0; - public boolean beenRead = false; - public int questId = -1; - public String questTitle = ""; - public ItemStack[] items = new ItemStack[4]; + public String subject = ""; + public String sender = ""; + public NBTTagCompound message = new NBTTagCompound(); + public long time = 0; + public boolean beenRead = false; + public int questId = -1; + public String questTitle = ""; + public ItemStack[] items = new ItemStack[4]; - public long timePast; + public long timePast; - public void readNBT(NBTTagCompound compound) { - subject = compound.getString("Subject"); - sender = compound.getString("Sender"); - time = compound.getLong("Time"); - beenRead = compound.getBoolean("BeenRead"); - message = compound.getCompoundTag("Message"); - timePast = compound.getLong("TimePast"); - if(compound.hasKey("MailQuest")) - questId = compound.getInteger("MailQuest"); - questTitle = compound.getString("MailQuestTitle"); + public void readNBT(NBTTagCompound compound) { + subject = compound.getString("Subject"); + sender = compound.getString("Sender"); + time = compound.getLong("Time"); + beenRead = compound.getBoolean("BeenRead"); + message = compound.getCompoundTag("Message"); + timePast = compound.getLong("TimePast"); + if (compound.hasKey("MailQuest")) + questId = compound.getInteger("MailQuest"); + questTitle = compound.getString("MailQuestTitle"); this.items = new ItemStack[this.getSizeInventory()]; NBTTagList nbttaglist = compound.getTagList("MailItems", 10); - for (int i = 0; i < nbttaglist.tagCount(); ++i) - { + for (int i = 0; i < nbttaglist.tagCount(); ++i) { NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i); int j = nbttagcompound1.getByte("Slot") & 255; - if (j >= 0 && j < this.items.length) - { + if (j >= 0 && j < this.items.length) { this.items[j] = NoppesUtilServer.readItem(nbttagcompound1); } } - } + } - public NBTTagCompound writeNBT() { - NBTTagCompound compound = new NBTTagCompound(); - compound.setString("Subject", subject); - compound.setString("Sender", sender); - compound.setLong("Time", time); - compound.setBoolean("BeenRead", beenRead); - compound.setTag("Message", message); - compound.setLong("TimePast", System.currentTimeMillis() - time); - compound.setInteger("MailQuest", questId); + public NBTTagCompound writeNBT() { + NBTTagCompound compound = new NBTTagCompound(); + compound.setString("Subject", subject); + compound.setString("Sender", sender); + compound.setLong("Time", time); + compound.setBoolean("BeenRead", beenRead); + compound.setTag("Message", message); + compound.setLong("TimePast", System.currentTimeMillis() - time); + compound.setInteger("MailQuest", questId); - if(hasQuest()) - compound.setString("MailQuestTitle", getQuest().title); + if (hasQuest()) + compound.setString("MailQuestTitle", getQuest().title); NBTTagList nbttaglist = new NBTTagList(); - for (int i = 0; i < this.items.length; ++i) - { - if (this.items[i] != null) - { + for (int i = 0; i < this.items.length; ++i) { + if (this.items[i] != null) { NBTTagCompound nbttagcompound1 = new NBTTagCompound(); - nbttagcompound1.setByte("Slot", (byte)i); - NoppesUtilServer.writeItem(this.items[i], nbttagcompound1); + nbttagcompound1.setByte("Slot", (byte) i); + NoppesUtilServer.writeItem(this.items[i], nbttagcompound1); nbttaglist.appendTag(nbttagcompound1); } } compound.setTag("MailItems", nbttaglist); - return compound; - } + return compound; + } - public boolean isValid(){ - return !subject.isEmpty() && !message.hasNoTags() && !sender.isEmpty(); - } + public boolean isValid() { + return !subject.isEmpty() && !message.hasNoTags() && !sender.isEmpty(); + } - public boolean hasQuest() { - return getQuest() != null; - } - public Quest getQuest() { - return QuestController.Instance != null?QuestController.Instance.quests.get(questId):null; - } + public boolean hasQuest() { + return getQuest() != null; + } - @Override - public int getSizeInventory() { - return 4; - } + public Quest getQuest() { + return QuestController.Instance != null ? QuestController.Instance.quests.get(questId) : null; + } - @Override - public int getInventoryStackLimit() { - return 64; - } + @Override + public int getSizeInventory() { + return 4; + } - @Override - public ItemStack getStackInSlot(int var1) { + @Override + public int getInventoryStackLimit() { + return 64; + } + + @Override + public ItemStack getStackInSlot(int var1) { return this.items[var1]; - } + } - @Override - public ItemStack decrStackSize(int par1, int par2) { - if (this.items[par1] != null) - { + @Override + public ItemStack decrStackSize(int par1, int par2) { + if (this.items[par1] != null) { ItemStack itemstack; - if (this.items[par1].stackSize <= par2) - { + if (this.items[par1].stackSize <= par2) { itemstack = this.items[par1]; this.items[par1] = null; this.markDirty(); return itemstack; - } - else - { + } else { itemstack = this.items[par1].splitStack(par2); - if (this.items[par1].stackSize == 0) - { + if (this.items[par1].stackSize == 0) { this.items[par1] = null; } this.markDirty(); return itemstack; } - } - else - { + } else { return null; } - } + } - @Override - public ItemStack getStackInSlotOnClosing(int var1) { - if (this.items[var1] != null) - { + @Override + public ItemStack getStackInSlotOnClosing(int var1) { + if (this.items[var1] != null) { ItemStack itemstack = this.items[var1]; this.items[var1] = null; return itemstack; - } - else - { + } else { return null; } - } + } - @Override - public void setInventorySlotContents(int par1, ItemStack par2ItemStack) { + @Override + public void setInventorySlotContents(int par1, ItemStack par2ItemStack) { this.items[par1] = par2ItemStack; - if (par2ItemStack != null && par2ItemStack.stackSize > this.getInventoryStackLimit()) - { + if (par2ItemStack != null && par2ItemStack.stackSize > this.getInventoryStackLimit()) { par2ItemStack.stackSize = this.getInventoryStackLimit(); } this.markDirty(); - } + } - @Override - public String getInventoryName() { + @Override + public String getInventoryName() { - return null; - } + return null; + } - @Override - public boolean hasCustomInventoryName() { + @Override + public boolean hasCustomInventoryName() { - return false; - } + return false; + } - @Override - public void markDirty() { + @Override + public void markDirty() { - } + } - @Override - public boolean isUseableByPlayer(EntityPlayer var1) { - return true; - } + @Override + public boolean isUseableByPlayer(EntityPlayer var1) { + return true; + } - @Override - public void openInventory() { + @Override + public void openInventory() { - } + } - @Override - public void closeInventory() { - } + @Override + public void closeInventory() { + } - @Override - public boolean isItemValidForSlot(int var1, ItemStack var2) { - return true; - } + @Override + public boolean isItemValidForSlot(int var1, ItemStack var2) { + return true; + } - public PlayerMail copy() { - PlayerMail mail = new PlayerMail(); - mail.readNBT(writeNBT()); - return mail; - } + public PlayerMail copy() { + PlayerMail mail = new PlayerMail(); + mail.readNBT(writeNBT()); + return mail; + } - public void setPageText(String[] pages) { - NBTTagList bookPages = new NBTTagList(); - for (String text : pages) { - bookPages.appendTag(new NBTTagString(text)); - } + public void setPageText(String[] pages) { + NBTTagList bookPages = new NBTTagList(); + for (String text : pages) { + bookPages.appendTag(new NBTTagString(text)); + } - message.setTag("pages", bookPages); - } + message.setTag("pages", bookPages); + } - public String[] getPageText() { - NBTTagList bookPages = new NBTTagList(); + public String[] getPageText() { + NBTTagList bookPages = new NBTTagList(); - if(message.hasKey("pages")) - bookPages = message.getTagList("pages", 8); + if (message.hasKey("pages")) + bookPages = message.getTagList("pages", 8); - if (bookPages != null) - { - bookPages = (NBTTagList)bookPages.copy(); - ArrayList pageStrings = new ArrayList<>(); + if (bookPages != null) { + bookPages = (NBTTagList) bookPages.copy(); + ArrayList pageStrings = new ArrayList<>(); - for (int i = 0; i < bookPages.tagCount(); i++) { - pageStrings.add(bookPages.getStringTagAt(i)); - } + for (int i = 0; i < bookPages.tagCount(); i++) { + pageStrings.add(bookPages.getStringTagAt(i)); + } - return pageStrings.toArray(new String[0]); - } else { - return new String[]{""}; - } - } + return pageStrings.toArray(new String[0]); + } else { + return new String[]{""}; + } + } - public int getPageCount() { - NBTTagList bookPages = new NBTTagList(); + public int getPageCount() { + NBTTagList bookPages = new NBTTagList(); - if(message.hasKey("pages")) - bookPages = message.getTagList("pages", 8); + if (message.hasKey("pages")) + bookPages = message.getTagList("pages", 8); - int bookTotalPages = 0; - if (bookPages != null) - { - bookPages = (NBTTagList)bookPages.copy(); - bookTotalPages = bookPages.tagCount(); + int bookTotalPages = 0; + if (bookPages != null) { + bookPages = (NBTTagList) bookPages.copy(); + bookTotalPages = bookPages.tagCount(); - if (bookTotalPages < 1) - { - bookTotalPages = 1; - } + if (bookTotalPages < 1) { + bookTotalPages = 1; + } - return bookTotalPages; - } + return bookTotalPages; + } - return 0; - } + return 0; + } - public void setSender(String sender) { - this.sender = sender; - } + public void setSender(String sender) { + this.sender = sender; + } - public String getSender() { - return sender; - } + public String getSender() { + return sender; + } - public void setSubject(String subject) { - this.subject = subject; - } + public void setSubject(String subject) { + this.subject = subject; + } - public String getSubject() { - return subject; - } + public String getSubject() { + return subject; + } - public long getTimePast() { - return timePast; - } + public long getTimePast() { + return timePast; + } - public long getTimeSent() { - return time; - } + public long getTimeSent() { + return time; + } - public IItemStack[] getItems() { - ArrayList list = new ArrayList<>(); - for (ItemStack itemStack : items) { - list.add(NpcAPI.Instance().getIItemStack(itemStack)); - } + public IItemStack[] getItems() { + ArrayList list = new ArrayList<>(); + for (ItemStack itemStack : items) { + list.add(NpcAPI.Instance().getIItemStack(itemStack)); + } - return list.toArray(new IItemStack[0]); - } + return list.toArray(new IItemStack[0]); + } - public void setItems(IItemStack[] items) { - ArrayList list = new ArrayList<>(); - for (IItemStack itemStack : items) { - list.add(itemStack.getMCItemStack()); - } + public void setItems(IItemStack[] items) { + ArrayList list = new ArrayList<>(); + for (IItemStack itemStack : items) { + list.add(itemStack.getMCItemStack()); + } - this.items = list.toArray(new ItemStack[0]); - } + this.items = list.toArray(new ItemStack[0]); + } } diff --git a/src/main/java/noppes/npcs/controllers/data/PlayerMailData.java b/src/main/java/noppes/npcs/controllers/data/PlayerMailData.java index 3861376ad..7d7aa3b1d 100644 --- a/src/main/java/noppes/npcs/controllers/data/PlayerMailData.java +++ b/src/main/java/noppes/npcs/controllers/data/PlayerMailData.java @@ -8,98 +8,98 @@ import noppes.npcs.api.handler.data.IPlayerMail; import java.util.ArrayList; public class PlayerMailData implements IPlayerMailData { - private final PlayerData parent; - public ArrayList playermail = new ArrayList(); + private final PlayerData parent; + public ArrayList playermail = new ArrayList(); - public PlayerMailData() { - this.parent = null; - } + public PlayerMailData() { + this.parent = null; + } - public PlayerMailData(PlayerData parent) { - this.parent = parent; - } + public PlayerMailData(PlayerData parent) { + this.parent = parent; + } - public void loadNBTData(NBTTagCompound compound) { - ArrayList newmail = new ArrayList(); - NBTTagList list = compound.getTagList("MailData", 10); - if(list == null) - return; - - for(int i = 0; i < list.tagCount(); i++){ - PlayerMail mail = new PlayerMail(); - mail.readNBT(list.getCompoundTagAt(i)); - newmail.add(mail); - } - playermail = newmail; - } + public void loadNBTData(NBTTagCompound compound) { + ArrayList newmail = new ArrayList(); + NBTTagList list = compound.getTagList("MailData", 10); + if (list == null) + return; - public NBTTagCompound saveNBTData(NBTTagCompound compound) { - NBTTagList list = new NBTTagList(); - - for(PlayerMail mail : playermail){ - list.appendTag(mail.writeNBT()); - } - - compound.setTag("MailData", list); - return compound; - } + for (int i = 0; i < list.tagCount(); i++) { + PlayerMail mail = new PlayerMail(); + mail.readNBT(list.getCompoundTagAt(i)); + newmail.add(mail); + } + playermail = newmail; + } - public boolean hasMail() { - for(PlayerMail mail : playermail) - if(!mail.beenRead) - return true; - return false; - } + public NBTTagCompound saveNBTData(NBTTagCompound compound) { + NBTTagList list = new NBTTagList(); - public void addMail(IPlayerMail mail) { - playermail.add((PlayerMail) mail); - } + for (PlayerMail mail : playermail) { + list.appendTag(mail.writeNBT()); + } - public void removeMail(IPlayerMail mail) { - playermail.remove((PlayerMail) mail); - } + compound.setTag("MailData", list); + return compound; + } - public boolean hasMail(IPlayerMail mail) { - return playermail.contains((PlayerMail) mail); - } + public boolean hasMail() { + for (PlayerMail mail : playermail) + if (!mail.beenRead) + return true; + return false; + } - public IPlayerMail[] getAllMail() { - return playermail.toArray(new IPlayerMail[0]); - } + public void addMail(IPlayerMail mail) { + playermail.add((PlayerMail) mail); + } - public IPlayerMail[] getUnreadMail() { - ArrayList mails = new ArrayList<>(); + public void removeMail(IPlayerMail mail) { + playermail.remove((PlayerMail) mail); + } - for (PlayerMail mail : playermail) { - if (!mail.beenRead) { - mails.add(mail); - } - } + public boolean hasMail(IPlayerMail mail) { + return playermail.contains((PlayerMail) mail); + } - return mails.toArray(new IPlayerMail[0]); - } + public IPlayerMail[] getAllMail() { + return playermail.toArray(new IPlayerMail[0]); + } - public IPlayerMail[] getReadMail() { - ArrayList mails = new ArrayList<>(); + public IPlayerMail[] getUnreadMail() { + ArrayList mails = new ArrayList<>(); - for (PlayerMail mail : playermail) { - if (mail.beenRead) { - mails.add(mail); - } - } + for (PlayerMail mail : playermail) { + if (!mail.beenRead) { + mails.add(mail); + } + } - return mails.toArray(new IPlayerMail[0]); - } + return mails.toArray(new IPlayerMail[0]); + } - public IPlayerMail[] getMailFrom(String sender) { - ArrayList mails = new ArrayList<>(); + public IPlayerMail[] getReadMail() { + ArrayList mails = new ArrayList<>(); - for (PlayerMail mail : playermail) { - if (mail.sender.equals(sender)) { - mails.add(mail); - } - } + for (PlayerMail mail : playermail) { + if (mail.beenRead) { + mails.add(mail); + } + } - return mails.toArray(new IPlayerMail[0]); - } + return mails.toArray(new IPlayerMail[0]); + } + + public IPlayerMail[] getMailFrom(String sender) { + ArrayList mails = new ArrayList<>(); + + for (PlayerMail mail : playermail) { + if (mail.sender.equals(sender)) { + mails.add(mail); + } + } + + return mails.toArray(new IPlayerMail[0]); + } } diff --git a/src/main/java/noppes/npcs/controllers/data/PlayerQuestData.java b/src/main/java/noppes/npcs/controllers/data/PlayerQuestData.java index cb91cfc7a..dbbd5437e 100644 --- a/src/main/java/noppes/npcs/controllers/data/PlayerQuestData.java +++ b/src/main/java/noppes/npcs/controllers/data/PlayerQuestData.java @@ -14,7 +14,6 @@ import noppes.npcs.api.handler.IPlayerQuestData; import noppes.npcs.api.handler.data.IParty; import noppes.npcs.api.handler.data.IQuest; import noppes.npcs.constants.EnumQuestCompletion; -import noppes.npcs.constants.EnumQuestRepeat; import noppes.npcs.constants.EnumQuestType; import noppes.npcs.controllers.PartyController; import noppes.npcs.controllers.PlayerDataController; @@ -29,103 +28,101 @@ import java.util.HashMap; import java.util.List; public class PlayerQuestData implements IPlayerQuestData { - private final PlayerData parent; - private IQuest trackedQuest = null; + private final PlayerData parent; + private IQuest trackedQuest = null; - public HashMap activeQuests = new HashMap(); - public HashMap finishedQuests = new HashMap(); + public HashMap activeQuests = new HashMap(); + public HashMap finishedQuests = new HashMap(); - public PlayerQuestData(PlayerData parent) { - this.parent = parent; - } + public PlayerQuestData(PlayerData parent) { + this.parent = parent; + } - public void loadNBTData(NBTTagCompound mainCompound) { - if(mainCompound == null) - return; - NBTTagCompound compound = mainCompound.getCompoundTag("QuestData"); + public void loadNBTData(NBTTagCompound mainCompound) { + if (mainCompound == null) + return; + NBTTagCompound compound = mainCompound.getCompoundTag("QuestData"); NBTTagList list = compound.getTagList("CompletedQuests", 10); - if(list != null){ - HashMap finishedQuests = new HashMap(); - for(int i = 0; i < list.tagCount(); i++) - { + if (list != null) { + HashMap finishedQuests = new HashMap(); + for (int i = 0; i < list.tagCount(); i++) { NBTTagCompound nbttagcompound = list.getCompoundTagAt(i); - finishedQuests.put(nbttagcompound.getInteger("Quest"),nbttagcompound.getLong("Date")); + finishedQuests.put(nbttagcompound.getInteger("Quest"), nbttagcompound.getLong("Date")); } this.finishedQuests = finishedQuests; } NBTTagList list2 = compound.getTagList("ActiveQuests", 10); - if(list2 != null){ - HashMap activeQuests = new HashMap(); - for(int i = 0; i < list2.tagCount(); i++) - { + if (list2 != null) { + HashMap activeQuests = new HashMap(); + for (int i = 0; i < list2.tagCount(); i++) { NBTTagCompound nbttagcompound = list2.getCompoundTagAt(i); int id = nbttagcompound.getInteger("Quest"); Quest quest = QuestController.Instance.quests.get(id); - if(quest == null) - continue; + if (quest == null) + continue; QuestData data = new QuestData(quest); data.readEntityFromNBT(nbttagcompound); - activeQuests.put(id,data); + activeQuests.put(id, data); } this.activeQuests = activeQuests; } - this.trackedQuest = QuestController.Instance.get(mainCompound.getInteger("TrackedQuestID")); - } + this.trackedQuest = QuestController.Instance.get(mainCompound.getInteger("TrackedQuestID")); + } - public void saveNBTData(NBTTagCompound maincompound) { - NBTTagCompound compound = new NBTTagCompound(); - NBTTagList list = new NBTTagList(); - for(int quest : finishedQuests.keySet()){ - NBTTagCompound nbttagcompound = new NBTTagCompound(); - nbttagcompound.setInteger("Quest", quest); - nbttagcompound.setLong("Date", finishedQuests.get(quest)); - list.appendTag(nbttagcompound); - } + public void saveNBTData(NBTTagCompound maincompound) { + NBTTagCompound compound = new NBTTagCompound(); + NBTTagList list = new NBTTagList(); + for (int quest : finishedQuests.keySet()) { + NBTTagCompound nbttagcompound = new NBTTagCompound(); + nbttagcompound.setInteger("Quest", quest); + nbttagcompound.setLong("Date", finishedQuests.get(quest)); + list.appendTag(nbttagcompound); + } - compound.setTag("CompletedQuests", list); + compound.setTag("CompletedQuests", list); - NBTTagList list2 = new NBTTagList(); - for(int quest : activeQuests.keySet()){ - NBTTagCompound nbttagcompound = new NBTTagCompound(); - nbttagcompound.setInteger("Quest", quest); - activeQuests.get(quest).writeEntityToNBT(nbttagcompound); - list2.appendTag(nbttagcompound); - } + NBTTagList list2 = new NBTTagList(); + for (int quest : activeQuests.keySet()) { + NBTTagCompound nbttagcompound = new NBTTagCompound(); + nbttagcompound.setInteger("Quest", quest); + activeQuests.get(quest).writeEntityToNBT(nbttagcompound); + list2.appendTag(nbttagcompound); + } - compound.setTag("ActiveQuests", list2); + compound.setTag("ActiveQuests", list2); - maincompound.setTag("QuestData", compound); + maincompound.setTag("QuestData", compound); - if (this.trackedQuest != null) { - maincompound.setInteger("TrackedQuestID", this.trackedQuest.getId()); - } else { - maincompound.setInteger("TrackedQuestID", -1); - } - } + if (this.trackedQuest != null) { + maincompound.setInteger("TrackedQuestID", this.trackedQuest.getId()); + } else { + maincompound.setInteger("TrackedQuestID", -1); + } + } - public QuestData getQuestCompletion(EntityPlayer player,EntityNPCInterface npc) { - PlayerData playerData = PlayerDataController.Instance.getPlayerData(player); - for(QuestData data : activeQuests.values()){ - Quest quest = data.quest; - if(quest != null && quest.completion == EnumQuestCompletion.Npc && quest.completerNpc.equals(npc.getCommandSenderName()) && quest.questInterface.isCompleted(playerData)){ - return data; - } - } - return null; - } - - public Party getPartyQuestCompletion(EntityPlayer player,EntityNPCInterface npc) { + public QuestData getQuestCompletion(EntityPlayer player, EntityNPCInterface npc) { PlayerData playerData = PlayerDataController.Instance.getPlayerData(player); - if(playerData != null){ + for (QuestData data : activeQuests.values()) { + Quest quest = data.quest; + if (quest != null && quest.completion == EnumQuestCompletion.Npc && quest.completerNpc.equals(npc.getCommandSenderName()) && quest.questInterface.isCompleted(playerData)) { + return data; + } + } + return null; + } + + public Party getPartyQuestCompletion(EntityPlayer player, EntityNPCInterface npc) { + PlayerData playerData = PlayerDataController.Instance.getPlayerData(player); + if (playerData != null) { Party party = playerData.getPlayerParty(); - if(party != null){ + if (party != null) { QuestData data = party.getQuestData(); - if(data != null){ + if (data != null) { Quest quest = data.quest; - if(quest != null && quest.completion == EnumQuestCompletion.Npc && quest.completerNpc.equals(npc.getCommandSenderName()) && quest.questInterface.isPartyCompleted(party)){ + if (quest != null && quest.completion == EnumQuestCompletion.Npc && quest.completerNpc.equals(npc.getCommandSenderName()) && quest.questInterface.isPartyCompleted(party)) { return party; } } @@ -134,64 +131,64 @@ public class PlayerQuestData implements IPlayerQuestData { return null; } - public boolean checkQuestCompletion(PlayerData playerData,EnumQuestType type) { - boolean bo = false; - EntityPlayer player = playerData.player; + public boolean checkQuestCompletion(PlayerData playerData, EnumQuestType type) { + boolean bo = false; + EntityPlayer player = playerData.player; int partyQuestID = -1; - if(playerData.partyUUID != null){ + if (playerData.partyUUID != null) { Party party = PartyController.Instance().getParty(playerData.partyUUID); - if(party != null){ + if (party != null) { IQuest quest = party.getQuest(); - if(quest != null){ + if (quest != null) { partyQuestID = quest.getId(); } } } - ArrayList activeQuestValues = new ArrayList<>(this.activeQuests.values()); - for(QuestData data : activeQuestValues){ - if(data.quest.type != type && type != null) - continue; + ArrayList activeQuestValues = new ArrayList<>(this.activeQuests.values()); + for (QuestData data : activeQuestValues) { + if (data.quest.type != type && type != null) + continue; // Check if Active Quest = Party Quest - if(partyQuestID != -1 && data.quest.id == partyQuestID && data.quest.partyOptions.isAllowParty()){ + if (partyQuestID != -1 && data.quest.id == partyQuestID && data.quest.partyOptions.isAllowParty()) { continue; } - if(data.quest.partyOptions.allowParty && data.quest.partyOptions.onlyParty) + if (data.quest.partyOptions.allowParty && data.quest.partyOptions.onlyParty) continue; - QuestInterface inter = data.quest.questInterface; - if(inter.isCompleted(playerData)){ - if((!data.isCompleted && data.quest.completion == EnumQuestCompletion.Npc) || data.quest.instantComplete(player,data)){ - data.isCompleted = true; - if (data.quest.completion == EnumQuestCompletion.Npc) { - EventHooks.onQuestFinished(player, data.quest); - } - bo = true; - } - } else { - data.isCompleted = false; - } + QuestInterface inter = data.quest.questInterface; + if (inter.isCompleted(playerData)) { + if ((!data.isCompleted && data.quest.completion == EnumQuestCompletion.Npc) || data.quest.instantComplete(player, data)) { + data.isCompleted = true; + if (data.quest.completion == EnumQuestCompletion.Npc) { + EventHooks.onQuestFinished(player, data.quest); + } + bo = true; + } + } else { + data.isCompleted = false; + } - if (this.trackedQuest != null && data.quest.getId() == this.trackedQuest.getId()) { - NoppesUtilPlayer.sendTrackedQuestData((EntityPlayerMP) player); - } - } - QuestItem.pickedUp = null; - return bo; - } + if (this.trackedQuest != null && data.quest.getId() == this.trackedQuest.getId()) { + NoppesUtilPlayer.sendTrackedQuestData((EntityPlayerMP) player); + } + } + QuestItem.pickedUp = null; + return bo; + } - public void trackQuest(IQuest quest) { - if (this.trackedQuest == null || quest.getId() != this.trackedQuest.getId()) { - this.trackedQuest = quest; - NoppesUtilPlayer.sendTrackedQuestData((EntityPlayerMP) this.parent.player); - } - } + public void trackQuest(IQuest quest) { + if (this.trackedQuest == null || quest.getId() != this.trackedQuest.getId()) { + this.trackedQuest = quest; + NoppesUtilPlayer.sendTrackedQuestData((EntityPlayerMP) this.parent.player); + } + } public void trackParty(IParty party) { - if(party == null) + if (party == null) return; IQuest quest = party.getQuest(); @@ -201,101 +198,101 @@ public class PlayerQuestData implements IPlayerQuestData { } } - public void untrackQuest() { - if (this.trackedQuest != null) { - this.trackedQuest = null; + public void untrackQuest() { + if (this.trackedQuest != null) { + this.trackedQuest = null; PacketHandler.Instance.sendToPlayer(new OverlayQuestTrackingPacket(new NBTTagCompound()), (EntityPlayerMP) this.parent.player); } - } + } - public IQuest getTrackedQuest() { - return this.trackedQuest; - } + public IQuest getTrackedQuest() { + return this.trackedQuest; + } - public void startQuest(int id) { - Quest quest = QuestController.Instance.quests.get(id); - if (quest == null) - return; - if(activeQuests.containsKey(id)) - return; - QuestData questdata = new QuestData(quest); - activeQuests.put(id, questdata); + public void startQuest(int id) { + Quest quest = QuestController.Instance.quests.get(id); + if (quest == null) + return; + if (activeQuests.containsKey(id)) + return; + QuestData questdata = new QuestData(quest); + activeQuests.put(id, questdata); AchievementPacket.sendAchievement((EntityPlayerMP) parent.player, false, "quest.newquest", quest.title); ChatAlertPacket.sendChatAlert((EntityPlayerMP) parent.player, "quest.newquest", ": ", quest.title); parent.updateClient = true; - } + } - public void finishQuest(int id) { - Quest quest = QuestController.Instance.quests.get(id); - if (quest == null) - return; + public void finishQuest(int id) { + Quest quest = QuestController.Instance.quests.get(id); + if (quest == null) + return; PlayerQuestController.setQuestFinished(quest, parent.player); parent.updateClient = true; - } + } - public void stopQuest(int id) { - Quest quest = QuestController.Instance.quests.get(id); - if (quest == null) - return; - activeQuests.remove(id); + public void stopQuest(int id) { + Quest quest = QuestController.Instance.quests.get(id); + if (quest == null) + return; + activeQuests.remove(id); parent.updateClient = true; - } + } - public void removeQuest(int id) { - Quest quest = QuestController.Instance.quests.get(id); - if (quest == null) - return; - activeQuests.remove(id); - finishedQuests.remove(id); + public void removeQuest(int id) { + Quest quest = QuestController.Instance.quests.get(id); + if (quest == null) + return; + activeQuests.remove(id); + finishedQuests.remove(id); parent.updateClient = true; - } + } - public boolean hasFinishedQuest(int id){ - return finishedQuests.containsKey(id); - } + public boolean hasFinishedQuest(int id) { + return finishedQuests.containsKey(id); + } - public boolean hasActiveQuest(int id){ - return activeQuests.containsKey(id); - } + public boolean hasActiveQuest(int id) { + return activeQuests.containsKey(id); + } - public IQuest[] getActiveQuests() { - List quests = new ArrayList<>(); + public IQuest[] getActiveQuests() { + List quests = new ArrayList<>(); - for (int id : activeQuests.keySet()) { - IQuest quest = (IQuest) QuestController.Instance.quests.get(id); - if (quest != null) { - quests.add(quest); - } - } + for (int id : activeQuests.keySet()) { + IQuest quest = (IQuest) QuestController.Instance.quests.get(id); + if (quest != null) { + quests.add(quest); + } + } - return (IQuest[])quests.toArray(new IQuest[0]); - } + return (IQuest[]) quests.toArray(new IQuest[0]); + } - public IQuest[] getFinishedQuests() { - List quests = new ArrayList<>(); + public IQuest[] getFinishedQuests() { + List quests = new ArrayList<>(); - for (int id : finishedQuests.keySet()) { - IQuest quest = (IQuest) QuestController.Instance.quests.get(id); - if (quest != null) { - quests.add(quest); - } - } + for (int id : finishedQuests.keySet()) { + IQuest quest = (IQuest) QuestController.Instance.quests.get(id); + if (quest != null) { + quests.add(quest); + } + } - return (IQuest[])quests.toArray(new IQuest[0]); - } + return (IQuest[]) quests.toArray(new IQuest[0]); + } - public long getLastCompletedTime(int id) { - if (this.hasFinishedQuest(id)) { - return this.finishedQuests.get(id); - } - return 0; - } + public long getLastCompletedTime(int id) { + if (this.hasFinishedQuest(id)) { + return this.finishedQuests.get(id); + } + return 0; + } - public void setLastCompletedTime(int id,long time) { - Quest quest = QuestController.Instance.quests.get(id); - if (quest == null) - return; - this.finishedQuests.put(id,time); - } + public void setLastCompletedTime(int id, long time) { + Quest quest = QuestController.Instance.quests.get(id); + if (quest == null) + return; + this.finishedQuests.put(id, time); + } } diff --git a/src/main/java/noppes/npcs/controllers/data/PlayerTransportData.java b/src/main/java/noppes/npcs/controllers/data/PlayerTransportData.java index 0893c31eb..4aac0fa7b 100644 --- a/src/main/java/noppes/npcs/controllers/data/PlayerTransportData.java +++ b/src/main/java/noppes/npcs/controllers/data/PlayerTransportData.java @@ -10,68 +10,67 @@ import java.util.ArrayList; import java.util.HashSet; public class PlayerTransportData implements IPlayerTransportData { - private final PlayerData parent; - public HashSet transports = new HashSet(); + private final PlayerData parent; + public HashSet transports = new HashSet(); - public PlayerTransportData(PlayerData parent) { - this.parent = parent; - } + public PlayerTransportData(PlayerData parent) { + this.parent = parent; + } - public void loadNBTData(NBTTagCompound compound) { - HashSet dialogsRead = new HashSet(); - if(compound == null) - return; + public void loadNBTData(NBTTagCompound compound) { + HashSet dialogsRead = new HashSet(); + if (compound == null) + return; NBTTagList list = compound.getTagList("TransportData", 10); - if(list == null){ - return; + if (list == null) { + return; } - for(int i = 0; i < list.tagCount(); i++) - { + for (int i = 0; i < list.tagCount(); i++) { NBTTagCompound nbttagcompound = list.getCompoundTagAt(i); dialogsRead.add(nbttagcompound.getInteger("Transport")); } this.transports = dialogsRead; - } + } - public void saveNBTData(NBTTagCompound compound) { - NBTTagList list = new NBTTagList(); - for(int dia : transports){ - NBTTagCompound nbttagcompound = new NBTTagCompound(); - nbttagcompound.setInteger("Transport", dia); - list.appendTag(nbttagcompound); - } - - compound.setTag("TransportData", list); - } + public void saveNBTData(NBTTagCompound compound) { + NBTTagList list = new NBTTagList(); + for (int dia : transports) { + NBTTagCompound nbttagcompound = new NBTTagCompound(); + nbttagcompound.setInteger("Transport", dia); + list.appendTag(nbttagcompound); + } - public boolean hasTransport(int id) { - return transports.contains(id); - } + compound.setTag("TransportData", list); + } - public void addTransport(int id) { - transports.add(id); - } + public boolean hasTransport(int id) { + return transports.contains(id); + } - public void addTransport(ITransportLocation location) { - transports.add(location.getId()); - } + public void addTransport(int id) { + transports.add(id); + } - public ITransportLocation getTransport(int id) { - return TransportController.getInstance().getTransport(id); - } + public void addTransport(ITransportLocation location) { + transports.add(location.getId()); + } - public ITransportLocation[] getTransports() { - ArrayList list = new ArrayList<>(); - for (int id : transports) { - ITransportLocation location = TransportController.getInstance().getTransport(id); - list.add(location); - } + public ITransportLocation getTransport(int id) { + return TransportController.getInstance().getTransport(id); + } - return list.toArray(new ITransportLocation[0]); - } + public ITransportLocation[] getTransports() { + ArrayList list = new ArrayList<>(); + for (int id : transports) { + ITransportLocation location = TransportController.getInstance().getTransport(id); + list.add(location); + } - public void removeTransport(int id) { - transports.remove(id); - } + return list.toArray(new ITransportLocation[0]); + } + + public void removeTransport(int id) { + transports.remove(id); + } } diff --git a/src/main/java/noppes/npcs/controllers/data/ProfileOptions.java b/src/main/java/noppes/npcs/controllers/data/ProfileOptions.java index 5605f1b63..231f42451 100644 --- a/src/main/java/noppes/npcs/controllers/data/ProfileOptions.java +++ b/src/main/java/noppes/npcs/controllers/data/ProfileOptions.java @@ -5,71 +5,68 @@ import noppes.npcs.api.handler.data.IProfileOptions; import noppes.npcs.constants.EnumProfileSync; public class ProfileOptions implements IProfileOptions { - public boolean enableOptions = false; + public boolean enableOptions = false; public EnumProfileSync cooldownControl = EnumProfileSync.Individual; - public EnumProfileSync completeControl = EnumProfileSync.Individual; + public EnumProfileSync completeControl = EnumProfileSync.Individual; - public void readFromNBT(NBTTagCompound compound) - { - // Party Management + public void readFromNBT(NBTTagCompound compound) { + // Party Management enableOptions = compound.getBoolean("EnableProfiles"); - if(enableOptions){ + if (enableOptions) { cooldownControl = EnumProfileSync.values()[compound.getInteger("CooldownControl")]; completeControl = EnumProfileSync.values()[compound.getInteger("CompleteControl")]; - } - else { - if(compound.hasKey("CooldownControl")){ + } else { + if (compound.hasKey("CooldownControl")) { compound.removeTag("CooldownControl"); } - if(compound.hasKey("CompleteControl")){ - compound.removeTag("CompleteControl"); - } + if (compound.hasKey("CompleteControl")) { + compound.removeTag("CompleteControl"); + } cooldownControl = EnumProfileSync.Individual; completeControl = EnumProfileSync.Individual; - } + } } - public NBTTagCompound writeToNBT() - { - NBTTagCompound compound = new NBTTagCompound(); - compound.setBoolean("EnableProfiles", enableOptions); - if(enableOptions){ - compound.setInteger("CooldownControl", cooldownControl.ordinal()); - compound.setInteger("CompleteControl", completeControl.ordinal()); - } - else { - if(compound.hasKey("CooldownControl")){ + + public NBTTagCompound writeToNBT() { + NBTTagCompound compound = new NBTTagCompound(); + compound.setBoolean("EnableProfiles", enableOptions); + if (enableOptions) { + compound.setInteger("CooldownControl", cooldownControl.ordinal()); + compound.setInteger("CompleteControl", completeControl.ordinal()); + } else { + if (compound.hasKey("CooldownControl")) { compound.removeTag("CooldownControl"); } - if(compound.hasKey("CompleteControl")){ - compound.removeTag("CompleteControl"); - } - } + if (compound.hasKey("CompleteControl")) { + compound.removeTag("CompleteControl"); + } + } - return compound; + return compound; } @Override - public boolean hasProfileOptions() { - return enableOptions; - } + public boolean hasProfileOptions() { + return enableOptions; + } @Override - public void setProfileOptions(boolean enable) { - this.enableOptions = enable; - } + public void setProfileOptions(boolean enable) { + this.enableOptions = enable; + } @Override - public void setCooldownControl(int profileType) { - if (profileType < 0 || profileType >= EnumProfileSync.values().length) { - return; - } - this.cooldownControl = EnumProfileSync.values()[profileType]; - } + public void setCooldownControl(int profileType) { + if (profileType < 0 || profileType >= EnumProfileSync.values().length) { + return; + } + this.cooldownControl = EnumProfileSync.values()[profileType]; + } @Override - public int getCooldownControl(){ + public int getCooldownControl() { return this.cooldownControl.ordinal(); } @@ -82,7 +79,7 @@ public class ProfileOptions implements IProfileOptions { } @Override - public int getCompleteControl(){ + public int getCompleteControl() { return this.completeControl.ordinal(); } } diff --git a/src/main/java/noppes/npcs/controllers/data/Quest.java b/src/main/java/noppes/npcs/controllers/data/Quest.java index d7f8ccdf8..5d7b11533 100644 --- a/src/main/java/noppes/npcs/controllers/data/Quest.java +++ b/src/main/java/noppes/npcs/controllers/data/Quest.java @@ -1,7 +1,6 @@ package noppes.npcs.controllers.data; import kamkeel.npcs.controllers.ProfileController; -import noppes.npcs.api.handler.data.ISlot; import kamkeel.npcs.controllers.data.profile.Profile; import kamkeel.npcs.network.packets.data.QuestCompletionPacket; import net.minecraft.entity.player.EntityPlayer; @@ -25,148 +24,149 @@ import noppes.npcs.scripted.CustomNPCsException; import noppes.npcs.scripted.NpcAPI; public class Quest implements ICompatibilty, IQuest { - public int version = VersionCompatibility.ModRev; - public int id = -1; - public EnumQuestType type = EnumQuestType.Item; - public EnumQuestRepeat repeat = EnumQuestRepeat.NONE; - public EnumQuestCompletion completion = EnumQuestCompletion.Npc; - public String title = "default"; - public QuestCategory category; - public String logText = ""; - public String completeText = ""; - public String completerNpc = ""; - public int nextQuestid = -1; - public String nextQuestTitle = ""; - public PlayerMail mail = new PlayerMail(); - public String command = ""; + public int version = VersionCompatibility.ModRev; + public int id = -1; + public EnumQuestType type = EnumQuestType.Item; + public EnumQuestRepeat repeat = EnumQuestRepeat.NONE; + public EnumQuestCompletion completion = EnumQuestCompletion.Npc; + public String title = "default"; + public QuestCategory category; + public String logText = ""; + public String completeText = ""; + public String completerNpc = ""; + public int nextQuestid = -1; + public String nextQuestTitle = ""; + public PlayerMail mail = new PlayerMail(); + public String command = ""; - public QuestInterface questInterface = new QuestItem(); + public QuestInterface questInterface = new QuestItem(); public long customCooldown = 0; - public int rewardExp = 0; - public NpcMiscInventory rewardItems = new NpcMiscInventory(9); - public boolean randomReward = false; - public FactionOptions factionOptions = new FactionOptions(); - public PartyOptions partyOptions = new PartyOptions(); + public int rewardExp = 0; + public NpcMiscInventory rewardItems = new NpcMiscInventory(9); + public boolean randomReward = false; + public FactionOptions factionOptions = new FactionOptions(); + public PartyOptions partyOptions = new PartyOptions(); public ProfileOptions profileOptions = new ProfileOptions(); - public void readNBT(NBTTagCompound compound) { - id = compound.getInteger("Id"); - readNBTPartial(compound); - } - public void readNBTPartial(NBTTagCompound compound) { - version = compound.getInteger("ModRev"); - VersionCompatibility.CheckAvailabilityCompatibility(this, compound); + public void readNBT(NBTTagCompound compound) { + id = compound.getInteger("Id"); + readNBTPartial(compound); + } - setType(EnumQuestType.values()[compound.getInteger("Type")]); - title = compound.getString("Title"); - logText = compound.getString("Text"); - completeText = compound.getString("CompleteText"); - completerNpc = compound.getString("CompleterNpc"); - command = compound.getString("QuestCommand"); - nextQuestid = compound.getInteger("NextQuestId"); - nextQuestTitle = compound.getString("NextQuestTitle"); - if(hasNewQuest()) - nextQuestTitle = getNextQuest().title; - else - nextQuestTitle = ""; - randomReward = compound.getBoolean("RandomReward"); - rewardExp = compound.getInteger("RewardExp"); - rewardItems.setFromNBT(compound.getCompoundTag("Rewards")); + public void readNBTPartial(NBTTagCompound compound) { + version = compound.getInteger("ModRev"); + VersionCompatibility.CheckAvailabilityCompatibility(this, compound); - completion = EnumQuestCompletion.values()[compound.getInteger("QuestCompletion")]; - repeat = EnumQuestRepeat.values()[compound.getInteger("QuestRepeat")]; + setType(EnumQuestType.values()[compound.getInteger("Type")]); + title = compound.getString("Title"); + logText = compound.getString("Text"); + completeText = compound.getString("CompleteText"); + completerNpc = compound.getString("CompleterNpc"); + command = compound.getString("QuestCommand"); + nextQuestid = compound.getInteger("NextQuestId"); + nextQuestTitle = compound.getString("NextQuestTitle"); + if (hasNewQuest()) + nextQuestTitle = getNextQuest().title; + else + nextQuestTitle = ""; + randomReward = compound.getBoolean("RandomReward"); + rewardExp = compound.getInteger("RewardExp"); + rewardItems.setFromNBT(compound.getCompoundTag("Rewards")); + + completion = EnumQuestCompletion.values()[compound.getInteger("QuestCompletion")]; + repeat = EnumQuestRepeat.values()[compound.getInteger("QuestRepeat")]; customCooldown = compound.getLong("CustomCooldown"); - questInterface.readEntityFromNBT(compound); + questInterface.readEntityFromNBT(compound); - factionOptions.readFromNBT(compound.getCompoundTag("QuestFactionPoints")); - partyOptions.readFromNBT(compound.getCompoundTag("PartyOptions")); + factionOptions.readFromNBT(compound.getCompoundTag("QuestFactionPoints")); + partyOptions.readFromNBT(compound.getCompoundTag("PartyOptions")); profileOptions.readFromNBT(compound.getCompoundTag("ProfileOptions")); - mail.readNBT(compound.getCompoundTag("QuestMail")); - } + mail.readNBT(compound.getCompoundTag("QuestMail")); + } - public void setType(EnumQuestType questType) { - type = questType; - if(type == EnumQuestType.Item) - questInterface = new QuestItem(); - else if(type == EnumQuestType.Dialog) - questInterface = new QuestDialog(); - else if(type == EnumQuestType.Kill || type == EnumQuestType.AreaKill) - questInterface = new QuestKill(); - else if(type == EnumQuestType.Location) - questInterface = new QuestLocation(); - else if(type == EnumQuestType.Manual) + public void setType(EnumQuestType questType) { + type = questType; + if (type == EnumQuestType.Item) + questInterface = new QuestItem(); + else if (type == EnumQuestType.Dialog) + questInterface = new QuestDialog(); + else if (type == EnumQuestType.Kill || type == EnumQuestType.AreaKill) + questInterface = new QuestKill(); + else if (type == EnumQuestType.Location) + questInterface = new QuestLocation(); + else if (type == EnumQuestType.Manual) questInterface = new QuestManual(); - if(questInterface != null) - questInterface.questId = id; - } + if (questInterface != null) + questInterface.questId = id; + } - public NBTTagCompound writeToNBT(NBTTagCompound compound) { - compound.setInteger("Id", id); - return writeToNBTPartial(compound); - } - public NBTTagCompound writeToNBTPartial(NBTTagCompound compound) { - compound.setInteger("ModRev", version); - compound.setInteger("Type", type.ordinal()); - compound.setString("Title", title); - compound.setString("Text", logText); - compound.setString("CompleteText", completeText); - compound.setString("CompleterNpc", completerNpc); - compound.setInteger("NextQuestId", nextQuestid); - compound.setString("NextQuestTitle", nextQuestTitle); - compound.setInteger("RewardExp", rewardExp); - compound.setTag("Rewards", rewardItems.getToNBT()); - compound.setString("QuestCommand", command); - compound.setBoolean("RandomReward", randomReward); + public NBTTagCompound writeToNBT(NBTTagCompound compound) { + compound.setInteger("Id", id); + return writeToNBTPartial(compound); + } + + public NBTTagCompound writeToNBTPartial(NBTTagCompound compound) { + compound.setInteger("ModRev", version); + compound.setInteger("Type", type.ordinal()); + compound.setString("Title", title); + compound.setString("Text", logText); + compound.setString("CompleteText", completeText); + compound.setString("CompleterNpc", completerNpc); + compound.setInteger("NextQuestId", nextQuestid); + compound.setString("NextQuestTitle", nextQuestTitle); + compound.setInteger("RewardExp", rewardExp); + compound.setTag("Rewards", rewardItems.getToNBT()); + compound.setString("QuestCommand", command); + compound.setBoolean("RandomReward", randomReward); compound.setLong("CustomCooldown", customCooldown); - compound.setInteger("QuestCompletion", completion.ordinal()); - compound.setInteger("QuestRepeat", repeat.ordinal()); + compound.setInteger("QuestCompletion", completion.ordinal()); + compound.setInteger("QuestRepeat", repeat.ordinal()); - this.questInterface.writeEntityToNBT(compound); - compound.setTag("QuestFactionPoints", factionOptions.writeToNBT(new NBTTagCompound())); - compound.setTag("PartyOptions", partyOptions.writeToNBT()); + this.questInterface.writeEntityToNBT(compound); + compound.setTag("QuestFactionPoints", factionOptions.writeToNBT(new NBTTagCompound())); + compound.setTag("PartyOptions", partyOptions.writeToNBT()); compound.setTag("ProfileOptions", profileOptions.writeToNBT()); - compound.setTag("QuestMail", mail.writeNBT()); + compound.setTag("QuestMail", mail.writeNBT()); - return compound; - } + return compound; + } - public boolean hasNewQuest() - { - return getNextQuest() != null; - } - public Quest getNextQuest() - { - return QuestController.Instance == null?null:QuestController.Instance.quests.get(nextQuestid); - } + public boolean hasNewQuest() { + return getNextQuest() != null; + } - public boolean instantComplete(EntityPlayer player, QuestData data) { - if(completion == EnumQuestCompletion.Instant && NoppesUtilPlayer.questCompletion((EntityPlayerMP) player, data.quest.id)){ - QuestCompletionPacket.sendQuestComplete((EntityPlayerMP)player, data.quest.writeToNBT(new NBTTagCompound())); - return true; - } - return false; - } + public Quest getNextQuest() { + return QuestController.Instance == null ? null : QuestController.Instance.quests.get(nextQuestid); + } + + public boolean instantComplete(EntityPlayer player, QuestData data) { + if (completion == EnumQuestCompletion.Instant && NoppesUtilPlayer.questCompletion((EntityPlayerMP) player, data.quest.id)) { + QuestCompletionPacket.sendQuestComplete((EntityPlayerMP) player, data.quest.writeToNBT(new NBTTagCompound())); + return true; + } + return false; + } public boolean instantPartyComplete(Party party) { return completion == EnumQuestCompletion.Instant && NoppesUtilPlayer.questPartyCompletion(party); } - public Quest copy(){ - Quest quest = new Quest(); - quest.readNBT(this.writeToNBT(new NBTTagCompound())); - return quest; - } + public Quest copy() { + Quest quest = new Quest(); + quest.readNBT(this.writeToNBT(new NBTTagCompound())); + return quest; + } public long getTimeUntilRepeat(EntityPlayer player) { - if(ConfigMain.ProfilesEnabled && profileOptions.enableOptions && profileOptions.cooldownControl == EnumProfileSync.Shared){ + if (ConfigMain.ProfilesEnabled && profileOptions.enableOptions && profileOptions.cooldownControl == EnumProfileSync.Shared) { Profile profile = ProfileController.Instance.getProfile(player); IPlayer iPlayer = NoppesUtilServer.getIPlayer(player); long timeRemaining = 0L; - for(ISlot slot : profile.getSlots().values()){ + for (ISlot slot : profile.getSlots().values()) { IPlayerData playerData = ProfileController.Instance.getSlotPlayerData(iPlayer, slot.getId()); IPlayerQuestData iPlayerQuestData = playerData.getQuestData(); timeRemaining = Math.max(timeRemaining, getTimeUntilRepeatQuestData(player, iPlayerQuestData)); @@ -177,7 +177,7 @@ public class Quest implements ICompatibilty, IQuest { return getTimeUntilRepeatQuestData(player, questData); } - public long getTimeUntilRepeatQuestData(EntityPlayer player, IPlayerQuestData questData){ + public long getTimeUntilRepeatQuestData(EntityPlayer player, IPlayerQuestData questData) { long questTime = questData.getLastCompletedTime(this.id); switch (repeat) { @@ -251,123 +251,124 @@ public class Quest implements ICompatibilty, IQuest { @Override - public int getVersion() { - return version; - } - @Override - public void setVersion(int version) { - this.version = version; - } + public int getVersion() { + return version; + } - public int getId() { - return this.id; - } + @Override + public void setVersion(int version) { + this.version = version; + } - public String getName() { - return this.title; - } + public int getId() { + return this.id; + } - public int getType() { - return this.type.ordinal(); - } + public String getName() { + return this.title; + } - public void setType(int questType) { - if(questType < 0 || questType >= EnumQuestType.values().length) - return; + public int getType() { + return this.type.ordinal(); + } - EnumQuestType type = EnumQuestType.values()[questType]; - setType(type); - } + public void setType(int questType) { + if (questType < 0 || questType >= EnumQuestType.values().length) + return; - public IQuestCategory getCategory() { - return this.category; - } + EnumQuestType type = EnumQuestType.values()[questType]; + setType(type); + } - public void save() { - QuestController.Instance.saveQuest(this.category.id, this); - } + public IQuestCategory getCategory() { + return this.category; + } - public void setName(String name) { - this.title = name; - } + public void save() { + QuestController.Instance.saveQuest(this.category.id, this); + } - public String getLogText() { - return this.logText; - } + public void setName(String name) { + this.title = name; + } - public void setLogText(String text) { - this.logText = text; - } + public String getLogText() { + return this.logText; + } - public String getCompleteText() { - return this.completeText; - } + public void setLogText(String text) { + this.logText = text; + } - public void setCompleteText(String text) { - this.completeText = text; - } + public String getCompleteText() { + return this.completeText; + } - public void setNextQuest(IQuest quest) { - if (quest == null) { - this.nextQuestid = -1; - this.nextQuestTitle = ""; - } else { - if (quest.getId() < 0) { - throw new CustomNPCsException("Quest id is lower than 0", new Object[0]); - } + public void setCompleteText(String text) { + this.completeText = text; + } - this.nextQuestid = quest.getId(); - this.nextQuestTitle = quest.getName(); - } + public void setNextQuest(IQuest quest) { + if (quest == null) { + this.nextQuestid = -1; + this.nextQuestTitle = ""; + } else { + if (quest.getId() < 0) { + throw new CustomNPCsException("Quest id is lower than 0", new Object[0]); + } - } + this.nextQuestid = quest.getId(); + this.nextQuestTitle = quest.getName(); + } - public String getNpcName() { - return this.completerNpc; - } + } - public void setNpcName(String name) { - this.completerNpc = name; - } + public String getNpcName() { + return this.completerNpc; + } - public IQuestObjective[] getObjectives(IPlayer player) { - if (!player.hasActiveQuest(this.id)) { - throw new CustomNPCsException("Player doesnt have this quest active.", new Object[0]); - } else { - return this.questInterface.getObjectives((EntityPlayer) player.getMCEntity()); - } - } + public void setNpcName(String name) { + this.completerNpc = name; + } - public boolean getIsRepeatable() { - return this.repeat != EnumQuestRepeat.NONE; - } + public IQuestObjective[] getObjectives(IPlayer player) { + if (!player.hasActiveQuest(this.id)) { + throw new CustomNPCsException("Player doesnt have this quest active.", new Object[0]); + } else { + return this.questInterface.getObjectives((EntityPlayer) player.getMCEntity()); + } + } - public long getTimeUntilRepeat(IPlayer player) { - return this.getTimeUntilRepeat((EntityPlayer) player.getMCEntity()); - } + public boolean getIsRepeatable() { + return this.repeat != EnumQuestRepeat.NONE; + } - public void setRepeatType(int type) { - if (type < 0 || type >= EnumQuestRepeat.values().length) { - return; - } - this.repeat = EnumQuestRepeat.values()[type]; - } + public long getTimeUntilRepeat(IPlayer player) { + return this.getTimeUntilRepeat((EntityPlayer) player.getMCEntity()); + } - public int getRepeatType() { - return this.repeat.ordinal(); - } + public void setRepeatType(int type) { + if (type < 0 || type >= EnumQuestRepeat.values().length) { + return; + } + this.repeat = EnumQuestRepeat.values()[type]; + } - public IContainer getRewards() { - return NpcAPI.Instance().getIContainer(this.rewardItems); - } + public int getRepeatType() { + return this.repeat.ordinal(); + } - public IQuestInterface getQuestInterface(){ - return this.questInterface; - } + public IContainer getRewards() { + return NpcAPI.Instance().getIContainer(this.rewardItems); + } - public IPartyOptions getPartyOptions() { - return this.partyOptions; - } + public IQuestInterface getQuestInterface() { + return this.questInterface; + } + + public IPartyOptions getPartyOptions() { + return this.partyOptions; + } public IProfileOptions getProfileOptions() { return this.profileOptions; diff --git a/src/main/java/noppes/npcs/controllers/data/QuestCategory.java b/src/main/java/noppes/npcs/controllers/data/QuestCategory.java index 8cf178971..c35c41dff 100644 --- a/src/main/java/noppes/npcs/controllers/data/QuestCategory.java +++ b/src/main/java/noppes/npcs/controllers/data/QuestCategory.java @@ -10,43 +10,42 @@ import java.util.HashMap; import java.util.List; public class QuestCategory implements IQuestCategory { - public HashMap quests; - public int id = -1; - public String title = ""; + public HashMap quests; + public int id = -1; + public String title = ""; - public QuestCategory(){ - quests = new HashMap(); - } + public QuestCategory() { + quests = new HashMap(); + } - public void readNBT(NBTTagCompound nbttagcompound) { + public void readNBT(NBTTagCompound nbttagcompound) { id = nbttagcompound.getInteger("Slot"); title = nbttagcompound.getString("Title"); NBTTagList questList = nbttagcompound.getTagList("Quests", 10); - if(questList != null){ - for(int ii = 0; ii < questList.tagCount(); ii++) - { + if (questList != null) { + for (int ii = 0; ii < questList.tagCount(); ii++) { NBTTagCompound nbttagcompound2 = questList.getCompoundTagAt(ii); Quest quest = new Quest(); quest.readNBT(nbttagcompound2); quest.category = this; - quests.put(quest.id, quest); + quests.put(quest.id, quest); } } - } + } - public NBTTagCompound writeNBT(NBTTagCompound nbttagcompound) { - nbttagcompound.setInteger("Slot", id); - nbttagcompound.setString("Title", title); + public NBTTagCompound writeNBT(NBTTagCompound nbttagcompound) { + nbttagcompound.setInteger("Slot", id); + nbttagcompound.setString("Title", title); NBTTagList quests = new NBTTagList(); - for(int questID : this.quests.keySet()){ - Quest quest = this.quests.get(questID); - quests.appendTag(quest.writeToNBT(new NBTTagCompound())); + for (int questID : this.quests.keySet()) { + Quest quest = this.quests.get(questID); + quests.appendTag(quest.writeToNBT(new NBTTagCompound())); } nbttagcompound.setTag("Quests", quests); return nbttagcompound; - } + } public NBTTagCompound writeSmallNBT(NBTTagCompound nbttagcompound) { nbttagcompound.setInteger("Slot", id); diff --git a/src/main/java/noppes/npcs/controllers/data/QuestData.java b/src/main/java/noppes/npcs/controllers/data/QuestData.java index d19fd30dc..418ba928a 100644 --- a/src/main/java/noppes/npcs/controllers/data/QuestData.java +++ b/src/main/java/noppes/npcs/controllers/data/QuestData.java @@ -3,21 +3,24 @@ package noppes.npcs.controllers.data; import net.minecraft.nbt.NBTTagCompound; public class QuestData { - public Quest quest; - public boolean isCompleted; - public boolean sendAlerts = true; - public NBTTagCompound extraData = new NBTTagCompound(); - public QuestData(Quest quest){ - this.quest = quest; - } - public void writeEntityToNBT(NBTTagCompound nbttagcompound){ - nbttagcompound.setBoolean("QuestCompleted", isCompleted); - nbttagcompound.setBoolean("SendAlerts", sendAlerts); - nbttagcompound.setTag("ExtraData", extraData); - } - public void readEntityFromNBT(NBTTagCompound nbttagcompound){ - isCompleted = nbttagcompound.getBoolean("QuestCompleted"); - sendAlerts = nbttagcompound.getBoolean("SendAlerts"); - extraData = nbttagcompound.getCompoundTag("ExtraData"); - } + public Quest quest; + public boolean isCompleted; + public boolean sendAlerts = true; + public NBTTagCompound extraData = new NBTTagCompound(); + + public QuestData(Quest quest) { + this.quest = quest; + } + + public void writeEntityToNBT(NBTTagCompound nbttagcompound) { + nbttagcompound.setBoolean("QuestCompleted", isCompleted); + nbttagcompound.setBoolean("SendAlerts", sendAlerts); + nbttagcompound.setTag("ExtraData", extraData); + } + + public void readEntityFromNBT(NBTTagCompound nbttagcompound) { + isCompleted = nbttagcompound.getBoolean("QuestCompleted"); + sendAlerts = nbttagcompound.getBoolean("SendAlerts"); + extraData = nbttagcompound.getCompoundTag("ExtraData"); + } } diff --git a/src/main/java/noppes/npcs/controllers/data/RecipeAnvil.java b/src/main/java/noppes/npcs/controllers/data/RecipeAnvil.java index 2b6291bd8..fe6fd0905 100644 --- a/src/main/java/noppes/npcs/controllers/data/RecipeAnvil.java +++ b/src/main/java/noppes/npcs/controllers/data/RecipeAnvil.java @@ -23,7 +23,8 @@ public class RecipeAnvil implements IAnvilRecipe { private boolean isAnvil = true; - public RecipeAnvil() { } + public RecipeAnvil() { + } public RecipeAnvil(String name, ItemStack itemToRepair, ItemStack repairMaterial, int xpCost, float repairPercentage) { this.name = name; @@ -56,10 +57,10 @@ public class RecipeAnvil implements IAnvilRecipe { compound.setTag("Availability", availability.writeToNBT(new NBTTagCompound())); compound.setInteger("XPCost", xpCost); compound.setFloat("RepairPercentage", repairPercentage); - if(itemToRepair != null){ + if (itemToRepair != null) { compound.setTag("ItemToRepair", NoppesUtilServer.writeItem(itemToRepair, new NBTTagCompound())); } - if(repairMaterial != null){ + if (repairMaterial != null) { compound.setTag("RepairMaterial", NoppesUtilServer.writeItem(repairMaterial, new NBTTagCompound())); } compound.setBoolean("IgnoreRepairMatNBT", ignoreRepairMaterialNBT); @@ -144,7 +145,8 @@ public class RecipeAnvil implements IAnvilRecipe { this.ignoreRepairMaterialDamage = recipe.ignoreRepairMaterialDamage; this.ignoreRepairItemNBT = recipe.ignoreRepairItemNBT; this.ignoreRepairMaterialNBT = recipe.ignoreRepairMaterialNBT; - this.repairPercentage = recipe.repairPercentage;; + this.repairPercentage = recipe.repairPercentage; + ; this.xpCost = recipe.xpCost; } } diff --git a/src/main/java/noppes/npcs/controllers/data/RecipeCarpentry.java b/src/main/java/noppes/npcs/controllers/data/RecipeCarpentry.java index 809d59df4..da03b548c 100644 --- a/src/main/java/noppes/npcs/controllers/data/RecipeCarpentry.java +++ b/src/main/java/noppes/npcs/controllers/data/RecipeCarpentry.java @@ -17,55 +17,56 @@ import java.io.IOException; import java.util.HashMap; public class RecipeCarpentry extends ShapedRecipes implements IRecipe { - public int id = -1; - public String name = ""; + public int id = -1; + public String name = ""; public Availability availability = new Availability(); public boolean isGlobal = false; public boolean ignoreDamage = false; public boolean ignoreNBT = false; - public RecipeCarpentry(int width, int height, ItemStack[] recipe, ItemStack result){ - super(width, height, recipe, result); - } - public RecipeCarpentry(String name){ - super(0, 0, new ItemStack[0], null); - this.name = name; + public RecipeCarpentry(int width, int height, ItemStack[] recipe, ItemStack result) { + super(width, height, recipe, result); } - public static RecipeCarpentry read(NBTTagCompound compound){ - RecipeCarpentry recipe = new RecipeCarpentry(compound.getInteger("Width"), compound.getInteger("Height"), - NBTTags.getItemStackArray(compound.getTagList("Materials", 10)), NoppesUtilServer.readItem(compound.getCompoundTag("Item"))); - recipe.name = compound.getString("Name"); - recipe.id = compound.getInteger("ID"); - recipe.availability.readFromNBT(compound.getCompoundTag("Availability")); - recipe.ignoreDamage = compound.getBoolean("IgnoreDamage"); - recipe.ignoreNBT = compound.getBoolean("IgnoreNBT"); - recipe.isGlobal = compound.getBoolean("Global"); - - return recipe; + public RecipeCarpentry(String name) { + super(0, 0, new ItemStack[0], null); + this.name = name; } - public NBTTagCompound writeNBT() { - NBTTagCompound compound = new NBTTagCompound(); - compound.setInteger("ID", id); - compound.setInteger("Width", recipeWidth); - compound.setInteger("Height", recipeHeight); - if(getRecipeOutput() != null) - compound.setTag("Item", NoppesUtilServer.writeItem(getRecipeOutput(), new NBTTagCompound())); - compound.setTag("Materials", NBTTags.nbtItemStackArray(recipeItems)); - compound.setTag("Availability", availability.writeToNBT(new NBTTagCompound())); - compound.setString("Name", name); - compound.setBoolean("Global", isGlobal); - compound.setBoolean("IgnoreDamage", ignoreDamage); - compound.setBoolean("IgnoreNBT", ignoreNBT); - return compound; - } + public static RecipeCarpentry read(NBTTagCompound compound) { + RecipeCarpentry recipe = new RecipeCarpentry(compound.getInteger("Width"), compound.getInteger("Height"), + NBTTags.getItemStackArray(compound.getTagList("Materials", 10)), NoppesUtilServer.readItem(compound.getCompoundTag("Item"))); + recipe.name = compound.getString("Name"); + recipe.id = compound.getInteger("ID"); + recipe.availability.readFromNBT(compound.getCompoundTag("Availability")); + recipe.ignoreDamage = compound.getBoolean("IgnoreDamage"); + recipe.ignoreNBT = compound.getBoolean("IgnoreNBT"); + recipe.isGlobal = compound.getBoolean("Global"); - @Override - public boolean matches(InventoryCrafting par1InventoryCrafting, World world) { - for (int i = 0; i <= 4 - this.recipeWidth; ++i){ - for (int j = 0; j <= 4 - this.recipeHeight; ++j){ + return recipe; + } + + public NBTTagCompound writeNBT() { + NBTTagCompound compound = new NBTTagCompound(); + compound.setInteger("ID", id); + compound.setInteger("Width", recipeWidth); + compound.setInteger("Height", recipeHeight); + if (getRecipeOutput() != null) + compound.setTag("Item", NoppesUtilServer.writeItem(getRecipeOutput(), new NBTTagCompound())); + compound.setTag("Materials", NBTTags.nbtItemStackArray(recipeItems)); + compound.setTag("Availability", availability.writeToNBT(new NBTTagCompound())); + compound.setString("Name", name); + compound.setBoolean("Global", isGlobal); + compound.setBoolean("IgnoreDamage", ignoreDamage); + compound.setBoolean("IgnoreNBT", ignoreNBT); + return compound; + } + + @Override + public boolean matches(InventoryCrafting par1InventoryCrafting, World world) { + for (int i = 0; i <= 4 - this.recipeWidth; ++i) { + for (int j = 0; j <= 4 - this.recipeHeight; ++j) { if (this.checkMatch(par1InventoryCrafting, i, j, true)) return true; @@ -74,21 +75,20 @@ public class RecipeCarpentry extends ShapedRecipes implements IRecipe { } } return false; - } - + } /** * Checks if the region of a crafting inventory is match for the recipe. */ - private boolean checkMatch(InventoryCrafting par1InventoryCrafting, int par2, int par3, boolean par4){ - for (int i = 0; i < 4; i++){ - for (int j = 0; j < 4; j++){ + private boolean checkMatch(InventoryCrafting par1InventoryCrafting, int par2, int par3, boolean par4) { + for (int i = 0; i < 4; i++) { + for (int j = 0; j < 4; j++) { int var7 = i - par2; int var8 = j - par3; ItemStack var9 = null; - if (var7 >= 0 && var8 >= 0 && var7 < this.recipeWidth && var8 < this.recipeHeight){ + if (var7 >= 0 && var8 >= 0 && var7 < this.recipeWidth && var8 < this.recipeHeight) { if (par4) var9 = this.recipeItems[this.recipeWidth - var7 - 1 + var8 * this.recipeWidth]; else @@ -97,8 +97,8 @@ public class RecipeCarpentry extends ShapedRecipes implements IRecipe { ItemStack var10 = par1InventoryCrafting.getStackInRowAndColumn(i, j); - if ((var10 != null || var9 != null) && !NoppesUtilPlayer.compareItems(var9, var10, ignoreDamage, ignoreNBT)){ - return false; + if ((var10 != null || var9 != null) && !NoppesUtilPlayer.compareItems(var9, var10, ignoreDamage, ignoreNBT)) { + return false; } } } @@ -106,44 +106,39 @@ public class RecipeCarpentry extends ShapedRecipes implements IRecipe { return true; } - @Override - public ItemStack getCraftingResult(InventoryCrafting var1) { - if(getRecipeOutput() == null) - return null; - return getRecipeOutput().copy(); - } + @Override + public ItemStack getCraftingResult(InventoryCrafting var1) { + if (getRecipeOutput() == null) + return null; + return getRecipeOutput().copy(); + } - @Override - public int getRecipeSize() { - return 16; - } + @Override + public int getRecipeSize() { + return 16; + } - public static RecipeCarpentry saveRecipe(RecipeCarpentry recipe, ItemStack par1ItemStack, Object ... par2ArrayOfObj){ + public static RecipeCarpentry saveRecipe(RecipeCarpentry recipe, ItemStack par1ItemStack, Object... par2ArrayOfObj) { String var3 = ""; int var4 = 0; int var5 = 0; int var6 = 0; int var9; - if (par2ArrayOfObj[var4] instanceof String[]) - { - String[] var7 = (String[])((String[])par2ArrayOfObj[var4++]); + if (par2ArrayOfObj[var4] instanceof String[]) { + String[] var7 = (String[]) ((String[]) par2ArrayOfObj[var4++]); String[] var8 = var7; var9 = var7.length; - for (int var10 = 0; var10 < var9; ++var10) - { + for (int var10 = 0; var10 < var9; ++var10) { String var11 = var8[var10]; ++var6; var5 = var11.length(); var3 = var3 + var11; } - } - else - { - while (par2ArrayOfObj[var4] instanceof String) - { - String var13 = (String)par2ArrayOfObj[var4++]; + } else { + while (par2ArrayOfObj[var4] instanceof String) { + String var13 = (String) par2ArrayOfObj[var4++]; ++var6; var5 = var13.length(); var3 = var3 + var13; @@ -152,22 +147,16 @@ public class RecipeCarpentry extends ShapedRecipes implements IRecipe { HashMap var14; - for (var14 = new HashMap(); var4 < par2ArrayOfObj.length; var4 += 2) - { - Character var16 = (Character)par2ArrayOfObj[var4]; + for (var14 = new HashMap(); var4 < par2ArrayOfObj.length; var4 += 2) { + Character var16 = (Character) par2ArrayOfObj[var4]; ItemStack var17 = null; - if (par2ArrayOfObj[var4 + 1] instanceof Item) - { - var17 = new ItemStack((Item)par2ArrayOfObj[var4 + 1]); - } - else if (par2ArrayOfObj[var4 + 1] instanceof Block) - { - var17 = new ItemStack((Block)par2ArrayOfObj[var4 + 1], 1, -1); - } - else if (par2ArrayOfObj[var4 + 1] instanceof ItemStack) - { - var17 = (ItemStack)par2ArrayOfObj[var4 + 1]; + if (par2ArrayOfObj[var4 + 1] instanceof Item) { + var17 = new ItemStack((Item) par2ArrayOfObj[var4 + 1]); + } else if (par2ArrayOfObj[var4 + 1] instanceof Block) { + var17 = new ItemStack((Block) par2ArrayOfObj[var4 + 1], 1, -1); + } else if (par2ArrayOfObj[var4 + 1] instanceof ItemStack) { + var17 = (ItemStack) par2ArrayOfObj[var4 + 1]; } var14.put(var16, var17); @@ -175,54 +164,52 @@ public class RecipeCarpentry extends ShapedRecipes implements IRecipe { ItemStack[] var15 = new ItemStack[var5 * var6]; - for (var9 = 0; var9 < var5 * var6; ++var9) - { + for (var9 = 0; var9 < var5 * var6; ++var9) { char var18 = var3.charAt(var9); - if (var14.containsKey(Character.valueOf(var18))) - { - var15[var9] = ((ItemStack)var14.get(Character.valueOf(var18))).copy(); - } - else - { + if (var14.containsKey(Character.valueOf(var18))) { + var15[var9] = ((ItemStack) var14.get(Character.valueOf(var18))).copy(); + } else { var15[var9] = null; } } RecipeCarpentry newrecipe = new RecipeCarpentry(var5, var6, var15, par1ItemStack); newrecipe.copy(recipe); - if(var5 == 4 || var6 == 4) - newrecipe.isGlobal = false; + if (var5 == 4 || var6 == 4) + newrecipe.isGlobal = false; return newrecipe; } public void copy(RecipeCarpentry recipe) { - this.id = recipe.id; - this.name = recipe.name; - this.availability = recipe.availability; - this.isGlobal = recipe.isGlobal; - this.ignoreDamage = recipe.ignoreDamage; - this.ignoreNBT = recipe.ignoreNBT; - } + this.id = recipe.id; + this.name = recipe.name; + this.availability = recipe.availability; + this.isGlobal = recipe.isGlobal; + this.ignoreDamage = recipe.ignoreDamage; + this.ignoreNBT = recipe.ignoreNBT; + } - public ItemStack getCraftingItem(int i){ - if(recipeItems == null || i >= recipeItems.length) - return null; - return recipeItems[i]; + public ItemStack getCraftingItem(int i) { + if (recipeItems == null || i >= recipeItems.length) + return null; + return recipeItems[i]; } - public void setCraftingItem(int i, ItemStack item){ - if(i < recipeItems.length) - recipeItems[i] = item; + + public void setCraftingItem(int i, ItemStack item) { + if (i < recipeItems.length) + recipeItems[i] = item; + } + + public boolean isValid() { + if (recipeItems.length == 0 || getRecipeOutput() == null) + return false; + for (ItemStack item : recipeItems) { + if (item != null) + return true; + } + return false; } - public boolean isValid() { - if(recipeItems.length == 0 || getRecipeOutput() == null) - return false; - for(ItemStack item : recipeItems){ - if(item != null) - return true; - } - return false; - } public String getName() { return this.name; diff --git a/src/main/java/noppes/npcs/controllers/data/RecipesDefault.java b/src/main/java/noppes/npcs/controllers/data/RecipesDefault.java index 671497ec8..2ff86f169 100644 --- a/src/main/java/noppes/npcs/controllers/data/RecipesDefault.java +++ b/src/main/java/noppes/npcs/controllers/data/RecipesDefault.java @@ -10,185 +10,186 @@ import noppes.npcs.config.ConfigItem; import noppes.npcs.controllers.RecipeController; public class RecipesDefault { - public static void addRecipe(String name, Object ob, boolean isGlobal, Object... recipe){ - ItemStack item; - if(ob instanceof Item) - item = new ItemStack((Item)ob); - else if(ob instanceof Block) - item = new ItemStack((Block)ob); - else - item = (ItemStack) ob; + public static void addRecipe(String name, Object ob, boolean isGlobal, Object... recipe) { + ItemStack item; + if (ob instanceof Item) + item = new ItemStack((Item) ob); + else if (ob instanceof Block) + item = new ItemStack((Block) ob); + else + item = (ItemStack) ob; - RecipeCarpentry recipeCarpentry = new RecipeCarpentry(name); - recipeCarpentry.isGlobal = isGlobal; - recipeCarpentry = RecipeCarpentry.saveRecipe(recipeCarpentry, item, recipe); - RecipeController.Instance.addRecipe(recipeCarpentry); - } - public static void loadDefaultRecipes(int i) { - if(i < 0){ - addRecipe("Npc Wand", CustomItems.wand, true, "XX"," Y"," Y",'X', Items.bread,'Y', Items.stick); - addRecipe("Mob Cloner", CustomItems.cloner, true, "XX","XY"," Y",'X', Items.bread,'Y', Items.stick); - addRecipe("Carpentry Bench", CustomItems.carpentyBench, true, "XYX","Z Z","Z Z", 'X', Blocks.planks, 'Z', Items.stick, 'Y', Blocks.crafting_table); + RecipeCarpentry recipeCarpentry = new RecipeCarpentry(name); + recipeCarpentry.isGlobal = isGlobal; + recipeCarpentry = RecipeCarpentry.saveRecipe(recipeCarpentry, item, recipe); + RecipeController.Instance.addRecipe(recipeCarpentry); + } + + public static void loadDefaultRecipes(int i) { + if (i < 0) { + addRecipe("Npc Wand", CustomItems.wand, true, "XX", " Y", " Y", 'X', Items.bread, 'Y', Items.stick); + addRecipe("Mob Cloner", CustomItems.cloner, true, "XX", "XY", " Y", 'X', Items.bread, 'Y', Items.stick); + addRecipe("Carpentry Bench", CustomItems.carpentyBench, true, "XYX", "Z Z", "Z Z", 'X', Blocks.planks, 'Z', Items.stick, 'Y', Blocks.crafting_table); ItemStack anvil = new ItemStack(CustomItems.carpentyBench); anvil.setItemDamage(1); - addRecipe("Anvil", anvil, true, "XXX","Z Z","Z Z", 'X', Blocks.iron_block, 'Z', Items.iron_ingot); + addRecipe("Anvil", anvil, true, "XXX", "Z Z", "Z Z", 'X', Blocks.iron_block, 'Z', Items.iron_ingot); - if(!ConfigItem.DisableExtraItems){ - addRecipe("Mana", CustomItems.mana, true, "XY",'X',Items.redstone,'Y',Items.glowstone_dust); - addRecipe("Gun Wooden", CustomItems.gunWood, false, "XXXY"," ZM "," M ",'Y', Blocks.lever, 'M', Items.stick, 'Z', Blocks.stone_button,'X', Blocks.planks); - addRecipe("Gun Stone", CustomItems.gunStone, false, "XXXY"," ZM "," M ",'Y', Blocks.lever, 'M', Items.stick, 'Z', Blocks.stone_button,'X', Blocks.cobblestone); - addRecipe("Gun Iron", CustomItems.gunIron, false, "XXXY"," ZM "," M ",'Y', Blocks.lever, 'M', Items.stick, 'Z', Blocks.stone_button,'X', Items.iron_ingot); - addRecipe("Gun Gold", CustomItems.gunGold, false, "XXXY"," ZM "," M ",'Y', Blocks.lever, 'M', Items.stick, 'Z', Blocks.stone_button,'X', Items.gold_ingot); - addRecipe("Gun Diamond", CustomItems.gunDiamond, false, "XXXY"," ZM "," M ",'Y', Blocks.lever, 'M', Items.stick, 'Z', Blocks.stone_button,'X', Items.diamond); - addRecipe("Gun Emerald", CustomItems.gunEmerald, false, "XXXY"," ZM "," M ",'Y', Blocks.lever, 'M', Items.stick, 'Z', Blocks.stone_button,'X', Items.emerald); - addRecipe("Gun Bronze", CustomItems.gunBronze, false, "XXXY"," ZM "," M ",'Y', Blocks.lever, 'M', Items.stick, 'Z', Blocks.stone_button,'X', CustomItems.bronze_ingot); + if (!ConfigItem.DisableExtraItems) { + addRecipe("Mana", CustomItems.mana, true, "XY", 'X', Items.redstone, 'Y', Items.glowstone_dust); + addRecipe("Gun Wooden", CustomItems.gunWood, false, "XXXY", " ZM ", " M ", 'Y', Blocks.lever, 'M', Items.stick, 'Z', Blocks.stone_button, 'X', Blocks.planks); + addRecipe("Gun Stone", CustomItems.gunStone, false, "XXXY", " ZM ", " M ", 'Y', Blocks.lever, 'M', Items.stick, 'Z', Blocks.stone_button, 'X', Blocks.cobblestone); + addRecipe("Gun Iron", CustomItems.gunIron, false, "XXXY", " ZM ", " M ", 'Y', Blocks.lever, 'M', Items.stick, 'Z', Blocks.stone_button, 'X', Items.iron_ingot); + addRecipe("Gun Gold", CustomItems.gunGold, false, "XXXY", " ZM ", " M ", 'Y', Blocks.lever, 'M', Items.stick, 'Z', Blocks.stone_button, 'X', Items.gold_ingot); + addRecipe("Gun Diamond", CustomItems.gunDiamond, false, "XXXY", " ZM ", " M ", 'Y', Blocks.lever, 'M', Items.stick, 'Z', Blocks.stone_button, 'X', Items.diamond); + addRecipe("Gun Emerald", CustomItems.gunEmerald, false, "XXXY", " ZM ", " M ", 'Y', Blocks.lever, 'M', Items.stick, 'Z', Blocks.stone_button, 'X', Items.emerald); + addRecipe("Gun Bronze", CustomItems.gunBronze, false, "XXXY", " ZM ", " M ", 'Y', Blocks.lever, 'M', Items.stick, 'Z', Blocks.stone_button, 'X', CustomItems.bronze_ingot); - addRecipe("Bullet Wooden", CustomItems.bulletWood, true, "X",'X', Blocks.planks); - addRecipe("Bullet Stone", CustomItems.bulletStone, true, "X",'X', Blocks.cobblestone); - addRecipe("Bullet Iron", CustomItems.bulletIron, true, "X",'X', Items.iron_ingot); - addRecipe("Bullet Gold", CustomItems.bulletGold, true, "X",'X', Items.gold_ingot); - addRecipe("Bullet Diamond", CustomItems.bulletDiamond, true, "X",'X', Items.diamond); - addRecipe("Bullet Emerald", CustomItems.bulletEmerald, true, "X",'X', Items.emerald); - addRecipe("Bullet Bronze", CustomItems.bulletBronze, true, "X",'X', CustomItems.bronze_ingot); - } - } - if(i < 1){ - if(!ConfigItem.DisableExtraBlock){ - addRecipe("WallBanner Wooden", new ItemStack(CustomItems.wallBanner, 1, 0), false, "XXX","ZZZ","ZZZ","Z Z",'Z', Blocks.wool, 'X', Blocks.planks); - addRecipe("WallBanner Stone", new ItemStack(CustomItems.wallBanner, 1, 1), false, "XXX","ZZZ","ZZZ","Z Z",'Z', Blocks.wool, 'X', Blocks.cobblestone); - addRecipe("WallBanner Iron", new ItemStack(CustomItems.wallBanner, 1, 2), false, "XXX","ZZZ","ZZZ","Z Z",'Z', Blocks.wool, 'X', Items.iron_ingot); - addRecipe("WallBanner Gold", new ItemStack(CustomItems.wallBanner, 1, 3), false, "XXX","ZZZ","ZZZ","Z Z",'Z', Blocks.wool, 'X', Items.gold_ingot); - addRecipe("WallBanner Diamond", new ItemStack(CustomItems.wallBanner, 1, 4), false, "XXX","ZZZ","ZZZ","Z Z",'Z', Blocks.wool, 'X', Items.diamond); + addRecipe("Bullet Wooden", CustomItems.bulletWood, true, "X", 'X', Blocks.planks); + addRecipe("Bullet Stone", CustomItems.bulletStone, true, "X", 'X', Blocks.cobblestone); + addRecipe("Bullet Iron", CustomItems.bulletIron, true, "X", 'X', Items.iron_ingot); + addRecipe("Bullet Gold", CustomItems.bulletGold, true, "X", 'X', Items.gold_ingot); + addRecipe("Bullet Diamond", CustomItems.bulletDiamond, true, "X", 'X', Items.diamond); + addRecipe("Bullet Emerald", CustomItems.bulletEmerald, true, "X", 'X', Items.emerald); + addRecipe("Bullet Bronze", CustomItems.bulletBronze, true, "X", 'X', CustomItems.bronze_ingot); + } + } + if (i < 1) { + if (!ConfigItem.DisableExtraBlock) { + addRecipe("WallBanner Wooden", new ItemStack(CustomItems.wallBanner, 1, 0), false, "XXX", "ZZZ", "ZZZ", "Z Z", 'Z', Blocks.wool, 'X', Blocks.planks); + addRecipe("WallBanner Stone", new ItemStack(CustomItems.wallBanner, 1, 1), false, "XXX", "ZZZ", "ZZZ", "Z Z", 'Z', Blocks.wool, 'X', Blocks.cobblestone); + addRecipe("WallBanner Iron", new ItemStack(CustomItems.wallBanner, 1, 2), false, "XXX", "ZZZ", "ZZZ", "Z Z", 'Z', Blocks.wool, 'X', Items.iron_ingot); + addRecipe("WallBanner Gold", new ItemStack(CustomItems.wallBanner, 1, 3), false, "XXX", "ZZZ", "ZZZ", "Z Z", 'Z', Blocks.wool, 'X', Items.gold_ingot); + addRecipe("WallBanner Diamond", new ItemStack(CustomItems.wallBanner, 1, 4), false, "XXX", "ZZZ", "ZZZ", "Z Z", 'Z', Blocks.wool, 'X', Items.diamond); - addRecipe("Banner Wooden", new ItemStack(CustomItems.banner, 1, 0), false, " X "," Z "," Z ","ZZZ", 'X', new ItemStack(CustomItems.wallBanner,1,0), 'Z', Blocks.planks); - addRecipe("Banner Stone", new ItemStack(CustomItems.banner, 1, 1), false, " X "," Z "," Z ","ZZZ", 'X', new ItemStack(CustomItems.wallBanner,1,1), 'Z', Blocks.cobblestone); - addRecipe("Banner Iron", new ItemStack(CustomItems.banner, 1, 2), false, " X "," Z "," Z ","ZZZ", 'X', new ItemStack(CustomItems.wallBanner,1,2), 'Z', Items.iron_ingot); - addRecipe("Banner Gold", new ItemStack(CustomItems.banner, 1, 3), false, " X "," Z "," Z ","ZZZ", 'X', new ItemStack(CustomItems.wallBanner,1,3), 'Z', Items.gold_ingot); - addRecipe("Banner Diamond", new ItemStack(CustomItems.banner, 1, 4), false, " X "," Z "," Z ","ZZZ", 'X', new ItemStack(CustomItems.wallBanner,1,4), 'Z', Items.diamond); + addRecipe("Banner Wooden", new ItemStack(CustomItems.banner, 1, 0), false, " X ", " Z ", " Z ", "ZZZ", 'X', new ItemStack(CustomItems.wallBanner, 1, 0), 'Z', Blocks.planks); + addRecipe("Banner Stone", new ItemStack(CustomItems.banner, 1, 1), false, " X ", " Z ", " Z ", "ZZZ", 'X', new ItemStack(CustomItems.wallBanner, 1, 1), 'Z', Blocks.cobblestone); + addRecipe("Banner Iron", new ItemStack(CustomItems.banner, 1, 2), false, " X ", " Z ", " Z ", "ZZZ", 'X', new ItemStack(CustomItems.wallBanner, 1, 2), 'Z', Items.iron_ingot); + addRecipe("Banner Gold", new ItemStack(CustomItems.banner, 1, 3), false, " X ", " Z ", " Z ", "ZZZ", 'X', new ItemStack(CustomItems.wallBanner, 1, 3), 'Z', Items.gold_ingot); + addRecipe("Banner Diamond", new ItemStack(CustomItems.banner, 1, 4), false, " X ", " Z ", " Z ", "ZZZ", 'X', new ItemStack(CustomItems.wallBanner, 1, 4), 'Z', Items.diamond); - addRecipe("Lamp Wooden", new ItemStack(CustomItems.tallLamp, 1, 0), false, "YXY"," Z "," Z ","ZZZ", 'X', Blocks.torch, 'Y', Blocks.wool, 'Z', Blocks.planks); - addRecipe("Lamp Stone", new ItemStack(CustomItems.tallLamp, 1, 1), false, "YXY"," Z "," Z ","ZZZ", 'X', Blocks.torch, 'Y', Blocks.wool, 'Z', Blocks.cobblestone); - addRecipe("Lamp Iron", new ItemStack(CustomItems.tallLamp, 1, 2), false, "YXY"," Z "," Z ","ZZZ", 'X', Blocks.torch, 'Y', Blocks.wool, 'Z', Items.iron_ingot); - addRecipe("Lamp Gold", new ItemStack(CustomItems.tallLamp, 1, 3), false, "YXY"," Z "," Z ","ZZZ", 'X', Blocks.torch, 'Y', Blocks.wool, 'Z', Items.gold_ingot); - addRecipe("Lamp Diamond", new ItemStack(CustomItems.tallLamp, 1, 4), false, "YXY"," Z "," Z ","ZZZ", 'X', Blocks.torch, 'Y', Blocks.wool, 'Z', Items.diamond); + addRecipe("Lamp Wooden", new ItemStack(CustomItems.tallLamp, 1, 0), false, "YXY", " Z ", " Z ", "ZZZ", 'X', Blocks.torch, 'Y', Blocks.wool, 'Z', Blocks.planks); + addRecipe("Lamp Stone", new ItemStack(CustomItems.tallLamp, 1, 1), false, "YXY", " Z ", " Z ", "ZZZ", 'X', Blocks.torch, 'Y', Blocks.wool, 'Z', Blocks.cobblestone); + addRecipe("Lamp Iron", new ItemStack(CustomItems.tallLamp, 1, 2), false, "YXY", " Z ", " Z ", "ZZZ", 'X', Blocks.torch, 'Y', Blocks.wool, 'Z', Items.iron_ingot); + addRecipe("Lamp Gold", new ItemStack(CustomItems.tallLamp, 1, 3), false, "YXY", " Z ", " Z ", "ZZZ", 'X', Blocks.torch, 'Y', Blocks.wool, 'Z', Items.gold_ingot); + addRecipe("Lamp Diamond", new ItemStack(CustomItems.tallLamp, 1, 4), false, "YXY", " Z ", " Z ", "ZZZ", 'X', Blocks.torch, 'Y', Blocks.wool, 'Z', Items.diamond); - addRecipe("Chair Wooden1", new ItemStack(CustomItems.chair, 1, 0), false, " X", " X","XXX","X X", 'X', new ItemStack(Blocks.planks,1,0)); - addRecipe("Chair Wooden2", new ItemStack(CustomItems.chair, 1, 1), false, " X", " X","XXX","X X", 'X', new ItemStack(Blocks.planks,1,1)); - addRecipe("Chair Wooden3", new ItemStack(CustomItems.chair, 1, 2), false, " X", " X","XXX","X X", 'X', new ItemStack(Blocks.planks,1,2)); - addRecipe("Chair Wooden4", new ItemStack(CustomItems.chair, 1, 3), false, " X", " X","XXX","X X", 'X', new ItemStack(Blocks.planks,1,3)); - addRecipe("Chair Wooden5", new ItemStack(CustomItems.chair, 1, 4), false, " X", " X","XXX","X X", 'X', new ItemStack(Blocks.planks,1,4)); - addRecipe("Chair Wooden6", new ItemStack(CustomItems.chair, 1, 5), false, " X", " X","XXX","X X", 'X', new ItemStack(Blocks.planks,1,5)); + addRecipe("Chair Wooden1", new ItemStack(CustomItems.chair, 1, 0), false, " X", " X", "XXX", "X X", 'X', new ItemStack(Blocks.planks, 1, 0)); + addRecipe("Chair Wooden2", new ItemStack(CustomItems.chair, 1, 1), false, " X", " X", "XXX", "X X", 'X', new ItemStack(Blocks.planks, 1, 1)); + addRecipe("Chair Wooden3", new ItemStack(CustomItems.chair, 1, 2), false, " X", " X", "XXX", "X X", 'X', new ItemStack(Blocks.planks, 1, 2)); + addRecipe("Chair Wooden4", new ItemStack(CustomItems.chair, 1, 3), false, " X", " X", "XXX", "X X", 'X', new ItemStack(Blocks.planks, 1, 3)); + addRecipe("Chair Wooden5", new ItemStack(CustomItems.chair, 1, 4), false, " X", " X", "XXX", "X X", 'X', new ItemStack(Blocks.planks, 1, 4)); + addRecipe("Chair Wooden6", new ItemStack(CustomItems.chair, 1, 5), false, " X", " X", "XXX", "X X", 'X', new ItemStack(Blocks.planks, 1, 5)); - addRecipe("Crate Wooden1", new ItemStack(CustomItems.crate, 1, 0), false, "XXXX","X X","X X","XXXX", 'X', new ItemStack(Blocks.planks,1,0)); - addRecipe("Crate Wooden2", new ItemStack(CustomItems.crate, 1, 1), false, "XXXX","X X","X X","XXXX", 'X', new ItemStack(Blocks.planks,1,1)); - addRecipe("Crate Wooden3", new ItemStack(CustomItems.crate, 1, 2), false, "XXXX","X X","X X","XXXX", 'X', new ItemStack(Blocks.planks,1,2)); - addRecipe("Crate Wooden4", new ItemStack(CustomItems.crate, 1, 3), false, "XXXX","X X","X X","XXXX", 'X', new ItemStack(Blocks.planks,1,3)); - addRecipe("Crate Wooden5", new ItemStack(CustomItems.crate, 1, 4), false, "XXXX","X X","X X","XXXX", 'X', new ItemStack(Blocks.planks,1,4)); - addRecipe("Crate Wooden6", new ItemStack(CustomItems.crate, 1, 5), false, "XXXX","X X","X X","XXXX", 'X', new ItemStack(Blocks.planks,1,5)); + addRecipe("Crate Wooden1", new ItemStack(CustomItems.crate, 1, 0), false, "XXXX", "X X", "X X", "XXXX", 'X', new ItemStack(Blocks.planks, 1, 0)); + addRecipe("Crate Wooden2", new ItemStack(CustomItems.crate, 1, 1), false, "XXXX", "X X", "X X", "XXXX", 'X', new ItemStack(Blocks.planks, 1, 1)); + addRecipe("Crate Wooden3", new ItemStack(CustomItems.crate, 1, 2), false, "XXXX", "X X", "X X", "XXXX", 'X', new ItemStack(Blocks.planks, 1, 2)); + addRecipe("Crate Wooden4", new ItemStack(CustomItems.crate, 1, 3), false, "XXXX", "X X", "X X", "XXXX", 'X', new ItemStack(Blocks.planks, 1, 3)); + addRecipe("Crate Wooden5", new ItemStack(CustomItems.crate, 1, 4), false, "XXXX", "X X", "X X", "XXXX", 'X', new ItemStack(Blocks.planks, 1, 4)); + addRecipe("Crate Wooden6", new ItemStack(CustomItems.crate, 1, 5), false, "XXXX", "X X", "X X", "XXXX", 'X', new ItemStack(Blocks.planks, 1, 5)); - addRecipe("WeaponRack Wooden1", new ItemStack(CustomItems.weaponsRack, 1, 0), false, "XXX","XYX","XYX","XXX", 'X', new ItemStack(Blocks.planks,1,0),'Y', Items.stick); - addRecipe("WeaponRack Wooden2", new ItemStack(CustomItems.weaponsRack, 1, 1), false, "XXX","XYX","XYX","XXX", 'X', new ItemStack(Blocks.planks,1,1),'Y', Items.stick); - addRecipe("WeaponRack Wooden3", new ItemStack(CustomItems.weaponsRack, 1, 2), false, "XXX","XYX","XYX","XXX", 'X', new ItemStack(Blocks.planks,1,2),'Y', Items.stick); - addRecipe("WeaponRack Wooden4", new ItemStack(CustomItems.weaponsRack, 1, 3), false, "XXX","XYX","XYX","XXX", 'X', new ItemStack(Blocks.planks,1,3),'Y', Items.stick); - addRecipe("WeaponRack Wooden5", new ItemStack(CustomItems.weaponsRack, 1, 4), false, "XXX","XYX","XYX","XXX", 'X', new ItemStack(Blocks.planks,1,4),'Y', Items.stick); - addRecipe("WeaponRack Wooden6", new ItemStack(CustomItems.weaponsRack, 1, 5), false, "XXX","XYX","XYX","XXX", 'X', new ItemStack(Blocks.planks,1,5),'Y', Items.stick); + addRecipe("WeaponRack Wooden1", new ItemStack(CustomItems.weaponsRack, 1, 0), false, "XXX", "XYX", "XYX", "XXX", 'X', new ItemStack(Blocks.planks, 1, 0), 'Y', Items.stick); + addRecipe("WeaponRack Wooden2", new ItemStack(CustomItems.weaponsRack, 1, 1), false, "XXX", "XYX", "XYX", "XXX", 'X', new ItemStack(Blocks.planks, 1, 1), 'Y', Items.stick); + addRecipe("WeaponRack Wooden3", new ItemStack(CustomItems.weaponsRack, 1, 2), false, "XXX", "XYX", "XYX", "XXX", 'X', new ItemStack(Blocks.planks, 1, 2), 'Y', Items.stick); + addRecipe("WeaponRack Wooden4", new ItemStack(CustomItems.weaponsRack, 1, 3), false, "XXX", "XYX", "XYX", "XXX", 'X', new ItemStack(Blocks.planks, 1, 3), 'Y', Items.stick); + addRecipe("WeaponRack Wooden5", new ItemStack(CustomItems.weaponsRack, 1, 4), false, "XXX", "XYX", "XYX", "XXX", 'X', new ItemStack(Blocks.planks, 1, 4), 'Y', Items.stick); + addRecipe("WeaponRack Wooden6", new ItemStack(CustomItems.weaponsRack, 1, 5), false, "XXX", "XYX", "XYX", "XXX", 'X', new ItemStack(Blocks.planks, 1, 5), 'Y', Items.stick); - addRecipe("Couch Wooden1", new ItemStack(CustomItems.couchWood, 1, 0), false, " X"," X","XXXX","X X", 'X', new ItemStack(Blocks.planks,1,0)); - addRecipe("Couch Wooden2", new ItemStack(CustomItems.couchWood, 1, 1), false, " X"," X","XXXX","X X", 'X', new ItemStack(Blocks.planks,1,1)); - addRecipe("Couch Wooden3", new ItemStack(CustomItems.couchWood, 1, 2), false, " X"," X","XXXX","X X", 'X', new ItemStack(Blocks.planks,1,2)); - addRecipe("Couch Wooden4", new ItemStack(CustomItems.couchWood, 1, 3), false, " X"," X","XXXX","X X", 'X', new ItemStack(Blocks.planks,1,3)); - addRecipe("Couch Wooden5", new ItemStack(CustomItems.couchWood, 1, 4), false, " X"," X","XXXX","X X", 'X', new ItemStack(Blocks.planks,1,4)); - addRecipe("Couch Wooden6", new ItemStack(CustomItems.couchWood, 1, 5), false, " X"," X","XXXX","X X", 'X', new ItemStack(Blocks.planks,1,5)); + addRecipe("Couch Wooden1", new ItemStack(CustomItems.couchWood, 1, 0), false, " X", " X", "XXXX", "X X", 'X', new ItemStack(Blocks.planks, 1, 0)); + addRecipe("Couch Wooden2", new ItemStack(CustomItems.couchWood, 1, 1), false, " X", " X", "XXXX", "X X", 'X', new ItemStack(Blocks.planks, 1, 1)); + addRecipe("Couch Wooden3", new ItemStack(CustomItems.couchWood, 1, 2), false, " X", " X", "XXXX", "X X", 'X', new ItemStack(Blocks.planks, 1, 2)); + addRecipe("Couch Wooden4", new ItemStack(CustomItems.couchWood, 1, 3), false, " X", " X", "XXXX", "X X", 'X', new ItemStack(Blocks.planks, 1, 3)); + addRecipe("Couch Wooden5", new ItemStack(CustomItems.couchWood, 1, 4), false, " X", " X", "XXXX", "X X", 'X', new ItemStack(Blocks.planks, 1, 4)); + addRecipe("Couch Wooden6", new ItemStack(CustomItems.couchWood, 1, 5), false, " X", " X", "XXXX", "X X", 'X', new ItemStack(Blocks.planks, 1, 5)); - addRecipe("Couch Wool1", new ItemStack(CustomItems.couchWool, 1, 0), false, " Z", " Z","ZZZZ","X X", 'X', new ItemStack(Blocks.planks,1,0), 'Z', Blocks.wool); - addRecipe("Couch Wool2", new ItemStack(CustomItems.couchWool, 1, 1), false, " Z", " Z","ZZZZ","X X", 'X', new ItemStack(Blocks.planks,1,1), 'Z', Blocks.wool); - addRecipe("Couch Wool3", new ItemStack(CustomItems.couchWool, 1, 2), false, " Z", " Z","ZZZZ","X X", 'X', new ItemStack(Blocks.planks,1,2), 'Z', Blocks.wool); - addRecipe("Couch Wool4", new ItemStack(CustomItems.couchWool, 1, 3), false, " Z", " Z","ZZZZ","X X", 'X', new ItemStack(Blocks.planks,1,3), 'Z', Blocks.wool); - addRecipe("Couch Wool5", new ItemStack(CustomItems.couchWool, 1, 4), false, " Z", " Z","ZZZZ","X X", 'X', new ItemStack(Blocks.planks,1,4), 'Z', Blocks.wool); - addRecipe("Couch Wool6", new ItemStack(CustomItems.couchWool, 1, 5), false, " Z", " Z","ZZZZ","X X", 'X', new ItemStack(Blocks.planks,1,5), 'Z', Blocks.wool); + addRecipe("Couch Wool1", new ItemStack(CustomItems.couchWool, 1, 0), false, " Z", " Z", "ZZZZ", "X X", 'X', new ItemStack(Blocks.planks, 1, 0), 'Z', Blocks.wool); + addRecipe("Couch Wool2", new ItemStack(CustomItems.couchWool, 1, 1), false, " Z", " Z", "ZZZZ", "X X", 'X', new ItemStack(Blocks.planks, 1, 1), 'Z', Blocks.wool); + addRecipe("Couch Wool3", new ItemStack(CustomItems.couchWool, 1, 2), false, " Z", " Z", "ZZZZ", "X X", 'X', new ItemStack(Blocks.planks, 1, 2), 'Z', Blocks.wool); + addRecipe("Couch Wool4", new ItemStack(CustomItems.couchWool, 1, 3), false, " Z", " Z", "ZZZZ", "X X", 'X', new ItemStack(Blocks.planks, 1, 3), 'Z', Blocks.wool); + addRecipe("Couch Wool5", new ItemStack(CustomItems.couchWool, 1, 4), false, " Z", " Z", "ZZZZ", "X X", 'X', new ItemStack(Blocks.planks, 1, 4), 'Z', Blocks.wool); + addRecipe("Couch Wool6", new ItemStack(CustomItems.couchWool, 1, 5), false, " Z", " Z", "ZZZZ", "X X", 'X', new ItemStack(Blocks.planks, 1, 5), 'Z', Blocks.wool); - addRecipe("Table Wood1", new ItemStack(CustomItems.table, 1, 0), false, "XXXX","X X","X X", 'X', new ItemStack(Blocks.planks,1,0), 'Z', Blocks.wool); - addRecipe("Table Wood2", new ItemStack(CustomItems.table, 1, 1), false, "XXXX","X X","X X", 'X', new ItemStack(Blocks.planks,1,1), 'Z', Blocks.wool); - addRecipe("Table Wood3", new ItemStack(CustomItems.table, 1, 2), false, "XXXX","X X","X X", 'X', new ItemStack(Blocks.planks,1,2), 'Z', Blocks.wool); - addRecipe("Table Wood4", new ItemStack(CustomItems.table, 1, 3), false, "XXXX","X X","X X", 'X', new ItemStack(Blocks.planks,1,3), 'Z', Blocks.wool); - addRecipe("Table Wood5", new ItemStack(CustomItems.table, 1, 4), false, "XXXX","X X","X X", 'X', new ItemStack(Blocks.planks,1,4), 'Z', Blocks.wool); - addRecipe("Table Wood6", new ItemStack(CustomItems.table, 1, 5), false, "XXXX","X X","X X", 'X', new ItemStack(Blocks.planks,1,5), 'Z', Blocks.wool); + addRecipe("Table Wood1", new ItemStack(CustomItems.table, 1, 0), false, "XXXX", "X X", "X X", 'X', new ItemStack(Blocks.planks, 1, 0), 'Z', Blocks.wool); + addRecipe("Table Wood2", new ItemStack(CustomItems.table, 1, 1), false, "XXXX", "X X", "X X", 'X', new ItemStack(Blocks.planks, 1, 1), 'Z', Blocks.wool); + addRecipe("Table Wood3", new ItemStack(CustomItems.table, 1, 2), false, "XXXX", "X X", "X X", 'X', new ItemStack(Blocks.planks, 1, 2), 'Z', Blocks.wool); + addRecipe("Table Wood4", new ItemStack(CustomItems.table, 1, 3), false, "XXXX", "X X", "X X", 'X', new ItemStack(Blocks.planks, 1, 3), 'Z', Blocks.wool); + addRecipe("Table Wood5", new ItemStack(CustomItems.table, 1, 4), false, "XXXX", "X X", "X X", 'X', new ItemStack(Blocks.planks, 1, 4), 'Z', Blocks.wool); + addRecipe("Table Wood6", new ItemStack(CustomItems.table, 1, 5), false, "XXXX", "X X", "X X", 'X', new ItemStack(Blocks.planks, 1, 5), 'Z', Blocks.wool); - addRecipe("noppes.npcs.client.model.blocks.Stool Wood1", new ItemStack(CustomItems.stool, 1, 0), false, "XXX"," X ","X X", 'X', new ItemStack(Blocks.planks,1,0)); - addRecipe("noppes.npcs.client.model.blocks.Stool Wood2", new ItemStack(CustomItems.stool, 1, 1), false, "XXX"," X ","X X", 'X', new ItemStack(Blocks.planks,1,1)); - addRecipe("noppes.npcs.client.model.blocks.Stool Wood3", new ItemStack(CustomItems.stool, 1, 2), false, "XXX"," X ","X X", 'X', new ItemStack(Blocks.planks,1,2)); - addRecipe("noppes.npcs.client.model.blocks.Stool Wood4", new ItemStack(CustomItems.stool, 1, 3), false, "XXX"," X ","X X", 'X', new ItemStack(Blocks.planks,1,3)); - addRecipe("noppes.npcs.client.model.blocks.Stool Wood5", new ItemStack(CustomItems.stool, 1, 4), false, "XXX"," X ","X X", 'X', new ItemStack(Blocks.planks,1,4)); - addRecipe("noppes.npcs.client.model.blocks.Stool Wood6", new ItemStack(CustomItems.stool, 1, 5), false, "XXX"," X ","X X", 'X', new ItemStack(Blocks.planks,1,5)); + addRecipe("noppes.npcs.client.model.blocks.Stool Wood1", new ItemStack(CustomItems.stool, 1, 0), false, "XXX", " X ", "X X", 'X', new ItemStack(Blocks.planks, 1, 0)); + addRecipe("noppes.npcs.client.model.blocks.Stool Wood2", new ItemStack(CustomItems.stool, 1, 1), false, "XXX", " X ", "X X", 'X', new ItemStack(Blocks.planks, 1, 1)); + addRecipe("noppes.npcs.client.model.blocks.Stool Wood3", new ItemStack(CustomItems.stool, 1, 2), false, "XXX", " X ", "X X", 'X', new ItemStack(Blocks.planks, 1, 2)); + addRecipe("noppes.npcs.client.model.blocks.Stool Wood4", new ItemStack(CustomItems.stool, 1, 3), false, "XXX", " X ", "X X", 'X', new ItemStack(Blocks.planks, 1, 3)); + addRecipe("noppes.npcs.client.model.blocks.Stool Wood5", new ItemStack(CustomItems.stool, 1, 4), false, "XXX", " X ", "X X", 'X', new ItemStack(Blocks.planks, 1, 4)); + addRecipe("noppes.npcs.client.model.blocks.Stool Wood6", new ItemStack(CustomItems.stool, 1, 5), false, "XXX", " X ", "X X", 'X', new ItemStack(Blocks.planks, 1, 5)); - addRecipe("Barrel Wood1", new ItemStack(CustomItems.barrel, 1, 0), false, "XXX","X X","X X", "XXX", 'X', new ItemStack(Blocks.planks,1,0)); - addRecipe("Barrel Wood2", new ItemStack(CustomItems.barrel, 1, 1), false, "XXX","X X","X X", "XXX", 'X', new ItemStack(Blocks.planks,1,1)); - addRecipe("Barrel Wood3", new ItemStack(CustomItems.barrel, 1, 2), false, "XXX","X X","X X", "XXX", 'X', new ItemStack(Blocks.planks,1,2)); - addRecipe("Barrel Wood4", new ItemStack(CustomItems.barrel, 1, 3), false, "XXX","X X","X X", "XXX", 'X', new ItemStack(Blocks.planks,1,3)); - addRecipe("Barrel Wood5", new ItemStack(CustomItems.barrel, 1, 4), false, "XXX","X X","X X", "XXX", 'X', new ItemStack(Blocks.planks,1,4)); - addRecipe("Barrel Wood6", new ItemStack(CustomItems.barrel, 1, 5), false, "XXX","X X","X X", "XXX", 'X', new ItemStack(Blocks.planks,1,5)); + addRecipe("Barrel Wood1", new ItemStack(CustomItems.barrel, 1, 0), false, "XXX", "X X", "X X", "XXX", 'X', new ItemStack(Blocks.planks, 1, 0)); + addRecipe("Barrel Wood2", new ItemStack(CustomItems.barrel, 1, 1), false, "XXX", "X X", "X X", "XXX", 'X', new ItemStack(Blocks.planks, 1, 1)); + addRecipe("Barrel Wood3", new ItemStack(CustomItems.barrel, 1, 2), false, "XXX", "X X", "X X", "XXX", 'X', new ItemStack(Blocks.planks, 1, 2)); + addRecipe("Barrel Wood4", new ItemStack(CustomItems.barrel, 1, 3), false, "XXX", "X X", "X X", "XXX", 'X', new ItemStack(Blocks.planks, 1, 3)); + addRecipe("Barrel Wood5", new ItemStack(CustomItems.barrel, 1, 4), false, "XXX", "X X", "X X", "XXX", 'X', new ItemStack(Blocks.planks, 1, 4)); + addRecipe("Barrel Wood6", new ItemStack(CustomItems.barrel, 1, 5), false, "XXX", "X X", "X X", "XXX", 'X', new ItemStack(Blocks.planks, 1, 5)); - addRecipe("Shelf Wood1", new ItemStack(CustomItems.shelf, 2, 0), false, "XXX","XY ","X ", 'Y', Items.stick, 'X', new ItemStack(Blocks.planks,1,0)); - addRecipe("Shelf Wood2", new ItemStack(CustomItems.shelf, 2, 1), false, "XXX","XY ","X ", 'Y', Items.stick, 'X', new ItemStack(Blocks.planks,1,1)); - addRecipe("Shelf Wood3", new ItemStack(CustomItems.shelf, 2, 2), false, "XXX","XY ","X ", 'Y', Items.stick, 'X', new ItemStack(Blocks.planks,1,2)); - addRecipe("Shelf Wood4", new ItemStack(CustomItems.shelf, 2, 3), false, "XXX","XY ","X ", 'Y', Items.stick, 'X', new ItemStack(Blocks.planks,1,3)); - addRecipe("Shelf Wood5", new ItemStack(CustomItems.shelf, 2, 4), false, "XXX","XY ","X ", 'Y', Items.stick, 'X', new ItemStack(Blocks.planks,1,4)); - addRecipe("Shelf Wood6", new ItemStack(CustomItems.shelf, 2, 5), false, "XXX","XY ","X ", 'Y', Items.stick, 'X', new ItemStack(Blocks.planks,1,5)); + addRecipe("Shelf Wood1", new ItemStack(CustomItems.shelf, 2, 0), false, "XXX", "XY ", "X ", 'Y', Items.stick, 'X', new ItemStack(Blocks.planks, 1, 0)); + addRecipe("Shelf Wood2", new ItemStack(CustomItems.shelf, 2, 1), false, "XXX", "XY ", "X ", 'Y', Items.stick, 'X', new ItemStack(Blocks.planks, 1, 1)); + addRecipe("Shelf Wood3", new ItemStack(CustomItems.shelf, 2, 2), false, "XXX", "XY ", "X ", 'Y', Items.stick, 'X', new ItemStack(Blocks.planks, 1, 2)); + addRecipe("Shelf Wood4", new ItemStack(CustomItems.shelf, 2, 3), false, "XXX", "XY ", "X ", 'Y', Items.stick, 'X', new ItemStack(Blocks.planks, 1, 3)); + addRecipe("Shelf Wood5", new ItemStack(CustomItems.shelf, 2, 4), false, "XXX", "XY ", "X ", 'Y', Items.stick, 'X', new ItemStack(Blocks.planks, 1, 4)); + addRecipe("Shelf Wood6", new ItemStack(CustomItems.shelf, 2, 5), false, "XXX", "XY ", "X ", 'Y', Items.stick, 'X', new ItemStack(Blocks.planks, 1, 5)); - addRecipe("Beam Wood1", new ItemStack(CustomItems.beam, 2, 0), false, "XXX", "XXX", 'X', new ItemStack(Blocks.planks,1,0)); - addRecipe("Beam Wood2", new ItemStack(CustomItems.beam, 2, 1), false, "XXX", "XXX", 'X', new ItemStack(Blocks.planks,1,1)); - addRecipe("Beam Wood3", new ItemStack(CustomItems.beam, 2, 2), false, "XXX", "XXX", 'X', new ItemStack(Blocks.planks,1,2)); - addRecipe("Beam Wood4", new ItemStack(CustomItems.beam, 2, 3), false, "XXX", "XXX", 'X', new ItemStack(Blocks.planks,1,3)); - addRecipe("Beam Wood5", new ItemStack(CustomItems.beam, 2, 4), false, "XXX", "XXX", 'X', new ItemStack(Blocks.planks,1,4)); - addRecipe("Beam Wood6", new ItemStack(CustomItems.beam, 2, 5), false, "XXX", "XXX", 'X', new ItemStack(Blocks.planks,1,5)); + addRecipe("Beam Wood1", new ItemStack(CustomItems.beam, 2, 0), false, "XXX", "XXX", 'X', new ItemStack(Blocks.planks, 1, 0)); + addRecipe("Beam Wood2", new ItemStack(CustomItems.beam, 2, 1), false, "XXX", "XXX", 'X', new ItemStack(Blocks.planks, 1, 1)); + addRecipe("Beam Wood3", new ItemStack(CustomItems.beam, 2, 2), false, "XXX", "XXX", 'X', new ItemStack(Blocks.planks, 1, 2)); + addRecipe("Beam Wood4", new ItemStack(CustomItems.beam, 2, 3), false, "XXX", "XXX", 'X', new ItemStack(Blocks.planks, 1, 3)); + addRecipe("Beam Wood5", new ItemStack(CustomItems.beam, 2, 4), false, "XXX", "XXX", 'X', new ItemStack(Blocks.planks, 1, 4)); + addRecipe("Beam Wood6", new ItemStack(CustomItems.beam, 2, 5), false, "XXX", "XXX", 'X', new ItemStack(Blocks.planks, 1, 5)); - addRecipe("Sign Wood1", new ItemStack(CustomItems.sign, 1, 0), false, "YYY", "XXX", "XXX", 'X', new ItemStack(Blocks.planks,1,0), 'Y', Items.iron_ingot); - addRecipe("Sign Wood2", new ItemStack(CustomItems.sign, 1, 1), false, "YYY", "XXX", "XXX", 'X', new ItemStack(Blocks.planks,1,1), 'Y', Items.iron_ingot); - addRecipe("Sign Wood3", new ItemStack(CustomItems.sign, 1, 2), false, "YYY", "XXX", "XXX", 'X', new ItemStack(Blocks.planks,1,2), 'Y', Items.iron_ingot); - addRecipe("Sign Wood4", new ItemStack(CustomItems.sign, 1, 3), false, "YYY", "XXX", "XXX", 'X', new ItemStack(Blocks.planks,1,3), 'Y', Items.iron_ingot); - addRecipe("Sign Wood5", new ItemStack(CustomItems.sign, 1, 4), false, "YYY", "XXX", "XXX", 'X', new ItemStack(Blocks.planks,1,4), 'Y', Items.iron_ingot); - addRecipe("Sign Wood6", new ItemStack(CustomItems.sign, 1, 5), false, "YYY", "XXX", "XXX", 'X', new ItemStack(Blocks.planks,1,5), 'Y', Items.iron_ingot); + addRecipe("Sign Wood1", new ItemStack(CustomItems.sign, 1, 0), false, "YYY", "XXX", "XXX", 'X', new ItemStack(Blocks.planks, 1, 0), 'Y', Items.iron_ingot); + addRecipe("Sign Wood2", new ItemStack(CustomItems.sign, 1, 1), false, "YYY", "XXX", "XXX", 'X', new ItemStack(Blocks.planks, 1, 1), 'Y', Items.iron_ingot); + addRecipe("Sign Wood3", new ItemStack(CustomItems.sign, 1, 2), false, "YYY", "XXX", "XXX", 'X', new ItemStack(Blocks.planks, 1, 2), 'Y', Items.iron_ingot); + addRecipe("Sign Wood4", new ItemStack(CustomItems.sign, 1, 3), false, "YYY", "XXX", "XXX", 'X', new ItemStack(Blocks.planks, 1, 3), 'Y', Items.iron_ingot); + addRecipe("Sign Wood5", new ItemStack(CustomItems.sign, 1, 4), false, "YYY", "XXX", "XXX", 'X', new ItemStack(Blocks.planks, 1, 4), 'Y', Items.iron_ingot); + addRecipe("Sign Wood6", new ItemStack(CustomItems.sign, 1, 5), false, "YYY", "XXX", "XXX", 'X', new ItemStack(Blocks.planks, 1, 5), 'Y', Items.iron_ingot); - addRecipe("Lamp", new ItemStack(CustomItems.lantern), false, "XXX","YZY","XXX", 'X', Items.iron_ingot, 'Y', Blocks.glass, 'Z', Blocks.torch); - addRecipe("Candle", new ItemStack(CustomItems.candle), false, "XZX"," X ", 'X', Items.iron_ingot, 'Z', Blocks.torch); - addRecipe("BigSign", new ItemStack(CustomItems.bigsign, 2), false, "XXX","XXX","XXX", 'X', Blocks.planks); + addRecipe("Lamp", new ItemStack(CustomItems.lantern), false, "XXX", "YZY", "XXX", 'X', Items.iron_ingot, 'Y', Blocks.glass, 'Z', Blocks.torch); + addRecipe("Candle", new ItemStack(CustomItems.candle), false, "XZX", " X ", 'X', Items.iron_ingot, 'Z', Blocks.torch); + addRecipe("BigSign", new ItemStack(CustomItems.bigsign, 2), false, "XXX", "XXX", "XXX", 'X', Blocks.planks); - } - if(!ConfigItem.DisableExtraItems){ - addRecipe("Battle Axe1", CustomItems.battleAxeWood, false, "XX","XY"," Y", " Y", 'Y', Items.stick, 'X', Blocks.planks); - addRecipe("Battle Axe2", CustomItems.battleAxeStone, false, "XX","XY"," Y", " Y", 'Y', Items.stick, 'X', Blocks.cobblestone); - addRecipe("Battle Axe3", CustomItems.battleAxeIron, false, "XX","XY"," Y", " Y", 'Y', Items.stick, 'X', Items.iron_ingot); - addRecipe("Battle Axe4", CustomItems.battleAxeGold, false, "XX","XY"," Y", " Y", 'Y', Items.stick, 'X', Items.gold_ingot); - addRecipe("Battle Axe5", CustomItems.battleAxeDiamond, false, "XX","XY"," Y", " Y", 'Y', Items.stick, 'X', Items.diamond); - addRecipe("Battle Axe6", CustomItems.battleAxeBronze, false, "XX","XY"," Y", " Y", 'Y', Items.stick, 'X', CustomItems.bronze_ingot); - addRecipe("Battle Axe7", CustomItems.battleAxeEmerald, false, "XX","XY"," Y", " Y", 'Y', Items.stick, 'X', Items.emerald); + } + if (!ConfigItem.DisableExtraItems) { + addRecipe("Battle Axe1", CustomItems.battleAxeWood, false, "XX", "XY", " Y", " Y", 'Y', Items.stick, 'X', Blocks.planks); + addRecipe("Battle Axe2", CustomItems.battleAxeStone, false, "XX", "XY", " Y", " Y", 'Y', Items.stick, 'X', Blocks.cobblestone); + addRecipe("Battle Axe3", CustomItems.battleAxeIron, false, "XX", "XY", " Y", " Y", 'Y', Items.stick, 'X', Items.iron_ingot); + addRecipe("Battle Axe4", CustomItems.battleAxeGold, false, "XX", "XY", " Y", " Y", 'Y', Items.stick, 'X', Items.gold_ingot); + addRecipe("Battle Axe5", CustomItems.battleAxeDiamond, false, "XX", "XY", " Y", " Y", 'Y', Items.stick, 'X', Items.diamond); + addRecipe("Battle Axe6", CustomItems.battleAxeBronze, false, "XX", "XY", " Y", " Y", 'Y', Items.stick, 'X', CustomItems.bronze_ingot); + addRecipe("Battle Axe7", CustomItems.battleAxeEmerald, false, "XX", "XY", " Y", " Y", 'Y', Items.stick, 'X', Items.emerald); - addRecipe("Halberd1", CustomItems.halberdWood, false, " X ","XYX"," Y ", " Y ", 'Y', Items.stick, 'X', Blocks.planks); - addRecipe("Halberd2", CustomItems.halberdStone, false, " X ","XYX"," Y ", " Y ", 'Y', Items.stick, 'X', Blocks.cobblestone); - addRecipe("Halberd3", CustomItems.halberdIron, false, " X ","XYX"," Y ", " Y ", 'Y', Items.stick, 'X', Items.iron_ingot); - addRecipe("Halberd4", CustomItems.halberdGold, false, " X ","XYX"," Y ", " Y ", 'Y', Items.stick, 'X', Items.gold_ingot); - addRecipe("Halberd5", CustomItems.halberdDiamond, false, " X ","XYX"," Y ", " Y ", 'Y', Items.stick, 'X', Items.diamond); - addRecipe("Halberd6", CustomItems.halberdBronze, false, " X ","XYX"," Y ", " Y ", 'Y', Items.stick, 'X', CustomItems.bronze_ingot); - addRecipe("Halberd7", CustomItems.halberdEmerald, false, " X ","XYX"," Y ", " Y ", 'Y', Items.stick, 'X', Items.emerald); + addRecipe("Halberd1", CustomItems.halberdWood, false, " X ", "XYX", " Y ", " Y ", 'Y', Items.stick, 'X', Blocks.planks); + addRecipe("Halberd2", CustomItems.halberdStone, false, " X ", "XYX", " Y ", " Y ", 'Y', Items.stick, 'X', Blocks.cobblestone); + addRecipe("Halberd3", CustomItems.halberdIron, false, " X ", "XYX", " Y ", " Y ", 'Y', Items.stick, 'X', Items.iron_ingot); + addRecipe("Halberd4", CustomItems.halberdGold, false, " X ", "XYX", " Y ", " Y ", 'Y', Items.stick, 'X', Items.gold_ingot); + addRecipe("Halberd5", CustomItems.halberdDiamond, false, " X ", "XYX", " Y ", " Y ", 'Y', Items.stick, 'X', Items.diamond); + addRecipe("Halberd6", CustomItems.halberdBronze, false, " X ", "XYX", " Y ", " Y ", 'Y', Items.stick, 'X', CustomItems.bronze_ingot); + addRecipe("Halberd7", CustomItems.halberdEmerald, false, " X ", "XYX", " Y ", " Y ", 'Y', Items.stick, 'X', Items.emerald); - addRecipe("Glaive1", CustomItems.glaiveWood, false, "X "," Y "," Y ", " X", 'Y', Items.stick, 'X', Blocks.planks); - addRecipe("Glaive2", CustomItems.glaiveStone, false, "X "," Y "," Y ", " X", 'Y', Items.stick, 'X', Blocks.cobblestone); - addRecipe("Glaive3", CustomItems.glaiveIron, false, "X "," Y "," Y ", " X", 'Y', Items.stick, 'X', Items.iron_ingot); - addRecipe("Glaive4", CustomItems.glaiveGold, false, "X "," Y "," Y ", " X", 'Y', Items.stick, 'X', Items.gold_ingot); - addRecipe("Glaive5", CustomItems.glaiveDiamond, false, "X "," Y "," Y ", " X", 'Y', Items.stick, 'X', Items.diamond); - addRecipe("Glaive6", CustomItems.glaiveBronze, false, "X "," Y "," Y ", " X", 'Y', Items.stick, 'X', CustomItems.bronze_ingot); - addRecipe("Glaive7", CustomItems.glaiveEmerald, false, "X "," Y "," Y ", " X", 'Y', Items.stick, 'X', Items.emerald); + addRecipe("Glaive1", CustomItems.glaiveWood, false, "X ", " Y ", " Y ", " X", 'Y', Items.stick, 'X', Blocks.planks); + addRecipe("Glaive2", CustomItems.glaiveStone, false, "X ", " Y ", " Y ", " X", 'Y', Items.stick, 'X', Blocks.cobblestone); + addRecipe("Glaive3", CustomItems.glaiveIron, false, "X ", " Y ", " Y ", " X", 'Y', Items.stick, 'X', Items.iron_ingot); + addRecipe("Glaive4", CustomItems.glaiveGold, false, "X ", " Y ", " Y ", " X", 'Y', Items.stick, 'X', Items.gold_ingot); + addRecipe("Glaive5", CustomItems.glaiveDiamond, false, "X ", " Y ", " Y ", " X", 'Y', Items.stick, 'X', Items.diamond); + addRecipe("Glaive6", CustomItems.glaiveBronze, false, "X ", " Y ", " Y ", " X", 'Y', Items.stick, 'X', CustomItems.bronze_ingot); + addRecipe("Glaive7", CustomItems.glaiveEmerald, false, "X ", " Y ", " Y ", " X", 'Y', Items.stick, 'X', Items.emerald); - addRecipe("Trident1", CustomItems.tridentWood, false, "X X"," X "," Y ", " Y ", 'Y', Items.stick, 'X', Blocks.planks); - addRecipe("Trident2", CustomItems.tridentStone, false, "X X"," X "," Y ", " Y ", 'Y', Items.stick, 'X', Blocks.cobblestone); - addRecipe("Trident3", CustomItems.tridentIron, false, "X X"," X "," Y ", " Y ", 'Y', Items.stick, 'X', Items.iron_ingot); - addRecipe("Trident4", CustomItems.tridentGold, false, "X X"," X "," Y ", " Y ", 'Y', Items.stick, 'X', Items.gold_ingot); - addRecipe("Trident5", CustomItems.tridentDiamond, false, "X X"," X "," Y ", " Y ", 'Y', Items.stick, 'X', Items.diamond); - addRecipe("Trident6", CustomItems.tridentBronze, false, "X X"," X "," Y ", " Y ", 'Y', Items.stick, 'X', CustomItems.bronze_ingot); - addRecipe("Trident7", CustomItems.tridentEmerald, false, "X X"," X "," Y ", " Y ", 'Y', Items.stick, 'X', Items.emerald); + addRecipe("Trident1", CustomItems.tridentWood, false, "X X", " X ", " Y ", " Y ", 'Y', Items.stick, 'X', Blocks.planks); + addRecipe("Trident2", CustomItems.tridentStone, false, "X X", " X ", " Y ", " Y ", 'Y', Items.stick, 'X', Blocks.cobblestone); + addRecipe("Trident3", CustomItems.tridentIron, false, "X X", " X ", " Y ", " Y ", 'Y', Items.stick, 'X', Items.iron_ingot); + addRecipe("Trident4", CustomItems.tridentGold, false, "X X", " X ", " Y ", " Y ", 'Y', Items.stick, 'X', Items.gold_ingot); + addRecipe("Trident5", CustomItems.tridentDiamond, false, "X X", " X ", " Y ", " Y ", 'Y', Items.stick, 'X', Items.diamond); + addRecipe("Trident6", CustomItems.tridentBronze, false, "X X", " X ", " Y ", " Y ", 'Y', Items.stick, 'X', CustomItems.bronze_ingot); + addRecipe("Trident7", CustomItems.tridentEmerald, false, "X X", " X ", " Y ", " Y ", 'Y', Items.stick, 'X', Items.emerald); - } - } - } + } + } + } } diff --git a/src/main/java/noppes/npcs/controllers/data/SkinOverlay.java b/src/main/java/noppes/npcs/controllers/data/SkinOverlay.java index 50d67bb19..4b0cde375 100644 --- a/src/main/java/noppes/npcs/controllers/data/SkinOverlay.java +++ b/src/main/java/noppes/npcs/controllers/data/SkinOverlay.java @@ -37,6 +37,7 @@ public class SkinOverlay implements ISkinOverlay { this.texture = texture; this.updateClient(); } + public String getTexture() { return this.texture; } @@ -45,6 +46,7 @@ public class SkinOverlay implements ISkinOverlay { this.glow = glow; this.updateClient(); } + public boolean getGlow() { return glow; } @@ -53,6 +55,7 @@ public class SkinOverlay implements ISkinOverlay { this.blend = blend; this.updateClient(); } + public boolean getBlend() { return blend; } @@ -61,6 +64,7 @@ public class SkinOverlay implements ISkinOverlay { this.alpha = alpha; this.updateClient(); } + public float getAlpha() { return alpha; } @@ -69,6 +73,7 @@ public class SkinOverlay implements ISkinOverlay { this.size = size; this.updateClient(); } + public float getSize() { return size; } @@ -78,9 +83,11 @@ public class SkinOverlay implements ISkinOverlay { this.scaleY = scaleY; this.updateClient(); } + public float getTextureScaleX() { return scaleX; } + public float getTextureScaleY() { return scaleY; } @@ -90,9 +97,11 @@ public class SkinOverlay implements ISkinOverlay { this.speedY = speedY; this.updateClient(); } + public float getSpeedX() { return speedX; } + public float getSpeedY() { return speedY; } @@ -103,12 +112,15 @@ public class SkinOverlay implements ISkinOverlay { this.offsetZ = offsetZ; this.updateClient(); } + public float getOffsetX() { return offsetX; } + public float getOffsetY() { return offsetY; } + public float getOffsetZ() { return offsetZ; } diff --git a/src/main/java/noppes/npcs/controllers/data/SpawnData.java b/src/main/java/noppes/npcs/controllers/data/SpawnData.java index 3d5f4da69..821a0e3aa 100644 --- a/src/main/java/noppes/npcs/controllers/data/SpawnData.java +++ b/src/main/java/noppes/npcs/controllers/data/SpawnData.java @@ -15,187 +15,187 @@ import noppes.npcs.scripted.NpcAPI; import java.util.*; public class SpawnData extends WeightedRandom.Item implements INaturalSpawn { - public List biomes = new ArrayList<>(); - public HashSet dimensions = new HashSet<>(); - public int id = -1; - public String name = ""; + public List biomes = new ArrayList<>(); + public HashSet dimensions = new HashSet<>(); + public int id = -1; + public String name = ""; - public HashMap spawnCompounds = new HashMap<>(); + public HashMap spawnCompounds = new HashMap<>(); - public boolean animalSpawning = true; - public boolean monsterSpawning = false; - public boolean liquidSpawning = false; - public boolean airSpawning = false; + public boolean animalSpawning = true; + public boolean monsterSpawning = false; + public boolean liquidSpawning = false; + public boolean airSpawning = false; - public int spawnHeightMin; - public int spawnHeightMax = 100; + public int spawnHeightMin; + public int spawnHeightMax = 100; - public SpawnData() { - super(10); - } + public SpawnData() { + super(10); + } - public void readNBT(NBTTagCompound compound) { - id = compound.getInteger("SpawnId"); - name = compound.getString("SpawnName"); - itemWeight = compound.getInteger("SpawnWeight"); - if(itemWeight == 0) - itemWeight = 1; + public void readNBT(NBTTagCompound compound) { + id = compound.getInteger("SpawnId"); + name = compound.getString("SpawnName"); + itemWeight = compound.getInteger("SpawnWeight"); + if (itemWeight == 0) + itemWeight = 1; - biomes = NBTTags.getStringList(compound.getTagList("SpawnBiomes", 10)); - if (!compound.hasKey("SpawnDimensions")) { - dimensions.addAll(Arrays.asList(DimensionManager.getStaticDimensionIDs())); - } else { - dimensions = NBTTags.getIntegerSet(compound.getTagList("SpawnDimensions", 10)); - } + biomes = NBTTags.getStringList(compound.getTagList("SpawnBiomes", 10)); + if (!compound.hasKey("SpawnDimensions")) { + dimensions.addAll(Arrays.asList(DimensionManager.getStaticDimensionIDs())); + } else { + dimensions = NBTTags.getIntegerSet(compound.getTagList("SpawnDimensions", 10)); + } - this.spawnCompounds.clear(); - Set keys = compound.func_150296_c(); - for (Object key : keys) { - if (((String)key).startsWith("SpawnCompound")) { - int i = Integer.parseInt(((String)key).replace("SpawnCompound","")); - this.spawnCompounds.put(i,compound.getCompoundTag("SpawnCompound"+i)); - } - } + this.spawnCompounds.clear(); + Set keys = compound.func_150296_c(); + for (Object key : keys) { + if (((String) key).startsWith("SpawnCompound")) { + int i = Integer.parseInt(((String) key).replace("SpawnCompound", "")); + this.spawnCompounds.put(i, compound.getCompoundTag("SpawnCompound" + i)); + } + } - animalSpawning = compound.getBoolean("AnimalSpawning"); - monsterSpawning = compound.getBoolean("MonsterSpawning"); - liquidSpawning = compound.getBoolean("LiquidSpawning"); - airSpawning = compound.getBoolean("CaveSpawning"); + animalSpawning = compound.getBoolean("AnimalSpawning"); + monsterSpawning = compound.getBoolean("MonsterSpawning"); + liquidSpawning = compound.getBoolean("LiquidSpawning"); + airSpawning = compound.getBoolean("CaveSpawning"); - spawnHeightMin = compound.getInteger("HeightMin"); - if (!compound.hasKey("HeightMax")) { - spawnHeightMax = 100; - } else { - spawnHeightMax = compound.getInteger("HeightMax"); - } - } + spawnHeightMin = compound.getInteger("HeightMin"); + if (!compound.hasKey("HeightMax")) { + spawnHeightMax = 100; + } else { + spawnHeightMax = compound.getInteger("HeightMax"); + } + } - public NBTTagCompound writeNBT(NBTTagCompound compound) { - compound.setInteger("SpawnId", id); - compound.setString("SpawnName", name); - compound.setInteger("SpawnWeight", itemWeight); - - compound.setTag("SpawnBiomes", NBTTags.nbtStringList(biomes)); - if (!this.dimensions.isEmpty()) { - compound.setTag("SpawnDimensions", NBTTags.nbtIntegerSet(dimensions)); - } + public NBTTagCompound writeNBT(NBTTagCompound compound) { + compound.setInteger("SpawnId", id); + compound.setString("SpawnName", name); + compound.setInteger("SpawnWeight", itemWeight); - Set> entries = this.spawnCompounds.entrySet(); - for (Map.Entry entry : entries) { - compound.setTag("SpawnCompound" + entry.getKey(), entry.getValue() != null ? entry.getValue() : new NBTTagCompound()); - } + compound.setTag("SpawnBiomes", NBTTags.nbtStringList(biomes)); + if (!this.dimensions.isEmpty()) { + compound.setTag("SpawnDimensions", NBTTags.nbtIntegerSet(dimensions)); + } - compound.setBoolean("AnimalSpawning", animalSpawning); - compound.setBoolean("MonsterSpawning", monsterSpawning); - compound.setBoolean("LiquidSpawning", liquidSpawning); - compound.setBoolean("CaveSpawning", airSpawning); + Set> entries = this.spawnCompounds.entrySet(); + for (Map.Entry entry : entries) { + compound.setTag("SpawnCompound" + entry.getKey(), entry.getValue() != null ? entry.getValue() : new NBTTagCompound()); + } - compound.setInteger("HeightMin", spawnHeightMin); - compound.setInteger("HeightMax", spawnHeightMax); - return compound; - } + compound.setBoolean("AnimalSpawning", animalSpawning); + compound.setBoolean("MonsterSpawning", monsterSpawning); + compound.setBoolean("LiquidSpawning", liquidSpawning); + compound.setBoolean("CaveSpawning", airSpawning); - public void setName(String name) { - if (name != null && !name.isEmpty()) { - this.name = name; - } - } + compound.setInteger("HeightMin", spawnHeightMin); + compound.setInteger("HeightMax", spawnHeightMax); + return compound; + } - public String getName() { - return this.name; - } + public void setName(String name) { + if (name != null && !name.isEmpty()) { + this.name = name; + } + } - public void setEntity(IEntity entity, int slot) { - NBTTagCompound compound = new NBTTagCompound(); - if (entity != null && !entity.getMCEntity().writeToNBTOptional(compound)) { - throw new CustomNPCsException("Entity could not be written to NBT"); - } else { - this.spawnCompounds.put(slot,compound); - } - } + public String getName() { + return this.name; + } - public IEntity getEntity(IWorld world, int slot) { - if (!this.spawnCompounds.containsKey(slot)) { - return null; - } - try { - Entity entity = EntityList.createEntityFromNBT(this.spawnCompounds.get(slot), world.getMCWorld()); - return NpcAPI.Instance().getIEntity(entity); - } catch (Exception e) { - throw new CustomNPCsException("Error creating entity from spawn data:\n" + e.getMessage()); - } - } + public void setEntity(IEntity entity, int slot) { + NBTTagCompound compound = new NBTTagCompound(); + if (entity != null && !entity.getMCEntity().writeToNBTOptional(compound)) { + throw new CustomNPCsException("Entity could not be written to NBT"); + } else { + this.spawnCompounds.put(slot, compound); + } + } - public Integer[] getSlots() { - return this.spawnCompounds.keySet().toArray(new Integer[0]); - } + public IEntity getEntity(IWorld world, int slot) { + if (!this.spawnCompounds.containsKey(slot)) { + return null; + } + try { + Entity entity = EntityList.createEntityFromNBT(this.spawnCompounds.get(slot), world.getMCWorld()); + return NpcAPI.Instance().getIEntity(entity); + } catch (Exception e) { + throw new CustomNPCsException("Error creating entity from spawn data:\n" + e.getMessage()); + } + } - public void setWeight(int weight) { - if (weight < 1) - weight = 1; - if (weight > 100) - weight = 100; + public Integer[] getSlots() { + return this.spawnCompounds.keySet().toArray(new Integer[0]); + } - this.itemWeight = weight; - } + public void setWeight(int weight) { + if (weight < 1) + weight = 1; + if (weight > 100) + weight = 100; - public int getWeight() { - return this.itemWeight; - } + this.itemWeight = weight; + } - public void setMinHeight(int height) { - this.spawnHeightMin = height; - } + public int getWeight() { + return this.itemWeight; + } - public int getMinHeight() { - return this.spawnHeightMin; - } + public void setMinHeight(int height) { + this.spawnHeightMin = height; + } - public void setMaxHeight(int height) { - this.spawnHeightMax = height; - } + public int getMinHeight() { + return this.spawnHeightMin; + } - public int getMaxHeight() { - return this.spawnHeightMax; - } + public void setMaxHeight(int height) { + this.spawnHeightMax = height; + } - public void spawnsLikeAnimal(boolean spawns) { - this.animalSpawning = spawns; - } + public int getMaxHeight() { + return this.spawnHeightMax; + } - public boolean spawnsLikeAnimal() { - return animalSpawning; - } + public void spawnsLikeAnimal(boolean spawns) { + this.animalSpawning = spawns; + } - public void spawnsLikeMonster(boolean spawns) { - this.monsterSpawning = spawns; - } + public boolean spawnsLikeAnimal() { + return animalSpawning; + } - public boolean spawnsLikeMonster() { - return monsterSpawning; - } + public void spawnsLikeMonster(boolean spawns) { + this.monsterSpawning = spawns; + } - public void spawnsInLiquid(boolean spawns) { - this.liquidSpawning = spawns; - } + public boolean spawnsLikeMonster() { + return monsterSpawning; + } - public boolean spawnsInLiquid() { - return this.liquidSpawning; - } + public void spawnsInLiquid(boolean spawns) { + this.liquidSpawning = spawns; + } - public void spawnsInAir(boolean spawns) { - this.airSpawning = spawns; - } + public boolean spawnsInLiquid() { + return this.liquidSpawning; + } - public boolean spawnsInAir() { - return this.airSpawning; - } + public void spawnsInAir(boolean spawns) { + this.airSpawning = spawns; + } - public String[] getBiomes() { - return biomes.toArray(new String[]{}); - } + public boolean spawnsInAir() { + return this.airSpawning; + } - public void setBiomes(String[] biomes) { - this.biomes = new ArrayList<>(Arrays.asList(biomes)); - } + public String[] getBiomes() { + return biomes.toArray(new String[]{}); + } + + public void setBiomes(String[] biomes) { + this.biomes = new ArrayList<>(Arrays.asList(biomes)); + } } diff --git a/src/main/java/noppes/npcs/controllers/data/Tag.java b/src/main/java/noppes/npcs/controllers/data/Tag.java index 4116e719e..bb530fe61 100644 --- a/src/main/java/noppes/npcs/controllers/data/Tag.java +++ b/src/main/java/noppes/npcs/controllers/data/Tag.java @@ -9,75 +9,85 @@ import java.util.UUID; import static java.util.UUID.randomUUID; public class Tag implements ITag { - public String name = ""; - public int color = Integer.parseInt("FF00", 16); - public int id = -1; - public UUID uuid = randomUUID(); - public boolean hideTag = false; + public String name = ""; + public int color = Integer.parseInt("FF00", 16); + public int id = -1; + public UUID uuid = randomUUID(); + public boolean hideTag = false; - public Tag(){} + public Tag() { + } - public Tag(int id, String name, int color){ - this.name = name; - this.color = color; - this.id = id; - } - public static String formatName(String name){ - name = name.toLowerCase().trim(); - return name.substring(0, 1).toUpperCase() + name.substring(1); - } - public void readNBT(NBTTagCompound compound){ + public Tag(int id, String name, int color) { + this.name = name; + this.color = color; + this.id = id; + } + + public static String formatName(String name) { + name = name.toLowerCase().trim(); + return name.substring(0, 1).toUpperCase() + name.substring(1); + } + + public void readNBT(NBTTagCompound compound) { name = compound.getString("Name"); color = compound.getInteger("Color"); id = compound.getInteger("Slot"); hideTag = compound.getBoolean("HideTag"); - uuid = UUID.fromString(compound.getString("Uuid")); - } - public void writeNBT(NBTTagCompound compound){ - compound.setInteger("Slot", id); - compound.setString("Name", name); - compound.setInteger("Color", color); - compound.setString("Uuid", uuid.toString()); - compound.setBoolean("HideTag", hideTag); - } - public void readShortNBT(NBTTagCompound compound){ - name = compound.getString("Name"); - uuid = UUID.fromString(compound.getString("Uuid")); - } - public void writeShortNBT(NBTTagCompound compound){ - compound.setString("Name", name); - compound.setString("Uuid", uuid.toString()); - } + uuid = UUID.fromString(compound.getString("Uuid")); + } - public int getId() { - return this.id; - } + public void writeNBT(NBTTagCompound compound) { + compound.setInteger("Slot", id); + compound.setString("Name", name); + compound.setInteger("Color", color); + compound.setString("Uuid", uuid.toString()); + compound.setBoolean("HideTag", hideTag); + } - public String getUuid() { - return this.uuid.toString(); - } + public void readShortNBT(NBTTagCompound compound) { + name = compound.getString("Name"); + uuid = UUID.fromString(compound.getString("Uuid")); + } - public String getName() { - return this.name; - } + public void writeShortNBT(NBTTagCompound compound) { + compound.setString("Name", name); + compound.setString("Uuid", uuid.toString()); + } - public void setName(String name) { this.name = name; } + public int getId() { + return this.id; + } - public void setColor(int color) { this.color = color; } + public String getUuid() { + return this.uuid.toString(); + } - public int getColor() { - return this.color; - } + public String getName() { + return this.name; + } - public boolean getIsHidden() { - return this.hideTag; - } + public void setName(String name) { + this.name = name; + } - public void setIsHidden(boolean bo) { - this.hideTag = bo; - } + public void setColor(int color) { + this.color = color; + } - public void save() { - TagController.getInstance().saveTag(this); - } + public int getColor() { + return this.color; + } + + public boolean getIsHidden() { + return this.hideTag; + } + + public void setIsHidden(boolean bo) { + this.hideTag = bo; + } + + public void save() { + TagController.getInstance().saveTag(this); + } } diff --git a/src/main/java/noppes/npcs/controllers/data/TagMap.java b/src/main/java/noppes/npcs/controllers/data/TagMap.java index 023a0c9d9..073439d50 100644 --- a/src/main/java/noppes/npcs/controllers/data/TagMap.java +++ b/src/main/java/noppes/npcs/controllers/data/TagMap.java @@ -7,104 +7,103 @@ import net.minecraft.nbt.NBTTagString; import java.util.*; public class TagMap { - public int cloneTab; - public HashMap> tagMap; + public int cloneTab; + public HashMap> tagMap; - public TagMap(int tab){ - this.cloneTab = tab; - this.tagMap = new HashMap>(); - } + public TagMap(int tab) { + this.cloneTab = tab; + this.tagMap = new HashMap>(); + } - public void readNBT(NBTTagCompound compound){ - this.tagMap = new HashMap>(); - NBTTagList list = compound.getTagList("TagMap", 10); - if(list != null){ - for(int i = 0; i < list.tagCount(); i++) - { - NBTTagCompound nbttagcompound = list.getCompoundTagAt(i); - String cloneName = nbttagcompound.getString("Clone"); + public void readNBT(NBTTagCompound compound) { + this.tagMap = new HashMap>(); + NBTTagList list = compound.getTagList("TagMap", 10); + if (list != null) { + for (int i = 0; i < list.tagCount(); i++) { + NBTTagCompound nbttagcompound = list.getCompoundTagAt(i); + String cloneName = nbttagcompound.getString("Clone"); - HashSet uuids = new HashSet(); - NBTTagList nbtTagList = nbttagcompound.getTagList("TagUUIDs",8); - for (int j = 0; j < nbtTagList.tagCount(); j++) { - String uuid = nbtTagList.getStringTagAt(j); - if(!uuid.isEmpty()){ - uuids.add(UUID.fromString(uuid)); - } - } - tagMap.put(cloneName, uuids); - } - } - } + HashSet uuids = new HashSet(); + NBTTagList nbtTagList = nbttagcompound.getTagList("TagUUIDs", 8); + for (int j = 0; j < nbtTagList.tagCount(); j++) { + String uuid = nbtTagList.getStringTagAt(j); + if (!uuid.isEmpty()) { + uuids.add(UUID.fromString(uuid)); + } + } + tagMap.put(cloneName, uuids); + } + } + } - public NBTTagCompound writeNBT(){ - NBTTagCompound nbt = new NBTTagCompound(); - NBTTagList cloneList = new NBTTagList(); - for(String key: tagMap.keySet()){ - HashSet uuidSet = tagMap.get(key); - if(uuidSet.size() > 0){ - NBTTagCompound cloneCompound = new NBTTagCompound(); - cloneCompound.setString("Clone", key); - NBTTagList nbtTagList = new NBTTagList(); - for (UUID uuid : uuidSet) { - nbtTagList.appendTag(new NBTTagString(uuid.toString())); - } - cloneCompound.setTag("TagUUIDs", nbtTagList); - cloneList.appendTag(cloneCompound); - } - } - nbt.setTag("TagMap", cloneList); - return nbt; - } + public NBTTagCompound writeNBT() { + NBTTagCompound nbt = new NBTTagCompound(); + NBTTagList cloneList = new NBTTagList(); + for (String key : tagMap.keySet()) { + HashSet uuidSet = tagMap.get(key); + if (uuidSet.size() > 0) { + NBTTagCompound cloneCompound = new NBTTagCompound(); + cloneCompound.setString("Clone", key); + NBTTagList nbtTagList = new NBTTagList(); + for (UUID uuid : uuidSet) { + nbtTagList.appendTag(new NBTTagString(uuid.toString())); + } + cloneCompound.setTag("TagUUIDs", nbtTagList); + cloneList.appendTag(cloneCompound); + } + } + nbt.setTag("TagMap", cloneList); + return nbt; + } - public int getCloneTab() { - return this.cloneTab; - } + public int getCloneTab() { + return this.cloneTab; + } - public boolean hasClone(String cloneName) { - return tagMap.containsKey(cloneName); - } + public boolean hasClone(String cloneName) { + return tagMap.containsKey(cloneName); + } - public HashSet getUUIDs(String cloneName) { - if(hasClone(cloneName)){ - return tagMap.get(cloneName); - } - return null; - } + public HashSet getUUIDs(String cloneName) { + if (hasClone(cloneName)) { + return tagMap.get(cloneName); + } + return null; + } - public List getUUIDsList(String cloneName) { - HashSet uuids = getUUIDs(cloneName); - if(uuids != null){ - List tagUUIDS = new ArrayList<>(uuids); - Collections.sort(tagUUIDS); - return tagUUIDS; - } + public List getUUIDsList(String cloneName) { + HashSet uuids = getUUIDs(cloneName); + if (uuids != null) { + List tagUUIDS = new ArrayList<>(uuids); + Collections.sort(tagUUIDS); + return tagUUIDS; + } - return null; - } + return null; + } - public boolean removeClone(String cloneName) { - return tagMap.remove(cloneName) != null; - } + public boolean removeClone(String cloneName) { + return tagMap.remove(cloneName) != null; + } - public void putClone(String cloneName, HashSet uuids) { - tagMap.put(cloneName, uuids); - } + public void putClone(String cloneName, HashSet uuids) { + tagMap.put(cloneName, uuids); + } - public boolean hasTag(String cloneName, UUID tag) { - HashSet uuids = getUUIDs(cloneName); - if(uuids == null){ - return false; - } - return uuids.contains(tag); - } + public boolean hasTag(String cloneName, UUID tag) { + HashSet uuids = getUUIDs(cloneName); + if (uuids == null) { + return false; + } + return uuids.contains(tag); + } - public HashSet getAllUUIDs() { - HashSet uuids = new HashSet(); - for(HashSet uuids1 : tagMap.values()){ - uuids.addAll(uuids1); - } - return uuids; - } + public HashSet getAllUUIDs() { + HashSet uuids = new HashSet(); + for (HashSet uuids1 : tagMap.values()) { + uuids.addAll(uuids1); + } + return uuids; + } } diff --git a/src/main/java/noppes/npcs/controllers/data/TintData.java b/src/main/java/noppes/npcs/controllers/data/TintData.java index b72c867fd..104600daf 100644 --- a/src/main/java/noppes/npcs/controllers/data/TintData.java +++ b/src/main/java/noppes/npcs/controllers/data/TintData.java @@ -12,7 +12,7 @@ public class TintData { public NBTTagCompound writeToNBT(NBTTagCompound nbttagcompound) { nbttagcompound.setBoolean("TintEnabled", tintEnabled); - if(tintEnabled) { + if (tintEnabled) { nbttagcompound.setBoolean("HurtTintEnabled", hurtTintEnabled); nbttagcompound.setBoolean("GeneralTintEnabled", generalTintEnabled); nbttagcompound.setInteger("HurtTint", hurtTint); @@ -24,7 +24,7 @@ public class TintData { public void readFromNBT(NBTTagCompound nbttagcompound) { tintEnabled = nbttagcompound.getBoolean("TintEnabled"); - if(tintEnabled) { + if (tintEnabled) { hurtTintEnabled = nbttagcompound.getBoolean("HurtTintEnabled"); generalTintEnabled = nbttagcompound.getBoolean("GeneralTintEnabled"); hurtTint = nbttagcompound.getInteger("HurtTint"); @@ -81,8 +81,8 @@ public class TintData { this.generalAlpha = generalAlpha; } - public boolean processColor(boolean isHurt){ - if(isHurt){ + public boolean processColor(boolean isHurt) { + if (isHurt) { return (isTintEnabled() && (!isHurtTintEnabled() && !isGeneralTintEnabled())); } else { return !(isTintEnabled() && isGeneralTintEnabled()); diff --git a/src/main/java/noppes/npcs/controllers/data/TransportCategory.java b/src/main/java/noppes/npcs/controllers/data/TransportCategory.java index 4a14ce184..f95159d5a 100644 --- a/src/main/java/noppes/npcs/controllers/data/TransportCategory.java +++ b/src/main/java/noppes/npcs/controllers/data/TransportCategory.java @@ -11,95 +11,95 @@ import java.util.Map; import java.util.Vector; public class TransportCategory implements ITransportCategory { - public int id = -1; - public String title = ""; - public HashMap locations; + public int id = -1; + public String title = ""; + public HashMap locations; - public TransportCategory(){ - locations = new HashMap(); - } + public TransportCategory() { + locations = new HashMap(); + } - public Vector getDefaultLocations() { - Vector list = new Vector(); - for(TransportLocation loc : locations.values()) - if(loc.isDefault()) - list.add(loc); - return list; - } + public Vector getDefaultLocations() { + Vector list = new Vector(); + for (TransportLocation loc : locations.values()) + if (loc.isDefault()) + list.add(loc); + return list; + } - public void readNBT(NBTTagCompound compound){ - id = compound.getInteger("CategoryId"); - title = compound.getString("CategoryTitle"); + public void readNBT(NBTTagCompound compound) { + id = compound.getInteger("CategoryId"); + title = compound.getString("CategoryTitle"); - NBTTagList locs = compound.getTagList("CategoryLocations", 10); - if(locs == null || locs.tagCount() == 0) - return; + NBTTagList locs = compound.getTagList("CategoryLocations", 10); + if (locs == null || locs.tagCount() == 0) + return; - for(int ii = 0; ii < locs.tagCount(); ii++) - { - TransportLocation location = new TransportLocation(); - location.readNBT(locs.getCompoundTagAt(ii)); - location.category = this; - locations.put(location.id,location); + for (int ii = 0; ii < locs.tagCount(); ii++) { + TransportLocation location = new TransportLocation(); + location.readNBT(locs.getCompoundTagAt(ii)); + location.category = this; + locations.put(location.id, location); } - } + } - public void writeNBT(NBTTagCompound compound){ - compound.setInteger("CategoryId", id); - compound.setString("CategoryTitle", title); + public void writeNBT(NBTTagCompound compound) { + compound.setInteger("CategoryId", id); + compound.setString("CategoryTitle", title); NBTTagList locs = new NBTTagList(); - for(TransportLocation location : locations.values()){ - locs.appendTag(location.writeNBT()); - } - compound.setTag("CategoryLocations", locs); - } + for (TransportLocation location : locations.values()) { + locs.appendTag(location.writeNBT()); + } + compound.setTag("CategoryLocations", locs); + } - public int getId() { - return id; - } + public int getId() { + return id; + } - public void setTitle(String title) { - this.title = title; - } + public void setTitle(String title) { + this.title = title; + } - public String getTitle() { - return title; - } + public String getTitle() { + return title; + } - public void addLocation(String name) { - int id = TransportController.getInstance().getUniqueIdLocation(); - TransportLocation location = new TransportLocation(); - location.id = id; - location.name = name; - location.category = this; + public void addLocation(String name) { + int id = TransportController.getInstance().getUniqueIdLocation(); + TransportLocation location = new TransportLocation(); + location.id = id; + location.name = name; + location.category = this; - TransportController.getInstance().setLocation(location); - } + TransportController.getInstance().setLocation(location); + } - public ITransportLocation getLocation(String name) { - TransportLocation location = null; - for (TransportLocation l : locations.values()) { - if (l.getName().equals(name)) { - location = l; - break; - } - } + public ITransportLocation getLocation(String name) { + TransportLocation location = null; + for (TransportLocation l : locations.values()) { + if (l.getName().equals(name)) { + location = l; + break; + } + } - return location; - } + return location; + } - public void removeLocation(String name) { - int id = -1; - for (Map.Entry entry : locations.entrySet()) { - if (entry.getValue().getName().equals(name)) { - id = entry.getKey();; - locations.remove(entry.getKey()); - break; - } - } + public void removeLocation(String name) { + int id = -1; + for (Map.Entry entry : locations.entrySet()) { + if (entry.getValue().getName().equals(name)) { + id = entry.getKey(); + ; + locations.remove(entry.getKey()); + break; + } + } - if (id >= 0) { - TransportController.getInstance().removeLocation(id); - } - } + if (id >= 0) { + TransportController.getInstance().removeLocation(id); + } + } } diff --git a/src/main/java/noppes/npcs/controllers/data/TransportLocation.java b/src/main/java/noppes/npcs/controllers/data/TransportLocation.java index ce21b6758..cd2d78ab3 100644 --- a/src/main/java/noppes/npcs/controllers/data/TransportLocation.java +++ b/src/main/java/noppes/npcs/controllers/data/TransportLocation.java @@ -7,102 +7,102 @@ import noppes.npcs.controllers.TransportController; import noppes.npcs.scripted.NpcAPI; public class TransportLocation implements ITransportLocation { - public int id = -1; - public String name = "default name"; - public double posX; - public double posY; - public double posZ; - - public int type = 0; - public int dimension = 0; - - public TransportCategory category; - - public void readNBT(NBTTagCompound compound) { - if(compound == null) - return; - id = compound.getInteger("Id"); - posX = compound.getDouble("PosX"); - posY = compound.getDouble("PosY"); - posZ = compound.getDouble("PosZ"); - type = compound.getInteger("Type"); - dimension = compound.getInteger("Dimension"); - name = compound.getString("Name"); - } + public int id = -1; + public String name = "default name"; + public double posX; + public double posY; + public double posZ; - public NBTTagCompound writeNBT() { - NBTTagCompound compound = new NBTTagCompound(); - compound.setInteger("Id", id); - compound.setDouble("PosX", posX); - compound.setDouble("PosY", posY); - compound.setDouble("PosZ", posZ); - compound.setInteger("Type", type); - compound.setInteger("Dimension", dimension); - compound.setString("Name", name); - return compound; - } + public int type = 0; + public int dimension = 0; - public boolean isDefault() { - return type == 1; - } + public TransportCategory category; - public int getId() { - return id; - } + public void readNBT(NBTTagCompound compound) { + if (compound == null) + return; + id = compound.getInteger("Id"); + posX = compound.getDouble("PosX"); + posY = compound.getDouble("PosY"); + posZ = compound.getDouble("PosZ"); + type = compound.getInteger("Type"); + dimension = compound.getInteger("Dimension"); + name = compound.getString("Name"); + } - public void setName(String name) { - this.name = name; - } + public NBTTagCompound writeNBT() { + NBTTagCompound compound = new NBTTagCompound(); + compound.setInteger("Id", id); + compound.setDouble("PosX", posX); + compound.setDouble("PosY", posY); + compound.setDouble("PosZ", posZ); + compound.setInteger("Type", type); + compound.setInteger("Dimension", dimension); + compound.setString("Name", name); + return compound; + } - public String getName() { - return name; - } + public boolean isDefault() { + return type == 1; + } - public void setDimension(int dimension) { - this.dimension = dimension; - } + public int getId() { + return id; + } - public int getDimension() { - return dimension; - } + public void setName(String name) { + this.name = name; + } - public void setType(int type) { - this.type = type; - } + public String getName() { + return name; + } - public int getType() { - return type; - } + public void setDimension(int dimension) { + this.dimension = dimension; + } - public void setPosition(int x, int y, int z) { - this.posX = x; - this.posY = y; - this.posZ = z; - } + public int getDimension() { + return dimension; + } - public void setPosition(IPos pos) { - this.posX = pos.getX(); - this.posY = pos.getY(); - this.posZ = pos.getZ(); - } + public void setType(int type) { + this.type = type; + } - public IPos getPos() { - return NpcAPI.Instance().getIPos(this.posX, this.posY, this.posZ); - } + public int getType() { + return type; + } - public double getX() { - return posX; - } + public void setPosition(int x, int y, int z) { + this.posX = x; + this.posY = y; + this.posZ = z; + } - public double getY() { - return posY; - } + public void setPosition(IPos pos) { + this.posX = pos.getX(); + this.posY = pos.getY(); + this.posZ = pos.getZ(); + } - public double getZ() { - return posZ; - } + public IPos getPos() { + return NpcAPI.Instance().getIPos(this.posX, this.posY, this.posZ); + } - public void save() { - TransportController.getInstance().saveLocation(this.category.id, this); - } + public double getX() { + return posX; + } + + public double getY() { + return posY; + } + + public double getZ() { + return posZ; + } + + public void save() { + TransportController.getInstance().saveLocation(this.category.id, this); + } } diff --git a/src/main/java/noppes/npcs/enchants/EnchantConfusion.java b/src/main/java/noppes/npcs/enchants/EnchantConfusion.java index 5c8f89e6a..482ecf68f 100644 --- a/src/main/java/noppes/npcs/enchants/EnchantConfusion.java +++ b/src/main/java/noppes/npcs/enchants/EnchantConfusion.java @@ -5,23 +5,23 @@ import noppes.npcs.items.ItemStaff; public class EnchantConfusion extends EnchantInterface { - public EnchantConfusion() { - super(3, ItemStaff.class, ItemGun.class); - setName("confusion"); - } + public EnchantConfusion() { + super(3, ItemStaff.class, ItemGun.class); + setName("confusion"); + } - @Override - public int getMinEnchantability(int par1) { + @Override + public int getMinEnchantability(int par1) { return 12 + (par1 - 1) * 20; - } + } - @Override - public int getMaxEnchantability(int par1) { - return this.getMinEnchantability(par1) + 25; - } + @Override + public int getMaxEnchantability(int par1) { + return this.getMinEnchantability(par1) + 25; + } - @Override - public int getMaxLevel() { - return 2; - } + @Override + public int getMaxLevel() { + return 2; + } } diff --git a/src/main/java/noppes/npcs/enchants/EnchantDamage.java b/src/main/java/noppes/npcs/enchants/EnchantDamage.java index b21d4553e..323b13763 100644 --- a/src/main/java/noppes/npcs/enchants/EnchantDamage.java +++ b/src/main/java/noppes/npcs/enchants/EnchantDamage.java @@ -5,23 +5,23 @@ import noppes.npcs.items.ItemStaff; public class EnchantDamage extends EnchantInterface { - public EnchantDamage() { - super(10, ItemStaff.class, ItemGun.class); - setName("damage"); - } + public EnchantDamage() { + super(10, ItemStaff.class, ItemGun.class); + setName("damage"); + } - @Override - public int getMinEnchantability(int par1) { - return 1 + (par1 - 1) * 10; - } + @Override + public int getMinEnchantability(int par1) { + return 1 + (par1 - 1) * 10; + } - @Override - public int getMaxEnchantability(int par1) { - return this.getMinEnchantability(par1) + 15; - } + @Override + public int getMaxEnchantability(int par1) { + return this.getMinEnchantability(par1) + 15; + } - @Override - public int getMaxLevel() { - return 5; - } + @Override + public int getMaxLevel() { + return 5; + } } diff --git a/src/main/java/noppes/npcs/enchants/EnchantInfinite.java b/src/main/java/noppes/npcs/enchants/EnchantInfinite.java index bc3f8c7d1..e3b783b36 100644 --- a/src/main/java/noppes/npcs/enchants/EnchantInfinite.java +++ b/src/main/java/noppes/npcs/enchants/EnchantInfinite.java @@ -5,23 +5,23 @@ import noppes.npcs.items.ItemStaff; public class EnchantInfinite extends EnchantInterface { - public EnchantInfinite() { - super(3, ItemStaff.class, ItemGun.class); - setName("infinite"); - } + public EnchantInfinite() { + super(3, ItemStaff.class, ItemGun.class); + setName("infinite"); + } - @Override - public int getMinEnchantability(int par1) { - return 20; - } + @Override + public int getMinEnchantability(int par1) { + return 20; + } - @Override - public int getMaxEnchantability(int par1) { - return 50; - } + @Override + public int getMaxEnchantability(int par1) { + return 50; + } - @Override - public int getMaxLevel() { - return 1; - } + @Override + public int getMaxLevel() { + return 1; + } } diff --git a/src/main/java/noppes/npcs/enchants/EnchantInterface.java b/src/main/java/noppes/npcs/enchants/EnchantInterface.java index 96bd406e5..2f7867eaf 100644 --- a/src/main/java/noppes/npcs/enchants/EnchantInterface.java +++ b/src/main/java/noppes/npcs/enchants/EnchantInterface.java @@ -8,51 +8,50 @@ import net.minecraftforge.common.util.EnumHelper; import noppes.npcs.LogWriter; import noppes.npcs.config.ConfigMain; -public abstract class EnchantInterface extends Enchantment{ +public abstract class EnchantInterface extends Enchantment { private static EnumEnchantmentType CustomNpcsType; - public static EnchantInterface Damage; - public static EnchantInterface Poison; - public static EnchantInterface Confusion; - public static EnchantInterface Infinite; - - private Class[] classes; + public static EnchantInterface Damage; + public static EnchantInterface Poison; + public static EnchantInterface Confusion; + public static EnchantInterface Infinite; - protected EnchantInterface(int par2, Class... obs) { - super(ConfigMain.EnchantStartId++, par2, CustomNpcsType); - classes = obs; - } - - @Override - public boolean canApply(ItemStack par1ItemStack){ - if(par1ItemStack.getItem() == null) - return false; - for(Class cls : classes){ - if(cls.isInstance(par1ItemStack.getItem())) - return true; - } - return false; + private Class[] classes; + + protected EnchantInterface(int par2, Class... obs) { + super(ConfigMain.EnchantStartId++, par2, CustomNpcsType); + classes = obs; } - - public static void load(){ - if(!ConfigMain.DisableEnchants){ - CustomNpcsType = EnumHelper.addEnchantmentType("customnpcs_enchants"); - try{ - Damage = new EnchantDamage(); - Poison = new EnchantPoison(); - Confusion = new EnchantConfusion(); - Infinite = new EnchantInfinite(); - } - catch(Exception e){ - LogWriter.except(e); - } - } - } - public static int getLevel(EnchantInterface enchant, ItemStack stack) { - if(ConfigMain.DisableEnchants || enchant == null) - return 0; - return EnchantmentHelper.getEnchantmentLevel(enchant.effectId, stack); - } + @Override + public boolean canApply(ItemStack par1ItemStack) { + if (par1ItemStack.getItem() == null) + return false; + for (Class cls : classes) { + if (cls.isInstance(par1ItemStack.getItem())) + return true; + } + return false; + } + + public static void load() { + if (!ConfigMain.DisableEnchants) { + CustomNpcsType = EnumHelper.addEnchantmentType("customnpcs_enchants"); + try { + Damage = new EnchantDamage(); + Poison = new EnchantPoison(); + Confusion = new EnchantConfusion(); + Infinite = new EnchantInfinite(); + } catch (Exception e) { + LogWriter.except(e); + } + } + } + + public static int getLevel(EnchantInterface enchant, ItemStack stack) { + if (ConfigMain.DisableEnchants || enchant == null) + return 0; + return EnchantmentHelper.getEnchantmentLevel(enchant.effectId, stack); + } } diff --git a/src/main/java/noppes/npcs/enchants/EnchantPoison.java b/src/main/java/noppes/npcs/enchants/EnchantPoison.java index d59dbec2a..81f8b661f 100644 --- a/src/main/java/noppes/npcs/enchants/EnchantPoison.java +++ b/src/main/java/noppes/npcs/enchants/EnchantPoison.java @@ -5,23 +5,23 @@ import noppes.npcs.items.ItemStaff; public class EnchantPoison extends EnchantInterface { - public EnchantPoison() { - super(6, ItemStaff.class, ItemGun.class); - setName("poison"); - } + public EnchantPoison() { + super(6, ItemStaff.class, ItemGun.class); + setName("poison"); + } - @Override - public int getMinEnchantability(int par1) { + @Override + public int getMinEnchantability(int par1) { return 12 + (par1 - 1) * 20; - } + } - @Override - public int getMaxEnchantability(int par1) { + @Override + public int getMaxEnchantability(int par1) { return this.getMinEnchantability(par1) + 25; - } + } - @Override - public int getMaxLevel() { - return 2; - } + @Override + public int getMaxLevel() { + return 2; + } } diff --git a/src/main/java/noppes/npcs/entity/EntityChairMount.java b/src/main/java/noppes/npcs/entity/EntityChairMount.java index ec022e1c6..82efb0a1a 100644 --- a/src/main/java/noppes/npcs/entity/EntityChairMount.java +++ b/src/main/java/noppes/npcs/entity/EntityChairMount.java @@ -6,68 +6,70 @@ import net.minecraft.entity.Entity; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.World; -public class EntityChairMount extends Entity{ +public class EntityChairMount extends Entity { - public EntityChairMount(World world) { - super(world); - setSize(0, 0); - } - - public double getMountedYOffset(){ + public EntityChairMount(World world) { + super(world); + setSize(0, 0); + } + + public double getMountedYOffset() { return 0.5f; } - @Override - protected void entityInit() { - } - - public void onEntityUpdate(){ - super.onEntityUpdate(); - if(this.worldObj != null && !this.worldObj.isRemote && riddenByEntity == null) - isDead = true; - } - @Override - public boolean isEntityInvulnerable(){ + protected void entityInit() { + } + + public void onEntityUpdate() { + super.onEntityUpdate(); + if (this.worldObj != null && !this.worldObj.isRemote && riddenByEntity == null) + isDead = true; + } + + @Override + public boolean isEntityInvulnerable() { return true; } - + @Override - public boolean isInvisible(){ + public boolean isInvisible() { return true; } + @Override - public void moveEntity(double p_70091_1_, double p_70091_3_, double p_70091_5_){ - + public void moveEntity(double p_70091_1_, double p_70091_3_, double p_70091_5_) { + } - @Override - protected void readEntityFromNBT(NBTTagCompound p_70037_1_) { - - } - @Override - protected void writeEntityToNBT(NBTTagCompound p_70014_1_) { - - } + @Override + protected void readEntityFromNBT(NBTTagCompound p_70037_1_) { - @Override - public boolean canBeCollidedWith(){ + } + + @Override + protected void writeEntityToNBT(NBTTagCompound p_70014_1_) { + + } + + @Override + public boolean canBeCollidedWith() { return false; } - @Override - public boolean canBePushed(){ + @Override + public boolean canBePushed() { return false; } - @Override - protected void fall(float p_70069_1_){ - + @Override + protected void fall(float p_70069_1_) { + } - - @Override + + @Override @SideOnly(Side.CLIENT) - public void setPositionAndRotation2(double p_70056_1_, double p_70056_3_, double p_70056_5_, float p_70056_7_, float p_70056_8_, int p_70056_9_){ + public void setPositionAndRotation2(double p_70056_1_, double p_70056_3_, double p_70056_5_, float p_70056_7_, float p_70056_8_, int p_70056_9_) { this.setPosition(p_70056_1_, p_70056_3_, p_70056_5_); this.setRotation(p_70056_7_, p_70056_8_); } diff --git a/src/main/java/noppes/npcs/entity/EntityCustomNpc.java b/src/main/java/noppes/npcs/entity/EntityCustomNpc.java index 0ace370dc..708ba3e42 100644 --- a/src/main/java/noppes/npcs/entity/EntityCustomNpc.java +++ b/src/main/java/noppes/npcs/entity/EntityCustomNpc.java @@ -11,85 +11,83 @@ import noppes.npcs.entity.data.ModelData; import noppes.npcs.entity.data.ModelPartData; public class EntityCustomNpc extends EntityNPCFlying { - public ModelData modelData = new ModelData(); + public ModelData modelData = new ModelData(); - public EntityCustomNpc(World world) { - super(world); - } - - @Override - public void readEntityFromNBT(NBTTagCompound compound) { - super.readEntityFromNBT(compound); - if(compound.hasKey("NpcModelData")) { - npcVersion = compound.getInteger("ModRev"); - VersionCompatibility.CheckModelCompatibility(this, compound); - modelData.readFromNBT(compound.getCompoundTag("NpcModelData")); - } - } - - @Override - public void writeEntityToNBT(NBTTagCompound compound) { - super.writeEntityToNBT(compound); - compound.setTag("NpcModelData", modelData.writeToNBT()); - } - - @Override - public void onUpdate(){ - super.onUpdate(); - if(isRemote()){ - ModelPartData particles = modelData.getPartData("particles"); - if(particles != null && !isKilled()){ - CustomNpcs.proxy.spawnParticle(this, "ModelData", modelData, particles); - } - EntityLivingBase entity = modelData.getEntity(this); - if(entity != null){ - try{ - entity.onUpdate(); - } - catch(Exception e){ - - } - EntityUtil.Copy(this, entity); - } - } + public EntityCustomNpc(World world) { + super(world); } - @Override - public void mountEntity(Entity par1Entity){ - super.mountEntity(par1Entity); - updateHitbox(); + @Override + public void readEntityFromNBT(NBTTagCompound compound) { + super.readEntityFromNBT(compound); + if (compound.hasKey("NpcModelData")) { + npcVersion = compound.getInteger("ModRev"); + VersionCompatibility.CheckModelCompatibility(this, compound); + modelData.readFromNBT(compound.getCompoundTag("NpcModelData")); + } } - @Override - public void updateHitbox() { - Entity entity = modelData.getEntity(this); - if(modelData == null || entity == null){ - baseHeight = 1.9f - modelData.getBodyY() + (modelData.modelScale.head.scaleY - 1) / 2; - super.updateHitbox(); - } - else{ - if(entity instanceof EntityNPCInterface) - ((EntityNPCInterface)entity).updateHitbox(); - width = (entity.width / 5f) * display.modelSize; - height = (entity.height / 5f) * display.modelSize; - if(display.hitboxData.isHitboxEnabled()){ + @Override + public void writeEntityToNBT(NBTTagCompound compound) { + super.writeEntityToNBT(compound); + compound.setTag("NpcModelData", modelData.writeToNBT()); + } + + @Override + public void onUpdate() { + super.onUpdate(); + if (isRemote()) { + ModelPartData particles = modelData.getPartData("particles"); + if (particles != null && !isKilled()) { + CustomNpcs.proxy.spawnParticle(this, "ModelData", modelData, particles); + } + EntityLivingBase entity = modelData.getEntity(this); + if (entity != null) { + try { + entity.onUpdate(); + } catch (Exception e) { + + } + EntityUtil.Copy(this, entity); + } + } + } + + @Override + public void mountEntity(Entity par1Entity) { + super.mountEntity(par1Entity); + updateHitbox(); + } + + @Override + public void updateHitbox() { + Entity entity = modelData.getEntity(this); + if (modelData == null || entity == null) { + baseHeight = 1.9f - modelData.getBodyY() + (modelData.modelScale.head.scaleY - 1) / 2; + super.updateHitbox(); + } else { + if (entity instanceof EntityNPCInterface) + ((EntityNPCInterface) entity).updateHitbox(); + width = (entity.width / 5f) * display.modelSize; + height = (entity.height / 5f) * display.modelSize; + if (display.hitboxData.isHitboxEnabled()) { width = width * display.hitboxData.getWidthScale(); height = height * display.hitboxData.getHeightScale(); } - if(width < 0.1f) - width = 0.1f; - if(height < 0.1f) - height = 0.1f; - if(isKilled() && stats.hideKilledBody){ + if (width < 0.1f) + width = 0.1f; + if (height < 0.1f) + height = 0.1f; + if (isKilled() && stats.hideKilledBody) { width = 0.00001f; } - if(width / 2 > worldObj.MAX_ENTITY_RADIUS) { + if (width / 2 > worldObj.MAX_ENTITY_RADIUS) { worldObj.MAX_ENTITY_RADIUS = width / 2; } - this.setPosition(posX, posY, posZ); - } - } + this.setPosition(posX, posY, posZ); + } + } } diff --git a/src/main/java/noppes/npcs/entity/EntityDialogNpc.java b/src/main/java/noppes/npcs/entity/EntityDialogNpc.java index 69190e655..bc6471519 100644 --- a/src/main/java/noppes/npcs/entity/EntityDialogNpc.java +++ b/src/main/java/noppes/npcs/entity/EntityDialogNpc.java @@ -3,30 +3,30 @@ package noppes.npcs.entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.world.World; -public class EntityDialogNpc extends EntityNPCInterface{ +public class EntityDialogNpc extends EntityNPCInterface { - public EntityDialogNpc(World world) { - super(world); - } + public EntityDialogNpc(World world) { + super(world); + } - @Override - public boolean isInvisibleToPlayer(EntityPlayer player){ + @Override + public boolean isInvisibleToPlayer(EntityPlayer player) { return true; } - @Override - public boolean isInvisible(){ - return true; - } + @Override + public boolean isInvisible() { + return true; + } - @Override - public void onUpdate(){ - - } - - @Override - public boolean interact(EntityPlayer player) { - return false; - } + @Override + public void onUpdate() { + + } + + @Override + public boolean interact(EntityPlayer player) { + return false; + } } diff --git a/src/main/java/noppes/npcs/entity/EntityFakeLiving.java b/src/main/java/noppes/npcs/entity/EntityFakeLiving.java index 1f3525f85..2a4ea5067 100644 --- a/src/main/java/noppes/npcs/entity/EntityFakeLiving.java +++ b/src/main/java/noppes/npcs/entity/EntityFakeLiving.java @@ -3,10 +3,10 @@ package noppes.npcs.entity; import net.minecraft.entity.EntityLiving; import net.minecraft.world.World; -public class EntityFakeLiving extends EntityLiving{ +public class EntityFakeLiving extends EntityLiving { - public EntityFakeLiving(World par1World) { - super(par1World); - } + public EntityFakeLiving(World par1World) { + super(par1World); + } } diff --git a/src/main/java/noppes/npcs/entity/EntityMagicProjectile.java b/src/main/java/noppes/npcs/entity/EntityMagicProjectile.java index 26ef17ac3..93d439696 100644 --- a/src/main/java/noppes/npcs/entity/EntityMagicProjectile.java +++ b/src/main/java/noppes/npcs/entity/EntityMagicProjectile.java @@ -5,31 +5,31 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.StatCollector; import net.minecraft.world.World; -public class EntityMagicProjectile extends EntityProjectile{ - private EntityPlayer player; - private ItemStack equiped; +public class EntityMagicProjectile extends EntityProjectile { + private EntityPlayer player; + private ItemStack equiped; - public EntityMagicProjectile(World par1World){ - super(par1World); - } + public EntityMagicProjectile(World par1World) { + super(par1World); + } - public EntityMagicProjectile(World par1World, - EntityPlayer player, ItemStack item, boolean isNPC) { - super(par1World, player, item, isNPC); + public EntityMagicProjectile(World par1World, + EntityPlayer player, ItemStack item, boolean isNPC) { + super(par1World, player, item, isNPC); - this.player = player; - this.equiped = player.inventory.getCurrentItem(); - } + this.player = player; + this.equiped = player.inventory.getCurrentItem(); + } - @Override - public void onUpdate(){ - if(!worldObj.isRemote && (player == null || player.inventory.getCurrentItem() != equiped)) - this.setDead(); - super.onUpdate(); - } + @Override + public void onUpdate() { + if (!worldObj.isRemote && (player == null || player.inventory.getCurrentItem() != equiped)) + this.setDead(); + super.onUpdate(); + } - @Override - public String getCommandSenderName(){ - return StatCollector.translateToLocal("entity.throwableitem.name"); - } + @Override + public String getCommandSenderName() { + return StatCollector.translateToLocal("entity.throwableitem.name"); + } } diff --git a/src/main/java/noppes/npcs/entity/EntityNPCFlying.java b/src/main/java/noppes/npcs/entity/EntityNPCFlying.java index 580e646e0..fde3a2561 100644 --- a/src/main/java/noppes/npcs/entity/EntityNPCFlying.java +++ b/src/main/java/noppes/npcs/entity/EntityNPCFlying.java @@ -14,30 +14,29 @@ public abstract class EntityNPCFlying extends EntityNPCInterface { } @Override - public boolean canFly(){ + public boolean canFly() { return ais.movementType == 1; } @Override public void fall(float distance) { - if(!canFly()) + if (!canFly()) super.fall(distance); } @Override protected void updateFallState(double p_180433_1_, boolean p_180433_3_) { - if(!canFly()) + if (!canFly()) super.updateFallState(p_180433_1_, p_180433_3_); } @Override - public boolean isOnLadder(){ + public boolean isOnLadder() { return false; } - public void moveEntityWithHeading(float p_70612_1_, float p_70612_2_) - { - if(!this.canFly() || this.hurtTime != 0 || !this.canBreathe()) { + public void moveEntityWithHeading(float p_70612_1_, float p_70612_2_) { + if (!this.canFly() || this.hurtTime != 0 || !this.canBreathe()) { super.moveEntityWithHeading(p_70612_1_, p_70612_2_); return; } @@ -45,9 +44,9 @@ public abstract class EntityNPCFlying extends EntityNPCInterface { boolean aboveLimit = false; double heightOffGround = this.posY - this.worldObj.getTopSolidOrLiquidBlock((int) this.posX, (int) this.posZ); if (heightOffGround < 0) { - Vec3 pos = Vec3.createVectorHelper(this.posX,this.posY,this.posZ); - Vec3 posLimit = Vec3.createVectorHelper(this.posX,this.posY - this.ais.flyHeightLimit,this.posZ); - MovingObjectPosition mob = this.worldObj.rayTraceBlocks(pos,posLimit,true); + Vec3 pos = Vec3.createVectorHelper(this.posX, this.posY, this.posZ); + Vec3 posLimit = Vec3.createVectorHelper(this.posX, this.posY - this.ais.flyHeightLimit, this.posZ); + MovingObjectPosition mob = this.worldObj.rayTraceBlocks(pos, posLimit, true); if (mob == null || mob.typeOfHit == MovingObjectPosition.MovingObjectType.MISS) { aboveLimit = true; } diff --git a/src/main/java/noppes/npcs/entity/EntityNPCGolem.java b/src/main/java/noppes/npcs/entity/EntityNPCGolem.java index c3427ff24..078e864f2 100644 --- a/src/main/java/noppes/npcs/entity/EntityNPCGolem.java +++ b/src/main/java/noppes/npcs/entity/EntityNPCGolem.java @@ -13,48 +13,44 @@ import noppes.npcs.entity.data.ModelData; // EntityAnimal, Item, EntityPlayer, InventoryPlayer, // ItemStack, World, NBTTagCompound -public class EntityNPCGolem extends EntityNPCInterface -{ +public class EntityNPCGolem extends EntityNPCInterface { - public EntityNPCGolem(World world) - { + public EntityNPCGolem(World world) { super(world); display.texture = "customnpcs:textures/entity/golem/Iron Golem.png"; - width = 1.4f; - height = 2.5f; + width = 1.4f; + height = 2.5f; } public void updateHitbox() { - currentAnimation = EnumAnimation.values()[dataWatcher.getWatchableObjectInt(14)]; - if(currentAnimation == EnumAnimation.LYING){ - width = height = 0.5f; - } - else if (currentAnimation == EnumAnimation.SITTING){ - width = 1.4f; - height = 2f; - } - else{ - width = 1.4f; - height = 2.5f; - } - } - public void onUpdate() - { - isDead = true; + currentAnimation = EnumAnimation.values()[dataWatcher.getWatchableObjectInt(14)]; + if (currentAnimation == EnumAnimation.LYING) { + width = height = 0.5f; + } else if (currentAnimation == EnumAnimation.SITTING) { + width = 1.4f; + height = 2f; + } else { + width = 1.4f; + height = 2.5f; + } + } - if(!worldObj.isRemote){ - NBTTagCompound compound = new NBTTagCompound(); + public void onUpdate() { + isDead = true; - writeToNBT(compound); - EntityCustomNpc npc = new EntityCustomNpc(worldObj); - npc.readFromNBT(compound); - ModelData data = npc.modelData; - data.setEntityClass(EntityNPCGolem.class); + if (!worldObj.isRemote) { + NBTTagCompound compound = new NBTTagCompound(); + + writeToNBT(compound); + EntityCustomNpc npc = new EntityCustomNpc(worldObj); + npc.readFromNBT(compound); + ModelData data = npc.modelData; + data.setEntityClass(EntityNPCGolem.class); - worldObj.spawnEntityInWorld(npc); - } + worldObj.spawnEntityInWorld(npc); + } super.onUpdate(); } } diff --git a/src/main/java/noppes/npcs/entity/EntityNPCInterface.java b/src/main/java/noppes/npcs/entity/EntityNPCInterface.java index 8917596ab..09853272a 100644 --- a/src/main/java/noppes/npcs/entity/EntityNPCInterface.java +++ b/src/main/java/noppes/npcs/entity/EntityNPCInterface.java @@ -566,7 +566,7 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti return false; // Attribute - if(!DBCAddon.IsAvailable() && attackingEntity instanceof EntityPlayer) + if (!DBCAddon.IsAvailable() && attackingEntity instanceof EntityPlayer) i = AttributeAttackUtil.calculateDamagePlayerToNPC((EntityPlayer) attackingEntity, this, i); // Resistances @@ -727,7 +727,7 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti if (isKilled()) return; - if(!faction.isPassive()){ + if (!faction.isPassive()) { IEntitySelector attackEntitySelector = new NPCAttackSelector(this); this.targetTasks.addTask(0, new EntityAIClearTarget(this)); this.targetTasks.addTask(1, new EntityAIHurtByTarget(this, false)); diff --git a/src/main/java/noppes/npcs/entity/EntityNpcCrystal.java b/src/main/java/noppes/npcs/entity/EntityNpcCrystal.java index de1c4aa1c..e33e90b20 100644 --- a/src/main/java/noppes/npcs/entity/EntityNpcCrystal.java +++ b/src/main/java/noppes/npcs/entity/EntityNpcCrystal.java @@ -1,6 +1,6 @@ // Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov. // Jad home page: http://www.kpdus.com/jad.html -// Decompiler options: packimports(3) braces deadcode fieldsfirst +// Decompiler options: packimports(3) braces deadcode fieldsfirst package noppes.npcs.entity; @@ -9,36 +9,33 @@ import net.minecraft.world.World; import noppes.npcs.entity.data.ModelData; // Referenced classes of package net.minecraft.src: -// EntityAnimal, Item, EntityPlayer, InventoryPlayer, +// EntityAnimal, Item, EntityPlayer, InventoryPlayer, // ItemStack, World, NBTTagCompound -public class EntityNpcCrystal extends EntityNPCInterface -{ - public EntityNpcCrystal(World world) - { +public class EntityNpcCrystal extends EntityNPCInterface { + public EntityNpcCrystal(World world) { super(world); - scaleX = 0.7f; - scaleY = 0.7f; - scaleZ = 0.7f; - display.texture = "customnpcs:textures/entity/crystal/EnderCrystal.png"; + scaleX = 0.7f; + scaleY = 0.7f; + scaleZ = 0.7f; + display.texture = "customnpcs:textures/entity/crystal/EnderCrystal.png"; } - + @Override - public void onUpdate() - { - isDead = true; - if(!worldObj.isRemote){ - NBTTagCompound compound = new NBTTagCompound(); - - writeToNBT(compound); - EntityCustomNpc npc = new EntityCustomNpc(worldObj); - npc.readFromNBT(compound); - ModelData data = npc.modelData; - data.setEntityClass(EntityNpcCrystal.class); - - - worldObj.spawnEntityInWorld(npc); - } + public void onUpdate() { + isDead = true; + if (!worldObj.isRemote) { + NBTTagCompound compound = new NBTTagCompound(); + + writeToNBT(compound); + EntityCustomNpc npc = new EntityCustomNpc(worldObj); + npc.readFromNBT(compound); + ModelData data = npc.modelData; + data.setEntityClass(EntityNpcCrystal.class); + + + worldObj.spawnEntityInWorld(npc); + } super.onUpdate(); } diff --git a/src/main/java/noppes/npcs/entity/EntityNpcDragon.java b/src/main/java/noppes/npcs/entity/EntityNpcDragon.java index 64d23e282..0d899ee2d 100644 --- a/src/main/java/noppes/npcs/entity/EntityNpcDragon.java +++ b/src/main/java/noppes/npcs/entity/EntityNpcDragon.java @@ -5,98 +5,98 @@ import net.minecraft.util.MathHelper; import net.minecraft.world.World; import noppes.npcs.entity.data.ModelData; -public class EntityNpcDragon extends EntityNPCInterface{ - public EntityNpcDragon(World world) - { +public class EntityNpcDragon extends EntityNPCInterface { + public EntityNpcDragon(World world) { super(world); field_40162_d = new double[64][3]; field_40164_e = -1; field_40173_aw = 0.0F; field_40172_ax = 0.0F; field_40178_aA = 0; - scaleX = 0.4f; - scaleY = 0.4f; - scaleZ = 0.4f; - display.texture = "customnpcs:textures/entity/dragon/BlackDragon.png"; + scaleX = 0.4f; + scaleY = 0.4f; + scaleZ = 0.4f; + display.texture = "customnpcs:textures/entity/dragon/BlackDragon.png"; + + width = 1.8f; + height = 1.4f; + } - width = 1.8f; - height = 1.4f; - } public double field_40162_d[][]; public int field_40164_e; public float field_40173_aw; public float field_40172_ax; public int field_40178_aA; - + public boolean isFlying = false; - + @Override - public double getMountedYOffset(){ - return 1.1; + public double getMountedYOffset() { + return 1.1; } - public double[] func_40160_a(int i, float f) - { + public double[] func_40160_a(int i, float f) { f = 1.0F - f; int j = field_40164_e - i * 1 & 0x3f; int k = field_40164_e - i * 1 - 1 & 0x3f; double ad[] = new double[3]; double d = field_40162_d[j][0]; double d1; - for(d1 = field_40162_d[k][0] - d; d1 < -180D; d1 += 360D) { } - for(; d1 >= 180D; d1 -= 360D) { } - ad[0] = d + d1 * (double)f; + for (d1 = field_40162_d[k][0] - d; d1 < -180D; d1 += 360D) { + } + for (; d1 >= 180D; d1 -= 360D) { + } + ad[0] = d + d1 * (double) f; d = field_40162_d[j][1]; d1 = field_40162_d[k][1] - d; - ad[1] = d + d1 * (double)f; - ad[2] = field_40162_d[j][2] + (field_40162_d[k][2] - field_40162_d[j][2]) * (double)f; + ad[1] = d + d1 * (double) f; + ad[2] = field_40162_d[j][2] + (field_40162_d[k][2] - field_40162_d[j][2]) * (double) f; return ad; } - public void onUpdate() - { - isDead = true; - if(!worldObj.isRemote){ - NBTTagCompound compound = new NBTTagCompound(); - - writeToNBT(compound); - EntityCustomNpc npc = new EntityCustomNpc(worldObj); - npc.readFromNBT(compound); - ModelData data = npc.modelData; - data.setEntityClass(EntityNpcDragon.class); - - - worldObj.spawnEntityInWorld(npc); - } + public void onUpdate() { + isDead = true; + + if (!worldObj.isRemote) { + NBTTagCompound compound = new NBTTagCompound(); + + writeToNBT(compound); + EntityCustomNpc npc = new EntityCustomNpc(worldObj); + npc.readFromNBT(compound); + ModelData data = npc.modelData; + data.setEntityClass(EntityNpcDragon.class); + + + worldObj.spawnEntityInWorld(npc); + } super.onUpdate(); } + private boolean exploded = false; + @Override - public void onLivingUpdate() - { + public void onLivingUpdate() { field_40173_aw = field_40172_ax; - if(worldObj.isRemote && getHealth() <= 0) - { - if(!exploded){ - exploded = true; - float f = (rand.nextFloat() - 0.5F) * 8F; - float f2 = (rand.nextFloat() - 0.5F) * 4F; - float f4 = (rand.nextFloat() - 0.5F) * 8F; - worldObj.spawnParticle("largeexplode", posX + (double)f, posY + 2D + (double)f2, posZ + (double)f4, 0.0D, 0.0D, 0.0D); - } - } - else{ - exploded = false; - //func_41011_ay(); - float f1 = 0.2F / (MathHelper.sqrt_double(motionX * motionX + motionZ * motionZ) * 10F + 1.0F); - f1 = 0.045f; - f1 *= (float)Math.pow(2D, motionY); - field_40172_ax += f1 * 0.5F; + if (worldObj.isRemote && getHealth() <= 0) { + if (!exploded) { + exploded = true; + float f = (rand.nextFloat() - 0.5F) * 8F; + float f2 = (rand.nextFloat() - 0.5F) * 4F; + float f4 = (rand.nextFloat() - 0.5F) * 8F; + worldObj.spawnParticle("largeexplode", posX + (double) f, posY + 2D + (double) f2, posZ + (double) f4, 0.0D, 0.0D, 0.0D); + } + } else { + exploded = false; + //func_41011_ay(); + float f1 = 0.2F / (MathHelper.sqrt_double(motionX * motionX + motionZ * motionZ) * 10F + 1.0F); + f1 = 0.045f; + f1 *= (float) Math.pow(2D, motionY); + field_40172_ax += f1 * 0.5F; } super.onLivingUpdate(); } -// public float ticks = 0.0f; + // public float ticks = 0.0f; // public void updateRiderPosition() // { // if (riddenByEntity == null) @@ -105,7 +105,7 @@ public class EntityNpcDragon extends EntityNPCInterface{ // return; // } // else -// { +// { // float f6 = field_40173_aw + (field_40172_ax - field_40173_aw) * ticks; // float f7 = (float)(Math.sin(f6 * 3.141593F * 2.0F - 1.0F) + 1.0D); // riddenByEntity.setPosition(posX , posY + getMountedYOffset() + riddenByEntity.getYOffset() - f7 / 12, posZ); @@ -113,9 +113,9 @@ public class EntityNpcDragon extends EntityNPCInterface{ // } // } @Override - public void updateHitbox() { - width = 1.8f; - height = 1.4f; - } + public void updateHitbox() { + width = 1.8f; + height = 1.4f; + } } diff --git a/src/main/java/noppes/npcs/entity/EntityNpcPony.java b/src/main/java/noppes/npcs/entity/EntityNpcPony.java index b0e92cd10..ed6ca617c 100644 --- a/src/main/java/noppes/npcs/entity/EntityNpcPony.java +++ b/src/main/java/noppes/npcs/entity/EntityNpcPony.java @@ -5,37 +5,34 @@ import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; import noppes.npcs.entity.data.ModelData; -public class EntityNpcPony extends EntityNPCInterface -{ +public class EntityNpcPony extends EntityNPCInterface { public boolean isPegasus = false; public boolean isUnicorn = false; public boolean isFlying = false; - + public ResourceLocation checked = null; - - public EntityNpcPony(World world) - { + + public EntityNpcPony(World world) { super(world); display.texture = "customnpcs:textures/entity/ponies/MineLP Derpy Hooves.png"; } - - public void onUpdate() - { - isDead = true; - if(!worldObj.isRemote){ - NBTTagCompound compound = new NBTTagCompound(); - - writeToNBT(compound); - EntityCustomNpc npc = new EntityCustomNpc(worldObj); - npc.readFromNBT(compound); - ModelData data = npc.modelData; - data.setEntityClass(EntityNpcPony.class); - - - worldObj.spawnEntityInWorld(npc); - } + public void onUpdate() { + isDead = true; + + if (!worldObj.isRemote) { + NBTTagCompound compound = new NBTTagCompound(); + + writeToNBT(compound); + EntityCustomNpc npc = new EntityCustomNpc(worldObj); + npc.readFromNBT(compound); + ModelData data = npc.modelData; + data.setEntityClass(EntityNpcPony.class); + + + worldObj.spawnEntityInWorld(npc); + } super.onUpdate(); } - + } diff --git a/src/main/java/noppes/npcs/entity/EntityNpcSlime.java b/src/main/java/noppes/npcs/entity/EntityNpcSlime.java index a0cea00f9..8ad000a2e 100644 --- a/src/main/java/noppes/npcs/entity/EntityNpcSlime.java +++ b/src/main/java/noppes/npcs/entity/EntityNpcSlime.java @@ -4,40 +4,39 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.World; import noppes.npcs.entity.data.ModelData; -public class EntityNpcSlime extends EntityNPCInterface{ - public EntityNpcSlime(World world) - { +public class EntityNpcSlime extends EntityNPCInterface { + public EntityNpcSlime(World world) { super(world); - scaleX = 2f; - scaleY = 2f; - scaleZ = 2f; - display.texture = "customnpcs:textures/entity/slime/Slime.png"; - width = 0.8f; - height = 0.8f; - } - @Override - public void updateHitbox() { - width = 0.8f; - height = 0.8f; - } - - @Override - public void onUpdate() - { - isDead = true; + scaleX = 2f; + scaleY = 2f; + scaleZ = 2f; + display.texture = "customnpcs:textures/entity/slime/Slime.png"; + width = 0.8f; + height = 0.8f; + } - if(!worldObj.isRemote){ - NBTTagCompound compound = new NBTTagCompound(); - - writeToNBT(compound); - EntityCustomNpc npc = new EntityCustomNpc(worldObj); - npc.readFromNBT(compound); - ModelData data = npc.modelData; - data.setEntityClass(EntityNpcSlime.class); - - - worldObj.spawnEntityInWorld(npc); - } + @Override + public void updateHitbox() { + width = 0.8f; + height = 0.8f; + } + + @Override + public void onUpdate() { + isDead = true; + + if (!worldObj.isRemote) { + NBTTagCompound compound = new NBTTagCompound(); + + writeToNBT(compound); + EntityCustomNpc npc = new EntityCustomNpc(worldObj); + npc.readFromNBT(compound); + ModelData data = npc.modelData; + data.setEntityClass(EntityNpcSlime.class); + + + worldObj.spawnEntityInWorld(npc); + } super.onUpdate(); } } diff --git a/src/main/java/noppes/npcs/entity/EntityProjectile.java b/src/main/java/noppes/npcs/entity/EntityProjectile.java index e3e581df2..05b60c460 100644 --- a/src/main/java/noppes/npcs/entity/EntityProjectile.java +++ b/src/main/java/noppes/npcs/entity/EntityProjectile.java @@ -46,7 +46,7 @@ import java.util.UUID; public class EntityProjectile extends EntityThrowable { - private int xTile = -1; + private int xTile = -1; private int yTile = -1; private int zTile = -1; private Block inTile; @@ -86,14 +86,13 @@ public class EntityProjectile extends EntityThrowable { public EnumPotionType effect = EnumPotionType.None; public int duration = 5; public int amplify = 0; - public int accuracy = 60; + public int accuracy = 60; public IProjectileCallback callback; public ItemStack callbackItem; - public List scripts = new ArrayList(); + public List scripts = new ArrayList(); - public EntityProjectile(World par1World) - { + public EntityProjectile(World par1World) { super(par1World); this.setSize(0.25F, 0.25F); } @@ -102,14 +101,14 @@ public class EntityProjectile extends EntityThrowable { this.dataWatcher.addObjectByDataType(21, 5); this.dataWatcher.addObject(22, String.valueOf(""));//particle this.dataWatcher.addObject(23, Integer.valueOf(5));//size - this.dataWatcher.addObject(24, Byte.valueOf((byte)0));//glows + this.dataWatcher.addObject(24, Byte.valueOf((byte) 0));//glows this.dataWatcher.addObject(25, Integer.valueOf(10));//velocity - this.dataWatcher.addObject(26, Byte.valueOf((byte)0));//gravity - this.dataWatcher.addObject(27, Byte.valueOf((byte)0));//Arrow - this.dataWatcher.addObject(28, Byte.valueOf((byte)0));//3D - this.dataWatcher.addObject(29, Byte.valueOf((byte)0));//Rotating - this.dataWatcher.addObject(30, Byte.valueOf((byte)0));//Sticks - this.dataWatcher.addObject(31, Byte.valueOf((byte)0));//FakeExplosion + this.dataWatcher.addObject(26, Byte.valueOf((byte) 0));//gravity + this.dataWatcher.addObject(27, Byte.valueOf((byte) 0));//Arrow + this.dataWatcher.addObject(28, Byte.valueOf((byte) 0));//3D + this.dataWatcher.addObject(29, Byte.valueOf((byte) 0));//Rotating + this.dataWatcher.addObject(30, Byte.valueOf((byte) 0));//Sticks + this.dataWatcher.addObject(31, Byte.valueOf((byte) 0));//FakeExplosion } @SideOnly(Side.CLIENT) @@ -118,37 +117,35 @@ public class EntityProjectile extends EntityThrowable { * Checks if the entity is in range to render by using the past in distance and comparing it to its average edge * length * 64 * renderDistanceWeight Args: distance */ - public boolean isInRangeToRenderDist(double par1) - { + public boolean isInRangeToRenderDist(double par1) { double d1 = this.boundingBox.getAverageEdgeLength() * 4.0D; d1 *= 64.0D; return par1 < d1 * d1; } - public EntityProjectile(World par1World, EntityLivingBase par2EntityLiving, ItemStack item, boolean isNPC) - { + public EntityProjectile(World par1World, EntityLivingBase par2EntityLiving, ItemStack item, boolean isNPC) { super(par1World); this.thrower = par2EntityLiving; - if(this.thrower != null) - this.throwerName = this.thrower.getUniqueID().toString(); + if (this.thrower != null) + this.throwerName = this.thrower.getUniqueID().toString(); setThrownItem(item); this.dataWatcher.updateObject(27, Byte.valueOf((byte) ((this.getItem() == Items.arrow) ? 1 : 0))); - this.setSize(this.dataWatcher.getWatchableObjectInt(23) / 10 , this.dataWatcher.getWatchableObjectInt(23) / 10); - this.setLocationAndAngles(par2EntityLiving.posX, par2EntityLiving.posY + (double)par2EntityLiving.getEyeHeight(), par2EntityLiving.posZ, par2EntityLiving.rotationYaw, par2EntityLiving.rotationPitch); - this.posX -= (double)(MathHelper.cos(this.rotationYaw / 180.0F * (float)Math.PI) * 0.1F); + this.setSize(this.dataWatcher.getWatchableObjectInt(23) / 10, this.dataWatcher.getWatchableObjectInt(23) / 10); + this.setLocationAndAngles(par2EntityLiving.posX, par2EntityLiving.posY + (double) par2EntityLiving.getEyeHeight(), par2EntityLiving.posZ, par2EntityLiving.rotationYaw, par2EntityLiving.rotationPitch); + this.posX -= (double) (MathHelper.cos(this.rotationYaw / 180.0F * (float) Math.PI) * 0.1F); this.posY -= 0.1f; - this.posZ -= (double)(MathHelper.sin(this.rotationYaw / 180.0F * (float)Math.PI) * 0.1F); + this.posZ -= (double) (MathHelper.sin(this.rotationYaw / 180.0F * (float) Math.PI) * 0.1F); this.setPosition(this.posX, this.posY, this.posZ); this.yOffset = 0.0F; if (isNPC) { - this.npc = (EntityNPCInterface) this.thrower; - this.getStatProperties(this.npc.stats); - this.destroyTerrain = !this.npc.stats.projectilesKeepTerrain; + this.npc = (EntityNPCInterface) this.thrower; + this.getStatProperties(this.npc.stats); + this.destroyTerrain = !this.npc.stats.projectilesKeepTerrain; } } - public void setThrownItem(ItemStack item){ + public void setThrownItem(ItemStack item) { dataWatcher.updateObject(21, item); } @@ -156,20 +153,19 @@ public class EntityProjectile extends EntityThrowable { * Par: X, Y, Z, Angle, Accuracy */ @Override - public void setThrowableHeading(double par1, double par3, double par5, float par7, float par8) - { + public void setThrowableHeading(double par1, double par3, double par5, float par7, float par8) { float f2 = MathHelper.sqrt_double(par1 * par1 + par3 * par3 + par5 * par5); float f3 = MathHelper.sqrt_double(par1 * par1 + par5 * par5); - float yaw = (float)(Math.atan2(par1, par5) * 180.0D / Math.PI); - float pitch = this.hasGravity() ? par7 : (float)(Math.atan2(par3, (double)f3) * 180.0D / Math.PI); + float yaw = (float) (Math.atan2(par1, par5) * 180.0D / Math.PI); + float pitch = this.hasGravity() ? par7 : (float) (Math.atan2(par3, (double) f3) * 180.0D / Math.PI); this.prevRotationYaw = this.rotationYaw = yaw; this.prevRotationPitch = this.rotationPitch = pitch; - this.motionX = (double)(MathHelper.sin(yaw / 180.0F * (float)Math.PI) * MathHelper.cos(pitch / 180.0F * (float)Math.PI)); - this.motionZ = (double)(MathHelper.cos(yaw / 180.0F * (float)Math.PI) * MathHelper.cos(pitch / 180.0F * (float)Math.PI)); - this.motionY = (double)(MathHelper.sin((pitch + 1.0F) / 180.0F * (float)Math.PI)); - this.motionX += this.rand.nextGaussian() * 0.007499999832361937D * (double)par8; - this.motionZ += this.rand.nextGaussian() * 0.007499999832361937D * (double)par8; - this.motionY += this.rand.nextGaussian() * 0.007499999832361937D * (double)par8; + this.motionX = (double) (MathHelper.sin(yaw / 180.0F * (float) Math.PI) * MathHelper.cos(pitch / 180.0F * (float) Math.PI)); + this.motionZ = (double) (MathHelper.cos(yaw / 180.0F * (float) Math.PI) * MathHelper.cos(pitch / 180.0F * (float) Math.PI)); + this.motionY = (double) (MathHelper.sin((pitch + 1.0F) / 180.0F * (float) Math.PI)); + this.motionX += this.rand.nextGaussian() * 0.007499999832361937D * (double) par8; + this.motionZ += this.rand.nextGaussian() * 0.007499999832361937D * (double) par8; + this.motionY += this.rand.nextGaussian() * 0.007499999832361937D * (double) par8; this.motionX *= this.getSpeed(); this.motionZ *= this.getSpeed(); this.motionY *= this.getSpeed(); @@ -184,21 +180,21 @@ public class EntityProjectile extends EntityThrowable { * Par: X Distance, Y Distance, Z Distance, Horizontial Distance */ public float getAngleForXYZ(double varX, double varY, double varZ, double horiDist, boolean arc) { - float g = this.getGravityVelocity(); - float var1 = this.getSpeed() * this.getSpeed(); - double var2 = (g * horiDist); - double var3 = ((g * horiDist * horiDist) + (2 * varY * var1)); - double var4 = (var1 * var1) - (g * var3); - if (var4 < 0) return 30.0F; - float var6 = arc ? var1 + MathHelper.sqrt_double(var4) : var1 - MathHelper.sqrt_double(var4); - float var7 = (float) (Math.atan2(var6 , var2) * 180.0D / Math.PI); - return var7; + float g = this.getGravityVelocity(); + float var1 = this.getSpeed() * this.getSpeed(); + double var2 = (g * horiDist); + double var3 = ((g * horiDist * horiDist) + (2 * varY * var1)); + double var4 = (var1 * var1) - (g * var3); + if (var4 < 0) return 30.0F; + float var6 = arc ? var1 + MathHelper.sqrt_double(var4) : var1 - MathHelper.sqrt_double(var4); + float var7 = (float) (Math.atan2(var6, var2) * 180.0D / Math.PI); + return var7; } - public void shoot(float speed){ - double varX = (double)(-MathHelper.sin(this.rotationYaw / 180.0F * (float)Math.PI) * MathHelper.cos(this.rotationPitch / 180.0F * (float)Math.PI)); - double varZ = (double)(MathHelper.cos(this.rotationYaw / 180.0F * (float)Math.PI) * MathHelper.cos(this.rotationPitch / 180.0F * (float)Math.PI)); - double varY = (double)(-MathHelper.sin(this.rotationPitch / 180.0F * (float)Math.PI)); + public void shoot(float speed) { + double varX = (double) (-MathHelper.sin(this.rotationYaw / 180.0F * (float) Math.PI) * MathHelper.cos(this.rotationPitch / 180.0F * (float) Math.PI)); + double varZ = (double) (MathHelper.cos(this.rotationYaw / 180.0F * (float) Math.PI) * MathHelper.cos(this.rotationPitch / 180.0F * (float) Math.PI)); + double varY = (double) (-MathHelper.sin(this.rotationPitch / 180.0F * (float) Math.PI)); this.setThrowableHeading(varX, varY, varZ, -rotationPitch, speed); } @@ -208,239 +204,206 @@ public class EntityProjectile extends EntityThrowable { * Sets the position and rotation. Only difference from the other one is no bounding on the rotation. Args: posX, * posY, posZ, yaw, pitch */ - public void setPositionAndRotation2(double par1, double par3, double par5, float par7, float par8, int par9) - { - if(worldObj.isRemote && inGround) - return; + public void setPositionAndRotation2(double par1, double par3, double par5, float par7, float par8, int par9) { + if (worldObj.isRemote && inGround) + return; this.setPosition(par1, par3, par5); this.setRotation(par7, par8); } @Override - public void onUpdate() - { + public void onUpdate() { super.onEntityUpdate(); - if (ticksExisted >= 1200) { - this.setDead(); - } - if(++ticksExisted % 10 == 0){ - EventHooks.onProjectileTick(this); - } + if (ticksExisted >= 1200) { + this.setDead(); + } + if (++ticksExisted % 10 == 0) { + EventHooks.onProjectileTick(this); + } - if (this.prevRotationPitch == 0.0F && this.prevRotationYaw == 0.0F) - { + if (this.prevRotationPitch == 0.0F && this.prevRotationYaw == 0.0F) { float f = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ); - this.prevRotationYaw = this.rotationYaw = (float)(Math.atan2(this.motionX, this.motionZ) * 180.0D / Math.PI); - this.prevRotationPitch = this.rotationPitch = (float)(Math.atan2(this.motionY, (double)f) * 180.0D / Math.PI); + this.prevRotationYaw = this.rotationYaw = (float) (Math.atan2(this.motionX, this.motionZ) * 180.0D / Math.PI); + this.prevRotationPitch = this.rotationPitch = (float) (Math.atan2(this.motionY, (double) f) * 180.0D / Math.PI); if (this.isRotating()) { - this.rotationPitch -= 20; + this.rotationPitch -= 20; } } if (this.effect == EnumPotionType.Fire && !this.inGround) - this.setFire(1); + this.setFire(1); Block block = this.worldObj.getBlock(this.xTile, this.yTile, this.zTile); - if ((this.isArrow() || this.sticksToWalls()) && block != null) - { + if ((this.isArrow() || this.sticksToWalls()) && block != null) { block.setBlockBoundsBasedOnState(this.worldObj, this.xTile, this.yTile, this.zTile); AxisAlignedBB axisalignedbb = block.getCollisionBoundingBoxFromPool(this.worldObj, this.xTile, this.yTile, this.zTile); - if (axisalignedbb != null && axisalignedbb.isVecInside(Vec3.createVectorHelper(this.posX, this.posY, this.posZ))) - { + if (axisalignedbb != null && axisalignedbb.isVecInside(Vec3.createVectorHelper(this.posX, this.posY, this.posZ))) { this.inGround = true; } } - if (this.arrowShake > 0) - { + if (this.arrowShake > 0) { --this.arrowShake; } - if (this.inGround) - { + if (this.inGround) { int j = this.worldObj.getBlockMetadata(this.xTile, this.yTile, this.zTile); - if (block == this.inTile && j == this.inData) - { + if (block == this.inTile && j == this.inData) { ++this.ticksInGround; - if (this.ticksInGround >= 1200) - { + if (this.ticksInGround >= 1200) { this.setDead(); } - } - else - { + } else { this.inGround = false; - this.motionX *= (double)(this.rand.nextFloat() * 0.2F); - this.motionY *= (double)(this.rand.nextFloat() * 0.2F); - this.motionZ *= (double)(this.rand.nextFloat() * 0.2F); + this.motionX *= (double) (this.rand.nextFloat() * 0.2F); + this.motionY *= (double) (this.rand.nextFloat() * 0.2F); + this.motionZ *= (double) (this.rand.nextFloat() * 0.2F); this.ticksInGround = 0; this.ticksInAir = 0; } - } - else - { + } else { ++this.ticksInAir; - if (this.ticksInAir >= 1200) - { + if (this.ticksInAir >= 1200) { this.setDead(); } - Vec3 vec3 = Vec3.createVectorHelper(this.posX, this.posY, this.posZ); - Vec3 vec31 = Vec3.createVectorHelper(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ); - MovingObjectPosition movingobjectposition = this.worldObj.func_147447_a(vec3, vec31, false, true, false);//rayTraceBlocks_do_do - vec3 = Vec3.createVectorHelper(this.posX, this.posY, this.posZ); - vec31 = Vec3.createVectorHelper(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ); + Vec3 vec3 = Vec3.createVectorHelper(this.posX, this.posY, this.posZ); + Vec3 vec31 = Vec3.createVectorHelper(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ); + MovingObjectPosition movingobjectposition = this.worldObj.func_147447_a(vec3, vec31, false, true, false);//rayTraceBlocks_do_do + vec3 = Vec3.createVectorHelper(this.posX, this.posY, this.posZ); + vec31 = Vec3.createVectorHelper(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ); - if (movingobjectposition != null) - { - vec31 = Vec3.createVectorHelper(movingobjectposition.hitVec.xCoord, movingobjectposition.hitVec.yCoord, movingobjectposition.hitVec.zCoord); - } - if (!this.worldObj.isRemote) - { - Entity entity = null; - List list = this.worldObj.getEntitiesWithinAABBExcludingEntity(this, this.boundingBox.addCoord(this.motionX, this.motionY, this.motionZ).expand(1.0D, 1.0D, 1.0D)); - double d0 = 0.0D; - EntityLivingBase entityliving = this.getThrower(); + if (movingobjectposition != null) { + vec31 = Vec3.createVectorHelper(movingobjectposition.hitVec.xCoord, movingobjectposition.hitVec.yCoord, movingobjectposition.hitVec.zCoord); + } + if (!this.worldObj.isRemote) { + Entity entity = null; + List list = this.worldObj.getEntitiesWithinAABBExcludingEntity(this, this.boundingBox.addCoord(this.motionX, this.motionY, this.motionZ).expand(1.0D, 1.0D, 1.0D)); + double d0 = 0.0D; + EntityLivingBase entityliving = this.getThrower(); - for (int k = 0; k < list.size(); ++k) - { - Entity entity1 = (Entity)list.get(k); + for (int k = 0; k < list.size(); ++k) { + Entity entity1 = (Entity) list.get(k); - if (entity1.canBeCollidedWith() && (!entity1.isEntityEqual(this.thrower) || this.ticksInAir >= 25)) - { - float f = 0.3F; - AxisAlignedBB axisalignedbb = entity1.boundingBox.expand((double)f, (double)f, (double)f); - MovingObjectPosition movingobjectposition1 = axisalignedbb.calculateIntercept(vec3, vec31); + if (entity1.canBeCollidedWith() && (!entity1.isEntityEqual(this.thrower) || this.ticksInAir >= 25)) { + float f = 0.3F; + AxisAlignedBB axisalignedbb = entity1.boundingBox.expand((double) f, (double) f, (double) f); + MovingObjectPosition movingobjectposition1 = axisalignedbb.calculateIntercept(vec3, vec31); - if (movingobjectposition1 != null) - { - double d1 = vec3.distanceTo(movingobjectposition1.hitVec); + if (movingobjectposition1 != null) { + double d1 = vec3.distanceTo(movingobjectposition1.hitVec); - if (d1 < d0 || d0 == 0.0D) - { - entity = entity1; - d0 = d1; - } - } - } - } + if (d1 < d0 || d0 == 0.0D) { + entity = entity1; + d0 = d1; + } + } + } + } - if (entity != null) - { - movingobjectposition = new MovingObjectPosition(entity); - } + if (entity != null) { + movingobjectposition = new MovingObjectPosition(entity); + } - if (npc != null && movingobjectposition != null && movingobjectposition.entityHit != null && movingobjectposition.entityHit instanceof EntityPlayer) - { - EntityPlayer entityplayer = (EntityPlayer)movingobjectposition.entityHit; - if (this.npc.faction.isFriendlyToPlayer(entityplayer)){ - movingobjectposition = null; - } - } - } + if (npc != null && movingobjectposition != null && movingobjectposition.entityHit != null && movingobjectposition.entityHit instanceof EntityPlayer) { + EntityPlayer entityplayer = (EntityPlayer) movingobjectposition.entityHit; + if (this.npc.faction.isFriendlyToPlayer(entityplayer)) { + movingobjectposition = null; + } + } + } - if (movingobjectposition != null) - { - if (movingobjectposition.typeOfHit == MovingObjectType.BLOCK && this.worldObj.getBlock(movingobjectposition.blockX, movingobjectposition.blockY, movingobjectposition.blockZ) == Blocks.portal) - { - this.setInPortal(); - } - else - { - this.dataWatcher.updateObject(29, Byte.valueOf((byte)0)); - this.onImpact(movingobjectposition); - } - } + if (movingobjectposition != null) { + if (movingobjectposition.typeOfHit == MovingObjectType.BLOCK && this.worldObj.getBlock(movingobjectposition.blockX, movingobjectposition.blockY, movingobjectposition.blockZ) == Blocks.portal) { + this.setInPortal(); + } else { + this.dataWatcher.updateObject(29, Byte.valueOf((byte) 0)); + this.onImpact(movingobjectposition); + } + } - this.posX += this.motionX; - this.posY += this.motionY; - this.posZ += this.motionZ; - float f1 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ); - this.rotationYaw = (float)(Math.atan2(this.motionX, this.motionZ) * 180.0D / Math.PI); + this.posX += this.motionX; + this.posY += this.motionY; + this.posZ += this.motionZ; + float f1 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ); + this.rotationYaw = (float) (Math.atan2(this.motionX, this.motionZ) * 180.0D / Math.PI); - for (this.rotationPitch = (float)(Math.atan2(this.motionY, (double)f1) * 180.0D / Math.PI); this.rotationPitch - this.prevRotationPitch < -180.0F; this.prevRotationPitch -= 360.0F) - { - ; - } + for (this.rotationPitch = (float) (Math.atan2(this.motionY, (double) f1) * 180.0D / Math.PI); this.rotationPitch - this.prevRotationPitch < -180.0F; this.prevRotationPitch -= 360.0F) { + ; + } - while (this.rotationPitch - this.prevRotationPitch >= 180.0F) - { - this.prevRotationPitch += 360.0F; - } + while (this.rotationPitch - this.prevRotationPitch >= 180.0F) { + this.prevRotationPitch += 360.0F; + } - while (this.rotationYaw - this.prevRotationYaw < -180.0F) - { - this.prevRotationYaw -= 360.0F; - } + while (this.rotationYaw - this.prevRotationYaw < -180.0F) { + this.prevRotationYaw -= 360.0F; + } - while (this.rotationYaw - this.prevRotationYaw >= 180.0F) - { - this.prevRotationYaw += 360.0F; - } + while (this.rotationYaw - this.prevRotationYaw >= 180.0F) { + this.prevRotationYaw += 360.0F; + } - float f = this.isArrow() ? 0.0F : 225.0F; - this.rotationPitch = this.prevRotationPitch + (this.rotationPitch - this.prevRotationPitch) + f * 0.2F; - this.rotationYaw = this.prevRotationYaw + (this.rotationYaw - this.prevRotationYaw) * 0.2F; - if (this.isRotating()) { - int spin = isBlock()? 10 : 20; - this.rotationPitch -= (this.ticksInAir % 15) * spin * getSpeed(); - } - float f2 = this.getMotionFactor(); - float f3 = this.getGravityVelocity(); + float f = this.isArrow() ? 0.0F : 225.0F; + this.rotationPitch = this.prevRotationPitch + (this.rotationPitch - this.prevRotationPitch) + f * 0.2F; + this.rotationYaw = this.prevRotationYaw + (this.rotationYaw - this.prevRotationYaw) * 0.2F; + if (this.isRotating()) { + int spin = isBlock() ? 10 : 20; + this.rotationPitch -= (this.ticksInAir % 15) * spin * getSpeed(); + } + float f2 = this.getMotionFactor(); + float f3 = this.getGravityVelocity(); - if (this.isInWater()) - { - if(worldObj.isRemote){ - for (int k = 0; k < 4; ++k) - { - float f4 = 0.25F; - this.worldObj.spawnParticle("bubble", this.posX - this.motionX * (double)f4, this.posY - this.motionY * (double)f4, this.posZ - this.motionZ * (double)f4, this.motionX, this.motionY, this.motionZ); - } - } + if (this.isInWater()) { + if (worldObj.isRemote) { + for (int k = 0; k < 4; ++k) { + float f4 = 0.25F; + this.worldObj.spawnParticle("bubble", this.posX - this.motionX * (double) f4, this.posY - this.motionY * (double) f4, this.posZ - this.motionZ * (double) f4, this.motionX, this.motionY, this.motionZ); + } + } - f2 = 0.8F; - } + f2 = 0.8F; + } - this.motionX *= (double)f2; - this.motionY *= (double)f2; - this.motionZ *= (double)f2; + this.motionX *= (double) f2; + this.motionY *= (double) f2; + this.motionZ *= (double) f2; - if (hasGravity()) - this.motionY -= (double)f3; + if (hasGravity()) + this.motionY -= (double) f3; - if (accelerate) - { - this.motionX += this.accelerationX; - this.motionY += this.accelerationY; - this.motionZ += this.accelerationZ; - } + if (accelerate) { + this.motionX += this.accelerationX; + this.motionY += this.accelerationY; + this.motionZ += this.accelerationZ; + } - if (worldObj.isRemote && !this.dataWatcher.getWatchableObjectString(22).equals("")){ - this.worldObj.spawnParticle(this.dataWatcher.getWatchableObjectString(22), this.posX, this.posY, this.posZ, 0.0D, 0.0D, 0.0D); - } - this.setPosition(this.posX, this.posY, this.posZ); - this.func_145775_I();//doBlockCollisions + if (worldObj.isRemote && !this.dataWatcher.getWatchableObjectString(22).equals("")) { + this.worldObj.spawnParticle(this.dataWatcher.getWatchableObjectString(22), this.posX, this.posY, this.posZ, 0.0D, 0.0D, 0.0D); + } + this.setPosition(this.posX, this.posY, this.posZ); + this.func_145775_I();//doBlockCollisions } } - public boolean isBlock(){ - ItemStack item = this.getItemDisplay(); - if(item == null) - return false; - return item.getItem() instanceof ItemBlock; + + public boolean isBlock() { + ItemStack item = this.getItemDisplay(); + if (item == null) + return false; + return item.getItem() instanceof ItemBlock; } - private Item getItem(){ - ItemStack item = this.getItemDisplay(); - if(item == null) - return null; - return item.getItem(); + private Item getItem() { + ItemStack item = this.getItemDisplay(); + if (item == null) + return null; + return item.getItem(); } - protected float getMotionFactor() - { + protected float getMotionFactor() { return accelerate ? 0.95F : 1.0F; } @@ -448,187 +411,158 @@ public class EntityProjectile extends EntityThrowable { * Called when this EntityThrowable hits a block or entity. */ @Override - protected void onImpact(MovingObjectPosition movingobjectposition) - { - if (!this.worldObj.isRemote) { - ProjectileEvent.ImpactEvent event; - if (movingobjectposition.entityHit != null) { - IEntity target = NpcAPI.Instance().getIEntity(movingobjectposition.entityHit); - event = new ProjectileEvent.ImpactEvent((IProjectile) NpcAPI.Instance().getIEntity(this), 0, target); - } else { - IPos pos = NpcAPI.Instance().getIPos(movingobjectposition.blockX, movingobjectposition.blockY, movingobjectposition.blockZ); - IWorld world = NpcAPI.Instance().getIWorld(this.worldObj); - event = new ProjectileEvent.ImpactEvent((IProjectile) NpcAPI.Instance().getIEntity(this), 1, NpcAPI.Instance().getIBlock(world, pos)); - } - if (movingobjectposition.entityHit != null) { - if (callback != null && callbackItem != null && movingobjectposition.entityHit instanceof EntityLivingBase && callback.onImpact(this, (EntityLivingBase) movingobjectposition.entityHit, callbackItem)) { - return; - } - } - EventHooks.onProjectileImpact(this, event); - } + protected void onImpact(MovingObjectPosition movingobjectposition) { + if (!this.worldObj.isRemote) { + ProjectileEvent.ImpactEvent event; + if (movingobjectposition.entityHit != null) { + IEntity target = NpcAPI.Instance().getIEntity(movingobjectposition.entityHit); + event = new ProjectileEvent.ImpactEvent((IProjectile) NpcAPI.Instance().getIEntity(this), 0, target); + } else { + IPos pos = NpcAPI.Instance().getIPos(movingobjectposition.blockX, movingobjectposition.blockY, movingobjectposition.blockZ); + IWorld world = NpcAPI.Instance().getIWorld(this.worldObj); + event = new ProjectileEvent.ImpactEvent((IProjectile) NpcAPI.Instance().getIEntity(this), 1, NpcAPI.Instance().getIBlock(world, pos)); + } + if (movingobjectposition.entityHit != null) { + if (callback != null && callbackItem != null && movingobjectposition.entityHit instanceof EntityLivingBase && callback.onImpact(this, (EntityLivingBase) movingobjectposition.entityHit, callbackItem)) { + return; + } + } + EventHooks.onProjectileImpact(this, event); + } - if (movingobjectposition.entityHit != null) - { - float damage = this.damage; - if(damage == 0) - damage = 0.001f; + if (movingobjectposition.entityHit != null) { + float damage = this.damage; + if (damage == 0) + damage = 0.001f; boolean didDBCAttack = false; - if(npc != null){ - if(DBCAddon.instance.canDBCAttack(npc, this.damage, movingobjectposition.entityHit)){ + if (npc != null) { + if (DBCAddon.instance.canDBCAttack(npc, this.damage, movingobjectposition.entityHit)) { damage = 0.001f; didDBCAttack = true; } } - if (movingobjectposition.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, this.getThrower()), damage)) - { - if(didDBCAttack) - DBCAddon.instance.doDBCDamage(npc, this.damage, movingobjectposition.entityHit); + if (movingobjectposition.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, this.getThrower()), damage)) { + if (didDBCAttack) + DBCAddon.instance.doDBCDamage(npc, this.damage, movingobjectposition.entityHit); - if (movingobjectposition.entityHit instanceof EntityLivingBase && (this.isArrow() || this.sticksToWalls())) - { - EntityLivingBase entityliving = (EntityLivingBase)movingobjectposition.entityHit; + if (movingobjectposition.entityHit instanceof EntityLivingBase && (this.isArrow() || this.sticksToWalls())) { + EntityLivingBase entityliving = (EntityLivingBase) movingobjectposition.entityHit; - if (!this.worldObj.isRemote) - { - entityliving.setArrowCountInEntity(entityliving.getArrowCountInEntity() + 1); - } + if (!this.worldObj.isRemote) { + entityliving.setArrowCountInEntity(entityliving.getArrowCountInEntity() + 1); + } - if (destroyedOnEntityHit && !(movingobjectposition.entityHit instanceof EntityEnderman)) - { + if (destroyedOnEntityHit && !(movingobjectposition.entityHit instanceof EntityEnderman)) { this.setDead(); } - } + } - if (this.isBlock()) - { - this.worldObj.playAuxSFX(2001, (int) movingobjectposition.entityHit.posX, (int) movingobjectposition.entityHit.posY, (int) movingobjectposition.entityHit.posZ, Item.getIdFromItem(getItem())); - } - else if (!this.isArrow() && !this.sticksToWalls()) - { - for (int i = 0; i < 8; ++i) - { - this.worldObj.spawnParticle("iconcrack_" + Item.getIdFromItem(getItem()), this.posX, this.posY, this.posZ, this.rand.nextGaussian() * 0.15D, this.rand.nextGaussian() * 0.2D, this.rand.nextGaussian() * 0.15D); - } - } + if (this.isBlock()) { + this.worldObj.playAuxSFX(2001, (int) movingobjectposition.entityHit.posX, (int) movingobjectposition.entityHit.posY, (int) movingobjectposition.entityHit.posZ, Item.getIdFromItem(getItem())); + } else if (!this.isArrow() && !this.sticksToWalls()) { + for (int i = 0; i < 8; ++i) { + this.worldObj.spawnParticle("iconcrack_" + Item.getIdFromItem(getItem()), this.posX, this.posY, this.posZ, this.rand.nextGaussian() * 0.15D, this.rand.nextGaussian() * 0.2D, this.rand.nextGaussian() * 0.15D); + } + } - if (this.punch > 0) - { - float f3 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ); + if (this.punch > 0) { + float f3 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ); - if (f3 > 0.0F) - { - movingobjectposition.entityHit.addVelocity(this.motionX * (double)this.punch * 0.6000000238418579D / (double)f3, 0.1D, this.motionZ * (double)this.punch * 0.6000000238418579D / (double)f3); - } - } + if (f3 > 0.0F) { + movingobjectposition.entityHit.addVelocity(this.motionX * (double) this.punch * 0.6000000238418579D / (double) f3, 0.1D, this.motionZ * (double) this.punch * 0.6000000238418579D / (double) f3); + } + } - if (this.effect != EnumPotionType.None && movingobjectposition.entityHit instanceof EntityLivingBase) - { - if (this.effect != EnumPotionType.Fire) - { - int p = this.getPotionEffect(effect); - ((EntityLivingBase)movingobjectposition.entityHit).addPotionEffect(new PotionEffect(p, this.duration * 20, this.amplify)); - } - else - { - movingobjectposition.entityHit.setFire(duration); - } - } - } - else if (this.hasGravity() && (this.isArrow() || this.sticksToWalls())) - { - this.motionX *= -0.10000000149011612D; + if (this.effect != EnumPotionType.None && movingobjectposition.entityHit instanceof EntityLivingBase) { + if (this.effect != EnumPotionType.Fire) { + int p = this.getPotionEffect(effect); + ((EntityLivingBase) movingobjectposition.entityHit).addPotionEffect(new PotionEffect(p, this.duration * 20, this.amplify)); + } else { + movingobjectposition.entityHit.setFire(duration); + } + } + } else if (this.hasGravity() && (this.isArrow() || this.sticksToWalls())) { + this.motionX *= -0.10000000149011612D; this.motionY *= -0.10000000149011612D; this.motionZ *= -0.10000000149011612D; this.rotationYaw += 180.0F; this.prevRotationYaw += 180.0F; this.ticksInAir = 0; } - } - else - { - if (this.isArrow() || this.sticksToWalls()) { + } else { + if (this.isArrow() || this.sticksToWalls()) { // if (this.sticksToWalls()) { // float f = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ); // float f1 = this.isArrow() ? 0.0F :this.isRotating() ? 180.0F : 225.0F; // this.prevRotationPitch = this.rotationPitch = (float)(Math.atan2(this.motionY, (double)f) * 180.0D / Math.PI) + f1; // } - this.xTile = movingobjectposition.blockX; - this.yTile = movingobjectposition.blockY; - this.zTile = movingobjectposition.blockZ; - this.inTile = this.worldObj.getBlock(this.xTile, this.yTile, this.zTile); - this.inData = this.worldObj.getBlockMetadata(this.xTile, this.yTile, this.zTile); - this.motionX = (double)((float)(movingobjectposition.hitVec.xCoord - this.posX)); - this.motionY = (double)((float)(movingobjectposition.hitVec.yCoord - this.posY)); - this.motionZ = (double)((float)(movingobjectposition.hitVec.zCoord - this.posZ)); - float f2 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionY * this.motionY + this.motionZ * this.motionZ); - this.posX -= this.motionX / (double)f2 * 0.05000000074505806D; - this.posY -= this.motionY / (double)f2 * 0.05000000074505806D; - this.posZ -= this.motionZ / (double)f2 * 0.05000000074505806D; - this.inGround = true; - if (this.isArrow()) - this.playSound("random.bowhit", 1.0F, 1.2F / (this.rand.nextFloat() * 0.2F + 0.9F)); - else - this.playSound("random.break", 1.0F, 1.2F / (this.rand.nextFloat() * 0.2F + 0.9F)); - this.arrowShake = 7; + this.xTile = movingobjectposition.blockX; + this.yTile = movingobjectposition.blockY; + this.zTile = movingobjectposition.blockZ; + this.inTile = this.worldObj.getBlock(this.xTile, this.yTile, this.zTile); + this.inData = this.worldObj.getBlockMetadata(this.xTile, this.yTile, this.zTile); + this.motionX = (double) ((float) (movingobjectposition.hitVec.xCoord - this.posX)); + this.motionY = (double) ((float) (movingobjectposition.hitVec.yCoord - this.posY)); + this.motionZ = (double) ((float) (movingobjectposition.hitVec.zCoord - this.posZ)); + float f2 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionY * this.motionY + this.motionZ * this.motionZ); + this.posX -= this.motionX / (double) f2 * 0.05000000074505806D; + this.posY -= this.motionY / (double) f2 * 0.05000000074505806D; + this.posZ -= this.motionZ / (double) f2 * 0.05000000074505806D; + this.inGround = true; + if (this.isArrow()) + this.playSound("random.bowhit", 1.0F, 1.2F / (this.rand.nextFloat() * 0.2F + 0.9F)); + else + this.playSound("random.break", 1.0F, 1.2F / (this.rand.nextFloat() * 0.2F + 0.9F)); + this.arrowShake = 7; - if (!this.hasGravity()) { - this.dataWatcher.updateObject(26, Byte.valueOf((byte) 1)); - } + if (!this.hasGravity()) { + this.dataWatcher.updateObject(26, Byte.valueOf((byte) 1)); + } - if (this.inTile != null) - {//onEntityCollidedWithBlock - inTile.onEntityCollidedWithBlock(this.worldObj, this.xTile, this.yTile, this.zTile, this); - } - } - else - { - if (this.isBlock()) - { - this.worldObj.playAuxSFX(2001, MathHelper.floor_double(posX), MathHelper.floor_double(posY), MathHelper.floor_double(posZ), Item.getIdFromItem(getItem())); - } - else - { - for (int i = 0; i < 8; ++i) - { - this.worldObj.spawnParticle("iconcrack_" + Item.getIdFromItem(getItem()), this.posX, this.posY, this.posZ, this.rand.nextGaussian() * 0.15D, this.rand.nextGaussian() * 0.2D, this.rand.nextGaussian() * 0.15D); - } - } - } + if (this.inTile != null) {//onEntityCollidedWithBlock + inTile.onEntityCollidedWithBlock(this.worldObj, this.xTile, this.yTile, this.zTile, this); + } + } else { + if (this.isBlock()) { + this.worldObj.playAuxSFX(2001, MathHelper.floor_double(posX), MathHelper.floor_double(posY), MathHelper.floor_double(posZ), Item.getIdFromItem(getItem())); + } else { + for (int i = 0; i < 8; ++i) { + this.worldObj.spawnParticle("iconcrack_" + Item.getIdFromItem(getItem()), this.posX, this.posY, this.posZ, this.rand.nextGaussian() * 0.15D, this.rand.nextGaussian() * 0.2D, this.rand.nextGaussian() * 0.15D); + } + } + } } - if (explosive){ - if (this.explosiveRadius != 0 || this.effect == EnumPotionType.None){ - boolean terraindamage = this.worldObj.getGameRules().getGameRuleBooleanValue("mobGriefing") && explosiveDamage && destroyTerrain; - Explosion explosion = new Explosion(worldObj, this, posX, posY, posZ, explosiveRadius); - explosion.isFlaming = this.effect == EnumPotionType.Fire; - explosion.isSmoking = terraindamage; - if(terraindamage) - explosion.doExplosionA(); - explosion.doExplosionB(worldObj.isRemote); - //this.worldObj.newExplosion(null, this.posX, this.posY, this.posZ, this.explosiveRadius, this.effect == EnumPotionType.Fire, this.worldObj.getGameRules().getGameRuleBooleanValue("mobGriefing") && explosiveDamage); - if(!worldObj.isRemote){ - Iterator iterator = worldObj.playerEntities.iterator(); + if (explosive) { + if (this.explosiveRadius != 0 || this.effect == EnumPotionType.None) { + boolean terraindamage = this.worldObj.getGameRules().getGameRuleBooleanValue("mobGriefing") && explosiveDamage && destroyTerrain; + Explosion explosion = new Explosion(worldObj, this, posX, posY, posZ, explosiveRadius); + explosion.isFlaming = this.effect == EnumPotionType.Fire; + explosion.isSmoking = terraindamage; + if (terraindamage) + explosion.doExplosionA(); + explosion.doExplosionB(worldObj.isRemote); + //this.worldObj.newExplosion(null, this.posX, this.posY, this.posZ, this.explosiveRadius, this.effect == EnumPotionType.Fire, this.worldObj.getGameRules().getGameRuleBooleanValue("mobGriefing") && explosiveDamage); + if (!worldObj.isRemote) { + Iterator iterator = worldObj.playerEntities.iterator(); - while (iterator.hasNext()){ - EntityPlayer entityplayer = (EntityPlayer)iterator.next(); - if (entityplayer.getDistanceSq(posX, posY, posZ) < 4096.0D){ - ((EntityPlayerMP)entityplayer).playerNetServerHandler.sendPacket(new S27PacketExplosion(posX, posY, posZ, explosiveRadius, explosion.affectedBlockPositions, (Vec3)explosion.func_77277_b().get(entityplayer))); - } - } + while (iterator.hasNext()) { + EntityPlayer entityplayer = (EntityPlayer) iterator.next(); + if (entityplayer.getDistanceSq(posX, posY, posZ) < 4096.0D) { + ((EntityPlayerMP) entityplayer).playerNetServerHandler.sendPacket(new S27PacketExplosion(posX, posY, posZ, explosiveRadius, explosion.affectedBlockPositions, (Vec3) explosion.func_77277_b().get(entityplayer))); + } + } } - if (this.explosiveRadius != 0 && (this.isArrow() || this.sticksToWalls())) - this.setDead(); - } - else if (this.effect == EnumPotionType.Fire){ - int i = movingobjectposition.blockX; + if (this.explosiveRadius != 0 && (this.isArrow() || this.sticksToWalls())) + this.setDead(); + } else if (this.effect == EnumPotionType.Fire) { + int i = movingobjectposition.blockX; int j = movingobjectposition.blockY; int k = movingobjectposition.blockZ; - switch (movingobjectposition.sideHit) - { + switch (movingobjectposition.sideHit) { case 0: --j; break; @@ -648,109 +582,93 @@ public class EntityProjectile extends EntityThrowable { ++i; } - if (this.worldObj.isAirBlock(i, j, k)) - { + if (this.worldObj.isAirBlock(i, j, k)) { this.worldObj.setBlock(i, j, k, Blocks.fire); } - } - else - { - AxisAlignedBB axisalignedbb = this.boundingBox.expand(4.0D, 2.0D, 4.0D); - List list1 = this.worldObj.getEntitiesWithinAABB(EntityLivingBase.class, axisalignedbb); + } else { + AxisAlignedBB axisalignedbb = this.boundingBox.expand(4.0D, 2.0D, 4.0D); + List list1 = this.worldObj.getEntitiesWithinAABB(EntityLivingBase.class, axisalignedbb); - if (list1 != null && !list1.isEmpty()) - { - Iterator iterator = list1.iterator(); + if (list1 != null && !list1.isEmpty()) { + Iterator iterator = list1.iterator(); - while (iterator.hasNext()) - { - EntityLivingBase entitylivingbase = (EntityLivingBase)iterator.next(); + while (iterator.hasNext()) { + EntityLivingBase entitylivingbase = (EntityLivingBase) iterator.next(); double d0 = this.getDistanceSqToEntity(entitylivingbase); - if (d0 < 16.0D) - { + if (d0 < 16.0D) { double d1 = 1.0D - Math.sqrt(d0) / 4.0D; - if (entitylivingbase == movingobjectposition.entityHit) - { + if (entitylivingbase == movingobjectposition.entityHit) { d1 = 1.0D; } int i = this.getPotionEffect(effect); - if (Potion.potionTypes[i].isInstant()) - { + if (Potion.potionTypes[i].isInstant()) { Potion.potionTypes[i].affectEntity(this.getThrower(), entitylivingbase, this.amplify, d1); - } - else - { - int j = (int)(d1 * (double)this.duration + 0.5D); + } else { + int j = (int) (d1 * (double) this.duration + 0.5D); - if (j > 20) - { + if (j > 20) { entitylivingbase.addPotionEffect(new PotionEffect(i, j, this.amplify)); } } } } } - this.worldObj.playAuxSFX(2002, (int)Math.round(this.posX), (int)Math.round(this.posY), (int)Math.round(this.posZ), this.getPotionColor(this.effect)); - } - } + this.worldObj.playAuxSFX(2002, (int) Math.round(this.posX), (int) Math.round(this.posY), (int) Math.round(this.posZ), this.getPotionColor(this.effect)); + } + } - if (!this.worldObj.isRemote && !this.isArrow() && !this.sticksToWalls()) - { + if (!this.worldObj.isRemote && !this.isArrow() && !this.sticksToWalls()) { this.setDead(); } } - public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound) - { - par1NBTTagCompound.setShort("xTile", (short)this.xTile); - par1NBTTagCompound.setShort("yTile", (short)this.yTile); - par1NBTTagCompound.setShort("zTile", (short)this.zTile); - par1NBTTagCompound.setByte("inTile", (byte)Block.getIdFromBlock(this.inTile)); - par1NBTTagCompound.setByte("inData", (byte)this.inData); - par1NBTTagCompound.setByte("shake", (byte)this.throwableShake); - par1NBTTagCompound.setByte("inGround", (byte)(this.inGround ? 1 : 0)); - par1NBTTagCompound.setByte("isArrow", (byte)(this.isArrow() ? 1 : 0)); - par1NBTTagCompound.setTag("direction", this.newDoubleNBTList(new double[] {this.motionX, this.motionY, this.motionZ})); + public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound) { + par1NBTTagCompound.setShort("xTile", (short) this.xTile); + par1NBTTagCompound.setShort("yTile", (short) this.yTile); + par1NBTTagCompound.setShort("zTile", (short) this.zTile); + par1NBTTagCompound.setByte("inTile", (byte) Block.getIdFromBlock(this.inTile)); + par1NBTTagCompound.setByte("inData", (byte) this.inData); + par1NBTTagCompound.setByte("shake", (byte) this.throwableShake); + par1NBTTagCompound.setByte("inGround", (byte) (this.inGround ? 1 : 0)); + par1NBTTagCompound.setByte("isArrow", (byte) (this.isArrow() ? 1 : 0)); + par1NBTTagCompound.setTag("direction", this.newDoubleNBTList(new double[]{this.motionX, this.motionY, this.motionZ})); par1NBTTagCompound.setBoolean("canBePickedUp", canBePickedUp); - if ((this.throwerName == null || this.throwerName.length() == 0) && this.thrower != null && this.thrower instanceof EntityPlayer) - { + if ((this.throwerName == null || this.throwerName.length() == 0) && this.thrower != null && this.thrower instanceof EntityPlayer) { this.throwerName = this.thrower.getUniqueID().toString(); } par1NBTTagCompound.setString("ownerName", this.throwerName == null ? "" : this.throwerName); - if (this.getItemDisplay() != null) - { + if (this.getItemDisplay() != null) { par1NBTTagCompound.setTag("Item", this.getItemDisplay().writeToNBT(new NBTTagCompound())); } par1NBTTagCompound.setFloat("damagev2", damage); - par1NBTTagCompound.setInteger("punch", punch); - par1NBTTagCompound.setInteger("size", this.dataWatcher.getWatchableObjectInt(23)); - par1NBTTagCompound.setInteger("velocity", this.dataWatcher.getWatchableObjectInt(25)); - par1NBTTagCompound.setInteger("explosiveRadius", explosiveRadius); - par1NBTTagCompound.setInteger("effectDuration", duration); - par1NBTTagCompound.setBoolean("gravity", this.hasGravity()); - par1NBTTagCompound.setBoolean("accelerate", this.accelerate); - par1NBTTagCompound.setByte("glows", this.dataWatcher.getWatchableObjectByte(24)); - par1NBTTagCompound.setBoolean("explosive", explosive); - par1NBTTagCompound.setInteger("accuracy", accuracy); - par1NBTTagCompound.setInteger("PotionEffect", effect.ordinal()); - par1NBTTagCompound.setString("trail", this.dataWatcher.getWatchableObjectString(22)); - par1NBTTagCompound.setByte("Render3D", this.dataWatcher.getWatchableObjectByte(28)); - par1NBTTagCompound.setByte("Spins", this.dataWatcher.getWatchableObjectByte(29)); - par1NBTTagCompound.setByte("Sticks", this.dataWatcher.getWatchableObjectByte(30)); + par1NBTTagCompound.setInteger("punch", punch); + par1NBTTagCompound.setInteger("size", this.dataWatcher.getWatchableObjectInt(23)); + par1NBTTagCompound.setInteger("velocity", this.dataWatcher.getWatchableObjectInt(25)); + par1NBTTagCompound.setInteger("explosiveRadius", explosiveRadius); + par1NBTTagCompound.setInteger("effectDuration", duration); + par1NBTTagCompound.setBoolean("gravity", this.hasGravity()); + par1NBTTagCompound.setBoolean("accelerate", this.accelerate); + par1NBTTagCompound.setByte("glows", this.dataWatcher.getWatchableObjectByte(24)); + par1NBTTagCompound.setBoolean("explosive", explosive); + par1NBTTagCompound.setInteger("accuracy", accuracy); + par1NBTTagCompound.setInteger("PotionEffect", effect.ordinal()); + par1NBTTagCompound.setString("trail", this.dataWatcher.getWatchableObjectString(22)); + par1NBTTagCompound.setByte("Render3D", this.dataWatcher.getWatchableObjectByte(28)); + par1NBTTagCompound.setByte("Spins", this.dataWatcher.getWatchableObjectByte(29)); + par1NBTTagCompound.setByte("Sticks", this.dataWatcher.getWatchableObjectByte(30)); } /** * (abstract) Protected helper method to read subclass entity data from NBT. */ - public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound) - { + public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound) { this.xTile = par1NBTTagCompound.getShort("xTile"); this.yTile = par1NBTTagCompound.getShort("yTile"); this.zTile = par1NBTTagCompound.getShort("zTile"); @@ -763,29 +681,27 @@ public class EntityProjectile extends EntityThrowable { this.canBePickedUp = par1NBTTagCompound.getBoolean("canBePickedUp"); this.damage = par1NBTTagCompound.getFloat("damagev2"); - this.punch = par1NBTTagCompound.getInteger("punch"); - this.explosiveRadius = par1NBTTagCompound.getInteger("explosiveRadius"); - this.duration = par1NBTTagCompound.getInteger("effectDuration"); - this.accelerate = par1NBTTagCompound.getBoolean("accelerate"); - this.explosive = par1NBTTagCompound.getBoolean("explosive"); - this.accuracy = par1NBTTagCompound.getInteger("accuracy"); - this.effect = EnumPotionType.values()[par1NBTTagCompound.getInteger("PotionEffect") % EnumPotionType.values().length]; + this.punch = par1NBTTagCompound.getInteger("punch"); + this.explosiveRadius = par1NBTTagCompound.getInteger("explosiveRadius"); + this.duration = par1NBTTagCompound.getInteger("effectDuration"); + this.accelerate = par1NBTTagCompound.getBoolean("accelerate"); + this.explosive = par1NBTTagCompound.getBoolean("explosive"); + this.accuracy = par1NBTTagCompound.getInteger("accuracy"); + this.effect = EnumPotionType.values()[par1NBTTagCompound.getInteger("PotionEffect") % EnumPotionType.values().length]; this.dataWatcher.updateObject(22, par1NBTTagCompound.getString("trail")); - this.dataWatcher.updateObject(23, Integer.valueOf(par1NBTTagCompound.getInteger("size"))); - this.dataWatcher.updateObject(24, Byte.valueOf((byte) (par1NBTTagCompound.getBoolean("glows") ? 1 : 0))); - this.dataWatcher.updateObject(25, Integer.valueOf(par1NBTTagCompound.getInteger("velocity"))); - this.dataWatcher.updateObject(26, Byte.valueOf((byte) (par1NBTTagCompound.getBoolean("gravity") ? 1 : 0))); - this.dataWatcher.updateObject(28, Byte.valueOf((byte) (par1NBTTagCompound.getBoolean("Render3D") ? 1 : 0))); - this.dataWatcher.updateObject(29, Byte.valueOf((byte) (par1NBTTagCompound.getBoolean("Spins") ? 1 : 0))); - this.dataWatcher.updateObject(30, Byte.valueOf((byte) (par1NBTTagCompound.getBoolean("Sticks") ? 1 : 0))); + this.dataWatcher.updateObject(23, Integer.valueOf(par1NBTTagCompound.getInteger("size"))); + this.dataWatcher.updateObject(24, Byte.valueOf((byte) (par1NBTTagCompound.getBoolean("glows") ? 1 : 0))); + this.dataWatcher.updateObject(25, Integer.valueOf(par1NBTTagCompound.getInteger("velocity"))); + this.dataWatcher.updateObject(26, Byte.valueOf((byte) (par1NBTTagCompound.getBoolean("gravity") ? 1 : 0))); + this.dataWatcher.updateObject(28, Byte.valueOf((byte) (par1NBTTagCompound.getBoolean("Render3D") ? 1 : 0))); + this.dataWatcher.updateObject(29, Byte.valueOf((byte) (par1NBTTagCompound.getBoolean("Spins") ? 1 : 0))); + this.dataWatcher.updateObject(30, Byte.valueOf((byte) (par1NBTTagCompound.getBoolean("Sticks") ? 1 : 0))); - if (this.throwerName != null && this.throwerName.length() == 0) - { + if (this.throwerName != null && this.throwerName.length() == 0) { this.throwerName = null; } - if (par1NBTTagCompound.hasKey("direction")) - { - NBTTagList nbttaglist = par1NBTTagCompound.getTagList("direction",6); + if (par1NBTTagCompound.hasKey("direction")) { + NBTTagList nbttaglist = par1NBTTagCompound.getTagList("direction", 6); this.motionX = nbttaglist.func_150309_d(0); this.motionY = nbttaglist.func_150309_d(1); this.motionZ = nbttaglist.func_150309_d(2); @@ -797,146 +713,156 @@ public class EntityProjectile extends EntityThrowable { if (item == null) this.setDead(); else - dataWatcher.updateObject(21, item); + dataWatcher.updateObject(21, item); } @Override - public EntityLivingBase getThrower() - { - if(throwerName == null || throwerName.isEmpty()) - return null; - try{ - UUID uuid = UUID.fromString(throwerName); - if (this.thrower == null && uuid != null) - this.thrower = this.worldObj.func_152378_a(uuid); - } - catch(IllegalArgumentException ex){ + public EntityLivingBase getThrower() { + if (throwerName == null || throwerName.isEmpty()) + return null; + try { + UUID uuid = UUID.fromString(throwerName); + if (this.thrower == null && uuid != null) + this.thrower = this.worldObj.func_152378_a(uuid); + } catch (IllegalArgumentException ex) { - } + } return this.thrower; } - private int getPotionEffect(EnumPotionType p) { - switch(p) - { - case Poison : return Potion.poison.id; - case Hunger : return Potion.hunger.id; - case Weakness : return Potion.weakness.id; - case Slowness : return Potion.moveSlowdown.id; - case Nausea : return Potion.confusion.id; - case Blindness : return Potion.blindness.id; - case Wither : return Potion.wither.id; - default : return 0; - } - } + private int getPotionEffect(EnumPotionType p) { + switch (p) { + case Poison: + return Potion.poison.id; + case Hunger: + return Potion.hunger.id; + case Weakness: + return Potion.weakness.id; + case Slowness: + return Potion.moveSlowdown.id; + case Nausea: + return Potion.confusion.id; + case Blindness: + return Potion.blindness.id; + case Wither: + return Potion.wither.id; + default: + return 0; + } + } - private int getPotionColor(EnumPotionType p) { - switch(p) - { - case Poison : return 32660; - case Hunger : return 32660; - case Weakness : return 32696; - case Slowness : return 32698; - case Nausea : return 32732; - case Blindness : return Potion.blindness.id; - case Wither : return 32732; - default : return 0; - } - } + private int getPotionColor(EnumPotionType p) { + switch (p) { + case Poison: + return 32660; + case Hunger: + return 32660; + case Weakness: + return 32696; + case Slowness: + return 32698; + case Nausea: + return 32732; + case Blindness: + return Potion.blindness.id; + case Wither: + return 32732; + default: + return 0; + } + } - public void getStatProperties(DataStats stats) - { - this.damage = stats.pDamage; - this.punch = stats.pImpact; - this.accelerate = stats.pXlr8; - this.explosive = stats.pExplode; - this.explosiveRadius = stats.pArea; - this.effect = stats.pEffect; - this.duration = stats.pDur; - this.amplify = stats.pEffAmp; - this.setParticleEffect(stats.pTrail); - this.dataWatcher.updateObject(23, Integer.valueOf(stats.pSize)); - this.dataWatcher.updateObject(24, Byte.valueOf((byte) (stats.pGlows ? 1 : 0))); - this.setSpeed(stats.pSpeed); - this.setHasGravity(stats.pPhysics); - setIs3D(stats.pRender3D); - this.setRotating(stats.pSpin); - this.setStickInWall(stats.pStick); - } - public void setParticleEffect(EnumParticleType type){ - this.dataWatcher.updateObject(22, type.particleName); - } + public void getStatProperties(DataStats stats) { + this.damage = stats.pDamage; + this.punch = stats.pImpact; + this.accelerate = stats.pXlr8; + this.explosive = stats.pExplode; + this.explosiveRadius = stats.pArea; + this.effect = stats.pEffect; + this.duration = stats.pDur; + this.amplify = stats.pEffAmp; + this.setParticleEffect(stats.pTrail); + this.dataWatcher.updateObject(23, Integer.valueOf(stats.pSize)); + this.dataWatcher.updateObject(24, Byte.valueOf((byte) (stats.pGlows ? 1 : 0))); + this.setSpeed(stats.pSpeed); + this.setHasGravity(stats.pPhysics); + setIs3D(stats.pRender3D); + this.setRotating(stats.pSpin); + this.setStickInWall(stats.pStick); + } - public void setHasGravity(boolean bo){ - this.dataWatcher.updateObject(26, Byte.valueOf((byte) (bo ? 1 : 0))); - } - public void setIs3D(boolean bo){ - this.dataWatcher.updateObject(28, Byte.valueOf((byte) (bo ? 1 : 0))); - } - public void setStickInWall(boolean bo){ - this.dataWatcher.updateObject(30, Byte.valueOf((byte) (bo ? 1 : 0))); - } + public void setParticleEffect(EnumParticleType type) { + this.dataWatcher.updateObject(22, type.particleName); + } - public ItemStack getItemDisplay() { - return dataWatcher.getWatchableObjectItemStack(21); - } + public void setHasGravity(boolean bo) { + this.dataWatcher.updateObject(26, Byte.valueOf((byte) (bo ? 1 : 0))); + } - public float getBrightness(float par1) - { + public void setIs3D(boolean bo) { + this.dataWatcher.updateObject(28, Byte.valueOf((byte) (bo ? 1 : 0))); + } + + public void setStickInWall(boolean bo) { + this.dataWatcher.updateObject(30, Byte.valueOf((byte) (bo ? 1 : 0))); + } + + public ItemStack getItemDisplay() { + return dataWatcher.getWatchableObjectItemStack(21); + } + + public float getBrightness(float par1) { return this.dataWatcher.getWatchableObjectByte(24) == 1 ? 1.0F : super.getBrightness(par1); } @SideOnly(Side.CLIENT) - public int getBrightnessForRender(float par1) - { + public int getBrightnessForRender(float par1) { return this.dataWatcher.getWatchableObjectByte(24) == 1 ? 15728880 : super.getBrightnessForRender(par1); } public boolean hasGravity() { - return this.dataWatcher.getWatchableObjectByte(26) == 1; + return this.dataWatcher.getWatchableObjectByte(26) == 1; } public void setSpeed(int speed) { - this.dataWatcher.updateObject(25, speed); + this.dataWatcher.updateObject(25, speed); } public float getSpeed() { - return this.dataWatcher.getWatchableObjectInt(25) / 10.0F; + return this.dataWatcher.getWatchableObjectInt(25) / 10.0F; } public boolean isArrow() { - return this.dataWatcher.getWatchableObjectByte(27) == 1; + return this.dataWatcher.getWatchableObjectByte(27) == 1; } - public void setRotating(boolean bo) { - dataWatcher.updateObject(29, Byte.valueOf((byte) (bo ? 1 : 0))); - } + public void setRotating(boolean bo) { + dataWatcher.updateObject(29, Byte.valueOf((byte) (bo ? 1 : 0))); + } public boolean isRotating() { - return this.dataWatcher.getWatchableObjectByte(29) == 1; + return this.dataWatcher.getWatchableObjectByte(29) == 1; } public boolean glows() { - return this.dataWatcher.getWatchableObjectByte(24) == 1; + return this.dataWatcher.getWatchableObjectByte(24) == 1; } public boolean is3D() { - return this.dataWatcher.getWatchableObjectByte(28) == 1 || isBlock(); + return this.dataWatcher.getWatchableObjectByte(28) == 1 || isBlock(); } public boolean sticksToWalls() { - return this.is3D() && this.dataWatcher.getWatchableObjectByte(30) == 1; + return this.is3D() && this.dataWatcher.getWatchableObjectByte(30) == 1; } @Override - public void onCollideWithPlayer(EntityPlayer par1EntityPlayer) - { + public void onCollideWithPlayer(EntityPlayer par1EntityPlayer) { if (this.worldObj.isRemote || !canBePickedUp || !this.inGround || this.arrowShake > 0) - return; - if (par1EntityPlayer.inventory.addItemStackToInventory(getItemDisplay())) - { - inGround = false; + return; + if (par1EntityPlayer.inventory.addItemStackToInventory(getItemDisplay())) { + inGround = false; this.playSound("random.pop", 0.2F, ((this.rand.nextFloat() - this.rand.nextFloat()) * 0.7F + 1.0F) * 2.0F); par1EntityPlayer.onItemPickup(this, 1); this.setDead(); @@ -945,16 +871,14 @@ public class EntityProjectile extends EntityThrowable { } @Override - protected boolean canTriggerWalking() - { + protected boolean canTriggerWalking() { return false; } @Override - public IChatComponent func_145748_c_() - { - if(getItemDisplay() != null) - return new ChatComponentTranslation(getItemDisplay().getDisplayName()); - return super.func_145748_c_(); + public IChatComponent func_145748_c_() { + if (getItemDisplay() != null) + return new ChatComponentTranslation(getItemDisplay().getDisplayName()); + return super.func_145748_c_(); } } diff --git a/src/main/java/noppes/npcs/entity/data/DataSkinOverlays.java b/src/main/java/noppes/npcs/entity/data/DataSkinOverlays.java index 92b408696..38f48c944 100644 --- a/src/main/java/noppes/npcs/entity/data/DataSkinOverlays.java +++ b/src/main/java/noppes/npcs/entity/data/DataSkinOverlays.java @@ -23,8 +23,8 @@ public class DataSkinOverlays implements IOverlayHandler { } public void readFromNBT(NBTTagCompound nbtTagCompound) { - HashMap skinOverlays = new HashMap<>(); - NBTTagList skinOverlayList = nbtTagCompound.getTagList("SkinOverlayData",10); + HashMap skinOverlays = new HashMap<>(); + NBTTagList skinOverlayList = nbtTagCompound.getTagList("SkinOverlayData", 10); for (int i = 0; i < skinOverlayList.tagCount(); i++) { int tagID = skinOverlayList.getCompoundTagAt(i).getInteger("SkinOverlayID"); SkinOverlay skinOverlay = (SkinOverlay) SkinOverlay.overlayFromNBT(skinOverlayList.getCompoundTagAt(i)); @@ -38,14 +38,14 @@ public class DataSkinOverlays implements IOverlayHandler { public NBTTagCompound writeToNBT(NBTTagCompound nbttagcompound) { NBTTagList overlayList = new NBTTagList(); if (!this.overlayList.isEmpty()) { - for (Map.Entry overlayData : this.overlayList.entrySet()) { + for (Map.Entry overlayData : this.overlayList.entrySet()) { NBTTagCompound compound = new NBTTagCompound(); compound.setInteger("SkinOverlayID", overlayData.getKey()); compound = ((SkinOverlay) overlayData.getValue()).writeToNBT(compound); overlayList.appendTag(compound); } } - nbttagcompound.setTag("SkinOverlayData",overlayList); + nbttagcompound.setTag("SkinOverlayData", overlayList); return nbttagcompound; } @@ -85,7 +85,9 @@ public class DataSkinOverlays implements IOverlayHandler { return removed; } - public int size() { return this.overlayList.size(); } + public int size() { + return this.overlayList.size(); + } public void clear() { this.overlayList.clear(); diff --git a/src/main/java/noppes/npcs/entity/data/DataTimers.java b/src/main/java/noppes/npcs/entity/data/DataTimers.java index 67fe8b952..9f555cdca 100644 --- a/src/main/java/noppes/npcs/entity/data/DataTimers.java +++ b/src/main/java/noppes/npcs/entity/data/DataTimers.java @@ -31,7 +31,7 @@ public class DataTimers implements ITimers { } public void start(int id, int ticks, boolean repeat) { - if(this.timers.containsKey(id)) { + if (this.timers.containsKey(id)) { throw new CustomNPCsException("There is already a timer with id: " + id); } else { this.timers.put(id, new DataTimers.Timer(id, ticks, repeat)); @@ -56,46 +56,46 @@ public class DataTimers implements ITimers { timer.ticks = 0; } - public int ticks(int id){ + public int ticks(int id) { this.timerException(id); return this.timers.get(id).ticks; } - public void setTicks(int id, int ticks){ + public void setTicks(int id, int ticks) { this.timerException(id); DataTimers.Timer timer = this.timers.get(id); - if(ticks < 0) + if (ticks < 0) ticks = 0; - if(ticks > timer.timerTicks) + if (ticks > timer.timerTicks) ticks = timer.timerTicks; timer.ticks = ticks; } - public int maxTicks(int id){ + public int maxTicks(int id) { this.timerException(id); return this.timers.get(id).timerTicks; } - public void setMaxTicks(int id, int maxTicks){ + public void setMaxTicks(int id, int maxTicks) { this.timerException(id); DataTimers.Timer timer = this.timers.get(id); - if(maxTicks < 0) + if (maxTicks < 0) maxTicks = 0; - if(timer.ticks > maxTicks) + if (timer.ticks > maxTicks) timer.ticks = maxTicks; timer.timerTicks = maxTicks; } - public boolean repeats(int id){ + public boolean repeats(int id) { this.timerException(id); return this.timers.get(id).repeat; } - public void setRepeats(int id, boolean repeat){ + public void setRepeats(int id, boolean repeat) { this.timerException(id); this.timers.get(id).repeat = repeat; } @@ -104,8 +104,8 @@ public class DataTimers implements ITimers { NBTTagList list = new NBTTagList(); Iterator var3 = this.timers.values().iterator(); - while(var3.hasNext()) { - DataTimers.Timer timer = (DataTimers.Timer)var3.next(); + while (var3.hasNext()) { + DataTimers.Timer timer = (DataTimers.Timer) var3.next(); NBTTagCompound c = new NBTTagCompound(); c.setInteger("ID", timer.id); c.setInteger("TimerTicks", timer.timerTicks); @@ -127,7 +127,7 @@ public class DataTimers implements ITimers { HashMap timers = new HashMap<>(); NBTTagList list = compound.getTagList("NpcsTimers", 10); - if(list != null) { + if (list != null) { for (int i = 0; i < list.tagCount(); ++i) { NBTTagCompound c = list.getCompoundTagAt(i); DataTimers.Timer t = new DataTimers.Timer(c.getInteger("ID"), c.getInteger("TimerTicks"), c.getBoolean("Repeat")); @@ -152,7 +152,9 @@ public class DataTimers implements ITimers { this.timers = new HashMap<>(); } - public int size() { return this.timers.size(); } + public int size() { + return this.timers.size(); + } class Timer { public int id; @@ -168,8 +170,8 @@ public class DataTimers implements ITimers { } public void update() { - if(this.ticks-- <= 0) { - if(this.repeat) { + if (this.ticks-- <= 0) { + if (this.repeat) { this.ticks = this.timerTicks; } else { DataTimers.this.stop(this.id); @@ -177,13 +179,11 @@ public class DataTimers implements ITimers { Object ob = DataTimers.this.parent; if (ob instanceof EntityNPCInterface) { - EventHooks.onNPCTimer((EntityNPCInterface)ob, this.id); - } - else if(ob instanceof PlayerData) { - EventHooks.onPlayerTimer((PlayerData)ob, this.id); - } - else if(ob instanceof TileScripted) { - EventHooks.onScriptBlockTimer((TileScripted)ob, this.id); + EventHooks.onNPCTimer((EntityNPCInterface) ob, this.id); + } else if (ob instanceof PlayerData) { + EventHooks.onPlayerTimer((PlayerData) ob, this.id); + } else if (ob instanceof TileScripted) { + EventHooks.onScriptBlockTimer((TileScripted) ob, this.id); } } } diff --git a/src/main/java/noppes/npcs/entity/data/ModelData.java b/src/main/java/noppes/npcs/entity/data/ModelData.java index bd0f13a3c..95708e553 100644 --- a/src/main/java/noppes/npcs/entity/data/ModelData.java +++ b/src/main/java/noppes/npcs/entity/data/ModelData.java @@ -6,40 +6,40 @@ import net.minecraft.world.World; import noppes.npcs.compat.PixelmonHelper; import noppes.npcs.entity.EntityNPCInterface; -public class ModelData extends ModelDataShared{ - - public EntityLivingBase getEntity(EntityNPCInterface npc){ - if(entityClass == null) - return null; - if(entity == null){ - try { - entity = entityClass.getConstructor(new Class[] {World.class}).newInstance(new Object[] {npc.worldObj}); +public class ModelData extends ModelDataShared { - entity.readEntityFromNBT(extra); - - if(entity instanceof EntityLiving){ - EntityLiving living = (EntityLiving)entity; - living.setCurrentItemOrArmor(0, npc.getHeldItem() != null?npc.getHeldItem():npc.getOffHand()); - living.setCurrentItemOrArmor(1, npc.inventory.armorItemInSlot(3)); - living.setCurrentItemOrArmor(2, npc.inventory.armorItemInSlot(2)); - living.setCurrentItemOrArmor(3, npc.inventory.armorItemInSlot(1)); - living.setCurrentItemOrArmor(4, npc.inventory.armorItemInSlot(0)); - } - if(PixelmonHelper.isPixelmon(entity) && npc.worldObj.isRemote){ - if(extra.hasKey("Name")) - PixelmonHelper.setName(entity, extra.getString("Name")); - else - PixelmonHelper.setName(entity, "Abra"); - } - } catch (Exception e) { - } - } - return entity; - } - - public ModelData copy(){ - ModelData data = new ModelData(); - data.readFromNBT(this.writeToNBT()); - return data; - } + public EntityLivingBase getEntity(EntityNPCInterface npc) { + if (entityClass == null) + return null; + if (entity == null) { + try { + entity = entityClass.getConstructor(new Class[]{World.class}).newInstance(new Object[]{npc.worldObj}); + + entity.readEntityFromNBT(extra); + + if (entity instanceof EntityLiving) { + EntityLiving living = (EntityLiving) entity; + living.setCurrentItemOrArmor(0, npc.getHeldItem() != null ? npc.getHeldItem() : npc.getOffHand()); + living.setCurrentItemOrArmor(1, npc.inventory.armorItemInSlot(3)); + living.setCurrentItemOrArmor(2, npc.inventory.armorItemInSlot(2)); + living.setCurrentItemOrArmor(3, npc.inventory.armorItemInSlot(1)); + living.setCurrentItemOrArmor(4, npc.inventory.armorItemInSlot(0)); + } + if (PixelmonHelper.isPixelmon(entity) && npc.worldObj.isRemote) { + if (extra.hasKey("Name")) + PixelmonHelper.setName(entity, extra.getString("Name")); + else + PixelmonHelper.setName(entity, "Abra"); + } + } catch (Exception e) { + } + } + return entity; + } + + public ModelData copy() { + ModelData data = new ModelData(); + data.readFromNBT(this.writeToNBT()); + return data; + } } diff --git a/src/main/java/noppes/npcs/entity/data/ModelDataShared.java b/src/main/java/noppes/npcs/entity/data/ModelDataShared.java index f7db2aa52..357312f1f 100644 --- a/src/main/java/noppes/npcs/entity/data/ModelDataShared.java +++ b/src/main/java/noppes/npcs/entity/data/ModelDataShared.java @@ -13,403 +13,404 @@ import java.util.HashMap; public class ModelDataShared implements IModelData { - public ModelScale modelScale = new ModelScale(); + public ModelScale modelScale = new ModelScale(); - public boolean enableRotation = false; - public ModelRotate rotation = new ModelRotate(); + public boolean enableRotation = false; + public ModelRotate rotation = new ModelRotate(); - public ModelPartData legParts = new ModelPartData(); - - public Class entityClass; - public EntityLivingBase entity; - - public NBTTagCompound extra = new NBTTagCompound(); - - private HashMap parts = new HashMap(); - public byte breasts = 0; + public ModelPartData legParts = new ModelPartData(); - public byte headwear = 2; - public byte bodywear = 0; - // Hide Arm/Legwear [0: None, 1: Both, 2: Right, 3: Left], - public byte armwear = 0; - public byte legwear = 0; + public Class entityClass; + public EntityLivingBase entity; - // Solid or normal arm/legwear [0: None, 1: Both, 2: Right, 3: Left] - public byte solidArmwear = 0; - public byte solidLegwear = 0; + public NBTTagCompound extra = new NBTTagCompound(); - // Hide Body Parts [0: None, 1: Both, 2: Right, 3: Left], - public byte hideHead = 0; - public byte hideBody = 0; - public byte hideArms = 0; - public byte hideLegs = 0; + private HashMap parts = new HashMap(); + public byte breasts = 0; - public NBTTagCompound writeToNBT(){ - NBTTagCompound compound = new NBTTagCompound(); + public byte headwear = 2; + public byte bodywear = 0; + // Hide Arm/Legwear [0: None, 1: Both, 2: Right, 3: Left], + public byte armwear = 0; + public byte legwear = 0; - if(entityClass != null) - compound.setString("EntityClass", entityClass.getCanonicalName()); + // Solid or normal arm/legwear [0: None, 1: Both, 2: Right, 3: Left] + public byte solidArmwear = 0; + public byte solidLegwear = 0; - compound = this.modelScale.writeToNBT(compound); + // Hide Body Parts [0: None, 1: Both, 2: Right, 3: Left], + public byte hideHead = 0; + public byte hideBody = 0; + public byte hideArms = 0; + public byte hideLegs = 0; - compound.setTag("LegParts", legParts.writeToNBT()); + public NBTTagCompound writeToNBT() { + NBTTagCompound compound = new NBTTagCompound(); - compound.setByte("Headwear", headwear); - compound.setByte("Bodywear", bodywear); - compound.setByte("Armwear", armwear); - compound.setByte("Legwear", legwear); + if (entityClass != null) + compound.setString("EntityClass", entityClass.getCanonicalName()); - compound.setByte("SolidArmwear", solidArmwear); - compound.setByte("SolidLegwear", solidLegwear); + compound = this.modelScale.writeToNBT(compound); - compound.setByte("hideHead", hideHead); - compound.setByte("hideBody", hideBody); - compound.setByte("hideArms", hideArms); - compound.setByte("hideLegs", hideLegs); + compound.setTag("LegParts", legParts.writeToNBT()); - compound.setBoolean("EnableRotation", enableRotation); - if(enableRotation) - compound.setTag("ModelRotation", rotation.writeToNBT()); + compound.setByte("Headwear", headwear); + compound.setByte("Bodywear", bodywear); + compound.setByte("Armwear", armwear); + compound.setByte("Legwear", legwear); - compound.setByte("Breasts", breasts); - compound.setTag("ExtraData", extra); + compound.setByte("SolidArmwear", solidArmwear); + compound.setByte("SolidLegwear", solidLegwear); - NBTTagList list = new NBTTagList(); - for(String name : parts.keySet()){ - NBTTagCompound item = parts.get(name).writeToNBT(); - item.setString("PartName", name); - list.appendTag(item); - } - compound.setTag("Parts", list); - - return compound; - } + compound.setByte("hideHead", hideHead); + compound.setByte("hideBody", hideBody); + compound.setByte("hideArms", hideArms); + compound.setByte("hideLegs", hideLegs); - public void readFromNBT(NBTTagCompound compound){ - setEntity(compound.getString("EntityClass")); + compound.setBoolean("EnableRotation", enableRotation); + if (enableRotation) + compound.setTag("ModelRotation", rotation.writeToNBT()); - this.modelScale.readFromNBT(compound); + compound.setByte("Breasts", breasts); + compound.setTag("ExtraData", extra); - legParts.readFromNBT(compound.getCompoundTag("LegParts")); + NBTTagList list = new NBTTagList(); + for (String name : parts.keySet()) { + NBTTagCompound item = parts.get(name).writeToNBT(); + item.setString("PartName", name); + list.appendTag(item); + } + compound.setTag("Parts", list); - headwear = compound.getByte("Headwear"); - bodywear = compound.getByte("Bodywear"); - armwear = compound.getByte("Armwear"); - legwear = compound.getByte("Legwear"); + return compound; + } - solidArmwear = compound.getByte("SolidArmwear"); - solidLegwear = compound.getByte("SolidLegwear"); + public void readFromNBT(NBTTagCompound compound) { + setEntity(compound.getString("EntityClass")); - hideHead = compound.getByte("hideHead"); - hideBody = compound.getByte("hideBody"); - hideArms = compound.getByte("hideArms"); - hideLegs = compound.getByte("hideLegs"); + this.modelScale.readFromNBT(compound); - enableRotation = compound.getBoolean("EnableRotation"); - if(enableRotation) - rotation.readFromNBT(compound.getCompoundTag("ModelRotation")); + legParts.readFromNBT(compound.getCompoundTag("LegParts")); - breasts = compound.getByte("Breasts"); - extra = compound.getCompoundTag("ExtraData"); + headwear = compound.getByte("Headwear"); + bodywear = compound.getByte("Bodywear"); + armwear = compound.getByte("Armwear"); + legwear = compound.getByte("Legwear"); - HashMap parts = new HashMap(); - NBTTagList list = compound.getTagList("Parts", 10); - for (int i = 0; i < list.tagCount(); i++) { - NBTTagCompound item = list.getCompoundTagAt(i); - ModelPartData part = new ModelPartData(); - part.readFromNBT(item); - parts.put(item.getString("PartName"), part); - } - this.parts = parts; - - } - - public void setEntityClass(Class entityClass){ - this.entityClass = entityClass; - entity = null; - extra = new NBTTagCompound(); - if(entityClass == EntityHorse.class) - extra.setInteger("Type", -1); - } - - public Class getEntityClass(){ - return entityClass; - } + solidArmwear = compound.getByte("SolidArmwear"); + solidLegwear = compound.getByte("SolidLegwear"); - public float offsetY() { - if(entity == null) - return -getBodyY(); - return entity.height - 1.8f; - } + hideHead = compound.getByte("hideHead"); + hideBody = compound.getByte("hideBody"); + hideArms = compound.getByte("hideArms"); + hideLegs = compound.getByte("hideLegs"); - public void clearEntity() { - entity = null; - } - - - public ModelPartData getPartData(String type){ - return parts.get(type); - } + enableRotation = compound.getBoolean("EnableRotation"); + if (enableRotation) + rotation.readFromNBT(compound.getCompoundTag("ModelRotation")); - public void removePart(String type) { - parts.remove(type); - } + breasts = compound.getByte("Breasts"); + extra = compound.getCompoundTag("ExtraData"); - public ModelPartData getOrCreatePart(String type) { - ModelPartData part = parts.get(type); - if(part == null) - parts.put(type, part = new ModelPartData()); - return part; - } - - public float getBodyY(){ - if(legParts.type == 3) - return (0.9f - modelScale.body.scaleY) * 0.75f + getLegsY(); - if(legParts.type == 3) - return (0.5f - modelScale.body.scaleY) * 0.75f + getLegsY(); - return (1 - modelScale.body.scaleY) * 0.75f + getLegsY(); - } + HashMap parts = new HashMap(); + NBTTagList list = compound.getTagList("Parts", 10); + for (int i = 0; i < list.tagCount(); i++) { + NBTTagCompound item = list.getCompoundTagAt(i); + ModelPartData part = new ModelPartData(); + part.readFromNBT(item); + parts.put(item.getString("PartName"), part); + } + this.parts = parts; - public float getLegsY() { - if(legParts.type == 3) - return (0.87f - modelScale.legs.scaleY); - return (1 - modelScale.legs.scaleY) * 0.75f; - } + } - //0 - hidden, 1 - 2d, 2 - 3d - public void headWear(byte config) { - headwear = ValueUtil.clamp(config, (byte)0, (byte)2); - } + public void setEntityClass(Class entityClass) { + this.entityClass = entityClass; + entity = null; + extra = new NBTTagCompound(); + if (entityClass == EntityHorse.class) + extra.setInteger("Type", -1); + } - public byte headWear() { - return this.headwear; - } + public Class getEntityClass() { + return entityClass; + } - //0 - hidden, 1 - 2d, 2 - 3d - public void bodyWear(byte config) { - bodywear = ValueUtil.clamp(config, (byte)0, (byte)2); - } + public float offsetY() { + if (entity == null) + return -getBodyY(); + return entity.height - 1.8f; + } - public byte bodyWear() { - return this.bodywear; - } + public void clearEntity() { + entity = null; + } - //0 - hidden, 1 - 2d, 2 - 3d - public void rightArmWear(byte config) { - config = ValueUtil.clamp(config, (byte)0, (byte)2); - // Hide Arm/Legwear [0: None, 1: Both, 2: Right, 3: Left], - if (config == 1 || config == 2) { - if (armwear == 0) - armwear = 2; - else if (armwear == 3) - armwear = 1; - } else { - if (armwear == 1) - armwear = 3; - else if (armwear == 2) - armwear = 0; - } + public ModelPartData getPartData(String type) { + return parts.get(type); + } - // Solid or normal arm/legwear [0: None, 1: Both, 2: Right, 3: Left] - if (config == 1) { - solidArmwear = 0; - } else if (config == 2) { - if (solidArmwear == 0) { - solidArmwear = 2; - } else if (solidArmwear == 3) { - solidArmwear = 1; - } - } - } + public void removePart(String type) { + parts.remove(type); + } - public byte rightArmWear() { - if (armwear == 0 || armwear == 3) { - return 0; - } else if (solidArmwear == 1 || solidArmwear == 2) { - return 2; - } else { - return 1; - } - } + public ModelPartData getOrCreatePart(String type) { + ModelPartData part = parts.get(type); + if (part == null) + parts.put(type, part = new ModelPartData()); + return part; + } - //0 - hidden, 1 - 2d, 2 - 3d - public void leftArmWear(byte config) { - config = ValueUtil.clamp(config, (byte)0, (byte)2); + public float getBodyY() { + if (legParts.type == 3) + return (0.9f - modelScale.body.scaleY) * 0.75f + getLegsY(); + if (legParts.type == 3) + return (0.5f - modelScale.body.scaleY) * 0.75f + getLegsY(); + return (1 - modelScale.body.scaleY) * 0.75f + getLegsY(); + } - // Hide Arm/Legwear [0: None, 1: Both, 2: Right, 3: Left], - if (config == 1 || config == 2) { - if (armwear == 0) - armwear = 3; - else if (armwear == 2) - armwear = 1; - } else { - if (armwear == 1) - armwear = 2; - else if (armwear == 3) - armwear = 0; - } + public float getLegsY() { + if (legParts.type == 3) + return (0.87f - modelScale.legs.scaleY); + return (1 - modelScale.legs.scaleY) * 0.75f; + } - // Solid or normal arm/legwear [0: None, 1: Both, 2: Right, 3: Left] - if (config == 1) { - solidArmwear = 0; - } else if (config == 2) { - if (solidArmwear == 0) { - solidArmwear = 3; - } else if (solidArmwear == 2) { - solidArmwear = 1; - } - } - } + //0 - hidden, 1 - 2d, 2 - 3d + public void headWear(byte config) { + headwear = ValueUtil.clamp(config, (byte) 0, (byte) 2); + } - public byte leftArmWear() { - if (armwear == 0 || armwear == 2) { - return 0; - } else if (solidArmwear == 1 || solidArmwear == 3) { - return 2; - } else { - return 1; - } - } + public byte headWear() { + return this.headwear; + } - public void rightLegWear(byte config) { - config = ValueUtil.clamp(config, (byte)0, (byte)2); + //0 - hidden, 1 - 2d, 2 - 3d + public void bodyWear(byte config) { + bodywear = ValueUtil.clamp(config, (byte) 0, (byte) 2); + } - // Hide Arm/Legwear [0: None, 1: Both, 2: Right, 3: Left], - if (config == 1 || config == 2) { - if (legwear == 0) - legwear = 2; - else if (legwear == 3) - legwear = 1; - } else { - if (legwear == 1) - legwear = 3; - else if (legwear == 2) - legwear = 0; - } + public byte bodyWear() { + return this.bodywear; + } - // Solid or normal arm/legwear [0: None, 1: Both, 2: Right, 3: Left] - if (config == 1) { - solidLegwear = 0; - } else if (config == 2) { - if (solidLegwear == 0) { - solidLegwear = 2; - } else if (solidLegwear == 3) { - solidLegwear = 1; - } - } - } + //0 - hidden, 1 - 2d, 2 - 3d + public void rightArmWear(byte config) { + config = ValueUtil.clamp(config, (byte) 0, (byte) 2); - public byte rightLegWear() { - if (legwear == 0 || legwear == 3) { - return 0; - } else if (solidLegwear == 1 || solidLegwear == 2) { - return 2; - } else { - return 1; - } - } + // Hide Arm/Legwear [0: None, 1: Both, 2: Right, 3: Left], + if (config == 1 || config == 2) { + if (armwear == 0) + armwear = 2; + else if (armwear == 3) + armwear = 1; + } else { + if (armwear == 1) + armwear = 3; + else if (armwear == 2) + armwear = 0; + } - public void leftLegWear(byte config) { - config = ValueUtil.clamp(config, (byte)0, (byte)2); + // Solid or normal arm/legwear [0: None, 1: Both, 2: Right, 3: Left] + if (config == 1) { + solidArmwear = 0; + } else if (config == 2) { + if (solidArmwear == 0) { + solidArmwear = 2; + } else if (solidArmwear == 3) { + solidArmwear = 1; + } + } + } - // Hide Arm/Legwear [0: None, 1: Both, 2: Right, 3: Left], - if (config == 1 || config == 2) { - if (legwear == 0) - legwear = 3; - else if (legwear == 2) - legwear = 1; - } else { - if (legwear == 1) - legwear = 2; - else if (legwear == 3) - legwear = 0; - } + public byte rightArmWear() { + if (armwear == 0 || armwear == 3) { + return 0; + } else if (solidArmwear == 1 || solidArmwear == 2) { + return 2; + } else { + return 1; + } + } - // Solid or normal arm/legwear [0: None, 1: Both, 2: Right, 3: Left] - if (config == 1) { - solidLegwear = 0; - } else if (config == 2) { - if (solidLegwear == 0) { - solidLegwear = 3; - } else if (solidLegwear == 2) { - solidLegwear = 1; - } - } - } + //0 - hidden, 1 - 2d, 2 - 3d + public void leftArmWear(byte config) { + config = ValueUtil.clamp(config, (byte) 0, (byte) 2); - public byte leftLegWear() { - if (legwear == 0 || legwear == 2) { - return 0; - } else if (solidLegwear == 1 || solidLegwear == 3) { - return 2; - } else { - return 1; - } - } + // Hide Arm/Legwear [0: None, 1: Both, 2: Right, 3: Left], + if (config == 1 || config == 2) { + if (armwear == 0) + armwear = 3; + else if (armwear == 2) + armwear = 1; + } else { + if (armwear == 1) + armwear = 2; + else if (armwear == 3) + armwear = 0; + } - public void hidePart(int part, byte hide) { - part = ValueUtil.clamp(part,0,3); - hide = part > 1 ? ValueUtil.clamp(hide,(byte) 0,(byte) 3) : ValueUtil.clamp(hide,(byte) 0,(byte) 1); - switch (part) { - case 0: - this.hideHead = hide; - break; - case 1: - this.hideBody = hide; - break; - case 2: - this.hideArms = hide; - break; - case 3: - this.hideLegs = hide; - break; - } - } + // Solid or normal arm/legwear [0: None, 1: Both, 2: Right, 3: Left] + if (config == 1) { + solidArmwear = 0; + } else if (config == 2) { + if (solidArmwear == 0) { + solidArmwear = 3; + } else if (solidArmwear == 2) { + solidArmwear = 1; + } + } + } - public int hidden(int part) { - part = ValueUtil.clamp(part,0,3); - switch (part) { - case 0: - return this.hideHead; - case 1: - return this.hideBody; - case 2: - return this.hideArms; - case 3: - return this.hideLegs; - } - return 0; - } + public byte leftArmWear() { + if (armwear == 0 || armwear == 2) { + return 0; + } else if (solidArmwear == 1 || solidArmwear == 3) { + return 2; + } else { + return 1; + } + } - public void enableRotation(boolean enableRotation) { - this.enableRotation = enableRotation; - } + public void rightLegWear(byte config) { + config = ValueUtil.clamp(config, (byte) 0, (byte) 2); - public boolean enableRotation() { - return this.enableRotation; - } + // Hide Arm/Legwear [0: None, 1: Both, 2: Right, 3: Left], + if (config == 1 || config == 2) { + if (legwear == 0) + legwear = 2; + else if (legwear == 3) + legwear = 1; + } else { + if (legwear == 1) + legwear = 3; + else if (legwear == 2) + legwear = 0; + } - public IModelRotate getRotation() { - return this.rotation; - } + // Solid or normal arm/legwear [0: None, 1: Both, 2: Right, 3: Left] + if (config == 1) { + solidLegwear = 0; + } else if (config == 2) { + if (solidLegwear == 0) { + solidLegwear = 2; + } else if (solidLegwear == 3) { + solidLegwear = 1; + } + } + } - public IModelScale getScale() { - return this.modelScale; - } + public byte rightLegWear() { + if (legwear == 0 || legwear == 3) { + return 0; + } else if (solidLegwear == 1 || solidLegwear == 2) { + return 2; + } else { + return 1; + } + } - public void setEntity(String string) { - entityClass = null; - entity = null; - try { - Class cls = Class.forName(string); - if (EntityLivingBase.class.isAssignableFrom(cls)) - entityClass = cls.asSubclass(EntityLivingBase.class); + public void leftLegWear(byte config) { + config = ValueUtil.clamp(config, (byte) 0, (byte) 2); - } catch (ClassNotFoundException ignored) {} - } + // Hide Arm/Legwear [0: None, 1: Both, 2: Right, 3: Left], + if (config == 1 || config == 2) { + if (legwear == 0) + legwear = 3; + else if (legwear == 2) + legwear = 1; + } else { + if (legwear == 1) + legwear = 2; + else if (legwear == 3) + legwear = 0; + } - public String getEntity() { - return entityClass == null ? null : entityClass.getName(); - } + // Solid or normal arm/legwear [0: None, 1: Both, 2: Right, 3: Left] + if (config == 1) { + solidLegwear = 0; + } else if (config == 2) { + if (solidLegwear == 0) { + solidLegwear = 3; + } else if (solidLegwear == 2) { + solidLegwear = 1; + } + } + } + + public byte leftLegWear() { + if (legwear == 0 || legwear == 2) { + return 0; + } else if (solidLegwear == 1 || solidLegwear == 3) { + return 2; + } else { + return 1; + } + } + + public void hidePart(int part, byte hide) { + part = ValueUtil.clamp(part, 0, 3); + hide = part > 1 ? ValueUtil.clamp(hide, (byte) 0, (byte) 3) : ValueUtil.clamp(hide, (byte) 0, (byte) 1); + switch (part) { + case 0: + this.hideHead = hide; + break; + case 1: + this.hideBody = hide; + break; + case 2: + this.hideArms = hide; + break; + case 3: + this.hideLegs = hide; + break; + } + } + + public int hidden(int part) { + part = ValueUtil.clamp(part, 0, 3); + switch (part) { + case 0: + return this.hideHead; + case 1: + return this.hideBody; + case 2: + return this.hideArms; + case 3: + return this.hideLegs; + } + return 0; + } + + public void enableRotation(boolean enableRotation) { + this.enableRotation = enableRotation; + } + + public boolean enableRotation() { + return this.enableRotation; + } + + public IModelRotate getRotation() { + return this.rotation; + } + + public IModelScale getScale() { + return this.modelScale; + } + + public void setEntity(String string) { + entityClass = null; + entity = null; + try { + Class cls = Class.forName(string); + if (EntityLivingBase.class.isAssignableFrom(cls)) + entityClass = cls.asSubclass(EntityLivingBase.class); + + } catch (ClassNotFoundException ignored) { + } + } + + public String getEntity() { + return entityClass == null ? null : entityClass.getName(); + } } diff --git a/src/main/java/noppes/npcs/entity/data/ModelPartData.java b/src/main/java/noppes/npcs/entity/data/ModelPartData.java index ddc17323e..53a9a5b19 100644 --- a/src/main/java/noppes/npcs/entity/data/ModelPartData.java +++ b/src/main/java/noppes/npcs/entity/data/ModelPartData.java @@ -4,76 +4,75 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.ResourceLocation; public class ModelPartData { - public int color = 0xFFFFFF; - public String texture; - public byte type = 0; + public int color = 0xFFFFFF; + public String texture; + public byte type = 0; public byte pattern = 0; - public boolean playerTexture; + public boolean playerTexture; - private ResourceLocation location; + private ResourceLocation location; - public ModelPartData(){ - playerTexture = true; - } + public ModelPartData() { + playerTexture = true; + } - public ModelPartData(String texture) { - this.texture = texture; - playerTexture = false; - } + public ModelPartData(String texture) { + this.texture = texture; + playerTexture = false; + } - public NBTTagCompound writeToNBT(){ - NBTTagCompound compound = new NBTTagCompound(); - compound.setByte("Type", type); - compound.setInteger("Color", color); + public NBTTagCompound writeToNBT() { + NBTTagCompound compound = new NBTTagCompound(); + compound.setByte("Type", type); + compound.setInteger("Color", color); compound.setByte("Pattern", pattern); - if(texture != null && !texture.isEmpty()) { - compound.setString("Texture", texture); - } - compound.setBoolean("PlayerTexture", playerTexture); - return compound; - } + if (texture != null && !texture.isEmpty()) { + compound.setString("Texture", texture); + } + compound.setBoolean("PlayerTexture", playerTexture); + return compound; + } - public void readFromNBT(NBTTagCompound compound){ - type = compound.getByte("Type"); - color = compound.getInteger("Color"); - texture = compound.getString("Texture"); + public void readFromNBT(NBTTagCompound compound) { + type = compound.getByte("Type"); + color = compound.getInteger("Color"); + texture = compound.getString("Texture"); pattern = compound.getByte("Pattern"); - playerTexture = compound.getBoolean("PlayerTexture"); - location = null; - } + playerTexture = compound.getBoolean("PlayerTexture"); + location = null; + } - public ResourceLocation getResource(){ - if(texture.isEmpty()) - return null; - if(location != null) - return location; - location = new ResourceLocation(texture); - return location; - } + public ResourceLocation getResource() { + if (texture.isEmpty()) + return null; + if (location != null) + return location; + location = new ResourceLocation(texture); + return location; + } - public void setTexture(String texture, int type) { - this.type = (byte) type; - this.location = null; - if(texture.isEmpty()){ - playerTexture = true; - this.texture = texture; - } - else{ - this.texture = "customnpcs:textures/parts/"+ texture + ".png"; - playerTexture = false; - } - } + public void setTexture(String texture, int type) { + this.type = (byte) type; + this.location = null; + if (texture.isEmpty()) { + playerTexture = true; + this.texture = texture; + } else { + this.texture = "customnpcs:textures/parts/" + texture + ".png"; + playerTexture = false; + } + } - public String toString(){ - return "Color: " + color + " Type: " + type; - } + public String toString() { + return "Color: " + color + " Type: " + type; + } - public String getColor() { - String str = Integer.toHexString(color); + public String getColor() { + String str = Integer.toHexString(color); - while(str.length() < 6) - str = "0" + str; + while (str.length() < 6) + str = "0" + str; - return str; - } + return str; + } } diff --git a/src/main/java/noppes/npcs/entity/data/ModelRotate.java b/src/main/java/noppes/npcs/entity/data/ModelRotate.java index 72c8fc10f..860b26bf7 100644 --- a/src/main/java/noppes/npcs/entity/data/ModelRotate.java +++ b/src/main/java/noppes/npcs/entity/data/ModelRotate.java @@ -6,83 +6,83 @@ import noppes.npcs.api.entity.data.IModelRotatePart; import noppes.npcs.util.ValueUtil; public class ModelRotate implements IModelRotate { - // Rotation - public boolean whileStanding = true; - public boolean whileAttacking = false; - public boolean whileMoving = false; + // Rotation + public boolean whileStanding = true; + public boolean whileAttacking = false; + public boolean whileMoving = false; - public ModelRotatePart head = new ModelRotatePart(); - public ModelRotatePart body = new ModelRotatePart(); - public ModelRotatePart larm = new ModelRotatePart(); - public ModelRotatePart rarm = new ModelRotatePart(); - public ModelRotatePart lleg = new ModelRotatePart(); - public ModelRotatePart rleg = new ModelRotatePart(); + public ModelRotatePart head = new ModelRotatePart(); + public ModelRotatePart body = new ModelRotatePart(); + public ModelRotatePart larm = new ModelRotatePart(); + public ModelRotatePart rarm = new ModelRotatePart(); + public ModelRotatePart lleg = new ModelRotatePart(); + public ModelRotatePart rleg = new ModelRotatePart(); - public NBTTagCompound writeToNBT(){ - NBTTagCompound compound = new NBTTagCompound(); - compound.setBoolean("PuppetStanding", whileStanding); - compound.setBoolean("PuppetAttacking", whileAttacking); - compound.setBoolean("PuppetMoving", whileMoving); - compound.setTag("PuppetHead", head.writeToNBT()); - compound.setTag("PuppetBody", body.writeToNBT()); - compound.setTag("PuppetRArm", rarm.writeToNBT()); - compound.setTag("PuppetLArm", larm.writeToNBT()); - compound.setTag("PuppetRLeg", rleg.writeToNBT()); - compound.setTag("PuppetLLeg", lleg.writeToNBT()); - return compound; - } - - public void readFromNBT(NBTTagCompound compound){ - whileStanding = compound.getBoolean("PuppetStanding"); - whileAttacking = compound.getBoolean("PuppetAttacking"); - whileMoving = compound.getBoolean("PuppetMoving"); - head.readFromNBT(compound.getCompoundTag("PuppetHead")); - body.readFromNBT(compound.getCompoundTag("PuppetBody")); - rarm.readFromNBT(compound.getCompoundTag("PuppetRArm")); - larm.readFromNBT(compound.getCompoundTag("PuppetLArm")); - rleg.readFromNBT(compound.getCompoundTag("PuppetRLeg")); - lleg.readFromNBT(compound.getCompoundTag("PuppetLLeg")); - } + public NBTTagCompound writeToNBT() { + NBTTagCompound compound = new NBTTagCompound(); + compound.setBoolean("PuppetStanding", whileStanding); + compound.setBoolean("PuppetAttacking", whileAttacking); + compound.setBoolean("PuppetMoving", whileMoving); + compound.setTag("PuppetHead", head.writeToNBT()); + compound.setTag("PuppetBody", body.writeToNBT()); + compound.setTag("PuppetRArm", rarm.writeToNBT()); + compound.setTag("PuppetLArm", larm.writeToNBT()); + compound.setTag("PuppetRLeg", rleg.writeToNBT()); + compound.setTag("PuppetLLeg", lleg.writeToNBT()); + return compound; + } - public boolean whileStanding() { - return this.whileStanding; - } + public void readFromNBT(NBTTagCompound compound) { + whileStanding = compound.getBoolean("PuppetStanding"); + whileAttacking = compound.getBoolean("PuppetAttacking"); + whileMoving = compound.getBoolean("PuppetMoving"); + head.readFromNBT(compound.getCompoundTag("PuppetHead")); + body.readFromNBT(compound.getCompoundTag("PuppetBody")); + rarm.readFromNBT(compound.getCompoundTag("PuppetRArm")); + larm.readFromNBT(compound.getCompoundTag("PuppetLArm")); + rleg.readFromNBT(compound.getCompoundTag("PuppetRLeg")); + lleg.readFromNBT(compound.getCompoundTag("PuppetLLeg")); + } - public void whileStanding(boolean whileStanding) { - this.whileStanding = whileStanding; - } + public boolean whileStanding() { + return this.whileStanding; + } - public boolean whileAttacking() { - return this.whileAttacking; - } + public void whileStanding(boolean whileStanding) { + this.whileStanding = whileStanding; + } - public void whileAttacking(boolean whileAttacking) { - this.whileAttacking = whileAttacking; - } + public boolean whileAttacking() { + return this.whileAttacking; + } - public boolean whileMoving() { - return this.whileMoving; - } + public void whileAttacking(boolean whileAttacking) { + this.whileAttacking = whileAttacking; + } - public void whileMoving(boolean whileMoving) { - this.whileMoving = whileMoving; - } + public boolean whileMoving() { + return this.whileMoving; + } - public IModelRotatePart getPart(int part) { - switch (ValueUtil.clamp(part,0,5)) { - case 0: - return head; - case 1: - return body; - case 2: - return larm; - case 3: - return rarm; - case 4: - return lleg; - case 5: - return rleg; - } - return null; - } + public void whileMoving(boolean whileMoving) { + this.whileMoving = whileMoving; + } + + public IModelRotatePart getPart(int part) { + switch (ValueUtil.clamp(part, 0, 5)) { + case 0: + return head; + case 1: + return body; + case 2: + return larm; + case 3: + return rarm; + case 4: + return lleg; + case 5: + return rleg; + } + return null; + } } diff --git a/src/main/java/noppes/npcs/entity/data/ModelRotatePart.java b/src/main/java/noppes/npcs/entity/data/ModelRotatePart.java index 58152764f..4305b9373 100644 --- a/src/main/java/noppes/npcs/entity/data/ModelRotatePart.java +++ b/src/main/java/noppes/npcs/entity/data/ModelRotatePart.java @@ -5,48 +5,48 @@ import noppes.npcs.api.entity.data.IModelRotatePart; import noppes.npcs.util.ValueUtil; public class ModelRotatePart implements IModelRotatePart { - public float rotationX = 0f, rotationY = 0f, rotationZ = 0f; - public boolean disabled = false; + public float rotationX = 0f, rotationY = 0f, rotationZ = 0f; + public boolean disabled = false; - public NBTTagCompound writeToNBT(){ - NBTTagCompound compound = new NBTTagCompound(); - compound.setBoolean("Disabled", disabled); - compound.setFloat("RotationX", rotationX); - compound.setFloat("RotationY", rotationY); - compound.setFloat("RotationZ", rotationZ); - return compound; - } - - public void readFromNBT(NBTTagCompound compound){ - disabled = compound.getBoolean("Disabled"); - rotationX = ValueUtil.clamp(compound.getFloat("RotationX"), -0.5f, 0.5f); - rotationY = ValueUtil.clamp(compound.getFloat("RotationY"), -0.5f, 0.5f); - rotationZ = ValueUtil.clamp(compound.getFloat("RotationZ"), -0.5f, 0.5f); - } + public NBTTagCompound writeToNBT() { + NBTTagCompound compound = new NBTTagCompound(); + compound.setBoolean("Disabled", disabled); + compound.setFloat("RotationX", rotationX); + compound.setFloat("RotationY", rotationY); + compound.setFloat("RotationZ", rotationZ); + return compound; + } - public void setRotation(float x, float y, float z) { - this.rotationX = ValueUtil.clamp(x, -0.5f, 0.5f); - this.rotationY = ValueUtil.clamp(y, -0.5f, 0.5f); - this.rotationZ = ValueUtil.clamp(z, -0.5f, 0.5f); - } + public void readFromNBT(NBTTagCompound compound) { + disabled = compound.getBoolean("Disabled"); + rotationX = ValueUtil.clamp(compound.getFloat("RotationX"), -0.5f, 0.5f); + rotationY = ValueUtil.clamp(compound.getFloat("RotationY"), -0.5f, 0.5f); + rotationZ = ValueUtil.clamp(compound.getFloat("RotationZ"), -0.5f, 0.5f); + } - public float getRotateX() { - return this.rotationX; - } + public void setRotation(float x, float y, float z) { + this.rotationX = ValueUtil.clamp(x, -0.5f, 0.5f); + this.rotationY = ValueUtil.clamp(y, -0.5f, 0.5f); + this.rotationZ = ValueUtil.clamp(z, -0.5f, 0.5f); + } - public float getRotateY() { - return this.rotationY; - } + public float getRotateX() { + return this.rotationX; + } - public float getRotateZ() { - return this.rotationZ; - } + public float getRotateY() { + return this.rotationY; + } - public void disabled(boolean disabled) { - this.disabled = disabled; - } + public float getRotateZ() { + return this.rotationZ; + } - public boolean disabled() { - return this.disabled; - } + public void disabled(boolean disabled) { + this.disabled = disabled; + } + + public boolean disabled() { + return this.disabled; + } } diff --git a/src/main/java/noppes/npcs/entity/data/ModelScale.java b/src/main/java/noppes/npcs/entity/data/ModelScale.java index 5785764ea..bde88faa0 100644 --- a/src/main/java/noppes/npcs/entity/data/ModelScale.java +++ b/src/main/java/noppes/npcs/entity/data/ModelScale.java @@ -28,7 +28,7 @@ public class ModelScale implements IModelScale { @Override public IModelScalePart getPart(int part) { - switch (ValueUtil.clamp(part,0,3)) { + switch (ValueUtil.clamp(part, 0, 3)) { case 0: return head; case 1: diff --git a/src/main/java/noppes/npcs/entity/data/ModelScalePart.java b/src/main/java/noppes/npcs/entity/data/ModelScalePart.java index 4c369d62d..5c8ba3d0a 100644 --- a/src/main/java/noppes/npcs/entity/data/ModelScalePart.java +++ b/src/main/java/noppes/npcs/entity/data/ModelScalePart.java @@ -5,47 +5,47 @@ import noppes.npcs.api.entity.data.IModelScalePart; import noppes.npcs.util.ValueUtil; public class ModelScalePart implements IModelScalePart { - public float scaleX = 1, scaleY = 1, scaleZ = 1; + public float scaleX = 1, scaleY = 1, scaleZ = 1; - public NBTTagCompound writeToNBT(){ - NBTTagCompound compound = new NBTTagCompound(); - compound.setFloat("ScaleX", scaleX); - compound.setFloat("ScaleY", scaleY); - compound.setFloat("ScaleZ", scaleZ); + public NBTTagCompound writeToNBT() { + NBTTagCompound compound = new NBTTagCompound(); + compound.setFloat("ScaleX", scaleX); + compound.setFloat("ScaleY", scaleY); + compound.setFloat("ScaleZ", scaleZ); - return compound; - } - - public void readFromNBT(NBTTagCompound compound){ - scaleX = ValueUtil.clamp(compound.getFloat("ScaleX"), 0.5f, 1.5f); - scaleY = ValueUtil.clamp(compound.getFloat("ScaleY"), 0.5f, 1.5f); - scaleZ = ValueUtil.clamp(compound.getFloat("ScaleZ"), 0.5f, 1.5f); - } - - public String toString(){ - return "ScaleX: " + scaleX + " - ScaleY: " + scaleY + " - ScaleZ: " + scaleZ; - } + return compound; + } - public void setScale(float x, float y) { - scaleZ = scaleX = x; - scaleY = y; - } + public void readFromNBT(NBTTagCompound compound) { + scaleX = ValueUtil.clamp(compound.getFloat("ScaleX"), 0.5f, 1.5f); + scaleY = ValueUtil.clamp(compound.getFloat("ScaleY"), 0.5f, 1.5f); + scaleZ = ValueUtil.clamp(compound.getFloat("ScaleZ"), 0.5f, 1.5f); + } - public void setScale(float x, float y, float z) { - scaleX = ValueUtil.clamp(x, 0.5f, 1.5f); - scaleY = ValueUtil.clamp(y, 0.5f, 1.5f); - scaleZ = ValueUtil.clamp(z, 0.5f, 1.5f); - } + public String toString() { + return "ScaleX: " + scaleX + " - ScaleY: " + scaleY + " - ScaleZ: " + scaleZ; + } - public float getScaleX() { - return scaleX; - } + public void setScale(float x, float y) { + scaleZ = scaleX = x; + scaleY = y; + } - public float getScaleY() { - return scaleY; - } + public void setScale(float x, float y, float z) { + scaleX = ValueUtil.clamp(x, 0.5f, 1.5f); + scaleY = ValueUtil.clamp(y, 0.5f, 1.5f); + scaleZ = ValueUtil.clamp(z, 0.5f, 1.5f); + } - public float getScaleZ() { - return scaleZ; - } + public float getScaleX() { + return scaleX; + } + + public float getScaleY() { + return scaleY; + } + + public float getScaleZ() { + return scaleZ; + } } diff --git a/src/main/java/noppes/npcs/entity/old/EntityNPCDwarfFemale.java b/src/main/java/noppes/npcs/entity/old/EntityNPCDwarfFemale.java index 2eedbd0d6..6d2a63617 100644 --- a/src/main/java/noppes/npcs/entity/old/EntityNPCDwarfFemale.java +++ b/src/main/java/noppes/npcs/entity/old/EntityNPCDwarfFemale.java @@ -14,33 +14,31 @@ import noppes.npcs.entity.data.ModelData; // EntityAnimal, Item, EntityPlayer, InventoryPlayer, // ItemStack, World, NBTTagCompound -public class EntityNPCDwarfFemale extends EntityNPCInterface -{ - public EntityNPCDwarfFemale(World world) - { +public class EntityNPCDwarfFemale extends EntityNPCInterface { + public EntityNPCDwarfFemale(World world) { super(world); scaleX = scaleZ = 0.75f; scaleY = 0.6275f; display.texture = "customnpcs:textures/entity/dwarffemale/Simone.png"; } - public void onUpdate(){ - isDead = true; + public void onUpdate() { + isDead = true; - if(!worldObj.isRemote){ - NBTTagCompound compound = new NBTTagCompound(); + if (!worldObj.isRemote) { + NBTTagCompound compound = new NBTTagCompound(); - writeToNBT(compound); - EntityCustomNpc npc = new EntityCustomNpc(worldObj); - npc.readFromNBT(compound); - ModelData data = npc.modelData; - data.breasts = 2; - data.modelScale.legs.setScale(0.8f,1.05f); - data.modelScale.arms.setScale(0.8f,1.05f); - data.modelScale.body.setScale(0.8f,1.05f); - data.modelScale.head.setScale(0.8f,0.85f); - worldObj.spawnEntityInWorld(npc); - } - super.onUpdate(); + writeToNBT(compound); + EntityCustomNpc npc = new EntityCustomNpc(worldObj); + npc.readFromNBT(compound); + ModelData data = npc.modelData; + data.breasts = 2; + data.modelScale.legs.setScale(0.8f, 1.05f); + data.modelScale.arms.setScale(0.8f, 1.05f); + data.modelScale.body.setScale(0.8f, 1.05f); + data.modelScale.head.setScale(0.8f, 0.85f); + worldObj.spawnEntityInWorld(npc); + } + super.onUpdate(); } } diff --git a/src/main/java/noppes/npcs/entity/old/EntityNPCDwarfMale.java b/src/main/java/noppes/npcs/entity/old/EntityNPCDwarfMale.java index 41fa485c8..87d5fb3d4 100644 --- a/src/main/java/noppes/npcs/entity/old/EntityNPCDwarfMale.java +++ b/src/main/java/noppes/npcs/entity/old/EntityNPCDwarfMale.java @@ -14,32 +14,30 @@ import noppes.npcs.entity.data.ModelData; // EntityAnimal, Item, EntityPlayer, InventoryPlayer, // ItemStack, World, NBTTagCompound -public class EntityNPCDwarfMale extends EntityNPCInterface -{ - public EntityNPCDwarfMale(World world) - { +public class EntityNPCDwarfMale extends EntityNPCInterface { + public EntityNPCDwarfMale(World world) { super(world); scaleX = scaleZ = 0.85f; scaleY = 0.6875f; display.texture = "customnpcs:textures/entity/dwarfmale/Simon.png"; } - public void onUpdate(){ - isDead = true; + public void onUpdate() { + isDead = true; - if(!worldObj.isRemote){ - NBTTagCompound compound = new NBTTagCompound(); + if (!worldObj.isRemote) { + NBTTagCompound compound = new NBTTagCompound(); - writeToNBT(compound); - EntityCustomNpc npc = new EntityCustomNpc(worldObj); - npc.readFromNBT(compound); - ModelData data = npc.modelData; - data.modelScale.legs.setScale(1.1f,0.7f, 0.9f); - data.modelScale.arms.setScale(0.9f,0.7f); - data.modelScale.body.setScale(1.2f, 0.7f, 1.5f); - data.modelScale.head.setScale(0.85f,0.85f); - worldObj.spawnEntityInWorld(npc); - } - super.onUpdate(); + writeToNBT(compound); + EntityCustomNpc npc = new EntityCustomNpc(worldObj); + npc.readFromNBT(compound); + ModelData data = npc.modelData; + data.modelScale.legs.setScale(1.1f, 0.7f, 0.9f); + data.modelScale.arms.setScale(0.9f, 0.7f); + data.modelScale.body.setScale(1.2f, 0.7f, 1.5f); + data.modelScale.head.setScale(0.85f, 0.85f); + worldObj.spawnEntityInWorld(npc); + } + super.onUpdate(); } } diff --git a/src/main/java/noppes/npcs/entity/old/EntityNPCElfFemale.java b/src/main/java/noppes/npcs/entity/old/EntityNPCElfFemale.java index e06e9ac84..65052bd48 100644 --- a/src/main/java/noppes/npcs/entity/old/EntityNPCElfFemale.java +++ b/src/main/java/noppes/npcs/entity/old/EntityNPCElfFemale.java @@ -14,35 +14,33 @@ import noppes.npcs.entity.data.ModelData; // EntityAnimal, Item, EntityPlayer, InventoryPlayer, // ItemStack, World, NBTTagCompound -public class EntityNPCElfFemale extends EntityNPCInterface -{ - public EntityNPCElfFemale(World world) - { +public class EntityNPCElfFemale extends EntityNPCInterface { + public EntityNPCElfFemale(World world) { super(world); display.texture = "customnpcs:textures/entity/elffemale/ElfFemale.png"; - scaleX = 0.8f; - scaleY = 1f; - scaleZ = 0.8f; + scaleX = 0.8f; + scaleY = 1f; + scaleZ = 0.8f; } - public void onUpdate(){ - isDead = true; + public void onUpdate() { + isDead = true; - if(!worldObj.isRemote){ - NBTTagCompound compound = new NBTTagCompound(); + if (!worldObj.isRemote) { + NBTTagCompound compound = new NBTTagCompound(); - writeToNBT(compound); - EntityCustomNpc npc = new EntityCustomNpc(worldObj); - npc.readFromNBT(compound); - ModelData data = npc.modelData; - data.breasts = 2; - data.modelScale.legs.setScale(0.8f,1.05f); - data.modelScale.arms.setScale(0.8f,1.05f); - data.modelScale.body.setScale(0.8f,1.05f); - data.modelScale.head.setScale(0.8f,0.85f); - worldObj.spawnEntityInWorld(npc); - } - super.onUpdate(); + writeToNBT(compound); + EntityCustomNpc npc = new EntityCustomNpc(worldObj); + npc.readFromNBT(compound); + ModelData data = npc.modelData; + data.breasts = 2; + data.modelScale.legs.setScale(0.8f, 1.05f); + data.modelScale.arms.setScale(0.8f, 1.05f); + data.modelScale.body.setScale(0.8f, 1.05f); + data.modelScale.head.setScale(0.8f, 0.85f); + worldObj.spawnEntityInWorld(npc); + } + super.onUpdate(); } } diff --git a/src/main/java/noppes/npcs/entity/old/EntityNPCElfMale.java b/src/main/java/noppes/npcs/entity/old/EntityNPCElfMale.java index 7c93d0f7d..4d3ab9c14 100644 --- a/src/main/java/noppes/npcs/entity/old/EntityNPCElfMale.java +++ b/src/main/java/noppes/npcs/entity/old/EntityNPCElfMale.java @@ -14,34 +14,32 @@ import noppes.npcs.entity.data.ModelData; // EntityAnimal, Item, EntityPlayer, InventoryPlayer, // ItemStack, World, NBTTagCompound -public class EntityNPCElfMale extends EntityNPCInterface -{ - public EntityNPCElfMale(World world) - { +public class EntityNPCElfMale extends EntityNPCInterface { + public EntityNPCElfMale(World world) { super(world); - scaleX = 0.85f; - scaleY = 1.07f; - scaleZ = 0.85f; - display.texture = "customnpcs:textures/entity/elfmale/ElfMale.png"; + scaleX = 0.85f; + scaleY = 1.07f; + scaleZ = 0.85f; + display.texture = "customnpcs:textures/entity/elfmale/ElfMale.png"; } - public void onUpdate(){ - isDead = true; + public void onUpdate() { + isDead = true; - if(!worldObj.isRemote){ - NBTTagCompound compound = new NBTTagCompound(); + if (!worldObj.isRemote) { + NBTTagCompound compound = new NBTTagCompound(); - writeToNBT(compound); - EntityCustomNpc npc = new EntityCustomNpc(worldObj); - npc.readFromNBT(compound); - ModelData data = npc.modelData; - data.modelScale.legs.setScale(0.85f,1.15f); - data.modelScale.arms.setScale(0.85f,1.15f); - data.modelScale.body.setScale(0.85f,1.15f); - data.modelScale.head.setScale(0.85f,0.95f); - worldObj.spawnEntityInWorld(npc); - } - super.onUpdate(); + writeToNBT(compound); + EntityCustomNpc npc = new EntityCustomNpc(worldObj); + npc.readFromNBT(compound); + ModelData data = npc.modelData; + data.modelScale.legs.setScale(0.85f, 1.15f); + data.modelScale.arms.setScale(0.85f, 1.15f); + data.modelScale.body.setScale(0.85f, 1.15f); + data.modelScale.head.setScale(0.85f, 0.95f); + worldObj.spawnEntityInWorld(npc); + } + super.onUpdate(); } } diff --git a/src/main/java/noppes/npcs/entity/old/EntityNPCEnderman.java b/src/main/java/noppes/npcs/entity/old/EntityNPCEnderman.java index 9aee5a58d..66a53055f 100644 --- a/src/main/java/noppes/npcs/entity/old/EntityNPCEnderman.java +++ b/src/main/java/noppes/npcs/entity/old/EntityNPCEnderman.java @@ -12,50 +12,45 @@ import noppes.npcs.controllers.data.SkinOverlay; import noppes.npcs.entity.EntityCustomNpc; import noppes.npcs.entity.data.ModelData; -public class EntityNPCEnderman extends EntityNpcEnderchibi -{ - public EntityNPCEnderman(World world) - { +public class EntityNPCEnderman extends EntityNpcEnderchibi { + public EntityNPCEnderman(World world) { super(world); display.texture = "customnpcs:textures/entity/enderman/enderman.png"; //display.glowTexture = ; - display.skinOverlayData.overlayList.put(0,new SkinOverlay("customnpcs:textures/overlays/ender_eyes.png")); + display.skinOverlayData.overlayList.put(0, new SkinOverlay("customnpcs:textures/overlays/ender_eyes.png")); this.width = 0.6F; this.height = 2.9F; } public void updateHitbox() { - if(currentAnimation == EnumAnimation.LYING){ - width = height = 0.2f; - } - else if (currentAnimation == EnumAnimation.SITTING){ - width = 0.6f; - height = 2.3f; - } - else{ - width = 0.6f; - height = 2.9f; - } - width = (width / 5f) * display.modelSize; - height = (height / 5f) * display.modelSize; - } + if (currentAnimation == EnumAnimation.LYING) { + width = height = 0.2f; + } else if (currentAnimation == EnumAnimation.SITTING) { + width = 0.6f; + height = 2.3f; + } else { + width = 0.6f; + height = 2.9f; + } + width = (width / 5f) * display.modelSize; + height = (height / 5f) * display.modelSize; + } - public void onUpdate() - { - isDead = true; + public void onUpdate() { + isDead = true; - if(!worldObj.isRemote){ - NBTTagCompound compound = new NBTTagCompound(); + if (!worldObj.isRemote) { + NBTTagCompound compound = new NBTTagCompound(); - writeToNBT(compound); - EntityCustomNpc npc = new EntityCustomNpc(worldObj); - npc.readFromNBT(compound); - ModelData data = npc.modelData; - data.setEntityClass(EntityEnderman.class); + writeToNBT(compound); + EntityCustomNpc npc = new EntityCustomNpc(worldObj); + npc.readFromNBT(compound); + ModelData data = npc.modelData; + data.setEntityClass(EntityEnderman.class); - worldObj.spawnEntityInWorld(npc); - } + worldObj.spawnEntityInWorld(npc); + } super.onUpdate(); } } diff --git a/src/main/java/noppes/npcs/entity/old/EntityNPCFurryFemale.java b/src/main/java/noppes/npcs/entity/old/EntityNPCFurryFemale.java index 04ad6a0ae..36dd66702 100644 --- a/src/main/java/noppes/npcs/entity/old/EntityNPCFurryFemale.java +++ b/src/main/java/noppes/npcs/entity/old/EntityNPCFurryFemale.java @@ -15,41 +15,39 @@ import noppes.npcs.entity.data.ModelPartData; // EntityAnimal, Item, EntityPlayer, InventoryPlayer, // ItemStack, World, NBTTagCompound -public class EntityNPCFurryFemale extends EntityNPCInterface -{ - public EntityNPCFurryFemale(World world) - { +public class EntityNPCFurryFemale extends EntityNPCInterface { + public EntityNPCFurryFemale(World world) { super(world); scaleX = scaleY = scaleZ = 0.9075f; display.texture = "customnpcs:textures/entity/furryfemale/WolfBlack.png"; } - public void onUpdate() - { - isDead = true; - if(!worldObj.isRemote){ - NBTTagCompound compound = new NBTTagCompound(); + public void onUpdate() { + isDead = true; - writeToNBT(compound); - EntityCustomNpc npc = new EntityCustomNpc(worldObj); - npc.readFromNBT(compound); - ModelData data = npc.modelData; - data.breasts = 2; - data.modelScale.head.setScale(0.95f,0.95f); - data.modelScale.legs.setScale(0.92f,0.92f); - data.modelScale.arms.setScale(0.80f,0.92f); - data.modelScale.body.setScale(0.92f, 0.92f); - ModelPartData hair = data.getOrCreatePart("ears"); - hair.playerTexture = true; - ModelPartData snout = data.getOrCreatePart("snout"); - snout.playerTexture = true; - snout.type = 1; - ModelPartData tail = data.getOrCreatePart("tail"); - tail.playerTexture = true; + if (!worldObj.isRemote) { + NBTTagCompound compound = new NBTTagCompound(); + + writeToNBT(compound); + EntityCustomNpc npc = new EntityCustomNpc(worldObj); + npc.readFromNBT(compound); + ModelData data = npc.modelData; + data.breasts = 2; + data.modelScale.head.setScale(0.95f, 0.95f); + data.modelScale.legs.setScale(0.92f, 0.92f); + data.modelScale.arms.setScale(0.80f, 0.92f); + data.modelScale.body.setScale(0.92f, 0.92f); + ModelPartData hair = data.getOrCreatePart("ears"); + hair.playerTexture = true; + ModelPartData snout = data.getOrCreatePart("snout"); + snout.playerTexture = true; + snout.type = 1; + ModelPartData tail = data.getOrCreatePart("tail"); + tail.playerTexture = true; - worldObj.spawnEntityInWorld(npc); - } + worldObj.spawnEntityInWorld(npc); + } super.onUpdate(); } } diff --git a/src/main/java/noppes/npcs/entity/old/EntityNPCFurryMale.java b/src/main/java/noppes/npcs/entity/old/EntityNPCFurryMale.java index bbbcfb8a3..2c82d62d6 100644 --- a/src/main/java/noppes/npcs/entity/old/EntityNPCFurryMale.java +++ b/src/main/java/noppes/npcs/entity/old/EntityNPCFurryMale.java @@ -15,36 +15,33 @@ import noppes.npcs.entity.data.ModelPartData; // EntityAnimal, Item, EntityPlayer, InventoryPlayer, // ItemStack, World, NBTTagCompound -public class EntityNPCFurryMale extends EntityNPCInterface -{ - public EntityNPCFurryMale(World world) - { +public class EntityNPCFurryMale extends EntityNPCInterface { + public EntityNPCFurryMale(World world) { super(world); display.texture = "customnpcs:textures/entity/furrymale/WolfGrey.png"; } - public void onUpdate() - { - isDead = true; + public void onUpdate() { + isDead = true; - if(!worldObj.isRemote){ - NBTTagCompound compound = new NBTTagCompound(); + if (!worldObj.isRemote) { + NBTTagCompound compound = new NBTTagCompound(); - writeToNBT(compound); - EntityCustomNpc npc = new EntityCustomNpc(worldObj); - npc.readFromNBT(compound); - ModelData data = npc.modelData; - ModelPartData hair = data.getOrCreatePart("ears"); - hair.playerTexture = true; - ModelPartData snout = data.getOrCreatePart("snout"); - snout.playerTexture = true; - snout.type = 1; - ModelPartData tail = data.getOrCreatePart("tail"); - tail.playerTexture = true; + writeToNBT(compound); + EntityCustomNpc npc = new EntityCustomNpc(worldObj); + npc.readFromNBT(compound); + ModelData data = npc.modelData; + ModelPartData hair = data.getOrCreatePart("ears"); + hair.playerTexture = true; + ModelPartData snout = data.getOrCreatePart("snout"); + snout.playerTexture = true; + snout.type = 1; + ModelPartData tail = data.getOrCreatePart("tail"); + tail.playerTexture = true; - worldObj.spawnEntityInWorld(npc); - } + worldObj.spawnEntityInWorld(npc); + } super.onUpdate(); } diff --git a/src/main/java/noppes/npcs/entity/old/EntityNPCHumanFemale.java b/src/main/java/noppes/npcs/entity/old/EntityNPCHumanFemale.java index 97e480a32..429d08e08 100644 --- a/src/main/java/noppes/npcs/entity/old/EntityNPCHumanFemale.java +++ b/src/main/java/noppes/npcs/entity/old/EntityNPCHumanFemale.java @@ -14,32 +14,30 @@ import noppes.npcs.entity.data.ModelData; // EntityAnimal, Item, EntityPlayer, InventoryPlayer, // ItemStack, World, NBTTagCompound -public class EntityNPCHumanFemale extends EntityNPCInterface -{ - public EntityNPCHumanFemale(World world) - { +public class EntityNPCHumanFemale extends EntityNPCInterface { + public EntityNPCHumanFemale(World world) { super(world); scaleX = scaleY = scaleZ = 0.9075f; display.texture = "customnpcs:textures/entity/humanfemale/Stephanie.png"; } - public void onUpdate(){ - isDead = true; + public void onUpdate() { + isDead = true; - if(!worldObj.isRemote){ - NBTTagCompound compound = new NBTTagCompound(); + if (!worldObj.isRemote) { + NBTTagCompound compound = new NBTTagCompound(); - writeToNBT(compound); - EntityCustomNpc npc = new EntityCustomNpc(worldObj); - npc.readFromNBT(compound); - ModelData data = npc.modelData; - data.breasts = 2; - data.modelScale.head.setScale(0.95f,0.95f); - data.modelScale.legs.setScale(0.92f,0.92f); - data.modelScale.arms.setScale(0.80f,0.92f); - data.modelScale.body.setScale(0.92f, 0.92f); - worldObj.spawnEntityInWorld(npc); - } - super.onUpdate(); + writeToNBT(compound); + EntityCustomNpc npc = new EntityCustomNpc(worldObj); + npc.readFromNBT(compound); + ModelData data = npc.modelData; + data.breasts = 2; + data.modelScale.head.setScale(0.95f, 0.95f); + data.modelScale.legs.setScale(0.92f, 0.92f); + data.modelScale.arms.setScale(0.80f, 0.92f); + data.modelScale.body.setScale(0.92f, 0.92f); + worldObj.spawnEntityInWorld(npc); + } + super.onUpdate(); } } diff --git a/src/main/java/noppes/npcs/entity/old/EntityNPCHumanMale.java b/src/main/java/noppes/npcs/entity/old/EntityNPCHumanMale.java index da42a077f..eefa6001e 100644 --- a/src/main/java/noppes/npcs/entity/old/EntityNPCHumanMale.java +++ b/src/main/java/noppes/npcs/entity/old/EntityNPCHumanMale.java @@ -1,6 +1,6 @@ // Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov. // Jad home page: http://www.kpdus.com/jad.html -// Decompiler options: packimports(3) braces deadcode fieldsfirst +// Decompiler options: packimports(3) braces deadcode fieldsfirst package noppes.npcs.entity.old; @@ -10,28 +10,26 @@ import noppes.npcs.entity.EntityCustomNpc; import noppes.npcs.entity.EntityNPCInterface; // Referenced classes of package net.minecraft.src: -// EntityAnimal, Item, EntityPlayer, InventoryPlayer, +// EntityAnimal, Item, EntityPlayer, InventoryPlayer, // ItemStack, World, NBTTagCompound -public class EntityNPCHumanMale extends EntityNPCInterface -{ - public EntityNPCHumanMale(World world) - { +public class EntityNPCHumanMale extends EntityNPCInterface { + public EntityNPCHumanMale(World world) { super(world); } - - public void onUpdate(){ - isDead = true; - if(!worldObj.isRemote){ - NBTTagCompound compound = new NBTTagCompound(); - - writeToNBT(compound); - EntityCustomNpc npc = new EntityCustomNpc(worldObj); - npc.readFromNBT(compound); - worldObj.spawnEntityInWorld(npc); - } - super.onUpdate(); + public void onUpdate() { + isDead = true; + + if (!worldObj.isRemote) { + NBTTagCompound compound = new NBTTagCompound(); + + writeToNBT(compound); + EntityCustomNpc npc = new EntityCustomNpc(worldObj); + npc.readFromNBT(compound); + worldObj.spawnEntityInWorld(npc); + } + super.onUpdate(); } } diff --git a/src/main/java/noppes/npcs/entity/old/EntityNPCOrcFemale.java b/src/main/java/noppes/npcs/entity/old/EntityNPCOrcFemale.java index 25700a191..0786c1aea 100644 --- a/src/main/java/noppes/npcs/entity/old/EntityNPCOrcFemale.java +++ b/src/main/java/noppes/npcs/entity/old/EntityNPCOrcFemale.java @@ -14,32 +14,30 @@ import noppes.npcs.entity.data.ModelData; // EntityAnimal, Item, EntityPlayer, InventoryPlayer, // ItemStack, World, NBTTagCompound -public class EntityNPCOrcFemale extends EntityNPCInterface -{ - public EntityNPCOrcFemale(World world) - { +public class EntityNPCOrcFemale extends EntityNPCInterface { + public EntityNPCOrcFemale(World world) { super(world); - scaleX = scaleY = scaleZ = 0.9375f; - display.texture = "customnpcs:textures/entity/orcfemale/StrandedFemaleOrc.png"; + scaleX = scaleY = scaleZ = 0.9375f; + display.texture = "customnpcs:textures/entity/orcfemale/StrandedFemaleOrc.png"; } - public void onUpdate(){ - isDead = true; + public void onUpdate() { + isDead = true; - if(!worldObj.isRemote){ - NBTTagCompound compound = new NBTTagCompound(); + if (!worldObj.isRemote) { + NBTTagCompound compound = new NBTTagCompound(); - writeToNBT(compound); - EntityCustomNpc npc = new EntityCustomNpc(worldObj); - npc.readFromNBT(compound); - ModelData data = npc.modelData; - data.breasts = 2; - data.modelScale.legs.setScale(0.9f,0.65f); - data.modelScale.arms.setScale(0.9f,0.65f); - data.modelScale.body.setScale(1f, 0.65f, 1.1f); - data.modelScale.head.setScale(0.85f,0.85f); - worldObj.spawnEntityInWorld(npc); - } - super.onUpdate(); + writeToNBT(compound); + EntityCustomNpc npc = new EntityCustomNpc(worldObj); + npc.readFromNBT(compound); + ModelData data = npc.modelData; + data.breasts = 2; + data.modelScale.legs.setScale(0.9f, 0.65f); + data.modelScale.arms.setScale(0.9f, 0.65f); + data.modelScale.body.setScale(1f, 0.65f, 1.1f); + data.modelScale.head.setScale(0.85f, 0.85f); + worldObj.spawnEntityInWorld(npc); + } + super.onUpdate(); } } diff --git a/src/main/java/noppes/npcs/entity/old/EntityNPCOrcMale.java b/src/main/java/noppes/npcs/entity/old/EntityNPCOrcMale.java index a3e228054..cbbe7919b 100644 --- a/src/main/java/noppes/npcs/entity/old/EntityNPCOrcMale.java +++ b/src/main/java/noppes/npcs/entity/old/EntityNPCOrcMale.java @@ -14,32 +14,30 @@ import noppes.npcs.entity.data.ModelData; // EntityAnimal, Item, EntityPlayer, InventoryPlayer, // ItemStack, World, NBTTagCompound -public class EntityNPCOrcMale extends EntityNPCInterface -{ - public EntityNPCOrcMale(World world) - { +public class EntityNPCOrcMale extends EntityNPCInterface { + public EntityNPCOrcMale(World world) { super(world); - scaleY = 1f; - scaleX = scaleZ = 1.2f; + scaleY = 1f; + scaleX = scaleZ = 1.2f; display.texture = "customnpcs:textures/entity/orcmale/StrandedOrc.png"; } - public void onUpdate(){ - isDead = true; + public void onUpdate() { + isDead = true; - if(!worldObj.isRemote){ - NBTTagCompound compound = new NBTTagCompound(); + if (!worldObj.isRemote) { + NBTTagCompound compound = new NBTTagCompound(); - writeToNBT(compound); - EntityCustomNpc npc = new EntityCustomNpc(worldObj); - npc.readFromNBT(compound); - ModelData data = npc.modelData; - data.modelScale.legs.setScale(1.2f,1.05f); - data.modelScale.arms.setScale(1.2f,1.05f); - data.modelScale.body.setScale(1.4f, 1.1f, 1.5f); - data.modelScale.head.setScale(1.2f,1.1f); - worldObj.spawnEntityInWorld(npc); - } - super.onUpdate(); + writeToNBT(compound); + EntityCustomNpc npc = new EntityCustomNpc(worldObj); + npc.readFromNBT(compound); + ModelData data = npc.modelData; + data.modelScale.legs.setScale(1.2f, 1.05f); + data.modelScale.arms.setScale(1.2f, 1.05f); + data.modelScale.body.setScale(1.4f, 1.1f, 1.5f); + data.modelScale.head.setScale(1.2f, 1.1f); + worldObj.spawnEntityInWorld(npc); + } + super.onUpdate(); } } diff --git a/src/main/java/noppes/npcs/entity/old/EntityNPCVillager.java b/src/main/java/noppes/npcs/entity/old/EntityNPCVillager.java index 88f3a30a6..187897d13 100644 --- a/src/main/java/noppes/npcs/entity/old/EntityNPCVillager.java +++ b/src/main/java/noppes/npcs/entity/old/EntityNPCVillager.java @@ -15,30 +15,28 @@ import noppes.npcs.entity.data.ModelData; // EntityAnimal, Item, EntityPlayer, InventoryPlayer, // ItemStack, World, NBTTagCompound -public class EntityNPCVillager extends EntityNPCInterface -{ +public class EntityNPCVillager extends EntityNPCInterface { - public EntityNPCVillager(World world) - { + public EntityNPCVillager(World world) { super(world); display.texture = "textures/entity/villager/villager.png"; } - public void onUpdate() - { - isDead = true; - if(!worldObj.isRemote){ - NBTTagCompound compound = new NBTTagCompound(); + public void onUpdate() { + isDead = true; - writeToNBT(compound); - EntityCustomNpc npc = new EntityCustomNpc(worldObj); - npc.readFromNBT(compound); - ModelData data = npc.modelData; - data.setEntityClass(EntityVillager.class); + if (!worldObj.isRemote) { + NBTTagCompound compound = new NBTTagCompound(); + + writeToNBT(compound); + EntityCustomNpc npc = new EntityCustomNpc(worldObj); + npc.readFromNBT(compound); + ModelData data = npc.modelData; + data.setEntityClass(EntityVillager.class); - worldObj.spawnEntityInWorld(npc); - } + worldObj.spawnEntityInWorld(npc); + } super.onUpdate(); } diff --git a/src/main/java/noppes/npcs/entity/old/EntityNpcEnderchibi.java b/src/main/java/noppes/npcs/entity/old/EntityNpcEnderchibi.java index e3b5548a5..4d206bf89 100644 --- a/src/main/java/noppes/npcs/entity/old/EntityNpcEnderchibi.java +++ b/src/main/java/noppes/npcs/entity/old/EntityNpcEnderchibi.java @@ -15,32 +15,30 @@ import noppes.npcs.entity.data.ModelPartData; // EntityAnimal, Item, EntityPlayer, InventoryPlayer, // ItemStack, World, NBTTagCompound -public class EntityNpcEnderchibi extends EntityNPCInterface -{ - public EntityNpcEnderchibi(World world) - { +public class EntityNpcEnderchibi extends EntityNPCInterface { + public EntityNpcEnderchibi(World world) { super(world); display.texture = "customnpcs:textures/entity/enderchibi/MrEnderchibi.png"; } + @Override - public void onUpdate() - { - isDead = true; + public void onUpdate() { + isDead = true; - if(!worldObj.isRemote){ - NBTTagCompound compound = new NBTTagCompound(); + if (!worldObj.isRemote) { + NBTTagCompound compound = new NBTTagCompound(); - writeToNBT(compound); - EntityCustomNpc npc = new EntityCustomNpc(worldObj); - npc.readFromNBT(compound); - ModelData data = npc.modelData; - data.modelScale.legs.setScale(0.65f,0.75f); - data.modelScale.arms.setScale(0.50f,1.45f); - ModelPartData part = data.getOrCreatePart("particles"); - part.playerTexture = true; + writeToNBT(compound); + EntityCustomNpc npc = new EntityCustomNpc(worldObj); + npc.readFromNBT(compound); + ModelData data = npc.modelData; + data.modelScale.legs.setScale(0.65f, 0.75f); + data.modelScale.arms.setScale(0.50f, 1.45f); + ModelPartData part = data.getOrCreatePart("particles"); + part.playerTexture = true; - worldObj.spawnEntityInWorld(npc); - } + worldObj.spawnEntityInWorld(npc); + } super.onUpdate(); } diff --git a/src/main/java/noppes/npcs/entity/old/EntityNpcMonsterFemale.java b/src/main/java/noppes/npcs/entity/old/EntityNpcMonsterFemale.java index e66c806b8..831d6b3d0 100644 --- a/src/main/java/noppes/npcs/entity/old/EntityNpcMonsterFemale.java +++ b/src/main/java/noppes/npcs/entity/old/EntityNpcMonsterFemale.java @@ -15,34 +15,32 @@ import noppes.npcs.entity.data.ModelData; // EntityAnimal, Item, EntityPlayer, InventoryPlayer, // ItemStack, World, NBTTagCompound -public class EntityNpcMonsterFemale extends EntityNPCInterface -{ - public EntityNpcMonsterFemale(World world) - { +public class EntityNpcMonsterFemale extends EntityNPCInterface { + public EntityNpcMonsterFemale(World world) { super(world); scaleX = scaleY = scaleZ = 0.9075f; display.texture = "customnpcs:textures/entity/monsterfemale/ZombieStephanie.png"; } - public void onUpdate(){ - isDead = true; + public void onUpdate() { + isDead = true; - if(!worldObj.isRemote){ - NBTTagCompound compound = new NBTTagCompound(); + if (!worldObj.isRemote) { + NBTTagCompound compound = new NBTTagCompound(); - writeToNBT(compound); - EntityCustomNpc npc = new EntityCustomNpc(worldObj); - npc.readFromNBT(compound); - ModelData data = npc.modelData; - data.breasts = 2; - data.modelScale.head.setScale(0.95f,0.95f); - data.modelScale.legs.setScale(0.92f,0.92f); - data.modelScale.arms.setScale(0.80f,0.92f); - data.modelScale.body.setScale(0.92f, 0.92f); - npc.ais.animationType = EnumAnimation.HUG; - worldObj.spawnEntityInWorld(npc); - } - super.onUpdate(); + writeToNBT(compound); + EntityCustomNpc npc = new EntityCustomNpc(worldObj); + npc.readFromNBT(compound); + ModelData data = npc.modelData; + data.breasts = 2; + data.modelScale.head.setScale(0.95f, 0.95f); + data.modelScale.legs.setScale(0.92f, 0.92f); + data.modelScale.arms.setScale(0.80f, 0.92f); + data.modelScale.body.setScale(0.92f, 0.92f); + npc.ais.animationType = EnumAnimation.HUG; + worldObj.spawnEntityInWorld(npc); + } + super.onUpdate(); } } diff --git a/src/main/java/noppes/npcs/entity/old/EntityNpcMonsterMale.java b/src/main/java/noppes/npcs/entity/old/EntityNpcMonsterMale.java index 2a81ac253..079d4690e 100644 --- a/src/main/java/noppes/npcs/entity/old/EntityNpcMonsterMale.java +++ b/src/main/java/noppes/npcs/entity/old/EntityNpcMonsterMale.java @@ -14,27 +14,25 @@ import noppes.npcs.entity.EntityNPCInterface; // EntityAnimal, Item, EntityPlayer, InventoryPlayer, // ItemStack, World, NBTTagCompound -public class EntityNpcMonsterMale extends EntityNPCInterface -{ - public EntityNpcMonsterMale(World world) - { +public class EntityNpcMonsterMale extends EntityNPCInterface { + public EntityNpcMonsterMale(World world) { super(world); display.texture = "customnpcs:textures/entity/monstermale/ZombieSteve.png"; } - public void onUpdate(){ - isDead = true; + public void onUpdate() { + isDead = true; - if(!worldObj.isRemote){ - NBTTagCompound compound = new NBTTagCompound(); + if (!worldObj.isRemote) { + NBTTagCompound compound = new NBTTagCompound(); - writeToNBT(compound); - EntityCustomNpc npc = new EntityCustomNpc(worldObj); - npc.readFromNBT(compound); - npc.ais.animationType = EnumAnimation.HUG; - worldObj.spawnEntityInWorld(npc); - } - super.onUpdate(); + writeToNBT(compound); + EntityCustomNpc npc = new EntityCustomNpc(worldObj); + npc.readFromNBT(compound); + npc.ais.animationType = EnumAnimation.HUG; + worldObj.spawnEntityInWorld(npc); + } + super.onUpdate(); } } diff --git a/src/main/java/noppes/npcs/entity/old/EntityNpcNagaFemale.java b/src/main/java/noppes/npcs/entity/old/EntityNpcNagaFemale.java index 45b98176b..cf100a9f4 100644 --- a/src/main/java/noppes/npcs/entity/old/EntityNpcNagaFemale.java +++ b/src/main/java/noppes/npcs/entity/old/EntityNpcNagaFemale.java @@ -15,36 +15,34 @@ import noppes.npcs.entity.data.ModelPartData; // EntityAnimal, Item, EntityPlayer, InventoryPlayer, // ItemStack, World, NBTTagCompound -public class EntityNpcNagaFemale extends EntityNPCInterface -{ - public EntityNpcNagaFemale(World world) - { +public class EntityNpcNagaFemale extends EntityNPCInterface { + public EntityNpcNagaFemale(World world) { super(world); scaleX = scaleY = scaleZ = 0.9075f; display.texture = "customnpcs:textures/entity/nagafemale/Claire.png"; } - public void onUpdate() - { - isDead = true; - if(!worldObj.isRemote){ - NBTTagCompound compound = new NBTTagCompound(); + public void onUpdate() { + isDead = true; - writeToNBT(compound); - EntityCustomNpc npc = new EntityCustomNpc(worldObj); - npc.readFromNBT(compound); - ModelData data = npc.modelData; - data.breasts = 2; - data.modelScale.head.setScale(0.95f,0.95f); - data.modelScale.legs.setScale(0.92f,0.92f); - data.modelScale.arms.setScale(0.80f,0.92f); - data.modelScale.body.setScale(0.92f, 0.92f); - ModelPartData legs = data.legParts; - legs.playerTexture = true; - legs.type = 1; + if (!worldObj.isRemote) { + NBTTagCompound compound = new NBTTagCompound(); - worldObj.spawnEntityInWorld(npc); - } + writeToNBT(compound); + EntityCustomNpc npc = new EntityCustomNpc(worldObj); + npc.readFromNBT(compound); + ModelData data = npc.modelData; + data.breasts = 2; + data.modelScale.head.setScale(0.95f, 0.95f); + data.modelScale.legs.setScale(0.92f, 0.92f); + data.modelScale.arms.setScale(0.80f, 0.92f); + data.modelScale.body.setScale(0.92f, 0.92f); + ModelPartData legs = data.legParts; + legs.playerTexture = true; + legs.type = 1; + + worldObj.spawnEntityInWorld(npc); + } super.onUpdate(); } } diff --git a/src/main/java/noppes/npcs/entity/old/EntityNpcNagaMale.java b/src/main/java/noppes/npcs/entity/old/EntityNpcNagaMale.java index b741b3c22..2fd34156d 100644 --- a/src/main/java/noppes/npcs/entity/old/EntityNpcNagaMale.java +++ b/src/main/java/noppes/npcs/entity/old/EntityNpcNagaMale.java @@ -15,31 +15,28 @@ import noppes.npcs.entity.data.ModelPartData; // EntityAnimal, Item, EntityPlayer, InventoryPlayer, // ItemStack, World, NBTTagCompound -public class EntityNpcNagaMale extends EntityNPCInterface -{ - public EntityNpcNagaMale(World world) - { +public class EntityNpcNagaMale extends EntityNPCInterface { + public EntityNpcNagaMale(World world) { super(world); display.texture = "customnpcs:textures/entity/nagamale/Cobra.png"; } - public void onUpdate() - { - isDead = true; + public void onUpdate() { + isDead = true; - if(!worldObj.isRemote){ - NBTTagCompound compound = new NBTTagCompound(); + if (!worldObj.isRemote) { + NBTTagCompound compound = new NBTTagCompound(); - writeToNBT(compound); - EntityCustomNpc npc = new EntityCustomNpc(worldObj); - npc.readFromNBT(compound); - ModelData data = npc.modelData; - ModelPartData legs = data.legParts; - legs.playerTexture = true; - legs.type = 1; + writeToNBT(compound); + EntityCustomNpc npc = new EntityCustomNpc(worldObj); + npc.readFromNBT(compound); + ModelData data = npc.modelData; + ModelPartData legs = data.legParts; + legs.playerTexture = true; + legs.type = 1; - worldObj.spawnEntityInWorld(npc); - } + worldObj.spawnEntityInWorld(npc); + } super.onUpdate(); } } diff --git a/src/main/java/noppes/npcs/entity/old/EntityNpcSkeleton.java b/src/main/java/noppes/npcs/entity/old/EntityNpcSkeleton.java index f31b5ee01..e25946a1c 100644 --- a/src/main/java/noppes/npcs/entity/old/EntityNpcSkeleton.java +++ b/src/main/java/noppes/npcs/entity/old/EntityNpcSkeleton.java @@ -15,30 +15,27 @@ import noppes.npcs.entity.data.ModelData; // EntityAnimal, Item, EntityPlayer, InventoryPlayer, // ItemStack, World, NBTTagCompound -public class EntityNpcSkeleton extends EntityNPCInterface -{ - public EntityNpcSkeleton(World world) - { +public class EntityNpcSkeleton extends EntityNPCInterface { + public EntityNpcSkeleton(World world) { super(world); display.texture = "customnpcs:textures/entity/skeleton/Skeleton.png"; } - public void onUpdate() - { - isDead = true; + public void onUpdate() { + isDead = true; - if(!worldObj.isRemote){ - NBTTagCompound compound = new NBTTagCompound(); + if (!worldObj.isRemote) { + NBTTagCompound compound = new NBTTagCompound(); - writeToNBT(compound); - EntityCustomNpc npc = new EntityCustomNpc(worldObj); - npc.readFromNBT(compound); - ModelData data = npc.modelData; - data.setEntityClass(EntitySkeleton.class); + writeToNBT(compound); + EntityCustomNpc npc = new EntityCustomNpc(worldObj); + npc.readFromNBT(compound); + ModelData data = npc.modelData; + data.setEntityClass(EntitySkeleton.class); - worldObj.spawnEntityInWorld(npc); - } + worldObj.spawnEntityInWorld(npc); + } super.onUpdate(); } } diff --git a/src/main/java/noppes/npcs/items/ItemBattleAxe.java b/src/main/java/noppes/npcs/items/ItemBattleAxe.java index 7d873cdcf..686de8864 100644 --- a/src/main/java/noppes/npcs/items/ItemBattleAxe.java +++ b/src/main/java/noppes/npcs/items/ItemBattleAxe.java @@ -3,15 +3,15 @@ package noppes.npcs.items; import org.lwjgl.opengl.GL11; -public class ItemBattleAxe extends ItemNpcWeaponInterface{ +public class ItemBattleAxe extends ItemNpcWeaponInterface { - public ItemBattleAxe(int par1, ToolMaterial tool) { - super(par1, tool); - } + public ItemBattleAxe(int par1, ToolMaterial tool) { + super(par1, tool); + } - public void renderSpecial(){ - GL11.glScalef(1f, 0.8f,1f); + public void renderSpecial() { + GL11.glScalef(1f, 0.8f, 1f); GL11.glTranslatef(-0.04f, 0.2f, -0.16f); GL11.glRotatef(180, 0, 1, 0); - } + } } diff --git a/src/main/java/noppes/npcs/items/ItemBroadSword.java b/src/main/java/noppes/npcs/items/ItemBroadSword.java index 25f6457f1..d42379524 100644 --- a/src/main/java/noppes/npcs/items/ItemBroadSword.java +++ b/src/main/java/noppes/npcs/items/ItemBroadSword.java @@ -3,16 +3,16 @@ package noppes.npcs.items; import org.lwjgl.opengl.GL11; -public class ItemBroadSword extends ItemNpcWeaponInterface{ +public class ItemBroadSword extends ItemNpcWeaponInterface { - public ItemBroadSword(ToolMaterial tool) { - super(tool); - } - - public void renderSpecial(){ + public ItemBroadSword(ToolMaterial tool) { + super(tool); + } + + public void renderSpecial() { GL11.glScalef(1f, 1.2f, 1f); GL11.glTranslatef(-0.12f, 0.14f, -0.16f); GL11.glRotatef(180, 0, 1, 0); - } - + } + } diff --git a/src/main/java/noppes/npcs/items/ItemBullet.java b/src/main/java/noppes/npcs/items/ItemBullet.java index 443621040..6f7b843be 100644 --- a/src/main/java/noppes/npcs/items/ItemBullet.java +++ b/src/main/java/noppes/npcs/items/ItemBullet.java @@ -4,15 +4,17 @@ import noppes.npcs.CustomItems; import noppes.npcs.constants.EnumNpcToolMaterial; -public class ItemBullet extends ItemNpcInterface{ - private EnumNpcToolMaterial material; - public ItemBullet(int par1, EnumNpcToolMaterial material) { - super(par1); - this.material = material; - setCreativeTab(CustomItems.tabWeapon); - } - public int getBulletDamage(){ - return material.getDamageVsEntity(); - } +public class ItemBullet extends ItemNpcInterface { + private EnumNpcToolMaterial material; + + public ItemBullet(int par1, EnumNpcToolMaterial material) { + super(par1); + this.material = material; + setCreativeTab(CustomItems.tabWeapon); + } + + public int getBulletDamage() { + return material.getDamageVsEntity(); + } } diff --git a/src/main/java/noppes/npcs/items/ItemClaw.java b/src/main/java/noppes/npcs/items/ItemClaw.java index a7a65c21b..bbc468c10 100644 --- a/src/main/java/noppes/npcs/items/ItemClaw.java +++ b/src/main/java/noppes/npcs/items/ItemClaw.java @@ -2,17 +2,17 @@ package noppes.npcs.items; import org.lwjgl.opengl.GL11; -public class ItemClaw extends ItemNpcWeaponInterface{ +public class ItemClaw extends ItemNpcWeaponInterface { - public ItemClaw(int par1, ToolMaterial material) { - super(par1,material); - } + public ItemClaw(int par1, ToolMaterial material) { + super(par1, material); + } - @Override - public void renderSpecial(){ - GL11.glScalef(0.6f, 0.6f,0.6f); - GL11.glTranslatef(-0.6f, 0.2f, -0.2f); + @Override + public void renderSpecial() { + GL11.glScalef(0.6f, 0.6f, 0.6f); + GL11.glTranslatef(-0.6f, 0.2f, -0.2f); GL11.glRotatef(90, 0, 0, -1); GL11.glRotatef(6, 1, 0, 0); - } + } } diff --git a/src/main/java/noppes/npcs/items/ItemCrossbow.java b/src/main/java/noppes/npcs/items/ItemCrossbow.java index 6e54298aa..c68d9238c 100644 --- a/src/main/java/noppes/npcs/items/ItemCrossbow.java +++ b/src/main/java/noppes/npcs/items/ItemCrossbow.java @@ -10,89 +10,88 @@ import noppes.npcs.CustomItems; import noppes.npcs.entity.EntityProjectile; import org.lwjgl.opengl.GL11; -public class ItemCrossbow extends ItemNpcInterface{ +public class ItemCrossbow extends ItemNpcInterface { - public ItemCrossbow(int par1) { - super(par1); + public ItemCrossbow(int par1) { + super(par1); this.setMaxDamage(129); setCreativeTab(CustomItems.tabWeapon); - } + } + public void onPlayerStoppedUsing(ItemStack stack, World par2World, EntityPlayer player, int count) { - if(player.worldObj.isRemote) - return; - - if(stack.stackTagCompound.getInteger("IsLoaded") == 1 || player.capabilities.isCreativeMode) { - if(stack.stackTagCompound.getInteger("Reloading") == 1 && !player.capabilities.isCreativeMode) { - stack.stackTagCompound.setInteger("Reloading", 0); - return; - } - stack.damageItem(1, player); - EntityProjectile projectile = new EntityProjectile(player.worldObj, player, new ItemStack(Items.arrow, 1, 0), false); - projectile.damage = 10; - projectile.setSpeed(20); - projectile.setHasGravity(true); - projectile.shoot(2); - - if(!player.capabilities.isCreativeMode) - consumeItem(player, CustomItems.crossbowBolt); - - player.worldObj.playSoundAtEntity(player, "random.bow", 0.9F, itemRand.nextFloat() * 0.3F + 0.8F); - player.worldObj.spawnEntityInWorld(projectile); - stack.stackTagCompound.setInteger("IsLoaded", 0); - } + if (player.worldObj.isRemote) + return; + + if (stack.stackTagCompound.getInteger("IsLoaded") == 1 || player.capabilities.isCreativeMode) { + if (stack.stackTagCompound.getInteger("Reloading") == 1 && !player.capabilities.isCreativeMode) { + stack.stackTagCompound.setInteger("Reloading", 0); + return; + } + stack.damageItem(1, player); + EntityProjectile projectile = new EntityProjectile(player.worldObj, player, new ItemStack(Items.arrow, 1, 0), false); + projectile.damage = 10; + projectile.setSpeed(20); + projectile.setHasGravity(true); + projectile.shoot(2); + + if (!player.capabilities.isCreativeMode) + consumeItem(player, CustomItems.crossbowBolt); + + player.worldObj.playSoundAtEntity(player, "random.bow", 0.9F, itemRand.nextFloat() * 0.3F + 0.8F); + player.worldObj.spawnEntityInWorld(projectile); + stack.stackTagCompound.setInteger("IsLoaded", 0); + } } - @Override - public void onUsingTick(ItemStack stack, EntityPlayer player, int count) - { - if(player.worldObj.isRemote){ - return; - } - - int ticks = getMaxItemUseDuration(stack) - count; + @Override + public void onUsingTick(ItemStack stack, EntityPlayer player, int count) { + if (player.worldObj.isRemote) { + return; + } - if(!player.capabilities.isCreativeMode){ - if(stack.stackTagCompound.getInteger("Reloading") == 1 && hasItem(player, CustomItems.crossbowBolt)){ - if(ticks == 20){ - player.worldObj.playSoundAtEntity(player, "random.click", 1.0F,1); - stack.stackTagCompound.setInteger("IsLoaded", 1); - } - return; - } - } + int ticks = getMaxItemUseDuration(stack) - count; + + if (!player.capabilities.isCreativeMode) { + if (stack.stackTagCompound.getInteger("Reloading") == 1 && hasItem(player, CustomItems.crossbowBolt)) { + if (ticks == 20) { + player.worldObj.playSoundAtEntity(player, "random.click", 1.0F, 1); + stack.stackTagCompound.setInteger("IsLoaded", 1); + } + return; + } + } } - - @Override - public void renderSpecial(){ - GL11.glRotatef(96, 1f, 0, 0); - GL11.glRotatef(-10, 0, 1f, 0); - GL11.glScalef(0.8f, 0.8f,0.8f); - GL11.glTranslatef(0.5f, -0.7f, -0.4F); - } + + @Override + public void renderSpecial() { + GL11.glRotatef(96, 1f, 0, 0); + GL11.glRotatef(-10, 0, 1f, 0); + GL11.glScalef(0.8f, 0.8f, 0.8f); + GL11.glTranslatef(0.5f, -0.7f, -0.4F); + } + /** * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer */ - @Override - public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) - { - if(stack.stackTagCompound == null) - stack.stackTagCompound = new NBTTagCompound(); - if(!player.capabilities.isCreativeMode && hasItem(player, CustomItems.crossbowBolt) && stack.stackTagCompound.getInteger("IsLoaded") == 0) - stack.stackTagCompound.setInteger("Reloading", 1); - player.setItemInUse(stack, this.getMaxItemUseDuration(stack)); + @Override + public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { + if (stack.stackTagCompound == null) + stack.stackTagCompound = new NBTTagCompound(); + if (!player.capabilities.isCreativeMode && hasItem(player, CustomItems.crossbowBolt) && stack.stackTagCompound.getInteger("IsLoaded") == 0) + stack.stackTagCompound.setInteger("Reloading", 1); + player.setItemInUse(stack, this.getMaxItemUseDuration(stack)); return stack; } - @Override - public int getMaxItemUseDuration(ItemStack par1ItemStack) - { + + @Override + public int getMaxItemUseDuration(ItemStack par1ItemStack) { return 72000; } - public EnumAction getItemUseAction(ItemStack stack) - { - if(stack.stackTagCompound == null || stack.stackTagCompound.getInteger("Reloading") == 0) - return EnumAction.bow; - - return EnumAction.block; + public EnumAction getItemUseAction(ItemStack stack) { + if (stack.stackTagCompound == null || stack.stackTagCompound.getInteger("Reloading") == 0) + return EnumAction.bow; + + return EnumAction.block; } -} \ No newline at end of file +} diff --git a/src/main/java/noppes/npcs/items/ItemCustomizable.java b/src/main/java/noppes/npcs/items/ItemCustomizable.java index 921af8afa..35aa37d70 100644 --- a/src/main/java/noppes/npcs/items/ItemCustomizable.java +++ b/src/main/java/noppes/npcs/items/ItemCustomizable.java @@ -20,20 +20,20 @@ import noppes.npcs.scripted.NpcAPI; import noppes.npcs.scripted.event.ItemEvent; import org.lwjgl.opengl.GL11; -public abstract class ItemCustomizable extends Item implements ItemRenderInterface { +public abstract class ItemCustomizable extends Item implements ItemRenderInterface { @SideOnly(Side.CLIENT) - public void registerIcons(IIconRegister par1IconRegister){ + public void registerIcons(IIconRegister par1IconRegister) { this.itemIcon = Items.iron_pickaxe.getIconFromDamage(0); } @Override - public int getColorFromItemStack(ItemStack itemStack, int par2){ + public int getColorFromItemStack(ItemStack itemStack, int par2) { return 0x8B4513; } @Override - public boolean onEntitySwing(EntityLivingBase entityLivingBase, ItemStack stack){ + public boolean onEntitySwing(EntityLivingBase entityLivingBase, ItemStack stack) { if (entityLivingBase.worldObj.isRemote) { return false; } @@ -43,7 +43,7 @@ public abstract class ItemCustomizable extends Item implements ItemRenderInterfa return EventHooks.onScriptItemAttack((IItemCustomizable) istack, eve); } - public int getMaxItemUseDuration(ItemStack stack){ + public int getMaxItemUseDuration(ItemStack stack) { IItemCustomizable customizable = (IItemCustomizable) NpcAPI.Instance().getIItemStack(stack); return customizable.getMaxItemUseDuration(); } @@ -64,31 +64,27 @@ public abstract class ItemCustomizable extends Item implements ItemRenderInterfa return istack instanceof IItemCustomizable ? istack.getMaxStackSize() : super.getItemStackLimit(stack); } - public boolean isItemTool(ItemStack stack) - { + public boolean isItemTool(ItemStack stack) { IItemStack istack = NpcAPI.Instance().getIItemStack(stack); return istack instanceof IItemCustomizable ? ((IItemCustomizable) istack).isTool() : super.isItemTool(stack); } - public float getDigSpeed(ItemStack stack, Block block, int metadata) - { + public float getDigSpeed(ItemStack stack, Block block, int metadata) { IItemStack istack = NpcAPI.Instance().getIItemStack(stack); return istack instanceof IItemCustomizable ? ((IItemCustomizable) istack).getDigSpeed() : super.getDigSpeed(stack, block, metadata); } - public boolean isValidArmor(ItemStack stack, int armorType, Entity entity) - { + public boolean isValidArmor(ItemStack stack, int armorType, Entity entity) { IItemStack istack = NpcAPI.Instance().getIItemStack(stack); if (istack instanceof IItemCustomizable) { - if(((IItemCustomizable) istack).getArmorType() == -1) + if (((IItemCustomizable) istack).getArmorType() == -1) return true; return armorType == ((IItemCustomizable) istack).getArmorType(); } return super.isValidArmor(stack, armorType, entity); } - public int getItemEnchantability(ItemStack stack) - { + public int getItemEnchantability(ItemStack stack) { IItemStack istack = NpcAPI.Instance().getIItemStack(stack); return istack instanceof IItemCustomizable ? ((IItemCustomizable) istack).getEnchantability() : super.getItemEnchantability(stack); } @@ -100,25 +96,23 @@ public abstract class ItemCustomizable extends Item implements ItemRenderInterfa } @Override - public boolean requiresMultipleRenderPasses(){ + public boolean requiresMultipleRenderPasses() { return true; } @Override - public Item setUnlocalizedName(String name){ + public Item setUnlocalizedName(String name) { GameRegistry.registerItem(this, name); return super.setUnlocalizedName(name); } - public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) - { + public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { player.setItemInUse(stack, this.getMaxItemUseDuration(stack)); return stack; } - public EnumAction getItemUseAction(ItemStack stack) - { + public EnumAction getItemUseAction(ItemStack stack) { IItemStack istack = NpcAPI.Instance().getIItemStack(stack); if (istack instanceof IItemCustomizable) { switch (((IItemCustomizable) istack).getItemUseAction()) { @@ -138,7 +132,8 @@ public abstract class ItemCustomizable extends Item implements ItemRenderInterfa } @Override - public void renderSpecial() {} + public void renderSpecial() { + } public void renderOffset(IItemCustomizable scriptCustomItem) { GL11.glTranslatef(0.135F * scriptCustomItem.getScaleX(), 0.2F * scriptCustomItem.getScaleY(), 0.07F * scriptCustomItem.getScaleZ()); diff --git a/src/main/java/noppes/npcs/items/ItemDagger.java b/src/main/java/noppes/npcs/items/ItemDagger.java index b167da44c..f04b2f609 100644 --- a/src/main/java/noppes/npcs/items/ItemDagger.java +++ b/src/main/java/noppes/npcs/items/ItemDagger.java @@ -2,15 +2,15 @@ package noppes.npcs.items; import org.lwjgl.opengl.GL11; -public class ItemDagger extends ItemNpcWeaponInterface{ +public class ItemDagger extends ItemNpcWeaponInterface { - public ItemDagger(int par1, ToolMaterial tool) { - super(par1, tool); - } + public ItemDagger(int par1, ToolMaterial tool) { + super(par1, tool); + } - @Override - public void renderSpecial(){ + @Override + public void renderSpecial() { GL11.glScalef(0.6f, 0.6f, 0.6f); GL11.glTranslatef(0.14F, 0.22f, 0.06f); - } + } } diff --git a/src/main/java/noppes/npcs/items/ItemDaggerReversed.java b/src/main/java/noppes/npcs/items/ItemDaggerReversed.java index 09668c12a..b0f16f6ec 100644 --- a/src/main/java/noppes/npcs/items/ItemDaggerReversed.java +++ b/src/main/java/noppes/npcs/items/ItemDaggerReversed.java @@ -3,24 +3,24 @@ package noppes.npcs.items; import net.minecraft.client.renderer.texture.IIconRegister; import org.lwjgl.opengl.GL11; -public class ItemDaggerReversed extends ItemDagger{ +public class ItemDaggerReversed extends ItemDagger { - private ItemDagger dagger; - public ItemDaggerReversed(int par1, ItemDagger dagger, ToolMaterial tool) { - super(par1,tool); - this.dagger = dagger; - } + private ItemDagger dagger; - @Override - public void renderSpecial(){ + public ItemDaggerReversed(int par1, ItemDagger dagger, ToolMaterial tool) { + super(par1, tool); + this.dagger = dagger; + } + + @Override + public void renderSpecial() { GL11.glScalef(0.6f, 0.6f, 0.6f); GL11.glTranslatef(0.16f, 0.6f, -0.16f); GL11.glRotatef(180F, 1F, 0F, 0F); - } - - @Override - public void registerIcons(IIconRegister par1IconRegister) - { + } + + @Override + public void registerIcons(IIconRegister par1IconRegister) { this.itemIcon = dagger.getIconFromDamage(0); } } diff --git a/src/main/java/noppes/npcs/items/ItemElementalStaff.java b/src/main/java/noppes/npcs/items/ItemElementalStaff.java index 846e24255..45f45c17f 100644 --- a/src/main/java/noppes/npcs/items/ItemElementalStaff.java +++ b/src/main/java/noppes/npcs/items/ItemElementalStaff.java @@ -12,37 +12,37 @@ import noppes.npcs.constants.EnumNpcToolMaterial; import java.awt.*; import java.util.List; -public class ItemElementalStaff extends ItemStaff{ - public ItemElementalStaff(int par1, EnumNpcToolMaterial material) { - super(par1,material); - setHasSubtypes(true); - } +public class ItemElementalStaff extends ItemStaff { + public ItemElementalStaff(int par1, EnumNpcToolMaterial material) { + super(par1, material); + setHasSubtypes(true); + } @Override - public int getColorFromItemStack(ItemStack par1ItemStack, int par2){ - float[] color = EntitySheep.fleeceColorTable[par1ItemStack.getItemDamage()]; - return new Color(color[0],color[1],color[2]).getRGB(); + public int getColorFromItemStack(ItemStack par1ItemStack, int par2) { + float[] color = EntitySheep.fleeceColorTable[par1ItemStack.getItemDamage()]; + return new Color(color[0], color[1], color[2]).getRGB(); } - + @Override - public boolean requiresMultipleRenderPasses(){ + public boolean requiresMultipleRenderPasses() { return true; } - - @Override - public void getSubItems(Item par1, CreativeTabs par2CreativeTabs, List par3List){ - for (int var4 = 0; var4 < 16; ++var4){ + + @Override + public void getSubItems(Item par1, CreativeTabs par2CreativeTabs, List par3List) { + for (int var4 = 0; var4 < 16; ++var4) { par3List.add(new ItemStack(par1, 1, var4)); } } - @Override - public ItemStack getProjectile(ItemStack stack){ - return new ItemStack(CustomItems.orb,1,stack.getItemDamage()); - } - - @Override - public void spawnParticle(ItemStack stack, EntityPlayer player){ - CustomNpcs.proxy.spawnParticle(player,"Spell",stack.getItemDamage(),4); - } + @Override + public ItemStack getProjectile(ItemStack stack) { + return new ItemStack(CustomItems.orb, 1, stack.getItemDamage()); + } + + @Override + public void spawnParticle(ItemStack stack, EntityPlayer player) { + CustomNpcs.proxy.spawnParticle(player, "Spell", stack.getItemDamage(), 4); + } } diff --git a/src/main/java/noppes/npcs/items/ItemExcalibur.java b/src/main/java/noppes/npcs/items/ItemExcalibur.java index 31bc68d09..be6174ef0 100644 --- a/src/main/java/noppes/npcs/items/ItemExcalibur.java +++ b/src/main/java/noppes/npcs/items/ItemExcalibur.java @@ -2,37 +2,37 @@ package noppes.npcs.items; import org.lwjgl.opengl.GL11; -public class ItemExcalibur extends ItemNpcWeaponInterface{ - - public static String[] quotes = new String[]{ - "Victory and Glory!", - "Excalibur! Excalibur! From the United K! I'm looking for heaven! I'm going to California!", - "FOOL! As someone who is unaware of the vital role that singing has played in the cultural history of mankind you are in no position to question me.", - "SILENCE! This is number 349 of the 1,000 provisions you must observe. Meisters should eat everything regardless of personal likes and dislikes. Never say anything as selfish as \"I don't like carrots.\" again.", - "About the 1,000 provisions that you are required to observe. Now I would like for you to participate in the most important provision. Number 452 the 5 hour story telling party.", - "Thus at long last the fighting between the rival gangs had ended! To sum up, this leads us to number 778 of the 1,000 provisions you must observe. Never mail a letter without the return address or the proper postage. And don't call collect.", - "To sum up, that is what led to number 679 of the 1,000 provisions you must observe. Always place a dehumidifier in your room.", - "This brings us to number 278 of the 1,000 provisions you must observe. I hate carrots. Never even think about putting them in my food, you get it?", - "Thus I found myself carrying the entire weight of the troop as I preformed my dance before a capacity crowd at the opera house.", - "A symphony can not be created using common sense and probabilities. It is already written in the fate of the composer. No... that's not it. A symphony is the inevitable result of a bad childhood, deafness, and too many beans eaten after a certain time of day.", - "Humming and the nightly news share a very tight connection indeed.", - "Number 58 of the 1,000 provisions I would like you to observe, never talk to me while I'm humming to myself. This is an important provision do you understand?", - "Hey! Hold on, come back! I'll tell you what! I can lower those 1,000 provisions down to 800, just as long as you take part in the five hour story telling party.", - "Before becoming my Meister there is a list of 1,000 provisions you must peruse. Be sure to look through all of them, they're important. I greatly look forward to your participation in number 452 the five hour story telling party.", - "Nothing beats a cup of herbal tea in the morning.", - "My legend dates back to the 12th Century you see. My legend is quite old. The 12th Century was a long time ago.", - "Young ones! Do you want to hear the legend of me? Do you want to hear a heroic tale?", - "No autographs!", - "The only thing you can change about the past is how you feel about it in the present.", - "My mornings begin with a cup of coffee with cream at the cafe. My afternoon begins with hot tea with two lumps of sugar. And my evenings... In the evening I change into my pajamas.", - }; +public class ItemExcalibur extends ItemNpcWeaponInterface { - public ItemExcalibur(int par1, ToolMaterial tool) { - super(par1, tool); - } + public static String[] quotes = new String[]{ + "Victory and Glory!", + "Excalibur! Excalibur! From the United K! I'm looking for heaven! I'm going to California!", + "FOOL! As someone who is unaware of the vital role that singing has played in the cultural history of mankind you are in no position to question me.", + "SILENCE! This is number 349 of the 1,000 provisions you must observe. Meisters should eat everything regardless of personal likes and dislikes. Never say anything as selfish as \"I don't like carrots.\" again.", + "About the 1,000 provisions that you are required to observe. Now I would like for you to participate in the most important provision. Number 452 the 5 hour story telling party.", + "Thus at long last the fighting between the rival gangs had ended! To sum up, this leads us to number 778 of the 1,000 provisions you must observe. Never mail a letter without the return address or the proper postage. And don't call collect.", + "To sum up, that is what led to number 679 of the 1,000 provisions you must observe. Always place a dehumidifier in your room.", + "This brings us to number 278 of the 1,000 provisions you must observe. I hate carrots. Never even think about putting them in my food, you get it?", + "Thus I found myself carrying the entire weight of the troop as I preformed my dance before a capacity crowd at the opera house.", + "A symphony can not be created using common sense and probabilities. It is already written in the fate of the composer. No... that's not it. A symphony is the inevitable result of a bad childhood, deafness, and too many beans eaten after a certain time of day.", + "Humming and the nightly news share a very tight connection indeed.", + "Number 58 of the 1,000 provisions I would like you to observe, never talk to me while I'm humming to myself. This is an important provision do you understand?", + "Hey! Hold on, come back! I'll tell you what! I can lower those 1,000 provisions down to 800, just as long as you take part in the five hour story telling party.", + "Before becoming my Meister there is a list of 1,000 provisions you must peruse. Be sure to look through all of them, they're important. I greatly look forward to your participation in number 452 the five hour story telling party.", + "Nothing beats a cup of herbal tea in the morning.", + "My legend dates back to the 12th Century you see. My legend is quite old. The 12th Century was a long time ago.", + "Young ones! Do you want to hear the legend of me? Do you want to hear a heroic tale?", + "No autographs!", + "The only thing you can change about the past is how you feel about it in the present.", + "My mornings begin with a cup of coffee with cream at the cafe. My afternoon begins with hot tea with two lumps of sugar. And my evenings... In the evening I change into my pajamas.", + }; - @Override - public void renderSpecial(){ + public ItemExcalibur(int par1, ToolMaterial tool) { + super(par1, tool); + } + + @Override + public void renderSpecial() { GL11.glTranslatef(0.2F, 0.3f, 0.1f); - } + } } diff --git a/src/main/java/noppes/npcs/items/ItemGlaive.java b/src/main/java/noppes/npcs/items/ItemGlaive.java index a83ce0386..0d14175d8 100644 --- a/src/main/java/noppes/npcs/items/ItemGlaive.java +++ b/src/main/java/noppes/npcs/items/ItemGlaive.java @@ -2,14 +2,14 @@ package noppes.npcs.items; import org.lwjgl.opengl.GL11; -public class ItemGlaive extends ItemNpcWeaponInterface{ +public class ItemGlaive extends ItemNpcWeaponInterface { - public ItemGlaive(int par1, ToolMaterial tool) { - super(par1, tool); - } + public ItemGlaive(int par1, ToolMaterial tool) { + super(par1, tool); + } - @Override - public void renderSpecial(){ + @Override + public void renderSpecial() { GL11.glTranslatef(0.03F, -0.4f, 0.08f); - } + } } diff --git a/src/main/java/noppes/npcs/items/ItemGun.java b/src/main/java/noppes/npcs/items/ItemGun.java index a3651e4a7..f890c7193 100644 --- a/src/main/java/noppes/npcs/items/ItemGun.java +++ b/src/main/java/noppes/npcs/items/ItemGun.java @@ -16,127 +16,130 @@ import noppes.npcs.entity.EntityProjectile; import noppes.npcs.util.IProjectileCallback; import org.lwjgl.opengl.GL11; -public class ItemGun extends ItemNpcInterface implements IProjectileCallback{ +public class ItemGun extends ItemNpcInterface implements IProjectileCallback { - private EnumNpcToolMaterial material; - public ItemGun(int par1, EnumNpcToolMaterial material) { - super(par1); + private EnumNpcToolMaterial material; + + public ItemGun(int par1, EnumNpcToolMaterial material) { + super(par1); this.maxStackSize = 1; - this.material = material; + this.material = material; this.setMaxDamage(material.getMaxUses()); setCreativeTab(CustomItems.tabWeapon); - } - @Override + } + + @Override public void onPlayerStoppedUsing(ItemStack stack, World worldObj, EntityPlayer player, int par4) { - if(worldObj.isRemote) - return; + if (worldObj.isRemote) + return; - if (!hasBullet(player, stack) || !ConfigItem.GunsEnabled){ - worldObj.playSoundAtEntity(player, "customnpcs:gun.empty", 1.0F,1); - return; + if (!hasBullet(player, stack) || !ConfigItem.GunsEnabled) { + worldObj.playSoundAtEntity(player, "customnpcs:gun.empty", 1.0F, 1); + return; } - int ticks = getMaxItemUseDuration(stack) - par4; - if(ticks < 10){ - return; - } - stack.damageItem(1, player); - ItemBullet bullet = (ItemBullet) getBullet(); - int damage = (bullet.getBulletDamage() + material.getDamageVsEntity() + 1) / 2 + 5; - damage += damage * EnchantInterface.getLevel(EnchantInterface.Damage, stack) * 0.5f; - EntityProjectile projectile = new EntityProjectile(worldObj, player, new ItemStack(getBullet()), false); - projectile.damage = damage; - projectile.callback = this; - projectile.callbackItem = stack; - projectile.setSpeed(40); - projectile.shoot(material.getDamageVsEntity() + 1); + int ticks = getMaxItemUseDuration(stack) - par4; + if (ticks < 10) { + return; + } + stack.damageItem(1, player); + ItemBullet bullet = (ItemBullet) getBullet(); + int damage = (bullet.getBulletDamage() + material.getDamageVsEntity() + 1) / 2 + 5; + damage += damage * EnchantInterface.getLevel(EnchantInterface.Damage, stack) * 0.5f; + EntityProjectile projectile = new EntityProjectile(worldObj, player, new ItemStack(getBullet()), false); + projectile.damage = damage; + projectile.callback = this; + projectile.callbackItem = stack; + projectile.setSpeed(40); + projectile.shoot(material.getDamageVsEntity() + 1); - if(!player.capabilities.isCreativeMode && !hasInfinite(stack)) - consumeItem(player, getBullet()); + if (!player.capabilities.isCreativeMode && !hasInfinite(stack)) + consumeItem(player, getBullet()); - worldObj.playSoundAtEntity(player, "customnpcs:gun.pistol.shot", 1.0F,itemRand.nextFloat() * 0.3F + 0.8F); - worldObj.spawnEntityInWorld(projectile); + worldObj.playSoundAtEntity(player, "customnpcs:gun.pistol.shot", 1.0F, itemRand.nextFloat() * 0.3F + 0.8F); + worldObj.spawnEntityInWorld(projectile); } - @Override - public void onUsingTick(ItemStack stack, EntityPlayer player, int count) - { - int ticks = getMaxItemUseDuration(stack) - count; - if(ticks == 8 && !player.worldObj.isRemote){ - player.worldObj.playSoundAtEntity(player, "customnpcs:gun.pistol.trigger", 1.0F, - 1.0F / (player.worldObj.rand.nextFloat() * 0.4F + 0.8F)); - } + @Override + public void onUsingTick(ItemStack stack, EntityPlayer player, int count) { + int ticks = getMaxItemUseDuration(stack) - count; + if (ticks == 8 && !player.worldObj.isRemote) { + player.worldObj.playSoundAtEntity(player, "customnpcs:gun.pistol.trigger", 1.0F, + 1.0F / (player.worldObj.rand.nextFloat() * 0.4F + 0.8F)); + } + } + + @Override + public void renderSpecial() { + GL11.glScalef(0.7f, 0.7f, 0.7f); + GL11.glTranslatef(0.3f, 0.3f, 0.1f); } - @Override - public void renderSpecial(){ - GL11.glScalef(0.7f, 0.7f,0.7f); - GL11.glTranslatef(0.3f, 0.3f, 0.1f); - } /** * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer */ - @Override - public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) - { - par3EntityPlayer.setItemInUse(par1ItemStack, this.getMaxItemUseDuration(par1ItemStack)); + @Override + public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { + par3EntityPlayer.setItemInUse(par1ItemStack, this.getMaxItemUseDuration(par1ItemStack)); return par1ItemStack; } - @Override - public int getMaxItemUseDuration(ItemStack par1ItemStack) - { - return 72000; - } - private boolean hasBullet(EntityPlayer player, ItemStack stack){ - if(player.capabilities.isCreativeMode || hasInfinite(stack)) - return true; - return hasItem(player, getBullet()); - } - private Item getBullet(){ - switch(material){ - case EMERALD: - return CustomItems.bulletEmerald; - case DIA: - return CustomItems.bulletDiamond; - case IRON: - return CustomItems.bulletIron; - case BRONZE: - return CustomItems.bulletBronze; - case GOLD: - return CustomItems.bulletGold; - case STONE: - return CustomItems.bulletStone; - case WOOD: - return CustomItems.bulletWood; - default: - return CustomItems.bulletBlack; - } - } - - public boolean hasInfinite(ItemStack stack){ - return EnchantInterface.getLevel(EnchantInterface.Infinite, stack) > 0; - } @Override - public int getItemEnchantability(){ + public int getMaxItemUseDuration(ItemStack par1ItemStack) { + return 72000; + } + + private boolean hasBullet(EntityPlayer player, ItemStack stack) { + if (player.capabilities.isCreativeMode || hasInfinite(stack)) + return true; + return hasItem(player, getBullet()); + } + + private Item getBullet() { + switch (material) { + case EMERALD: + return CustomItems.bulletEmerald; + case DIA: + return CustomItems.bulletDiamond; + case IRON: + return CustomItems.bulletIron; + case BRONZE: + return CustomItems.bulletBronze; + case GOLD: + return CustomItems.bulletGold; + case STONE: + return CustomItems.bulletStone; + case WOOD: + return CustomItems.bulletWood; + default: + return CustomItems.bulletBlack; + } + } + + public boolean hasInfinite(ItemStack stack) { + return EnchantInterface.getLevel(EnchantInterface.Infinite, stack) > 0; + } + + @Override + public int getItemEnchantability() { return this.material.getEnchantability(); } - public EnumAction getItemUseAction(ItemStack par1ItemStack) - { + public EnumAction getItemUseAction(ItemStack par1ItemStack) { return EnumAction.bow; } - @Override - public boolean onImpact(EntityProjectile entityProjectile, EntityLivingBase entity, ItemStack itemstack) { - int confusion = EnchantInterface.getLevel(EnchantInterface.Confusion, itemstack); - if(confusion > 0){ - if(entity.getRNG().nextInt(4) > confusion) - entity.addPotionEffect(new PotionEffect(Potion.confusion.id, 100)); - } - int poison = EnchantInterface.getLevel(EnchantInterface.Poison, itemstack); - if(poison > 0){ - if(entity.getRNG().nextInt(4) > poison) - entity.addPotionEffect(new PotionEffect(Potion.poison.id, 100)); - } - return false; - } + + @Override + public boolean onImpact(EntityProjectile entityProjectile, EntityLivingBase entity, ItemStack itemstack) { + int confusion = EnchantInterface.getLevel(EnchantInterface.Confusion, itemstack); + if (confusion > 0) { + if (entity.getRNG().nextInt(4) > confusion) + entity.addPotionEffect(new PotionEffect(Potion.confusion.id, 100)); + } + int poison = EnchantInterface.getLevel(EnchantInterface.Poison, itemstack); + if (poison > 0) { + if (entity.getRNG().nextInt(4) > poison) + entity.addPotionEffect(new PotionEffect(Potion.poison.id, 100)); + } + return false; + } } diff --git a/src/main/java/noppes/npcs/items/ItemGunChainsaw.java b/src/main/java/noppes/npcs/items/ItemGunChainsaw.java index 9ac87e920..6e6fee8a1 100644 --- a/src/main/java/noppes/npcs/items/ItemGunChainsaw.java +++ b/src/main/java/noppes/npcs/items/ItemGunChainsaw.java @@ -4,30 +4,29 @@ import net.minecraft.entity.EntityLivingBase; import net.minecraft.item.ItemStack; import org.lwjgl.opengl.GL11; -public class ItemGunChainsaw extends ItemNpcWeaponInterface{ +public class ItemGunChainsaw extends ItemNpcWeaponInterface { - public ItemGunChainsaw(int par1, ToolMaterial tool) { - super(par1, tool); - } + public ItemGunChainsaw(int par1, ToolMaterial tool) { + super(par1, tool); + } @Override - public boolean hitEntity(ItemStack par1ItemStack, EntityLivingBase par2EntityLiving, EntityLivingBase par3EntityLiving) - { - if(par2EntityLiving.getHealth() <= 0) - return false; + public boolean hitEntity(ItemStack par1ItemStack, EntityLivingBase par2EntityLiving, EntityLivingBase par3EntityLiving) { + if (par2EntityLiving.getHealth() <= 0) + return false; double x = par2EntityLiving.posX; - double y = par2EntityLiving.posY+ par2EntityLiving.height / 2; + double y = par2EntityLiving.posY + par2EntityLiving.height / 2; double z = par2EntityLiving.posZ; - - par3EntityLiving.worldObj.playSoundEffect(x, y, z, "random.explode", 0.8F, (1.0F + (par3EntityLiving.worldObj.rand.nextFloat() - par3EntityLiving.worldObj.rand.nextFloat()) * 0.2F) * 0.7F); - par3EntityLiving.worldObj.spawnParticle("largeexplode", x, y , z, 0.0D, 0.0D, 0.0D); - return super.hitEntity(par1ItemStack, par2EntityLiving, par3EntityLiving); - } - public void renderSpecial(){ - super.renderSpecial(); + par3EntityLiving.worldObj.playSoundEffect(x, y, z, "random.explode", 0.8F, (1.0F + (par3EntityLiving.worldObj.rand.nextFloat() - par3EntityLiving.worldObj.rand.nextFloat()) * 0.2F) * 0.7F); + par3EntityLiving.worldObj.spawnParticle("largeexplode", x, y, z, 0.0D, 0.0D, 0.0D); + return super.hitEntity(par1ItemStack, par2EntityLiving, par3EntityLiving); + } + + public void renderSpecial() { + super.renderSpecial(); GL11.glTranslatef(-0.1f, 0f, -0.16f); GL11.glRotatef(180, 0, 1, 0); GL11.glRotatef(-16, 0, 0, 1); - } + } } diff --git a/src/main/java/noppes/npcs/items/ItemKunai.java b/src/main/java/noppes/npcs/items/ItemKunai.java index 1e8ae7a5e..92eaadb36 100644 --- a/src/main/java/noppes/npcs/items/ItemKunai.java +++ b/src/main/java/noppes/npcs/items/ItemKunai.java @@ -6,59 +6,59 @@ import net.minecraft.world.World; import noppes.npcs.entity.EntityProjectile; import org.lwjgl.opengl.GL11; -public class ItemKunai extends ItemNpcWeaponInterface{ +public class ItemKunai extends ItemNpcWeaponInterface { - public ItemKunai(int par1, ToolMaterial tool) { - super(par1, tool); - } - - public void onPlayerStoppedUsing(ItemStack par1ItemStack, World worldObj, EntityPlayer player, int par4) - { - if(worldObj.isRemote){ - player.swingItem(); - return; - } - EntityProjectile projectile = new EntityProjectile(worldObj, player, par1ItemStack, false); - projectile.damage = func_150931_i(); - projectile.destroyedOnEntityHit = false; - projectile.canBePickedUp = !player.capabilities.isCreativeMode; - projectile.setIs3D(true); - projectile.setStickInWall(true); - projectile.setHasGravity(true); - projectile.setSpeed(12); - projectile.shoot(1); - - if(!player.capabilities.isCreativeMode){ - par1ItemStack.damageItem(1, player); - if(par1ItemStack.stackSize == 0) - return; - player.inventory.mainInventory[player.inventory.currentItem] = null; - //item.dropItem = par1ItemStack; - } - - worldObj.playSoundAtEntity(player, "customnpcs:misc.swosh", 1.0F,1); - - worldObj.spawnEntityInWorld(projectile); + public ItemKunai(int par1, ToolMaterial tool) { + super(par1, tool); } - - @Override - public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) - { - par3EntityPlayer.setItemInUse(par1ItemStack, this.getMaxItemUseDuration(par1ItemStack)); + + public void onPlayerStoppedUsing(ItemStack par1ItemStack, World worldObj, EntityPlayer player, int par4) { + if (worldObj.isRemote) { + player.swingItem(); + return; + } + EntityProjectile projectile = new EntityProjectile(worldObj, player, par1ItemStack, false); + projectile.damage = func_150931_i(); + projectile.destroyedOnEntityHit = false; + projectile.canBePickedUp = !player.capabilities.isCreativeMode; + projectile.setIs3D(true); + projectile.setStickInWall(true); + projectile.setHasGravity(true); + projectile.setSpeed(12); + projectile.shoot(1); + + if (!player.capabilities.isCreativeMode) { + par1ItemStack.damageItem(1, player); + if (par1ItemStack.stackSize == 0) + return; + player.inventory.mainInventory[player.inventory.currentItem] = null; + //item.dropItem = par1ItemStack; + } + + worldObj.playSoundAtEntity(player, "customnpcs:misc.swosh", 1.0F, 1); + + worldObj.spawnEntityInWorld(projectile); + } + + @Override + public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { + par3EntityPlayer.setItemInUse(par1ItemStack, this.getMaxItemUseDuration(par1ItemStack)); return par1ItemStack; } - @Override - public int getMaxItemUseDuration(ItemStack par1ItemStack) - { + + @Override + public int getMaxItemUseDuration(ItemStack par1ItemStack) { return 72000; } - @Override - public void renderSpecial(){ + + @Override + public void renderSpecial() { GL11.glScalef(0.4f, 0.4f, 0.4f); GL11.glTranslatef(-0.4F, 0.5f, 0.1f); - } - @Override - public boolean shouldRotateAroundWhenRendering(){ - return true; - } + } + + @Override + public boolean shouldRotateAroundWhenRendering() { + return true; + } } diff --git a/src/main/java/noppes/npcs/items/ItemKunaiReversed.java b/src/main/java/noppes/npcs/items/ItemKunaiReversed.java index cdd948603..a1285ff2a 100644 --- a/src/main/java/noppes/npcs/items/ItemKunaiReversed.java +++ b/src/main/java/noppes/npcs/items/ItemKunaiReversed.java @@ -4,23 +4,23 @@ import net.minecraft.client.renderer.texture.IIconRegister; import noppes.npcs.CustomItems; import org.lwjgl.opengl.GL11; -public class ItemKunaiReversed extends ItemKunai{ +public class ItemKunaiReversed extends ItemKunai { - public ItemKunaiReversed(int par1, ToolMaterial tool) { - super(par1, tool); + public ItemKunaiReversed(int par1, ToolMaterial tool) { + super(par1, tool); - } + } - @Override - public void renderSpecial(){ + @Override + public void renderSpecial() { GL11.glScalef(0.4f, 0.4f, 0.4f); GL11.glRotatef(180F, 1F, 0F, 0F); - + GL11.glTranslatef(-0.4f, -0.9f, 0.2f); - } - @Override - public void registerIcons(IIconRegister par1IconRegister) - { - this.itemIcon = CustomItems.kunai.getIconFromDamage(0); + } + + @Override + public void registerIcons(IIconRegister par1IconRegister) { + this.itemIcon = CustomItems.kunai.getIconFromDamage(0); } } diff --git a/src/main/java/noppes/npcs/items/ItemLeafBlade.java b/src/main/java/noppes/npcs/items/ItemLeafBlade.java index 66e0b06be..717a4a9d9 100644 --- a/src/main/java/noppes/npcs/items/ItemLeafBlade.java +++ b/src/main/java/noppes/npcs/items/ItemLeafBlade.java @@ -2,17 +2,17 @@ package noppes.npcs.items; import org.lwjgl.opengl.GL11; -public class ItemLeafBlade extends ItemNpcWeaponInterface{ +public class ItemLeafBlade extends ItemNpcWeaponInterface { - public ItemLeafBlade(int par1, ToolMaterial tool) { - super(par1, tool); - } + public ItemLeafBlade(int par1, ToolMaterial tool) { + super(par1, tool); + } - @Override - public void renderSpecial(){ + @Override + public void renderSpecial() { GL11.glScalef(0.8f, 0.8f, 0.8f); GL11.glTranslatef(-0.2F, 0.28f, -0.12f); GL11.glRotatef(180, 0, 1, 0); GL11.glRotatef(-16, 0, 0, 1); - } + } } diff --git a/src/main/java/noppes/npcs/items/ItemLinked.java b/src/main/java/noppes/npcs/items/ItemLinked.java index ed9cdeddc..011f971ea 100644 --- a/src/main/java/noppes/npcs/items/ItemLinked.java +++ b/src/main/java/noppes/npcs/items/ItemLinked.java @@ -26,22 +26,22 @@ public class ItemLinked extends ItemCustomizable { if (world.isRemote) return; - if(world.getTotalWorldTime() % 10 != 0) + if (world.getTotalWorldTime() % 10 != 0) return; IItemStack itemStack = NpcAPI.Instance().getIItemStack(stack); - if(itemStack instanceof ScriptLinkedItem){ + if (itemStack instanceof ScriptLinkedItem) { ScriptLinkedItem scriptLinkedItem = (ScriptLinkedItem) itemStack; LinkedItem linkedItem = LinkedItemController.getInstance().get(scriptLinkedItem.linkedItem.getId()); int prevVersion = scriptLinkedItem.linkedVersion; - if(linkedItem != null && scriptLinkedItem.linkedVersion != linkedItem.version){ + if (linkedItem != null && scriptLinkedItem.linkedVersion != linkedItem.version) { scriptLinkedItem.linkedItem = linkedItem.clone(); scriptLinkedItem.linkedVersion = linkedItem.version; scriptLinkedItem.saveItemData(); // Send Version Change Event EventHooks.onLinkedItemVersionChange(scriptLinkedItem, linkedItem.version, prevVersion); - } else if (linkedItem == null){ + } else if (linkedItem == null) { if (entity instanceof EntityPlayer) { EntityPlayer player = (EntityPlayer) entity; player.inventory.setInventorySlotContents(itemSlot, null); // Remove the item diff --git a/src/main/java/noppes/npcs/items/ItemMoneyBag.java b/src/main/java/noppes/npcs/items/ItemMoneyBag.java index df485a1a3..6bf52f9fe 100644 --- a/src/main/java/noppes/npcs/items/ItemMoneyBag.java +++ b/src/main/java/noppes/npcs/items/ItemMoneyBag.java @@ -9,27 +9,26 @@ import net.minecraft.world.World; import noppes.npcs.CustomItems; import noppes.npcs.client.NoppesUtil; -public class ItemMoneyBag extends Item{ - - public ItemMoneyBag(int i) - { +public class ItemMoneyBag extends Item { + + public ItemMoneyBag(int i) { //super(i - 26700 + CustomNpcs.ItemStartId); maxStackSize = 1; setCreativeTab(CustomItems.tab); } - @Override - public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) - { - if(par2World.isRemote) //Client check. Only server may create the moneybagcontents - return par1ItemStack; - - if(par1ItemStack.stackTagCompound == null) //You use the par1ItemStack.stackTagCompound to store your data in the item - par1ItemStack.stackTagCompound = new NBTTagCompound(); - - MoneyBagContents contents = new MoneyBagContents(par3EntityPlayer); - - NoppesUtil.openGUI(par3EntityPlayer, new GuiScreen()); - - return par1ItemStack; + + @Override + public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { + if (par2World.isRemote) //Client check. Only server may create the moneybagcontents + return par1ItemStack; + + if (par1ItemStack.stackTagCompound == null) //You use the par1ItemStack.stackTagCompound to store your data in the item + par1ItemStack.stackTagCompound = new NBTTagCompound(); + + MoneyBagContents contents = new MoneyBagContents(par3EntityPlayer); + + NoppesUtil.openGUI(par3EntityPlayer, new GuiScreen()); + + return par1ItemStack; } -} \ No newline at end of file +} diff --git a/src/main/java/noppes/npcs/items/ItemMounter.java b/src/main/java/noppes/npcs/items/ItemMounter.java index eabbc4d2d..1fd321ba8 100644 --- a/src/main/java/noppes/npcs/items/ItemMounter.java +++ b/src/main/java/noppes/npcs/items/ItemMounter.java @@ -10,32 +10,32 @@ import net.minecraft.item.ItemStack; import noppes.npcs.CustomItems; -public class ItemMounter extends Item{ - - public ItemMounter(){ +public class ItemMounter extends Item { + + public ItemMounter() { maxStackSize = 1; setCreativeTab(CustomItems.tab); } @Override - public int getColorFromItemStack(ItemStack par1ItemStack, int par2){ - return 0x8B4513; + public int getColorFromItemStack(ItemStack par1ItemStack, int par2) { + return 0x8B4513; } - + @Override - public boolean requiresMultipleRenderPasses(){ + public boolean requiresMultipleRenderPasses() { return true; } @SideOnly(Side.CLIENT) @Override - public void registerIcons(IIconRegister par1IconRegister){ + public void registerIcons(IIconRegister par1IconRegister) { this.itemIcon = Items.saddle.getIconFromDamage(0); } @Override - public Item setUnlocalizedName(String name){ - GameRegistry.registerItem(this, name); - return super.setUnlocalizedName(name); + public Item setUnlocalizedName(String name) { + GameRegistry.registerItem(this, name); + return super.setUnlocalizedName(name); } } diff --git a/src/main/java/noppes/npcs/items/ItemMusic.java b/src/main/java/noppes/npcs/items/ItemMusic.java index 13f6b13ec..95e4c662b 100644 --- a/src/main/java/noppes/npcs/items/ItemMusic.java +++ b/src/main/java/noppes/npcs/items/ItemMusic.java @@ -6,36 +6,35 @@ import net.minecraft.item.ItemStack; import net.minecraft.world.World; import noppes.npcs.CustomItems; -public class ItemMusic extends ItemNpcInterface{ - - private boolean shouldRotate = false; +public class ItemMusic extends ItemNpcInterface { - public ItemMusic() { - setCreativeTab(CustomItems.tabMisc); - } - public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer player) - { - if(par2World.isRemote) - return par1ItemStack; - - int note = par2World.rand.nextInt(24); - float var7 = (float)Math.pow(2.0D, (double)(note - 12) / 12.0D); + private boolean shouldRotate = false; + + public ItemMusic() { + setCreativeTab(CustomItems.tabMisc); + } + + public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer player) { + if (par2World.isRemote) + return par1ItemStack; + + int note = par2World.rand.nextInt(24); + float var7 = (float) Math.pow(2.0D, (double) (note - 12) / 12.0D); String var8 = "harp"; - - par2World.playSoundEffect(player.posX, player.posY, player.posZ, "note." + var8, 3.0F, var7); - par2World.spawnParticle("note", player.posY, player.posY + 1.2D, player.posY, (double)note / 24.0D, 0.0D, 0.0D); - - return par1ItemStack; + + par2World.playSoundEffect(player.posX, player.posY, player.posZ, "note." + var8, 3.0F, var7); + par2World.spawnParticle("note", player.posY, player.posY + 1.2D, player.posY, (double) note / 24.0D, 0.0D, 0.0D); + + return par1ItemStack; } - - public Item setRotated(){ - shouldRotate = true; - return this; + + public Item setRotated() { + shouldRotate = true; + return this; } - - public boolean shouldRotateAroundWhenRendering() - { + + public boolean shouldRotateAroundWhenRendering() { return shouldRotate; } diff --git a/src/main/java/noppes/npcs/items/ItemMusicBanjo.java b/src/main/java/noppes/npcs/items/ItemMusicBanjo.java index 6f20e5dab..1c7c64e9d 100644 --- a/src/main/java/noppes/npcs/items/ItemMusicBanjo.java +++ b/src/main/java/noppes/npcs/items/ItemMusicBanjo.java @@ -2,12 +2,12 @@ package noppes.npcs.items; import org.lwjgl.opengl.GL11; -public class ItemMusicBanjo extends ItemMusic{ +public class ItemMusicBanjo extends ItemMusic { - @Override - public void renderSpecial(){ - GL11.glScalef(0.85f, 0.85f,0.85f); + @Override + public void renderSpecial() { + GL11.glScalef(0.85f, 0.85f, 0.85f); GL11.glTranslatef(0.1f, 0.4f, -0.14f); GL11.glRotatef(-90, -1F, 0, 0F); - } + } } diff --git a/src/main/java/noppes/npcs/items/ItemMusicClarinet.java b/src/main/java/noppes/npcs/items/ItemMusicClarinet.java index 8e3ac568f..3f33cd5e4 100644 --- a/src/main/java/noppes/npcs/items/ItemMusicClarinet.java +++ b/src/main/java/noppes/npcs/items/ItemMusicClarinet.java @@ -6,29 +6,29 @@ import net.minecraft.item.ItemStack; import net.minecraft.world.World; import org.lwjgl.opengl.GL11; -public class ItemMusicClarinet extends ItemMusic{ +public class ItemMusicClarinet extends ItemMusic { - @Override - public void renderSpecial(){ + @Override + public void renderSpecial() { GL11.glScalef(0.8f, 0.9f, 0.8f); GL11.glRotatef(-90, 0, 1, 0); GL11.glRotatef(20, 1, 0, 0); GL11.glTranslatef(0.44f, -0.7f, -0.04f); - } - @Override - public EnumAction getItemUseAction(ItemStack par1ItemStack) - { + } + + @Override + public EnumAction getItemUseAction(ItemStack par1ItemStack) { return EnumAction.bow; } - @Override - public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) - { + + @Override + public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { par3EntityPlayer.setItemInUse(par1ItemStack, this.getMaxItemUseDuration(par1ItemStack)); return super.onItemRightClick(par1ItemStack, par2World, par3EntityPlayer); } - @Override - public int getMaxItemUseDuration(ItemStack par1ItemStack) - { + + @Override + public int getMaxItemUseDuration(ItemStack par1ItemStack) { return 72000; } } diff --git a/src/main/java/noppes/npcs/items/ItemMusicOracina.java b/src/main/java/noppes/npcs/items/ItemMusicOracina.java index 04c8202d4..394e63252 100644 --- a/src/main/java/noppes/npcs/items/ItemMusicOracina.java +++ b/src/main/java/noppes/npcs/items/ItemMusicOracina.java @@ -6,30 +6,30 @@ import net.minecraft.item.ItemStack; import net.minecraft.world.World; import org.lwjgl.opengl.GL11; -public class ItemMusicOracina extends ItemMusic{ +public class ItemMusicOracina extends ItemMusic { - @Override - public void renderSpecial(){ - GL11.glScalef(0.5f, 0.5f,0.5f); + @Override + public void renderSpecial() { + GL11.glScalef(0.5f, 0.5f, 0.5f); GL11.glRotatef(-30, -1, 0, -1F); GL11.glRotatef(90, 0, 1, 0F); - + GL11.glTranslatef(-0.0f, 0.3f, 0.3f); - } - @Override - public EnumAction getItemUseAction(ItemStack par1ItemStack) - { + } + + @Override + public EnumAction getItemUseAction(ItemStack par1ItemStack) { return EnumAction.bow; } - @Override - public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) - { + + @Override + public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { par3EntityPlayer.setItemInUse(par1ItemStack, this.getMaxItemUseDuration(par1ItemStack)); return super.onItemRightClick(par1ItemStack, par2World, par3EntityPlayer); } - @Override - public int getMaxItemUseDuration(ItemStack par1ItemStack) - { + + @Override + public int getMaxItemUseDuration(ItemStack par1ItemStack) { return 72000; } } diff --git a/src/main/java/noppes/npcs/items/ItemMusicViolin.java b/src/main/java/noppes/npcs/items/ItemMusicViolin.java index c198d0165..3aee11c10 100644 --- a/src/main/java/noppes/npcs/items/ItemMusicViolin.java +++ b/src/main/java/noppes/npcs/items/ItemMusicViolin.java @@ -6,31 +6,30 @@ import net.minecraft.item.ItemStack; import net.minecraft.world.World; import org.lwjgl.opengl.GL11; -public class ItemMusicViolin extends ItemMusic{ +public class ItemMusicViolin extends ItemMusic { - @Override - public void renderSpecial(){ - GL11.glScalef(0.66f, 0.66f,0.66f); + @Override + public void renderSpecial() { + GL11.glScalef(0.66f, 0.66f, 0.66f); GL11.glRotatef(-90, 0F, 0, 1F); GL11.glRotatef(90, 0, 1, 0F); - - GL11.glTranslatef(0.2f, -0.9f, -0.52f); - } - @Override - public EnumAction getItemUseAction(ItemStack par1ItemStack) - { + GL11.glTranslatef(0.2f, -0.9f, -0.52f); + } + + @Override + public EnumAction getItemUseAction(ItemStack par1ItemStack) { return EnumAction.bow; } - @Override - public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) - { + + @Override + public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { par3EntityPlayer.setItemInUse(par1ItemStack, this.getMaxItemUseDuration(par1ItemStack)); return super.onItemRightClick(par1ItemStack, par2World, par3EntityPlayer); } - @Override - public int getMaxItemUseDuration(ItemStack par1ItemStack) - { + + @Override + public int getMaxItemUseDuration(ItemStack par1ItemStack) { return 72000; } } diff --git a/src/main/java/noppes/npcs/items/ItemMusket.java b/src/main/java/noppes/npcs/items/ItemMusket.java index 176677813..84aa88ec5 100644 --- a/src/main/java/noppes/npcs/items/ItemMusket.java +++ b/src/main/java/noppes/npcs/items/ItemMusket.java @@ -11,93 +11,92 @@ import noppes.npcs.constants.EnumParticleType; import noppes.npcs.entity.EntityProjectile; import org.lwjgl.opengl.GL11; -public class ItemMusket extends ItemNpcInterface{ +public class ItemMusket extends ItemNpcInterface { - public ItemMusket(int par1) { - super(par1); + public ItemMusket(int par1) { + super(par1); this.setMaxDamage(129); setCreativeTab(CustomItems.tabWeapon); - } + } + public void onPlayerStoppedUsing(ItemStack stack, World par2World, EntityPlayer player, int count) { - if(player.worldObj.isRemote) - return; + if (player.worldObj.isRemote) + return; - if(!stack.stackTagCompound.getBoolean("IsLoaded2") && !player.capabilities.isCreativeMode || !ConfigItem.GunsEnabled) { - player.worldObj.playSoundAtEntity(player, "customnpcs:gun.empty", 1.0F,1); - return; - } + if (!stack.stackTagCompound.getBoolean("IsLoaded2") && !player.capabilities.isCreativeMode || !ConfigItem.GunsEnabled) { + player.worldObj.playSoundAtEntity(player, "customnpcs:gun.empty", 1.0F, 1); + return; + } - if(stack.stackTagCompound.getBoolean("Reloading2") && !player.capabilities.isCreativeMode) { - stack.stackTagCompound.setBoolean("Reloading2", false); - return; - } - stack.damageItem(1, player); - EntityProjectile projectile = new EntityProjectile(player.worldObj, player, new ItemStack(CustomItems.bulletBlack,1, 0), false); - projectile.damage = 16; - projectile.setSpeed(50); - projectile.setParticleEffect(EnumParticleType.Smoke); - projectile.shoot(2); + if (stack.stackTagCompound.getBoolean("Reloading2") && !player.capabilities.isCreativeMode) { + stack.stackTagCompound.setBoolean("Reloading2", false); + return; + } + stack.damageItem(1, player); + EntityProjectile projectile = new EntityProjectile(player.worldObj, player, new ItemStack(CustomItems.bulletBlack, 1, 0), false); + projectile.damage = 16; + projectile.setSpeed(50); + projectile.setParticleEffect(EnumParticleType.Smoke); + projectile.shoot(2); - if(!player.capabilities.isCreativeMode) - consumeItem(player, CustomItems.bulletBlack); + if (!player.capabilities.isCreativeMode) + consumeItem(player, CustomItems.bulletBlack); - player.worldObj.playSoundAtEntity(player, "random.explode", 0.9F, itemRand.nextFloat() * 0.3F + 1.8F); - player.worldObj.playSoundAtEntity(player, "ambient.weather.thunder", 2.0F, itemRand.nextFloat() * 0.3F + 1.8F); - player.worldObj.spawnEntityInWorld(projectile); - stack.stackTagCompound.setBoolean("IsLoaded2", false); + player.worldObj.playSoundAtEntity(player, "random.explode", 0.9F, itemRand.nextFloat() * 0.3F + 1.8F); + player.worldObj.playSoundAtEntity(player, "ambient.weather.thunder", 2.0F, itemRand.nextFloat() * 0.3F + 1.8F); + player.worldObj.spawnEntityInWorld(projectile); + stack.stackTagCompound.setBoolean("IsLoaded2", false); } - @Override - public void onUsingTick(ItemStack stack, EntityPlayer player, int count) - { - if(player.worldObj.isRemote){ - return; - } + @Override + public void onUsingTick(ItemStack stack, EntityPlayer player, int count) { + if (player.worldObj.isRemote) { + return; + } - int ticks = getMaxItemUseDuration(stack) - count; + int ticks = getMaxItemUseDuration(stack) - count; - if(!player.capabilities.isCreativeMode){ - if(stack.stackTagCompound.getBoolean("Reloading2") && hasItem(player, CustomItems.bulletBlack)){ - if(ticks == 60){ - player.worldObj.playSoundAtEntity(player, "customnpcs:gun.ak47.load", 1.0F,1); - stack.stackTagCompound.setBoolean("IsLoaded2", true); - } - return; - } - } + if (!player.capabilities.isCreativeMode) { + if (stack.stackTagCompound.getBoolean("Reloading2") && hasItem(player, CustomItems.bulletBlack)) { + if (ticks == 60) { + player.worldObj.playSoundAtEntity(player, "customnpcs:gun.ak47.load", 1.0F, 1); + stack.stackTagCompound.setBoolean("IsLoaded2", true); + } + return; + } + } + } + + @Override + public void renderSpecial() { + GL11.glRotatef(-6, 0, 0, 1f); + GL11.glScalef(0.7f, 0.7f, 0.7f); + GL11.glTranslatef(0.4f, 0.0f, 0.2F); } - @Override - public void renderSpecial(){ - GL11.glRotatef(-6, 0, 0, 1f); - GL11.glScalef(0.7f, 0.7f,0.7f); - GL11.glTranslatef(0.4f, 0.0f, 0.2F); - } /** * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer */ - @Override - public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) - { - if(stack.stackTagCompound == null) - stack.stackTagCompound = new NBTTagCompound(); - if(!player.capabilities.isCreativeMode && hasItem(player, CustomItems.bulletBlack) && !stack.stackTagCompound.getBoolean("IsLoaded2")) - stack.stackTagCompound.setBoolean("Reloading2", true); - player.setItemInUse(stack, this.getMaxItemUseDuration(stack)); + @Override + public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { + if (stack.stackTagCompound == null) + stack.stackTagCompound = new NBTTagCompound(); + if (!player.capabilities.isCreativeMode && hasItem(player, CustomItems.bulletBlack) && !stack.stackTagCompound.getBoolean("IsLoaded2")) + stack.stackTagCompound.setBoolean("Reloading2", true); + player.setItemInUse(stack, this.getMaxItemUseDuration(stack)); return stack; } - @Override - public int getMaxItemUseDuration(ItemStack par1ItemStack) - { + + @Override + public int getMaxItemUseDuration(ItemStack par1ItemStack) { return 72000; } - public EnumAction getItemUseAction(ItemStack stack) - { - if(stack.stackTagCompound == null || !stack.stackTagCompound.getBoolean("Reloading2")) - return EnumAction.bow; + public EnumAction getItemUseAction(ItemStack stack) { + if (stack.stackTagCompound == null || !stack.stackTagCompound.getBoolean("Reloading2")) + return EnumAction.bow; - return EnumAction.block; + return EnumAction.block; } } diff --git a/src/main/java/noppes/npcs/items/ItemNpcArmor.java b/src/main/java/noppes/npcs/items/ItemNpcArmor.java index 2a57d273d..25aa8e45a 100644 --- a/src/main/java/noppes/npcs/items/ItemNpcArmor.java +++ b/src/main/java/noppes/npcs/items/ItemNpcArmor.java @@ -7,28 +7,28 @@ import net.minecraft.item.ItemArmor; import net.minecraft.item.ItemStack; import noppes.npcs.CustomItems; -public class ItemNpcArmor extends ItemArmor{ +public class ItemNpcArmor extends ItemArmor { - private String texture; - public ItemNpcArmor(int par1, ArmorMaterial par2EnumArmorMaterial,int par4, String texture) { - super(par2EnumArmorMaterial, 0, par4); - this.texture = texture; - setCreativeTab(CustomItems.tabArmor); - } - - - @Override - public String getArmorTexture(ItemStack stack, Entity entity, int slot, String type) - { - if(armorType == 2) - return "customnpcs:textures/armor/" + texture + "_2.png"; - return "customnpcs:textures/armor/" + texture + "_1.png"; + private String texture; + + public ItemNpcArmor(int par1, ArmorMaterial par2EnumArmorMaterial, int par4, String texture) { + super(par2EnumArmorMaterial, 0, par4); + this.texture = texture; + setCreativeTab(CustomItems.tabArmor); } @Override - public Item setUnlocalizedName(String name){ - GameRegistry.registerItem(this, name); - return super.setUnlocalizedName(name); + public String getArmorTexture(ItemStack stack, Entity entity, int slot, String type) { + if (armorType == 2) + return "customnpcs:textures/armor/" + texture + "_2.png"; + return "customnpcs:textures/armor/" + texture + "_1.png"; + } + + + @Override + public Item setUnlocalizedName(String name) { + GameRegistry.registerItem(this, name); + return super.setUnlocalizedName(name); } } diff --git a/src/main/java/noppes/npcs/items/ItemNpcArmorColorable.java b/src/main/java/noppes/npcs/items/ItemNpcArmorColorable.java index 275c2cc65..d29d8f65f 100644 --- a/src/main/java/noppes/npcs/items/ItemNpcArmorColorable.java +++ b/src/main/java/noppes/npcs/items/ItemNpcArmorColorable.java @@ -12,61 +12,62 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.IIcon; import noppes.npcs.CustomItems; -public class ItemNpcArmorColorable extends ItemArmor{ +public class ItemNpcArmorColorable extends ItemArmor { - private String texture; - public ItemNpcArmorColorable(int par1, ArmorMaterial par2EnumArmorMaterial,int par4, String texture) { - super(par2EnumArmorMaterial, 0, par4); - this.texture = texture; - setCreativeTab(CustomItems.tabArmor); - } - - - @Override - public String getArmorTexture(ItemStack stack, Entity entity, int slot, String type){ - if(type != null) - return "customnpcs:textures/gui/invisible.png"; - if(armorType == 2) - return "customnpcs:textures/armor/" + texture + "_2.png"; - return "customnpcs:textures/armor/" + texture + "_1.png"; + private String texture; + + public ItemNpcArmorColorable(int par1, ArmorMaterial par2EnumArmorMaterial, int par4, String texture) { + super(par2EnumArmorMaterial, 0, par4); + this.texture = texture; + setCreativeTab(CustomItems.tabArmor); } - + + @Override - public int getColorFromItemStack(ItemStack par1ItemStack, int par2){ + public String getArmorTexture(ItemStack stack, Entity entity, int slot, String type) { + if (type != null) + return "customnpcs:textures/gui/invisible.png"; + if (armorType == 2) + return "customnpcs:textures/armor/" + texture + "_2.png"; + return "customnpcs:textures/armor/" + texture + "_1.png"; + } + + @Override + public int getColorFromItemStack(ItemStack par1ItemStack, int par2) { int j = this.getColor(par1ItemStack); if (j < 0) return 16777215; return j; } - - public int getColor(ItemStack par1ItemStack){ + + public int getColor(ItemStack par1ItemStack) { NBTTagCompound nbttagcompound = par1ItemStack.getTagCompound(); if (nbttagcompound == null) return 10511680; - else{ + else { NBTTagCompound nbttagcompound1 = nbttagcompound.getCompoundTag("display"); return nbttagcompound1 == null ? 10511680 : (nbttagcompound1.hasKey("color", 3) ? nbttagcompound1.getInteger("color") : 10511680); } } - @Override - public void removeColor(ItemStack par1ItemStack) { - NBTTagCompound nbttagcompound = par1ItemStack.getTagCompound(); - - if (nbttagcompound != null) { - NBTTagCompound nbttagcompound1 = nbttagcompound.getCompoundTag("display"); - - if (nbttagcompound1.hasKey("color")) { - nbttagcompound1.removeTag("color"); - } - } - } - - public void func_82813_b(ItemStack par1ItemStack, int par2){ + @Override + public void removeColor(ItemStack par1ItemStack) { NBTTagCompound nbttagcompound = par1ItemStack.getTagCompound(); - if (nbttagcompound == null){ + if (nbttagcompound != null) { + NBTTagCompound nbttagcompound1 = nbttagcompound.getCompoundTag("display"); + + if (nbttagcompound1.hasKey("color")) { + nbttagcompound1.removeTag("color"); + } + } + } + + public void func_82813_b(ItemStack par1ItemStack, int par2) { + NBTTagCompound nbttagcompound = par1ItemStack.getTagCompound(); + + if (nbttagcompound == null) { nbttagcompound = new NBTTagCompound(); par1ItemStack.setTagCompound(nbttagcompound); } @@ -77,34 +78,35 @@ public class ItemNpcArmorColorable extends ItemArmor{ nbttagcompound.setTag("display", nbttagcompound1); nbttagcompound1.setInteger("color", par2); - + } + @Override @SideOnly(Side.CLIENT) - public IIcon getIconFromDamageForRenderPass(int par1, int par2){ + public IIcon getIconFromDamageForRenderPass(int par1, int par2) { return this.getIconFromDamage(par1); } @Override @SideOnly(Side.CLIENT) - public boolean requiresMultipleRenderPasses(){ - return true; + public boolean requiresMultipleRenderPasses() { + return true; } - + @Override @SideOnly(Side.CLIENT) - public void registerIcons(IIconRegister par1IconRegister){ + public void registerIcons(IIconRegister par1IconRegister) { this.itemIcon = par1IconRegister.registerIcon(this.getIconString()); } @Override - public boolean hasColor(ItemStack par1ItemStack){ + public boolean hasColor(ItemStack par1ItemStack) { return !par1ItemStack.hasTagCompound() ? false : (!par1ItemStack.getTagCompound().hasKey("display", 10) ? false : par1ItemStack.getTagCompound().getCompoundTag("display").hasKey("color", 3)); } @Override - public Item setUnlocalizedName(String name){ - GameRegistry.registerItem(this, name); - return super.setUnlocalizedName(name); + public Item setUnlocalizedName(String name) { + GameRegistry.registerItem(this, name); + return super.setUnlocalizedName(name); } } diff --git a/src/main/java/noppes/npcs/items/ItemNpcBlock.java b/src/main/java/noppes/npcs/items/ItemNpcBlock.java index 5b9babebe..f20c89744 100644 --- a/src/main/java/noppes/npcs/items/ItemNpcBlock.java +++ b/src/main/java/noppes/npcs/items/ItemNpcBlock.java @@ -4,15 +4,16 @@ import net.minecraft.block.Block; import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; -public class ItemNpcBlock extends ItemBlock{ - public String[] names; - public ItemNpcBlock(Block block) { - super(block); - } - - public String getUnlocalizedName(ItemStack par1ItemStack){ - if(names != null && par1ItemStack.getItemDamage() < names.length) - return names[par1ItemStack.getItemDamage()]; +public class ItemNpcBlock extends ItemBlock { + public String[] names; + + public ItemNpcBlock(Block block) { + super(block); + } + + public String getUnlocalizedName(ItemStack par1ItemStack) { + if (names != null && par1ItemStack.getItemDamage() < names.length) + return names[par1ItemStack.getItemDamage()]; return this.field_150939_a.getUnlocalizedName(); } } diff --git a/src/main/java/noppes/npcs/items/ItemNpcCloner.java b/src/main/java/noppes/npcs/items/ItemNpcCloner.java index 8fcf1d50c..b8482475e 100644 --- a/src/main/java/noppes/npcs/items/ItemNpcCloner.java +++ b/src/main/java/noppes/npcs/items/ItemNpcCloner.java @@ -14,16 +14,16 @@ import noppes.npcs.CustomItems; import noppes.npcs.CustomNpcsPermissions; import noppes.npcs.NoppesUtilServer; -public class ItemNpcCloner extends Item{ +public class ItemNpcCloner extends Item { - public ItemNpcCloner(){ + public ItemNpcCloner() { maxStackSize = 1; setCreativeTab(CustomItems.tab); } - @Override - public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10){ - if(par3World.isRemote || !CustomNpcsPermissions.Instance.hasPermission(par2EntityPlayer, CustomNpcsPermissions.TOOL_CLONER)) + @Override + public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10) { + if (par3World.isRemote || !CustomNpcsPermissions.Instance.hasPermission(par2EntityPlayer, CustomNpcsPermissions.TOOL_CLONER)) return false; NoppesUtilServer.setClonerGui((EntityPlayerMP) par2EntityPlayer, par4, par5, par6); @@ -31,24 +31,24 @@ public class ItemNpcCloner extends Item{ } @Override - public int getColorFromItemStack(ItemStack par1ItemStack, int par2){ - return 0x8B4513; + public int getColorFromItemStack(ItemStack par1ItemStack, int par2) { + return 0x8B4513; } @Override - public boolean requiresMultipleRenderPasses(){ + public boolean requiresMultipleRenderPasses() { return true; } @SideOnly(Side.CLIENT) @Override - public void registerIcons(IIconRegister par1IconRegister){ + public void registerIcons(IIconRegister par1IconRegister) { this.itemIcon = Items.iron_axe.getIconFromDamage(0); } @Override - public Item setUnlocalizedName(String name){ - GameRegistry.registerItem(this, name); - return super.setUnlocalizedName(name); + public Item setUnlocalizedName(String name) { + GameRegistry.registerItem(this, name); + return super.setUnlocalizedName(name); } } diff --git a/src/main/java/noppes/npcs/items/ItemNpcColored.java b/src/main/java/noppes/npcs/items/ItemNpcColored.java index 274f52b49..5997e2e5e 100644 --- a/src/main/java/noppes/npcs/items/ItemNpcColored.java +++ b/src/main/java/noppes/npcs/items/ItemNpcColored.java @@ -3,10 +3,10 @@ package noppes.npcs.items; import net.minecraft.block.Block; import net.minecraft.item.ItemColored; -public class ItemNpcColored extends ItemColored{ +public class ItemNpcColored extends ItemColored { - public ItemNpcColored(Block p_i45332_1_) { - super(p_i45332_1_, true); - } + public ItemNpcColored(Block p_i45332_1_) { + super(p_i45332_1_, true); + } } diff --git a/src/main/java/noppes/npcs/items/ItemNpcInterface.java b/src/main/java/noppes/npcs/items/ItemNpcInterface.java index e744687d6..16f198825 100644 --- a/src/main/java/noppes/npcs/items/ItemNpcInterface.java +++ b/src/main/java/noppes/npcs/items/ItemNpcInterface.java @@ -9,48 +9,50 @@ import noppes.npcs.CustomItems; import noppes.npcs.CustomNpcs; import org.lwjgl.opengl.GL11; -public class ItemNpcInterface extends Item implements ItemRenderInterface{ - - public ItemNpcInterface(int par1) { - this(); - } - public ItemNpcInterface() { - setCreativeTab(CustomItems.tab); - CustomNpcs.proxy.registerItem(this); - } - public void renderSpecial(){ - GL11.glScalef(0.66f, 0.66f,0.66f); +public class ItemNpcInterface extends Item implements ItemRenderInterface { + + public ItemNpcInterface(int par1) { + this(); + } + + public ItemNpcInterface() { + setCreativeTab(CustomItems.tab); + CustomNpcs.proxy.registerItem(this); + } + + public void renderSpecial() { + GL11.glScalef(0.66f, 0.66f, 0.66f); GL11.glTranslatef(0, 0.3f, 0); - }; + } + + ; @Override - public int getItemEnchantability() - { + public int getItemEnchantability() { //return this.toolMaterial.getEnchantability(); - return super.getItemEnchantability(); + return super.getItemEnchantability(); } @Override - public Item setUnlocalizedName(String name){ - super.setUnlocalizedName(name); - GameRegistry.registerItem(this, name); - return this; + public Item setUnlocalizedName(String name) { + super.setUnlocalizedName(name); + GameRegistry.registerItem(this, name); + return this; } @Override - public boolean hitEntity(ItemStack par1ItemStack, EntityLivingBase par2EntityLiving, EntityLivingBase par3EntityLiving) - { - if(par2EntityLiving.getHealth() <= 0) - return false; + public boolean hitEntity(ItemStack par1ItemStack, EntityLivingBase par2EntityLiving, EntityLivingBase par3EntityLiving) { + if (par2EntityLiving.getHealth() <= 0) + return false; par1ItemStack.damageItem(1, par3EntityLiving); return true; } - public boolean hasItem(EntityPlayer player, Item item) { - return player.inventory.hasItem(item); - } - - public boolean consumeItem(EntityPlayer player, Item item) { - return player.inventory.consumeInventoryItem(item); - } + public boolean hasItem(EntityPlayer player, Item item) { + return player.inventory.hasItem(item); + } + + public boolean consumeItem(EntityPlayer player, Item item) { + return player.inventory.consumeInventoryItem(item); + } } diff --git a/src/main/java/noppes/npcs/items/ItemNpcMovingPath.java b/src/main/java/noppes/npcs/items/ItemNpcMovingPath.java index bb758e178..5d0ebbdf0 100644 --- a/src/main/java/noppes/npcs/items/ItemNpcMovingPath.java +++ b/src/main/java/noppes/npcs/items/ItemNpcMovingPath.java @@ -22,76 +22,75 @@ import noppes.npcs.entity.EntityNPCInterface; import java.util.List; - -public class ItemNpcMovingPath extends Item{ - public ItemNpcMovingPath(){ +public class ItemNpcMovingPath extends Item { + public ItemNpcMovingPath() { maxStackSize = 1; setCreativeTab(CustomItems.tab); } - @Override - public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer){ - if(par2World.isRemote || !CustomNpcsPermissions.Instance.hasPermission(par3EntityPlayer, CustomNpcsPermissions.TOOL_MOUNTER)) - return par1ItemStack; - EntityNPCInterface npc = getNpc(par1ItemStack, par2World); - if(npc != null) - NoppesUtilServer.sendOpenGui(par3EntityPlayer, EnumGuiType.MovingPath, npc); + @Override + public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { + if (par2World.isRemote || !CustomNpcsPermissions.Instance.hasPermission(par3EntityPlayer, CustomNpcsPermissions.TOOL_MOUNTER)) + return par1ItemStack; + EntityNPCInterface npc = getNpc(par1ItemStack, par2World); + if (npc != null) + NoppesUtilServer.sendOpenGui(par3EntityPlayer, EnumGuiType.MovingPath, npc); return par1ItemStack; } - @Override - public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer player, World par3World, int x, int y, int z, int par7, float par8, float par9, float par10){ - if(par3World.isRemote || !CustomNpcsPermissions.Instance.hasPermission(player, CustomNpcsPermissions.TOOL_MOUNTER)) - return false; - EntityNPCInterface npc = getNpc(par1ItemStack, par3World); - if(npc == null) - return false; - List list = npc.ais.getMovingPath(); - int[] pos = list.get(list.size() - 1); - list.add(new int[]{x,y,z}); + @Override + public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer player, World par3World, int x, int y, int z, int par7, float par8, float par9, float par10) { + if (par3World.isRemote || !CustomNpcsPermissions.Instance.hasPermission(player, CustomNpcsPermissions.TOOL_MOUNTER)) + return false; + EntityNPCInterface npc = getNpc(par1ItemStack, par3World); + if (npc == null) + return false; + List list = npc.ais.getMovingPath(); + int[] pos = list.get(list.size() - 1); + list.add(new int[]{x, y, z}); double d3 = x - pos[0]; double d4 = y - pos[1]; double d5 = z - pos[2]; - double distance = (double)MathHelper.sqrt_double(d3 * d3 + d4 * d4 + d5 * d5); + double distance = (double) MathHelper.sqrt_double(d3 * d3 + d4 * d4 + d5 * d5); - player.addChatMessage(new ChatComponentText("Added point x:" + x + " y:"+ y + " z:" + z + " to npc " + npc.getCommandSenderName())); - if(distance > ConfigMain.NpcNavRange) - player.addChatMessage(new ChatComponentText("Warning: point is too far away from previous point. Max block walk distance = " + ConfigMain.NpcNavRange)); + player.addChatMessage(new ChatComponentText("Added point x:" + x + " y:" + y + " z:" + z + " to npc " + npc.getCommandSenderName())); + if (distance > ConfigMain.NpcNavRange) + player.addChatMessage(new ChatComponentText("Warning: point is too far away from previous point. Max block walk distance = " + ConfigMain.NpcNavRange)); - return true; + return true; } - private EntityNPCInterface getNpc(ItemStack item, World world){ - if(world.isRemote || item.stackTagCompound == null) - return null; + private EntityNPCInterface getNpc(ItemStack item, World world) { + if (world.isRemote || item.stackTagCompound == null) + return null; - Entity entity = world.getEntityByID(item.stackTagCompound.getInteger("NPCID")); - if(entity == null || !(entity instanceof EntityNPCInterface)) - return null; + Entity entity = world.getEntityByID(item.stackTagCompound.getInteger("NPCID")); + if (entity == null || !(entity instanceof EntityNPCInterface)) + return null; - return (EntityNPCInterface) entity; - } - - @Override - public int getColorFromItemStack(ItemStack par1ItemStack, int par2){ - return 0x8B4513; + return (EntityNPCInterface) entity; } @Override - public boolean requiresMultipleRenderPasses(){ + public int getColorFromItemStack(ItemStack par1ItemStack, int par2) { + return 0x8B4513; + } + + @Override + public boolean requiresMultipleRenderPasses() { return true; } @SideOnly(Side.CLIENT) @Override - public void registerIcons(IIconRegister par1IconRegister){ + public void registerIcons(IIconRegister par1IconRegister) { this.itemIcon = Items.iron_sword.getIconFromDamage(0); } @Override - public Item setUnlocalizedName(String name){ - GameRegistry.registerItem(this, name); - return super.setUnlocalizedName(name); + public Item setUnlocalizedName(String name) { + GameRegistry.registerItem(this, name); + return super.setUnlocalizedName(name); } } diff --git a/src/main/java/noppes/npcs/items/ItemNpcScripter.java b/src/main/java/noppes/npcs/items/ItemNpcScripter.java index cb5e7c3ec..5c5734140 100644 --- a/src/main/java/noppes/npcs/items/ItemNpcScripter.java +++ b/src/main/java/noppes/npcs/items/ItemNpcScripter.java @@ -16,27 +16,27 @@ import noppes.npcs.CustomNpcsPermissions; import noppes.npcs.config.ConfigScript; import noppes.npcs.constants.EnumGuiType; -public class ItemNpcScripter extends Item{ +public class ItemNpcScripter extends Item { - public ItemNpcScripter(){ + public ItemNpcScripter() { maxStackSize = 1; setCreativeTab(CustomItems.tab); } @Override - public int getColorFromItemStack(ItemStack par1ItemStack, int par2){ - return 0x8B4513; + public int getColorFromItemStack(ItemStack par1ItemStack, int par2) { + return 0x8B4513; } @Override - public boolean requiresMultipleRenderPasses(){ + public boolean requiresMultipleRenderPasses() { return true; } @Override - public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer player){ + public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer player) { if (!world.isRemote) { - if(!ConfigScript.canScript(player, CustomNpcsPermissions.TOOL_SCRIPTER)){ + if (!ConfigScript.canScript(player, CustomNpcsPermissions.TOOL_SCRIPTER)) { player.addChatMessage(new ChatComponentTranslation("availability.permission")); } return itemStack; @@ -47,13 +47,13 @@ public class ItemNpcScripter extends Item{ @SideOnly(Side.CLIENT) @Override - public void registerIcons(IIconRegister par1IconRegister){ + public void registerIcons(IIconRegister par1IconRegister) { this.itemIcon = Items.iron_shovel.getIconFromDamage(0); } @Override - public Item setUnlocalizedName(String name){ - GameRegistry.registerItem(this, name); - return super.setUnlocalizedName(name); + public Item setUnlocalizedName(String name) { + GameRegistry.registerItem(this, name); + return super.setUnlocalizedName(name); } } diff --git a/src/main/java/noppes/npcs/items/ItemNpcTool.java b/src/main/java/noppes/npcs/items/ItemNpcTool.java index 5cc70d170..3e45f757d 100644 --- a/src/main/java/noppes/npcs/items/ItemNpcTool.java +++ b/src/main/java/noppes/npcs/items/ItemNpcTool.java @@ -1,21 +1,17 @@ package noppes.npcs.items; import cpw.mods.fml.common.registry.GameRegistry; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import kamkeel.npcs.network.PacketClient; import kamkeel.npcs.network.packets.request.item.ColorBrushPacket; import kamkeel.npcs.network.packets.request.item.ColorSetPacket; import kamkeel.npcs.network.packets.request.item.HammerPacket; import net.minecraft.block.Block; -import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.IIcon; import net.minecraft.world.World; import noppes.npcs.CustomItems; import noppes.npcs.CustomNpcs; @@ -36,7 +32,7 @@ public class ItemNpcTool extends Item { // Define our tool types based on metadata: // meta 0: Hammer, meta 1: Paintbrush, meta 2: Wrench - public static final String[] toolTypes = new String[] {"hammer", "paintbrush"}; + public static final String[] toolTypes = new String[]{"hammer", "paintbrush"}; public static String BRUSH_COLOR_TAG = "BrushColor"; public ItemNpcTool() { @@ -51,7 +47,7 @@ public class ItemNpcTool extends Item { @Override public String getUnlocalizedName(ItemStack stack) { int meta = stack.getItemDamage(); - if(meta < 0 || meta >= toolTypes.length){ + if (meta < 0 || meta >= toolTypes.length) { meta = 0; } return super.getUnlocalizedName() + "." + toolTypes[meta]; @@ -66,11 +62,11 @@ public class ItemNpcTool extends Item { @Override public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { - if(world.isRemote) + if (world.isRemote) return stack; - if(isPaintbrush(stack) && player.isSneaking()){ - if(CustomNpcsPermissions.hasPermission(player, CustomNpcsPermissions.PAINTBRUSH_GUI)){ + if (isPaintbrush(stack) && player.isSneaking()) { + if (CustomNpcsPermissions.hasPermission(player, CustomNpcsPermissions.PAINTBRUSH_GUI)) { NoppesUtil.requestOpenGUI(EnumGuiType.Paintbrush); } } @@ -79,37 +75,37 @@ public class ItemNpcTool extends Item { @Override public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) { - if(!world.isRemote) + if (!world.isRemote) return false; - if(isPaintbrush(stack)) { + if (isPaintbrush(stack)) { Block block = world.getBlock(x, y, z); - if(block instanceof BlockTallLamp || block instanceof BlockBanner){ + if (block instanceof BlockTallLamp || block instanceof BlockBanner) { int meta = world.getBlockMetadata(x, y, z); - if(meta >= 7) + if (meta >= 7) y--; } TileEntity tile = world.getTileEntity(x, y, z); - if(tile instanceof TileColorable) { + if (tile instanceof TileColorable) { PacketClient.sendClient(new ColorSetPacket(x, y, z)); return true; } - } else if (isHammer(stack)){ + } else if (isHammer(stack)) { Block block = player.worldObj.getBlock(x, y, z); - if(block instanceof BlockBanner || block instanceof BlockWallBanner){ + if (block instanceof BlockBanner || block instanceof BlockWallBanner) { int meta = world.getBlockMetadata(x, y, z); - if(meta >= 7) + if (meta >= 7) y--; TileEntity tile = player.worldObj.getTileEntity(x, y, z); - if(tile instanceof TileBanner) { + if (tile instanceof TileBanner) { PacketClient.sendClient(new HammerPacket(x, y, z)); return true; } - } else if(block instanceof BlockChair){ + } else if (block instanceof BlockChair) { TileEntity tile = player.worldObj.getTileEntity(x, y, z); - if(tile instanceof TileChair) { + if (tile instanceof TileChair) { PacketClient.sendClient(new HammerPacket(x, y, z)); return true; } @@ -119,21 +115,20 @@ public class ItemNpcTool extends Item { return false; } - public boolean onBlockStartBreak(ItemStack itemstack, int x, int y, int z, EntityPlayer player) - { - if(!player.worldObj.isRemote) + public boolean onBlockStartBreak(ItemStack itemstack, int x, int y, int z, EntityPlayer player) { + if (!player.worldObj.isRemote) return true; - if(isPaintbrush(itemstack)) { + if (isPaintbrush(itemstack)) { Block block = player.worldObj.getBlock(x, y, z); - if(block instanceof BlockTallLamp || block instanceof BlockBanner){ + if (block instanceof BlockTallLamp || block instanceof BlockBanner) { int meta = player.worldObj.getBlockMetadata(x, y, z); - if(meta >= 7) + if (meta >= 7) y--; } TileEntity tile = player.worldObj.getTileEntity(x, y, z); - if(tile instanceof TileColorable) { + if (tile instanceof TileColorable) { int color = ((TileColorable) tile).color; PacketClient.sendClient(new ColorBrushPacket(color)); } @@ -142,29 +137,29 @@ public class ItemNpcTool extends Item { return true; } - public static boolean isPaintbrush(ItemStack itemStack){ + public static boolean isPaintbrush(ItemStack itemStack) { return itemStack.getItemDamage() == 1; } - public static boolean isHammer(ItemStack itemStack){ + public static boolean isHammer(ItemStack itemStack) { return itemStack.getItemDamage() == 0; } @Override - public Item setUnlocalizedName(String name){ + public Item setUnlocalizedName(String name) { GameRegistry.registerItem(this, name); return super.setUnlocalizedName(name); } - public static int getColor(NBTTagCompound tagCompound){ - if(tagCompound == null || !tagCompound.hasKey(BRUSH_COLOR_TAG)) + public static int getColor(NBTTagCompound tagCompound) { + if (tagCompound == null || !tagCompound.hasKey(BRUSH_COLOR_TAG)) return 0xFFFFFF; return tagCompound.getInteger(BRUSH_COLOR_TAG); } - public static int setColor(NBTTagCompound tagCompound, int color){ - if(tagCompound == null || !tagCompound.hasKey(BRUSH_COLOR_TAG)) + public static int setColor(NBTTagCompound tagCompound, int color) { + if (tagCompound == null || !tagCompound.hasKey(BRUSH_COLOR_TAG)) return 0xFFFFFF; return tagCompound.getInteger(BRUSH_COLOR_TAG); diff --git a/src/main/java/noppes/npcs/items/ItemNpcWand.java b/src/main/java/noppes/npcs/items/ItemNpcWand.java index 6d6477f5a..1a11918ae 100644 --- a/src/main/java/noppes/npcs/items/ItemNpcWand.java +++ b/src/main/java/noppes/npcs/items/ItemNpcWand.java @@ -19,69 +19,66 @@ import noppes.npcs.config.ConfigMain; import noppes.npcs.constants.EnumGuiType; import noppes.npcs.entity.EntityCustomNpc; -public class ItemNpcWand extends Item{ +public class ItemNpcWand extends Item { - public ItemNpcWand(){ + public ItemNpcWand() { maxStackSize = 1; setCreativeTab(CustomItems.tab); } - @Override - public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer player){ - if(!par2World.isRemote) - return par1ItemStack; - else if(CustomNpcsPermissions.hasPermission(player, CustomNpcsPermissions.NPC_GUI)){ + @Override + public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer player) { + if (!par2World.isRemote) + return par1ItemStack; + else if (CustomNpcsPermissions.hasPermission(player, CustomNpcsPermissions.NPC_GUI)) { CustomNpcs.proxy.openGui(0, 0, 0, EnumGuiType.NpcRemote, player); - } - else + } else player.addChatMessage(new ChatComponentTranslation("availability.permission")); return par1ItemStack; } - @Override - public boolean onItemUse(ItemStack par1ItemStack, final EntityPlayer player, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10) - { - if(par3World.isRemote) - return false; - if(ConfigMain.OpsOnly && !MinecraftServer.getServer().getConfigurationManager().func_152596_g(player.getGameProfile())){ - player.addChatMessage(new ChatComponentTranslation("availability.permission")); + @Override + public boolean onItemUse(ItemStack par1ItemStack, final EntityPlayer player, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10) { + if (par3World.isRemote) return false; - } - else if(CustomNpcsPermissions.hasPermission(player, CustomNpcsPermissions.NPC_CREATE)){ - EntityCustomNpc npc = new EntityCustomNpc(par3World); - npc.ais.startPos = new int[]{par4,par5,par6}; + if (ConfigMain.OpsOnly && !MinecraftServer.getServer().getConfigurationManager().func_152596_g(player.getGameProfile())) { + player.addChatMessage(new ChatComponentTranslation("availability.permission")); + return false; + } else if (CustomNpcsPermissions.hasPermission(player, CustomNpcsPermissions.NPC_CREATE)) { + EntityCustomNpc npc = new EntityCustomNpc(par3World); + npc.ais.startPos = new int[]{par4, par5, par6}; - npc.setLocationAndAngles((float)par4 + 0.5F, npc.getStartYPos(), (float)par6 + 0.5F, player.rotationYaw, player.rotationPitch); + npc.setLocationAndAngles((float) par4 + 0.5F, npc.getStartYPos(), (float) par6 + 0.5F, player.rotationYaw, player.rotationPitch); - par3World.spawnEntityInWorld(npc); - npc.setHealth(npc.getMaxHealth()); + par3World.spawnEntityInWorld(npc); + npc.setHealth(npc.getMaxHealth()); - NoppesUtilServer.sendOpenGuiNoDelay(player, EnumGuiType.MainMenuDisplay,npc); + NoppesUtilServer.sendOpenGuiNoDelay(player, EnumGuiType.MainMenuDisplay, npc); return true; - } - else - player.addChatMessage(new ChatComponentTranslation("availability.permission")); + } else + player.addChatMessage(new ChatComponentTranslation("availability.permission")); return false; } @Override - public int getColorFromItemStack(ItemStack par1ItemStack, int par2){ - return 0x8B4513; + public int getColorFromItemStack(ItemStack par1ItemStack, int par2) { + return 0x8B4513; } + @Override - public boolean requiresMultipleRenderPasses(){ + public boolean requiresMultipleRenderPasses() { return true; } @SideOnly(Side.CLIENT) @Override - public void registerIcons(IIconRegister par1IconRegister){ + public void registerIcons(IIconRegister par1IconRegister) { this.itemIcon = Items.iron_hoe.getIconFromDamage(0); } @Override - public Item setUnlocalizedName(String name){ - GameRegistry.registerItem(this, name); - return super.setUnlocalizedName(name); + public Item setUnlocalizedName(String name) { + GameRegistry.registerItem(this, name); + return super.setUnlocalizedName(name); } } diff --git a/src/main/java/noppes/npcs/items/ItemNpcWeaponInterface.java b/src/main/java/noppes/npcs/items/ItemNpcWeaponInterface.java index 517613151..7c326143f 100644 --- a/src/main/java/noppes/npcs/items/ItemNpcWeaponInterface.java +++ b/src/main/java/noppes/npcs/items/ItemNpcWeaponInterface.java @@ -7,27 +7,28 @@ import noppes.npcs.CustomItems; import noppes.npcs.CustomNpcs; import org.lwjgl.opengl.GL11; -public class ItemNpcWeaponInterface extends ItemSword implements ItemRenderInterface{ +public class ItemNpcWeaponInterface extends ItemSword implements ItemRenderInterface { - - public ItemNpcWeaponInterface(int par1, ToolMaterial material) { - this(material); - } - public ItemNpcWeaponInterface(ToolMaterial material) { - super(material); - setCreativeTab(CustomItems.tab); - CustomNpcs.proxy.registerItem(this); - setCreativeTab(CustomItems.tabWeapon); - } - - public void renderSpecial(){ - GL11.glScalef(0.66f, 0.66f,0.66f); + + public ItemNpcWeaponInterface(int par1, ToolMaterial material) { + this(material); + } + + public ItemNpcWeaponInterface(ToolMaterial material) { + super(material); + setCreativeTab(CustomItems.tab); + CustomNpcs.proxy.registerItem(this); + setCreativeTab(CustomItems.tabWeapon); + } + + public void renderSpecial() { + GL11.glScalef(0.66f, 0.66f, 0.66f); GL11.glTranslatef(0.16f, 0.26f, 0.06f); } @Override - public Item setUnlocalizedName(String name){ - GameRegistry.registerItem(this, name); - return super.setUnlocalizedName(name); + public Item setUnlocalizedName(String name) { + GameRegistry.registerItem(this, name); + return super.setUnlocalizedName(name); } } diff --git a/src/main/java/noppes/npcs/items/ItemOrb.java b/src/main/java/noppes/npcs/items/ItemOrb.java index 0fd8a3b09..04df0e16c 100644 --- a/src/main/java/noppes/npcs/items/ItemOrb.java +++ b/src/main/java/noppes/npcs/items/ItemOrb.java @@ -8,29 +8,27 @@ import net.minecraft.item.ItemStack; import java.awt.*; import java.util.List; -public class ItemOrb extends ItemNpcInterface{ +public class ItemOrb extends ItemNpcInterface { - public ItemOrb(int par1) { - super(par1); - setHasSubtypes(true); - } + public ItemOrb(int par1) { + super(par1); + setHasSubtypes(true); + } @Override - public int getColorFromItemStack(ItemStack par1ItemStack, int par2){ - float[] color = EntitySheep.fleeceColorTable[par1ItemStack.getItemDamage()]; - return new Color(color[0],color[1],color[2]).getRGB(); + public int getColorFromItemStack(ItemStack par1ItemStack, int par2) { + float[] color = EntitySheep.fleeceColorTable[par1ItemStack.getItemDamage()]; + return new Color(color[0], color[1], color[2]).getRGB(); } - - public boolean requiresMultipleRenderPasses() - { + + public boolean requiresMultipleRenderPasses() { return true; } - @Override - public void getSubItems(Item par1, CreativeTabs par2CreativeTabs, List par3List) - { - for (int var4 = 0; var4 < 16; ++var4) - { + + @Override + public void getSubItems(Item par1, CreativeTabs par2CreativeTabs, List par3List) { + for (int var4 = 0; var4 < 16; ++var4) { par3List.add(new ItemStack(par1, 1, var4)); } } diff --git a/src/main/java/noppes/npcs/items/ItemPlaceholder.java b/src/main/java/noppes/npcs/items/ItemPlaceholder.java index 08cafd322..3f5c73ef5 100644 --- a/src/main/java/noppes/npcs/items/ItemPlaceholder.java +++ b/src/main/java/noppes/npcs/items/ItemPlaceholder.java @@ -7,22 +7,21 @@ import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; -public class ItemPlaceholder extends ItemBlock{ +public class ItemPlaceholder extends ItemBlock { - public ItemPlaceholder(Block p_i45328_1_) { - super(p_i45328_1_); - setHasSubtypes(true); - } - - @Override - public String getUnlocalizedName(ItemStack par1ItemStack){ + public ItemPlaceholder(Block p_i45328_1_) { + super(p_i45328_1_); + setHasSubtypes(true); + } + + @Override + public String getUnlocalizedName(ItemStack par1ItemStack) { return super.getUnlocalizedName(par1ItemStack) + "_" + par1ItemStack.getItemDamage(); } - - @Override + + @Override @SideOnly(Side.CLIENT) - public IIcon getIconFromDamage(int par1) - { + public IIcon getIconFromDamage(int par1) { return this.field_150939_a.getIcon(0, par1); } } diff --git a/src/main/java/noppes/npcs/items/ItemRenderInterface.java b/src/main/java/noppes/npcs/items/ItemRenderInterface.java index 603e56fbf..a21d1602e 100644 --- a/src/main/java/noppes/npcs/items/ItemRenderInterface.java +++ b/src/main/java/noppes/npcs/items/ItemRenderInterface.java @@ -1,5 +1,5 @@ package noppes.npcs.items; public interface ItemRenderInterface { - public void renderSpecial(); + public void renderSpecial(); } diff --git a/src/main/java/noppes/npcs/items/ItemRotatedShield.java b/src/main/java/noppes/npcs/items/ItemRotatedShield.java index edcb4d924..52a4f01bf 100644 --- a/src/main/java/noppes/npcs/items/ItemRotatedShield.java +++ b/src/main/java/noppes/npcs/items/ItemRotatedShield.java @@ -3,17 +3,17 @@ package noppes.npcs.items; import noppes.npcs.constants.EnumNpcToolMaterial; import org.lwjgl.opengl.GL11; -public class ItemRotatedShield extends ItemShield{ +public class ItemRotatedShield extends ItemShield { - public ItemRotatedShield(int par1, EnumNpcToolMaterial material) { - super(par1,material); - } + public ItemRotatedShield(int par1, EnumNpcToolMaterial material) { + super(par1, material); + } - @Override - public void renderSpecial(){ - GL11.glScalef(0.6f, 0.6f,0.6f); - GL11.glTranslatef(0.4f, 1f, -0.18f); + @Override + public void renderSpecial() { + GL11.glScalef(0.6f, 0.6f, 0.6f); + GL11.glTranslatef(0.4f, 1f, -0.18f); GL11.glRotatef(-6, 0, 1, 0); GL11.glRotatef(120, 0, 0, 1); - } + } } diff --git a/src/main/java/noppes/npcs/items/ItemScripted.java b/src/main/java/noppes/npcs/items/ItemScripted.java index 4c7168e1c..8130f56b5 100644 --- a/src/main/java/noppes/npcs/items/ItemScripted.java +++ b/src/main/java/noppes/npcs/items/ItemScripted.java @@ -4,7 +4,6 @@ import kamkeel.npcs.network.packets.data.ChatAlertPacket; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.item.ItemStack; -import net.minecraft.util.ChatComponentTranslation; import net.minecraft.world.World; import noppes.npcs.CustomItems; import noppes.npcs.CustomNpcs; @@ -22,11 +21,10 @@ public class ItemScripted extends ItemCustomizable { setHasSubtypes(true); } - public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) - { - if (!world.isRemote){ - if(player.isSneaking() && player.capabilities.isCreativeMode) { - if(!ConfigScript.canScript(player, CustomNpcsPermissions.TOOL_SCRIPTED_ITEM)){ + public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { + if (!world.isRemote) { + if (player.isSneaking() && player.capabilities.isCreativeMode) { + if (!ConfigScript.canScript(player, CustomNpcsPermissions.TOOL_SCRIPTED_ITEM)) { ChatAlertPacket.sendChatAlert((EntityPlayerMP) player, "availability.permission"); } else { NoppesUtilServer.sendOpenGui(player, EnumGuiType.ScriptItem, null, 0, 0, 0); diff --git a/src/main/java/noppes/npcs/items/ItemScythe.java b/src/main/java/noppes/npcs/items/ItemScythe.java index 0acd40c00..ae9c88517 100644 --- a/src/main/java/noppes/npcs/items/ItemScythe.java +++ b/src/main/java/noppes/npcs/items/ItemScythe.java @@ -2,16 +2,16 @@ package noppes.npcs.items; import org.lwjgl.opengl.GL11; -public class ItemScythe extends ItemNpcWeaponInterface{ +public class ItemScythe extends ItemNpcWeaponInterface { - public ItemScythe(int par1 ,ToolMaterial tool) { - super(par1, tool); - } + public ItemScythe(int par1, ToolMaterial tool) { + super(par1, tool); + } - @Override - public void renderSpecial(){ + @Override + public void renderSpecial() { GL11.glScalef(1f, 1.3f, 1f); GL11.glTranslatef(0.0F, -0.2f, -0.16f); GL11.glRotatef(180, 0, 1, 0); - } + } } diff --git a/src/main/java/noppes/npcs/items/ItemShield.java b/src/main/java/noppes/npcs/items/ItemShield.java index 574e702a9..0da524808 100644 --- a/src/main/java/noppes/npcs/items/ItemShield.java +++ b/src/main/java/noppes/npcs/items/ItemShield.java @@ -8,34 +8,35 @@ import noppes.npcs.CustomItems; import noppes.npcs.constants.EnumNpcToolMaterial; import org.lwjgl.opengl.GL11; -public class ItemShield extends ItemNpcInterface{ - public EnumNpcToolMaterial material; - public ItemShield(int par1, EnumNpcToolMaterial material) { - super(par1); - this.material = material; +public class ItemShield extends ItemNpcInterface { + public EnumNpcToolMaterial material; + + public ItemShield(int par1, EnumNpcToolMaterial material) { + super(par1); + this.material = material; this.setMaxDamage(material.getMaxUses()); setCreativeTab(CustomItems.tabWeapon); - } + } - @Override - public void renderSpecial(){ - GL11.glScalef(0.6f, 0.6f,0.6f); - GL11.glTranslatef(0f, 0f, -0.2f); + @Override + public void renderSpecial() { + GL11.glScalef(0.6f, 0.6f, 0.6f); + GL11.glTranslatef(0f, 0f, -0.2f); GL11.glRotatef(-6, 0, 1, 0); - } - - public EnumAction getItemUseAction(ItemStack par1ItemStack){ + } + + public EnumAction getItemUseAction(ItemStack par1ItemStack) { return EnumAction.block; } - - @Override - public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer){ + + @Override + public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { par3EntityPlayer.setItemInUse(par1ItemStack, this.getMaxItemUseDuration(par1ItemStack)); return par1ItemStack; } - - @Override - public int getMaxItemUseDuration(ItemStack par1ItemStack){ + + @Override + public int getMaxItemUseDuration(ItemStack par1ItemStack) { return 72000; } } diff --git a/src/main/java/noppes/npcs/items/ItemSkirt.java b/src/main/java/noppes/npcs/items/ItemSkirt.java index 63e73d03f..ae6e43bb6 100644 --- a/src/main/java/noppes/npcs/items/ItemSkirt.java +++ b/src/main/java/noppes/npcs/items/ItemSkirt.java @@ -13,49 +13,49 @@ import net.minecraft.util.IIcon; import noppes.npcs.CustomItems; import noppes.npcs.CustomNpcs; -public class ItemSkirt extends ItemArmor{ +public class ItemSkirt extends ItemArmor { + + private String texture; + + public ItemSkirt(ArmorMaterial par2EnumArmorMaterial, String texture) { + super(par2EnumArmorMaterial, 0, 2); + this.texture = texture; + setCreativeTab(CustomItems.tabArmor); + setMaxStackSize(1); + } - private String texture; - - public ItemSkirt(ArmorMaterial par2EnumArmorMaterial, String texture) { - super(par2EnumArmorMaterial, 0, 2); - this.texture = texture; - setCreativeTab(CustomItems.tabArmor); - setMaxStackSize(1); - } @Override - public int getColorFromItemStack(ItemStack par1ItemStack, int par2){ + public int getColorFromItemStack(ItemStack par1ItemStack, int par2) { int j = this.getColor(par1ItemStack); - if (j < 0) - { + if (j < 0) { j = 16777215; } return j; } - - @Override - public String getArmorTexture(ItemStack stack, Entity entity, int slot, String type){ - if(type != null && type.equals("overlay")) - return null; - return texture; + + @Override + public String getArmorTexture(ItemStack stack, Entity entity, int slot, String type) { + if (type != null && type.equals("overlay")) + return null; + return texture; } - - @Override + + @Override @SideOnly(Side.CLIENT) - public ModelBiped getArmorModel(EntityLivingBase entityLiving, ItemStack itemStack, int armorSlot){ + public ModelBiped getArmorModel(EntityLivingBase entityLiving, ItemStack itemStack, int armorSlot) { return CustomNpcs.proxy.getSkirtModel(); } @Override - public Item setUnlocalizedName(String name){ - GameRegistry.registerItem(this, name); - return super.setUnlocalizedName(name); + public Item setUnlocalizedName(String name) { + GameRegistry.registerItem(this, name); + return super.setUnlocalizedName(name); } + @SideOnly(Side.CLIENT) - public IIcon getIconFromDamageForRenderPass(int par1, int par2) - { - return super.getIconFromDamage(par1); + public IIcon getIconFromDamageForRenderPass(int par1, int par2) { + return super.getIconFromDamage(par1); } } diff --git a/src/main/java/noppes/npcs/items/ItemSlingshot.java b/src/main/java/noppes/npcs/items/ItemSlingshot.java index 3baea4037..572d45575 100644 --- a/src/main/java/noppes/npcs/items/ItemSlingshot.java +++ b/src/main/java/noppes/npcs/items/ItemSlingshot.java @@ -11,67 +11,66 @@ import noppes.npcs.constants.EnumParticleType; import noppes.npcs.entity.EntityProjectile; import org.lwjgl.opengl.GL11; -public class ItemSlingshot extends ItemNpcInterface{ +public class ItemSlingshot extends ItemNpcInterface { - public ItemSlingshot(int par1) { - super(par1); + public ItemSlingshot(int par1) { + super(par1); this.maxStackSize = 1; this.setMaxDamage(384); setCreativeTab(CustomItems.tabWeapon); - } - @Override - public void onPlayerStoppedUsing(ItemStack par1ItemStack, World worldObj, EntityPlayer player, int par4) { - if(worldObj.isRemote) - return; - int ticks = getMaxItemUseDuration(par1ItemStack) - par4; - - if(ticks < 6){//prevent rightclick spamming - return; - } - if (!player.capabilities.isCreativeMode && !consumeItem(player, Item.getItemFromBlock(Blocks.cobblestone))) - { - return; - } - par1ItemStack.damageItem(1, player); - EntityProjectile projectile = new EntityProjectile(worldObj, player, new ItemStack(Blocks.cobblestone), false); - projectile.damage = 4; - projectile.punch = 1; - projectile.setRotating(true); - if(ticks > 24){ - projectile.setParticleEffect(EnumParticleType.Crit); - projectile.punch = 2; - } - projectile.setHasGravity(true); - projectile.setSpeed(14); - projectile.shoot(1); - - worldObj.playSoundAtEntity(player, "random.bow", 1.0F,itemRand.nextFloat() * 0.3F + 0.8F); - worldObj.spawnEntityInWorld(projectile); } - @Override - public void renderSpecial(){ - GL11.glRotatef(90, 0, 1, 0); - GL11.glScalef(0.5f, 0.5f,0.5f); - GL11.glTranslatef(0f, 0.5f, 0); - } + @Override + public void onPlayerStoppedUsing(ItemStack par1ItemStack, World worldObj, EntityPlayer player, int par4) { + if (worldObj.isRemote) + return; + int ticks = getMaxItemUseDuration(par1ItemStack) - par4; + + if (ticks < 6) {//prevent rightclick spamming + return; + } + if (!player.capabilities.isCreativeMode && !consumeItem(player, Item.getItemFromBlock(Blocks.cobblestone))) { + return; + } + par1ItemStack.damageItem(1, player); + EntityProjectile projectile = new EntityProjectile(worldObj, player, new ItemStack(Blocks.cobblestone), false); + projectile.damage = 4; + projectile.punch = 1; + projectile.setRotating(true); + if (ticks > 24) { + projectile.setParticleEffect(EnumParticleType.Crit); + projectile.punch = 2; + } + projectile.setHasGravity(true); + projectile.setSpeed(14); + projectile.shoot(1); + + worldObj.playSoundAtEntity(player, "random.bow", 1.0F, itemRand.nextFloat() * 0.3F + 0.8F); + worldObj.spawnEntityInWorld(projectile); + } + + @Override + public void renderSpecial() { + GL11.glRotatef(90, 0, 1, 0); + GL11.glScalef(0.5f, 0.5f, 0.5f); + GL11.glTranslatef(0f, 0.5f, 0); + } + /** * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer */ - @Override - public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) - { - par3EntityPlayer.setItemInUse(par1ItemStack, this.getMaxItemUseDuration(par1ItemStack)); + @Override + public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { + par3EntityPlayer.setItemInUse(par1ItemStack, this.getMaxItemUseDuration(par1ItemStack)); return par1ItemStack; } - @Override - public int getMaxItemUseDuration(ItemStack par1ItemStack) - { + + @Override + public int getMaxItemUseDuration(ItemStack par1ItemStack) { return 72000; } - - public EnumAction getItemUseAction(ItemStack par1ItemStack) - { + + public EnumAction getItemUseAction(ItemStack par1ItemStack) { return EnumAction.bow; } } diff --git a/src/main/java/noppes/npcs/items/ItemSoulstoneEmpty.java b/src/main/java/noppes/npcs/items/ItemSoulstoneEmpty.java index 727457b5f..82d0359a6 100644 --- a/src/main/java/noppes/npcs/items/ItemSoulstoneEmpty.java +++ b/src/main/java/noppes/npcs/items/ItemSoulstoneEmpty.java @@ -23,84 +23,84 @@ import noppes.npcs.roles.RoleCompanion; import noppes.npcs.roles.RoleFollower; public class ItemSoulstoneEmpty extends Item { - public ItemSoulstoneEmpty(){ - this.setMaxStackSize(64); - } - @Override - public Item setUnlocalizedName(String name){ - super.setUnlocalizedName(name); - GameRegistry.registerItem(this, name); - return this; + public ItemSoulstoneEmpty() { + this.setMaxStackSize(64); } - public boolean store(EntityLivingBase entity, ItemStack stack, EntityPlayer player) { - if(!canSoulStone(entity, player) || entity instanceof EntityPlayer) - return false; - ItemStack stone = new ItemStack(CustomItems.soulstoneFull); - NBTTagCompound compound = new NBTTagCompound(); - if(!entity.writeToNBTOptional(compound)) - return false; - ServerCloneController.Instance.cleanTags(compound); - if(stone.stackTagCompound == null) - stone.stackTagCompound = new NBTTagCompound(); - stone.stackTagCompound.setTag("Entity", compound); + @Override + public Item setUnlocalizedName(String name) { + super.setUnlocalizedName(name); + GameRegistry.registerItem(this, name); + return this; + } + + public boolean store(EntityLivingBase entity, ItemStack stack, EntityPlayer player) { + if (!canSoulStone(entity, player) || entity instanceof EntityPlayer) + return false; + ItemStack stone = new ItemStack(CustomItems.soulstoneFull); + NBTTagCompound compound = new NBTTagCompound(); + if (!entity.writeToNBTOptional(compound)) + return false; + ServerCloneController.Instance.cleanTags(compound); + if (stone.stackTagCompound == null) + stone.stackTagCompound = new NBTTagCompound(); + stone.stackTagCompound.setTag("Entity", compound); String name = EntityList.getEntityString(entity); if (name == null) - name = "generic"; - stone.stackTagCompound.setString("Name", "entity." + name + ".name"); - if(entity instanceof EntityNPCInterface){ - EntityNPCInterface npc = (EntityNPCInterface) entity; - stone.stackTagCompound.setString("DisplayName", entity.getCommandSenderName()); - if(npc.advanced.role == EnumRoleType.Companion){ - RoleCompanion role = (RoleCompanion) npc.roleInterface; - stone.stackTagCompound.setString("ExtraText", "companion.stage,: ," + role.stage.name); - } + name = "generic"; + stone.stackTagCompound.setString("Name", "entity." + name + ".name"); + if (entity instanceof EntityNPCInterface) { + EntityNPCInterface npc = (EntityNPCInterface) entity; + stone.stackTagCompound.setString("DisplayName", entity.getCommandSenderName()); + if (npc.advanced.role == EnumRoleType.Companion) { + RoleCompanion role = (RoleCompanion) npc.roleInterface; + stone.stackTagCompound.setString("ExtraText", "companion.stage,: ," + role.stage.name); + } + } else if (entity instanceof EntityLiving && ((EntityLiving) entity).hasCustomNameTag()) + stone.stackTagCompound.setString("DisplayName", ((EntityLiving) entity).getCustomNameTag()); + NoppesUtilServer.GivePlayerItem(player, player, stone); + + if (!player.capabilities.isCreativeMode) { + stack.splitStack(1); + if (stack.stackSize <= 0) + player.destroyCurrentEquippedItem(); } - else if(entity instanceof EntityLiving && ((EntityLiving)entity).hasCustomNameTag()) - stone.stackTagCompound.setString("DisplayName", ((EntityLiving)entity).getCustomNameTag()); - NoppesUtilServer.GivePlayerItem(player, player, stone); - if(!player.capabilities.isCreativeMode){ - stack.splitStack(1); - if(stack.stackSize <= 0) - player.destroyCurrentEquippedItem(); - } + entity.isDead = true; + return true; + } - entity.isDead = true; - return true; - } - - public boolean canSoulStone(EntityLivingBase entity, EntityPlayer player){ - if(NoppesUtilServer.isOp(player) && player.capabilities.isCreativeMode) - return true; - if(CustomNpcsPermissions.enabled() && CustomNpcsPermissions.hasPermission(player, CustomNpcsPermissions.SOULSTONE_ALL)) - return true; - if(entity instanceof EntityNPCInterface){ - EntityNPCInterface npc = (EntityNPCInterface) entity; - if (npc.advanced.refuseSoulStone) return false; - if (ConfigMain.SoulStoneFriendlyNPCs && npc.getFaction() != null) { - int p = npc.advanced.minFactionPointsToSoulStone; - if (p == -1 && npc.getFaction().isFriendlyToPlayer(player)) return true; - else if (p != -1) { - PlayerData data = PlayerDataController.Instance.getPlayerData(player); - return data.factionData.getFactionPoints(npc.getFaction().getId()) >= p; - } - } - if (npc.advanced.role == EnumRoleType.Companion){ - RoleCompanion role = (RoleCompanion) npc.roleInterface; - if(role.getOwner() == player) - return true; - } - if (npc.advanced.role == EnumRoleType.Follower){ - RoleFollower role = (RoleFollower) npc.roleInterface; - if(role.getOwner() == player) - return !role.refuseSoulStone; - } - return ConfigMain.SoulStoneNPCs; - } - if (entity instanceof EntityAnimal) return ConfigMain.SoulStoneAnimals; - if (entity instanceof EntityVillager) return ConfigMain.SoulStoneVillagers; - return false; - } + public boolean canSoulStone(EntityLivingBase entity, EntityPlayer player) { + if (NoppesUtilServer.isOp(player) && player.capabilities.isCreativeMode) + return true; + if (CustomNpcsPermissions.enabled() && CustomNpcsPermissions.hasPermission(player, CustomNpcsPermissions.SOULSTONE_ALL)) + return true; + if (entity instanceof EntityNPCInterface) { + EntityNPCInterface npc = (EntityNPCInterface) entity; + if (npc.advanced.refuseSoulStone) return false; + if (ConfigMain.SoulStoneFriendlyNPCs && npc.getFaction() != null) { + int p = npc.advanced.minFactionPointsToSoulStone; + if (p == -1 && npc.getFaction().isFriendlyToPlayer(player)) return true; + else if (p != -1) { + PlayerData data = PlayerDataController.Instance.getPlayerData(player); + return data.factionData.getFactionPoints(npc.getFaction().getId()) >= p; + } + } + if (npc.advanced.role == EnumRoleType.Companion) { + RoleCompanion role = (RoleCompanion) npc.roleInterface; + if (role.getOwner() == player) + return true; + } + if (npc.advanced.role == EnumRoleType.Follower) { + RoleFollower role = (RoleFollower) npc.roleInterface; + if (role.getOwner() == player) + return !role.refuseSoulStone; + } + return ConfigMain.SoulStoneNPCs; + } + if (entity instanceof EntityAnimal) return ConfigMain.SoulStoneAnimals; + if (entity instanceof EntityVillager) return ConfigMain.SoulStoneVillagers; + return false; + } } diff --git a/src/main/java/noppes/npcs/items/ItemSoulstoneFilled.java b/src/main/java/noppes/npcs/items/ItemSoulstoneFilled.java index 6e3480040..abca79104 100644 --- a/src/main/java/noppes/npcs/items/ItemSoulstoneFilled.java +++ b/src/main/java/noppes/npcs/items/ItemSoulstoneFilled.java @@ -25,84 +25,85 @@ import noppes.npcs.roles.RoleFollower; import java.util.List; public class ItemSoulstoneFilled extends Item { - public ItemSoulstoneFilled(){ - setMaxStackSize(1); - } + public ItemSoulstoneFilled() { + setMaxStackSize(1); + } + @Override - public Item setUnlocalizedName(String name){ - super.setUnlocalizedName(name); - GameRegistry.registerItem(this, name); - return this; + public Item setUnlocalizedName(String name) { + super.setUnlocalizedName(name); + GameRegistry.registerItem(this, name); + return this; } @Override @SideOnly(Side.CLIENT) public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean bo) { - if(stack.stackTagCompound == null || !stack.stackTagCompound.hasKey("Entity", 10)){ - list.add(EnumChatFormatting.RED + "Error"); - return; - } - String name = StatCollector.translateToLocal(stack.stackTagCompound.getString("Name")); - if(stack.stackTagCompound.hasKey("DisplayName")) - name = stack.stackTagCompound.getString("DisplayName") + " (" + name + ")"; - list.add(EnumChatFormatting.BLUE + name); + if (stack.stackTagCompound == null || !stack.stackTagCompound.hasKey("Entity", 10)) { + list.add(EnumChatFormatting.RED + "Error"); + return; + } + String name = StatCollector.translateToLocal(stack.stackTagCompound.getString("Name")); + if (stack.stackTagCompound.hasKey("DisplayName")) + name = stack.stackTagCompound.getString("DisplayName") + " (" + name + ")"; + list.add(EnumChatFormatting.BLUE + name); - if(stack.stackTagCompound.hasKey("ExtraText")){ - String text = ""; - String[] split = stack.stackTagCompound.getString("ExtraText").split(","); - for(String s : split) - text += StatCollector.translateToLocal(s); - list.add(text); - } + if (stack.stackTagCompound.hasKey("ExtraText")) { + String text = ""; + String[] split = stack.stackTagCompound.getString("ExtraText").split(","); + for (String s : split) + text += StatCollector.translateToLocal(s); + list.add(text); + } } @Override - public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int p_77648_7_, float p_77648_8_, float p_77648_9_, float p_77648_10_){ - if(!spawn(player, stack, world, x, y, z)) - return false; + public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int p_77648_7_, float p_77648_8_, float p_77648_9_, float p_77648_10_) { + if (!spawn(player, stack, world, x, y, z)) + return false; - if(!player.capabilities.isCreativeMode) - stack.splitStack(1); - return true; + if (!player.capabilities.isCreativeMode) + stack.splitStack(1); + return true; } - public boolean spawn(EntityPlayer player, ItemStack stack, World world, int x, int y, int z){ - if(world.isRemote) - return true; - if(stack.stackTagCompound == null || !stack.stackTagCompound.hasKey("Entity", 10)) - return false; - NBTTagCompound compound = stack.stackTagCompound.getCompoundTag("Entity"); - Entity entity = EntityList.createEntityFromNBT(compound, world); - if(entity == null) - return false; - entity.setPosition(x + 0.5, y + 1 + 0.2F, z + 0.5); - entity.dimension = world.provider.dimensionId; - String sourceName = "DISPENSER"; - if(player != null){ - sourceName = player.getCommandSenderName(); - } - if(ConfigDebug.PlayerLogging && FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER){ - LogWriter.script(String.format("[%s] %s PLACED ENTITY %s", "SOULSTONE", sourceName, entity)); - } - if(entity instanceof EntityNPCInterface){ - EntityNPCInterface npc = (EntityNPCInterface) entity; - npc.ais.startPos = new int[]{x, y, z}; - npc.setHealth(npc.getMaxHealth()); - npc.setPosition((float)x + 0.5F, npc.getStartYPos(), (float)z + 0.5F); - npc.advanced.soulStonePlayerName = sourceName; - npc.advanced.soulStoneInit = true; - if(npc.advanced.role == EnumRoleType.Companion && player != null){ - PlayerData data = PlayerDataController.Instance.getPlayerData(player); - if(data.hasCompanion()) - return false; - ((RoleCompanion)npc.roleInterface).setOwner(player); - data.setCompanion(npc); - } - if(npc.advanced.role == EnumRoleType.Follower && player != null){ - ((RoleFollower)npc.roleInterface).setOwner(player); - } - } - world.spawnEntityInWorld(entity); - return true; + public boolean spawn(EntityPlayer player, ItemStack stack, World world, int x, int y, int z) { + if (world.isRemote) + return true; + if (stack.stackTagCompound == null || !stack.stackTagCompound.hasKey("Entity", 10)) + return false; + NBTTagCompound compound = stack.stackTagCompound.getCompoundTag("Entity"); + Entity entity = EntityList.createEntityFromNBT(compound, world); + if (entity == null) + return false; + entity.setPosition(x + 0.5, y + 1 + 0.2F, z + 0.5); + entity.dimension = world.provider.dimensionId; + String sourceName = "DISPENSER"; + if (player != null) { + sourceName = player.getCommandSenderName(); + } + if (ConfigDebug.PlayerLogging && FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER) { + LogWriter.script(String.format("[%s] %s PLACED ENTITY %s", "SOULSTONE", sourceName, entity)); + } + if (entity instanceof EntityNPCInterface) { + EntityNPCInterface npc = (EntityNPCInterface) entity; + npc.ais.startPos = new int[]{x, y, z}; + npc.setHealth(npc.getMaxHealth()); + npc.setPosition((float) x + 0.5F, npc.getStartYPos(), (float) z + 0.5F); + npc.advanced.soulStonePlayerName = sourceName; + npc.advanced.soulStoneInit = true; + if (npc.advanced.role == EnumRoleType.Companion && player != null) { + PlayerData data = PlayerDataController.Instance.getPlayerData(player); + if (data.hasCompanion()) + return false; + ((RoleCompanion) npc.roleInterface).setOwner(player); + data.setCompanion(npc); + } + if (npc.advanced.role == EnumRoleType.Follower && player != null) { + ((RoleFollower) npc.roleInterface).setOwner(player); + } + } + world.spawnEntityInWorld(entity); + return true; } } diff --git a/src/main/java/noppes/npcs/items/ItemSpear.java b/src/main/java/noppes/npcs/items/ItemSpear.java index ad69b5c53..03f1f6477 100644 --- a/src/main/java/noppes/npcs/items/ItemSpear.java +++ b/src/main/java/noppes/npcs/items/ItemSpear.java @@ -3,16 +3,16 @@ package noppes.npcs.items; import org.lwjgl.opengl.GL11; -public class ItemSpear extends ItemNpcWeaponInterface{ +public class ItemSpear extends ItemNpcWeaponInterface { - public ItemSpear(int par1, ToolMaterial tool) { - super(par1, tool); - } - - public void renderSpecial(){ + public ItemSpear(int par1, ToolMaterial tool) { + super(par1, tool); + } + + public void renderSpecial() { GL11.glScalef(1f, 1.3f, 1f); GL11.glTranslatef(-0.12f, -0.24f, -0.16f); GL11.glRotatef(180, 0, 1, 0); - } - + } + } diff --git a/src/main/java/noppes/npcs/items/ItemStaff.java b/src/main/java/noppes/npcs/items/ItemStaff.java index d1e7b7bdc..89ce879cf 100644 --- a/src/main/java/noppes/npcs/items/ItemStaff.java +++ b/src/main/java/noppes/npcs/items/ItemStaff.java @@ -20,180 +20,180 @@ import noppes.npcs.entity.EntityProjectile; import noppes.npcs.util.IProjectileCallback; import org.lwjgl.opengl.GL11; -public class ItemStaff extends ItemNpcInterface implements IProjectileCallback{ +public class ItemStaff extends ItemNpcInterface implements IProjectileCallback { - private EnumNpcToolMaterial material; - public ItemStaff(int par1, EnumNpcToolMaterial material) { - super(par1); - this.material = material; - setCreativeTab(CustomItems.tabWeapon); - } - public void renderSpecial(){ + private EnumNpcToolMaterial material; + + public ItemStaff(int par1, EnumNpcToolMaterial material) { + super(par1); + this.material = material; + setCreativeTab(CustomItems.tabWeapon); + } + + public void renderSpecial() { GL11.glScalef(1f, 1.14f, 1f); GL11.glTranslatef(0.14f, -0.3f, 0.08f); - } - @Override - public void onPlayerStoppedUsing(ItemStack stack, World worldObj, EntityPlayer player, int par4) { - if(worldObj.isRemote){ - return; - } - if(stack.stackTagCompound == null) - return; - Entity entity = ((WorldServer)player.worldObj).getEntityByID(stack.stackTagCompound.getInteger("MagicProjectile")); - if(entity == null || !(entity instanceof EntityProjectile)) - return; - EntityProjectile item = (EntityProjectile) entity; - item.callback = this; - item.callbackItem = stack; - item.explosive = true; - item.explosiveDamage = false; - item.explosiveRadius = 1; - item.prevRotationYaw = item.rotationYaw = player.rotationYaw; - item.prevRotationPitch = item.rotationPitch = player.rotationPitch; - item.shoot(2); - - player.worldObj.playSoundAtEntity(player, "customnpcs:magic.shot", 1.0F,1); - - } - - @Override - public void onUsingTick(ItemStack stack, EntityPlayer player, int count) - { - int tick = getMaxItemUseDuration(stack) - count; - if(player.worldObj.isRemote){ - spawnParticle(stack, player); - return; - } - int chargeTime = 20 + material.getHarvestLevel() * 8; - if(tick == chargeTime){ - if(!player.capabilities.isCreativeMode && !hasInfinite(stack)){ - if(!hasItem(player, CustomItems.mana)) - return; - consumeItem(player, CustomItems.mana); - } - player.worldObj.playSoundAtEntity(player, "customnpcs:magic.charge", 1.0F,1); - if(stack.stackTagCompound == null){ - stack.stackTagCompound = new NBTTagCompound(); - } - int damage = 6 + material.getDamageVsEntity() + player.worldObj.rand.nextInt(4); - damage += damage * EnchantInterface.getLevel(EnchantInterface.Damage, stack) * 0.5f; - EntityProjectile projectile = new EntityMagicProjectile(player.worldObj, player, getProjectile(stack), false); - projectile.damage = damage; - projectile.setSpeed(25); - double dx = -MathHelper.sin((float) ((player.rotationYaw / 180F) * Math.PI)) * MathHelper.cos((float) ((player.rotationPitch / 180F) * Math.PI)); - double dz = MathHelper.cos((float) ((player.rotationYaw / 180F) * Math.PI)) * MathHelper.cos((float) ((player.rotationPitch / 180F) * Math.PI)); - projectile.setPosition(player.posX + dx * 0.8, player.posY + 1.5 - player.rotationPitch/80, player.posZ + dz * 0.8); - player.worldObj.spawnEntityInWorld(projectile); - stack.stackTagCompound.setInteger("MagicProjectile", projectile.getEntityId());//entityid - } - if(tick > chargeTime && stack.stackTagCompound != null){ - Entity entity = ((WorldServer)player.worldObj).getEntityByID(stack.stackTagCompound.getInteger("MagicProjectile")); - if(entity == null || !(entity instanceof EntityProjectile)) - return; - EntityProjectile item = (EntityProjectile) entity; - item.ticksInAir = 0; - - double dx = -MathHelper.sin((float) ((player.rotationYaw / 180F) * Math.PI)) * MathHelper.cos((float) ((player.rotationPitch / 180F) * Math.PI)); - double dz = MathHelper.cos((float) ((player.rotationYaw / 180F) * Math.PI)) * MathHelper.cos((float) ((player.rotationPitch / 180F) * Math.PI)); - item.setPosition(player.posX + dx * 0.8, player.posY + 1.5 - player.rotationPitch/80, player.posZ + dz * 0.8); - } - } - @Override - public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer){ - par3EntityPlayer.setItemInUse(par1ItemStack, this.getMaxItemUseDuration(par1ItemStack)); + + @Override + public void onPlayerStoppedUsing(ItemStack stack, World worldObj, EntityPlayer player, int par4) { + if (worldObj.isRemote) { + return; + } + if (stack.stackTagCompound == null) + return; + Entity entity = ((WorldServer) player.worldObj).getEntityByID(stack.stackTagCompound.getInteger("MagicProjectile")); + if (entity == null || !(entity instanceof EntityProjectile)) + return; + EntityProjectile item = (EntityProjectile) entity; + item.callback = this; + item.callbackItem = stack; + item.explosive = true; + item.explosiveDamage = false; + item.explosiveRadius = 1; + item.prevRotationYaw = item.rotationYaw = player.rotationYaw; + item.prevRotationPitch = item.rotationPitch = player.rotationPitch; + item.shoot(2); + + player.worldObj.playSoundAtEntity(player, "customnpcs:magic.shot", 1.0F, 1); + + } + + @Override + public void onUsingTick(ItemStack stack, EntityPlayer player, int count) { + int tick = getMaxItemUseDuration(stack) - count; + if (player.worldObj.isRemote) { + spawnParticle(stack, player); + return; + } + int chargeTime = 20 + material.getHarvestLevel() * 8; + if (tick == chargeTime) { + if (!player.capabilities.isCreativeMode && !hasInfinite(stack)) { + if (!hasItem(player, CustomItems.mana)) + return; + consumeItem(player, CustomItems.mana); + } + player.worldObj.playSoundAtEntity(player, "customnpcs:magic.charge", 1.0F, 1); + if (stack.stackTagCompound == null) { + stack.stackTagCompound = new NBTTagCompound(); + } + int damage = 6 + material.getDamageVsEntity() + player.worldObj.rand.nextInt(4); + damage += damage * EnchantInterface.getLevel(EnchantInterface.Damage, stack) * 0.5f; + EntityProjectile projectile = new EntityMagicProjectile(player.worldObj, player, getProjectile(stack), false); + projectile.damage = damage; + projectile.setSpeed(25); + double dx = -MathHelper.sin((float) ((player.rotationYaw / 180F) * Math.PI)) * MathHelper.cos((float) ((player.rotationPitch / 180F) * Math.PI)); + double dz = MathHelper.cos((float) ((player.rotationYaw / 180F) * Math.PI)) * MathHelper.cos((float) ((player.rotationPitch / 180F) * Math.PI)); + projectile.setPosition(player.posX + dx * 0.8, player.posY + 1.5 - player.rotationPitch / 80, player.posZ + dz * 0.8); + player.worldObj.spawnEntityInWorld(projectile); + stack.stackTagCompound.setInteger("MagicProjectile", projectile.getEntityId());//entityid + } + if (tick > chargeTime && stack.stackTagCompound != null) { + Entity entity = ((WorldServer) player.worldObj).getEntityByID(stack.stackTagCompound.getInteger("MagicProjectile")); + if (entity == null || !(entity instanceof EntityProjectile)) + return; + EntityProjectile item = (EntityProjectile) entity; + item.ticksInAir = 0; + + double dx = -MathHelper.sin((float) ((player.rotationYaw / 180F) * Math.PI)) * MathHelper.cos((float) ((player.rotationPitch / 180F) * Math.PI)); + double dz = MathHelper.cos((float) ((player.rotationYaw / 180F) * Math.PI)) * MathHelper.cos((float) ((player.rotationPitch / 180F) * Math.PI)); + item.setPosition(player.posX + dx * 0.8, player.posY + 1.5 - player.rotationPitch / 80, player.posZ + dz * 0.8); + } + + } + + @Override + public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { + par3EntityPlayer.setItemInUse(par1ItemStack, this.getMaxItemUseDuration(par1ItemStack)); return par1ItemStack; } - @Override - public int getMaxItemUseDuration(ItemStack par1ItemStack){ + + @Override + public int getMaxItemUseDuration(ItemStack par1ItemStack) { return 72000; } - @Override - public EnumAction getItemUseAction(ItemStack par1ItemStack){ + @Override + public EnumAction getItemUseAction(ItemStack par1ItemStack) { return EnumAction.bow; } - - public ItemStack getProjectile(ItemStack stack){ - if(stack.getItem() == CustomItems.staffWood){ - return new ItemStack(CustomItems.spellNature); - } - if(stack.getItem() == CustomItems.staffStone || stack.getItem() == CustomItems.staffDemonic){ - return new ItemStack(CustomItems.spellDark); - } - if(stack.getItem() == CustomItems.staffIron || stack.getItem() == CustomItems.staffMithril){ - return new ItemStack(CustomItems.spellHoly); - } - if(stack.getItem() == CustomItems.staffBronze){ - return new ItemStack(CustomItems.spellLightning); - } - if(stack.getItem() == CustomItems.staffGold){ - return new ItemStack(CustomItems.spellFire); - } - if(stack.getItem() == CustomItems.staffDiamond || stack.getItem() == CustomItems.staffFrost){ - return new ItemStack(CustomItems.spellIce); - } - if(stack.getItem() == CustomItems.staffEmerald){ - return new ItemStack(CustomItems.spellArcane); - } - return new ItemStack(CustomItems.orb,1,stack.getItemDamage()); - } - public void spawnParticle(ItemStack stack, EntityPlayer player){ - if(stack.getItem() == CustomItems.staffWood){ - CustomNpcs.proxy.spawnParticle(player,"Spell",5,2); - CustomNpcs.proxy.spawnParticle(player,"Spell",12,2); - } - else if(stack.getItem() == CustomItems.staffStone || stack.getItem() == CustomItems.staffDemonic){ - CustomNpcs.proxy.spawnParticle(player,"Spell",0x563357,2); - CustomNpcs.proxy.spawnParticle(player,"Spell",0x432744,2); - } - else if(stack.getItem() == CustomItems.staffBronze){ - CustomNpcs.proxy.spawnParticle(player,"Spell",0x83F7F6,2); - CustomNpcs.proxy.spawnParticle(player,"Spell",0x5CF0FF,2); - } - else if(stack.getItem() == CustomItems.staffIron || stack.getItem() == CustomItems.staffMithril){ - CustomNpcs.proxy.spawnParticle(player,"Spell",0xFCFFC9,2); - CustomNpcs.proxy.spawnParticle(player,"Spell",0xEFFF97,2); - } - else if(stack.getItem() == CustomItems.staffGold){ - CustomNpcs.proxy.spawnParticle(player,"Spell",1,2); - CustomNpcs.proxy.spawnParticle(player,"Spell",14,2); - } - else if(stack.getItem() == CustomItems.staffDiamond || stack.getItem() == CustomItems.staffFrost){ - CustomNpcs.proxy.spawnParticle(player,"Spell",0x94DFED,2); - CustomNpcs.proxy.spawnParticle(player,"Spell",0x44B6FF,2); - } - else if(stack.getItem() == CustomItems.staffEmerald){ - CustomNpcs.proxy.spawnParticle(player,"Spell",0xFFC3E7,2); - CustomNpcs.proxy.spawnParticle(player,"Spell",0xFB92FF,2); - } - } - + + public ItemStack getProjectile(ItemStack stack) { + if (stack.getItem() == CustomItems.staffWood) { + return new ItemStack(CustomItems.spellNature); + } + if (stack.getItem() == CustomItems.staffStone || stack.getItem() == CustomItems.staffDemonic) { + return new ItemStack(CustomItems.spellDark); + } + if (stack.getItem() == CustomItems.staffIron || stack.getItem() == CustomItems.staffMithril) { + return new ItemStack(CustomItems.spellHoly); + } + if (stack.getItem() == CustomItems.staffBronze) { + return new ItemStack(CustomItems.spellLightning); + } + if (stack.getItem() == CustomItems.staffGold) { + return new ItemStack(CustomItems.spellFire); + } + if (stack.getItem() == CustomItems.staffDiamond || stack.getItem() == CustomItems.staffFrost) { + return new ItemStack(CustomItems.spellIce); + } + if (stack.getItem() == CustomItems.staffEmerald) { + return new ItemStack(CustomItems.spellArcane); + } + return new ItemStack(CustomItems.orb, 1, stack.getItemDamage()); + } + + public void spawnParticle(ItemStack stack, EntityPlayer player) { + if (stack.getItem() == CustomItems.staffWood) { + CustomNpcs.proxy.spawnParticle(player, "Spell", 5, 2); + CustomNpcs.proxy.spawnParticle(player, "Spell", 12, 2); + } else if (stack.getItem() == CustomItems.staffStone || stack.getItem() == CustomItems.staffDemonic) { + CustomNpcs.proxy.spawnParticle(player, "Spell", 0x563357, 2); + CustomNpcs.proxy.spawnParticle(player, "Spell", 0x432744, 2); + } else if (stack.getItem() == CustomItems.staffBronze) { + CustomNpcs.proxy.spawnParticle(player, "Spell", 0x83F7F6, 2); + CustomNpcs.proxy.spawnParticle(player, "Spell", 0x5CF0FF, 2); + } else if (stack.getItem() == CustomItems.staffIron || stack.getItem() == CustomItems.staffMithril) { + CustomNpcs.proxy.spawnParticle(player, "Spell", 0xFCFFC9, 2); + CustomNpcs.proxy.spawnParticle(player, "Spell", 0xEFFF97, 2); + } else if (stack.getItem() == CustomItems.staffGold) { + CustomNpcs.proxy.spawnParticle(player, "Spell", 1, 2); + CustomNpcs.proxy.spawnParticle(player, "Spell", 14, 2); + } else if (stack.getItem() == CustomItems.staffDiamond || stack.getItem() == CustomItems.staffFrost) { + CustomNpcs.proxy.spawnParticle(player, "Spell", 0x94DFED, 2); + CustomNpcs.proxy.spawnParticle(player, "Spell", 0x44B6FF, 2); + } else if (stack.getItem() == CustomItems.staffEmerald) { + CustomNpcs.proxy.spawnParticle(player, "Spell", 0xFFC3E7, 2); + CustomNpcs.proxy.spawnParticle(player, "Spell", 0xFB92FF, 2); + } + } + @Override - public int getItemEnchantability(){ + public int getItemEnchantability() { return this.material.getEnchantability(); } + @Override - public boolean isItemTool(ItemStack par1ItemStack){ + public boolean isItemTool(ItemStack par1ItemStack) { return true; } - @Override - public boolean onImpact(EntityProjectile entityProjectile, EntityLivingBase entity, ItemStack itemstack) { - int confusion = EnchantInterface.getLevel(EnchantInterface.Confusion, itemstack); - if(confusion > 0){ - if(entity.getRNG().nextInt(4) > confusion) - entity.addPotionEffect(new PotionEffect(Potion.confusion.id, 100)); - } - int poison = EnchantInterface.getLevel(EnchantInterface.Poison, itemstack); - if(poison > 0){ - if(entity.getRNG().nextInt(4) > poison) - entity.addPotionEffect(new PotionEffect(Potion.poison.id, 100)); - } - return false; - } + @Override + public boolean onImpact(EntityProjectile entityProjectile, EntityLivingBase entity, ItemStack itemstack) { + int confusion = EnchantInterface.getLevel(EnchantInterface.Confusion, itemstack); + if (confusion > 0) { + if (entity.getRNG().nextInt(4) > confusion) + entity.addPotionEffect(new PotionEffect(Potion.confusion.id, 100)); + } + int poison = EnchantInterface.getLevel(EnchantInterface.Poison, itemstack); + if (poison > 0) { + if (entity.getRNG().nextInt(4) > poison) + entity.addPotionEffect(new PotionEffect(Potion.poison.id, 100)); + } + return false; + } - public boolean hasInfinite(ItemStack stack){ - return EnchantInterface.getLevel(EnchantInterface.Infinite, stack) > 0; - } + public boolean hasInfinite(ItemStack stack) { + return EnchantInterface.getLevel(EnchantInterface.Infinite, stack) > 0; + } } diff --git a/src/main/java/noppes/npcs/items/ItemTeleporter.java b/src/main/java/noppes/npcs/items/ItemTeleporter.java index 339680845..8d2a890c5 100644 --- a/src/main/java/noppes/npcs/items/ItemTeleporter.java +++ b/src/main/java/noppes/npcs/items/ItemTeleporter.java @@ -24,16 +24,16 @@ import noppes.npcs.NoppesUtilServer; import java.util.List; -public class ItemTeleporter extends Item{ +public class ItemTeleporter extends Item { - public ItemTeleporter(){ + public ItemTeleporter() { maxStackSize = 1; setCreativeTab(CustomItems.tab); } @Override - public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer){ - if(par2World.isRemote || !CustomNpcsPermissions.Instance.hasPermission(par3EntityPlayer, CustomNpcsPermissions.TOOL_TELEPORTER)) + public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { + if (par2World.isRemote || !CustomNpcsPermissions.Instance.hasPermission(par3EntityPlayer, CustomNpcsPermissions.TOOL_TELEPORTER)) return par1ItemStack; NoppesUtilServer.setTeleporterGUI((EntityPlayerMP) par3EntityPlayer); @@ -41,24 +41,24 @@ public class ItemTeleporter extends Item{ } @Override - public boolean onEntitySwing(EntityLivingBase par3EntityPlayer, ItemStack stack){ - if(par3EntityPlayer.worldObj.isRemote) - return false; + public boolean onEntitySwing(EntityLivingBase par3EntityPlayer, ItemStack stack) { + if (par3EntityPlayer.worldObj.isRemote) + return false; float f = 1.0F; float f1 = par3EntityPlayer.prevRotationPitch + (par3EntityPlayer.rotationPitch - par3EntityPlayer.prevRotationPitch) * f; float f2 = par3EntityPlayer.prevRotationYaw + (par3EntityPlayer.rotationYaw - par3EntityPlayer.prevRotationYaw) * f; - double d0 = par3EntityPlayer.prevPosX + (par3EntityPlayer.posX - par3EntityPlayer.prevPosX) * (double)f; - double d1 = par3EntityPlayer.prevPosY + (par3EntityPlayer.posY - par3EntityPlayer.prevPosY) * (double)f + 1.62D - (double)par3EntityPlayer.yOffset; - double d2 = par3EntityPlayer.prevPosZ + (par3EntityPlayer.posZ - par3EntityPlayer.prevPosZ) * (double)f; + double d0 = par3EntityPlayer.prevPosX + (par3EntityPlayer.posX - par3EntityPlayer.prevPosX) * (double) f; + double d1 = par3EntityPlayer.prevPosY + (par3EntityPlayer.posY - par3EntityPlayer.prevPosY) * (double) f + 1.62D - (double) par3EntityPlayer.yOffset; + double d2 = par3EntityPlayer.prevPosZ + (par3EntityPlayer.posZ - par3EntityPlayer.prevPosZ) * (double) f; Vec3 vec3 = Vec3.createVectorHelper(d0, d1, d2); - float f3 = MathHelper.cos(-f2 * 0.017453292F - (float)Math.PI); - float f4 = MathHelper.sin(-f2 * 0.017453292F - (float)Math.PI); + float f3 = MathHelper.cos(-f2 * 0.017453292F - (float) Math.PI); + float f4 = MathHelper.sin(-f2 * 0.017453292F - (float) Math.PI); float f5 = -MathHelper.cos(-f1 * 0.017453292F); float f6 = MathHelper.sin(-f1 * 0.017453292F); float f7 = f4 * f5; float f8 = f3 * f5; double d3 = 80.0D; - Vec3 vec31 = vec3.addVector((double)f7 * d3, (double)f6 * d3, (double)f8 * d3); + Vec3 vec31 = vec3.addVector((double) f7 * d3, (double) f6 * d3, (double) f8 * d3); MovingObjectPosition movingobjectposition = par3EntityPlayer.worldObj.rayTraceBlocks(vec3, vec31, true); if (movingobjectposition == null) return false; @@ -66,16 +66,16 @@ public class ItemTeleporter extends Item{ Vec3 vec32 = par3EntityPlayer.getLook(f); boolean flag = false; float f9 = 1.0F; - List list = par3EntityPlayer.worldObj.getEntitiesWithinAABBExcludingEntity(par3EntityPlayer, par3EntityPlayer.boundingBox.addCoord(vec32.xCoord * d3, vec32.yCoord * d3, vec32.zCoord * d3).expand((double)f9, (double)f9, (double)f9)); + List list = par3EntityPlayer.worldObj.getEntitiesWithinAABBExcludingEntity(par3EntityPlayer, par3EntityPlayer.boundingBox.addCoord(vec32.xCoord * d3, vec32.yCoord * d3, vec32.zCoord * d3).expand((double) f9, (double) f9, (double) f9)); - for (int i = 0; i < list.size(); ++i){ - Entity entity = (Entity)list.get(i); + for (int i = 0; i < list.size(); ++i) { + Entity entity = (Entity) list.get(i); - if (entity.canBeCollidedWith()){ + if (entity.canBeCollidedWith()) { float f10 = entity.getCollisionBorderSize(); - AxisAlignedBB axisalignedbb = entity.boundingBox.expand((double)f10, (double)f10, (double)f10); + AxisAlignedBB axisalignedbb = entity.boundingBox.expand((double) f10, (double) f10, (double) f10); - if (axisalignedbb.isVecInside(vec3)){ + if (axisalignedbb.isVecInside(vec3)) { flag = true; } } @@ -84,40 +84,40 @@ public class ItemTeleporter extends Item{ if (flag) return false; - if (movingobjectposition.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK){ + if (movingobjectposition.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) { int i = movingobjectposition.blockX; int j = movingobjectposition.blockY; int k = movingobjectposition.blockZ; - while(par3EntityPlayer.worldObj.getBlock(i, j, k) != Blocks.air){ - j++; + while (par3EntityPlayer.worldObj.getBlock(i, j, k) != Blocks.air) { + j++; } par3EntityPlayer.setPositionAndUpdate(i + 0.5F, j + 1.0F, k + 0.5F); } - return true; + return true; } @Override - public int getColorFromItemStack(ItemStack par1ItemStack, int par2){ - return 0x8B4513; + public int getColorFromItemStack(ItemStack par1ItemStack, int par2) { + return 0x8B4513; } @Override - public boolean requiresMultipleRenderPasses(){ + public boolean requiresMultipleRenderPasses() { return true; } @SideOnly(Side.CLIENT) @Override - public void registerIcons(IIconRegister par1IconRegister){ + public void registerIcons(IIconRegister par1IconRegister) { this.itemIcon = Items.feather.getIconFromDamage(0); } @Override - public Item setUnlocalizedName(String name){ - GameRegistry.registerItem(this, name); - return super.setUnlocalizedName(name); + public Item setUnlocalizedName(String name) { + GameRegistry.registerItem(this, name); + return super.setUnlocalizedName(name); } } diff --git a/src/main/java/noppes/npcs/items/ItemThrowingShuriken.java b/src/main/java/noppes/npcs/items/ItemThrowingShuriken.java index 643092b61..ac326ffdc 100644 --- a/src/main/java/noppes/npcs/items/ItemThrowingShuriken.java +++ b/src/main/java/noppes/npcs/items/ItemThrowingShuriken.java @@ -2,19 +2,20 @@ package noppes.npcs.items; import org.lwjgl.opengl.GL11; -public class ItemThrowingShuriken extends ItemThrowingWeapon{ +public class ItemThrowingShuriken extends ItemThrowingWeapon { - public ItemThrowingShuriken(int par1) { - super(par1); - } + public ItemThrowingShuriken(int par1) { + super(par1); + } - @Override - public void renderSpecial(){ + @Override + public void renderSpecial() { GL11.glScalef(0.5f, 0.5f, 0.5f); GL11.glTranslatef(-0.1F, 0.3f, 0f); - } - @Override - public boolean shouldRotateAroundWhenRendering(){ - return true; - } + } + + @Override + public boolean shouldRotateAroundWhenRendering() { + return true; + } } diff --git a/src/main/java/noppes/npcs/items/ItemThrowingWeapon.java b/src/main/java/noppes/npcs/items/ItemThrowingWeapon.java index 00b2922b1..ce00858ac 100644 --- a/src/main/java/noppes/npcs/items/ItemThrowingWeapon.java +++ b/src/main/java/noppes/npcs/items/ItemThrowingWeapon.java @@ -7,66 +7,68 @@ import noppes.npcs.CustomItems; import noppes.npcs.entity.EntityProjectile; import org.lwjgl.opengl.GL11; -public class ItemThrowingWeapon extends ItemNpcInterface{ - private boolean rotating = false; - private int damage = 2; - private boolean dropItem = false; - - public ItemThrowingWeapon(int par1) { - super(par1); - setCreativeTab(CustomItems.tabWeapon); - } +public class ItemThrowingWeapon extends ItemNpcInterface { + private boolean rotating = false; + private int damage = 2; + private boolean dropItem = false; - public void onPlayerStoppedUsing(ItemStack par1ItemStack, World worldObj, EntityPlayer player, int par4) - { - if(worldObj.isRemote){ - player.swingItem(); - return; - } - EntityProjectile projectile = new EntityProjectile(worldObj, player, new ItemStack(par1ItemStack.getItem(), 1,par1ItemStack.getItemDamage()), false); - projectile.damage = damage; - projectile.canBePickedUp = !player.capabilities.isCreativeMode && dropItem; - projectile.setRotating(rotating);; - projectile.setIs3D(true); - projectile.setStickInWall(true); - projectile.setHasGravity(true); - projectile.setSpeed(12); - - if(!player.capabilities.isCreativeMode){ - consumeItem(player, this); - } - projectile.shoot(1); - worldObj.playSoundAtEntity(player, "customnpcs:misc.swosh", 1.0F,1); - worldObj.spawnEntityInWorld(projectile); + public ItemThrowingWeapon(int par1) { + super(par1); + setCreativeTab(CustomItems.tabWeapon); } - public ItemThrowingWeapon setRotating(){ - rotating = true; - return this; + + public void onPlayerStoppedUsing(ItemStack par1ItemStack, World worldObj, EntityPlayer player, int par4) { + if (worldObj.isRemote) { + player.swingItem(); + return; + } + EntityProjectile projectile = new EntityProjectile(worldObj, player, new ItemStack(par1ItemStack.getItem(), 1, par1ItemStack.getItemDamage()), false); + projectile.damage = damage; + projectile.canBePickedUp = !player.capabilities.isCreativeMode && dropItem; + projectile.setRotating(rotating); + ; + projectile.setIs3D(true); + projectile.setStickInWall(true); + projectile.setHasGravity(true); + projectile.setSpeed(12); + + if (!player.capabilities.isCreativeMode) { + consumeItem(player, this); + } + projectile.shoot(1); + worldObj.playSoundAtEntity(player, "customnpcs:misc.swosh", 1.0F, 1); + worldObj.spawnEntityInWorld(projectile); } - public ItemThrowingWeapon setDamage(int damage){ - this.damage = damage; - return this; + + public ItemThrowingWeapon setRotating() { + rotating = true; + return this; } - public ItemThrowingWeapon setDropItem(){ - dropItem = true; - return this; + + public ItemThrowingWeapon setDamage(int damage) { + this.damage = damage; + return this; } - - @Override - public void renderSpecial(){ - super.renderSpecial(); + + public ItemThrowingWeapon setDropItem() { + dropItem = true; + return this; + } + + @Override + public void renderSpecial() { + super.renderSpecial(); GL11.glTranslatef(0.2F, 0.1f, 0.06f); - } - - @Override - public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) - { - par3EntityPlayer.setItemInUse(par1ItemStack, this.getMaxItemUseDuration(par1ItemStack)); + } + + @Override + public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { + par3EntityPlayer.setItemInUse(par1ItemStack, this.getMaxItemUseDuration(par1ItemStack)); return par1ItemStack; } - @Override - public int getMaxItemUseDuration(ItemStack par1ItemStack) - { + + @Override + public int getMaxItemUseDuration(ItemStack par1ItemStack) { return 72000; } } diff --git a/src/main/java/noppes/npcs/items/ItemWand.java b/src/main/java/noppes/npcs/items/ItemWand.java index d4ef7bdc8..3668d9f95 100644 --- a/src/main/java/noppes/npcs/items/ItemWand.java +++ b/src/main/java/noppes/npcs/items/ItemWand.java @@ -4,21 +4,21 @@ import net.minecraft.item.ItemStack; import noppes.npcs.CustomItems; import org.lwjgl.opengl.GL11; -public class ItemWand extends ItemNpcInterface{ +public class ItemWand extends ItemNpcInterface { - public ItemWand(int par1) { - super(par1); - setCreativeTab(CustomItems.tabMisc); - } - - @Override - public boolean hasEffect(ItemStack par1ItemStack, int pass){ - return true; - } + public ItemWand(int par1) { + super(par1); + setCreativeTab(CustomItems.tabMisc); + } - @Override - public void renderSpecial(){ + @Override + public boolean hasEffect(ItemStack par1ItemStack, int pass) { + return true; + } + + @Override + public void renderSpecial() { GL11.glScalef(0.54f, 0.54f, 0.54f); GL11.glTranslatef(0.1F, 0.5f, 0.1f); - } + } } diff --git a/src/main/java/noppes/npcs/items/ItemWarhammer.java b/src/main/java/noppes/npcs/items/ItemWarhammer.java index 208d2caae..6a008e892 100644 --- a/src/main/java/noppes/npcs/items/ItemWarhammer.java +++ b/src/main/java/noppes/npcs/items/ItemWarhammer.java @@ -2,15 +2,15 @@ package noppes.npcs.items; import org.lwjgl.opengl.GL11; -public class ItemWarhammer extends ItemNpcWeaponInterface{ +public class ItemWarhammer extends ItemNpcWeaponInterface { - public ItemWarhammer(int par1 ,ToolMaterial tool) { - super(par1, tool); - } + public ItemWarhammer(int par1, ToolMaterial tool) { + super(par1, tool); + } - @Override - public void renderSpecial(){ + @Override + public void renderSpecial() { GL11.glScalef(1.2f, 1.4f, 1f); GL11.glTranslatef(0.2F, -0.08f, 0.08f); - } + } } diff --git a/src/main/java/noppes/npcs/items/MoneyBagContents.java b/src/main/java/noppes/npcs/items/MoneyBagContents.java index 9a0b75d6c..e75e2e615 100644 --- a/src/main/java/noppes/npcs/items/MoneyBagContents.java +++ b/src/main/java/noppes/npcs/items/MoneyBagContents.java @@ -5,49 +5,49 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; public class MoneyBagContents { - private EntityPlayer player; - private int[] coinData = new int[]{0,0,0,0,0,0,0}; + private EntityPlayer player; + private int[] coinData = new int[]{0, 0, 0, 0, 0, 0, 0}; - public MoneyBagContents(EntityPlayer player) { - this.player = player; - } - - public void readNBT(NBTTagCompound compound){ - coinData = compound.getIntArray("coins"); - } - - public NBTTagCompound writeNBT(){ - NBTTagCompound compound = new NBTTagCompound(); - compound.setIntArray("coins", coinData); - return compound; - } - - - public enum CoinType { - WOOD,STONE,IRON,GOLD,DIAMOND,BRONZE,EMERALD; - } - - - //Adds stackSize to coinType - public void AddCurrency(CoinType coinType, byte stackSize, ItemStack theBag){ - coinData[coinType.ordinal()] = coinData[coinType.ordinal()] + stackSize; - theBag.stackTagCompound.setTag("contents", writeNBT()); - } - - //Creates amount number of coinType in playerInventory and subtracts from the moneyBag. - public void WithdrawCurrencyByVal(CoinType coinType, short amount, ItemStack theBag) { - int amtAdded = 0; - - coinData[coinType.ordinal()] = coinData[coinType.ordinal()]- amtAdded; - theBag.stackTagCompound.setTag("contents", writeNBT()); - } - - //Creates numStacks of coinType in recievingInventory and subtracts from the moneyBag. - public void WithdrawCurrencyByStack(CoinType coinType, byte numStacks, ItemStack theBag) { - int amtAdded = 0; - //check inventory space - - coinData[coinType.ordinal()] = coinData[coinType.ordinal()]- amtAdded; - theBag.stackTagCompound.setTag("contents", writeNBT()); - } + public MoneyBagContents(EntityPlayer player) { + this.player = player; + } + + public void readNBT(NBTTagCompound compound) { + coinData = compound.getIntArray("coins"); + } + + public NBTTagCompound writeNBT() { + NBTTagCompound compound = new NBTTagCompound(); + compound.setIntArray("coins", coinData); + return compound; + } + + + public enum CoinType { + WOOD, STONE, IRON, GOLD, DIAMOND, BRONZE, EMERALD; + } + + + //Adds stackSize to coinType + public void AddCurrency(CoinType coinType, byte stackSize, ItemStack theBag) { + coinData[coinType.ordinal()] = coinData[coinType.ordinal()] + stackSize; + theBag.stackTagCompound.setTag("contents", writeNBT()); + } + + //Creates amount number of coinType in playerInventory and subtracts from the moneyBag. + public void WithdrawCurrencyByVal(CoinType coinType, short amount, ItemStack theBag) { + int amtAdded = 0; + + coinData[coinType.ordinal()] = coinData[coinType.ordinal()] - amtAdded; + theBag.stackTagCompound.setTag("contents", writeNBT()); + } + + //Creates numStacks of coinType in recievingInventory and subtracts from the moneyBag. + public void WithdrawCurrencyByStack(CoinType coinType, byte numStacks, ItemStack theBag) { + int amtAdded = 0; + //check inventory space + + coinData[coinType.ordinal()] = coinData[coinType.ordinal()] - amtAdded; + theBag.stackTagCompound.setTag("contents", writeNBT()); + } } diff --git a/src/main/java/noppes/npcs/mixin/CustomNPCsMixinPlugin.java b/src/main/java/noppes/npcs/mixin/CustomNPCsMixinPlugin.java index 1088c2c44..9b09759c0 100644 --- a/src/main/java/noppes/npcs/mixin/CustomNPCsMixinPlugin.java +++ b/src/main/java/noppes/npcs/mixin/CustomNPCsMixinPlugin.java @@ -36,15 +36,15 @@ public class CustomNPCsMixinPlugin implements IMixinConfigPlugin { public List getMixins() { // Load Mixin Config - String configPath = "config" + File.separator + "CustomNpcPlus" + File.separator; + String configPath = "config" + File.separator + "CustomNpcPlus" + File.separator; ConfigMixin.init(new File(configPath + "mixin.cfg")); boolean client = FMLLaunchHandler.side().isClient(); List mixins = new ArrayList<>(); // Client Only Mixins - if(client){ - if (ConfigMixin.EntityRendererMixin){ + if (client) { + if (ConfigMixin.EntityRendererMixin) { mixins.add("MixinEntityRenderer"); } if (ConfigMixin.AnimationMixin) { diff --git a/src/main/java/noppes/npcs/mixin/MixinEntityRenderer.java b/src/main/java/noppes/npcs/mixin/MixinEntityRenderer.java index b23a03e7f..af192b5eb 100644 --- a/src/main/java/noppes/npcs/mixin/MixinEntityRenderer.java +++ b/src/main/java/noppes/npcs/mixin/MixinEntityRenderer.java @@ -14,12 +14,11 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; public abstract class MixinEntityRenderer { @Inject(method = "renderWorld", at = @At(value = "RETURN")) - private void renderFirstPersonOverlays(float p_78476_1_, long p_78476_2_, CallbackInfo callbackInfo) - { + private void renderFirstPersonOverlays(float p_78476_1_, long p_78476_2_, CallbackInfo callbackInfo) { EntityPlayer player = Minecraft.getMinecraft().thePlayer; if (ClientEventHandler.hasOverlays(player)) { GL11.glPushMatrix(); - ClientEventHandler.renderCNPCSelf.renderHand(p_78476_1_,0); + ClientEventHandler.renderCNPCSelf.renderHand(p_78476_1_, 0); GL11.glPopMatrix(); } } diff --git a/src/main/java/noppes/npcs/mixin/MixinItemRenderer.java b/src/main/java/noppes/npcs/mixin/MixinItemRenderer.java index 1b1403791..174a81e4a 100644 --- a/src/main/java/noppes/npcs/mixin/MixinItemRenderer.java +++ b/src/main/java/noppes/npcs/mixin/MixinItemRenderer.java @@ -1,55 +1,27 @@ package noppes.npcs.mixin; -import net.minecraft.block.Block; import net.minecraft.client.Minecraft; -import net.minecraft.client.entity.EntityClientPlayerMP; import net.minecraft.client.model.ModelBiped; -import net.minecraft.client.model.ModelRenderer; -import net.minecraft.client.renderer.*; -import net.minecraft.client.renderer.entity.*; -import net.minecraft.client.renderer.texture.TextureManager; -import net.minecraft.client.renderer.texture.TextureUtil; -import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityLivingBase; +import net.minecraft.client.renderer.ItemRenderer; +import net.minecraft.client.renderer.RenderBlocks; +import net.minecraft.client.renderer.entity.Render; +import net.minecraft.client.renderer.entity.RenderManager; +import net.minecraft.client.renderer.entity.RendererLivingEntity; import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.init.Items; -import net.minecraft.item.Item; -import net.minecraft.item.ItemArmor; -import net.minecraft.item.ItemBlock; -import net.minecraft.item.ItemStack; -import net.minecraft.util.IIcon; -import net.minecraft.util.MathHelper; import net.minecraft.util.ResourceLocation; -import net.minecraftforge.client.ForgeHooksClient; -import net.minecraftforge.client.IItemRenderer; -import net.minecraftforge.client.MinecraftForgeClient; import noppes.npcs.AnimationMixinFunctions; -import noppes.npcs.client.ClientCacheHandler; import noppes.npcs.client.ClientEventHandler; -import noppes.npcs.constants.EnumAnimationPart; -import noppes.npcs.controllers.data.Animation; -import noppes.npcs.controllers.data.AnimationData; -import noppes.npcs.controllers.data.Frame; -import noppes.npcs.controllers.data.FramePart; -import org.lwjgl.opengl.GL11; -import org.lwjgl.opengl.GL12; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; - -import static net.minecraftforge.client.IItemRenderer.ItemRenderType.EQUIPPED_FIRST_PERSON; - @Mixin(ItemRenderer.class) public abstract class MixinItemRenderer { @Inject(method = "renderItemInFirstPerson", at = @At(value = "HEAD"), cancellable = true) - public void renderItemInFirstPerson(float p_78440_1_, CallbackInfo callbackInfo) - { + public void renderItemInFirstPerson(float p_78440_1_, CallbackInfo callbackInfo) { EntityPlayer player = Minecraft.getMinecraft().thePlayer; Render renderer = RenderManager.instance.getEntityRenderObject(player); if (renderer instanceof RendererLivingEntity && ((RendererLivingEntity) renderer).mainModel instanceof ModelBiped) { @@ -71,6 +43,8 @@ public abstract class MixinItemRenderer { } } - @Shadow private RenderBlocks renderBlocksIr; - @Shadow private static ResourceLocation RES_ITEM_GLINT; + @Shadow + private RenderBlocks renderBlocksIr; + @Shadow + private static ResourceLocation RES_ITEM_GLINT; } diff --git a/src/main/java/noppes/npcs/mixin/MixinItemStack.java b/src/main/java/noppes/npcs/mixin/MixinItemStack.java index aaa2adbe4..8615573c0 100644 --- a/src/main/java/noppes/npcs/mixin/MixinItemStack.java +++ b/src/main/java/noppes/npcs/mixin/MixinItemStack.java @@ -1,14 +1,15 @@ package noppes.npcs.mixin; +import kamkeel.npcs.util.AttributeItemUtil; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; -import kamkeel.npcs.util.AttributeItemUtil; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + import java.util.List; import static kamkeel.npcs.util.AttributeItemUtil.TAG_RPGCORE; diff --git a/src/main/java/noppes/npcs/mixin/MixinModelRenderer.java b/src/main/java/noppes/npcs/mixin/MixinModelRenderer.java index d5e8eadbd..e38805870 100644 --- a/src/main/java/noppes/npcs/mixin/MixinModelRenderer.java +++ b/src/main/java/noppes/npcs/mixin/MixinModelRenderer.java @@ -16,23 +16,40 @@ import java.util.List; @Mixin(value = ModelRenderer.class) public abstract class MixinModelRenderer { - @Shadow public float rotationPointX; - @Shadow public float rotationPointY; - @Shadow public float rotationPointZ; - @Shadow public float rotateAngleX; - @Shadow public float rotateAngleY; - @Shadow public float rotateAngleZ; - @Shadow public float offsetX; - @Shadow public float offsetY; - @Shadow public float offsetZ; - @Shadow public boolean isHidden; - @Shadow public boolean showModel; - @Shadow public boolean compiled; - @Shadow private int displayList; - @Shadow public List childModels; - @Shadow abstract void compileDisplayList(float p_78788_1_); + @Shadow + public float rotationPointX; + @Shadow + public float rotationPointY; + @Shadow + public float rotationPointZ; + @Shadow + public float rotateAngleX; + @Shadow + public float rotateAngleY; + @Shadow + public float rotateAngleZ; + @Shadow + public float offsetX; + @Shadow + public float offsetY; + @Shadow + public float offsetZ; + @Shadow + public boolean isHidden; + @Shadow + public boolean showModel; + @Shadow + public boolean compiled; + @Shadow + private int displayList; + @Shadow + public List childModels; - @Shadow public ModelBase baseModel; + @Shadow + abstract void compileDisplayList(float p_78788_1_); + + @Shadow + public ModelBase baseModel; /** * @author Someone @@ -40,16 +57,15 @@ public abstract class MixinModelRenderer { */ @Overwrite @SideOnly(Side.CLIENT) - public void render(float p_78785_1_) - { + public void render(float p_78785_1_) { if (ClientEventHandler.partNames.isEmpty()) { - String[] headNames = new String[]{"field_78116_c","bipedHead","bipedHeadwear","head","Head","headwear", - "bipedHeadg","bipedHeadt","bipedHeadgh","bipedHeadv","bipedHeadb","bipedHeadt2"}; - String[] bodyNames = new String[]{"field_78115_e","bipedBody","B1","body","Body","UpperBody","Body1","BodyBase"}; - String[] larmNames = new String[]{"field_78113_g","bipedLeftArm","LA","leftarm","ArmL","Arm1L","ArmL1"}; - String[] rarmNames = new String[]{"field_78112_f","bipedRightArm","RA","rightarm","ArmR","Arm1R","ArmR1"}; - String[] llegNames = new String[]{"field_78124_i","bipedLeftLeg","LL","leftleg","LegL","Leg1L","LegL1"}; - String[] rlegNames = new String[]{"field_78123_h","bipedRightLeg","RL","rightleg","LegR","Leg1R","LegR1"}; + String[] headNames = new String[]{"field_78116_c", "bipedHead", "bipedHeadwear", "head", "Head", "headwear", + "bipedHeadg", "bipedHeadt", "bipedHeadgh", "bipedHeadv", "bipedHeadb", "bipedHeadt2"}; + String[] bodyNames = new String[]{"field_78115_e", "bipedBody", "B1", "body", "Body", "UpperBody", "Body1", "BodyBase"}; + String[] larmNames = new String[]{"field_78113_g", "bipedLeftArm", "LA", "leftarm", "ArmL", "Arm1L", "ArmL1"}; + String[] rarmNames = new String[]{"field_78112_f", "bipedRightArm", "RA", "rightarm", "ArmR", "Arm1R", "ArmR1"}; + String[] llegNames = new String[]{"field_78124_i", "bipedLeftLeg", "LL", "leftleg", "LegL", "Leg1L", "LegL1"}; + String[] rlegNames = new String[]{"field_78123_h", "bipedRightLeg", "RL", "rightleg", "LegR", "Leg1R", "LegR1"}; ClientEventHandler.partNames.put(EnumAnimationPart.HEAD, headNames); ClientEventHandler.partNames.put(EnumAnimationPart.BODY, bodyNames); @@ -58,12 +74,9 @@ public abstract class MixinModelRenderer { ClientEventHandler.partNames.put(EnumAnimationPart.LEFT_LEG, llegNames); ClientEventHandler.partNames.put(EnumAnimationPart.RIGHT_LEG, rlegNames); } - if (!this.isHidden) - { - if (this.showModel) - { - if (!this.compiled) - { + if (!this.isHidden) { + if (this.showModel) { + if (!this.compiled) { this.compileDisplayList(p_78785_1_); } @@ -83,68 +96,53 @@ public abstract class MixinModelRenderer { GL11.glTranslatef(this.offsetX, this.offsetY, this.offsetZ); int i; - if (this.rotateAngleX == 0.0F && this.rotateAngleY == 0.0F && this.rotateAngleZ == 0.0F) - { - if (this.rotationPointX == 0.0F && this.rotationPointY == 0.0F && this.rotationPointZ == 0.0F) - { + if (this.rotateAngleX == 0.0F && this.rotateAngleY == 0.0F && this.rotateAngleZ == 0.0F) { + if (this.rotationPointX == 0.0F && this.rotationPointY == 0.0F && this.rotationPointZ == 0.0F) { GL11.glCallList(this.displayList); - if (this.childModels != null) - { - for (i = 0; i < this.childModels.size(); ++i) - { - if(this.childModels.get(i) instanceof ModelRenderer){ - ((ModelRenderer)this.childModels.get(i)).render(p_78785_1_); + if (this.childModels != null) { + for (i = 0; i < this.childModels.size(); ++i) { + if (this.childModels.get(i) instanceof ModelRenderer) { + ((ModelRenderer) this.childModels.get(i)).render(p_78785_1_); } } } - } - else - { + } else { GL11.glTranslatef(this.rotationPointX * p_78785_1_, this.rotationPointY * p_78785_1_, this.rotationPointZ * p_78785_1_); GL11.glCallList(this.displayList); - if (this.childModels != null) - { - for (i = 0; i < this.childModels.size(); ++i) - { - if(this.childModels.get(i) instanceof ModelRenderer){ - ((ModelRenderer)this.childModels.get(i)).render(p_78785_1_); + if (this.childModels != null) { + for (i = 0; i < this.childModels.size(); ++i) { + if (this.childModels.get(i) instanceof ModelRenderer) { + ((ModelRenderer) this.childModels.get(i)).render(p_78785_1_); } } } GL11.glTranslatef(-this.rotationPointX * p_78785_1_, -this.rotationPointY * p_78785_1_, -this.rotationPointZ * p_78785_1_); } - } - else - { + } else { GL11.glPushMatrix(); GL11.glTranslatef(this.rotationPointX * p_78785_1_, this.rotationPointY * p_78785_1_, this.rotationPointZ * p_78785_1_); - if (this.rotateAngleZ != 0.0F) - { - GL11.glRotatef(this.rotateAngleZ * (180F / (float)Math.PI), 0.0F, 0.0F, 1.0F); + if (this.rotateAngleZ != 0.0F) { + GL11.glRotatef(this.rotateAngleZ * (180F / (float) Math.PI), 0.0F, 0.0F, 1.0F); } - if (this.rotateAngleY != 0.0F) - { - GL11.glRotatef(this.rotateAngleY * (180F / (float)Math.PI), 0.0F, 1.0F, 0.0F); + if (this.rotateAngleY != 0.0F) { + GL11.glRotatef(this.rotateAngleY * (180F / (float) Math.PI), 0.0F, 1.0F, 0.0F); } - if (this.rotateAngleX != 0.0F) - { - GL11.glRotatef(this.rotateAngleX * (180F / (float)Math.PI), 1.0F, 0.0F, 0.0F); + if (this.rotateAngleX != 0.0F) { + GL11.glRotatef(this.rotateAngleX * (180F / (float) Math.PI), 1.0F, 0.0F, 0.0F); } GL11.glCallList(this.displayList); - if (this.childModels != null) - { - for (i = 0; i < this.childModels.size(); ++i) - { - if(this.childModels.get(i) instanceof ModelRenderer){ - ((ModelRenderer)this.childModels.get(i)).render(p_78785_1_); + if (this.childModels != null) { + for (i = 0; i < this.childModels.size(); ++i) { + if (this.childModels.get(i) instanceof ModelRenderer) { + ((ModelRenderer) this.childModels.get(i)).render(p_78785_1_); } } } diff --git a/src/main/java/noppes/npcs/quests/QuestDialog.java b/src/main/java/noppes/npcs/quests/QuestDialog.java index 7a5e10a57..554348a99 100644 --- a/src/main/java/noppes/npcs/quests/QuestDialog.java +++ b/src/main/java/noppes/npcs/quests/QuestDialog.java @@ -20,121 +20,119 @@ import java.util.*; public class QuestDialog extends QuestInterface implements IQuestDialog { - public HashMap dialogs = new HashMap(); - - @Override - public void readEntityFromNBT(NBTTagCompound compound) { - dialogs = NBTTags.getIntegerIntegerMap(compound.getTagList("QuestDialogs", 10)); - } - - @Override - public void writeEntityToNBT(NBTTagCompound compound) { - compound.setTag("QuestDialogs", NBTTags.nbtIntegerIntegerMap(dialogs)); - } - - @Override - public boolean isCompleted(PlayerData playerData) { - for(int dialogId : dialogs.values()) - if(!playerData.dialogData.dialogsRead.contains(dialogId)) - return false; - return true; - } - - @Override - public void handleComplete(EntityPlayer player) { - super.handleComplete(player); - } - - @Override - public Vector getQuestLogStatus(EntityPlayer player) { - Vector vec = new Vector(); - for(int dialogId : dialogs.values()){ - Dialog dialog = DialogController.Instance.dialogs.get(dialogId); - if(dialog == null) - continue; - String title = dialog.title; - if(PlayerDataController.Instance.getPlayerData(player).dialogData.dialogsRead.contains(dialogId)) - title += " (read)"; - else - title += " (unread)"; - vec.add(title); - } - - return vec; - } + public HashMap dialogs = new HashMap(); @Override - public IQuestObjective[] getObjectives(EntityPlayer player) { - List list = new ArrayList(); + public void readEntityFromNBT(NBTTagCompound compound) { + dialogs = NBTTags.getIntegerIntegerMap(compound.getTagList("QuestDialogs", 10)); + } - for(int i = 0; i < 3; ++i) { - if (this.dialogs.containsKey(i)) { - Dialog dialog = (Dialog)DialogController.Instance.dialogs.get(this.dialogs.get(i)); - if (dialog != null) { - list.add(new noppes.npcs.quests.QuestDialog.QuestDialogObjective(this, player, dialog)); - } - } - } + @Override + public void writeEntityToNBT(NBTTagCompound compound) { + compound.setTag("QuestDialogs", NBTTags.nbtIntegerIntegerMap(dialogs)); + } - return (IQuestObjective[])list.toArray(new IQuestObjective[list.size()]); - } + @Override + public boolean isCompleted(PlayerData playerData) { + for (int dialogId : dialogs.values()) + if (!playerData.dialogData.dialogsRead.contains(dialogId)) + return false; + return true; + } + + @Override + public void handleComplete(EntityPlayer player) { + super.handleComplete(player); + } + + @Override + public Vector getQuestLogStatus(EntityPlayer player) { + Vector vec = new Vector(); + for (int dialogId : dialogs.values()) { + Dialog dialog = DialogController.Instance.dialogs.get(dialogId); + if (dialog == null) + continue; + String title = dialog.title; + if (PlayerDataController.Instance.getPlayerData(player).dialogData.dialogsRead.contains(dialogId)) + title += " (read)"; + else + title += " (unread)"; + vec.add(title); + } + + return vec; + } + + @Override + public IQuestObjective[] getObjectives(EntityPlayer player) { + List list = new ArrayList(); + + for (int i = 0; i < 3; ++i) { + if (this.dialogs.containsKey(i)) { + Dialog dialog = (Dialog) DialogController.Instance.dialogs.get(this.dialogs.get(i)); + if (dialog != null) { + list.add(new noppes.npcs.quests.QuestDialog.QuestDialogObjective(this, player, dialog)); + } + } + } + + return (IQuestObjective[]) list.toArray(new IQuestObjective[list.size()]); + } @Override public IQuestObjective[] getPartyObjectives(Party party) { List list = new ArrayList(); - for(int i = 0; i < 3; ++i) { + for (int i = 0; i < 3; ++i) { if (this.dialogs.containsKey(i)) { - Dialog dialog = (Dialog)DialogController.Instance.dialogs.get(this.dialogs.get(i)); + Dialog dialog = (Dialog) DialogController.Instance.dialogs.get(this.dialogs.get(i)); if (dialog != null) { list.add(new noppes.npcs.quests.QuestDialog.QuestDialogObjective(this, party, dialog)); } } } - return (IQuestObjective[])list.toArray(new IQuestObjective[list.size()]); + return (IQuestObjective[]) list.toArray(new IQuestObjective[list.size()]); } @Override public Vector getPartyQuestLogStatus(Party party) { Vector vec = new Vector(); - if(party == null) + if (party == null) return vec; - if(party.getQuestData() == null) + if (party.getQuestData() == null) return vec; - if(party.getQuestData().quest == null) + if (party.getQuestData().quest == null) return vec; EnumPartyObjectives objectives = party.getQuestData().quest.partyOptions.objectiveRequirement; - if(objectives == EnumPartyObjectives.All){ - for(int dialogId : dialogs.values()){ + if (objectives == EnumPartyObjectives.All) { + for (int dialogId : dialogs.values()) { Dialog dialog = DialogController.Instance.dialogs.get(dialogId); - if(dialog == null) + if (dialog == null) continue; ArrayList unread = new ArrayList<>(); - for (UUID uuid: party.getPlayerUUIDs()) { + for (UUID uuid : party.getPlayerUUIDs()) { EntityPlayer player = NoppesUtilServer.getPlayer(uuid); PlayerData playerData; - if(player != null){ + if (player != null) { playerData = PlayerDataController.Instance.getPlayerData(player); - } - else { + } else { playerData = PlayerDataController.Instance.getPlayerDataCache(uuid.toString()); } - if(playerData != null){ - if(!playerData.dialogData.dialogsRead.contains(dialogId)) + if (playerData != null) { + if (!playerData.dialogData.dialogsRead.contains(dialogId)) unread.add(playerData.playername); } } String title = dialog.title; - if(!unread.isEmpty()){ + if (!unread.isEmpty()) { title += " (unread)"; - } - else { + } else { title += " (read)"; } vec.add(title); @@ -151,23 +149,22 @@ public class QuestDialog extends QuestInterface implements IQuestDialog { } } return vec; - } else if(objectives == EnumPartyObjectives.Leader){ + } else if (objectives == EnumPartyObjectives.Leader) { EntityPlayer leader = NoppesUtilServer.getPlayer(party.getLeaderUUID()); PlayerData playerData; - if(leader != null){ + if (leader != null) { playerData = PlayerDataController.Instance.getPlayerData(leader); - } - else { + } else { playerData = PlayerDataController.Instance.getPlayerDataCache(party.getLeaderUUID().toString()); } - if(playerData == null) + if (playerData == null) return vec; - for(int dialogId : dialogs.values()){ + for (int dialogId : dialogs.values()) { Dialog dialog = DialogController.Instance.dialogs.get(dialogId); - if(dialog == null) + if (dialog == null) continue; String title = dialog.title; - if(playerData.dialogData.dialogsRead.contains(dialogId)) + if (playerData.dialogData.dialogsRead.contains(dialogId)) title += " (read)"; else title += " (unread)"; @@ -176,31 +173,30 @@ public class QuestDialog extends QuestInterface implements IQuestDialog { return vec; } else { Set readValues = new HashSet<>(); - for(int dialogId : dialogs.values()){ + for (int dialogId : dialogs.values()) { Dialog dialog = DialogController.Instance.dialogs.get(dialogId); - if(dialog == null) + if (dialog == null) continue; - for (UUID uuid: party.getPlayerUUIDs()) { + for (UUID uuid : party.getPlayerUUIDs()) { EntityPlayer player = NoppesUtilServer.getPlayer(uuid); PlayerData sharedData; - if(player != null){ + if (player != null) { sharedData = PlayerDataController.Instance.getPlayerData(player); - } - else { + } else { sharedData = PlayerDataController.Instance.getPlayerDataCache(uuid.toString()); } - if(sharedData != null){ - if(sharedData.dialogData.dialogsRead.contains(dialogId)) + if (sharedData != null) { + if (sharedData.dialogData.dialogsRead.contains(dialogId)) readValues.add(dialogId); } } } - for(int dialogId : dialogs.values()){ + for (int dialogId : dialogs.values()) { Dialog dialog = DialogController.Instance.dialogs.get(dialogId); - if(dialog == null) + if (dialog == null) continue; String title = dialog.title; - if(readValues.contains(dialogId)) + if (readValues.contains(dialogId)) title += " (read)"; else title += " (unread)"; @@ -212,30 +208,29 @@ public class QuestDialog extends QuestInterface implements IQuestDialog { @Override public boolean isPartyCompleted(Party party) { - if(party == null) + if (party == null) return false; - if(party.getQuestData() == null) + if (party.getQuestData() == null) return false; - if(party.getQuestData().quest == null) + if (party.getQuestData().quest == null) return false; EnumPartyObjectives objectives = party.getQuestData().quest.partyOptions.objectiveRequirement; - if(objectives == EnumPartyObjectives.All){ + if (objectives == EnumPartyObjectives.All) { List incomplete = new ArrayList<>(); - for (UUID uuid: party.getPlayerUUIDs()) { + for (UUID uuid : party.getPlayerUUIDs()) { EntityPlayer individual = NoppesUtilServer.getPlayer(uuid); PlayerData individualData; - if(individual != null){ + if (individual != null) { individualData = PlayerDataController.Instance.getPlayerData(individual); - } - else { + } else { individualData = PlayerDataController.Instance.getPlayerDataCache(uuid.toString()); } - if(individualData != null){ - for(int dialogId : dialogs.values()){ - if(!individualData.dialogData.dialogsRead.contains(dialogId)){ + if (individualData != null) { + for (int dialogId : dialogs.values()) { + if (!individualData.dialogData.dialogsRead.contains(dialogId)) { incomplete.add(individualData.playername); break; } @@ -243,18 +238,17 @@ public class QuestDialog extends QuestInterface implements IQuestDialog { } } return incomplete.isEmpty(); - } else if(objectives == EnumPartyObjectives.Leader){ + } else if (objectives == EnumPartyObjectives.Leader) { EntityPlayer leaderPlayer = NoppesUtilServer.getPlayer(party.getLeaderUUID()); PlayerData leaderData; - if(leaderPlayer != null){ + if (leaderPlayer != null) { leaderData = PlayerDataController.Instance.getPlayerData(leaderPlayer); - } - else { + } else { leaderData = PlayerDataController.Instance.getPlayerDataCache(party.getLeaderUUID().toString()); } - if(leaderData != null){ - for(int dialogId : dialogs.values()){ - if(!leaderData.dialogData.dialogsRead.contains(dialogId)){ + if (leaderData != null) { + for (int dialogId : dialogs.values()) { + if (!leaderData.dialogData.dialogsRead.contains(dialogId)) { return false; } } @@ -264,25 +258,24 @@ public class QuestDialog extends QuestInterface implements IQuestDialog { return true; } else { HashMap readValues = new HashMap<>(); - for (UUID uuid: party.getPlayerUUIDs()) { + for (UUID uuid : party.getPlayerUUIDs()) { EntityPlayer player = NoppesUtilServer.getPlayer(uuid); PlayerData playerData; - if(player != null){ + if (player != null) { playerData = PlayerDataController.Instance.getPlayerData(player); - } - else { + } else { playerData = PlayerDataController.Instance.getPlayerDataCache(uuid.toString()); } - if(playerData != null){ - for(int dialogId : dialogs.values()){ - if(playerData.dialogData.dialogsRead.contains(dialogId)){ + if (playerData != null) { + for (int dialogId : dialogs.values()) { + if (playerData.dialogData.dialogsRead.contains(dialogId)) { readValues.put(dialogId, true); } } } } - for(boolean result : readValues.values()){ - if(!result) + for (boolean result : readValues.values()) { + if (!result) return false; } return true; @@ -290,17 +283,17 @@ public class QuestDialog extends QuestInterface implements IQuestDialog { } class QuestDialogObjective implements IQuestObjective { - private final QuestDialog parent; - private final EntityPlayer player; + private final QuestDialog parent; + private final EntityPlayer player; private final Party party; - private final Dialog dialog; + private final Dialog dialog; - public QuestDialogObjective(QuestDialog this$0, EntityPlayer player, Dialog dialog) { - this.parent = this$0; - this.player = player; - this.dialog = dialog; + public QuestDialogObjective(QuestDialog this$0, EntityPlayer player, Dialog dialog) { + this.parent = this$0; + this.player = player; + this.dialog = dialog; this.party = null; - } + } public QuestDialogObjective(QuestDialog this$0, Party party, Dialog dialog) { this.parent = this$0; @@ -309,13 +302,13 @@ public class QuestDialog extends QuestInterface implements IQuestDialog { this.player = null; } - public int getProgress() { - return this.isCompleted() ? 1 : 0; - } + public int getProgress() { + return this.isCompleted() ? 1 : 0; + } - public void setProgress(int progress) { - if (progress >= 0 && progress <= 1) { - if(player != null){ + public void setProgress(int progress) { + if (progress >= 0 && progress <= 1) { + if (player != null) { PlayerData data = PlayerDataController.Instance.getPlayerData(player); boolean completed = data.dialogData.dialogsRead.contains(this.dialog.id); if (progress == 0 && completed) { @@ -331,19 +324,18 @@ public class QuestDialog extends QuestInterface implements IQuestDialog { data.updateClient = true; data.save(); } - } else if (party != null){ - if(party.getObjectiveRequirement() != null){ + } else if (party != null) { + if (party.getObjectiveRequirement() != null) { EnumPartyObjectives objectives = party.getObjectiveRequirement(); - if(objectives == EnumPartyObjectives.Leader){ + if (objectives == EnumPartyObjectives.Leader) { EntityPlayer leaderPlayer = NoppesUtilServer.getPlayer(party.getLeaderUUID()); PlayerData leaderData; - if(leaderPlayer != null){ + if (leaderPlayer != null) { leaderData = PlayerDataController.Instance.getPlayerData(leaderPlayer); - } - else { + } else { leaderData = PlayerDataController.Instance.getPlayerDataCache(party.getLeaderUUID().toString()); } - if(leaderData == null) + if (leaderData == null) return; boolean completed = leaderData.dialogData.dialogsRead.contains(this.dialog.id); @@ -360,16 +352,15 @@ public class QuestDialog extends QuestInterface implements IQuestDialog { leaderData.save(); } } else { - for (UUID uuid: party.getPlayerUUIDs()) { + for (UUID uuid : party.getPlayerUUIDs()) { EntityPlayer individual = NoppesUtilServer.getPlayer(uuid); PlayerData individualData; - if(individual != null){ + if (individual != null) { individualData = PlayerDataController.Instance.getPlayerData(individual); - } - else { + } else { individualData = PlayerDataController.Instance.getPlayerDataCache(uuid.toString()); } - if(individualData != null){ + if (individualData != null) { boolean completed = individualData.dialogData.dialogsRead.contains(this.dialog.id); if (progress == 0 && completed) { individualData.dialogData.dialogsRead.remove(this.dialog.id); @@ -387,16 +378,16 @@ public class QuestDialog extends QuestInterface implements IQuestDialog { } } } - } else { - throw new CustomNPCsException("Progress has to be 0 or 1", new Object[0]); - } - } + } else { + throw new CustomNPCsException("Progress has to be 0 or 1", new Object[0]); + } + } @Override public void setPlayerProgress(String playerName, int progress) { if (progress >= 0 && progress <= 1) { EntityPlayer foundplayer = NoppesUtilServer.getPlayerByName(playerName); - if(foundplayer != null && party == null){ + if (foundplayer != null && party == null) { PlayerData data = PlayerDataController.Instance.getPlayerData(foundplayer); boolean completed = data.dialogData.dialogsRead.contains(this.dialog.id); if (progress == 0 && completed) { @@ -412,19 +403,18 @@ public class QuestDialog extends QuestInterface implements IQuestDialog { data.updateClient = true; data.save(); } - } else if (foundplayer != null){ - if(party.getObjectiveRequirement() != null){ + } else if (foundplayer != null) { + if (party.getObjectiveRequirement() != null) { EnumPartyObjectives objectives = party.getObjectiveRequirement(); - if(objectives == EnumPartyObjectives.Leader){ + if (objectives == EnumPartyObjectives.Leader) { EntityPlayer leaderPlayer = NoppesUtilServer.getPlayer(party.getLeaderUUID()); PlayerData leaderData; - if(leaderPlayer != null){ + if (leaderPlayer != null) { leaderData = PlayerDataController.Instance.getPlayerData(leaderPlayer); - } - else { + } else { leaderData = PlayerDataController.Instance.getPlayerDataCache(party.getLeaderUUID().toString()); } - if(leaderData == null) + if (leaderData == null) return; boolean completed = leaderData.dialogData.dialogsRead.contains(this.dialog.id); @@ -442,7 +432,7 @@ public class QuestDialog extends QuestInterface implements IQuestDialog { } } else { PlayerData individualData = PlayerDataController.Instance.getPlayerData(foundplayer); - if(individualData != null){ + if (individualData != null) { boolean completed = individualData.dialogData.dialogsRead.contains(this.dialog.id); if (progress == 0 && completed) { individualData.dialogData.dialogsRead.remove(this.dialog.id); @@ -465,45 +455,42 @@ public class QuestDialog extends QuestInterface implements IQuestDialog { } public int getMaxProgress() { - return 1; - } + return 1; + } - public boolean isCompleted() { - if(player != null){ + public boolean isCompleted() { + if (player != null) { PlayerData data = PlayerDataController.Instance.getPlayerData(player); return data.dialogData.dialogsRead.contains(this.dialog.id); - } - else if (party != null){ - if(party.getObjectiveRequirement() != null){ + } else if (party != null) { + if (party.getObjectiveRequirement() != null) { EnumPartyObjectives objectives = party.getObjectiveRequirement(); - if(objectives == EnumPartyObjectives.Leader){ + if (objectives == EnumPartyObjectives.Leader) { EntityPlayer leaderPlayer = NoppesUtilServer.getPlayer(party.getLeaderUUID()); PlayerData leaderData; - if(leaderPlayer != null){ + if (leaderPlayer != null) { leaderData = PlayerDataController.Instance.getPlayerData(leaderPlayer); - } - else { + } else { leaderData = PlayerDataController.Instance.getPlayerDataCache(party.getLeaderUUID().toString()); } - if(leaderData == null) + if (leaderData == null) return false; return leaderData.dialogData.dialogsRead.contains(this.dialog.id); } else { boolean requiresOneRead = objectives == EnumPartyObjectives.Shared; - for (UUID uuid: party.getPlayerUUIDs()) { + for (UUID uuid : party.getPlayerUUIDs()) { EntityPlayer individual = NoppesUtilServer.getPlayer(uuid); PlayerData individualData; - if(individual != null){ + if (individual != null) { individualData = PlayerDataController.Instance.getPlayerData(individual); - } - else { + } else { individualData = PlayerDataController.Instance.getPlayerDataCache(uuid.toString()); } - if(individualData != null){ + if (individualData != null) { boolean read = individualData.dialogData.dialogsRead.contains(this.dialog.id); - if(requiresOneRead && read){ + if (requiresOneRead && read) { return true; - } else if(!requiresOneRead && !read){ + } else if (!requiresOneRead && !read) { return false; } } @@ -513,34 +500,33 @@ public class QuestDialog extends QuestInterface implements IQuestDialog { } } return true; - } + } - public String getText() { - return this.dialog.title + (this.isCompleted() ? " (read)" : " (unread)"); - } + public String getText() { + return this.dialog.title + (this.isCompleted() ? " (read)" : " (unread)"); + } @Override public String getAdditionalText() { - if(party != null && party.getObjectiveRequirement() == EnumPartyObjectives.All){ + if (party != null && party.getObjectiveRequirement() == EnumPartyObjectives.All) { List incomplete = new ArrayList<>(); - for (UUID uuid: party.getPlayerUUIDs()) { + for (UUID uuid : party.getPlayerUUIDs()) { EntityPlayer individual = NoppesUtilServer.getPlayer(uuid); PlayerData individualData; - if(individual != null){ + if (individual != null) { individualData = PlayerDataController.Instance.getPlayerData(individual); - } - else { + } else { individualData = PlayerDataController.Instance.getPlayerDataCache(uuid.toString()); } - if(individualData != null){ + if (individualData != null) { boolean read = individualData.dialogData.dialogsRead.contains(this.dialog.id); - if(!read) { + if (!read) { incomplete.add(individualData.playername); } } } - if(!incomplete.isEmpty()) - return "[" + String.join(", ", incomplete) + "]"; + if (!incomplete.isEmpty()) + return "[" + String.join(", ", incomplete) + "]"; } return null; diff --git a/src/main/java/noppes/npcs/quests/QuestInterface.java b/src/main/java/noppes/npcs/quests/QuestInterface.java index 46b876076..14e52d2a0 100644 --- a/src/main/java/noppes/npcs/quests/QuestInterface.java +++ b/src/main/java/noppes/npcs/quests/QuestInterface.java @@ -13,32 +13,39 @@ import noppes.npcs.controllers.data.PlayerQuestData; import java.util.Vector; public abstract class QuestInterface implements IQuestInterface { - public int questId; - public abstract void writeEntityToNBT(NBTTagCompound compound); - public abstract void readEntityFromNBT(NBTTagCompound compound); - public abstract boolean isCompleted(PlayerData player); - public void handleComplete(EntityPlayer player) { - PlayerQuestData questData = PlayerDataController.Instance.getPlayerData(player).questData; - if(questData != null && questData.getTrackedQuest() != null){ - if (this.questId == PlayerDataController.Instance.getPlayerData(player).questData.getTrackedQuest().getId()) { - PlayerDataController.Instance.getPlayerData(player).questData.untrackQuest(); - } - } - } + public int questId; - public void handlePartyComplete(EntityPlayer player, Party party, boolean isLeader, EnumPartyObjectives objectives){ + public abstract void writeEntityToNBT(NBTTagCompound compound); + + public abstract void readEntityFromNBT(NBTTagCompound compound); + + public abstract boolean isCompleted(PlayerData player); + + public void handleComplete(EntityPlayer player) { + PlayerQuestData questData = PlayerDataController.Instance.getPlayerData(player).questData; + if (questData != null && questData.getTrackedQuest() != null) { + if (this.questId == PlayerDataController.Instance.getPlayerData(player).questData.getTrackedQuest().getId()) { + PlayerDataController.Instance.getPlayerData(player).questData.untrackQuest(); + } + } + } + + public void handlePartyComplete(EntityPlayer player, Party party, boolean isLeader, EnumPartyObjectives objectives) { handleComplete(player); } - public void removePartyItems(Party party){} + public void removePartyItems(Party party) { + } public abstract Vector getQuestLogStatus(EntityPlayer player); - public abstract IQuestObjective[] getObjectives(EntityPlayer var1); + + public abstract IQuestObjective[] getObjectives(EntityPlayer var1); // Party Related public abstract IQuestObjective[] getPartyObjectives(Party party); public abstract Vector getPartyQuestLogStatus(Party party); + public abstract boolean isPartyCompleted(Party party); } diff --git a/src/main/java/noppes/npcs/quests/QuestItem.java b/src/main/java/noppes/npcs/quests/QuestItem.java index a71487b82..a9302ff66 100644 --- a/src/main/java/noppes/npcs/quests/QuestItem.java +++ b/src/main/java/noppes/npcs/quests/QuestItem.java @@ -17,95 +17,96 @@ import noppes.npcs.util.ValueUtil; import java.util.*; public class QuestItem extends QuestInterface implements IQuestItem { - public NpcMiscInventory items = new NpcMiscInventory(3); + public NpcMiscInventory items = new NpcMiscInventory(3); public static EntityPlayer pickedUpPlayerSolo; - public static ItemStack pickedUp; + public static ItemStack pickedUp; public static ItemStack pickedUpParty; public static EntityPlayer pickedUpPlayer; - public boolean leaveItems = false; - public boolean ignoreDamage = false; - public boolean ignoreNBT = false; + public boolean leaveItems = false; + public boolean ignoreDamage = false; + public boolean ignoreNBT = false; - @Override - public void readEntityFromNBT(NBTTagCompound compound) { - items.setFromNBT(compound.getCompoundTag("Items")); - leaveItems = compound.getBoolean("LeaveItems"); - ignoreDamage = compound.getBoolean("IgnoreDamage"); - ignoreNBT = compound.getBoolean("IgnoreNBT"); - } + @Override + public void readEntityFromNBT(NBTTagCompound compound) { + items.setFromNBT(compound.getCompoundTag("Items")); + leaveItems = compound.getBoolean("LeaveItems"); + ignoreDamage = compound.getBoolean("IgnoreDamage"); + ignoreNBT = compound.getBoolean("IgnoreNBT"); + } - @Override - public void writeEntityToNBT(NBTTagCompound compound) { - compound.setTag("Items", items.getToNBT()); - compound.setBoolean("LeaveItems", leaveItems); - compound.setBoolean("IgnoreDamage", ignoreDamage); - compound.setBoolean("IgnoreNBT", ignoreNBT); - } + @Override + public void writeEntityToNBT(NBTTagCompound compound) { + compound.setTag("Items", items.getToNBT()); + compound.setBoolean("LeaveItems", leaveItems); + compound.setBoolean("IgnoreDamage", ignoreDamage); + compound.setBoolean("IgnoreNBT", ignoreNBT); + } - @Override - public boolean isCompleted(PlayerData playerData) { - HashMap map = getProcessSet(playerData.player); - for(ItemStack reqItem : items.items.values()){ - boolean done = false; - for(ItemStack item : map.values()){ - if(NoppesUtilPlayer.compareItems(reqItem, item, ignoreDamage, ignoreNBT) && item.stackSize >= reqItem.stackSize){ - done = true; - break; - } - } - if(!done) - return false; - } + @Override + public boolean isCompleted(PlayerData playerData) { + HashMap map = getProcessSet(playerData.player); + for (ItemStack reqItem : items.items.values()) { + boolean done = false; + for (ItemStack item : map.values()) { + if (NoppesUtilPlayer.compareItems(reqItem, item, ignoreDamage, ignoreNBT) && item.stackSize >= reqItem.stackSize) { + done = true; + break; + } + } + if (!done) + return false; + } - return true; - } - public HashMap getProcessSet(EntityPlayer player){ - HashMap map = new HashMap(); - for(int slot : items.items.keySet()){ - ItemStack item = items.items.get(slot); - if(item == null) - continue; - ItemStack is = item.copy(); - is.stackSize = 0; - map.put(slot,is); - } + return true; + } - ArrayList list = new ArrayList<>(Arrays.asList(player.inventory.mainInventory)); - list.add(pickedUp); + public HashMap getProcessSet(EntityPlayer player) { + HashMap map = new HashMap(); + for (int slot : items.items.keySet()) { + ItemStack item = items.items.get(slot); + if (item == null) + continue; + ItemStack is = item.copy(); + is.stackSize = 0; + map.put(slot, is); + } - for(ItemStack item : list){ - if(item == null) - continue; - for(ItemStack questItem : map.values()){ - if(NoppesUtilPlayer.compareItems(questItem, item, ignoreDamage, ignoreNBT)){ - questItem.stackSize += item.stackSize; - } - } - } - return map; - } + ArrayList list = new ArrayList<>(Arrays.asList(player.inventory.mainInventory)); + list.add(pickedUp); - @Override - public void handleComplete(EntityPlayer player) { - super.handleComplete(player); - if(leaveItems) - return; + for (ItemStack item : list) { + if (item == null) + continue; + for (ItemStack questItem : map.values()) { + if (NoppesUtilPlayer.compareItems(questItem, item, ignoreDamage, ignoreNBT)) { + questItem.stackSize += item.stackSize; + } + } + } + return map; + } + + @Override + public void handleComplete(EntityPlayer player) { + super.handleComplete(player); + if (leaveItems) + return; removeItems(player); - } + } - public void handlePartyComplete(EntityPlayer player, Party party, boolean isLeader, EnumPartyObjectives objectives){ + public void handlePartyComplete(EntityPlayer player, Party party, boolean isLeader, EnumPartyObjectives objectives) { super.handlePartyComplete(player, party, isLeader, objectives); - if(leaveItems) + if (leaveItems) return; - if(isLeader && objectives == EnumPartyObjectives.Leader){ + if (isLeader && objectives == EnumPartyObjectives.Leader) { removeItems(player); - } else if (objectives == EnumPartyObjectives.All){ + } else if (objectives == EnumPartyObjectives.All) { removeItems(player); - } else if (objectives == EnumPartyObjectives.Shared){ + } else if (objectives == EnumPartyObjectives.Shared) { // Shared Case // Do nothing, handled later in quest completion } @@ -163,65 +164,63 @@ public class QuestItem extends QuestInterface implements IQuestItem { } - - public void removeItems(EntityPlayer player){ - for(ItemStack questitem : items.items.values()){ + public void removeItems(EntityPlayer player) { + for (ItemStack questitem : items.items.values()) { int stacksize = questitem.stackSize; - for(int i = 0; i < player.inventory.mainInventory.length; i++){ + for (int i = 0; i < player.inventory.mainInventory.length; i++) { ItemStack item = player.inventory.mainInventory[i]; - if(item == null) + if (item == null) continue; - if(NoppesUtilPlayer.compareItems(item, questitem, ignoreDamage, ignoreNBT)){ + if (NoppesUtilPlayer.compareItems(item, questitem, ignoreDamage, ignoreNBT)) { int size = item.stackSize; - if(stacksize - size >= 0){ + if (stacksize - size >= 0) { player.inventory.setInventorySlotContents(i, null); item.splitStack(size); - } - else{ + } else { item.splitStack(stacksize); } stacksize -= size; - if(stacksize <= 0) + if (stacksize <= 0) break; } } } } - @Override - public Vector getQuestLogStatus(EntityPlayer player) { - Vector vec = new Vector(); + @Override + public Vector getQuestLogStatus(EntityPlayer player) { + Vector vec = new Vector(); - HashMap map = getProcessSet(player); - for(int slot : map.keySet()){ - ItemStack item = map.get(slot); - ItemStack quest = items.items.get(slot); - if(item == null) - continue; - String process = item.stackSize + ""; - if(item.stackSize > quest.stackSize) - process = quest.stackSize + ""; - process += "/" + quest.stackSize + ""; - if(item.hasDisplayName()) - vec.add(item.getDisplayName() + ": " + process); - else - vec.add(item.getUnlocalizedName() + ".name" + ": " + process); - } - return vec; - } + HashMap map = getProcessSet(player); + for (int slot : map.keySet()) { + ItemStack item = map.get(slot); + ItemStack quest = items.items.get(slot); + if (item == null) + continue; + String process = item.stackSize + ""; + if (item.stackSize > quest.stackSize) + process = quest.stackSize + ""; + process += "/" + quest.stackSize + ""; + if (item.hasDisplayName()) + vec.add(item.getDisplayName() + ": " + process); + else + vec.add(item.getUnlocalizedName() + ".name" + ": " + process); + } + return vec; + } - public IQuestObjective[] getObjectives(EntityPlayer player) { - List list = new ArrayList<>(); - List questItems = NoppesUtilPlayer.countStacks(this.items, this.ignoreDamage, this.ignoreNBT); + public IQuestObjective[] getObjectives(EntityPlayer player) { + List list = new ArrayList<>(); + List questItems = NoppesUtilPlayer.countStacks(this.items, this.ignoreDamage, this.ignoreNBT); - for (ItemStack stack : questItems) { - if (stack.stackSize > 0) { - list.add(new QuestItemObjective(this, player, stack)); - } - } + for (ItemStack stack : questItems) { + if (stack.stackSize > 0) { + list.add(new QuestItemObjective(this, player, stack)); + } + } - return list.toArray(new IQuestObjective[0]); - } + return list.toArray(new IQuestObjective[0]); + } @Override public IQuestObjective[] getPartyObjectives(Party party) { @@ -240,18 +239,18 @@ public class QuestItem extends QuestInterface implements IQuestItem { @Override public Vector getPartyQuestLogStatus(Party party) { Vector vec = new Vector(); - if(party == null || party.getObjectiveRequirement() == null) + if (party == null || party.getObjectiveRequirement() == null) return vec; EnumPartyObjectives objectives = party.getObjectiveRequirement(); - if(objectives == EnumPartyObjectives.All){ + if (objectives == EnumPartyObjectives.All) { // Slot, QuestItem Vector HashMap questVector = new HashMap<>(); HashMap> playerVector = new HashMap<>(); - for(int slot : items.items.keySet()){ + for (int slot : items.items.keySet()) { ItemStack questItem = items.items.get(slot); - if(questItem != null){ - if(questItem.hasDisplayName()) + if (questItem != null) { + if (questItem.hasDisplayName()) questVector.put(slot, questItem.getDisplayName() + ": " + questItem.stackSize); else questVector.put(slot, questItem.getUnlocalizedName() + ".name" + ": " + questItem.stackSize); @@ -262,19 +261,19 @@ public class QuestItem extends QuestInterface implements IQuestItem { // Slot, List of Players and Their Item Counts - for (UUID uuid: party.getPlayerUUIDs()) { + for (UUID uuid : party.getPlayerUUIDs()) { EntityPlayer player = NoppesUtilServer.getPlayer(uuid); - if(player != null){ - HashMap perPlayerMap = getProcessSetParty(player); - for(int slot : perPlayerMap.keySet()){ + if (player != null) { + HashMap perPlayerMap = getProcessSetParty(player); + for (int slot : perPlayerMap.keySet()) { List slotCurrent = playerVector.get(slot); ItemStack item = perPlayerMap.get(slot); ItemStack quest = items.items.get(slot); - if(item == null) + if (item == null) continue; - if(quest == null) + if (quest == null) continue; - if(item.stackSize > quest.stackSize) + if (item.stackSize > quest.stackSize) continue; slotCurrent.add(player.getCommandSenderName() + ": " + item.stackSize); playerVector.put(slot, slotCurrent); @@ -298,7 +297,7 @@ public class QuestItem extends QuestInterface implements IQuestItem { vec.add("[" + playerNamesBuilder.toString() + "]"); } } - } else if (objectives == EnumPartyObjectives.Shared || objectives == EnumPartyObjectives.Leader){ + } else if (objectives == EnumPartyObjectives.Shared || objectives == EnumPartyObjectives.Leader) { HashMap totals = new HashMap(); for (int slot : items.items.keySet()) { ItemStack item = items.items.get(slot); @@ -308,10 +307,10 @@ public class QuestItem extends QuestInterface implements IQuestItem { } // Iterate over each player in the party for (UUID uuid : party.getPlayerUUIDs()) { - if(uuid == null) + if (uuid == null) continue; - if(objectives == EnumPartyObjectives.Leader && !party.getLeaderUUID().equals(uuid)) + if (objectives == EnumPartyObjectives.Leader && !party.getLeaderUUID().equals(uuid)) continue; EntityPlayer player = NoppesUtilServer.getPlayer(uuid); @@ -320,8 +319,8 @@ public class QuestItem extends QuestInterface implements IQuestItem { for (Map.Entry entry : items.items.entrySet()) { int slot = entry.getKey(); ItemStack reqItem = entry.getValue(); - for(ItemStack item : perPlayerMap.values()){ - if(NoppesUtilPlayer.compareItems(reqItem, item, ignoreDamage, ignoreNBT)){ + for (ItemStack item : perPlayerMap.values()) { + if (NoppesUtilPlayer.compareItems(reqItem, item, ignoreDamage, ignoreNBT)) { int count = totals.get(slot); count += item.stackSize; totals.put(slot, count); @@ -334,7 +333,7 @@ public class QuestItem extends QuestInterface implements IQuestItem { // Check if the total count of required items collected by the party exceeds the required amount for each slot for (int slot : items.items.keySet()) { ItemStack reqItem = items.items.get(slot); - if(reqItem == null) + if (reqItem == null) continue; int totalCount = totals.get(slot); @@ -342,7 +341,7 @@ public class QuestItem extends QuestInterface implements IQuestItem { totalCount = reqItem.stackSize; } String process = totalCount + "/" + reqItem.stackSize; - if(reqItem.hasDisplayName()) + if (reqItem.hasDisplayName()) vec.add(reqItem.getDisplayName() + ": " + process); else vec.add(reqItem.getUnlocalizedName() + ".name" + ": " + process); @@ -353,29 +352,29 @@ public class QuestItem extends QuestInterface implements IQuestItem { @Override public boolean isPartyCompleted(Party party) { - if(party == null || party.getObjectiveRequirement() == null) + if (party == null || party.getObjectiveRequirement() == null) return false; EnumPartyObjectives objectives = party.getObjectiveRequirement(); - if(objectives == EnumPartyObjectives.All){ - for (UUID uuid: party.getPlayerUUIDs()) { + if (objectives == EnumPartyObjectives.All) { + for (UUID uuid : party.getPlayerUUIDs()) { EntityPlayer player = NoppesUtilServer.getPlayer(uuid); - if(player != null){ - HashMap perPlayerMap = getProcessSetParty(player); - for(ItemStack reqItem : items.items.values()){ + if (player != null) { + HashMap perPlayerMap = getProcessSetParty(player); + for (ItemStack reqItem : items.items.values()) { boolean done = false; - for(ItemStack item : perPlayerMap.values()){ - if(NoppesUtilPlayer.compareItems(reqItem, item, ignoreDamage, ignoreNBT) && item.stackSize >= reqItem.stackSize){ + for (ItemStack item : perPlayerMap.values()) { + if (NoppesUtilPlayer.compareItems(reqItem, item, ignoreDamage, ignoreNBT) && item.stackSize >= reqItem.stackSize) { done = true; break; } } - if(!done) + if (!done) return false; } } } - } else if (objectives == EnumPartyObjectives.Shared || objectives == EnumPartyObjectives.Leader){ + } else if (objectives == EnumPartyObjectives.Shared || objectives == EnumPartyObjectives.Leader) { HashMap totals = new HashMap(); for (int slot : items.items.keySet()) { ItemStack item = items.items.get(slot); @@ -386,10 +385,10 @@ public class QuestItem extends QuestInterface implements IQuestItem { // Iterate over each player in the party for (UUID uuid : party.getPlayerUUIDs()) { - if(uuid == null) + if (uuid == null) continue; - if(objectives == EnumPartyObjectives.Leader && !party.getLeaderUUID().equals(uuid)) + if (objectives == EnumPartyObjectives.Leader && !party.getLeaderUUID().equals(uuid)) continue; EntityPlayer player = NoppesUtilServer.getPlayer(uuid); @@ -398,8 +397,8 @@ public class QuestItem extends QuestInterface implements IQuestItem { for (Map.Entry entry : items.items.entrySet()) { int slot = entry.getKey(); ItemStack reqItem = entry.getValue(); - for(ItemStack item : perPlayerMap.values()){ - if(NoppesUtilPlayer.compareItems(reqItem, item, ignoreDamage, ignoreNBT)){ + for (ItemStack item : perPlayerMap.values()) { + if (NoppesUtilPlayer.compareItems(reqItem, item, ignoreDamage, ignoreNBT)) { int count = totals.get(slot); count += item.stackSize; totals.put(slot, count); @@ -421,26 +420,26 @@ public class QuestItem extends QuestInterface implements IQuestItem { return true; } - public HashMap getProcessSetParty(EntityPlayer player){ - HashMap map = new HashMap(); - for(int slot : items.items.keySet()){ + public HashMap getProcessSetParty(EntityPlayer player) { + HashMap map = new HashMap(); + for (int slot : items.items.keySet()) { ItemStack item = items.items.get(slot); - if(item == null) + if (item == null) continue; ItemStack is = item.copy(); is.stackSize = 0; - map.put(slot,is); + map.put(slot, is); } ArrayList list = new ArrayList<>(Arrays.asList(player.inventory.mainInventory)); - if(pickedUpPlayer != null && player.getCommandSenderName().equals(pickedUpPlayer.getCommandSenderName())) + if (pickedUpPlayer != null && player.getCommandSenderName().equals(pickedUpPlayer.getCommandSenderName())) list.add(pickedUpParty); - for(ItemStack item : list){ - if(item == null) + for (ItemStack item : list) { + if (item == null) continue; - for(ItemStack questItem : map.values()){ - if(NoppesUtilPlayer.compareItems(questItem, item, ignoreDamage, ignoreNBT)){ + for (ItemStack questItem : map.values()) { + if (NoppesUtilPlayer.compareItems(questItem, item, ignoreDamage, ignoreNBT)) { questItem.stackSize += item.stackSize; } } @@ -448,39 +447,43 @@ public class QuestItem extends QuestInterface implements IQuestItem { return map; } - public void setLeaveItems(boolean leaveItems){ - this.leaveItems = leaveItems; - } - public boolean getLeaveItems(){ - return this.leaveItems; - } + public void setLeaveItems(boolean leaveItems) { + this.leaveItems = leaveItems; + } - public void setIgnoreDamage(boolean ignoreDamage){ - this.ignoreDamage = ignoreDamage; - } - public boolean getIgnoreDamage(){ - return this.ignoreDamage; - } + public boolean getLeaveItems() { + return this.leaveItems; + } - public void setIgnoreNbt(boolean ignoreNbt){ - this.ignoreNBT = ignoreNbt; - } - public boolean getIgnoreNbt(){ - return this.ignoreNBT; - } + public void setIgnoreDamage(boolean ignoreDamage) { + this.ignoreDamage = ignoreDamage; + } - class QuestItemObjective implements IQuestObjective { - private final QuestItem parent; - private final EntityPlayer player; + public boolean getIgnoreDamage() { + return this.ignoreDamage; + } + + public void setIgnoreNbt(boolean ignoreNbt) { + this.ignoreNBT = ignoreNbt; + } + + public boolean getIgnoreNbt() { + return this.ignoreNBT; + } + + class QuestItemObjective implements IQuestObjective { + private final QuestItem parent; + private final EntityPlayer player; private final Party party; - private final ItemStack questItem; + private final ItemStack questItem; - public QuestItemObjective(QuestItem this$0, EntityPlayer player, ItemStack item) { - this.parent = this$0; - this.player = player; - this.questItem = item; + public QuestItemObjective(QuestItem this$0, EntityPlayer player, ItemStack item) { + this.parent = this$0; + this.player = player; + this.questItem = item; this.party = null; - } + } + public QuestItemObjective(QuestItem this$0, Party party, ItemStack item) { this.parent = this$0; this.player = null; @@ -488,57 +491,57 @@ public class QuestItem extends QuestInterface implements IQuestItem { this.party = party; } - public int getProgress() { - int count = 0; - if(player != null){ + public int getProgress() { + int count = 0; + if (player != null) { ItemStack item = QuestItem.pickedUp; if (!NoppesUtilServer.IsItemStackNull(item) && NoppesUtilPlayer.compareItems(this.questItem, item, this.parent.ignoreDamage, this.parent.ignoreNBT)) { count += item.stackSize; } - for(int i = 0; i < this.player.inventory.getSizeInventory(); ++i) { + for (int i = 0; i < this.player.inventory.getSizeInventory(); ++i) { item = this.player.inventory.getStackInSlot(i); if (!NoppesUtilServer.IsItemStackNull(item) && NoppesUtilPlayer.compareItems(this.questItem, item, this.parent.ignoreDamage, this.parent.ignoreNBT)) { count += item.stackSize; } } - } else if (party != null && party.getObjectiveRequirement() != null){ + } else if (party != null && party.getObjectiveRequirement() != null) { ItemStack item; EnumPartyObjectives objectives = party.getObjectiveRequirement(); - for(String name : party.getPlayerNames()){ + for (String name : party.getPlayerNames()) { EntityPlayer playerMP = NoppesUtilServer.getPlayerByName(name); - if(playerMP == null) + if (playerMP == null) continue; - if(!playerMP.getUniqueID().equals(party.getLeaderUUID()) && objectives == EnumPartyObjectives.Leader) + if (!playerMP.getUniqueID().equals(party.getLeaderUUID()) && objectives == EnumPartyObjectives.Leader) continue; int amount = 0; - for(int i = 0; i < playerMP.inventory.getSizeInventory(); ++i) { + for (int i = 0; i < playerMP.inventory.getSizeInventory(); ++i) { item = playerMP.inventory.getStackInSlot(i); if (!NoppesUtilServer.IsItemStackNull(item) && NoppesUtilPlayer.compareItems(this.questItem, item, this.parent.ignoreDamage, this.parent.ignoreNBT)) { amount += item.stackSize; } } - if(objectives == EnumPartyObjectives.All){ + if (objectives == EnumPartyObjectives.All) { count += ValueUtil.clamp(amount, 0, this.questItem.stackSize); } else { count += amount; } } - if(objectives == EnumPartyObjectives.All){ + if (objectives == EnumPartyObjectives.All) { return ValueUtil.clamp(count, 0, this.questItem.stackSize * party.getPlayerNames().size()); } } - return ValueUtil.clamp(count, 0, this.questItem.stackSize); - } + return ValueUtil.clamp(count, 0, this.questItem.stackSize); + } - public void setProgress(int progress) { - throw new CustomNPCsException("Cant set the progress of ItemQuests", new Object[0]); - } + public void setProgress(int progress) { + throw new CustomNPCsException("Cant set the progress of ItemQuests", new Object[0]); + } @Override public void setPlayerProgress(String playerName, int progress) { @@ -546,71 +549,71 @@ public class QuestItem extends QuestInterface implements IQuestItem { } public int getMaxProgress() { - if(party != null && party.getObjectiveRequirement() != null){ + if (party != null && party.getObjectiveRequirement() != null) { EnumPartyObjectives objectives = party.getObjectiveRequirement(); - if(objectives == EnumPartyObjectives.All){ + if (objectives == EnumPartyObjectives.All) { return this.questItem.stackSize * party.getPlayerNames().size(); } } - return this.questItem.stackSize; - } + return this.questItem.stackSize; + } - public boolean isCompleted() { - if(player != null) + public boolean isCompleted() { + if (player != null) return NoppesUtilPlayer.compareItems(this.player, this.questItem, this.parent.ignoreDamage, this.parent.ignoreNBT); - else if(party != null) + else if (party != null) return comparePartyItems(this.party, this.questItem, this.parent.ignoreDamage, this.parent.ignoreNBT); return false; - } + } - public boolean comparePartyItems(Party party, ItemStack item, boolean ignoreDamage, boolean ignoreNBT){ + public boolean comparePartyItems(Party party, ItemStack item, boolean ignoreDamage, boolean ignoreNBT) { int size = 0; - if(party.getObjectiveRequirement() == null) + if (party.getObjectiveRequirement() == null) return false; EnumPartyObjectives objectives = party.getObjectiveRequirement(); - for(String name : party.getPlayerNames()){ + for (String name : party.getPlayerNames()) { EntityPlayer playerMP = NoppesUtilServer.getPlayerByName(name); - if(playerMP == null) + if (playerMP == null) continue; - if(objectives == EnumPartyObjectives.Leader && !playerMP.getUniqueID().equals(party.getLeaderUUID())) + if (objectives == EnumPartyObjectives.Leader && !playerMP.getUniqueID().equals(party.getLeaderUUID())) continue; int amount = 0; - for(ItemStack is : playerMP.inventory.mainInventory){ - if(NoppesUtilPlayer.compareItems(item, is, ignoreDamage, ignoreNBT)) + for (ItemStack is : playerMP.inventory.mainInventory) { + if (NoppesUtilPlayer.compareItems(item, is, ignoreDamage, ignoreNBT)) amount += is.stackSize; } - if(objectives == EnumPartyObjectives.All){ + if (objectives == EnumPartyObjectives.All) { size += ValueUtil.clamp(amount, 0, this.questItem.stackSize); } else { size += amount; } } - if(objectives == EnumPartyObjectives.All){ + if (objectives == EnumPartyObjectives.All) { return size >= item.stackSize * party.getPlayerNames().size(); } return size >= item.stackSize; } - public String getText() { - return this.questItem.getDisplayName() + ": " + this.getProgress() + "/" + this.getMaxProgress(); - } + public String getText() { + return this.questItem.getDisplayName() + ": " + this.getProgress() + "/" + this.getMaxProgress(); + } @Override public String getAdditionalText() { - if(party != null && party.getObjectiveRequirement() == EnumPartyObjectives.All) { + if (party != null && party.getObjectiveRequirement() == EnumPartyObjectives.All) { List incompletePlayers = new ArrayList<>(); EnumPartyObjectives objectives = party.getObjectiveRequirement(); for (String name : party.getPlayerNames()) { EntityPlayer playerMP = NoppesUtilServer.getPlayerByName(name); - if (playerMP == null){ + if (playerMP == null) { incompletePlayers.add(name + ": " + "N/A"); continue; } @@ -622,11 +625,11 @@ public class QuestItem extends QuestInterface implements IQuestItem { } int completedSize = ValueUtil.clamp(amount, 0, this.questItem.stackSize); - if(completedSize < this.questItem.stackSize) + if (completedSize < this.questItem.stackSize) incompletePlayers.add(name + ": " + completedSize); } - if(!incompletePlayers.isEmpty()) - return "[" + String.join(", ", incompletePlayers) + "]"; + if (!incompletePlayers.isEmpty()) + return "[" + String.join(", ", incompletePlayers) + "]"; } return null; } diff --git a/src/main/java/noppes/npcs/quests/QuestKill.java b/src/main/java/noppes/npcs/quests/QuestKill.java index 69f608388..9a271bb68 100644 --- a/src/main/java/noppes/npcs/quests/QuestKill.java +++ b/src/main/java/noppes/npcs/quests/QuestKill.java @@ -19,108 +19,110 @@ import noppes.npcs.scripted.CustomNPCsException; import java.util.*; public class QuestKill extends QuestInterface implements IQuestKill { - public TreeMap targets = new TreeMap(); - public int targetType = 0; - public String customTargetType = "noppes.npcs.entity.EntityCustomNpc"; + public TreeMap targets = new TreeMap(); + public int targetType = 0; + public String customTargetType = "noppes.npcs.entity.EntityCustomNpc"; - @Override - public void writeEntityToNBT(NBTTagCompound compound) { - compound.setTag("QuestKills", NBTTags.nbtStringIntegerMap(targets)); - compound.setInteger("TargetType",targetType); - compound.setString("CustomTargetType",customTargetType); - } + @Override + public void writeEntityToNBT(NBTTagCompound compound) { + compound.setTag("QuestKills", NBTTags.nbtStringIntegerMap(targets)); + compound.setInteger("TargetType", targetType); + compound.setString("CustomTargetType", customTargetType); + } - @Override - public void readEntityFromNBT(NBTTagCompound compound) { - if(!compound.hasKey("QuestKills")) { - targets.clear(); - TreeMap oldTargets = new TreeMap(NBTTags.getStringIntegerMap(compound.getTagList("QuestDialogs", 10))); - targets.putAll(oldTargets); - } else { - targets = new TreeMap(NBTTags.getStringIntegerMap(compound.getTagList("QuestKills", 10))); - } + @Override + public void readEntityFromNBT(NBTTagCompound compound) { + if (!compound.hasKey("QuestKills")) { + targets.clear(); + TreeMap oldTargets = new TreeMap(NBTTags.getStringIntegerMap(compound.getTagList("QuestDialogs", 10))); + targets.putAll(oldTargets); + } else { + targets = new TreeMap(NBTTags.getStringIntegerMap(compound.getTagList("QuestKills", 10))); + } targetType = compound.getInteger("TargetType"); - customTargetType = compound.getString("CustomTargetType"); - } + customTargetType = compound.getString("CustomTargetType"); + } - @Override - public boolean isCompleted(PlayerData playerData) { - PlayerQuestData playerdata = playerData.questData; - QuestData data = playerdata.activeQuests.get(questId); - if(data == null) - return false; + @Override + public boolean isCompleted(PlayerData playerData) { + PlayerQuestData playerdata = playerData.questData; + QuestData data = playerdata.activeQuests.get(questId); + if (data == null) + return false; - HashMap killed = getKilled(data); - int completed = 0; - for(String entityName : targets.keySet()){ - int amount = 0; - if(killed.containsKey(entityName)) - amount = killed.get(entityName); - if(amount >= targets.get(entityName)){ - completed++; - } - } - if(completed >= targets.keySet().size()) - return true; + HashMap killed = getKilled(data); + int completed = 0; + for (String entityName : targets.keySet()) { + int amount = 0; + if (killed.containsKey(entityName)) + amount = killed.get(entityName); + if (amount >= targets.get(entityName)) { + completed++; + } + } + if (completed >= targets.keySet().size()) + return true; - if(killed.size() != targets.size()) - return false; - for(String entity : killed.keySet()){ - if(!targets.containsKey(entity) || targets.get(entity) > killed.get(entity)) - return false; - } + if (killed.size() != targets.size()) + return false; + for (String entity : killed.keySet()) { + if (!targets.containsKey(entity) || targets.get(entity) > killed.get(entity)) + return false; + } - return true; - } + return true; + } - @Override - public void handleComplete(EntityPlayer player) { - super.handleComplete(player); - } + @Override + public void handleComplete(EntityPlayer player) { + super.handleComplete(player); + } - @Override - public Vector getQuestLogStatus(EntityPlayer player) { - Vector vec = new Vector(); - PlayerQuestData playerdata = PlayerDataController.Instance.getPlayerData(player).questData; - QuestData data = playerdata.activeQuests.get(questId); - if(data == null) - return vec; - HashMap killed = getKilled(data); - for(String entityName : targets.keySet()){ - //Class cls = (Class) EntityList.stringToClassMapping.get(entityName); - int amount = 0; - if(killed.containsKey(entityName)) - amount = killed.get(entityName); - String state = amount + "/" + targets.get(entityName); + @Override + public Vector getQuestLogStatus(EntityPlayer player) { + Vector vec = new Vector(); + PlayerQuestData playerdata = PlayerDataController.Instance.getPlayerData(player).questData; + QuestData data = playerdata.activeQuests.get(questId); + if (data == null) + return vec; + HashMap killed = getKilled(data); + for (String entityName : targets.keySet()) { + //Class cls = (Class) EntityList.stringToClassMapping.get(entityName); + int amount = 0; + if (killed.containsKey(entityName)) + amount = killed.get(entityName); + String state = amount + "/" + targets.get(entityName); - vec.add(entityName + ": " + state); - } + vec.add(entityName + ": " + state); + } - return vec; - } + return vec; + } - public HashMap getKilled(QuestData data) { - return NBTTags.getStringIntegerMap(data.extraData.getTagList("Killed", 10)); - } - public void setKilled(QuestData data, HashMap killed) { - data.extraData.setTag("Killed", NBTTags.nbtStringIntegerMap(killed)); - } + public HashMap getKilled(QuestData data) { + return NBTTags.getStringIntegerMap(data.extraData.getTagList("Killed", 10)); + } - public IQuestObjective[] getObjectives(EntityPlayer player) { - List list = new ArrayList(); - Iterator var3 = this.targets.entrySet().iterator(); + public void setKilled(QuestData data, HashMap killed) { + data.extraData.setTag("Killed", NBTTags.nbtStringIntegerMap(killed)); + } - while(var3.hasNext()) { - Map.Entry entry = (Map.Entry)var3.next(); - list.add(new noppes.npcs.quests.QuestKill.QuestKillObjective(this, player, (String)entry.getKey(), (Integer)entry.getValue())); - } + public IQuestObjective[] getObjectives(EntityPlayer player) { + List list = new ArrayList(); + Iterator var3 = this.targets.entrySet().iterator(); - return (IQuestObjective[])list.toArray(new IQuestObjective[list.size()]); - } + while (var3.hasNext()) { + Map.Entry entry = (Map.Entry) var3.next(); + list.add(new noppes.npcs.quests.QuestKill.QuestKillObjective(this, player, (String) entry.getKey(), (Integer) entry.getValue())); + } + + return (IQuestObjective[]) list.toArray(new IQuestObjective[list.size()]); + } public HashMap getPlayerKilled(QuestData data, String playerName) { return NBTTags.getStringIntegerMap(data.extraData.getTagList(playerName + "Killed", 10)); } + public void setPlayerKilled(QuestData data, HashMap killed, String playerName) { data.extraData.setTag(playerName + "Killed", NBTTags.nbtStringIntegerMap(killed)); } @@ -129,51 +131,49 @@ public class QuestKill extends QuestInterface implements IQuestKill { List list = new ArrayList(); Iterator var3 = this.targets.entrySet().iterator(); - while(var3.hasNext()) { - Map.Entry entry = (Map.Entry)var3.next(); - list.add(new noppes.npcs.quests.QuestKill.QuestKillObjective(this, party, (String)entry.getKey(), (Integer)entry.getValue())); + while (var3.hasNext()) { + Map.Entry entry = (Map.Entry) var3.next(); + list.add(new noppes.npcs.quests.QuestKill.QuestKillObjective(this, party, (String) entry.getKey(), (Integer) entry.getValue())); } - return (IQuestObjective[])list.toArray(new IQuestObjective[list.size()]); + return (IQuestObjective[]) list.toArray(new IQuestObjective[list.size()]); } @Override public Vector getPartyQuestLogStatus(Party party) { Vector vec = new Vector(); QuestData data = party.getQuestData(); - if(data == null) + if (data == null) return vec; - if(data.quest.partyOptions.objectiveRequirement == EnumPartyObjectives.All){ - for(String entityName : targets.keySet()){ + if (data.quest.partyOptions.objectiveRequirement == EnumPartyObjectives.All) { + for (String entityName : targets.keySet()) { String firstLine = entityName + ": " + targets.get(entityName); List playerResults = new ArrayList<>(); - for(String player : party.getPlayerNames()){ - HashMap killed = getPlayerKilled(data, player); + for (String player : party.getPlayerNames()) { + HashMap killed = getPlayerKilled(data, player); int amount = 0; - if(killed.containsKey(entityName)) + if (killed.containsKey(entityName)) amount = killed.get(entityName); - if(amount < targets.get(entityName)){ + if (amount < targets.get(entityName)) { String state = player + ": " + amount; playerResults.add(state); } } - if(!playerResults.isEmpty()){ + if (!playerResults.isEmpty()) { vec.add(firstLine); vec.add("[" + String.join(", ", playerResults) + "]"); - } - else { + } else { vec.add(firstLine + " (Done)"); } } - } - else { - HashMap killed = getKilled(data); - for(String entityName : targets.keySet()){ + } else { + HashMap killed = getKilled(data); + for (String entityName : targets.keySet()) { int amount = 0; - if(killed.containsKey(entityName)) + if (killed.containsKey(entityName)) amount = killed.get(entityName); String state = amount + "/" + targets.get(entityName); @@ -185,42 +185,41 @@ public class QuestKill extends QuestInterface implements IQuestKill { @Override public boolean isPartyCompleted(Party party) { - if(party == null) + if (party == null) return false; QuestData data = party.getQuestData(); - if(data == null) + if (data == null) return false; - if(data.quest.partyOptions.objectiveRequirement == EnumPartyObjectives.All){ - for(String entityName : targets.keySet()){ - for(String player : party.getPlayerNames()){ + if (data.quest.partyOptions.objectiveRequirement == EnumPartyObjectives.All) { + for (String entityName : targets.keySet()) { + for (String player : party.getPlayerNames()) { HashMap killed = getPlayerKilled(data, player); int amount = killed.getOrDefault(entityName, 0); - if(amount < targets.get(entityName)){ + if (amount < targets.get(entityName)) { return false; } } } - } - else { + } else { int completed = 0; - HashMap killed = getKilled(data); - for(String entityName : targets.keySet()){ + HashMap killed = getKilled(data); + for (String entityName : targets.keySet()) { int amount = 0; - if(killed.containsKey(entityName)) + if (killed.containsKey(entityName)) amount = killed.get(entityName); - if(amount >= targets.get(entityName)){ + if (amount >= targets.get(entityName)) { completed++; } } - if(completed >= targets.keySet().size()) + if (completed >= targets.keySet().size()) return true; - if(killed.size() != targets.size()) + if (killed.size() != targets.size()) return false; - for(String entity : killed.keySet()){ - if(!targets.containsKey(entity) || targets.get(entity) > killed.get(entity)) + for (String entity : killed.keySet()) { + if (!targets.containsKey(entity) || targets.get(entity) > killed.get(entity)) return false; } } @@ -229,32 +228,32 @@ public class QuestKill extends QuestInterface implements IQuestKill { } public void setTargetType(int type) { - if(type < 0) - type = 0; - if(type > 2) - type = 2; + if (type < 0) + type = 0; + if (type > 2) + type = 2; - this.targetType = type; - } + this.targetType = type; + } - public int getTargetType() { - return this.targetType; - } + public int getTargetType() { + return this.targetType; + } - class QuestKillObjective implements IQuestObjective { - private final QuestKill parent; - private final EntityPlayer player; + class QuestKillObjective implements IQuestObjective { + private final QuestKill parent; + private final EntityPlayer player; private final Party party; - private final String entity; - private final int amount; + private final String entity; + private final int amount; - public QuestKillObjective(QuestKill parent, EntityPlayer player, String entity, int amount) { - this.parent = parent; - this.player = player; - this.entity = entity; - this.amount = amount; + public QuestKillObjective(QuestKill parent, EntityPlayer player, String entity, int amount) { + this.parent = parent; + this.player = player; + this.entity = entity; + this.amount = amount; this.party = null; - } + } public QuestKillObjective(QuestKill parent, Party party, String entity, int amount) { this.parent = parent; @@ -264,16 +263,16 @@ public class QuestKill extends QuestInterface implements IQuestKill { this.player = null; } - public int getProgress() { - if(player != null){ + public int getProgress() { + if (player != null) { PlayerData data = PlayerDataController.Instance.getPlayerData(player); PlayerQuestData playerdata = data.questData; - QuestData questdata = (QuestData)playerdata.activeQuests.get(this.parent.questId); - if(questdata != null){ + QuestData questdata = (QuestData) playerdata.activeQuests.get(this.parent.questId); + if (questdata != null) { HashMap killed = this.parent.getKilled(questdata); - return !killed.containsKey(this.entity) ? 0 : (Integer)killed.get(this.entity); + return !killed.containsKey(this.entity) ? 0 : (Integer) killed.get(this.entity); } - } else if(party != null) { + } else if (party != null) { QuestData questdata = party.getQuestData(); if (questdata != null) { if (questdata.quest.partyOptions.objectiveRequirement == EnumPartyObjectives.All) { @@ -281,10 +280,10 @@ public class QuestKill extends QuestInterface implements IQuestKill { for (String player : party.getPlayerNames()) { HashMap killed = this.parent.getPlayerKilled(questdata, player); int currentProgress = !killed.containsKey(this.entity) ? 0 : (Integer) killed.get(this.entity); - if(currentProgress >= this.amount) + if (currentProgress >= this.amount) howManyDone += 1; } - if(howManyDone == party.getPlayerNames().size()) + if (howManyDone == party.getPlayerNames().size()) return getMaxProgress(); return 0; @@ -294,18 +293,18 @@ public class QuestKill extends QuestInterface implements IQuestKill { } } } - return 0; - } + return 0; + } - public void setProgress(int progress) { - if (progress >= 0 && progress <= this.amount) { - if(player != null){ + public void setProgress(int progress) { + if (progress >= 0 && progress <= this.amount) { + if (player != null) { PlayerData data = PlayerDataController.Instance.getPlayerData(player); PlayerQuestData playerdata = data.questData; - QuestData questdata = (QuestData)playerdata.activeQuests.get(this.parent.questId); - if(questdata != null){ + QuestData questdata = (QuestData) playerdata.activeQuests.get(this.parent.questId); + if (questdata != null) { HashMap killed = this.parent.getKilled(questdata); - if (!killed.containsKey(this.entity) || (Integer)killed.get(this.entity) != progress) { + if (!killed.containsKey(this.entity) || (Integer) killed.get(this.entity) != progress) { killed.put(this.entity, progress); this.parent.setKilled(questdata, killed); data.questData.checkQuestCompletion(data, EnumQuestType.values()[2]); @@ -314,23 +313,22 @@ public class QuestKill extends QuestInterface implements IQuestKill { data.save(); } } - } else if(party != null){ + } else if (party != null) { QuestData questdata = party.getQuestData(); - if(questdata != null){ - if(questdata.quest.partyOptions.objectiveRequirement == EnumPartyObjectives.All){ - for(String player : party.getPlayerNames()){ + if (questdata != null) { + if (questdata.quest.partyOptions.objectiveRequirement == EnumPartyObjectives.All) { + for (String player : party.getPlayerNames()) { HashMap killed = this.parent.getPlayerKilled(questdata, player); - if (!killed.containsKey(this.entity) || (Integer)killed.get(this.entity) != progress) { + if (!killed.containsKey(this.entity) || (Integer) killed.get(this.entity) != progress) { killed.put(this.entity, progress); this.parent.setPlayerKilled(questdata, killed, player); } } PartyController.Instance().checkQuestCompletion(party, EnumQuestType.values()[2]); PartyController.Instance().checkQuestCompletion(party, EnumQuestType.values()[4]); - } - else { + } else { HashMap killed = this.parent.getKilled(questdata); - if (!killed.containsKey(this.entity) || (Integer)killed.get(this.entity) != progress) { + if (!killed.containsKey(this.entity) || (Integer) killed.get(this.entity) != progress) { killed.put(this.entity, progress); this.parent.setKilled(questdata, killed); PartyController.Instance().checkQuestCompletion(party, EnumQuestType.values()[2]); @@ -339,22 +337,22 @@ public class QuestKill extends QuestInterface implements IQuestKill { } } } - } else { - throw new CustomNPCsException("Progress has to be between 0 and " + this.amount, new Object[0]); - } - } + } else { + throw new CustomNPCsException("Progress has to be between 0 and " + this.amount, new Object[0]); + } + } @Override public void setPlayerProgress(String playerName, int progress) { if (progress >= 0 && progress <= this.amount) { EntityPlayer foundplayer = NoppesUtilServer.getPlayerByName(playerName); - if(foundplayer != null && party == null){ + if (foundplayer != null && party == null) { PlayerData data = PlayerDataController.Instance.getPlayerData(foundplayer); PlayerQuestData playerdata = data.questData; - QuestData questdata = (QuestData)playerdata.activeQuests.get(this.parent.questId); - if(questdata != null){ + QuestData questdata = (QuestData) playerdata.activeQuests.get(this.parent.questId); + if (questdata != null) { HashMap killed = this.parent.getKilled(questdata); - if (!killed.containsKey(this.entity) || (Integer)killed.get(this.entity) != progress) { + if (!killed.containsKey(this.entity) || (Integer) killed.get(this.entity) != progress) { killed.put(this.entity, progress); this.parent.setKilled(questdata, killed); data.questData.checkQuestCompletion(data, EnumQuestType.values()[2]); @@ -363,21 +361,20 @@ public class QuestKill extends QuestInterface implements IQuestKill { data.save(); } } - } else if (foundplayer != null){ + } else if (foundplayer != null) { QuestData questdata = party.getQuestData(); - if(questdata != null){ - if(questdata.quest.partyOptions.objectiveRequirement == EnumPartyObjectives.All){ + if (questdata != null) { + if (questdata.quest.partyOptions.objectiveRequirement == EnumPartyObjectives.All) { HashMap killed = this.parent.getPlayerKilled(questdata, playerName); - if (!killed.containsKey(this.entity) || (Integer)killed.get(this.entity) != progress) { + if (!killed.containsKey(this.entity) || (Integer) killed.get(this.entity) != progress) { killed.put(this.entity, progress); this.parent.setPlayerKilled(questdata, killed, playerName); } PartyController.Instance().checkQuestCompletion(party, EnumQuestType.values()[2]); PartyController.Instance().checkQuestCompletion(party, EnumQuestType.values()[4]); - } - else { + } else { HashMap killed = this.parent.getKilled(questdata); - if (!killed.containsKey(this.entity) || (Integer)killed.get(this.entity) != progress) { + if (!killed.containsKey(this.entity) || (Integer) killed.get(this.entity) != progress) { killed.put(this.entity, progress); this.parent.setKilled(questdata, killed); PartyController.Instance().checkQuestCompletion(party, EnumQuestType.values()[2]); @@ -392,25 +389,25 @@ public class QuestKill extends QuestInterface implements IQuestKill { } public int getMaxProgress() { - return this.amount; - } + return this.amount; + } - public boolean isCompleted() { - return this.getProgress() >= this.amount; - } + public boolean isCompleted() { + return this.getProgress() >= this.amount; + } - public String getText() { - if(party != null) { - if(party.getObjectiveRequirement() == EnumPartyObjectives.All ){ + public String getText() { + if (party != null) { + if (party.getObjectiveRequirement() == EnumPartyObjectives.All) { return this.entity + ": " + this.getMaxProgress() + (isCompleted() ? " (Done)" : ""); } } - return this.entity + ": " + this.getProgress() + "/" + this.getMaxProgress(); - } + return this.entity + ": " + this.getProgress() + "/" + this.getMaxProgress(); + } @Override public String getAdditionalText() { - if(party != null) { + if (party != null) { List incompletePlayers = new ArrayList<>(); QuestData questdata = party.getQuestData(); if (questdata != null) { @@ -418,13 +415,13 @@ public class QuestKill extends QuestInterface implements IQuestKill { for (String player : party.getPlayerNames()) { HashMap killed = this.parent.getPlayerKilled(questdata, player); int currentProgress = !killed.containsKey(this.entity) ? 0 : (Integer) killed.get(this.entity); - if(currentProgress < this.amount){ + if (currentProgress < this.amount) { String state = player + ": " + currentProgress; incompletePlayers.add(state); } } - if(!incompletePlayers.isEmpty()) - return "[" + String.join(", ", incompletePlayers) + "]"; + if (!incompletePlayers.isEmpty()) + return "[" + String.join(", ", incompletePlayers) + "]"; } } } diff --git a/src/main/java/noppes/npcs/quests/QuestLocation.java b/src/main/java/noppes/npcs/quests/QuestLocation.java index 85b09d1c0..c5b8be0ed 100644 --- a/src/main/java/noppes/npcs/quests/QuestLocation.java +++ b/src/main/java/noppes/npcs/quests/QuestLocation.java @@ -22,57 +22,57 @@ import java.util.List; import java.util.Vector; public class QuestLocation extends QuestInterface implements IQuestLocation { - public String location = ""; - public String location2 = ""; - public String location3 = ""; + public String location = ""; + public String location2 = ""; + public String location3 = ""; @Override - public void readEntityFromNBT(NBTTagCompound compound) { - location = compound.getString("QuestLocation"); - location2 = compound.getString("QuestLocation2"); - location3 = compound.getString("QuestLocation3"); - } + public void readEntityFromNBT(NBTTagCompound compound) { + location = compound.getString("QuestLocation"); + location2 = compound.getString("QuestLocation2"); + location3 = compound.getString("QuestLocation3"); + } - @Override - public void writeEntityToNBT(NBTTagCompound compound) { - compound.setString("QuestLocation", location); - compound.setString("QuestLocation2", location2); - compound.setString("QuestLocation3", location3); - } + @Override + public void writeEntityToNBT(NBTTagCompound compound) { + compound.setString("QuestLocation", location); + compound.setString("QuestLocation2", location2); + compound.setString("QuestLocation3", location3); + } - @Override - public boolean isCompleted(PlayerData playerData) { - PlayerQuestData playerdata = playerData.questData; - QuestData data = playerdata.activeQuests.get(questId); - if(data == null) - return false; - return getFound(data, 0); - } + @Override + public boolean isCompleted(PlayerData playerData) { + PlayerQuestData playerdata = playerData.questData; + QuestData data = playerdata.activeQuests.get(questId); + if (data == null) + return false; + return getFound(data, 0); + } - @Override - public void handleComplete(EntityPlayer player) { - super.handleComplete(player); - } + @Override + public void handleComplete(EntityPlayer player) { + super.handleComplete(player); + } - @Override - public Vector getQuestLogStatus(EntityPlayer player) { - Vector vec = new Vector(); - PlayerQuestData playerdata = PlayerDataController.Instance.getPlayerData(player).questData; - QuestData data = playerdata.activeQuests.get(questId); - if(data == null) - return vec; - String found = StatCollector.translateToLocal("quest.found"); - String notfound = StatCollector.translateToLocal("quest.notfound"); + @Override + public Vector getQuestLogStatus(EntityPlayer player) { + Vector vec = new Vector(); + PlayerQuestData playerdata = PlayerDataController.Instance.getPlayerData(player).questData; + QuestData data = playerdata.activeQuests.get(questId); + if (data == null) + return vec; + String found = StatCollector.translateToLocal("quest.found"); + String notfound = StatCollector.translateToLocal("quest.notfound"); - if(!location.isEmpty()) - vec.add(location + ": " + (getFound(data,1)?found:notfound)); - if(!location2.isEmpty()) - vec.add(location2 + ": " + (getFound(data,2)?found:notfound)); - if(!location3.isEmpty()) - vec.add(location3 + ": " + (getFound(data,3)?found:notfound)); + if (!location.isEmpty()) + vec.add(location + ": " + (getFound(data, 1) ? found : notfound)); + if (!location2.isEmpty()) + vec.add(location2 + ": " + (getFound(data, 2) ? found : notfound)); + if (!location3.isEmpty()) + vec.add(location3 + ": " + (getFound(data, 3) ? found : notfound)); - return vec; - } + return vec; + } @Override public IQuestObjective[] getObjectives(EntityPlayer player) { @@ -89,74 +89,73 @@ public class QuestLocation extends QuestInterface implements IQuestLocation { list.add(new noppes.npcs.quests.QuestLocation.QuestLocationObjective(this, player, this.location3, "Location3Found")); } - return (IQuestObjective[])list.toArray(new IQuestObjective[list.size()]); + return (IQuestObjective[]) list.toArray(new IQuestObjective[list.size()]); } - public boolean getFound(QuestData data, int i) { - if(i == 1) + public boolean getFound(QuestData data, int i) { + if (i == 1) return data.extraData.getBoolean("LocationFound"); - if(i == 2) + if (i == 2) return data.extraData.getBoolean("Location2Found"); - if(i == 3) + if (i == 3) return data.extraData.getBoolean("Location3Found"); - if(!location.isEmpty() && !data.extraData.getBoolean("LocationFound")) + if (!location.isEmpty() && !data.extraData.getBoolean("LocationFound")) return false; - if(!location2.isEmpty() && !data.extraData.getBoolean("Location2Found")) + if (!location2.isEmpty() && !data.extraData.getBoolean("Location2Found")) return false; - if(!location3.isEmpty() && !data.extraData.getBoolean("Location3Found")) + if (!location3.isEmpty() && !data.extraData.getBoolean("Location3Found")) return false; return true; } - public boolean setFound(QuestData data, String location) { - if(location.equalsIgnoreCase(this.location) && !data.extraData.getBoolean("LocationFound")){ - data.extraData.setBoolean("LocationFound", true); - return true; - } - if(location.equalsIgnoreCase(location2) && !data.extraData.getBoolean("LocationFound2")){ - data.extraData.setBoolean("Location2Found", true); - return true; - } - if(location.equalsIgnoreCase(location3) && !data.extraData.getBoolean("LocationFound3")){ - data.extraData.setBoolean("Location3Found", true); - return true; - } + public boolean setFound(QuestData data, String location) { + if (location.equalsIgnoreCase(this.location) && !data.extraData.getBoolean("LocationFound")) { + data.extraData.setBoolean("LocationFound", true); + return true; + } + if (location.equalsIgnoreCase(location2) && !data.extraData.getBoolean("LocationFound2")) { + data.extraData.setBoolean("Location2Found", true); + return true; + } + if (location.equalsIgnoreCase(location3) && !data.extraData.getBoolean("LocationFound3")) { + data.extraData.setBoolean("Location3Found", true); + return true; + } - return false; - } + return false; + } public boolean setFoundParty(Party party, EntityPlayer player, String location, boolean isLeader) { QuestData data = party.getQuestData(); - if(data == null) + if (data == null) return false; - if(data.quest == null) + if (data.quest == null) return false; int memberCount = party.getPlayerNames().size(); EnumPartyObjectives objectives = data.quest.partyOptions.objectiveRequirement; - if(objectives == EnumPartyObjectives.All){ - if(location.equalsIgnoreCase(this.location) && !data.extraData.getBoolean("LocationFound")){ + if (objectives == EnumPartyObjectives.All) { + if (location.equalsIgnoreCase(this.location) && !data.extraData.getBoolean("LocationFound")) { return setPartyPlayerFound(data, player, "LocationFound", memberCount); } - if(location.equalsIgnoreCase(location2) && !data.extraData.getBoolean("LocationFound2")){ + if (location.equalsIgnoreCase(location2) && !data.extraData.getBoolean("LocationFound2")) { return setPartyPlayerFound(data, player, "Location2Found", memberCount); } - if(location.equalsIgnoreCase(location3) && !data.extraData.getBoolean("LocationFound3")){ + if (location.equalsIgnoreCase(location3) && !data.extraData.getBoolean("LocationFound3")) { return setPartyPlayerFound(data, player, "Location3Found", memberCount); } - } - else if(objectives == EnumPartyObjectives.Leader && isLeader || objectives == EnumPartyObjectives.Shared){ - if(location.equalsIgnoreCase(this.location) && !data.extraData.getBoolean("LocationFound")){ + } else if (objectives == EnumPartyObjectives.Leader && isLeader || objectives == EnumPartyObjectives.Shared) { + if (location.equalsIgnoreCase(this.location) && !data.extraData.getBoolean("LocationFound")) { data.extraData.setBoolean("LocationFound", true); return true; } - if(location.equalsIgnoreCase(location2) && !data.extraData.getBoolean("LocationFound2")){ + if (location.equalsIgnoreCase(location2) && !data.extraData.getBoolean("LocationFound2")) { data.extraData.setBoolean("Location2Found", true); return true; } - if(location.equalsIgnoreCase(location3) && !data.extraData.getBoolean("LocationFound3")){ + if (location.equalsIgnoreCase(location3) && !data.extraData.getBoolean("LocationFound3")) { data.extraData.setBoolean("Location3Found", true); return true; } @@ -166,15 +165,15 @@ public class QuestLocation extends QuestInterface implements IQuestLocation { public List getPartyFound(Party party, String locationFoundKey) { List foundPlayers = new ArrayList<>(); - if(party == null) + if (party == null) return foundPlayers; QuestData data = party.getQuestData(); - if(data == null) + if (data == null) return foundPlayers; String locationKey = "Players" + locationFoundKey; - if(data.extraData.hasKey(locationKey)){ + if (data.extraData.hasKey(locationKey)) { foundPlayers = NBTTags.getStringList(data.extraData.getTagList(locationKey, 10)); } @@ -186,20 +185,19 @@ public class QuestLocation extends QuestInterface implements IQuestLocation { boolean newFind = false; List foundPlayers; String locationKey = "Players" + locationFoundKey; - if(data.extraData.hasKey(locationKey)){ + if (data.extraData.hasKey(locationKey)) { foundPlayers = NBTTags.getStringList(data.extraData.getTagList(locationKey, 10)); - } - else { + } else { foundPlayers = new ArrayList<>(); } - if(!foundPlayers.contains(player.getCommandSenderName())){ + if (!foundPlayers.contains(player.getCommandSenderName())) { foundPlayers.add(player.getCommandSenderName()); newFind = true; } data.extraData.setTag(locationKey, NBTTags.nbtStringList(foundPlayers)); - if(foundPlayers.size() == partySize){ + if (foundPlayers.size() == partySize) { data.extraData.setBoolean(locationFoundKey, true); } @@ -221,41 +219,41 @@ public class QuestLocation extends QuestInterface implements IQuestLocation { list.add(new noppes.npcs.quests.QuestLocation.QuestLocationObjective(this, party, this.location3, "Location3Found", getPartyFound(party, "Location3Found"))); } - return (IQuestObjective[])list.toArray(new IQuestObjective[list.size()]); + return (IQuestObjective[]) list.toArray(new IQuestObjective[list.size()]); } @Override public Vector getPartyQuestLogStatus(Party party) { Vector vec = new Vector(); QuestData data = party.getQuestData(); - if(data == null) + if (data == null) return vec; String found = StatCollector.translateToLocal("quest.found"); String notfound = StatCollector.translateToLocal("quest.notfound"); - if(data.quest == null) + if (data.quest == null) return vec; boolean requireAll = data.quest.partyOptions.objectiveRequirement == EnumPartyObjectives.All; - if(!location.isEmpty()){ - vec.add(location + ": " + (getFound(data,1)?found:notfound)); - if(requireAll){ + if (!location.isEmpty()) { + vec.add(location + ": " + (getFound(data, 1) ? found : notfound)); + if (requireAll) { List playersFound = getPartyFound(party, "LocationFound"); String playersFoundString = "Completed: " + String.join(", ", playersFound); vec.add(playersFoundString); } } - if(!location2.isEmpty()){ - vec.add(location2 + ": " + (getFound(data,2)?found:notfound)); - if(requireAll){ + if (!location2.isEmpty()) { + vec.add(location2 + ": " + (getFound(data, 2) ? found : notfound)); + if (requireAll) { List playersFound = getPartyFound(party, "Location2Found"); String playersFoundString = "Completed: " + String.join(", ", playersFound); vec.add(playersFoundString); } } - if(!location3.isEmpty()){ - vec.add(location3 + ": " + (getFound(data,3)?found:notfound)); - if(requireAll){ + if (!location3.isEmpty()) { + vec.add(location3 + ": " + (getFound(data, 3) ? found : notfound)); + if (requireAll) { List playersFound = getPartyFound(party, "Location3Found"); String playersFoundString = "Completed: " + String.join(", ", playersFound); vec.add(playersFoundString); @@ -264,12 +262,12 @@ public class QuestLocation extends QuestInterface implements IQuestLocation { return vec; } - public boolean isMultiQuest(Party party){ + public boolean isMultiQuest(Party party) { QuestData data = party.getQuestData(); - if(data == null) + if (data == null) return false; - if(data.quest == null) + if (data.quest == null) return false; return data.quest.partyOptions.objectiveRequirement == EnumPartyObjectives.All; @@ -277,52 +275,55 @@ public class QuestLocation extends QuestInterface implements IQuestLocation { @Override public boolean isPartyCompleted(Party party) { - if(party == null) + if (party == null) return false; QuestData data = party.getQuestData(); - if(data == null) + if (data == null) return false; return getFound(data, 0); } - public void setLocation1(String loc1){ - this.location = loc1; - } - public String getLocation1(){ - return location; - } + public void setLocation1(String loc1) { + this.location = loc1; + } - public void setLocation2(String loc2){ - this.location2 = loc2; - } - public String getLocation2(){ - return location2; - } + public String getLocation1() { + return location; + } - public void setLocation3(String loc3){ - this.location3 = loc3; - } - public String getLocation3(){ - return location3; - } + public void setLocation2(String loc2) { + this.location2 = loc2; + } - class QuestLocationObjective implements IQuestObjective { - private final QuestLocation parent; - private final EntityPlayer player; + public String getLocation2() { + return location2; + } + + public void setLocation3(String loc3) { + this.location3 = loc3; + } + + public String getLocation3() { + return location3; + } + + class QuestLocationObjective implements IQuestObjective { + private final QuestLocation parent; + private final EntityPlayer player; private final Party party; - private final String location; - private final String nbtName; + private final String location; + private final String nbtName; private final List completedPlayers; - public QuestLocationObjective(QuestLocation this$0, EntityPlayer player, String location, String nbtName) { - this.parent = this$0; - this.player = player; - this.location = location; - this.nbtName = nbtName; + public QuestLocationObjective(QuestLocation this$0, EntityPlayer player, String location, String nbtName) { + this.parent = this$0; + this.player = player; + this.location = location; + this.nbtName = nbtName; this.party = null; this.completedPlayers = new ArrayList<>(); - } + } public QuestLocationObjective(QuestLocation this$0, Party party, String location, String nbtName, List completedPlayers) { this.parent = this$0; @@ -330,34 +331,34 @@ public class QuestLocation extends QuestInterface implements IQuestLocation { this.location = location; this.nbtName = nbtName; this.party = party; - this.completedPlayers = new ArrayList<>(completedPlayers); + this.completedPlayers = new ArrayList<>(completedPlayers); } - public int getProgress() { - return this.isCompleted() ? 1 : 0; - } + public int getProgress() { + return this.isCompleted() ? 1 : 0; + } - public void setProgress(int progress) { - if (progress >= 0 && progress <= 1) { - if(player != null){ + public void setProgress(int progress) { + if (progress >= 0 && progress <= 1) { + if (player != null) { PlayerData data = PlayerDataController.Instance.getPlayerData(player); - QuestData questData = (QuestData)data.questData.activeQuests.get(this.parent.questId); - boolean completed = questData.extraData.getBoolean (this.nbtName); + QuestData questData = (QuestData) data.questData.activeQuests.get(this.parent.questId); + boolean completed = questData.extraData.getBoolean(this.nbtName); if ((!completed || progress != 1) && (completed || progress != 0)) { questData.extraData.setBoolean(this.nbtName, progress == 1); data.questData.checkQuestCompletion(data, EnumQuestType.values()[3]); data.save(); data.updateClient = true; } - } else if (party != null){ + } else if (party != null) { QuestData questData = party.getQuestData(); - boolean completed = questData.extraData.getBoolean (this.nbtName); + boolean completed = questData.extraData.getBoolean(this.nbtName); if ((!completed || progress != 1) && (completed || progress != 0)) { boolean setTo = progress == 1; questData.extraData.setBoolean(this.nbtName, setTo); - if(questData.quest.partyOptions.objectiveRequirement == EnumPartyObjectives.All){ + if (questData.quest.partyOptions.objectiveRequirement == EnumPartyObjectives.All) { completedPlayers.clear(); - if(setTo){ + if (setTo) { completedPlayers.addAll(party.getPlayerNames()); } String locationKey = "Players" + nbtName; @@ -366,34 +367,34 @@ public class QuestLocation extends QuestInterface implements IQuestLocation { PartyController.Instance().checkQuestCompletion(party, EnumQuestType.values()[3]); } } - } else { - throw new CustomNPCsException("Progress has to be 0 or 1", new Object[0]); - } - } + } else { + throw new CustomNPCsException("Progress has to be 0 or 1", new Object[0]); + } + } @Override public void setPlayerProgress(String playerName, int progress) { if (progress >= 0 && progress <= 1) { EntityPlayer foundplayer = NoppesUtilServer.getPlayerByName(playerName); - if(foundplayer != null && party == null){ + if (foundplayer != null && party == null) { PlayerData data = PlayerDataController.Instance.getPlayerData(foundplayer); - QuestData questData = (QuestData)data.questData.activeQuests.get(this.parent.questId); - boolean completed = questData.extraData.getBoolean (this.nbtName); + QuestData questData = (QuestData) data.questData.activeQuests.get(this.parent.questId); + boolean completed = questData.extraData.getBoolean(this.nbtName); if ((!completed || progress != 1) && (completed || progress != 0)) { questData.extraData.setBoolean(this.nbtName, progress == 1); data.questData.checkQuestCompletion(data, EnumQuestType.values()[3]); data.save(); data.updateClient = true; } - } else if (foundplayer != null){ + } else if (foundplayer != null) { QuestData questData = party.getQuestData(); - boolean completed = questData.extraData.getBoolean (this.nbtName); + boolean completed = questData.extraData.getBoolean(this.nbtName); if ((!completed || progress != 1) && (completed || progress != 0)) { boolean setTo = progress == 1; questData.extraData.setBoolean(this.nbtName, setTo); - if(questData.quest.partyOptions.objectiveRequirement == EnumPartyObjectives.All){ - if(setTo){ - if(!completedPlayers.contains(foundplayer.getCommandSenderName())) + if (questData.quest.partyOptions.objectiveRequirement == EnumPartyObjectives.All) { + if (setTo) { + if (!completedPlayers.contains(foundplayer.getCommandSenderName())) completedPlayers.add(foundplayer.getCommandSenderName()); } else { completedPlayers.remove(foundplayer.getCommandSenderName()); @@ -410,35 +411,35 @@ public class QuestLocation extends QuestInterface implements IQuestLocation { } public int getMaxProgress() { - return 1; - } + return 1; + } - public boolean isCompleted() { + public boolean isCompleted() { QuestData questData = null; - if(player != null){ + if (player != null) { PlayerData data = PlayerDataController.Instance.getPlayerData(player); PlayerQuestData playerQuestData = data.questData; - if(playerQuestData != null){ + if (playerQuestData != null) { questData = playerQuestData.activeQuests.get(this.parent.questId); } - } else if(party != null){ + } else if (party != null) { questData = party.getQuestData(); } - if(questData != null){ + if (questData != null) { return questData.extraData.getBoolean(this.nbtName); } - return false; - } + return false; + } - public String getText() { - return this.location + ": " + (this.isCompleted() ? "Found" : "Not Found"); - } + public String getText() { + return this.location + ": " + (this.isCompleted() ? "Found" : "Not Found"); + } public String getAdditionalText() { - if(party != null && parent.isMultiQuest(party) && completedPlayers.size() != party.getPlayerNames().size()) - return "Completed: " + String.join(", ", completedPlayers); + if (party != null && parent.isMultiQuest(party) && completedPlayers.size() != party.getPlayerNames().size()) + return "Completed: " + String.join(", ", completedPlayers); return null; } - } + } } diff --git a/src/main/java/noppes/npcs/quests/QuestManual.java b/src/main/java/noppes/npcs/quests/QuestManual.java index 2bac92bef..ba0ee2b20 100644 --- a/src/main/java/noppes/npcs/quests/QuestManual.java +++ b/src/main/java/noppes/npcs/quests/QuestManual.java @@ -18,27 +18,27 @@ import noppes.npcs.scripted.CustomNPCsException; import java.util.*; import java.util.Map.Entry; -public class QuestManual extends QuestInterface{ - public TreeMap manuals = new TreeMap(); +public class QuestManual extends QuestInterface { + public TreeMap manuals = new TreeMap(); - @Override - public void readEntityFromNBT(NBTTagCompound compound) { - manuals = new TreeMap<>(NBTTags.getStringIntegerMap(compound.getTagList("QuestManual", 10))); - } + @Override + public void readEntityFromNBT(NBTTagCompound compound) { + manuals = new TreeMap<>(NBTTags.getStringIntegerMap(compound.getTagList("QuestManual", 10))); + } - @Override - public void writeEntityToNBT(NBTTagCompound compound) { - compound.setTag("QuestManual", NBTTags.nbtStringIntegerMap(manuals)); - } + @Override + public void writeEntityToNBT(NBTTagCompound compound) { + compound.setTag("QuestManual", NBTTags.nbtStringIntegerMap(manuals)); + } - @Override - public boolean isCompleted(PlayerData playerData) { - if(playerData == null) + @Override + public boolean isCompleted(PlayerData playerData) { + if (playerData == null) return false; - QuestData data = playerData.questData.activeQuests.get(questId); - if(data == null) - return false; + QuestData data = playerData.questData.activeQuests.get(questId); + if (data == null) + return false; HashMap manual = getManual(data); if (manuals.size() != manual.size()) return false; @@ -48,11 +48,12 @@ public class QuestManual extends QuestInterface{ return false; } - return true; - } + return true; + } - @Override - public void handleComplete(EntityPlayer player) {} + @Override + public void handleComplete(EntityPlayer player) { + } @Override public Vector getQuestLogStatus(EntityPlayer player) { @@ -73,75 +74,74 @@ public class QuestManual extends QuestInterface{ } public HashMap getManual(QuestData data) { - return NBTTags.getStringIntegerMap(data.extraData.getTagList("Manual", 10)); - } + return NBTTags.getStringIntegerMap(data.extraData.getTagList("Manual", 10)); + } - public void setManual(QuestData data, HashMap manual) { - data.extraData.setTag("Manual", NBTTags.nbtStringIntegerMap(manual)); - } + public void setManual(QuestData data, HashMap manual) { + data.extraData.setTag("Manual", NBTTags.nbtStringIntegerMap(manual)); + } public HashMap getPlayerManual(QuestData data, String playerName) { return NBTTags.getStringIntegerMap(data.extraData.getTagList(playerName + "Manual", 10)); } + public void setPlayerManual(QuestData data, HashMap playerManual, String playerName) { data.extraData.setTag(playerName + "Manual", NBTTags.nbtStringIntegerMap(playerManual)); } - @Override - public IQuestObjective[] getObjectives(EntityPlayer player) { - List list = new ArrayList(); - for(Entry entry : manuals.entrySet()){ - list.add(new QuestManualObjective(player, entry.getKey(), entry.getValue())); - } - return list.toArray(new IQuestObjective[list.size()]); - } + @Override + public IQuestObjective[] getObjectives(EntityPlayer player) { + List list = new ArrayList(); + for (Entry entry : manuals.entrySet()) { + list.add(new QuestManualObjective(player, entry.getKey(), entry.getValue())); + } + return list.toArray(new IQuestObjective[list.size()]); + } @Override - public IQuestObjective[] getPartyObjectives(Party party){ + public IQuestObjective[] getPartyObjectives(Party party) { List list = new ArrayList(); - for(Entry entry : manuals.entrySet()){ + for (Entry entry : manuals.entrySet()) { list.add(new QuestManualObjective(party, entry.getKey(), entry.getValue())); } - return (IQuestObjective[])list.toArray(new IQuestObjective[list.size()]); + return (IQuestObjective[]) list.toArray(new IQuestObjective[list.size()]); } @Override public Vector getPartyQuestLogStatus(Party party) { Vector vec = new Vector(); QuestData data = party.getQuestData(); - if(data == null) + if (data == null) return vec; - if(data.quest.partyOptions.objectiveRequirement == EnumPartyObjectives.All){ - for(String entityName : manuals.keySet()){ + if (data.quest.partyOptions.objectiveRequirement == EnumPartyObjectives.All) { + for (String entityName : manuals.keySet()) { String firstLine = entityName + ": " + manuals.get(entityName); List playerResults = new ArrayList<>(); - for(String player : party.getPlayerNames()){ - HashMap playerManual = getPlayerManual(data, player); + for (String player : party.getPlayerNames()) { + HashMap playerManual = getPlayerManual(data, player); int amount = 0; - if(playerManual.containsKey(entityName)) + if (playerManual.containsKey(entityName)) amount = playerManual.get(entityName); - if(amount < manuals.get(entityName)){ + if (amount < manuals.get(entityName)) { String state = player + ": " + amount; playerResults.add(state); } } - if(!playerResults.isEmpty()){ + if (!playerResults.isEmpty()) { vec.add(firstLine); vec.add("[" + String.join(", ", playerResults) + "]"); - } - else { + } else { vec.add(firstLine + " (Done)"); } } - } - else { + } else { HashMap manual = getManual(data); for (String entity : manuals.keySet()) { int amount = 0; - if(manual.containsKey(entity)) + if (manual.containsKey(entity)) amount = manual.get(entity); String state = amount + "/" + manuals.get(entity); vec.add(entity + ": " + state); @@ -152,60 +152,59 @@ public class QuestManual extends QuestInterface{ @Override public boolean isPartyCompleted(Party party) { - if(party == null) + if (party == null) return false; QuestData data = party.getQuestData(); - if(data == null) + if (data == null) return false; - if(data.quest.partyOptions.objectiveRequirement == EnumPartyObjectives.All){ - for(String entityName : manuals.keySet()){ - for(String player : party.getPlayerNames()){ + if (data.quest.partyOptions.objectiveRequirement == EnumPartyObjectives.All) { + for (String entityName : manuals.keySet()) { + for (String player : party.getPlayerNames()) { HashMap playerManual = getPlayerManual(data, player); int amount = playerManual.getOrDefault(entityName, 0); - if(amount < manuals.get(entityName)){ + if (amount < manuals.get(entityName)) { return false; } } } - } - else { + } else { int completed = 0; - HashMap playerManual = getManual(data); - for(String entityName : manuals.keySet()){ + HashMap playerManual = getManual(data); + for (String entityName : manuals.keySet()) { int amount = 0; - if(playerManual.containsKey(entityName)) + if (playerManual.containsKey(entityName)) amount = playerManual.get(entityName); - if(amount >= manuals.get(entityName)){ + if (amount >= manuals.get(entityName)) { completed++; } } - if(completed >= manuals.keySet().size()) + if (completed >= manuals.keySet().size()) return true; - if(playerManual.size() != manuals.size()) + if (playerManual.size() != manuals.size()) return false; - for(String entity : playerManual.keySet()){ - if(!manuals.containsKey(entity) || manuals.get(entity) > playerManual.get(entity)) + for (String entity : playerManual.keySet()) { + if (!manuals.containsKey(entity) || manuals.get(entity) > playerManual.get(entity)) return false; } } return true; } - class QuestManualObjective implements IQuestObjective{ - private final EntityPlayer player; - private final String entity; + class QuestManualObjective implements IQuestObjective { + private final EntityPlayer player; + private final String entity; private final Party party; - private final int amount; + private final int amount; public QuestManualObjective(EntityPlayer player, String entity, int amount) { - this.player = player; - this.entity = entity; - this.amount = amount; + this.player = player; + this.entity = entity; + this.amount = amount; this.party = null; - } + } public QuestManualObjective(Party party, String entity, int amount) { this.party = party; @@ -214,17 +213,17 @@ public class QuestManual extends QuestInterface{ this.player = null; } - @Override - public int getProgress() { - if(player != null){ + @Override + public int getProgress() { + if (player != null) { PlayerData data = PlayerDataController.Instance.getPlayerData(player); PlayerQuestData playerdata = data.questData; - QuestData questdata = (QuestData)playerdata.activeQuests.get(questId); - if(questdata != null){ + QuestData questdata = (QuestData) playerdata.activeQuests.get(questId); + if (questdata != null) { HashMap playerManual = getManual(questdata); - return !playerManual.containsKey(this.entity) ? 0 : (Integer)playerManual.get(this.entity); + return !playerManual.containsKey(this.entity) ? 0 : (Integer) playerManual.get(this.entity); } - } else if(party != null) { + } else if (party != null) { QuestData questdata = party.getQuestData(); if (questdata != null) { if (questdata.quest.partyOptions.objectiveRequirement == EnumPartyObjectives.All) { @@ -232,10 +231,10 @@ public class QuestManual extends QuestInterface{ for (String player : party.getPlayerNames()) { HashMap playerManual = getPlayerManual(questdata, player); int currentProgress = !playerManual.containsKey(this.entity) ? 0 : (Integer) playerManual.get(this.entity); - if(currentProgress >= this.amount) + if (currentProgress >= this.amount) howManyDone += 1; } - if(howManyDone == party.getPlayerNames().size()) + if (howManyDone == party.getPlayerNames().size()) return getMaxProgress(); return 0; @@ -246,10 +245,10 @@ public class QuestManual extends QuestInterface{ } } return 0; - } + } - @Override - public void setProgress(int progress) { + @Override + public void setProgress(int progress) { if (progress >= 0 && progress <= this.amount) { if (player != null) { PlayerData data = PlayerDataController.Instance.getPlayerData(player); @@ -296,7 +295,7 @@ public class QuestManual extends QuestInterface{ public void setPlayerProgress(String playerName, int progress) { if (progress >= 0 && progress <= this.amount) { EntityPlayer foundplayer = NoppesUtilServer.getPlayerByName(playerName); - if(foundplayer != null && party == null){ + if (foundplayer != null && party == null) { PlayerData data = PlayerDataController.Instance.getPlayerData(foundplayer); PlayerQuestData playerdata = data.questData; QuestData questdata = (QuestData) playerdata.activeQuests.get(questId); @@ -310,7 +309,7 @@ public class QuestManual extends QuestInterface{ data.save(); } } - } else if (foundplayer != null){ + } else if (foundplayer != null) { QuestData questdata = party.getQuestData(); if (questdata != null) { if (questdata.quest.partyOptions.objectiveRequirement == EnumPartyObjectives.All) { @@ -336,28 +335,28 @@ public class QuestManual extends QuestInterface{ } @Override - public int getMaxProgress() { - return amount; - } + public int getMaxProgress() { + return amount; + } - @Override - public boolean isCompleted() { - return getProgress() >= amount; - } + @Override + public boolean isCompleted() { + return getProgress() >= amount; + } - @Override - public String getText() { - if(party != null) { - if(party.getObjectiveRequirement() == EnumPartyObjectives.All ){ + @Override + public String getText() { + if (party != null) { + if (party.getObjectiveRequirement() == EnumPartyObjectives.All) { return this.entity + ": " + this.getMaxProgress() + (isCompleted() ? " (Done)" : ""); } } return this.entity + ": " + this.getProgress() + "/" + this.getMaxProgress(); - } + } @Override public String getAdditionalText() { - if(party != null) { + if (party != null) { List incompletePlayers = new ArrayList<>(); QuestData questdata = party.getQuestData(); if (questdata != null) { @@ -365,13 +364,13 @@ public class QuestManual extends QuestInterface{ for (String player : party.getPlayerNames()) { HashMap playerManual = getPlayerManual(questdata, player); int currentProgress = !playerManual.containsKey(this.entity) ? 0 : (Integer) playerManual.get(this.entity); - if(currentProgress < this.amount){ + if (currentProgress < this.amount) { String state = player + ": " + currentProgress; incompletePlayers.add(state); } } - if(!incompletePlayers.isEmpty()) - return "[" + String.join(", ", incompletePlayers) + "]"; + if (!incompletePlayers.isEmpty()) + return "[" + String.join(", ", incompletePlayers) + "]"; } } } diff --git a/src/main/java/noppes/npcs/roles/JobBard.java b/src/main/java/noppes/npcs/roles/JobBard.java index b17105629..ebdc2e8a8 100644 --- a/src/main/java/noppes/npcs/roles/JobBard.java +++ b/src/main/java/noppes/npcs/roles/JobBard.java @@ -12,131 +12,131 @@ import noppes.npcs.entity.EntityNPCInterface; import java.util.List; -public class JobBard extends JobInterface{ - public int minRange = 2; - public int maxRange = 64; +public class JobBard extends JobInterface { + public int minRange = 2; + public int maxRange = 64; - public boolean isStreamer = true; - public boolean hasOffRange = true; + public boolean isStreamer = true; + public boolean hasOffRange = true; - public String song = ""; + public String song = ""; - private EnumBardInstrument instrument = EnumBardInstrument.Banjo; + private EnumBardInstrument instrument = EnumBardInstrument.Banjo; - public JobBard(EntityNPCInterface npc) { - super(npc); - if(CustomItems.banjo != null){ - mainhand = new ItemStack(CustomItems.banjo); - overrideMainHand = overrideOffHand = true; - } - } + public JobBard(EntityNPCInterface npc) { + super(npc); + if (CustomItems.banjo != null) { + mainhand = new ItemStack(CustomItems.banjo); + overrideMainHand = overrideOffHand = true; + } + } - @Override - public NBTTagCompound writeToNBT(NBTTagCompound nbttagcompound) { - nbttagcompound.setString("BardSong", song); - nbttagcompound.setInteger("BardMinRange", minRange); - nbttagcompound.setInteger("BardMaxRange", maxRange); - nbttagcompound.setInteger("BardInstrument", instrument.ordinal()); - nbttagcompound.setBoolean("BardStreamer", isStreamer); - nbttagcompound.setBoolean("BardHasOff", hasOffRange); + @Override + public NBTTagCompound writeToNBT(NBTTagCompound nbttagcompound) { + nbttagcompound.setString("BardSong", song); + nbttagcompound.setInteger("BardMinRange", minRange); + nbttagcompound.setInteger("BardMaxRange", maxRange); + nbttagcompound.setInteger("BardInstrument", instrument.ordinal()); + nbttagcompound.setBoolean("BardStreamer", isStreamer); + nbttagcompound.setBoolean("BardHasOff", hasOffRange); - return nbttagcompound; - } + return nbttagcompound; + } - @Override - public void readFromNBT(NBTTagCompound nbttagcompound) { - song = nbttagcompound.getString("BardSong"); - minRange = nbttagcompound.getInteger("BardMinRange"); - maxRange = nbttagcompound.getInteger("BardMaxRange"); - setInstrument(nbttagcompound.getInteger("BardInstrument")); - isStreamer = nbttagcompound.getBoolean("BardStreamer"); - hasOffRange = nbttagcompound.getBoolean("BardHasOff"); - } + @Override + public void readFromNBT(NBTTagCompound nbttagcompound) { + song = nbttagcompound.getString("BardSong"); + minRange = nbttagcompound.getInteger("BardMinRange"); + maxRange = nbttagcompound.getInteger("BardMaxRange"); + setInstrument(nbttagcompound.getInteger("BardInstrument")); + isStreamer = nbttagcompound.getBoolean("BardStreamer"); + hasOffRange = nbttagcompound.getBoolean("BardHasOff"); + } - public void setInstrument(int i) { - if(CustomItems.banjo == null) - return; - instrument = EnumBardInstrument.values()[i]; - overrideMainHand = overrideOffHand = instrument != EnumBardInstrument.None; - switch(instrument){ - case None: - this.mainhand = null; - this.offhand = null; - break; - case Banjo: - this.mainhand = new ItemStack(CustomItems.banjo); - this.offhand = null; - break; - case Violin: - this.mainhand = new ItemStack(CustomItems.violin); - this.offhand = new ItemStack(CustomItems.violinbow); - break; - case Guitar: - this.mainhand = new ItemStack(CustomItems.guitar); - this.offhand = null; - break; - case Harp: - this.mainhand = new ItemStack(CustomItems.harp); - this.offhand = null; - break; - case FrenchHorn: - this.mainhand = new ItemStack(CustomItems.frenchHorn); - this.offhand = null; - break; - } - } - public EnumBardInstrument getInstrument(){ - return instrument; - } - public void onLivingUpdate() { - if(!npc.isRemote() || song.isEmpty()) - return; + public void setInstrument(int i) { + if (CustomItems.banjo == null) + return; + instrument = EnumBardInstrument.values()[i]; + overrideMainHand = overrideOffHand = instrument != EnumBardInstrument.None; + switch (instrument) { + case None: + this.mainhand = null; + this.offhand = null; + break; + case Banjo: + this.mainhand = new ItemStack(CustomItems.banjo); + this.offhand = null; + break; + case Violin: + this.mainhand = new ItemStack(CustomItems.violin); + this.offhand = new ItemStack(CustomItems.violinbow); + break; + case Guitar: + this.mainhand = new ItemStack(CustomItems.guitar); + this.offhand = null; + break; + case Harp: + this.mainhand = new ItemStack(CustomItems.harp); + this.offhand = null; + break; + case FrenchHorn: + this.mainhand = new ItemStack(CustomItems.frenchHorn); + this.offhand = null; + break; + } + } - if(!MusicController.Instance.isPlaying() && Minecraft.getMinecraft().currentScreen == null){ + public EnumBardInstrument getInstrument() { + return instrument; + } + + public void onLivingUpdate() { + if (!npc.isRemote() || song.isEmpty()) + return; + + if (!MusicController.Instance.isPlaying() && Minecraft.getMinecraft().currentScreen == null) { if (!this.play()) return; - } - else if(MusicController.Instance.getEntity() != npc){ - EntityPlayer player = CustomNpcs.proxy.getPlayer(); + } else if (MusicController.Instance.getEntity() != npc) { + EntityPlayer player = CustomNpcs.proxy.getPlayer(); double distanceToPlayer = npc.getDistanceToEntity(player); double distanceToMusic = MusicController.Instance.getDistance(); - if(Math.ceil(distanceToPlayer) < Math.ceil(distanceToMusic)){ + if (Math.ceil(distanceToPlayer) < Math.ceil(distanceToMusic)) { if (!this.play()) return; - } - } - else if(hasOffRange){ - List list = npc.worldObj.getEntitiesWithinAABB(EntityPlayer.class, npc.boundingBox.expand(maxRange, maxRange, maxRange)); - if(!list.contains(CustomNpcs.proxy.getPlayer())) - MusicController.Instance.stopMusic(); - } + } + } else if (hasOffRange) { + List list = npc.worldObj.getEntitiesWithinAABB(EntityPlayer.class, npc.boundingBox.expand(maxRange, maxRange, maxRange)); + if (!list.contains(CustomNpcs.proxy.getPlayer())) + MusicController.Instance.stopMusic(); + } - if(MusicController.Instance.isPlaying(song)) { + if (MusicController.Instance.isPlaying(song)) { Minecraft.getMinecraft().mcMusicTicker.field_147676_d = 12000; } - } + } private boolean play() { List list = npc.worldObj.getEntitiesWithinAABB(EntityPlayer.class, npc.boundingBox.expand(minRange, minRange, minRange)); - if(!list.contains(CustomNpcs.proxy.getPlayer())) + if (!list.contains(CustomNpcs.proxy.getPlayer())) return false; - if(isStreamer) + if (isStreamer) MusicController.Instance.playMusicJukebox(song, npc, hasOffRange ? maxRange : 0); else MusicController.Instance.playMusicBackground(song, npc, hasOffRange ? maxRange : 0); return true; } - @Override - public void killed() { - delete(); - } + @Override + public void killed() { + delete(); + } - @Override - public void delete() { - if(npc.worldObj.isRemote && hasOffRange){ - if(MusicController.Instance.isPlaying(song)){ - MusicController.Instance.stopAllSounds(); - } - } - } + @Override + public void delete() { + if (npc.worldObj.isRemote && hasOffRange) { + if (MusicController.Instance.isPlaying(song)) { + MusicController.Instance.stopAllSounds(); + } + } + } } diff --git a/src/main/java/noppes/npcs/roles/JobChunkLoader.java b/src/main/java/noppes/npcs/roles/JobChunkLoader.java index 6517693de..a70351bde 100644 --- a/src/main/java/noppes/npcs/roles/JobChunkLoader.java +++ b/src/main/java/noppes/npcs/roles/JobChunkLoader.java @@ -12,77 +12,77 @@ import noppes.npcs.entity.EntityNPCInterface; import java.util.ArrayList; import java.util.List; -public class JobChunkLoader extends JobInterface{ - - private List chunks = new ArrayList(); - private int ticks = 20; - private long playerLastSeen = 0; +public class JobChunkLoader extends JobInterface { - public JobChunkLoader(EntityNPCInterface npc) { - super(npc); - } + private List chunks = new ArrayList(); + private int ticks = 20; + private long playerLastSeen = 0; - @Override - public NBTTagCompound writeToNBT(NBTTagCompound compound) { - compound.setLong("ChunkPlayerLastSeen", playerLastSeen); - return compound; - } + public JobChunkLoader(EntityNPCInterface npc) { + super(npc); + } - @Override - public void readFromNBT(NBTTagCompound compound) { - playerLastSeen = compound.getLong("ChunkPlayerLastSeen"); - } + @Override + public NBTTagCompound writeToNBT(NBTTagCompound compound) { + compound.setLong("ChunkPlayerLastSeen", playerLastSeen); + return compound; + } - @Override - public boolean aiShouldExecute() { - ticks--; - if(ticks > 0) - return false; - ticks = 20; - - List players = npc.worldObj.getEntitiesWithinAABB(EntityPlayer.class, npc.boundingBox.expand(48, 48, 48)); - if(!players.isEmpty()) - playerLastSeen = System.currentTimeMillis(); - - //unload after 10 min - if(System.currentTimeMillis() > playerLastSeen + 600000){ - ChunkController.Instance.deleteNPC(npc); - chunks.clear(); - return false; - } - Ticket ticket = ChunkController.Instance.getTicket(npc); - if(ticket == null) //Only null when too many active chunkloaders already - return false; - double x = npc.posX / 16; - double z = npc.posZ / 16; - - List list = new ArrayList(); - list.add(new ChunkCoordIntPair(MathHelper.floor_double(x), MathHelper.floor_double(z))); - list.add(new ChunkCoordIntPair(MathHelper.ceiling_double_int(x), MathHelper.ceiling_double_int(z))); - list.add(new ChunkCoordIntPair(MathHelper.floor_double(x), MathHelper.ceiling_double_int(z))); - list.add(new ChunkCoordIntPair(MathHelper.ceiling_double_int(x), MathHelper.floor_double(z))); + @Override + public void readFromNBT(NBTTagCompound compound) { + playerLastSeen = compound.getLong("ChunkPlayerLastSeen"); + } - for(ChunkCoordIntPair chunk : list){ - if(!chunks.contains(chunk)){ - ForgeChunkManager.forceChunk(ticket, chunk); - } - else - chunks.remove(chunk); - } - - for(ChunkCoordIntPair chunk : chunks) - ForgeChunkManager.unforceChunk(ticket, chunk); - - this.chunks = list; - return false; - } + @Override + public boolean aiShouldExecute() { + ticks--; + if (ticks > 0) + return false; + ticks = 20; - @Override - public void reset() { - ChunkController.Instance.deleteNPC(npc); - chunks.clear(); - playerLastSeen = 0; - } - public void delete() { - } + List players = npc.worldObj.getEntitiesWithinAABB(EntityPlayer.class, npc.boundingBox.expand(48, 48, 48)); + if (!players.isEmpty()) + playerLastSeen = System.currentTimeMillis(); + + //unload after 10 min + if (System.currentTimeMillis() > playerLastSeen + 600000) { + ChunkController.Instance.deleteNPC(npc); + chunks.clear(); + return false; + } + Ticket ticket = ChunkController.Instance.getTicket(npc); + if (ticket == null) //Only null when too many active chunkloaders already + return false; + double x = npc.posX / 16; + double z = npc.posZ / 16; + + List list = new ArrayList(); + list.add(new ChunkCoordIntPair(MathHelper.floor_double(x), MathHelper.floor_double(z))); + list.add(new ChunkCoordIntPair(MathHelper.ceiling_double_int(x), MathHelper.ceiling_double_int(z))); + list.add(new ChunkCoordIntPair(MathHelper.floor_double(x), MathHelper.ceiling_double_int(z))); + list.add(new ChunkCoordIntPair(MathHelper.ceiling_double_int(x), MathHelper.floor_double(z))); + + for (ChunkCoordIntPair chunk : list) { + if (!chunks.contains(chunk)) { + ForgeChunkManager.forceChunk(ticket, chunk); + } else + chunks.remove(chunk); + } + + for (ChunkCoordIntPair chunk : chunks) + ForgeChunkManager.unforceChunk(ticket, chunk); + + this.chunks = list; + return false; + } + + @Override + public void reset() { + ChunkController.Instance.deleteNPC(npc); + chunks.clear(); + playerLastSeen = 0; + } + + public void delete() { + } } diff --git a/src/main/java/noppes/npcs/roles/JobConversation.java b/src/main/java/noppes/npcs/roles/JobConversation.java index 81e864134..6ba55f958 100644 --- a/src/main/java/noppes/npcs/roles/JobConversation.java +++ b/src/main/java/noppes/npcs/roles/JobConversation.java @@ -15,230 +15,235 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; -public class JobConversation extends JobInterface{ - public Availability availability = new Availability(); +public class JobConversation extends JobInterface { + public Availability availability = new Availability(); - private ArrayList names = new ArrayList(); - private HashMap npcs = new HashMap(); - - public HashMap lines = new HashMap(); + private ArrayList names = new ArrayList(); + private HashMap npcs = new HashMap(); - public int quest = -1; - public String questTitle = ""; - public int generalDelay = 400; - public int ticks = 100; - public int range = 20; - - private ConversationLine nextLine; - - private boolean hasStarted = false; - private int startedTicks = 20; - public int mode = 0; //0:Always, 1:Player near + public HashMap lines = new HashMap(); - public JobConversation(EntityNPCInterface npc) { - super(npc); - } + public int quest = -1; + public String questTitle = ""; + public int generalDelay = 400; + public int ticks = 100; + public int range = 20; - @Override - public NBTTagCompound writeToNBT(NBTTagCompound compound) { - compound.setTag("ConversationAvailability", availability.writeToNBT(new NBTTagCompound())); - compound.setInteger("ConversationQuest", quest); - compound.setInteger("ConversationDelay", generalDelay); - compound.setInteger("ConversationRange", range); - compound.setInteger("ConversationMode", mode); + private ConversationLine nextLine; + + private boolean hasStarted = false; + private int startedTicks = 20; + public int mode = 0; //0:Always, 1:Player near + + public JobConversation(EntityNPCInterface npc) { + super(npc); + } + + @Override + public NBTTagCompound writeToNBT(NBTTagCompound compound) { + compound.setTag("ConversationAvailability", availability.writeToNBT(new NBTTagCompound())); + compound.setInteger("ConversationQuest", quest); + compound.setInteger("ConversationDelay", generalDelay); + compound.setInteger("ConversationRange", range); + compound.setInteger("ConversationMode", mode); NBTTagList nbttaglist = new NBTTagList(); - for(int slot : lines.keySet()){ - ConversationLine line = lines.get(slot); + for (int slot : lines.keySet()) { + ConversationLine line = lines.get(slot); NBTTagCompound nbttagcompound = new NBTTagCompound(); nbttagcompound.setInteger("Slot", slot); line.writeEntityToNBT(nbttagcompound); - + nbttaglist.appendTag(nbttagcompound); } - - compound.setTag("ConversationLines", nbttaglist); - if(hasQuest()) - compound.setString("ConversationQuestTitle", getQuest().title); - - return compound; - } - @Override - public void readFromNBT(NBTTagCompound compound) { - names.clear(); - availability.readFromNBT(compound.getCompoundTag("ConversationAvailability")); - quest = compound.getInteger("ConversationQuest"); - generalDelay = compound.getInteger("ConversationDelay"); - questTitle = compound.getString("ConversationQuestTitle"); - range = compound.getInteger("ConversationRange"); - mode = compound.getInteger("ConversationMode"); + compound.setTag("ConversationLines", nbttaglist); + if (hasQuest()) + compound.setString("ConversationQuestTitle", getQuest().title); - NBTTagList nbttaglist = compound.getTagList("ConversationLines", 10); - HashMap map = new HashMap(); - for(int i = 0; i < nbttaglist.tagCount(); i++){ + return compound; + } + + @Override + public void readFromNBT(NBTTagCompound compound) { + names.clear(); + availability.readFromNBT(compound.getCompoundTag("ConversationAvailability")); + quest = compound.getInteger("ConversationQuest"); + generalDelay = compound.getInteger("ConversationDelay"); + questTitle = compound.getString("ConversationQuestTitle"); + range = compound.getInteger("ConversationRange"); + mode = compound.getInteger("ConversationMode"); + + NBTTagList nbttaglist = compound.getTagList("ConversationLines", 10); + HashMap map = new HashMap(); + for (int i = 0; i < nbttaglist.tagCount(); i++) { NBTTagCompound nbttagcompound = nbttaglist.getCompoundTagAt(i); ConversationLine line = new ConversationLine(); line.readEntityFromNBT(nbttagcompound); - if(!line.npc.isEmpty() && !names.contains(line.npc.toLowerCase())) - names.add(line.npc.toLowerCase()); - + if (!line.npc.isEmpty() && !names.contains(line.npc.toLowerCase())) + names.add(line.npc.toLowerCase()); + map.put(nbttagcompound.getInteger("Slot"), line); } lines = map; ticks = generalDelay; - } + } - public boolean hasQuest() { - return getQuest() != null; - } - public Quest getQuest() { - if(npc.isRemote()) - return null; - return QuestController.Instance.quests.get(quest); - } - @Override - public void aiUpdateTask() { - ticks--; - if(ticks > 0 || nextLine == null) - return; - say(nextLine); - boolean seenNext = false; - ConversationLine compare = nextLine; - nextLine = null; - for(ConversationLine line : lines.values()){ - if(line.isEmpty()) - continue; - if(seenNext){ - nextLine = line; - break; - } - if(line == compare){ - seenNext = true; - } - } - if(nextLine != null) - ticks = nextLine.delay; - else if(hasQuest()){ - List inRange = npc.worldObj.getEntitiesWithinAABB(EntityPlayer.class, npc.boundingBox.expand(range, range, range)); + public boolean hasQuest() { + return getQuest() != null; + } - for (EntityPlayer player : inRange){ - if(availability.isAvailable(player)) - PlayerQuestController.addActiveQuest(new QuestData(getQuest()), player); - } - } - } - + public Quest getQuest() { + if (npc.isRemote()) + return null; + return QuestController.Instance.quests.get(quest); + } - @Override - public boolean aiShouldExecute() { - if(lines.isEmpty() || npc.isKilled() || npc.isAttacking() || !shouldRun()) - return false; - if(!hasStarted && mode == 1){ - if(startedTicks-- > 0) - return false; - startedTicks = 10; - if(npc.worldObj.getEntitiesWithinAABB(EntityPlayer.class, npc.boundingBox.expand(range, range, range)).isEmpty()){ - return false; - } - } - - for(ConversationLine line : lines.values()){ - if(line == null || line.isEmpty()) - continue; - nextLine = line; - break; - } - return nextLine != null; - } + @Override + public void aiUpdateTask() { + ticks--; + if (ticks > 0 || nextLine == null) + return; + say(nextLine); + boolean seenNext = false; + ConversationLine compare = nextLine; + nextLine = null; + for (ConversationLine line : lines.values()) { + if (line.isEmpty()) + continue; + if (seenNext) { + nextLine = line; + break; + } + if (line == compare) { + seenNext = true; + } + } + if (nextLine != null) + ticks = nextLine.delay; + else if (hasQuest()) { + List inRange = npc.worldObj.getEntitiesWithinAABB(EntityPlayer.class, npc.boundingBox.expand(range, range, range)); - private boolean shouldRun() { - ticks--; - if(ticks > 0) - return false; - npcs.clear(); - List list = npc.worldObj.getEntitiesWithinAABB(EntityNPCInterface.class, npc.boundingBox.expand(10, 10, 10)); - for(EntityNPCInterface npc : list){ - if(!npc.isKilled() && !npc.isAttacking() && names.contains(npc.getCommandSenderName().toLowerCase())) - npcs.put(npc.getCommandSenderName().toLowerCase(), npc); - } - boolean bo = names.size() == npcs.size(); - if(!bo) - ticks = 20; - return bo; - } + for (EntityPlayer player : inRange) { + if (availability.isAvailable(player)) + PlayerQuestController.addActiveQuest(new QuestData(getQuest()), player); + } + } + } - @Override - public boolean aiContinueExecute() { - for(EntityNPCInterface npc : npcs.values()){ - if(npc.isKilled() || npc.isAttacking()) - return false; - } - return nextLine != null; - } - @Override - public void resetTask() { - nextLine = null; - ticks = generalDelay; - hasStarted = false; - } + @Override + public boolean aiShouldExecute() { + if (lines.isEmpty() || npc.isKilled() || npc.isAttacking() || !shouldRun()) + return false; + if (!hasStarted && mode == 1) { + if (startedTicks-- > 0) + return false; + startedTicks = 10; + if (npc.worldObj.getEntitiesWithinAABB(EntityPlayer.class, npc.boundingBox.expand(range, range, range)).isEmpty()) { + return false; + } + } - @Override - public void aiStartExecuting() { - startedTicks = 20; - hasStarted = true; - } - - private void say(ConversationLine line) { - List inRange = npc.worldObj.getEntitiesWithinAABB(EntityPlayer.class, npc.boundingBox.expand(range, range, range)); + for (ConversationLine line : lines.values()) { + if (line == null || line.isEmpty()) + continue; + nextLine = line; + break; + } + return nextLine != null; + } - EntityNPCInterface npc = npcs.get(line.npc.toLowerCase()); - if(npc == null) - return; - for (EntityPlayer player : inRange){ - if(availability.isAvailable(player)) - npc.say(player, line); - } - } + private boolean shouldRun() { + ticks--; + if (ticks > 0) + return false; + npcs.clear(); + List list = npc.worldObj.getEntitiesWithinAABB(EntityNPCInterface.class, npc.boundingBox.expand(10, 10, 10)); + for (EntityNPCInterface npc : list) { + if (!npc.isKilled() && !npc.isAttacking() && names.contains(npc.getCommandSenderName().toLowerCase())) + npcs.put(npc.getCommandSenderName().toLowerCase(), npc); + } + boolean bo = names.size() == npcs.size(); + if (!bo) + ticks = 20; + return bo; + } - @Override - public void reset() { - hasStarted = false; - resetTask(); - ticks = 60; - } - @Override - public void killed() { - reset(); - } - public class ConversationLine extends Line{ - public String npc = ""; - public int delay = 40; - - public void writeEntityToNBT(NBTTagCompound compound) { - compound.setString("Line", text); - compound.setString("Npc", npc); - compound.setString("Sound", sound); - compound.setInteger("Delay", delay); - } + @Override + public boolean aiContinueExecute() { + for (EntityNPCInterface npc : npcs.values()) { + if (npc.isKilled() || npc.isAttacking()) + return false; + } + return nextLine != null; + } - public void readEntityFromNBT(NBTTagCompound compound) { - text = compound.getString("Line"); - npc = compound.getString("Npc"); - sound = compound.getString("Sound"); - delay = compound.getInteger("Delay"); - } - - public boolean isEmpty(){ - return npc.isEmpty() || text.isEmpty(); - } - } - public ConversationLine getLine(int slot) { - if(lines.containsKey(slot)) - return lines.get(slot); - ConversationLine line = new ConversationLine(); - lines.put(slot, line); - return line; - } + @Override + public void resetTask() { + nextLine = null; + ticks = generalDelay; + hasStarted = false; + } + + @Override + public void aiStartExecuting() { + startedTicks = 20; + hasStarted = true; + } + + private void say(ConversationLine line) { + List inRange = npc.worldObj.getEntitiesWithinAABB(EntityPlayer.class, npc.boundingBox.expand(range, range, range)); + + EntityNPCInterface npc = npcs.get(line.npc.toLowerCase()); + if (npc == null) + return; + for (EntityPlayer player : inRange) { + if (availability.isAvailable(player)) + npc.say(player, line); + } + } + + @Override + public void reset() { + hasStarted = false; + resetTask(); + ticks = 60; + } + + @Override + public void killed() { + reset(); + } + + public class ConversationLine extends Line { + public String npc = ""; + public int delay = 40; + + public void writeEntityToNBT(NBTTagCompound compound) { + compound.setString("Line", text); + compound.setString("Npc", npc); + compound.setString("Sound", sound); + compound.setInteger("Delay", delay); + } + + public void readEntityFromNBT(NBTTagCompound compound) { + text = compound.getString("Line"); + npc = compound.getString("Npc"); + sound = compound.getString("Sound"); + delay = compound.getInteger("Delay"); + } + + public boolean isEmpty() { + return npc.isEmpty() || text.isEmpty(); + } + } + + public ConversationLine getLine(int slot) { + if (lines.containsKey(slot)) + return lines.get(slot); + ConversationLine line = new ConversationLine(); + lines.put(slot, line); + return line; + } } diff --git a/src/main/java/noppes/npcs/roles/JobFollower.java b/src/main/java/noppes/npcs/roles/JobFollower.java index 979c0f845..9d80c9dc0 100644 --- a/src/main/java/noppes/npcs/roles/JobFollower.java +++ b/src/main/java/noppes/npcs/roles/JobFollower.java @@ -6,68 +6,70 @@ import noppes.npcs.entity.EntityNPCInterface; import java.util.List; -public class JobFollower extends JobInterface{ - public EntityNPCInterface following = null; - private int ticks = 40; - private int range = 20; - public String name = ""; +public class JobFollower extends JobInterface { + public EntityNPCInterface following = null; + private int ticks = 40; + private int range = 20; + public String name = ""; - public JobFollower(EntityNPCInterface npc) { - super(npc); - } + public JobFollower(EntityNPCInterface npc) { + super(npc); + } - @Override - public NBTTagCompound writeToNBT(NBTTagCompound compound) { - compound.setString("FollowingEntityName", name); - return compound; - } + @Override + public NBTTagCompound writeToNBT(NBTTagCompound compound) { + compound.setString("FollowingEntityName", name); + return compound; + } - @Override - public void readFromNBT(NBTTagCompound compound) { - name = compound.getString("FollowingEntityName"); - - } - @Override - public boolean aiShouldExecute() { - if(npc.isAttacking()) - return false; - - ticks--; - if(ticks > 0) - return false; - - ticks = 10; - following = null; - List list = npc.worldObj.getEntitiesWithinAABB(EntityNPCInterface.class, npc.boundingBox.expand(getRange(), getRange(), getRange())); - for(EntityNPCInterface entity : list){ - if(entity == npc || entity.isKilled()) - continue; - if(entity.display.name.equalsIgnoreCase(name)){ - following = entity; - break; - } - } - - return false; - } - - private int getRange(){ - if(range > ConfigMain.NpcNavRange) - return ConfigMain.NpcNavRange; - return range; - } - - public boolean isFollowing(){ - return following != null; - } + @Override + public void readFromNBT(NBTTagCompound compound) { + name = compound.getString("FollowingEntityName"); - public void reset() { - } - public void resetTask() { - following = null; - } + } - public boolean hasOwner() { - return !name.isEmpty(); - } + @Override + public boolean aiShouldExecute() { + if (npc.isAttacking()) + return false; + + ticks--; + if (ticks > 0) + return false; + + ticks = 10; + following = null; + List list = npc.worldObj.getEntitiesWithinAABB(EntityNPCInterface.class, npc.boundingBox.expand(getRange(), getRange(), getRange())); + for (EntityNPCInterface entity : list) { + if (entity == npc || entity.isKilled()) + continue; + if (entity.display.name.equalsIgnoreCase(name)) { + following = entity; + break; + } + } + + return false; + } + + private int getRange() { + if (range > ConfigMain.NpcNavRange) + return ConfigMain.NpcNavRange; + return range; + } + + public boolean isFollowing() { + return following != null; + } + + public void reset() { + } + + public void resetTask() { + following = null; + } + + public boolean hasOwner() { + return !name.isEmpty(); + } } diff --git a/src/main/java/noppes/npcs/roles/JobGuard.java b/src/main/java/noppes/npcs/roles/JobGuard.java index 7a137e184..20adbe62e 100644 --- a/src/main/java/noppes/npcs/roles/JobGuard.java +++ b/src/main/java/noppes/npcs/roles/JobGuard.java @@ -15,57 +15,55 @@ import noppes.npcs.entity.EntityNPCInterface; import java.util.ArrayList; import java.util.List; -public class JobGuard extends JobInterface{ +public class JobGuard extends JobInterface { - public boolean attacksAnimals = false; - public boolean attackHostileMobs = true; - public boolean attackCreepers = false; - - public List targets = new ArrayList(); - public boolean specific = false; - - public JobGuard(EntityNPCInterface npc) { - super(npc); - } + public boolean attacksAnimals = false; + public boolean attackHostileMobs = true; + public boolean attackCreepers = false; - @Override - public NBTTagCompound writeToNBT(NBTTagCompound nbttagcompound) { - nbttagcompound.setBoolean("GuardAttackAnimals", attacksAnimals); - nbttagcompound.setBoolean("GuardAttackMobs", attackHostileMobs); - nbttagcompound.setBoolean("GuardAttackCreepers", attackCreepers); - nbttagcompound.setBoolean("GuardSpecific", specific); - - nbttagcompound.setTag("GuardTargets", NBTTags.nbtStringList(targets)); - return nbttagcompound; - } + public List targets = new ArrayList(); + public boolean specific = false; - @Override - public void readFromNBT(NBTTagCompound nbttagcompound) { - attacksAnimals = nbttagcompound.getBoolean("GuardAttackAnimals"); - attackHostileMobs = nbttagcompound.getBoolean("GuardAttackMobs"); - attackCreepers = nbttagcompound.getBoolean("GuardAttackCreepers"); - specific = nbttagcompound.getBoolean("GuardSpecific"); + public JobGuard(EntityNPCInterface npc) { + super(npc); + } - targets = NBTTags.getStringList(nbttagcompound.getTagList("GuardTargets", 10)); - } - - public boolean isEntityApplicable(Entity entity) { - if(entity instanceof EntityPlayer || entity instanceof EntityNPCInterface) - return false; - if(specific && targets.contains("entity." + EntityList.getEntityString(entity) + ".name")) - return true; - - if(entity instanceof EntityAnimal){ - if(!attacksAnimals || entity instanceof EntityTameable && ((EntityTameable)entity).getOwner() != null) - return false; - return true; - } - else if (entity instanceof EntityCreeper) { - return attackCreepers; - } - else if(entity instanceof IMob || entity instanceof EntityDragon){ - return attackHostileMobs; - } - return false; - } + @Override + public NBTTagCompound writeToNBT(NBTTagCompound nbttagcompound) { + nbttagcompound.setBoolean("GuardAttackAnimals", attacksAnimals); + nbttagcompound.setBoolean("GuardAttackMobs", attackHostileMobs); + nbttagcompound.setBoolean("GuardAttackCreepers", attackCreepers); + nbttagcompound.setBoolean("GuardSpecific", specific); + + nbttagcompound.setTag("GuardTargets", NBTTags.nbtStringList(targets)); + return nbttagcompound; + } + + @Override + public void readFromNBT(NBTTagCompound nbttagcompound) { + attacksAnimals = nbttagcompound.getBoolean("GuardAttackAnimals"); + attackHostileMobs = nbttagcompound.getBoolean("GuardAttackMobs"); + attackCreepers = nbttagcompound.getBoolean("GuardAttackCreepers"); + specific = nbttagcompound.getBoolean("GuardSpecific"); + + targets = NBTTags.getStringList(nbttagcompound.getTagList("GuardTargets", 10)); + } + + public boolean isEntityApplicable(Entity entity) { + if (entity instanceof EntityPlayer || entity instanceof EntityNPCInterface) + return false; + if (specific && targets.contains("entity." + EntityList.getEntityString(entity) + ".name")) + return true; + + if (entity instanceof EntityAnimal) { + if (!attacksAnimals || entity instanceof EntityTameable && ((EntityTameable) entity).getOwner() != null) + return false; + return true; + } else if (entity instanceof EntityCreeper) { + return attackCreepers; + } else if (entity instanceof IMob || entity instanceof EntityDragon) { + return attackHostileMobs; + } + return false; + } } diff --git a/src/main/java/noppes/npcs/roles/JobHealer.java b/src/main/java/noppes/npcs/roles/JobHealer.java index f12036e1c..576761f86 100644 --- a/src/main/java/noppes/npcs/roles/JobHealer.java +++ b/src/main/java/noppes/npcs/roles/JobHealer.java @@ -9,64 +9,65 @@ import noppes.npcs.entity.EntityNPCInterface; import java.util.ArrayList; import java.util.List; -public class JobHealer extends JobInterface{ - private long healTicks = 0; - public int range = 5; - public int speed = 5; +public class JobHealer extends JobInterface { + private long healTicks = 0; + public int range = 5; + public int speed = 5; - public JobHealer(EntityNPCInterface npc) { - super(npc); - } + public JobHealer(EntityNPCInterface npc) { + super(npc); + } - @Override - public NBTTagCompound writeToNBT(NBTTagCompound nbttagcompound) { - nbttagcompound.setInteger("HealerRange", range); - nbttagcompound.setInteger("HealerSpeed", speed); - return nbttagcompound; - } + @Override + public NBTTagCompound writeToNBT(NBTTagCompound nbttagcompound) { + nbttagcompound.setInteger("HealerRange", range); + nbttagcompound.setInteger("HealerSpeed", speed); + return nbttagcompound; + } - @Override - public void readFromNBT(NBTTagCompound nbttagcompound) { - range = nbttagcompound.getInteger("HealerRange"); - speed = nbttagcompound.getInteger("HealerSpeed"); - } - private List toHeal = new ArrayList(); - - public boolean aiShouldExecute() { - healTicks++; - if (healTicks < speed * 10) - return false; + @Override + public void readFromNBT(NBTTagCompound nbttagcompound) { + range = nbttagcompound.getInteger("HealerRange"); + speed = nbttagcompound.getInteger("HealerSpeed"); + } - for(Object plObj: npc.worldObj.getEntitiesWithinAABB(EntityLivingBase.class, npc.boundingBox.expand(range, range/2.0, range))){ - EntityLivingBase entity = (EntityLivingBase) plObj; + private List toHeal = new ArrayList(); - if(entity instanceof EntityPlayer){ - EntityPlayer player = (EntityPlayer) entity; - if(player.getHealth() < player.getMaxHealth() && !npc.faction.isAggressiveToPlayer(player)) - toHeal.add(player); - } - if(entity instanceof EntityNPCInterface){ - EntityNPCInterface npc = (EntityNPCInterface) entity; - if(npc.getHealth() < npc.getMaxHealth() && !this.npc.faction.isAggressiveToNpc(npc)) - toHeal.add(npc); - } + public boolean aiShouldExecute() { + healTicks++; + if (healTicks < speed * 10) + return false; - } + for (Object plObj : npc.worldObj.getEntitiesWithinAABB(EntityLivingBase.class, npc.boundingBox.expand(range, range / 2.0, range))) { + EntityLivingBase entity = (EntityLivingBase) plObj; - healTicks = 0; - return !toHeal.isEmpty(); - } + if (entity instanceof EntityPlayer) { + EntityPlayer player = (EntityPlayer) entity; + if (player.getHealth() < player.getMaxHealth() && !npc.faction.isAggressiveToPlayer(player)) + toHeal.add(player); + } + if (entity instanceof EntityNPCInterface) { + EntityNPCInterface npc = (EntityNPCInterface) entity; + if (npc.getHealth() < npc.getMaxHealth() && !this.npc.faction.isAggressiveToNpc(npc)) + toHeal.add(npc); + } - public void aiStartExecuting() { - for(EntityLivingBase entity : toHeal){ - float heal = entity.getMaxHealth() / 20; //heal 5% of max health - heal(entity, heal > 0?heal:1); - } - toHeal.clear(); - } + } - public void heal(EntityLivingBase entity, float amount){ - entity.heal(amount); - NoppesUtilServer.spawnParticle(entity, "heal",entity.dimension); - } + healTicks = 0; + return !toHeal.isEmpty(); + } + + public void aiStartExecuting() { + for (EntityLivingBase entity : toHeal) { + float heal = entity.getMaxHealth() / 20; //heal 5% of max health + heal(entity, heal > 0 ? heal : 1); + } + toHeal.clear(); + } + + public void heal(EntityLivingBase entity, float amount) { + entity.heal(amount); + NoppesUtilServer.spawnParticle(entity, "heal", entity.dimension); + } } diff --git a/src/main/java/noppes/npcs/roles/JobInterface.java b/src/main/java/noppes/npcs/roles/JobInterface.java index 72949fa90..34cd0c70d 100644 --- a/src/main/java/noppes/npcs/roles/JobInterface.java +++ b/src/main/java/noppes/npcs/roles/JobInterface.java @@ -5,33 +5,51 @@ import net.minecraft.nbt.NBTTagCompound; import noppes.npcs.entity.EntityNPCInterface; public abstract class JobInterface { - public EntityNPCInterface npc; - - public boolean overrideMainHand = false; - public boolean overrideOffHand = false; + public EntityNPCInterface npc; + + public boolean overrideMainHand = false; + public boolean overrideOffHand = false; + + public ItemStack mainhand = null; + public ItemStack offhand = null; + + public JobInterface(EntityNPCInterface npc) { + this.npc = npc; + } + + public abstract NBTTagCompound writeToNBT(NBTTagCompound nbttagcompound); + + public abstract void readFromNBT(NBTTagCompound nbttagcompound); + + public void killed() { + } + + ; + + public void delete() { + } + + ; + + public boolean aiShouldExecute() { + return false; + } + + public boolean aiContinueExecute() { + return aiShouldExecute(); + } + + public void aiStartExecuting() { + } + + public void aiUpdateTask() { + } + + public void reset() { + } + + public void resetTask() { + } + - public ItemStack mainhand = null; - public ItemStack offhand = null; - - public JobInterface(EntityNPCInterface npc){ - this.npc = npc; - } - public abstract NBTTagCompound writeToNBT(NBTTagCompound nbttagcompound); - public abstract void readFromNBT(NBTTagCompound nbttagcompound); - public void killed(){}; - public void delete(){}; - - public boolean aiShouldExecute() { - return false; - } - - public boolean aiContinueExecute() { - return aiShouldExecute(); - } - public void aiStartExecuting() {} - public void aiUpdateTask() {} - public void reset() {} - public void resetTask() {} - - } diff --git a/src/main/java/noppes/npcs/roles/JobItemGiver.java b/src/main/java/noppes/npcs/roles/JobItemGiver.java index 8a72ff2aa..b899e6570 100644 --- a/src/main/java/noppes/npcs/roles/JobItemGiver.java +++ b/src/main/java/noppes/npcs/roles/JobItemGiver.java @@ -19,268 +19,273 @@ import java.util.HashMap; import java.util.List; import java.util.Vector; -public class JobItemGiver extends JobInterface{ +public class JobItemGiver extends JobInterface { - public int cooldownType = 0; - public int givingMethod = 0; - public int cooldown = 10; - public NpcMiscInventory inventory; - public int itemGiverId = 0; + public int cooldownType = 0; + public int givingMethod = 0; + public int cooldown = 10; + public NpcMiscInventory inventory; + public int itemGiverId = 0; - public List lines = new ArrayList(); + public List lines = new ArrayList(); - private int ticks = 10; + private int ticks = 10; - private List recentlyChecked = new ArrayList(); - private List toCheck; - public Availability availability = new Availability(); + private List recentlyChecked = new ArrayList(); + private List toCheck; + public Availability availability = new Availability(); - public JobItemGiver() { - super(null); - inventory = new NpcMiscInventory(9); - } + public JobItemGiver() { + super(null); + inventory = new NpcMiscInventory(9); + } - public JobItemGiver(EntityNPCInterface npc) { - super(npc); - inventory = new NpcMiscInventory(9); - lines.add("Have these items {player}"); - } + public JobItemGiver(EntityNPCInterface npc) { + super(npc); + inventory = new NpcMiscInventory(9); + lines.add("Have these items {player}"); + } - @Override - public NBTTagCompound writeToNBT(NBTTagCompound nbttagcompound) { - nbttagcompound.setInteger("igCooldownType", cooldownType); - nbttagcompound.setInteger("igGivingMethod", givingMethod); - nbttagcompound.setInteger("igCooldown", cooldown); - nbttagcompound.setInteger("ItemGiverId", itemGiverId); - nbttagcompound.setTag("igLines", NBTTags.nbtStringList(lines)); - nbttagcompound.setTag("igJobInventory", inventory.getToNBT()); - nbttagcompound.setTag("igAvailability", availability.writeToNBT(new NBTTagCompound())); - return nbttagcompound; - } + @Override + public NBTTagCompound writeToNBT(NBTTagCompound nbttagcompound) { + nbttagcompound.setInteger("igCooldownType", cooldownType); + nbttagcompound.setInteger("igGivingMethod", givingMethod); + nbttagcompound.setInteger("igCooldown", cooldown); + nbttagcompound.setInteger("ItemGiverId", itemGiverId); + nbttagcompound.setTag("igLines", NBTTags.nbtStringList(lines)); + nbttagcompound.setTag("igJobInventory", inventory.getToNBT()); + nbttagcompound.setTag("igAvailability", availability.writeToNBT(new NBTTagCompound())); + return nbttagcompound; + } - @Override - public void readFromNBT(NBTTagCompound nbttagcompound) { - itemGiverId = nbttagcompound.getInteger("ItemGiverId"); - cooldownType = nbttagcompound.getInteger("igCooldownType"); - givingMethod = nbttagcompound.getInteger("igGivingMethod"); - cooldown = nbttagcompound.getInteger("igCooldown"); - lines = NBTTags.getStringList(nbttagcompound.getTagList("igLines", 10)); - inventory.setFromNBT(nbttagcompound.getCompoundTag("igJobInventory")); + @Override + public void readFromNBT(NBTTagCompound nbttagcompound) { + itemGiverId = nbttagcompound.getInteger("ItemGiverId"); + cooldownType = nbttagcompound.getInteger("igCooldownType"); + givingMethod = nbttagcompound.getInteger("igGivingMethod"); + cooldown = nbttagcompound.getInteger("igCooldown"); + lines = NBTTags.getStringList(nbttagcompound.getTagList("igLines", 10)); + inventory.setFromNBT(nbttagcompound.getCompoundTag("igJobInventory")); - if(itemGiverId == 0 && GlobalDataController.Instance != null) + if (itemGiverId == 0 && GlobalDataController.Instance != null) itemGiverId = GlobalDataController.Instance.incrementItemGiverId(); - availability.readFromNBT(nbttagcompound.getCompoundTag("igAvailability")); - } + availability.readFromNBT(nbttagcompound.getCompoundTag("igAvailability")); + } - public NBTTagList newHashMapNBTList(HashMap lines) { - NBTTagList nbttaglist = new NBTTagList(); - HashMap lines2 = lines; - for (String s : lines2.keySet()) { - NBTTagCompound nbttagcompound = new NBTTagCompound(); - nbttagcompound.setString("Line", s); - nbttagcompound.setLong("Time", lines.get(s)); - nbttaglist.appendTag(nbttagcompound); - } - return nbttaglist; - } + public NBTTagList newHashMapNBTList(HashMap lines) { + NBTTagList nbttaglist = new NBTTagList(); + HashMap lines2 = lines; + for (String s : lines2.keySet()) { + NBTTagCompound nbttagcompound = new NBTTagCompound(); + nbttagcompound.setString("Line", s); + nbttagcompound.setLong("Time", lines.get(s)); + nbttaglist.appendTag(nbttagcompound); + } + return nbttaglist; + } - public HashMap getNBTLines(NBTTagList tagList) { - HashMap map = new HashMap(); - for (int i = 0; i < tagList.tagCount(); i++) { - NBTTagCompound nbttagcompound = tagList.getCompoundTagAt(i); - String line = nbttagcompound.getString("Line"); - long time = nbttagcompound.getLong("Time"); - map.put(line, time); + public HashMap getNBTLines(NBTTagList tagList) { + HashMap map = new HashMap(); + for (int i = 0; i < tagList.tagCount(); i++) { + NBTTagCompound nbttagcompound = tagList.getCompoundTagAt(i); + String line = nbttagcompound.getString("Line"); + long time = nbttagcompound.getLong("Time"); + map.put(line, time); - } - return map; - } + } + return map; + } - public boolean giveItems(EntityPlayer player){ - PlayerItemGiverData data = PlayerDataController.Instance.getPlayerData(player).itemgiverData; - if(!canPlayerInteract(data)){ - return false; - } + public boolean giveItems(EntityPlayer player) { + PlayerItemGiverData data = PlayerDataController.Instance.getPlayerData(player).itemgiverData; + if (!canPlayerInteract(data)) { + return false; + } - Vector items = new Vector(); - Vector toGive = new Vector(); + Vector items = new Vector(); + Vector toGive = new Vector(); - for(ItemStack is : inventory.items.values()) - if(is != null) - items.add(is.copy()); - if(items.isEmpty()) - return false; - if(isAllGiver()){ - toGive = items; - } - else if(isRemainingGiver()){ - for(ItemStack is : items){ - if(!playerHasItem(player,is.getItem())) - toGive.add(is); - } - } - else if(isRandomGiver()){ - toGive.add(items.get(npc.worldObj.rand.nextInt(items.size())).copy()); - } - else if(isGiverWhenNotOwnedAny()){ - boolean ownsItems = false; - for(ItemStack is : items){ - if(playerHasItem(player,is.getItem())){ - ownsItems = true; - break; - } - } - if(!ownsItems){ - toGive = items; - } - else - return false; - } - else if(isChainedGiver()){ - int itemIndex = data.getItemIndex(this); - int i = 0; - for(ItemStack item : inventory.items.values()){ - if(i == itemIndex){ - toGive.add(item); - break; - } - i++; - } - } - if(toGive.isEmpty()) - return false; - if(givePlayerItems(player,toGive)){ - if(!lines.isEmpty()){ - npc.say(player, new Line(lines.get(npc.getRNG().nextInt(lines.size())))); - } - if(isDaily()) - data.setTime(this,getDay()); - else - data.setTime(this,System.currentTimeMillis()); - if(isChainedGiver()) - data.setItemIndex(this, (data.getItemIndex(this) + 1) % inventory.items.size()); - return true; - } - return false; - } - private int getDay(){ - return (int) (npc.worldObj.getTotalWorldTime() / 24000L); - } - public boolean canPlayerInteract(PlayerItemGiverData data) { - if(inventory.items.isEmpty()) - return false; - if(isOnTimer()){ - if(!data.hasInteractedBefore(this)) - return true; - return data.getTime(this) + (cooldown*1000) < System.currentTimeMillis(); - } - else if(isGiveOnce()){ - return !data.hasInteractedBefore(this); - } - else if(isDaily()){ - if(!data.hasInteractedBefore(this)) - return true; - return getDay() > data.getTime(this); - } - return false; - } + for (ItemStack is : inventory.items.values()) + if (is != null) + items.add(is.copy()); + if (items.isEmpty()) + return false; + if (isAllGiver()) { + toGive = items; + } else if (isRemainingGiver()) { + for (ItemStack is : items) { + if (!playerHasItem(player, is.getItem())) + toGive.add(is); + } + } else if (isRandomGiver()) { + toGive.add(items.get(npc.worldObj.rand.nextInt(items.size())).copy()); + } else if (isGiverWhenNotOwnedAny()) { + boolean ownsItems = false; + for (ItemStack is : items) { + if (playerHasItem(player, is.getItem())) { + ownsItems = true; + break; + } + } + if (!ownsItems) { + toGive = items; + } else + return false; + } else if (isChainedGiver()) { + int itemIndex = data.getItemIndex(this); + int i = 0; + for (ItemStack item : inventory.items.values()) { + if (i == itemIndex) { + toGive.add(item); + break; + } + i++; + } + } + if (toGive.isEmpty()) + return false; + if (givePlayerItems(player, toGive)) { + if (!lines.isEmpty()) { + npc.say(player, new Line(lines.get(npc.getRNG().nextInt(lines.size())))); + } + if (isDaily()) + data.setTime(this, getDay()); + else + data.setTime(this, System.currentTimeMillis()); + if (isChainedGiver()) + data.setItemIndex(this, (data.getItemIndex(this) + 1) % inventory.items.size()); + return true; + } + return false; + } - private boolean givePlayerItems(EntityPlayer player, - Vector toGive) { - if(toGive.isEmpty()) - return false; - if(freeInventorySlots(player) < toGive.size()) - return false; - for(ItemStack is : toGive){ - npc.givePlayerItem(player, is); - } - return true; - } - private boolean playerHasItem(EntityPlayer player, Item item){ - for(ItemStack is : player.inventory.mainInventory){ - if(is != null && is.getItem() == item) - return true; - } - for(ItemStack is : player.inventory.armorInventory){ - if(is != null && is.getItem() == item) - return true; - } - return false; - } - private int freeInventorySlots(EntityPlayer player){ - int i = 0; - for(ItemStack is : player.inventory.mainInventory) - if(is == null) - i++; - return i; - } - private boolean isRandomGiver(){ - return givingMethod == 0; - } - private boolean isAllGiver(){ - return givingMethod == 1; - } - private boolean isRemainingGiver(){ - return givingMethod == 2; - } - private boolean isGiverWhenNotOwnedAny(){ - return givingMethod == 3; - } - private boolean isChainedGiver(){ - return givingMethod == 4; - } - public boolean isOnTimer(){ - return cooldownType == 0; - } - private boolean isGiveOnce(){ - return cooldownType == 1; - } - private boolean isDaily(){ - return cooldownType == 2; - } + private int getDay() { + return (int) (npc.worldObj.getTotalWorldTime() / 24000L); + } - public boolean aiShouldExecute() { - if(npc.isAttacking()) - return false; - ticks--; - if(ticks > 0) - return false; - ticks = 10; + public boolean canPlayerInteract(PlayerItemGiverData data) { + if (inventory.items.isEmpty()) + return false; + if (isOnTimer()) { + if (!data.hasInteractedBefore(this)) + return true; + return data.getTime(this) + (cooldown * 1000) < System.currentTimeMillis(); + } else if (isGiveOnce()) { + return !data.hasInteractedBefore(this); + } else if (isDaily()) { + if (!data.hasInteractedBefore(this)) + return true; + return getDay() > data.getTime(this); + } + return false; + } - toCheck = npc.worldObj.getEntitiesWithinAABB(EntityPlayer.class, npc.boundingBox.expand(3, 3, 3)); - toCheck.removeAll(recentlyChecked); + private boolean givePlayerItems(EntityPlayer player, + Vector toGive) { + if (toGive.isEmpty()) + return false; + if (freeInventorySlots(player) < toGive.size()) + return false; + for (ItemStack is : toGive) { + npc.givePlayerItem(player, is); + } + return true; + } - List listMax = npc.worldObj.getEntitiesWithinAABB(EntityPlayer.class, npc.boundingBox.expand(10, 10, 10)); - recentlyChecked.retainAll(listMax); - recentlyChecked.addAll(toCheck); - return toCheck.size() > 0; - } + private boolean playerHasItem(EntityPlayer player, Item item) { + for (ItemStack is : player.inventory.mainInventory) { + if (is != null && is.getItem() == item) + return true; + } + for (ItemStack is : player.inventory.armorInventory) { + if (is != null && is.getItem() == item) + return true; + } + return false; + } - public void aiStartExecuting() { - for(EntityPlayer player : toCheck){ - if(npc.canSee(player) && availability.isAvailable(player)){ - recentlyChecked.add(player); - interact(player); - } - } - } + private int freeInventorySlots(EntityPlayer player) { + int i = 0; + for (ItemStack is : player.inventory.mainInventory) + if (is == null) + i++; + return i; + } - @Override - public void killed() { + private boolean isRandomGiver() { + return givingMethod == 0; + } + + private boolean isAllGiver() { + return givingMethod == 1; + } + + private boolean isRemainingGiver() { + return givingMethod == 2; + } + + private boolean isGiverWhenNotOwnedAny() { + return givingMethod == 3; + } + + private boolean isChainedGiver() { + return givingMethod == 4; + } + + public boolean isOnTimer() { + return cooldownType == 0; + } + + private boolean isGiveOnce() { + return cooldownType == 1; + } + + private boolean isDaily() { + return cooldownType == 2; + } + + public boolean aiShouldExecute() { + if (npc.isAttacking()) + return false; + ticks--; + if (ticks > 0) + return false; + ticks = 10; + + toCheck = npc.worldObj.getEntitiesWithinAABB(EntityPlayer.class, npc.boundingBox.expand(3, 3, 3)); + toCheck.removeAll(recentlyChecked); + + List listMax = npc.worldObj.getEntitiesWithinAABB(EntityPlayer.class, npc.boundingBox.expand(10, 10, 10)); + recentlyChecked.retainAll(listMax); + recentlyChecked.addAll(toCheck); + return toCheck.size() > 0; + } + + public void aiStartExecuting() { + for (EntityPlayer player : toCheck) { + if (npc.canSee(player) && availability.isAvailable(player)) { + recentlyChecked.add(player); + interact(player); + } + } + } + + @Override + public void killed() { - } + } - private boolean interact(EntityPlayer player) { - if(!giveItems(player)) - npc.say(player, npc.advanced.getInteractLine()); - return true; - } + private boolean interact(EntityPlayer player) { + if (!giveItems(player)) + npc.say(player, npc.advanced.getInteractLine()); + return true; + } - @Override - public void delete() { + @Override + public void delete() { - } + } } diff --git a/src/main/java/noppes/npcs/roles/JobSpawner.java b/src/main/java/noppes/npcs/roles/JobSpawner.java index ae1099d38..a533a7625 100644 --- a/src/main/java/noppes/npcs/roles/JobSpawner.java +++ b/src/main/java/noppes/npcs/roles/JobSpawner.java @@ -14,317 +14,313 @@ import org.apache.commons.lang3.RandomStringUtils; import java.util.*; import java.util.Map.Entry; -public class JobSpawner extends JobInterface{ - public NBTTagCompound compound6; - public NBTTagCompound compound5; - public NBTTagCompound compound4; - public NBTTagCompound compound3; - public NBTTagCompound compound2; - public NBTTagCompound compound1; +public class JobSpawner extends JobInterface { + public NBTTagCompound compound6; + public NBTTagCompound compound5; + public NBTTagCompound compound4; + public NBTTagCompound compound3; + public NBTTagCompound compound2; + public NBTTagCompound compound1; - private int number = 0; + private int number = 0; - public List spawned = new ArrayList(); + public List spawned = new ArrayList(); - private Map cooldown = new HashMap(); + private Map cooldown = new HashMap(); - private String id = RandomStringUtils.random(8, true, true); + private String id = RandomStringUtils.random(8, true, true); - public boolean doesntDie = false; - public boolean despawnOnSummonerDeath = false; - public boolean despawnOnTargetLost = true; + public boolean doesntDie = false; + public boolean despawnOnSummonerDeath = false; + public boolean despawnOnTargetLost = true; - // 0 - One By One, 1 - All at Once, 2 - Random, 3 - When Summoner Dies - public int spawnType = 0; + // 0 - One By One, 1 - All at Once, 2 - Random, 3 - When Summoner Dies + public int spawnType = 0; - public int xOffset = 0; - public int yOffset = 0; - public int zOffset = 0; + public int xOffset = 0; + public int yOffset = 0; + public int zOffset = 0; - private EntityLivingBase target; + private EntityLivingBase target; - public JobSpawner(EntityNPCInterface npc) { - super(npc); - } - - @Override - public NBTTagCompound writeToNBT(NBTTagCompound compound) { - saveCompound(compound1, "SpawnerNBT1", compound); - saveCompound(compound2, "SpawnerNBT2", compound); - saveCompound(compound3, "SpawnerNBT3", compound); - saveCompound(compound4, "SpawnerNBT4", compound); - saveCompound(compound5, "SpawnerNBT5", compound); - saveCompound(compound6, "SpawnerNBT6", compound); - - compound.setString("SpawnerId", id); - compound.setBoolean("SpawnerDoesntDie", doesntDie); - compound.setInteger("SpawnerType", spawnType); - compound.setInteger("SpawnerXOffset", xOffset); - compound.setInteger("SpawnerYOffset", yOffset); - compound.setInteger("SpawnerZOffset", zOffset); - - compound.setBoolean("DespawnOnTargetLost", despawnOnTargetLost); - compound.setBoolean("DespawnOnSummmoner", despawnOnSummonerDeath); - return compound; - } - - public NBTTagCompound getTitles() { - NBTTagCompound compound = new NBTTagCompound(); - compound.setString("Title1", getTitle(compound1)); - compound.setString("Title2", getTitle(compound2)); - compound.setString("Title3", getTitle(compound3)); - compound.setString("Title4", getTitle(compound4)); - compound.setString("Title5", getTitle(compound5)); - compound.setString("Title6", getTitle(compound6)); - return compound; - } - - private String getTitle(NBTTagCompound compound) { - if(compound != null && compound.hasKey("ClonedName")) - return compound.getString("ClonedName"); - - return "gui.selectnpc"; - } - - private void saveCompound(NBTTagCompound save, String name, NBTTagCompound compound) { - if(save != null) - compound.setTag(name, save); - } - - - @Override - public void readFromNBT(NBTTagCompound compound) { - compound1 = compound.getCompoundTag("SpawnerNBT1"); - compound2 = compound.getCompoundTag("SpawnerNBT2"); - compound3 = compound.getCompoundTag("SpawnerNBT3"); - compound4 = compound.getCompoundTag("SpawnerNBT4"); - compound5 = compound.getCompoundTag("SpawnerNBT5"); - compound6 = compound.getCompoundTag("SpawnerNBT6"); - - id = compound.getString("SpawnerId"); - doesntDie = compound.getBoolean("SpawnerDoesntDie"); - spawnType = compound.getInteger("SpawnerType"); - xOffset = compound.getInteger("SpawnerXOffset"); - yOffset = compound.getInteger("SpawnerYOffset"); - zOffset = compound.getInteger("SpawnerZOffset"); - - despawnOnTargetLost = compound.getBoolean("DespawnOnTargetLost"); - despawnOnSummonerDeath = compound.getBoolean("DespawnOnSummmoner"); - } - - - public void cleanCompound(NBTTagCompound compound) { - compound.removeTag("SpawnerNBT1"); - compound.removeTag("SpawnerNBT2"); - compound.removeTag("SpawnerNBT3"); - compound.removeTag("SpawnerNBT4"); - compound.removeTag("SpawnerNBT5"); - compound.removeTag("SpawnerNBT6"); - } - - public void setJobCompound(int i, NBTTagCompound compound){ - if(i == 1) - compound1 = compound; - if(i == 2) - compound2 = compound; - if(i == 3) - compound3 = compound; - if(i == 4) - compound4 = compound; - if(i == 5) - compound5 = compound; - if(i == 6) - compound6 = compound; + public JobSpawner(EntityNPCInterface npc) { + super(npc); } - @Override - public void aiUpdateTask() { - if(spawned.isEmpty()){ - if(spawnType == 0){ - if(spawnEntity(number + 1) == null && !doesntDie) - npc.setDead(); - } - if(spawnType == 1){ - if(number >= 6 && !doesntDie) - npc.setDead(); - else{ - spawnEntity(compound1); - spawnEntity(compound2); - spawnEntity(compound3); - spawnEntity(compound4); - spawnEntity(compound5); - spawnEntity(compound6); - number = 6; - } - } - if(spawnType == 2){ - ArrayList list = new ArrayList(); - if(compound1 != null && compound1.hasKey("id")) - list.add(compound1); - if(compound2 != null && compound2.hasKey("id")) - list.add(compound2); - if(compound3 != null && compound3.hasKey("id")) - list.add(compound3); - if(compound4 != null && compound4.hasKey("id")) - list.add(compound4); - if(compound5 != null && compound5.hasKey("id")) - list.add(compound5); - if(compound6 != null && compound6.hasKey("id")) - list.add(compound6); + @Override + public NBTTagCompound writeToNBT(NBTTagCompound compound) { + saveCompound(compound1, "SpawnerNBT1", compound); + saveCompound(compound2, "SpawnerNBT2", compound); + saveCompound(compound3, "SpawnerNBT3", compound); + saveCompound(compound4, "SpawnerNBT4", compound); + saveCompound(compound5, "SpawnerNBT5", compound); + saveCompound(compound6, "SpawnerNBT6", compound); - if(!list.isEmpty()){ - NBTTagCompound compound = list.get(npc.getRNG().nextInt(list.size())); - spawnEntity(compound); - } - else if(!doesntDie) - npc.setDead(); - } - } - else{ - checkSpawns(); - } + compound.setString("SpawnerId", id); + compound.setBoolean("SpawnerDoesntDie", doesntDie); + compound.setInteger("SpawnerType", spawnType); + compound.setInteger("SpawnerXOffset", xOffset); + compound.setInteger("SpawnerYOffset", yOffset); + compound.setInteger("SpawnerZOffset", zOffset); - } + compound.setBoolean("DespawnOnTargetLost", despawnOnTargetLost); + compound.setBoolean("DespawnOnSummmoner", despawnOnSummonerDeath); + return compound; + } - public void checkSpawns(){ - Iterator iterator = spawned.iterator(); - while(iterator.hasNext()){ - EntityLivingBase spawn = iterator.next(); - if(shouldDelete(spawn)){ - spawn.isDead = true; - iterator.remove(); - } - else{ - checkTarget(spawn); - } - } - } + public NBTTagCompound getTitles() { + NBTTagCompound compound = new NBTTagCompound(); + compound.setString("Title1", getTitle(compound1)); + compound.setString("Title2", getTitle(compound2)); + compound.setString("Title3", getTitle(compound3)); + compound.setString("Title4", getTitle(compound4)); + compound.setString("Title5", getTitle(compound5)); + compound.setString("Title6", getTitle(compound6)); + return compound; + } - public void checkTarget(EntityLivingBase entity){ - if(entity instanceof EntityLiving){ - EntityLiving liv = (EntityLiving) entity; - if(liv.getAttackTarget() == null || npc.getRNG().nextInt(100) == 1) - liv.setAttackTarget(target); - } - else if(entity.getAITarget() == null || npc.getRNG().nextInt(100) == 1){ - entity.setRevengeTarget(target); - } - } + private String getTitle(NBTTagCompound compound) { + if (compound != null && compound.hasKey("ClonedName")) + return compound.getString("ClonedName"); - public boolean shouldDelete(EntityLivingBase entity){ - return npc.getDistanceToEntity(entity) > 60 || entity.isDead || entity.getHealth() <= 0 || - PixelmonHelper.Enabled && hasPixelmon() && !PixelmonHelper.isBattling(entity) || (despawnOnSummonerDeath && npc.isDead) || despawnOnTargetLost && target == null; - } + return "gui.selectnpc"; + } - private EntityLivingBase getTarget() { - EntityLivingBase target = getTarget(npc); - if(target != null) - return target; + private void saveCompound(NBTTagCompound save, String name, NBTTagCompound compound) { + if (save != null) + compound.setTag(name, save); + } - for(EntityLivingBase entity : spawned){ - target = getTarget(entity); - if(target != null) - return target; - } - return null; - } - private EntityLivingBase getTarget(EntityLivingBase entity){ - if(entity instanceof EntityLiving){ - target = ((EntityLiving)entity).getAttackTarget(); - if(target != null && !target.isDead && target.getHealth() > 0) - return target; - } - target = entity.getAITarget(); - if(target != null && !target.isDead && target.getHealth() > 0) - return target; - return null; - } + @Override + public void readFromNBT(NBTTagCompound compound) { + compound1 = compound.getCompoundTag("SpawnerNBT1"); + compound2 = compound.getCompoundTag("SpawnerNBT2"); + compound3 = compound.getCompoundTag("SpawnerNBT3"); + compound4 = compound.getCompoundTag("SpawnerNBT4"); + compound5 = compound.getCompoundTag("SpawnerNBT5"); + compound6 = compound.getCompoundTag("SpawnerNBT6"); - public boolean isEmpty(){ - if(compound1 != null && compound1.hasKey("id")) - return false; - if(compound2 != null && compound2.hasKey("id")) - return false; - if(compound3 != null && compound3.hasKey("id")) - return false; - if(compound4 != null && compound4.hasKey("id")) - return false; - if(compound5 != null && compound5.hasKey("id")) - return false; - if(compound6 != null && compound6.hasKey("id")) - return false; + id = compound.getString("SpawnerId"); + doesntDie = compound.getBoolean("SpawnerDoesntDie"); + spawnType = compound.getInteger("SpawnerType"); + xOffset = compound.getInteger("SpawnerXOffset"); + yOffset = compound.getInteger("SpawnerYOffset"); + zOffset = compound.getInteger("SpawnerZOffset"); - return true; - } + despawnOnTargetLost = compound.getBoolean("DespawnOnTargetLost"); + despawnOnSummonerDeath = compound.getBoolean("DespawnOnSummmoner"); + } - private void setTarget(EntityLivingBase base, EntityLivingBase target) { - if (PixelmonHelper.isTrainer(base) && target instanceof EntityPlayerMP) { - EntityPlayerMP player = (EntityPlayerMP) target; - if(!PixelmonHelper.canBattle(player, npc)) - return; - cooldown.put(player.getCommandSenderName(), System.currentTimeMillis()); - Iterator> ita = cooldown.entrySet().iterator(); + public void cleanCompound(NBTTagCompound compound) { + compound.removeTag("SpawnerNBT1"); + compound.removeTag("SpawnerNBT2"); + compound.removeTag("SpawnerNBT3"); + compound.removeTag("SpawnerNBT4"); + compound.removeTag("SpawnerNBT5"); + compound.removeTag("SpawnerNBT6"); + } - while(ita.hasNext()){ - Entry entry = ita.next(); - if(!isOnCooldown(entry.getKey())) - ita.remove(); - } - } - else if (base instanceof EntityLiving) - ((EntityLiving) base).setAttackTarget(target); - else - base.setRevengeTarget(target); - } + public void setJobCompound(int i, NBTTagCompound compound) { + if (i == 1) + compound1 = compound; + if (i == 2) + compound2 = compound; + if (i == 3) + compound3 = compound; + if (i == 4) + compound4 = compound; + if (i == 5) + compound5 = compound; + if (i == 6) + compound6 = compound; + } - @Override - public boolean aiShouldExecute() { - if(isEmpty() || npc.isKilled()) - return false; + @Override + public void aiUpdateTask() { + if (spawned.isEmpty()) { + if (spawnType == 0) { + if (spawnEntity(number + 1) == null && !doesntDie) + npc.setDead(); + } + if (spawnType == 1) { + if (number >= 6 && !doesntDie) + npc.setDead(); + else { + spawnEntity(compound1); + spawnEntity(compound2); + spawnEntity(compound3); + spawnEntity(compound4); + spawnEntity(compound5); + spawnEntity(compound6); + number = 6; + } + } + if (spawnType == 2) { + ArrayList list = new ArrayList(); + if (compound1 != null && compound1.hasKey("id")) + list.add(compound1); + if (compound2 != null && compound2.hasKey("id")) + list.add(compound2); + if (compound3 != null && compound3.hasKey("id")) + list.add(compound3); + if (compound4 != null && compound4.hasKey("id")) + list.add(compound4); + if (compound5 != null && compound5.hasKey("id")) + list.add(compound5); + if (compound6 != null && compound6.hasKey("id")) + list.add(compound6); - target = getTarget(); - if(npc.getRNG().nextInt(30) == 1){ - if(spawned.isEmpty()) - spawned = getNearbySpawned(); - } - if(!spawned.isEmpty()) - checkSpawns(); - return target != null; - } + if (!list.isEmpty()) { + NBTTagCompound compound = list.get(npc.getRNG().nextInt(list.size())); + spawnEntity(compound); + } else if (!doesntDie) + npc.setDead(); + } + } else { + checkSpawns(); + } - public boolean aiContinueExecute() { - return aiShouldExecute(); - } - public void resetTask() { - reset(); - } + } - public void aiStartExecuting() { - number = 0; - for(EntityLivingBase entity : spawned){ - int i = entity.getEntityData().getInteger("NpcSpawnerNr"); - if(i > number) - number = i; - setTarget(entity, npc.getAttackTarget()); - } - } + public void checkSpawns() { + Iterator iterator = spawned.iterator(); + while (iterator.hasNext()) { + EntityLivingBase spawn = iterator.next(); + if (shouldDelete(spawn)) { + spawn.isDead = true; + iterator.remove(); + } else { + checkTarget(spawn); + } + } + } - @Override - public void reset() { - number = 0; - if(spawned.isEmpty()) - spawned = getNearbySpawned(); + public void checkTarget(EntityLivingBase entity) { + if (entity instanceof EntityLiving) { + EntityLiving liv = (EntityLiving) entity; + if (liv.getAttackTarget() == null || npc.getRNG().nextInt(100) == 1) + liv.setAttackTarget(target); + } else if (entity.getAITarget() == null || npc.getRNG().nextInt(100) == 1) { + entity.setRevengeTarget(target); + } + } - target = null; - checkSpawns(); - } + public boolean shouldDelete(EntityLivingBase entity) { + return npc.getDistanceToEntity(entity) > 60 || entity.isDead || entity.getHealth() <= 0 || + PixelmonHelper.Enabled && hasPixelmon() && !PixelmonHelper.isBattling(entity) || (despawnOnSummonerDeath && npc.isDead) || despawnOnTargetLost && target == null; + } + + private EntityLivingBase getTarget() { + EntityLivingBase target = getTarget(npc); + if (target != null) + return target; + + for (EntityLivingBase entity : spawned) { + target = getTarget(entity); + if (target != null) + return target; + } + return null; + } + + private EntityLivingBase getTarget(EntityLivingBase entity) { + if (entity instanceof EntityLiving) { + target = ((EntityLiving) entity).getAttackTarget(); + if (target != null && !target.isDead && target.getHealth() > 0) + return target; + } + target = entity.getAITarget(); + if (target != null && !target.isDead && target.getHealth() > 0) + return target; + return null; + } + + public boolean isEmpty() { + if (compound1 != null && compound1.hasKey("id")) + return false; + if (compound2 != null && compound2.hasKey("id")) + return false; + if (compound3 != null && compound3.hasKey("id")) + return false; + if (compound4 != null && compound4.hasKey("id")) + return false; + if (compound5 != null && compound5.hasKey("id")) + return false; + if (compound6 != null && compound6.hasKey("id")) + return false; + + return true; + } + + private void setTarget(EntityLivingBase base, EntityLivingBase target) { + if (PixelmonHelper.isTrainer(base) && target instanceof EntityPlayerMP) { + EntityPlayerMP player = (EntityPlayerMP) target; + if (!PixelmonHelper.canBattle(player, npc)) + return; + cooldown.put(player.getCommandSenderName(), System.currentTimeMillis()); + + Iterator> ita = cooldown.entrySet().iterator(); + + while (ita.hasNext()) { + Entry entry = ita.next(); + if (!isOnCooldown(entry.getKey())) + ita.remove(); + } + } else if (base instanceof EntityLiving) + ((EntityLiving) base).setAttackTarget(target); + else + base.setRevengeTarget(target); + } + + @Override + public boolean aiShouldExecute() { + if (isEmpty() || npc.isKilled()) + return false; + + target = getTarget(); + if (npc.getRNG().nextInt(30) == 1) { + if (spawned.isEmpty()) + spawned = getNearbySpawned(); + } + if (!spawned.isEmpty()) + checkSpawns(); + return target != null; + } + + public boolean aiContinueExecute() { + return aiShouldExecute(); + } + + public void resetTask() { + reset(); + } + + public void aiStartExecuting() { + number = 0; + for (EntityLivingBase entity : spawned) { + int i = entity.getEntityData().getInteger("NpcSpawnerNr"); + if (i > number) + number = i; + setTarget(entity, npc.getAttackTarget()); + } + } + + @Override + public void reset() { + number = 0; + if (spawned.isEmpty()) + spawned = getNearbySpawned(); + + target = null; + checkSpawns(); + } @Override public void delete() { - if(spawnType == 3 && npc.stats.spawnCycle == 3){ + if (spawnType == 3 && npc.stats.spawnCycle == 3) { spawnEntity(compound1); spawnEntity(compound2); spawnEntity(compound3); @@ -338,121 +334,120 @@ public class JobSpawner extends JobInterface{ @Override - public void killed() { - if(spawnType == 3 && npc.stats.spawnCycle != 3){ - spawnEntity(compound1); - spawnEntity(compound2); - spawnEntity(compound3); - spawnEntity(compound4); - spawnEntity(compound5); - spawnEntity(compound6); - number = 6; - } - reset(); - } + public void killed() { + if (spawnType == 3 && npc.stats.spawnCycle != 3) { + spawnEntity(compound1); + spawnEntity(compound2); + spawnEntity(compound3); + spawnEntity(compound4); + spawnEntity(compound5); + spawnEntity(compound6); + number = 6; + } + reset(); + } - public EntityLivingBase spawnEntity(int i){ - NBTTagCompound compound = getCompound(i); - if(compound == null){ - return null; - } - return spawnEntity(compound); - } + public EntityLivingBase spawnEntity(int i) { + NBTTagCompound compound = getCompound(i); + if (compound == null) { + return null; + } + return spawnEntity(compound); + } - private EntityLivingBase spawnEntity(NBTTagCompound compound){ - if(compound == null || !compound.hasKey("id")) - return null; - double x = this.npc.posX + xOffset - 0.5 + this.npc.getRNG().nextFloat(); - double y = this.npc.posY + yOffset; - double z = this.npc.posZ + zOffset - 0.5 + this.npc.getRNG().nextFloat(); - Entity entity = NoppesUtilServer.getEntityFromNBT(compound, MathHelper.floor_double(x), MathHelper.floor_double(y), MathHelper.floor_double(z), npc.worldObj); - if(entity == null){ - return null; - } - entity.dimension = npc.worldObj.provider.dimensionId; - if (!entity.forceSpawn && !npc.worldObj.checkChunksExist( - (int)entity.posX,(int)entity.posY,(int)entity.posZ,(int)entity.posX,(int)entity.posY,(int)entity.posZ - )) { - return null; - } - else { - if (!(entity instanceof EntityLivingBase)) - return null; + private EntityLivingBase spawnEntity(NBTTagCompound compound) { + if (compound == null || !compound.hasKey("id")) + return null; + double x = this.npc.posX + xOffset - 0.5 + this.npc.getRNG().nextFloat(); + double y = this.npc.posY + yOffset; + double z = this.npc.posZ + zOffset - 0.5 + this.npc.getRNG().nextFloat(); + Entity entity = NoppesUtilServer.getEntityFromNBT(compound, MathHelper.floor_double(x), MathHelper.floor_double(y), MathHelper.floor_double(z), npc.worldObj); + if (entity == null) { + return null; + } + entity.dimension = npc.worldObj.provider.dimensionId; + if (!entity.forceSpawn && !npc.worldObj.checkChunksExist( + (int) entity.posX, (int) entity.posY, (int) entity.posZ, (int) entity.posX, (int) entity.posY, (int) entity.posZ + )) { + return null; + } else { + if (!(entity instanceof EntityLivingBase)) + return null; - EntityLivingBase living = (EntityLivingBase) entity; - living.getEntityData().setString("NpcSpawnerId", id); - living.getEntityData().setInteger("NpcSpawnerNr", number); - setTarget(living, this.npc.getAttackTarget()); - living.setPosition(x + 0.5, y + 1 + 0.2F, z + 0.5); + EntityLivingBase living = (EntityLivingBase) entity; + living.getEntityData().setString("NpcSpawnerId", id); + living.getEntityData().setInteger("NpcSpawnerNr", number); + setTarget(living, this.npc.getAttackTarget()); + living.setPosition(x + 0.5, y + 1 + 0.2F, z + 0.5); - if (living instanceof EntityNPCInterface) { - EntityNPCInterface snpc = (EntityNPCInterface) living; - snpc.stats.spawnCycle = 3; - snpc.ais.returnToStart = false; - snpc.stats.canDespawn = true; - snpc.stats.playerSetCanDespawn = true; - } + if (living instanceof EntityNPCInterface) { + EntityNPCInterface snpc = (EntityNPCInterface) living; + snpc.stats.spawnCycle = 3; + snpc.ais.returnToStart = false; + snpc.stats.canDespawn = true; + snpc.stats.playerSetCanDespawn = true; + } - int i = MathHelper.floor_double(living.posX / 16.0D); - int j = MathHelper.floor_double(living.posZ / 16.0D); + int i = MathHelper.floor_double(living.posX / 16.0D); + int j = MathHelper.floor_double(living.posZ / 16.0D); - npc.worldObj.getChunkFromChunkCoords(i, j).addEntity(living); - npc.worldObj.loadedEntityList.add(living); - npc.worldObj.onEntityAdded(living); - spawned.add(living); - return living; - } - } + npc.worldObj.getChunkFromChunkCoords(i, j).addEntity(living); + npc.worldObj.loadedEntityList.add(living); + npc.worldObj.onEntityAdded(living); + spawned.add(living); + return living; + } + } - public NBTTagCompound getCompound(int i) { - if(i <= 1 && compound1 != null && compound1.hasKey("id")){ - number = 1; - return compound1; - } - if(i <= 2 && compound2 != null && compound2.hasKey("id")){ - number = 2; - return compound2; - } - if(i <= 3 && compound3 != null && compound3.hasKey("id")){ - number = 3; - return compound3; - } - if(i <= 4 && compound4 != null && compound4.hasKey("id")){ - number = 4; - return compound4; - } - if(i <= 5 && compound5 != null && compound5.hasKey("id")){ - number = 5; - return compound5; - } - if(i <= 6 && compound6 != null && compound6.hasKey("id")){ - number = 6; - return compound6; - } - return null; - } + public NBTTagCompound getCompound(int i) { + if (i <= 1 && compound1 != null && compound1.hasKey("id")) { + number = 1; + return compound1; + } + if (i <= 2 && compound2 != null && compound2.hasKey("id")) { + number = 2; + return compound2; + } + if (i <= 3 && compound3 != null && compound3.hasKey("id")) { + number = 3; + return compound3; + } + if (i <= 4 && compound4 != null && compound4.hasKey("id")) { + number = 4; + return compound4; + } + if (i <= 5 && compound5 != null && compound5.hasKey("id")) { + number = 5; + return compound5; + } + if (i <= 6 && compound6 != null && compound6.hasKey("id")) { + number = 6; + return compound6; + } + return null; + } - public List getNearbySpawned(){ - List spawnList = new ArrayList(); - List list = npc.worldObj.getEntitiesWithinAABB(EntityLivingBase.class, npc.boundingBox.expand(40, 40, 40)); - for(EntityLivingBase entity : list){ - if(entity.getEntityData().getString("NpcSpawnerId").equals(id) && !entity.isDead) - spawnList.add(entity); - } - return spawnList; - } + public List getNearbySpawned() { + List spawnList = new ArrayList(); + List list = npc.worldObj.getEntitiesWithinAABB(EntityLivingBase.class, npc.boundingBox.expand(40, 40, 40)); + for (EntityLivingBase entity : list) { + if (entity.getEntityData().getString("NpcSpawnerId").equals(id) && !entity.isDead) + spawnList.add(entity); + } + return spawnList; + } - public boolean isOnCooldown(String name) { - if(!cooldown.containsKey(name)) - return false; + public boolean isOnCooldown(String name) { + if (!cooldown.containsKey(name)) + return false; - long time = cooldown.get(name); - return System.currentTimeMillis() < time + 1200000; //20 minutes cooldown - } + long time = cooldown.get(name); + return System.currentTimeMillis() < time + 1200000; //20 minutes cooldown + } - public boolean hasPixelmon() { - return compound1 != null && compound1.getString("id").equals("pixelmontainer"); - } + public boolean hasPixelmon() { + return compound1 != null && compound1.getString("id").equals("pixelmontainer"); + } } diff --git a/src/main/java/noppes/npcs/roles/RoleBank.java b/src/main/java/noppes/npcs/roles/RoleBank.java index 2675d7558..28e557f12 100644 --- a/src/main/java/noppes/npcs/roles/RoleBank.java +++ b/src/main/java/noppes/npcs/roles/RoleBank.java @@ -8,36 +8,36 @@ import noppes.npcs.controllers.data.Bank; import noppes.npcs.controllers.data.BankData; import noppes.npcs.entity.EntityNPCInterface; -public class RoleBank extends RoleInterface{ - - public int bankId = -1; - - public RoleBank(EntityNPCInterface npc) { - super(npc); - } +public class RoleBank extends RoleInterface { - @Override - public NBTTagCompound writeToNBT(NBTTagCompound nbttagcompound) { - nbttagcompound.setInteger("RoleBankID", bankId); - return nbttagcompound; - } + public int bankId = -1; - @Override - public void readFromNBT(NBTTagCompound nbttagcompound) { - bankId = nbttagcompound.getInteger("RoleBankID"); - } + public RoleBank(EntityNPCInterface npc) { + super(npc); + } - @Override - public void interact(EntityPlayer player) { - BankData data = PlayerDataController.Instance.getBankData(player,bankId).getBankOrDefault(bankId); - data.openBankGui(player,npc,bankId,0); - npc.say(player, npc.advanced.getInteractLine()); - } + @Override + public NBTTagCompound writeToNBT(NBTTagCompound nbttagcompound) { + nbttagcompound.setInteger("RoleBankID", bankId); + return nbttagcompound; + } - public Bank getBank() { - Bank bank = BankController.getInstance().banks.get(bankId); - if(bank != null) - return bank; - return BankController.getInstance().banks.values().iterator().next(); - } + @Override + public void readFromNBT(NBTTagCompound nbttagcompound) { + bankId = nbttagcompound.getInteger("RoleBankID"); + } + + @Override + public void interact(EntityPlayer player) { + BankData data = PlayerDataController.Instance.getBankData(player, bankId).getBankOrDefault(bankId); + data.openBankGui(player, npc, bankId, 0); + npc.say(player, npc.advanced.getInteractLine()); + } + + public Bank getBank() { + Bank bank = BankController.getInstance().banks.get(bankId); + if (bank != null) + return bank; + return BankController.getInstance().banks.values().iterator().next(); + } } diff --git a/src/main/java/noppes/npcs/roles/RoleCompanion.java b/src/main/java/noppes/npcs/roles/RoleCompanion.java index 7e5a904a9..0ca34ba6b 100644 --- a/src/main/java/noppes/npcs/roles/RoleCompanion.java +++ b/src/main/java/noppes/npcs/roles/RoleCompanion.java @@ -28,654 +28,645 @@ import java.util.*; import java.util.Map.Entry; public class RoleCompanion extends RoleInterface { - public NpcMiscInventory inventory; - public String uuid = ""; - public String ownerName = ""; - public Map talents = new TreeMap(); + public NpcMiscInventory inventory; + public String uuid = ""; + public String ownerName = ""; + public Map talents = new TreeMap(); - public boolean canAge = true; - public long ticksActive = 0; - public EnumCompanionStage stage = EnumCompanionStage.FULLGROWN; + public boolean canAge = true; + public long ticksActive = 0; + public EnumCompanionStage stage = EnumCompanionStage.FULLGROWN; - public EntityPlayer owner = null; - public int companionID; + public EntityPlayer owner = null; + public int companionID; - public EnumCompanionJobs job = EnumCompanionJobs.NONE; - public CompanionJobInterface jobInterface = null; + public EnumCompanionJobs job = EnumCompanionJobs.NONE; + public CompanionJobInterface jobInterface = null; - public boolean hasInv = true; - public boolean defendOwner = true; + public boolean hasInv = true; + public boolean defendOwner = true; - public CompanionFoodStats foodstats = new CompanionFoodStats(); - private int eatingTicks = 20; - private ItemStack eating = null; - private int eatingDelay = 00; + public CompanionFoodStats foodstats = new CompanionFoodStats(); + private int eatingTicks = 20; + private ItemStack eating = null; + private int eatingDelay = 00; - public int currentExp = 0; + public int currentExp = 0; - public RoleCompanion(EntityNPCInterface npc) { - super(npc); - inventory = new NpcMiscInventory(12); - } + public RoleCompanion(EntityNPCInterface npc) { + super(npc); + inventory = new NpcMiscInventory(12); + } - @Override - public boolean aiShouldExecute() { - EntityPlayer prev = owner; - owner = getOwner(); - if(jobInterface != null && jobInterface.isSelfSufficient()) - return true; + @Override + public boolean aiShouldExecute() { + EntityPlayer prev = owner; + owner = getOwner(); + if (jobInterface != null && jobInterface.isSelfSufficient()) + return true; - if(owner == null && !uuid.isEmpty()){ - npc.isDead = true; - } - else if(prev != owner && owner != null){ - ownerName = owner.getDisplayName(); - PlayerData data = PlayerDataController.Instance.getPlayerData(owner); - if(data.companionID != companionID){ - npc.isDead = true; - } - } - return owner != null; - } + if (owner == null && !uuid.isEmpty()) { + npc.isDead = true; + } else if (prev != owner && owner != null) { + ownerName = owner.getDisplayName(); + PlayerData data = PlayerDataController.Instance.getPlayerData(owner); + if (data.companionID != companionID) { + npc.isDead = true; + } + } + return owner != null; + } - @Override - public void aiUpdateTask() { - if(owner != null && (jobInterface == null || !jobInterface.isSelfSufficient())) - foodstats.onUpdate(npc); - if(foodstats.getFoodLevel() >= 18){ - npc.stats.healthRegen = 0; - npc.stats.combatRegen = 0; - } - if(foodstats.needFood() && isSitting()){ - if(eatingDelay > 0){ - eatingDelay--; - return; - } + @Override + public void aiUpdateTask() { + if (owner != null && (jobInterface == null || !jobInterface.isSelfSufficient())) + foodstats.onUpdate(npc); + if (foodstats.getFoodLevel() >= 18) { + npc.stats.healthRegen = 0; + npc.stats.combatRegen = 0; + } + if (foodstats.needFood() && isSitting()) { + if (eatingDelay > 0) { + eatingDelay--; + return; + } - ItemStack prev = eating; - eating = getFood(); + ItemStack prev = eating; + eating = getFood(); - if(prev != null && eating == null) - npc.setRoleDataWatcher(""); + if (prev != null && eating == null) + npc.setRoleDataWatcher(""); - if(prev == null && eating != null){ - npc.setRoleDataWatcher("eating"); - eatingTicks = 20; - } + if (prev == null && eating != null) { + npc.setRoleDataWatcher("eating"); + eatingTicks = 20; + } - if(isEating()){ - doEating(); - } + if (isEating()) { + doEating(); + } - } - else if(eating != null && !isSitting()){ - eating = null; - eatingDelay = 20; - npc.setRoleDataWatcher(""); - } + } else if (eating != null && !isSitting()) { + eating = null; + eatingDelay = 20; + npc.setRoleDataWatcher(""); + } - ticksActive++; - if(canAge && stage != EnumCompanionStage.FULLGROWN){ - if(stage == EnumCompanionStage.BABY && ticksActive > EnumCompanionStage.CHILD.matureAge){ - matureTo(EnumCompanionStage.CHILD); - } - else if(stage == EnumCompanionStage.CHILD && ticksActive > EnumCompanionStage.TEEN.matureAge){ - matureTo(EnumCompanionStage.TEEN); - } - else if(stage == EnumCompanionStage.TEEN && ticksActive > EnumCompanionStage.ADULT.matureAge){ - matureTo(EnumCompanionStage.ADULT); - } - else if(stage == EnumCompanionStage.ADULT && ticksActive > EnumCompanionStage.FULLGROWN.matureAge){ - matureTo(EnumCompanionStage.FULLGROWN); - } - } - } + ticksActive++; + if (canAge && stage != EnumCompanionStage.FULLGROWN) { + if (stage == EnumCompanionStage.BABY && ticksActive > EnumCompanionStage.CHILD.matureAge) { + matureTo(EnumCompanionStage.CHILD); + } else if (stage == EnumCompanionStage.CHILD && ticksActive > EnumCompanionStage.TEEN.matureAge) { + matureTo(EnumCompanionStage.TEEN); + } else if (stage == EnumCompanionStage.TEEN && ticksActive > EnumCompanionStage.ADULT.matureAge) { + matureTo(EnumCompanionStage.ADULT); + } else if (stage == EnumCompanionStage.ADULT && ticksActive > EnumCompanionStage.FULLGROWN.matureAge) { + matureTo(EnumCompanionStage.FULLGROWN); + } + } + } - public void clientUpdate() { - if(npc.getRoleDataWatcher().equals("eating")){ - eating = getFood(); + public void clientUpdate() { + if (npc.getRoleDataWatcher().equals("eating")) { + eating = getFood(); - if(isEating()){ - doEating(); - } - } - else if(eating != null){ - eating = null; - } + if (isEating()) { + doEating(); + } + } else if (eating != null) { + eating = null; + } - } - private void doEating(){ - if(npc.worldObj.isRemote){ - Random rand = npc.getRNG(); - for (int j = 0; j < 2; ++j){ - Vec3 vec3 = Vec3.createVectorHelper(((double)rand.nextFloat() - 0.5D) * 0.1D, Math.random() * 0.1D + 0.1D, 0.0D); - vec3.rotateAroundX(-npc.rotationPitch * (float)Math.PI / 180.0F); - vec3.rotateAroundY(-npc.renderYawOffset * (float)Math.PI / 180.0F); - Vec3 vec31 = Vec3.createVectorHelper(((double)rand.nextFloat() - 0.5D) * 0.3D, (double)(-rand.nextFloat()) * 0.6D - 0.3D, npc.width / 2 + 0.1); - vec31.rotateAroundX(-npc.rotationPitch * (float)Math.PI / 180.0F); - vec31.rotateAroundY(-npc.renderYawOffset * (float)Math.PI / 180.0F); - vec31 = vec31.addVector(npc.posX, npc.posY + (double)npc.height + 0.1, npc.posZ); + } + + private void doEating() { + if (npc.worldObj.isRemote) { + Random rand = npc.getRNG(); + for (int j = 0; j < 2; ++j) { + Vec3 vec3 = Vec3.createVectorHelper(((double) rand.nextFloat() - 0.5D) * 0.1D, Math.random() * 0.1D + 0.1D, 0.0D); + vec3.rotateAroundX(-npc.rotationPitch * (float) Math.PI / 180.0F); + vec3.rotateAroundY(-npc.renderYawOffset * (float) Math.PI / 180.0F); + Vec3 vec31 = Vec3.createVectorHelper(((double) rand.nextFloat() - 0.5D) * 0.3D, (double) (-rand.nextFloat()) * 0.6D - 0.3D, npc.width / 2 + 0.1); + vec31.rotateAroundX(-npc.rotationPitch * (float) Math.PI / 180.0F); + vec31.rotateAroundY(-npc.renderYawOffset * (float) Math.PI / 180.0F); + vec31 = vec31.addVector(npc.posX, npc.posY + (double) npc.height + 0.1, npc.posZ); String s = "iconcrack_" + Item.getIdFromItem(eating.getItem()); - if (eating.getHasSubtypes()){ + if (eating.getHasSubtypes()) { s = s + "_" + eating.getItemDamage(); } npc.worldObj.spawnParticle(s, vec31.xCoord, vec31.yCoord, vec31.zCoord, vec3.xCoord, vec3.yCoord + 0.0D, vec3.zCoord); } - } - else{ - eatingTicks--; + } else { + eatingTicks--; - if(eatingTicks <= 0){ - if(inventory.decrStackSize(eating, 1)){ - ItemFood food = (ItemFood) eating.getItem(); - foodstats.onFoodEaten(food, eating); - npc.playSound("random.burp", 0.5F, npc.getRNG().nextFloat() * 0.1F + 0.9F); - } - eatingDelay = 20; - npc.setRoleDataWatcher(""); - eating = null; - } - else if(eatingTicks > 3 && eatingTicks % 2 == 0){ - Random rand = npc.getRNG(); - npc.playSound("random.eat", 0.5F + 0.5F * rand.nextInt(2), (rand.nextFloat() - rand.nextFloat()) * 0.2F + 1.0F); - } - } - } + if (eatingTicks <= 0) { + if (inventory.decrStackSize(eating, 1)) { + ItemFood food = (ItemFood) eating.getItem(); + foodstats.onFoodEaten(food, eating); + npc.playSound("random.burp", 0.5F, npc.getRNG().nextFloat() * 0.1F + 0.9F); + } + eatingDelay = 20; + npc.setRoleDataWatcher(""); + eating = null; + } else if (eatingTicks > 3 && eatingTicks % 2 == 0) { + Random rand = npc.getRNG(); + npc.playSound("random.eat", 0.5F + 0.5F * rand.nextInt(2), (rand.nextFloat() - rand.nextFloat()) * 0.2F + 1.0F); + } + } + } - public void matureTo(EnumCompanionStage stage){ - this.stage = stage; - EntityCustomNpc npc = (EntityCustomNpc) this.npc; - npc.ais.animationType = stage.animation; - if(stage == EnumCompanionStage.BABY){ - npc.modelData.modelScale.arms.setScale(0.5f, 0.5f, 0.5f); - npc.modelData.modelScale.legs.setScale(0.5f, 0.5f, 0.5f); - npc.modelData.modelScale.body.setScale(0.5f, 0.5f, 0.5f); - npc.modelData.modelScale.head.setScale(0.7f, 0.7f, 0.7f); + public void matureTo(EnumCompanionStage stage) { + this.stage = stage; + EntityCustomNpc npc = (EntityCustomNpc) this.npc; + npc.ais.animationType = stage.animation; + if (stage == EnumCompanionStage.BABY) { + npc.modelData.modelScale.arms.setScale(0.5f, 0.5f, 0.5f); + npc.modelData.modelScale.legs.setScale(0.5f, 0.5f, 0.5f); + npc.modelData.modelScale.body.setScale(0.5f, 0.5f, 0.5f); + npc.modelData.modelScale.head.setScale(0.7f, 0.7f, 0.7f); - npc.ais.onAttack = 1; - npc.ais.setWalkingSpeed(3); - if(!talents.containsKey(EnumCompanionTalent.INVENTORY)) - talents.put(EnumCompanionTalent.INVENTORY, 0); - } - if(stage == EnumCompanionStage.CHILD){ - npc.modelData.modelScale.arms.setScale(0.6f, 0.6f, 0.6f); - npc.modelData.modelScale.legs.setScale(0.6f, 0.6f, 0.6f); - npc.modelData.modelScale.body.setScale(0.6f, 0.6f, 0.6f); - npc.modelData.modelScale.head.setScale(0.8f, 0.8f, 0.8f); + npc.ais.onAttack = 1; + npc.ais.setWalkingSpeed(3); + if (!talents.containsKey(EnumCompanionTalent.INVENTORY)) + talents.put(EnumCompanionTalent.INVENTORY, 0); + } + if (stage == EnumCompanionStage.CHILD) { + npc.modelData.modelScale.arms.setScale(0.6f, 0.6f, 0.6f); + npc.modelData.modelScale.legs.setScale(0.6f, 0.6f, 0.6f); + npc.modelData.modelScale.body.setScale(0.6f, 0.6f, 0.6f); + npc.modelData.modelScale.head.setScale(0.8f, 0.8f, 0.8f); - npc.ais.onAttack = 0; - npc.ais.setWalkingSpeed(4); - if(!talents.containsKey(EnumCompanionTalent.SWORD)) - talents.put(EnumCompanionTalent.SWORD, 0); - } - if(stage == EnumCompanionStage.TEEN){ - npc.modelData.modelScale.arms.setScale(0.8f, 0.8f, 0.8f); - npc.modelData.modelScale.legs.setScale(0.8f, 0.8f, 0.8f); - npc.modelData.modelScale.body.setScale(0.8f, 0.8f, 0.8f); - npc.modelData.modelScale.head.setScale(0.9f, 0.9f, 0.9f); + npc.ais.onAttack = 0; + npc.ais.setWalkingSpeed(4); + if (!talents.containsKey(EnumCompanionTalent.SWORD)) + talents.put(EnumCompanionTalent.SWORD, 0); + } + if (stage == EnumCompanionStage.TEEN) { + npc.modelData.modelScale.arms.setScale(0.8f, 0.8f, 0.8f); + npc.modelData.modelScale.legs.setScale(0.8f, 0.8f, 0.8f); + npc.modelData.modelScale.body.setScale(0.8f, 0.8f, 0.8f); + npc.modelData.modelScale.head.setScale(0.9f, 0.9f, 0.9f); - npc.ais.onAttack = 0; - npc.ais.setWalkingSpeed(5); - if(!talents.containsKey(EnumCompanionTalent.ARMOR)) - talents.put(EnumCompanionTalent.ARMOR, 0); - } - if(stage == EnumCompanionStage.ADULT || stage == EnumCompanionStage.FULLGROWN){ - npc.modelData.modelScale.arms.setScale(1f, 1f, 1f); - npc.modelData.modelScale.legs.setScale(1f, 1f, 1f); - npc.modelData.modelScale.body.setScale(1f, 1f, 1f); - npc.modelData.modelScale.head.setScale(1f, 1f, 1f); + npc.ais.onAttack = 0; + npc.ais.setWalkingSpeed(5); + if (!talents.containsKey(EnumCompanionTalent.ARMOR)) + talents.put(EnumCompanionTalent.ARMOR, 0); + } + if (stage == EnumCompanionStage.ADULT || stage == EnumCompanionStage.FULLGROWN) { + npc.modelData.modelScale.arms.setScale(1f, 1f, 1f); + npc.modelData.modelScale.legs.setScale(1f, 1f, 1f); + npc.modelData.modelScale.body.setScale(1f, 1f, 1f); + npc.modelData.modelScale.head.setScale(1f, 1f, 1f); - npc.ais.onAttack = 0; - npc.ais.setWalkingSpeed(5); - } - } + npc.ais.onAttack = 0; + npc.ais.setWalkingSpeed(5); + } + } - @Override - public NBTTagCompound writeToNBT(NBTTagCompound compound) { - compound.setTag("CompanionInventory", inventory.getToNBT()); - compound.setString("CompanionOwner", uuid); - compound.setString("CompanionOwnerName", ownerName); - compound.setInteger("CompanionID", companionID); + @Override + public NBTTagCompound writeToNBT(NBTTagCompound compound) { + compound.setTag("CompanionInventory", inventory.getToNBT()); + compound.setString("CompanionOwner", uuid); + compound.setString("CompanionOwnerName", ownerName); + compound.setInteger("CompanionID", companionID); - compound.setInteger("CompanionStage", stage.ordinal()); - compound.setInteger("CompanionExp", currentExp); - compound.setBoolean("CompanionCanAge", canAge); - compound.setLong("CompanionAge", ticksActive); + compound.setInteger("CompanionStage", stage.ordinal()); + compound.setInteger("CompanionExp", currentExp); + compound.setBoolean("CompanionCanAge", canAge); + compound.setLong("CompanionAge", ticksActive); - compound.setBoolean("CompanionHasInv", hasInv); - compound.setBoolean("CompanionDefendOwner", defendOwner); + compound.setBoolean("CompanionHasInv", hasInv); + compound.setBoolean("CompanionDefendOwner", defendOwner); - foodstats.writeNBT(compound); + foodstats.writeNBT(compound); - compound.setInteger("CompanionJob", job.ordinal()); - if(jobInterface != null) - compound.setTag("CompanionJobData", jobInterface.getNBT()); + compound.setInteger("CompanionJob", job.ordinal()); + if (jobInterface != null) + compound.setTag("CompanionJobData", jobInterface.getNBT()); - NBTTagList list = new NBTTagList(); - for(EnumCompanionTalent talent : talents.keySet()){ - NBTTagCompound c = new NBTTagCompound(); - c.setInteger("Talent", talent.ordinal()); - c.setInteger("Exp", talents.get(talent)); - list.appendTag(c); - } - compound.setTag("CompanionTalents", list); - return compound; - } + NBTTagList list = new NBTTagList(); + for (EnumCompanionTalent talent : talents.keySet()) { + NBTTagCompound c = new NBTTagCompound(); + c.setInteger("Talent", talent.ordinal()); + c.setInteger("Exp", talents.get(talent)); + list.appendTag(c); + } + compound.setTag("CompanionTalents", list); + return compound; + } - @Override - public void readFromNBT(NBTTagCompound compound) { - inventory.setFromNBT(compound.getCompoundTag("CompanionInventory")); - uuid = compound.getString("CompanionOwner"); - ownerName = compound.getString("CompanionOwnerName"); - companionID = compound.getInteger("CompanionID"); + @Override + public void readFromNBT(NBTTagCompound compound) { + inventory.setFromNBT(compound.getCompoundTag("CompanionInventory")); + uuid = compound.getString("CompanionOwner"); + ownerName = compound.getString("CompanionOwnerName"); + companionID = compound.getInteger("CompanionID"); - stage = EnumCompanionStage.values()[compound.getInteger("CompanionStage")]; - currentExp = compound.getInteger("CompanionExp"); - canAge = compound.getBoolean("CompanionCanAge"); - ticksActive = compound.getLong("CompanionAge"); + stage = EnumCompanionStage.values()[compound.getInteger("CompanionStage")]; + currentExp = compound.getInteger("CompanionExp"); + canAge = compound.getBoolean("CompanionCanAge"); + ticksActive = compound.getLong("CompanionAge"); - hasInv = compound.getBoolean("CompanionHasInv"); - defendOwner = compound.getBoolean("CompanionDefendOwner"); + hasInv = compound.getBoolean("CompanionHasInv"); + defendOwner = compound.getBoolean("CompanionDefendOwner"); - foodstats.readNBT(compound); + foodstats.readNBT(compound); - NBTTagList list = compound.getTagList("CompanionTalents", 10); - Map talents = new TreeMap(); - for(int i = 0; i < list.tagCount(); i++){ - NBTTagCompound c = list.getCompoundTagAt(i); - EnumCompanionTalent talent = EnumCompanionTalent.values()[c.getInteger("Talent")]; - talents.put(talent, c.getInteger("Exp")); - } - this.talents = talents; + NBTTagList list = compound.getTagList("CompanionTalents", 10); + Map talents = new TreeMap(); + for (int i = 0; i < list.tagCount(); i++) { + NBTTagCompound c = list.getCompoundTagAt(i); + EnumCompanionTalent talent = EnumCompanionTalent.values()[c.getInteger("Talent")]; + talents.put(talent, c.getInteger("Exp")); + } + this.talents = talents; - setJob(compound.getInteger("CompanionJob")); - if(jobInterface != null) - jobInterface.setNBT(compound.getCompoundTag("CompanionJobData")); - setStats(); - } + setJob(compound.getInteger("CompanionJob")); + if (jobInterface != null) + jobInterface.setNBT(compound.getCompoundTag("CompanionJobData")); + setStats(); + } - private void setJob(int i) { - job = EnumCompanionJobs.values()[i]; - if(job == EnumCompanionJobs.SHOP) - jobInterface = new CompanionTrader(); - else if(job == EnumCompanionJobs.FARMER) - jobInterface = new CompanionFarmer(); - else if(job == EnumCompanionJobs.GUARD) - jobInterface = new CompanionGuard(); - else - jobInterface = null; + private void setJob(int i) { + job = EnumCompanionJobs.values()[i]; + if (job == EnumCompanionJobs.SHOP) + jobInterface = new CompanionTrader(); + else if (job == EnumCompanionJobs.FARMER) + jobInterface = new CompanionFarmer(); + else if (job == EnumCompanionJobs.GUARD) + jobInterface = new CompanionGuard(); + else + jobInterface = null; - if(jobInterface != null) - jobInterface.npc = npc; - } + if (jobInterface != null) + jobInterface.npc = npc; + } - @Override - public void interact(EntityPlayer player) { - if(player != null && job == EnumCompanionJobs.SHOP) - ((CompanionTrader)jobInterface).interact(player); - if(player != owner || !npc.isEntityAlive() || npc.isAttacking()) - return; - if(player.isSneaking()){ - openGui(player); - } - else{ - setSitting(!isSitting()); - } - } + @Override + public void interact(EntityPlayer player) { + if (player != null && job == EnumCompanionJobs.SHOP) + ((CompanionTrader) jobInterface).interact(player); + if (player != owner || !npc.isEntityAlive() || npc.isAttacking()) + return; + if (player.isSneaking()) { + openGui(player); + } else { + setSitting(!isSitting()); + } + } - public int getTotalLevel(){ - int level = 0; - for(EnumCompanionTalent talent : talents.keySet()) - level += this.getTalentLevel(talent); - return level; - } + public int getTotalLevel() { + int level = 0; + for (EnumCompanionTalent talent : talents.keySet()) + level += this.getTalentLevel(talent); + return level; + } - public int getMaxExp(){ - return 500 + getTotalLevel() * 200; - } + public int getMaxExp() { + return 500 + getTotalLevel() * 200; + } - public void addExp(int exp){ - if(canAddExp(exp)) - this.currentExp += exp; - } + public void addExp(int exp) { + if (canAddExp(exp)) + this.currentExp += exp; + } - public boolean canAddExp(int exp){ - int newExp = this.currentExp + exp; - return newExp >= 0 && newExp < getMaxExp(); - } + public boolean canAddExp(int exp) { + int newExp = this.currentExp + exp; + return newExp >= 0 && newExp < getMaxExp(); + } - public void gainExp(int chance){ - if(npc.getRNG().nextInt(chance) == 0) - addExp(1); - } + public void gainExp(int chance) { + if (npc.getRNG().nextInt(chance) == 0) + addExp(1); + } - private void openGui(EntityPlayer player){ - NoppesUtilServer.sendOpenGui(player, EnumGuiType.Companion, npc); - } + private void openGui(EntityPlayer player) { + NoppesUtilServer.sendOpenGui(player, EnumGuiType.Companion, npc); + } - public EntityPlayer getOwner(){ - if(uuid == null || uuid.isEmpty()) - return null; - try{ - UUID id = UUID.fromString(uuid); - if(id != null){ - return NoppesUtilServer.getPlayer(id); - } - } - catch(IllegalArgumentException ex){ + public EntityPlayer getOwner() { + if (uuid == null || uuid.isEmpty()) + return null; + try { + UUID id = UUID.fromString(uuid); + if (id != null) { + return NoppesUtilServer.getPlayer(id); + } + } catch (IllegalArgumentException ex) { - } - return null; - } + } + return null; + } - public void setOwner(EntityPlayer player) { - uuid = player.getUniqueID().toString(); - } + public void setOwner(EntityPlayer player) { + uuid = player.getUniqueID().toString(); + } - public boolean hasTalent(EnumCompanionTalent talent) { - return getTalentLevel(talent) > 0; - } + public boolean hasTalent(EnumCompanionTalent talent) { + return getTalentLevel(talent) > 0; + } - public int getTalentLevel(EnumCompanionTalent talent){ - if(!talents.containsKey(talent)) - return 0; + public int getTalentLevel(EnumCompanionTalent talent) { + if (!talents.containsKey(talent)) + return 0; - int exp = talents.get(talent); - if(exp >= 5000) - return 5; - if(exp >= 3000) - return 4; - if(exp >= 1700) - return 3; - if(exp >= 1000) - return 2; - if(exp >= 400) - return 1; - return 0; - } + int exp = talents.get(talent); + if (exp >= 5000) + return 5; + if (exp >= 3000) + return 4; + if (exp >= 1700) + return 3; + if (exp >= 1000) + return 2; + if (exp >= 400) + return 1; + return 0; + } - public Integer getNextLevel(EnumCompanionTalent talent) { - if(!talents.containsKey(talent)) - return 0; - int exp = talents.get(talent); - if(exp < 400) - return 400; - if(exp < 1000) - return 700; - if(exp < 1700) - return 1700; - if(exp < 3000) - return 3000; - return 5000; - } + public Integer getNextLevel(EnumCompanionTalent talent) { + if (!talents.containsKey(talent)) + return 0; + int exp = talents.get(talent); + if (exp < 400) + return 400; + if (exp < 1000) + return 700; + if (exp < 1700) + return 1700; + if (exp < 3000) + return 3000; + return 5000; + } - public void levelSword(){ - if(!talents.containsKey(EnumCompanionTalent.SWORD)) - return; - } - public void levelTalent(EnumCompanionTalent talent, int exp){ - if(!talents.containsKey(EnumCompanionTalent.SWORD)) - return; - talents.put(talent, exp + talents.get(talent)); - } + public void levelSword() { + if (!talents.containsKey(EnumCompanionTalent.SWORD)) + return; + } - public int getExp(EnumCompanionTalent talent) { - if(talents.containsKey(talent)) - return talents.get(talent); - return -1; - } + public void levelTalent(EnumCompanionTalent talent, int exp) { + if (!talents.containsKey(EnumCompanionTalent.SWORD)) + return; + talents.put(talent, exp + talents.get(talent)); + } - public void setExp(EnumCompanionTalent talent, int exp) { - talents.put(talent, exp); - } + public int getExp(EnumCompanionTalent talent) { + if (talents.containsKey(talent)) + return talents.get(talent); + return -1; + } - private boolean isWeapon(ItemStack item) { - if(item == null || item.getItem() == null) - return false; - return item.getItem() instanceof ItemSword || - item.getItem() instanceof ItemBow || - item.getItem() == Item.getItemFromBlock(Blocks.cobblestone); - } + public void setExp(EnumCompanionTalent talent, int exp) { + talents.put(talent, exp); + } - public boolean canWearWeapon(ItemStack item){ - if(item == null || item.getItem() == null) - return false; + private boolean isWeapon(ItemStack item) { + if (item == null || item.getItem() == null) + return false; + return item.getItem() instanceof ItemSword || + item.getItem() instanceof ItemBow || + item.getItem() == Item.getItemFromBlock(Blocks.cobblestone); + } - if(item.getItem() instanceof ItemSword) - return canWearSword(item); + public boolean canWearWeapon(ItemStack item) { + if (item == null || item.getItem() == null) + return false; - if(item.getItem() instanceof ItemBow) - return this.getTalentLevel(EnumCompanionTalent.RANGED) > 2; + if (item.getItem() instanceof ItemSword) + return canWearSword(item); - if(item.getItem() == Item.getItemFromBlock(Blocks.cobblestone)) - return this.getTalentLevel(EnumCompanionTalent.RANGED) > 1; + if (item.getItem() instanceof ItemBow) + return this.getTalentLevel(EnumCompanionTalent.RANGED) > 2; - return false; - } + if (item.getItem() == Item.getItemFromBlock(Blocks.cobblestone)) + return this.getTalentLevel(EnumCompanionTalent.RANGED) > 1; - public boolean canWearArmor(ItemStack item){ - int level = getTalentLevel(EnumCompanionTalent.ARMOR); - if(item == null || !(item.getItem() instanceof ItemArmor) || level <= 0) - return false; + return false; + } - if(level >= 5) - return true; + public boolean canWearArmor(ItemStack item) { + int level = getTalentLevel(EnumCompanionTalent.ARMOR); + if (item == null || !(item.getItem() instanceof ItemArmor) || level <= 0) + return false; - ItemArmor armor = (ItemArmor) item.getItem(); - int reduction = ObfuscationReflectionHelper.getPrivateValue(ArmorMaterial.class, armor.getArmorMaterial(), 5); - if(reduction <= 5 && level >= 1) - return true; - if(reduction <= 7 && level >= 2) - return true; - if(reduction <= 15 && level >= 3) - return true; - if(reduction <= 33 && level >= 4) - return true; - return false; - } - public boolean canWearSword(ItemStack item){ - int level = getTalentLevel(EnumCompanionTalent.SWORD); - if(item == null || !(item.getItem() instanceof ItemSword) || level <= 0) - return false; - if(level >= 5) - return true; - return getSwordDamage(item) - level < 4; - } + if (level >= 5) + return true; - private double getSwordDamage(ItemStack item){ - if(item == null || !(item.getItem() instanceof ItemSword)) - return 0; - HashMultimap map = (HashMultimap) item.getAttributeModifiers(); + ItemArmor armor = (ItemArmor) item.getItem(); + int reduction = ObfuscationReflectionHelper.getPrivateValue(ArmorMaterial.class, armor.getArmorMaterial(), 5); + if (reduction <= 5 && level >= 1) + return true; + if (reduction <= 7 && level >= 2) + return true; + if (reduction <= 15 && level >= 3) + return true; + if (reduction <= 33 && level >= 4) + return true; + return false; + } + + public boolean canWearSword(ItemStack item) { + int level = getTalentLevel(EnumCompanionTalent.SWORD); + if (item == null || !(item.getItem() instanceof ItemSword) || level <= 0) + return false; + if (level >= 5) + return true; + return getSwordDamage(item) - level < 4; + } + + private double getSwordDamage(ItemStack item) { + if (item == null || !(item.getItem() instanceof ItemSword)) + return 0; + HashMultimap map = (HashMultimap) item.getAttributeModifiers(); Iterator iterator = map.entries().iterator(); - while (iterator.hasNext()) - { - Entry entry = (Entry)iterator.next(); - if(entry.getKey().equals(SharedMonsterAttributes.attackDamage.getAttributeUnlocalizedName())){ + while (iterator.hasNext()) { + Entry entry = (Entry) iterator.next(); + if (entry.getKey().equals(SharedMonsterAttributes.attackDamage.getAttributeUnlocalizedName())) { AttributeModifier mod = (AttributeModifier) entry.getValue(); return mod.getAmount(); } } - return 0; - } + return 0; + } - public void setStats(){ - ItemStack weapon = npc.inventory.getWeapon(); - npc.stats.setAttackStrength((float) (1 + getSwordDamage(weapon))); - npc.stats.healthRegen = 0; - npc.stats.combatRegen = 0; - int ranged = getTalentLevel(EnumCompanionTalent.RANGED); - if(ranged > 0 && weapon != null){ - if(ranged > 0 && weapon.getItem() == Item.getItemFromBlock(Blocks.cobblestone)){ - npc.inventory.setProjectile(weapon); - } - if(ranged > 0 && weapon.getItem() instanceof ItemBow){ - npc.inventory.setProjectile(new ItemStack(Items.arrow)); - } - } + public void setStats() { + ItemStack weapon = npc.inventory.getWeapon(); + npc.stats.setAttackStrength((float) (1 + getSwordDamage(weapon))); + npc.stats.healthRegen = 0; + npc.stats.combatRegen = 0; + int ranged = getTalentLevel(EnumCompanionTalent.RANGED); + if (ranged > 0 && weapon != null) { + if (ranged > 0 && weapon.getItem() == Item.getItemFromBlock(Blocks.cobblestone)) { + npc.inventory.setProjectile(weapon); + } + if (ranged > 0 && weapon.getItem() instanceof ItemBow) { + npc.inventory.setProjectile(new ItemStack(Items.arrow)); + } + } - inventory.setSize(2 + getTalentLevel(EnumCompanionTalent.INVENTORY) * 2); - } + inventory.setSize(2 + getTalentLevel(EnumCompanionTalent.INVENTORY) * 2); + } - public void setSelfsuficient(boolean bo){ - if(owner == null || jobInterface != null && bo == jobInterface.isSelfSufficient()) - return; - PlayerData data = PlayerDataController.Instance.getPlayerData(owner); - if(!bo && data.hasCompanion()) - return; - data.setCompanion(bo?null:npc); - if(job == EnumCompanionJobs.GUARD) - ((CompanionGuard)jobInterface).isStanding = bo; - else if(job == EnumCompanionJobs.FARMER) - ((CompanionFarmer)jobInterface).isStanding = bo; + public void setSelfsuficient(boolean bo) { + if (owner == null || jobInterface != null && bo == jobInterface.isSelfSufficient()) + return; + PlayerData data = PlayerDataController.Instance.getPlayerData(owner); + if (!bo && data.hasCompanion()) + return; + data.setCompanion(bo ? null : npc); + if (job == EnumCompanionJobs.GUARD) + ((CompanionGuard) jobInterface).isStanding = bo; + else if (job == EnumCompanionJobs.FARMER) + ((CompanionFarmer) jobInterface).isStanding = bo; - } + } - public void setSitting(boolean sit){ - if(sit){ - npc.ais.animationType = EnumAnimation.SITTING; - npc.ais.onAttack = 3; - npc.ais.startPos = new int[]{MathHelper.floor_double(npc.posX), - MathHelper.floor_double(npc.posY), MathHelper.floor_double(npc.posZ)}; - npc.getNavigator().clearPathEntity(); - npc.setPositionAndUpdate(npc.ais.startPos[0] + 0.5, npc.posY, npc.ais.startPos[2] + 0.5); - } - else{ - npc.ais.animationType = stage.animation; - npc.ais.onAttack = 0; - } - npc.setResponse(); - } + public void setSitting(boolean sit) { + if (sit) { + npc.ais.animationType = EnumAnimation.SITTING; + npc.ais.onAttack = 3; + npc.ais.startPos = new int[]{MathHelper.floor_double(npc.posX), + MathHelper.floor_double(npc.posY), MathHelper.floor_double(npc.posZ)}; + npc.getNavigator().clearPathEntity(); + npc.setPositionAndUpdate(npc.ais.startPos[0] + 0.5, npc.posY, npc.ais.startPos[2] + 0.5); + } else { + npc.ais.animationType = stage.animation; + npc.ais.onAttack = 0; + } + npc.setResponse(); + } - public boolean isSitting(){ - return npc.ais.animationType == EnumAnimation.SITTING; - } + public boolean isSitting() { + return npc.ais.animationType == EnumAnimation.SITTING; + } - public float applyArmorCalculations(DamageSource source, float damage) { - if(!hasInv || getTalentLevel(EnumCompanionTalent.ARMOR) <=0) - return damage; - if (!source.isUnblockable()){ - damageArmor(damage); + public float applyArmorCalculations(DamageSource source, float damage) { + if (!hasInv || getTalentLevel(EnumCompanionTalent.ARMOR) <= 0) + return damage; + if (!source.isUnblockable()) { + damageArmor(damage); int i = 25 - getTotalArmorValue(); - float f1 = damage * (float)i; + float f1 = damage * (float) i; damage = f1 / 25.0F; } - return damage; - } + return damage; + } - private void damageArmor(float damage){ + private void damageArmor(float damage) { damage /= 4.0F; - if (damage < 1.0F){ + if (damage < 1.0F) { damage = 1.0F; } boolean hasArmor = false; - Iterator> ita = npc.inventory.armor.entrySet().iterator(); - while(ita.hasNext()){ - Entry entry = ita.next(); - ItemStack item = entry.getValue(); - if(item == null || !(item.getItem() instanceof ItemArmor)) - continue; - hasArmor = true; - item.damageItem((int)damage, npc); - if(item.stackSize <= 0) - ita.remove(); + Iterator> ita = npc.inventory.armor.entrySet().iterator(); + while (ita.hasNext()) { + Entry entry = ita.next(); + ItemStack item = entry.getValue(); + if (item == null || !(item.getItem() instanceof ItemArmor)) + continue; + hasArmor = true; + item.damageItem((int) damage, npc); + if (item.stackSize <= 0) + ita.remove(); } - this.gainExp(hasArmor?4:8); + this.gainExp(hasArmor ? 4 : 8); } - public int getTotalArmorValue(){ - int armorValue = 0; - for(ItemStack armor : npc.inventory.getArmor().values()){ - if(armor != null && armor.getItem() instanceof ItemArmor) - armorValue += ((ItemArmor)armor.getItem()).damageReduceAmount; - } - return armorValue; - } + public int getTotalArmorValue() { + int armorValue = 0; + for (ItemStack armor : npc.inventory.getArmor().values()) { + if (armor != null && armor.getItem() instanceof ItemArmor) + armorValue += ((ItemArmor) armor.getItem()).damageReduceAmount; + } + return armorValue; + } - public boolean isFollowing(){ - if(jobInterface != null && jobInterface.isSelfSufficient()) - return false; - return owner != null && !isSitting(); - } + public boolean isFollowing() { + if (jobInterface != null && jobInterface.isSelfSufficient()) + return false; + return owner != null && !isSitting(); + } - @Override - public boolean defendOwner() { - if(!defendOwner || owner == null || stage == EnumCompanionStage.BABY || jobInterface != null && jobInterface.isSelfSufficient()) - return false; - return true; - } + @Override + public boolean defendOwner() { + if (!defendOwner || owner == null || stage == EnumCompanionStage.BABY || jobInterface != null && jobInterface.isSelfSufficient()) + return false; + return true; + } - public int followRange() { - return 9 + 12 * stage.ordinal(); + public int followRange() { + return 9 + 12 * stage.ordinal(); - } + } - public boolean hasOwner() { - return !uuid.isEmpty(); - } + public boolean hasOwner() { + return !uuid.isEmpty(); + } - public void addMovementStat(double x, double y, double z) { + public void addMovementStat(double x, double y, double z) { int i = Math.round(MathHelper.sqrt_double(x * x + y * y + z * z) * 100.0F); - if(npc.isAttacking()) - foodstats.addExhaustion(0.04F * (float)i * 0.01F); + if (npc.isAttacking()) + foodstats.addExhaustion(0.04F * (float) i * 0.01F); else - foodstats.addExhaustion(0.02F * (float)i * 0.01F); - } - - private ItemStack getFood(){ - List food = new ArrayList(inventory.items.values()); - Iterator ite = food.iterator(); - int i = -1; - while(ite.hasNext()){ - ItemStack is = ite.next(); - if(is == null || !(is.getItem() instanceof ItemFood)){ - ite.remove(); - continue; - } - int amount = ((ItemFood) is.getItem()).func_150905_g(is); - if(i == -1 || amount < i) - i = amount; - } - for(ItemStack is : food){ - if(((ItemFood)is.getItem()).func_150905_g(is) == i) - return is; - } - return null; + foodstats.addExhaustion(0.02F * (float) i * 0.01F); } - public ItemStack getHeldItem() { - if(eating != null) - return eating; - return npc.inventory.getWeapon(); - } + private ItemStack getFood() { + List food = new ArrayList(inventory.items.values()); + Iterator ite = food.iterator(); + int i = -1; + while (ite.hasNext()) { + ItemStack is = ite.next(); + if (is == null || !(is.getItem() instanceof ItemFood)) { + ite.remove(); + continue; + } + int amount = ((ItemFood) is.getItem()).func_150905_g(is); + if (i == -1 || amount < i) + i = amount; + } + for (ItemStack is : food) { + if (((ItemFood) is.getItem()).func_150905_g(is) == i) + return is; + } + return null; + } - public boolean isEating() { - return eating != null; - } + public ItemStack getHeldItem() { + if (eating != null) + return eating; + return npc.inventory.getWeapon(); + } - public boolean hasInv() { - if(!hasInv) - return false; - return hasTalent(EnumCompanionTalent.INVENTORY) || hasTalent(EnumCompanionTalent.ARMOR) || hasTalent(EnumCompanionTalent.SWORD); - } + public boolean isEating() { + return eating != null; + } - public void attackedEntity(Entity entity) { - ItemStack weapon = npc.inventory.getWeapon(); - gainExp(weapon == null?8:4); - if(weapon == null) - return; - weapon.damageItem(1, npc); - if(weapon.stackSize <= 0) - npc.inventory.setWeapon(null); - } + public boolean hasInv() { + if (!hasInv) + return false; + return hasTalent(EnumCompanionTalent.INVENTORY) || hasTalent(EnumCompanionTalent.ARMOR) || hasTalent(EnumCompanionTalent.SWORD); + } - public void addTalentExp(EnumCompanionTalent talent, int exp) { - if(talents.containsKey(talent)) - exp += talents.get(talent); - talents.put(talent, exp); - } + public void attackedEntity(Entity entity) { + ItemStack weapon = npc.inventory.getWeapon(); + gainExp(weapon == null ? 8 : 4); + if (weapon == null) + return; + weapon.damageItem(1, npc); + if (weapon.stackSize <= 0) + npc.inventory.setWeapon(null); + } + + public void addTalentExp(EnumCompanionTalent talent, int exp) { + if (talents.containsKey(talent)) + exp += talents.get(talent); + talents.put(talent, exp); + } } diff --git a/src/main/java/noppes/npcs/roles/RoleFollower.java b/src/main/java/noppes/npcs/roles/RoleFollower.java index 3927088ad..f87f8f207 100644 --- a/src/main/java/noppes/npcs/roles/RoleFollower.java +++ b/src/main/java/noppes/npcs/roles/RoleFollower.java @@ -16,177 +16,177 @@ import java.util.HashMap; import java.util.UUID; public class RoleFollower extends RoleInterface { - - private String ownerUUID; - public boolean isFollowing = true; - public HashMap rates; - public NpcMiscInventory inventory; - public String dialogHire = StatCollector.translateToLocal("follower.hireText") + " {days} " + StatCollector.translateToLocal("follower.days"); - public String dialogFarewell = StatCollector.translateToLocal("follower.farewellText") + " {player}"; - public int daysHired; - public long hiredTime; - public boolean disableGui = false; - public boolean infiniteDays = false; - public boolean refuseSoulStone = false; - - public EntityPlayer owner = null; - - public RoleFollower(EntityNPCInterface npc) { - super(npc); - inventory = new NpcMiscInventory(3); - rates = new HashMap(); - } - @Override - public NBTTagCompound writeToNBT(NBTTagCompound nbttagcompound) { - nbttagcompound.setInteger("MercenaryDaysHired", daysHired); - nbttagcompound.setLong("MercenaryHiredTime", hiredTime); - nbttagcompound.setString("MercenaryDialogHired", dialogHire); - nbttagcompound.setString("MercenaryDialogFarewell", dialogFarewell); - if(hasOwner()) - nbttagcompound.setString("MercenaryOwner", ownerUUID); - nbttagcompound.setTag("MercenaryDayRates", NBTTags.nbtIntegerIntegerMap(rates)); - nbttagcompound.setTag("MercenaryInv", inventory.getToNBT()); - nbttagcompound.setBoolean("MercenaryIsFollowing", isFollowing); - nbttagcompound.setBoolean("MercenaryDisableGui", disableGui); - nbttagcompound.setBoolean("MercenaryInfiniteDays", infiniteDays); - nbttagcompound.setBoolean("MercenaryRefuseSoulstone", refuseSoulStone); - return nbttagcompound; - } + private String ownerUUID; + public boolean isFollowing = true; + public HashMap rates; + public NpcMiscInventory inventory; + public String dialogHire = StatCollector.translateToLocal("follower.hireText") + " {days} " + StatCollector.translateToLocal("follower.days"); + public String dialogFarewell = StatCollector.translateToLocal("follower.farewellText") + " {player}"; + public int daysHired; + public long hiredTime; + public boolean disableGui = false; + public boolean infiniteDays = false; + public boolean refuseSoulStone = false; - @Override - public void readFromNBT(NBTTagCompound nbttagcompound) { - ownerUUID = nbttagcompound.getString("MercenaryOwner"); - daysHired = nbttagcompound.getInteger("MercenaryDaysHired"); - hiredTime = nbttagcompound.getLong("MercenaryHiredTime"); - dialogHire = nbttagcompound.getString("MercenaryDialogHired"); - dialogFarewell = nbttagcompound.getString("MercenaryDialogFarewell"); - rates = NBTTags.getIntegerIntegerMap(nbttagcompound.getTagList("MercenaryDayRates", 10)); - inventory.setFromNBT(nbttagcompound.getCompoundTag("MercenaryInv")); - isFollowing = nbttagcompound.getBoolean("MercenaryIsFollowing"); - disableGui = nbttagcompound.getBoolean("MercenaryDisableGui"); - infiniteDays = nbttagcompound.getBoolean("MercenaryInfiniteDays"); - refuseSoulStone = nbttagcompound.getBoolean("MercenaryRefuseSoulstone"); - } + public EntityPlayer owner = null; - @Override - public boolean aiShouldExecute() { - owner = getOwner(); - if(!infiniteDays && owner != null && getDaysLeft() <= 0){ - owner.addChatMessage(new ChatComponentTranslation(NoppesStringUtils.formatText(dialogFarewell, owner, npc))); - killed(); - } - return false; - } - - public EntityPlayer getOwner(){ - if(ownerUUID == null || ownerUUID.isEmpty()) - return null; - try{ - UUID uuid = UUID.fromString(ownerUUID); - if(uuid != null) - return npc.worldObj.func_152378_a(uuid); - } - catch(IllegalArgumentException ex){ - - } - - return npc.worldObj.getPlayerEntityByName(ownerUUID); - } - public boolean hasOwner(){ - if(!infiniteDays && daysHired <= 0) - return false; - return ownerUUID != null && !ownerUUID.isEmpty(); - } - @Override - public void killed() { - ownerUUID = null; - daysHired = 0; - hiredTime = 0; - isFollowing = true; - npc.stats.canDespawn = npc.stats.playerSetCanDespawn; - } - - public int getDaysLeft(){ - if(infiniteDays) - return 100; - if(daysHired <= 0) - return 0; - int days = (int) ((npc.worldObj.getTotalWorldTime()- hiredTime) / 24000); - return daysHired - days; - } - - public void addDays(int days) { - daysHired = days + getDaysLeft(); - hiredTime = npc.worldObj.getTotalWorldTime(); - } - - @Override - public void interact(EntityPlayer player) { - if(ownerUUID == null || ownerUUID.isEmpty()){ - npc.say(player, npc.advanced.getInteractLine()); - NoppesUtilServer.sendOpenGui(player, EnumGuiType.PlayerFollowerHire, npc); - } - else if(player == owner && !disableGui){ - NoppesUtilServer.sendOpenGui(player, EnumGuiType.PlayerFollower, npc); - } - } - - @Override - public boolean defendOwner() { - return isFollowing() && npc.advanced.job == EnumJobType.Guard; - } + public RoleFollower(EntityNPCInterface npc) { + super(npc); + inventory = new NpcMiscInventory(3); + rates = new HashMap(); + } - @Override - public void delete() { - - } - - public boolean isFollowing(){ - return owner != null && isFollowing && getDaysLeft() > 0; - } + @Override + public NBTTagCompound writeToNBT(NBTTagCompound nbttagcompound) { + nbttagcompound.setInteger("MercenaryDaysHired", daysHired); + nbttagcompound.setLong("MercenaryHiredTime", hiredTime); + nbttagcompound.setString("MercenaryDialogHired", dialogHire); + nbttagcompound.setString("MercenaryDialogFarewell", dialogFarewell); + if (hasOwner()) + nbttagcompound.setString("MercenaryOwner", ownerUUID); + nbttagcompound.setTag("MercenaryDayRates", NBTTags.nbtIntegerIntegerMap(rates)); + nbttagcompound.setTag("MercenaryInv", inventory.getToNBT()); + nbttagcompound.setBoolean("MercenaryIsFollowing", isFollowing); + nbttagcompound.setBoolean("MercenaryDisableGui", disableGui); + nbttagcompound.setBoolean("MercenaryInfiniteDays", infiniteDays); + nbttagcompound.setBoolean("MercenaryRefuseSoulstone", refuseSoulStone); + return nbttagcompound; + } - public void setOwner(EntityPlayer player) { - UUID id = player.getUniqueID(); - if(ownerUUID == null || id == null || !ownerUUID.equals(id)) - killed(); - ownerUUID = id.toString(); - npc.stats.canDespawn = false; - } + @Override + public void readFromNBT(NBTTagCompound nbttagcompound) { + ownerUUID = nbttagcompound.getString("MercenaryOwner"); + daysHired = nbttagcompound.getInteger("MercenaryDaysHired"); + hiredTime = nbttagcompound.getLong("MercenaryHiredTime"); + dialogHire = nbttagcompound.getString("MercenaryDialogHired"); + dialogFarewell = nbttagcompound.getString("MercenaryDialogFarewell"); + rates = NBTTags.getIntegerIntegerMap(nbttagcompound.getTagList("MercenaryDayRates", 10)); + inventory.setFromNBT(nbttagcompound.getCompoundTag("MercenaryInv")); + isFollowing = nbttagcompound.getBoolean("MercenaryIsFollowing"); + disableGui = nbttagcompound.getBoolean("MercenaryDisableGui"); + infiniteDays = nbttagcompound.getBoolean("MercenaryInfiniteDays"); + refuseSoulStone = nbttagcompound.getBoolean("MercenaryRefuseSoulstone"); + } - public void setRate(int index, int amount) { - if(index > 2 || index < 0) - return; + @Override + public boolean aiShouldExecute() { + owner = getOwner(); + if (!infiniteDays && owner != null && getDaysLeft() <= 0) { + owner.addChatMessage(new ChatComponentTranslation(NoppesStringUtils.formatText(dialogFarewell, owner, npc))); + killed(); + } + return false; + } - if(amount < 1) - return; + public EntityPlayer getOwner() { + if (ownerUUID == null || ownerUUID.isEmpty()) + return null; + try { + UUID uuid = UUID.fromString(ownerUUID); + if (uuid != null) + return npc.worldObj.func_152378_a(uuid); + } catch (IllegalArgumentException ex) { - rates.put(index, amount); - } + } - public int getRate(int index) { - if(index > 2 || index < 0) - return -1; + return npc.worldObj.getPlayerEntityByName(ownerUUID); + } - if(!rates.containsKey(index)) - return -1; + public boolean hasOwner() { + if (!infiniteDays && daysHired <= 0) + return false; + return ownerUUID != null && !ownerUUID.isEmpty(); + } - return rates.get(index); - } + @Override + public void killed() { + ownerUUID = null; + daysHired = 0; + hiredTime = 0; + isFollowing = true; + npc.stats.canDespawn = npc.stats.playerSetCanDespawn; + } - public void setDialogHire(String dialogHire) { - this.dialogHire = dialogHire; - } + public int getDaysLeft() { + if (infiniteDays) + return 100; + if (daysHired <= 0) + return 0; + int days = (int) ((npc.worldObj.getTotalWorldTime() - hiredTime) / 24000); + return daysHired - days; + } - public String getDialogHire() { - return dialogHire; - } + public void addDays(int days) { + daysHired = days + getDaysLeft(); + hiredTime = npc.worldObj.getTotalWorldTime(); + } - public void setDialogFarewell(String dialogFarewell){ - this.dialogFarewell = dialogFarewell; - } + @Override + public void interact(EntityPlayer player) { + if (ownerUUID == null || ownerUUID.isEmpty()) { + npc.say(player, npc.advanced.getInteractLine()); + NoppesUtilServer.sendOpenGui(player, EnumGuiType.PlayerFollowerHire, npc); + } else if (player == owner && !disableGui) { + NoppesUtilServer.sendOpenGui(player, EnumGuiType.PlayerFollower, npc); + } + } - public String getDialogFarewell(){ - return this.dialogFarewell; - } + @Override + public boolean defendOwner() { + return isFollowing() && npc.advanced.job == EnumJobType.Guard; + } + + @Override + public void delete() { + + } + + public boolean isFollowing() { + return owner != null && isFollowing && getDaysLeft() > 0; + } + + public void setOwner(EntityPlayer player) { + UUID id = player.getUniqueID(); + if (ownerUUID == null || id == null || !ownerUUID.equals(id)) + killed(); + ownerUUID = id.toString(); + npc.stats.canDespawn = false; + } + + public void setRate(int index, int amount) { + if (index > 2 || index < 0) + return; + + if (amount < 1) + return; + + rates.put(index, amount); + } + + public int getRate(int index) { + if (index > 2 || index < 0) + return -1; + + if (!rates.containsKey(index)) + return -1; + + return rates.get(index); + } + + public void setDialogHire(String dialogHire) { + this.dialogHire = dialogHire; + } + + public String getDialogHire() { + return dialogHire; + } + + public void setDialogFarewell(String dialogFarewell) { + this.dialogFarewell = dialogFarewell; + } + + public String getDialogFarewell() { + return this.dialogFarewell; + } } diff --git a/src/main/java/noppes/npcs/roles/RoleInnkeeper.java b/src/main/java/noppes/npcs/roles/RoleInnkeeper.java index d910af254..8e930f28c 100644 --- a/src/main/java/noppes/npcs/roles/RoleInnkeeper.java +++ b/src/main/java/noppes/npcs/roles/RoleInnkeeper.java @@ -10,71 +10,69 @@ import noppes.npcs.entity.EntityNPCInterface; import java.util.HashMap; -public class RoleInnkeeper extends RoleInterface{ - - private String innName = "Inn"; - private HashMap doors = new HashMap(); - - public RoleInnkeeper(EntityNPCInterface npc) { - super(npc); - } +public class RoleInnkeeper extends RoleInterface { - @Override - public NBTTagCompound writeToNBT(NBTTagCompound nbttagcompound) { - nbttagcompound.setString("InnName", innName); - nbttagcompound.setTag("InnDoors", nbtInnDoors(doors)); - return nbttagcompound; - } + private String innName = "Inn"; + private HashMap doors = new HashMap(); - private NBTBase nbtInnDoors(HashMap doors1) { + public RoleInnkeeper(EntityNPCInterface npc) { + super(npc); + } + + @Override + public NBTTagCompound writeToNBT(NBTTagCompound nbttagcompound) { + nbttagcompound.setString("InnName", innName); + nbttagcompound.setTag("InnDoors", nbtInnDoors(doors)); + return nbttagcompound; + } + + private NBTBase nbtInnDoors(HashMap doors1) { NBTTagList nbttaglist = new NBTTagList(); - if(doors1 == null) - return nbttaglist; - HashMap doors2 = doors1; - for(String name : doors2.keySet()) - { - InnDoorData door = doors2.get(name); - if(door == null) - continue; + if (doors1 == null) + return nbttaglist; + HashMap doors2 = doors1; + for (String name : doors2.keySet()) { + InnDoorData door = doors2.get(name); + if (door == null) + continue; NBTTagCompound nbttagcompound = new NBTTagCompound(); nbttagcompound.setString("Name", name); nbttagcompound.setInteger("posX", door.x); nbttagcompound.setInteger("posY", door.y); nbttagcompound.setInteger("posZ", door.z); - + nbttaglist.appendTag(nbttagcompound); } return nbttaglist; - } + } - @Override - public void readFromNBT(NBTTagCompound nbttagcompound) { - innName = nbttagcompound.getString("InnName"); - doors = getInnDoors(nbttagcompound.getTagList("InnDoors", 10)); - } + @Override + public void readFromNBT(NBTTagCompound nbttagcompound) { + innName = nbttagcompound.getString("InnName"); + doors = getInnDoors(nbttagcompound.getTagList("InnDoors", 10)); + } - private HashMap getInnDoors(NBTTagList tagList) { - HashMap list = new HashMap(); - for(int i = 0; i < tagList.tagCount(); i++) - { + private HashMap getInnDoors(NBTTagList tagList) { + HashMap list = new HashMap(); + for (int i = 0; i < tagList.tagCount(); i++) { NBTTagCompound nbttagcompound = tagList.getCompoundTagAt(i); String name = nbttagcompound.getString("Name"); - + InnDoorData door = new InnDoorData(); door.x = nbttagcompound.getInteger("posX"); door.y = nbttagcompound.getInteger("posY"); door.z = nbttagcompound.getInteger("posZ"); list.put(name, door); } - return list; - } + return list; + } - @Override - public void interact(EntityPlayer player) { - npc.say(player, npc.advanced.getInteractLine()); - if(doors.isEmpty()){ - player.addChatMessage(new ChatComponentTranslation("No Rooms available")); - } - } + @Override + public void interact(EntityPlayer player) { + npc.say(player, npc.advanced.getInteractLine()); + if (doors.isEmpty()) { + player.addChatMessage(new ChatComponentTranslation("No Rooms available")); + } + } } diff --git a/src/main/java/noppes/npcs/roles/RoleInterface.java b/src/main/java/noppes/npcs/roles/RoleInterface.java index 0c7c42ecf..ba62d199d 100644 --- a/src/main/java/noppes/npcs/roles/RoleInterface.java +++ b/src/main/java/noppes/npcs/roles/RoleInterface.java @@ -7,30 +7,48 @@ import noppes.npcs.entity.EntityNPCInterface; import java.util.HashMap; public abstract class RoleInterface { - public EntityNPCInterface npc; - public HashMap dataString = new HashMap(); - public RoleInterface(EntityNPCInterface npc){ - this.npc = npc; - } - public abstract NBTTagCompound writeToNBT(NBTTagCompound compound); - public abstract void readFromNBT(NBTTagCompound compound); - public abstract void interact(EntityPlayer player); - public void killed(){}; - public void delete(){}; - - public boolean aiShouldExecute() { - return false; - } - - public boolean aiContinueExecute() { - return false; - } - public void aiStartExecuting() {} - public void aiUpdateTask() {} - public boolean defendOwner() { - return false; - } - public void clientUpdate() { - - } + public EntityNPCInterface npc; + public HashMap dataString = new HashMap(); + + public RoleInterface(EntityNPCInterface npc) { + this.npc = npc; + } + + public abstract NBTTagCompound writeToNBT(NBTTagCompound compound); + + public abstract void readFromNBT(NBTTagCompound compound); + + public abstract void interact(EntityPlayer player); + + public void killed() { + } + + ; + + public void delete() { + } + + ; + + public boolean aiShouldExecute() { + return false; + } + + public boolean aiContinueExecute() { + return false; + } + + public void aiStartExecuting() { + } + + public void aiUpdateTask() { + } + + public boolean defendOwner() { + return false; + } + + public void clientUpdate() { + + } } diff --git a/src/main/java/noppes/npcs/roles/RolePostman.java b/src/main/java/noppes/npcs/roles/RolePostman.java index e11a9594a..3d6da3e9d 100644 --- a/src/main/java/noppes/npcs/roles/RolePostman.java +++ b/src/main/java/noppes/npcs/roles/RolePostman.java @@ -12,49 +12,49 @@ import noppes.npcs.entity.EntityNPCInterface; import java.util.ArrayList; import java.util.List; -public class RolePostman extends RoleInterface{ +public class RolePostman extends RoleInterface { - public NpcMiscInventory inventory = new NpcMiscInventory(1); - private List recentlyChecked = new ArrayList(); - private List toCheck; - - public RolePostman(EntityNPCInterface npc) { - super(npc); - } + public NpcMiscInventory inventory = new NpcMiscInventory(1); + private List recentlyChecked = new ArrayList(); + private List toCheck; - public boolean aiShouldExecute() { - if(npc.ticksExisted % 20 != 0) - return false; + public RolePostman(EntityNPCInterface npc) { + super(npc); + } - toCheck = npc.worldObj.getEntitiesWithinAABB(EntityPlayer.class, npc.boundingBox.expand(10, 10, 10)); - toCheck.removeAll(recentlyChecked); + public boolean aiShouldExecute() { + if (npc.ticksExisted % 20 != 0) + return false; - List listMax = npc.worldObj.getEntitiesWithinAABB(EntityPlayer.class, npc.boundingBox.expand(20, 20, 20)); - recentlyChecked.retainAll(listMax); - recentlyChecked.addAll(toCheck); - - for(EntityPlayer player : toCheck){ - if(PlayerDataController.Instance.hasMail(player)) - player.addChatMessage(new ChatComponentTranslation("You've got mail")); - } - return false; - } - - @Override - public NBTTagCompound writeToNBT(NBTTagCompound nbttagcompound) { - nbttagcompound.setTag("PostInv", inventory.getToNBT()); - return nbttagcompound; - } + toCheck = npc.worldObj.getEntitiesWithinAABB(EntityPlayer.class, npc.boundingBox.expand(10, 10, 10)); + toCheck.removeAll(recentlyChecked); - @Override - public void readFromNBT(NBTTagCompound nbttagcompound) { - inventory.setFromNBT(nbttagcompound.getCompoundTag("PostInv")); - } + List listMax = npc.worldObj.getEntitiesWithinAABB(EntityPlayer.class, npc.boundingBox.expand(20, 20, 20)); + recentlyChecked.retainAll(listMax); + recentlyChecked.addAll(toCheck); + + for (EntityPlayer player : toCheck) { + if (PlayerDataController.Instance.hasMail(player)) + player.addChatMessage(new ChatComponentTranslation("You've got mail")); + } + return false; + } + + @Override + public NBTTagCompound writeToNBT(NBTTagCompound nbttagcompound) { + nbttagcompound.setTag("PostInv", inventory.getToNBT()); + return nbttagcompound; + } + + @Override + public void readFromNBT(NBTTagCompound nbttagcompound) { + inventory.setFromNBT(nbttagcompound.getCompoundTag("PostInv")); + } - @Override - public void interact(EntityPlayer player) { - player.openGui(CustomNpcs.instance, EnumGuiType.PlayerMailman.ordinal(), player.worldObj, 1, 1, 0); - } + @Override + public void interact(EntityPlayer player) { + player.openGui(CustomNpcs.instance, EnumGuiType.PlayerMailman.ordinal(), player.worldObj, 1, 1, 0); + } } diff --git a/src/main/java/noppes/npcs/roles/RoleTrader.java b/src/main/java/noppes/npcs/roles/RoleTrader.java index fa5ae40bc..5275c26c0 100644 --- a/src/main/java/noppes/npcs/roles/RoleTrader.java +++ b/src/main/java/noppes/npcs/roles/RoleTrader.java @@ -18,124 +18,124 @@ import java.util.logging.Logger; public class RoleTrader extends RoleInterface { public String marketName = ""; - public NpcMiscInventory inventoryCurrency; - public NpcMiscInventory inventorySold; + public NpcMiscInventory inventoryCurrency; + public NpcMiscInventory inventorySold; - public boolean ignoreDamage = false; - public boolean ignoreNBT = false; + public boolean ignoreDamage = false; + public boolean ignoreNBT = false; public boolean recordHistory = false; - public int[] purchases; - public int[] disableSlot; - public HashMap playerPurchases; - public HashMap playerDisableSlot; + public int[] purchases; + public int[] disableSlot; + public HashMap playerPurchases; + public HashMap playerDisableSlot; - public RoleTrader(EntityNPCInterface npc) { - super(npc); - inventoryCurrency = new NpcMiscInventory(36); - inventorySold = new NpcMiscInventory(18); - purchases = new int[18]; - disableSlot = new int[18]; - playerPurchases = new HashMap(); - playerDisableSlot = new HashMap(); - } + public RoleTrader(EntityNPCInterface npc) { + super(npc); + inventoryCurrency = new NpcMiscInventory(36); + inventorySold = new NpcMiscInventory(18); + purchases = new int[18]; + disableSlot = new int[18]; + playerPurchases = new HashMap(); + playerDisableSlot = new HashMap(); + } - @Override - public NBTTagCompound writeToNBT(NBTTagCompound nbttagcompound) { + @Override + public NBTTagCompound writeToNBT(NBTTagCompound nbttagcompound) { nbttagcompound.setString("TraderMarket", marketName); - writeNBT(nbttagcompound); + writeNBT(nbttagcompound); return nbttagcompound; - } + } - public NBTTagCompound writeNBT(NBTTagCompound nbttagcompound) { - nbttagcompound.setTag("TraderCurrency", inventoryCurrency.getToNBT()); - nbttagcompound.setTag("TraderSold", inventorySold.getToNBT()); + public NBTTagCompound writeNBT(NBTTagCompound nbttagcompound) { + nbttagcompound.setTag("TraderCurrency", inventoryCurrency.getToNBT()); + nbttagcompound.setTag("TraderSold", inventorySold.getToNBT()); nbttagcompound.setBoolean("TraderIgnoreDamage", ignoreDamage); nbttagcompound.setBoolean("TraderIgnoreNBT", ignoreNBT); nbttagcompound.setBoolean("RecordHistory", recordHistory); nbttagcompound.setIntArray("DisableSlot", disableSlot); nbttagcompound.setTag("PlayerDisableSlot", NBTTags.nbtStringIntegerArrayMap(playerDisableSlot)); - if(recordHistory){ + if (recordHistory) { nbttagcompound.setIntArray("Purchases", purchases); nbttagcompound.setTag("PlayerPurchases", NBTTags.nbtStringIntegerArrayMap(playerPurchases)); } return nbttagcompound; - } + } - @Override - public void readFromNBT(NBTTagCompound nbttagcompound) { + @Override + public void readFromNBT(NBTTagCompound nbttagcompound) { marketName = nbttagcompound.getString("TraderMarket"); - readNBT(nbttagcompound); + readNBT(nbttagcompound); - try { - Market.getMarket(this, marketName); - } catch (Exception ex) { + try { + Market.getMarket(this, marketName); + } catch (Exception ex) { Logger.getLogger(getClass().getName()).log(Level.SEVERE, null, ex); - } - } + } + } - public void readNBT(NBTTagCompound nbttagcompound) { - inventoryCurrency.setFromNBT(nbttagcompound.getCompoundTag("TraderCurrency")); - inventorySold.setFromNBT(nbttagcompound.getCompoundTag("TraderSold")); + public void readNBT(NBTTagCompound nbttagcompound) { + inventoryCurrency.setFromNBT(nbttagcompound.getCompoundTag("TraderCurrency")); + inventorySold.setFromNBT(nbttagcompound.getCompoundTag("TraderSold")); ignoreDamage = nbttagcompound.getBoolean("TraderIgnoreDamage"); ignoreNBT = nbttagcompound.getBoolean("TraderIgnoreNBT"); recordHistory = nbttagcompound.getBoolean("RecordHistory"); disableSlot = nbttagcompound.getIntArray("DisableSlot"); playerDisableSlot = NBTTags.getStringIntegerArrayMap(nbttagcompound.getTagList("PlayerDisableSlot", 10), 18); - if(recordHistory){ + if (recordHistory) { purchases = nbttagcompound.getIntArray("Purchases"); playerPurchases = NBTTags.getStringIntegerArrayMap(nbttagcompound.getTagList("PlayerPurchases", 10), 18); } if (purchases == null || purchases.length != 18) { - purchases = new int[18]; - for (int i = 0; i < purchases.length; ++i) purchases[i] = 0; + purchases = new int[18]; + for (int i = 0; i < purchases.length; ++i) purchases[i] = 0; } if (disableSlot == null || disableSlot.length != 18) { - disableSlot = new int[18]; - for (int i = 0; i < disableSlot.length; ++i) disableSlot[i] = 0; + disableSlot = new int[18]; + for (int i = 0; i < disableSlot.length; ++i) disableSlot[i] = 0; } - } + } - @Override - public void interact(EntityPlayer player) { - npc.say(player, npc.advanced.getInteractLine()); + @Override + public void interact(EntityPlayer player) { + npc.say(player, npc.advanced.getInteractLine()); try { - Market.getMarket(this, marketName); + Market.getMarket(this, marketName); } catch (Exception ex) { Logger.getLogger(getClass().getName()).log(Level.SEVERE, null, ex); } - NoppesUtilServer.sendOpenGui(player, EnumGuiType.PlayerTrader, npc); - } + NoppesUtilServer.sendOpenGui(player, EnumGuiType.PlayerTrader, npc); + } - public boolean hasCurrency(ItemStack itemstack) { - if(itemstack == null) - return false; - for(ItemStack item : inventoryCurrency.items.values()){ - if(item != null && NoppesUtilPlayer.compareItems(item, itemstack, ignoreDamage, ignoreNBT)){ - return true; - } - } - return false; - } + public boolean hasCurrency(ItemStack itemstack) { + if (itemstack == null) + return false; + for (ItemStack item : inventoryCurrency.items.values()) { + if (item != null && NoppesUtilPlayer.compareItems(item, itemstack, ignoreDamage, ignoreNBT)) { + return true; + } + } + return false; + } - public void addPurchase(int slot, String playerName) { - if(slot >= 18 || slot < 0) return; - ++purchases[slot]; - ++getArrayByName(playerName, playerPurchases)[slot]; + public void addPurchase(int slot, String playerName) { + if (slot >= 18 || slot < 0) return; + ++purchases[slot]; + ++getArrayByName(playerName, playerPurchases)[slot]; - if(recordHistory) + if (recordHistory) Market.save(this, marketName); - } + } - public boolean isSlotEnabled(int slot, String playerName) { - if(slot >= 18 || slot < 0) return false; - if (disableSlot[slot] > 0) return false; - return getArrayByName(playerName, playerDisableSlot)[slot] <= 0; - } + public boolean isSlotEnabled(int slot, String playerName) { + if (slot >= 18 || slot < 0) return false; + if (disableSlot[slot] > 0) return false; + return getArrayByName(playerName, playerDisableSlot)[slot] <= 0; + } - public int[] getArrayByName(String name, HashMap map) { - map.computeIfAbsent(name, k -> new int[18]); - return map.get(name); - } + public int[] getArrayByName(String name, HashMap map) { + map.computeIfAbsent(name, k -> new int[18]); + return map.get(name); + } } diff --git a/src/main/java/noppes/npcs/roles/RoleTransporter.java b/src/main/java/noppes/npcs/roles/RoleTransporter.java index a910c3e01..40d16d294 100644 --- a/src/main/java/noppes/npcs/roles/RoleTransporter.java +++ b/src/main/java/noppes/npcs/roles/RoleTransporter.java @@ -14,90 +14,95 @@ import noppes.npcs.entity.EntityNPCInterface; import java.util.List; -public class RoleTransporter extends RoleInterface{ - - public int transportId = -1; - public String name; - - public RoleTransporter(EntityNPCInterface npc) { - super(npc); - } - +public class RoleTransporter extends RoleInterface { - @Override - public NBTTagCompound writeToNBT(NBTTagCompound nbttagcompound) { - nbttagcompound.setInteger("TransporterId", transportId); - return nbttagcompound; - } + public int transportId = -1; + public String name; - @Override - public void readFromNBT(NBTTagCompound nbttagcompound) { - transportId = nbttagcompound.getInteger("TransporterId"); - TransportLocation loc = getLocation(); - if(loc != null){ - name = loc.name; - } - } - private int ticks = 10; - @Override - public boolean aiShouldExecute() { - ticks--; - if(ticks > 0) - return false; - ticks = 10; - - if(!hasTransport()) - return false; - - TransportLocation loc = getLocation(); - if(loc.type != 0) - return false; + public RoleTransporter(EntityNPCInterface npc) { + super(npc); + } - List inRange = npc.worldObj.getEntitiesWithinAABB(EntityPlayer.class,npc.boundingBox.expand(6D, 6D, 6D)); - for(EntityPlayer player :inRange){ - if(!npc.canSee(player)) - continue; - unlock(player, loc); - } - return false; - - } - @Override - public void aiStartExecuting() { - - } - @Override - public void interact(EntityPlayer player) { - if(hasTransport()){ - TransportLocation loc = getLocation(); - if(loc.type == 2){ - unlock(player, loc); - } - NoppesUtilServer.sendOpenGui(player, EnumGuiType.PlayerTransporter, npc); - } - } - - public void unlock(EntityPlayer player, ITransportLocation loc){ - PlayerTransportData data = PlayerDataController.Instance.getPlayerData(player).transportData; - if(data.transports.contains(transportId)) - return; - data.transports.add(transportId); - player.addChatMessage(new ChatComponentTranslation("transporter.unlock", loc.getName())); - } - public TransportLocation getLocation(){ - if(npc.isRemote()) - return null; - return TransportController.getInstance().getTransport(transportId); - } - public boolean hasTransport(){ - TransportLocation loc = getLocation(); - return loc != null && loc.id == transportId; - } + @Override + public NBTTagCompound writeToNBT(NBTTagCompound nbttagcompound) { + nbttagcompound.setInteger("TransporterId", transportId); + return nbttagcompound; + } - public void setTransport(ITransportLocation location) { - transportId = location.getId(); - name = location.getName(); - } + @Override + public void readFromNBT(NBTTagCompound nbttagcompound) { + transportId = nbttagcompound.getInteger("TransporterId"); + TransportLocation loc = getLocation(); + if (loc != null) { + name = loc.name; + } + } + + private int ticks = 10; + + @Override + public boolean aiShouldExecute() { + ticks--; + if (ticks > 0) + return false; + ticks = 10; + + if (!hasTransport()) + return false; + + TransportLocation loc = getLocation(); + if (loc.type != 0) + return false; + + List inRange = npc.worldObj.getEntitiesWithinAABB(EntityPlayer.class, npc.boundingBox.expand(6D, 6D, 6D)); + for (EntityPlayer player : inRange) { + if (!npc.canSee(player)) + continue; + unlock(player, loc); + } + return false; + + } + + @Override + public void aiStartExecuting() { + + } + + @Override + public void interact(EntityPlayer player) { + if (hasTransport()) { + TransportLocation loc = getLocation(); + if (loc.type == 2) { + unlock(player, loc); + } + NoppesUtilServer.sendOpenGui(player, EnumGuiType.PlayerTransporter, npc); + } + } + + public void unlock(EntityPlayer player, ITransportLocation loc) { + PlayerTransportData data = PlayerDataController.Instance.getPlayerData(player).transportData; + if (data.transports.contains(transportId)) + return; + data.transports.add(transportId); + player.addChatMessage(new ChatComponentTranslation("transporter.unlock", loc.getName())); + } + + public TransportLocation getLocation() { + if (npc.isRemote()) + return null; + return TransportController.getInstance().getTransport(transportId); + } + + public boolean hasTransport() { + TransportLocation loc = getLocation(); + return loc != null && loc.id == transportId; + } + + public void setTransport(ITransportLocation location) { + transportId = location.getId(); + name = location.getName(); + } } diff --git a/src/main/java/noppes/npcs/roles/companion/CompanionFarmer.java b/src/main/java/noppes/npcs/roles/companion/CompanionFarmer.java index 437db5922..7368e995a 100644 --- a/src/main/java/noppes/npcs/roles/companion/CompanionFarmer.java +++ b/src/main/java/noppes/npcs/roles/companion/CompanionFarmer.java @@ -2,27 +2,28 @@ package noppes.npcs.roles.companion; import net.minecraft.nbt.NBTTagCompound; -public class CompanionFarmer extends CompanionJobInterface{ - public boolean isStanding = false; - @Override - public NBTTagCompound getNBT() { - NBTTagCompound compound = new NBTTagCompound(); - compound.setBoolean("CompanionFarmerStanding", isStanding); - return compound; - } +public class CompanionFarmer extends CompanionJobInterface { + public boolean isStanding = false; - @Override - public void setNBT(NBTTagCompound compound) { - isStanding = compound.getBoolean("CompanionFarmerStanding"); - } + @Override + public NBTTagCompound getNBT() { + NBTTagCompound compound = new NBTTagCompound(); + compound.setBoolean("CompanionFarmerStanding", isStanding); + return compound; + } - @Override - public boolean isSelfSufficient(){ - return isStanding; - } + @Override + public void setNBT(NBTTagCompound compound) { + isStanding = compound.getBoolean("CompanionFarmerStanding"); + } - @Override - public void onUpdate(){ - - } + @Override + public boolean isSelfSufficient() { + return isStanding; + } + + @Override + public void onUpdate() { + + } } diff --git a/src/main/java/noppes/npcs/roles/companion/CompanionFoodStats.java b/src/main/java/noppes/npcs/roles/companion/CompanionFoodStats.java index 84b127aba..a824f5fa0 100644 --- a/src/main/java/noppes/npcs/roles/companion/CompanionFoodStats.java +++ b/src/main/java/noppes/npcs/roles/companion/CompanionFoodStats.java @@ -10,72 +10,72 @@ import net.minecraft.world.EnumDifficulty; import noppes.npcs.entity.EntityNPCInterface; public class CompanionFoodStats { - /** The player's food level. */ + /** + * The player's food level. + */ private int foodLevel = 20; - /** The player's food saturation. */ + /** + * The player's food saturation. + */ private float foodSaturationLevel = 5.0F; - /** The player's food exhaustion. */ + /** + * The player's food exhaustion. + */ private float foodExhaustionLevel; - /** The player's food timer value. */ + /** + * The player's food timer value. + */ private int foodTimer; private int prevFoodLevel = 20; /** * Args: int foodLevel, float foodSaturationModifier */ - private void addStats(int p_75122_1_, float p_75122_2_){ + private void addStats(int p_75122_1_, float p_75122_2_) { this.foodLevel = Math.min(p_75122_1_ + this.foodLevel, 20); - this.foodSaturationLevel = Math.min(this.foodSaturationLevel + (float)p_75122_1_ * p_75122_2_ * 2.0F, (float)this.foodLevel); + this.foodSaturationLevel = Math.min(this.foodSaturationLevel + (float) p_75122_1_ * p_75122_2_ * 2.0F, (float) this.foodLevel); } - public void onFoodEaten(ItemFood food, ItemStack itemstack){ + public void onFoodEaten(ItemFood food, ItemStack itemstack) { this.addStats(food.func_150905_g(itemstack), food.func_150906_h(itemstack)); } /** * Handles the food game logic. */ - public void onUpdate(EntityNPCInterface npc){ + public void onUpdate(EntityNPCInterface npc) { EnumDifficulty enumdifficulty = npc.worldObj.difficultySetting; this.prevFoodLevel = this.foodLevel; - if (this.foodExhaustionLevel > 4.0F){ + if (this.foodExhaustionLevel > 4.0F) { this.foodExhaustionLevel -= 4.0F; - if (this.foodSaturationLevel > 0.0F) - { + if (this.foodSaturationLevel > 0.0F) { this.foodSaturationLevel = Math.max(this.foodSaturationLevel - 1.0F, 0.0F); - } - else if (enumdifficulty != EnumDifficulty.PEACEFUL) - { + } else if (enumdifficulty != EnumDifficulty.PEACEFUL) { this.foodLevel = Math.max(this.foodLevel - 1, 0); } } - if (npc.worldObj.getGameRules().getGameRuleBooleanValue("naturalRegeneration") && this.foodLevel >= 18 && npc.getHealth() > 0.0F && npc.getHealth() < npc.getMaxHealth()) - { + if (npc.worldObj.getGameRules().getGameRuleBooleanValue("naturalRegeneration") && this.foodLevel >= 18 && npc.getHealth() > 0.0F && npc.getHealth() < npc.getMaxHealth()) { ++this.foodTimer; - if (this.foodTimer >= 80){ + if (this.foodTimer >= 80) { npc.heal(1.0F); this.addExhaustion(3.0F); this.foodTimer = 0; } - } - else if (this.foodLevel <= 0){ + } else if (this.foodLevel <= 0) { ++this.foodTimer; - if (this.foodTimer >= 80){ - if (npc.getHealth() > 10.0F || enumdifficulty == EnumDifficulty.HARD || npc.getHealth() > 1.0F && enumdifficulty == EnumDifficulty.NORMAL) - { + if (this.foodTimer >= 80) { + if (npc.getHealth() > 10.0F || enumdifficulty == EnumDifficulty.HARD || npc.getHealth() > 1.0F && enumdifficulty == EnumDifficulty.NORMAL) { npc.attackEntityFrom(DamageSource.starve, 1.0F); } this.foodTimer = 0; } - } - else - { + } else { this.foodTimer = 0; } } @@ -83,10 +83,8 @@ public class CompanionFoodStats { /** * Reads food stats from an NBT object. */ - public void readNBT(NBTTagCompound p_75112_1_) - { - if (p_75112_1_.hasKey("foodLevel", 99)) - { + public void readNBT(NBTTagCompound p_75112_1_) { + if (p_75112_1_.hasKey("foodLevel", 99)) { this.foodLevel = p_75112_1_.getInteger("foodLevel"); this.foodTimer = p_75112_1_.getInteger("foodTickTimer"); this.foodSaturationLevel = p_75112_1_.getFloat("foodSaturationLevel"); @@ -97,8 +95,7 @@ public class CompanionFoodStats { /** * Writes food stats to an NBT object. */ - public void writeNBT(NBTTagCompound p_75117_1_) - { + public void writeNBT(NBTTagCompound p_75117_1_) { p_75117_1_.setInteger("foodLevel", this.foodLevel); p_75117_1_.setInteger("foodTickTimer", this.foodTimer); p_75117_1_.setFloat("foodSaturationLevel", this.foodSaturationLevel); @@ -108,43 +105,43 @@ public class CompanionFoodStats { /** * Get the player's food level. */ - public int getFoodLevel(){ + public int getFoodLevel() { return this.foodLevel; } @SideOnly(Side.CLIENT) - public int getPrevFoodLevel(){ + public int getPrevFoodLevel() { return this.prevFoodLevel; } /** * If foodLevel is not max. */ - public boolean needFood(){ + public boolean needFood() { return this.foodLevel < 20; } /** * adds input to foodExhaustionLevel to a max of 40 */ - public void addExhaustion(float p_75113_1_){ + public void addExhaustion(float p_75113_1_) { this.foodExhaustionLevel = Math.min(this.foodExhaustionLevel + p_75113_1_, 40.0F); } /** * Get the player's food saturation level. */ - public float getSaturationLevel(){ + public float getSaturationLevel() { return this.foodSaturationLevel; } @SideOnly(Side.CLIENT) - public void setFoodLevel(int p_75114_1_){ + public void setFoodLevel(int p_75114_1_) { this.foodLevel = p_75114_1_; } @SideOnly(Side.CLIENT) - public void setFoodSaturationLevel(float p_75119_1_){ + public void setFoodSaturationLevel(float p_75119_1_) { this.foodSaturationLevel = p_75119_1_; } } diff --git a/src/main/java/noppes/npcs/roles/companion/CompanionGuard.java b/src/main/java/noppes/npcs/roles/companion/CompanionGuard.java index 7ea382213..7753b8111 100644 --- a/src/main/java/noppes/npcs/roles/companion/CompanionGuard.java +++ b/src/main/java/noppes/npcs/roles/companion/CompanionGuard.java @@ -7,35 +7,35 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.nbt.NBTTagCompound; import noppes.npcs.entity.EntityNPCInterface; -public class CompanionGuard extends CompanionJobInterface{ - public boolean isStanding = false; - @Override - public NBTTagCompound getNBT() { - NBTTagCompound compound = new NBTTagCompound(); - compound.setBoolean("CompanionGuardStanding", isStanding); - return compound; - } +public class CompanionGuard extends CompanionJobInterface { + public boolean isStanding = false; - @Override - public void setNBT(NBTTagCompound compound) { - isStanding = compound.getBoolean("CompanionGuardStanding"); - } - - public boolean isEntityApplicable(Entity entity) { - - if(entity instanceof EntityPlayer || entity instanceof EntityNPCInterface) - return false; + @Override + public NBTTagCompound getNBT() { + NBTTagCompound compound = new NBTTagCompound(); + compound.setBoolean("CompanionGuardStanding", isStanding); + return compound; + } - else if (entity instanceof EntityCreeper) { - return false; - } - else if(entity instanceof IMob){ - return true; - } - return false; - } + @Override + public void setNBT(NBTTagCompound compound) { + isStanding = compound.getBoolean("CompanionGuardStanding"); + } - public boolean isSelfSufficient(){ - return isStanding; - } + public boolean isEntityApplicable(Entity entity) { + + if (entity instanceof EntityPlayer || entity instanceof EntityNPCInterface) + return false; + + else if (entity instanceof EntityCreeper) { + return false; + } else if (entity instanceof IMob) { + return true; + } + return false; + } + + public boolean isSelfSufficient() { + return isStanding; + } } diff --git a/src/main/java/noppes/npcs/roles/companion/CompanionJobInterface.java b/src/main/java/noppes/npcs/roles/companion/CompanionJobInterface.java index 475ab715a..5a7b4f8d5 100644 --- a/src/main/java/noppes/npcs/roles/companion/CompanionJobInterface.java +++ b/src/main/java/noppes/npcs/roles/companion/CompanionJobInterface.java @@ -4,11 +4,16 @@ import net.minecraft.nbt.NBTTagCompound; import noppes.npcs.entity.EntityNPCInterface; public abstract class CompanionJobInterface { - public EntityNPCInterface npc; - public abstract NBTTagCompound getNBT(); - public abstract void setNBT(NBTTagCompound compound); - public void onUpdate(){} - public boolean isSelfSufficient(){ - return false; - } + public EntityNPCInterface npc; + + public abstract NBTTagCompound getNBT(); + + public abstract void setNBT(NBTTagCompound compound); + + public void onUpdate() { + } + + public boolean isSelfSufficient() { + return false; + } } diff --git a/src/main/java/noppes/npcs/roles/companion/CompanionTrader.java b/src/main/java/noppes/npcs/roles/companion/CompanionTrader.java index 052c4e945..d789a2710 100644 --- a/src/main/java/noppes/npcs/roles/companion/CompanionTrader.java +++ b/src/main/java/noppes/npcs/roles/companion/CompanionTrader.java @@ -5,20 +5,20 @@ import net.minecraft.nbt.NBTTagCompound; import noppes.npcs.NoppesUtilServer; import noppes.npcs.constants.EnumGuiType; -public class CompanionTrader extends CompanionJobInterface{ +public class CompanionTrader extends CompanionJobInterface { - @Override - public NBTTagCompound getNBT() { - NBTTagCompound compound = new NBTTagCompound(); - return compound; - } + @Override + public NBTTagCompound getNBT() { + NBTTagCompound compound = new NBTTagCompound(); + return compound; + } - @Override - public void setNBT(NBTTagCompound compound) { - - } - - public void interact(EntityPlayer player){ - NoppesUtilServer.sendOpenGui(player, EnumGuiType.CompanionTrader, npc); - } + @Override + public void setNBT(NBTTagCompound compound) { + + } + + public void interact(EntityPlayer player) { + NoppesUtilServer.sendOpenGui(player, EnumGuiType.CompanionTrader, npc); + } } diff --git a/src/main/java/noppes/npcs/scripted/BlockScriptedWrapper.java b/src/main/java/noppes/npcs/scripted/BlockScriptedWrapper.java index 6c6b81605..95155656a 100644 --- a/src/main/java/noppes/npcs/scripted/BlockScriptedWrapper.java +++ b/src/main/java/noppes/npcs/scripted/BlockScriptedWrapper.java @@ -19,34 +19,34 @@ import noppes.npcs.blocks.tiles.TileScripted; import java.util.Set; -public class BlockScriptedWrapper extends ScriptBlock implements IBlockScripted{ +public class BlockScriptedWrapper extends ScriptBlock implements IBlockScripted { private TileScripted tile; public BlockScriptedWrapper(World world, Block block, int x, int y, int z) { - super(world, block, new BlockPos(x,y,z)); + super(world, block, new BlockPos(x, y, z)); tile = (TileScripted) super.tile.getMCTileEntity(); } @Override - public void setModel(IItemStack item){ - if(item == null) + public void setModel(IItemStack item) { + if (item == null) tile.setItemModel(null, null); else tile.setItemModel(item.getMCItemStack(), Block.getBlockFromItem(item.getMCItemStack().getItem())); } @Override - public void setModel(String name){ - if(name == null) + public void setModel(String name) { + if (name == null) tile.setItemModel(null, null); - else{ + else { Block block = Block.getBlockFromName(name); - if(block!=null) { + if (block != null) { tile.setItemModel(new ItemStack(Item.getItemFromBlock(block)), block); - }else{ - if(Item.itemRegistry.containsKey(name)) { + } else { + if (Item.itemRegistry.containsKey(name)) { tile.setItemModel(new ItemStack((Item) Item.itemRegistry.getObject(name)), null); - }else{ + } else { tile.setItemModel(null, null); } } @@ -54,103 +54,103 @@ public class BlockScriptedWrapper extends ScriptBlock implements IBlockScripted{ } @Override - public IItemStack getModel(){ + public IItemStack getModel() { return NpcAPI.Instance().getIItemStack(tile.itemModel); } @Override - public void setRedstonePower(int strength){ + public void setRedstonePower(int strength) { tile.setRedstonePower(strength); } @Override - public int getRedstonePower(){ + public int getRedstonePower() { return tile.powering; } @Override - public void setIsLadder(boolean bo){ + public void setIsLadder(boolean bo) { tile.isLadder = bo; tile.needsClientUpdate = true; } @Override - public boolean getIsLadder(){ + public boolean getIsLadder() { return tile.isLadder; } @Override - public void setIsPassible(boolean bo){ + public void setIsPassible(boolean bo) { setIsPassable(bo); } @Override - public boolean getIsPassible(){ + public boolean getIsPassible() { return getIsPassable(); } @Override - public void setIsPassable(boolean bo){ + public void setIsPassable(boolean bo) { tile.isPassible = bo; tile.needsClientUpdate = true; } @Override - public boolean getIsPassable(){ - if(tile == null) + public boolean getIsPassable() { + if (tile == null) return false; return tile.isPassible; } @Override - public void setLight(int value){ + public void setLight(int value) { tile.setLightValue(value); } @Override - public int getLight(){ - if(tile == null) + public int getLight() { + if (tile == null) return 0; return tile.lightValue; } @Override - public void setScale(float x, float y, float z){ + public void setScale(float x, float y, float z) { tile.setScale(x, y, z); } @Override - public float getScaleX(){ + public float getScaleX() { return tile.scaleX; } @Override - public float getScaleY(){ + public float getScaleY() { return tile.scaleY; } @Override - public float getScaleZ(){ + public float getScaleZ() { return tile.scaleZ; } @Override - public void setRotation(int x, int y, int z){ - tile.setRotation(x % 360, y % 360, z % 360); + public void setRotation(int x, int y, int z) { + tile.setRotation(x % 360, y % 360, z % 360); } @Override - public int getRotationX(){ + public int getRotationX() { return tile.rotationX; } @Override - public int getRotationY(){ + public int getRotationY() { return tile.rotationY; } @Override - public int getRotationZ(){ + public int getRotationZ() { return tile.rotationZ; } @@ -175,8 +175,8 @@ public class BlockScriptedWrapper extends ScriptBlock implements IBlockScripted{ } @Override - public void executeCommand(String command){ - if(!MinecraftServer.getServer().isCommandBlockEnabled()) + public void executeCommand(String command) { + if (!MinecraftServer.getServer().isCommandBlockEnabled()) throw new CustomNPCsException("Command blocks need to be enabled to executeCommands"); NoppesUtilServer.runCommand(world.getMCWorld(), "ScriptedBlock", command); } @@ -217,16 +217,16 @@ public class BlockScriptedWrapper extends ScriptBlock implements IBlockScripted{ } @Override - public void setTileEntity(ITileEntity tile){ + public void setTileEntity(ITileEntity tile) { this.tile = (TileScripted) tile; super.setTileEntity(tile); } - private NBTTagCompound getNBT(){ - if(tile == null) + private NBTTagCompound getNBT() { + if (tile == null) return null; NBTTagCompound compound = tile.getTileData().getCompoundTag("CustomNPCsData"); - if(compound.hasNoTags() && !tile.getTileData().hasKey("CustomNPCsData")){ + if (compound.hasNoTags() && !tile.getTileData().hasKey("CustomNPCsData")) { tile.getTileData().setTag("CustomNPCsData", compound); } return compound; @@ -235,31 +235,31 @@ public class BlockScriptedWrapper extends ScriptBlock implements IBlockScripted{ @Override public void setStoredData(String key, Object value) { NBTTagCompound compound = getNBT(); - if(compound == null) + if (compound == null) return; - if(value instanceof Number) + if (value instanceof Number) compound.setDouble(key, ((Number) value).doubleValue()); - else if(value instanceof String) - compound.setString(key, (String)value); + else if (value instanceof String) + compound.setString(key, (String) value); } @Override public Object getStoredData(String key) { NBTTagCompound compound = getNBT(); - if(compound == null) + if (compound == null) return null; - if(!compound.hasKey(key)) + if (!compound.hasKey(key)) return null; NBTBase base = compound.getTag(key); - if(base instanceof NBTBase.NBTPrimitive) - return ((NBTBase.NBTPrimitive)base).func_150286_g(); - return ((NBTTagString)base).func_150285_a_(); + if (base instanceof NBTBase.NBTPrimitive) + return ((NBTBase.NBTPrimitive) base).func_150286_g(); + return ((NBTTagString) base).func_150285_a_(); } @Override public void removeStoredData(String key) { NBTTagCompound compound = getNBT(); - if(compound == null) + if (compound == null) return; compound.removeTag(key); } @@ -267,14 +267,14 @@ public class BlockScriptedWrapper extends ScriptBlock implements IBlockScripted{ @Override public boolean hasStoredData(String key) { NBTTagCompound compound = getNBT(); - if(compound == null) + if (compound == null) return false; return compound.hasKey(key); } @Override public void clearStoredData() { - if(tile == null) + if (tile == null) return; tile.getTileData().setTag("CustomNPCsData", new NBTTagCompound()); } @@ -282,41 +282,42 @@ public class BlockScriptedWrapper extends ScriptBlock implements IBlockScripted{ @Override public String[] getStoredDataKeys() { NBTTagCompound compound = getNBT(); - if(compound == null) + if (compound == null) return new String[0]; - return ((Set)compound.func_150296_c()).toArray(new String[0]); + return ((Set) compound.func_150296_c()).toArray(new String[0]); } @Override public void removeTempData(String key) { - if(tile == null) + if (tile == null) return; tile.tempData.remove(key); } @Override public void setTempData(String key, Object value) { - if(tile == null) + if (tile == null) return; tile.tempData.put(key, value); } @Override public boolean hasTempData(String key) { - if(tile == null) + if (tile == null) return false; return tile.tempData.containsKey(key); } @Override public Object getTempData(String key) { - if(tile == null) + if (tile == null) return null; return tile.tempData.get(key); } + @Override public void clearTempData() { - if(tile == null) + if (tile == null) return; tile.tempData.clear(); } diff --git a/src/main/java/noppes/npcs/scripted/NpcAPI.java b/src/main/java/noppes/npcs/scripted/NpcAPI.java index 0fef6256f..1ce31d1c5 100644 --- a/src/main/java/noppes/npcs/scripted/NpcAPI.java +++ b/src/main/java/noppes/npcs/scripted/NpcAPI.java @@ -73,10 +73,10 @@ import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; public class NpcAPI extends AbstractNpcAPI { - private static final Map tempData = new HashMap<>(); + private static final Map tempData = new HashMap<>(); private static final Map worldCache = new LRUHashMap<>(10); - private static final CacheHashMap> scriptItemCache = new CacheHashMap<>(60*1000); - public static final HashMap engineObjects = new HashMap<>(); + private static final CacheHashMap> scriptItemCache = new CacheHashMap<>(60 * 1000); + public static final HashMap engineObjects = new HashMap<>(); public static final EventBus EVENT_BUS = new EventBus(); private static AbstractNpcAPI instance = null; @@ -91,23 +91,23 @@ public class NpcAPI extends AbstractNpcAPI { scriptItemCache.clear(); } - public Object getTempData(String key){ + public Object getTempData(String key) { return tempData.get(key); } - public void setTempData(String key, Object value){ + public void setTempData(String key, Object value) { tempData.put(key, value); } - public boolean hasTempData(String key){ + public boolean hasTempData(String key) { return tempData.containsKey(key); } - public void removeTempData(String key){ + public void removeTempData(String key) { tempData.remove(key); } - public void clearTempData(){ + public void clearTempData() { tempData.clear(); } @@ -115,35 +115,35 @@ public class NpcAPI extends AbstractNpcAPI { return tempData.keySet().toArray(new String[0]); } - public Object getStoredData(String key){ + public Object getStoredData(String key) { NBTTagCompound compound = ScriptController.Instance.compound; - if(!compound.hasKey(key)) + if (!compound.hasKey(key)) return null; NBTBase base = compound.getTag(key); - if(base instanceof NBTBase.NBTPrimitive) - return ((NBTBase.NBTPrimitive)base).func_150286_g(); - return ((NBTTagString)base).func_150285_a_(); + if (base instanceof NBTBase.NBTPrimitive) + return ((NBTBase.NBTPrimitive) base).func_150286_g(); + return ((NBTTagString) base).func_150285_a_(); } - public void setStoredData(String key, Object value){ + public void setStoredData(String key, Object value) { NBTTagCompound compound = ScriptController.Instance.compound; - if(value instanceof Number) + if (value instanceof Number) compound.setDouble(key, ((Number) value).doubleValue()); - else if(value instanceof String) - compound.setString(key, (String)value); + else if (value instanceof String) + compound.setString(key, (String) value); ScriptController.Instance.shouldSave = true; } - public boolean hasStoredData(String key){ + public boolean hasStoredData(String key) { return ScriptController.Instance.compound.hasKey(key); } - public void removeStoredData(String key){ + public void removeStoredData(String key) { ScriptController.Instance.compound.removeTag(key); ScriptController.Instance.shouldSave = true; } - public void clearStoredData(){ + public void clearStoredData() { ScriptController.Instance.compound = new NBTTagCompound(); ScriptController.Instance.shouldSave = true; } @@ -153,7 +153,7 @@ public class NpcAPI extends AbstractNpcAPI { if (compound != null) { Set keySet = compound.func_150296_c(); List list = new ArrayList<>(); - for(Object o : keySet){ + for (Object o : keySet) { list.add((String) o); } String[] array = list.toArray(new String[list.size()]); @@ -163,15 +163,15 @@ public class NpcAPI extends AbstractNpcAPI { } public void registerICommand(ICommand command) { - ((CommandHandler)CustomNpcs.getServer().getCommandManager()).registerCommand((ScriptedCommand) command); + ((CommandHandler) CustomNpcs.getServer().getCommandManager()).registerCommand((ScriptedCommand) command); } public ICommand getICommand(String commandName, int priorityLevel) { - return new ScriptedCommand(commandName,priorityLevel); + return new ScriptedCommand(commandName, priorityLevel); } public void addGlobalObject(String key, Object obj) { - NpcAPI.engineObjects.put(key,obj); + NpcAPI.engineObjects.put(key, obj); } public void removeGlobalObject(String key) { @@ -182,7 +182,7 @@ public class NpcAPI extends AbstractNpcAPI { return NpcAPI.engineObjects.containsKey(key); } - public HashMap getEngineObjects() { + public HashMap getEngineObjects() { return NpcAPI.engineObjects; } @@ -241,13 +241,21 @@ public class NpcAPI extends AbstractNpcAPI { return ServerCloneController.Instance; } - public INaturalSpawnsHandler getNaturalSpawns() { return SpawnController.Instance; } + public INaturalSpawnsHandler getNaturalSpawns() { + return SpawnController.Instance; + } - public IProfileHandler getProfileHandler() { return ProfileController.Instance; } + public IProfileHandler getProfileHandler() { + return ProfileController.Instance; + } - public ICustomEffectHandler getCustomEffectHandler() { return CustomEffectController.Instance; } + public ICustomEffectHandler getCustomEffectHandler() { + return CustomEffectController.Instance; + } - public IPartyHandler getPartyHandler() { return PartyController.Instance(); } + public IPartyHandler getPartyHandler() { + return PartyController.Instance(); + } public ITransportHandler getLocations() { return TransportController.getInstance(); @@ -272,21 +280,21 @@ public class NpcAPI extends AbstractNpcAPI { public static Boolean dbcLoaded = null; + public IEntity getIEntity(Entity entity) { - if(entity == null) + if (entity == null) return null; - if(entity instanceof EntityNPCInterface) - return ((EntityNPCInterface)entity).wrappedNPC; - else{ + if (entity instanceof EntityNPCInterface) + return ((EntityNPCInterface) entity).wrappedNPC; + else { ScriptEntityData data = (ScriptEntityData) entity.getExtendedProperties("ScriptedObject"); if (data == null) { if (entity instanceof EntityPlayerMP) { - if(dbcLoaded == null){ + if (dbcLoaded == null) { dbcLoaded = Loader.isModLoaded("jinryuujrmcore"); } data = dbcLoaded ? new ScriptEntityData(new ScriptDBCPlayer<>((EntityPlayerMP) entity)) : new ScriptEntityData(new ScriptPlayer<>((EntityPlayerMP) entity)); - } - else if (PixelmonHelper.isPixelmon(entity)) + } else if (PixelmonHelper.isPixelmon(entity)) return new ScriptPixelmon((EntityTameable) entity); else if (entity instanceof EntityAnimal) data = new ScriptEntityData(new ScriptAnimal<>((EntityAnimal) entity)); @@ -336,14 +344,14 @@ public class NpcAPI extends AbstractNpcAPI { public IBlock getIBlock(IWorld world, int x, int y, int z) { Block block = world.getMCWorld().getBlock(x, y, z); - if(block == null || block.isAir(world.getMCWorld(), x, y, z)) + if (block == null || block.isAir(world.getMCWorld(), x, y, z)) return null; - return new ScriptBlock(world.getMCWorld(), world.getMCWorld().getBlock(x, y, z), new BlockPos(x,y,z)); + return new ScriptBlock(world.getMCWorld(), world.getMCWorld().getBlock(x, y, z), new BlockPos(x, y, z)); } public IBlock getIBlock(IWorld world, IPos pos) { - return pos == null ? null : this.getIBlock(world, pos.getX(),pos.getY(),pos.getZ()); + return pos == null ? null : this.getIBlock(world, pos.getX(), pos.getY(), pos.getZ()); } public ITileEntity getITileEntity(IWorld world, IPos pos) { @@ -351,12 +359,12 @@ public class NpcAPI extends AbstractNpcAPI { return null; } - TileEntity tileEntity = world.getMCWorld().getTileEntity(pos.getX(), pos.getY(),pos.getZ()); + TileEntity tileEntity = world.getMCWorld().getTileEntity(pos.getX(), pos.getY(), pos.getZ()); return this.getITileEntity(tileEntity); } public ITileEntity getITileEntity(IWorld world, int x, int y, int z) { - TileEntity tileEntity = world.getMCWorld().getTileEntity(x,y,z); + TileEntity tileEntity = world.getMCWorld().getTileEntity(x, y, z); return this.getITileEntity(tileEntity); } @@ -369,7 +377,7 @@ public class NpcAPI extends AbstractNpcAPI { } public IPos getIPos(double x, double y, double z) { - return this.getIPos(new BlockPos(x,y,z)); + return this.getIPos(new BlockPos(x, y, z)); } public IPos getIPos(int x, int y, int z) { @@ -387,7 +395,7 @@ public class NpcAPI extends AbstractNpcAPI { public IPos[] getAllInBox(IPos from, IPos to, boolean sortByDistance) { ArrayList list = new ArrayList<>(); if (from != null && to != null) { - Iterator posIterable = BlockPos.getAllInBox(from.getMCPos(),to.getMCPos()).iterator(); + Iterator posIterable = BlockPos.getAllInBox(from.getMCPos(), to.getMCPos()).iterator(); posIterable.forEachRemaining(BlockPos -> list.add(this.getIPos(BlockPos))); if (sortByDistance) { list.sort(Comparator.comparingDouble(pos -> pos.distanceTo(from))); @@ -397,11 +405,11 @@ public class NpcAPI extends AbstractNpcAPI { } public IPos[] getAllInBox(IPos from, IPos to) { - return this.getAllInBox(from,to,true); + return this.getAllInBox(from, to, true); } public INbt getINbt(NBTTagCompound nbtTagCompound) { - return nbtTagCompound == null?new ScriptNbt(new NBTTagCompound()):new ScriptNbt(nbtTagCompound); + return nbtTagCompound == null ? new ScriptNbt(new NBTTagCompound()) : new ScriptNbt(nbtTagCompound); } public INbt stringToNbt(String str) { @@ -430,7 +438,7 @@ public class NpcAPI extends AbstractNpcAPI { return null; } else { EntityCustomNpc npc = new EntityCustomNpc(world.getMCWorld()); - npc.setPositionAndRotation((double)x + 0.5D, y, (double)z + 0.5D, 0.0F, 0.0F); + npc.setPositionAndRotation((double) x + 0.5D, y, (double) z + 0.5D, 0.0F, 0.0F); npc.setHealth(npc.getMaxHealth()); world.getMCWorld().spawnEntityInWorld(npc); return npc.wrappedNPC; @@ -457,7 +465,7 @@ public class NpcAPI extends AbstractNpcAPI { } public IItemStack getIItemStack(ItemStack itemstack) { - if(itemstack == null) + if (itemstack == null) return null; synchronized (scriptItemCache) { @@ -521,10 +529,10 @@ public class NpcAPI extends AbstractNpcAPI { public IWorld getIWorldLoad(int dimensionId) { try { IWorld iWorld = this.getIWorld(dimensionId); - if(iWorld != null) + if (iWorld != null) return iWorld; + } catch (CustomNPCsException ignored) { } - catch (CustomNPCsException ignored){} WorldServer worldServer = CustomNpcs.getServer().worldServerForDimension(dimensionId); if (worldServer != null) { @@ -539,7 +547,7 @@ public class NpcAPI extends AbstractNpcAPI { } public IContainer getIContainer(Container container) { - return container instanceof ContainerNpcInterface ? ContainerNpcInterface.getOrCreateIContainer((ContainerNpcInterface)container) : new ScriptContainer(container); + return container instanceof ContainerNpcInterface ? ContainerNpcInterface.getOrCreateIContainer((ContainerNpcInterface) container) : new ScriptContainer(container); } private void checkWorld() { @@ -552,7 +560,7 @@ public class NpcAPI extends AbstractNpcAPI { this.checkWorld(); IWorld[] worlds = new IWorld[CustomNpcs.getServer().worldServers.length]; - for(int i = 0; i < CustomNpcs.getServer().worldServers.length; ++i) { + for (int i = 0; i < CustomNpcs.getServer().worldServers.length; ++i) { worlds[i] = this.getIWorld(CustomNpcs.getServer().worldServers[i]); } @@ -572,15 +580,15 @@ public class NpcAPI extends AbstractNpcAPI { } public IDamageSource getIDamageSource(IEntity entity) { - if(entity.getType() == 1)//if player - return new ScriptDamageSource(new EntityDamageSource("player",entity.getMCEntity())); + if (entity.getType() == 1)//if player + return new ScriptDamageSource(new EntityDamageSource("player", entity.getMCEntity())); else - return new ScriptDamageSource(new EntityDamageSource(entity.getTypeName(),entity.getMCEntity())); + return new ScriptDamageSource(new EntityDamageSource(entity.getTypeName(), entity.getMCEntity())); } public void executeCommand(IWorld world, String command) { //if(!world.getMCWorld().isRemote) - NoppesUtilServer.runCommand(world.getMCWorld(), "API", command); + NoppesUtilServer.runCommand(world.getMCWorld(), "API", command); } public String getRandomName(int dictionary, int gender) { @@ -596,11 +604,11 @@ public class NpcAPI extends AbstractNpcAPI { return player == null ? null : (IPlayer) NpcAPI.Instance().getIEntity(player); } - public IPlayer[] getAllServerPlayers(){ + public IPlayer[] getAllServerPlayers() { List list = MinecraftServer.getServer().getConfigurationManager().playerEntityList; IPlayer[] arr = new IPlayer[list.size()]; - for(int i = 0; i < list.size(); i++){ - arr[i] = (IPlayer) NpcAPI.Instance().getIEntity((EntityPlayerMP)list.get(i)); + for (int i = 0; i < list.size(); i++) { + arr[i] = (IPlayer) NpcAPI.Instance().getIEntity((EntityPlayerMP) list.get(i)); } return arr; @@ -610,30 +618,28 @@ public class NpcAPI extends AbstractNpcAPI { return MinecraftServer.getServer().getConfigurationManager().getAllUsernames(); } - public void playSoundAtEntity(IEntity entity, String sound, float volume, float pitch){ + public void playSoundAtEntity(IEntity entity, String sound, float volume, float pitch) { entity.getWorld().getMCWorld().playSoundAtEntity(entity.getMCEntity(), sound, volume, pitch); } - public void playSoundToNearExcept(IPlayer player, String sound, float volume, float pitch){ + public void playSoundToNearExcept(IPlayer player, String sound, float volume, float pitch) { player.getWorld().getMCWorld().playSoundToNearExcept(player.getMCEntity(), sound, volume, pitch); } - public String getMOTD() - { + public String getMOTD() { return MinecraftServer.getServer().getMOTD(); } - public void setMOTD(String motd) - { + public void setMOTD(String motd) { MinecraftServer.getServer().setMOTD(motd); } - public IParticle createParticle(String directory){ + public IParticle createParticle(String directory) { return new ScriptParticle(directory); } @Deprecated - public IParticle createEntityParticle(String directory){ + public IParticle createEntityParticle(String directory) { return new ScriptParticle(directory); } @@ -726,7 +732,7 @@ public class NpcAPI extends AbstractNpcAPI { } public IFrame createFrame(int duration, float speed, byte smooth) { - return new Frame(duration,speed,smooth); + return new Frame(duration, speed, smooth); } public IFramePart createPart(String name) { @@ -749,7 +755,7 @@ public class NpcAPI extends AbstractNpcAPI { } public IFramePart createPart(String name, float[] rotation, float[] pivot, float speed, byte smooth) { - FramePart part = (FramePart) this.createPart(name,rotation,pivot); + FramePart part = (FramePart) this.createPart(name, rotation, pivot); part.setSpeed(speed); part.setSmooth(smooth); return part; @@ -776,7 +782,7 @@ public class NpcAPI extends AbstractNpcAPI { } public IFramePart createPart(int partId, float[] rotation, float[] pivot, float speed, byte smooth) { - FramePart part = (FramePart) this.createPart(partId,rotation,pivot); + FramePart part = (FramePart) this.createPart(partId, rotation, pivot); part.setSpeed(speed); part.setSmooth(smooth); return part; diff --git a/src/main/java/noppes/npcs/scripted/ScreenSize.java b/src/main/java/noppes/npcs/scripted/ScreenSize.java index b2cc540e2..d8183b22c 100644 --- a/src/main/java/noppes/npcs/scripted/ScreenSize.java +++ b/src/main/java/noppes/npcs/scripted/ScreenSize.java @@ -28,11 +28,11 @@ public class ScreenSize implements IScreenSize { @Override public int getWidthPercent(double percent) { - return (int) (((double)width)*percent/100); + return (int) (((double) width) * percent / 100); } @Override public int getHeightPercent(double percent) { - return (int) (((double)height)*percent/100); + return (int) (((double) height) * percent / 100); } } diff --git a/src/main/java/noppes/npcs/scripted/ScriptBlock.java b/src/main/java/noppes/npcs/scripted/ScriptBlock.java index c08c821bc..074ba4269 100644 --- a/src/main/java/noppes/npcs/scripted/ScriptBlock.java +++ b/src/main/java/noppes/npcs/scripted/ScriptBlock.java @@ -22,7 +22,7 @@ public class ScriptBlock implements IBlock { this.block = block; this.pos = pos; this.bPos = NpcAPI.Instance().getIPos(pos); - this.tile = NpcAPI.Instance().getITileEntity(world.getTileEntity(pos.getX(),pos.getY(), pos.getZ())); + this.tile = NpcAPI.Instance().getITileEntity(world.getTileEntity(pos.getX(), pos.getY(), pos.getZ())); } public IPos getPosition() { @@ -43,16 +43,16 @@ public class ScriptBlock implements IBlock { this.block = world.getBlock(pos).getMCBlock(); this.pos = pos.getMCPos(); this.bPos = pos; - this.tile = NpcAPI.Instance().getITileEntity(world.getMCWorld().getTileEntity(pos.getX(),pos.getY(),pos.getZ())); + this.tile = NpcAPI.Instance().getITileEntity(world.getMCWorld().getTileEntity(pos.getX(), pos.getY(), pos.getZ())); return true; } public boolean setPosition(IPos pos) { - return this.setPosition(pos,world); + return this.setPosition(pos, world); } public boolean setPos(IPos pos, IWorld world) { - return this.setPosition(pos,world); + return this.setPosition(pos, world); } public boolean setPos(IPos pos) { @@ -60,19 +60,19 @@ public class ScriptBlock implements IBlock { } public boolean setPosition(int x, int y, int z, IWorld world) { - return this.setPos(NpcAPI.Instance().getIPos(x,y,z),world); + return this.setPos(NpcAPI.Instance().getIPos(x, y, z), world); } public boolean setPosition(int x, int y, int z) { - return this.setPos(NpcAPI.Instance().getIPos(x,y,z)); + return this.setPos(NpcAPI.Instance().getIPos(x, y, z)); } public boolean setPos(int x, int y, int z, IWorld world) { - return this.setPosition(x,y,z, world); + return this.setPosition(x, y, z, world); } public boolean setPos(int x, int y, int z) { - return this.setPosition(x,y,z); + return this.setPosition(x, y, z); } public int getX() { @@ -96,18 +96,18 @@ public class ScriptBlock implements IBlock { } public IBlock setBlock(String blockName) { - Block block = (Block)Block.blockRegistry.getObject(new ResourceLocation(blockName)); - if(block == null) { + Block block = (Block) Block.blockRegistry.getObject(new ResourceLocation(blockName)); + if (block == null) { return this; } else { - this.world.getMCWorld().setBlock(getX(),getY(),getZ(),block); - return NpcAPI.Instance().getIBlock(world, getX(),getY(),getZ()); + this.world.getMCWorld().setBlock(getX(), getY(), getZ(), block); + return NpcAPI.Instance().getIBlock(world, getX(), getY(), getZ()); } } public IBlock setBlock(IBlock block) { - this.world.getMCWorld().setBlock(getX(),getY(),getZ(),block.getMCBlock()); - return NpcAPI.Instance().getIBlock(world, getX(),getY(),getZ()); + this.world.getMCWorld().setBlock(getX(), getY(), getZ(), block.getMCBlock()); + return NpcAPI.Instance().getIBlock(world, getX(), getY(), getZ()); } public boolean isContainer() { @@ -115,10 +115,10 @@ public class ScriptBlock implements IBlock { } public IContainer getContainer() { - if(!this.isContainer()) { + if (!this.isContainer()) { throw new CustomNPCsException("This block is not a container", new Object[0]); } else { - return NpcAPI.Instance().getIContainer((IInventory)this.tile.getMCTileEntity()); + return NpcAPI.Instance().getIContainer((IInventory) this.tile.getMCTileEntity()); } } @@ -127,7 +127,7 @@ public class ScriptBlock implements IBlock { } public String getDisplayName() { - return this.tile == null || this.tile.getMCTileEntity() == null ? this.getName():this.tile.getMCTileEntity().blockType.getItemIconName(); + return this.tile == null || this.tile.getMCTileEntity() == null ? this.getName() : this.tile.getMCTileEntity().blockType.getItemIconName(); } public IWorld getWorld() { @@ -146,8 +146,8 @@ public class ScriptBlock implements IBlock { return this.tile; } - public void setTileEntity(ITileEntity tileEntity){ - world.setTileEntity(pos.getX(),pos.getY(), pos.getZ(),tileEntity); + public void setTileEntity(ITileEntity tileEntity) { + world.setTileEntity(pos.getX(), pos.getY(), pos.getZ(), tileEntity); this.tile = tileEntity; } @@ -168,7 +168,7 @@ public class ScriptBlock implements IBlock { } public boolean canCollide(double maxVolume) { - AxisAlignedBB alignedBB = block.getCollisionBoundingBoxFromPool(world.getMCWorld(),getX(),getY(),getZ()); + AxisAlignedBB alignedBB = block.getCollisionBoundingBoxFromPool(world.getMCWorld(), getX(), getY(), getZ()); if (alignedBB == null) { return false; } @@ -183,7 +183,7 @@ public class ScriptBlock implements IBlock { } public void setBounds(float minX, float minY, float minZ, float maxX, float maxY, float maxZ) { - this.block.setBlockBounds(minX,minY,minZ,maxX,maxY,maxZ); + this.block.setBlockBounds(minX, minY, minZ, maxX, maxY, maxZ); } public double getBlockBoundsMinX() { @@ -215,8 +215,8 @@ public class ScriptBlock implements IBlock { } public boolean equals(Object obj) { - return obj instanceof IBlock && ((ScriptBlock)obj).getName().equals(this.getName()) && - ((ScriptBlock)obj).getWorld() == this.getWorld() && - ((ScriptBlock)obj).getPos().equals(this.getPos()); + return obj instanceof IBlock && ((ScriptBlock) obj).getName().equals(this.getName()) && + ((ScriptBlock) obj).getWorld() == this.getWorld() && + ((ScriptBlock) obj).getPos().equals(this.getPos()); } } diff --git a/src/main/java/noppes/npcs/scripted/ScriptBlockPos.java b/src/main/java/noppes/npcs/scripted/ScriptBlockPos.java index ed4a32279..037907907 100644 --- a/src/main/java/noppes/npcs/scripted/ScriptBlockPos.java +++ b/src/main/java/noppes/npcs/scripted/ScriptBlockPos.java @@ -109,7 +109,7 @@ public class ScriptBlockPos implements IPos { } public IPos crossProduct(double x, double y, double z) { - return this.crossProduct(NpcAPI.Instance().getIPos(x,y,z)); + return this.crossProduct(NpcAPI.Instance().getIPos(x, y, z)); } public IPos crossProduct(IPos pos) { @@ -118,7 +118,7 @@ public class ScriptBlockPos implements IPos { public IPos divide(double scalar) { return NpcAPI.Instance().getIPos( - getXD()/scalar , getYD()/scalar, getZD()/scalar + getXD() / scalar, getYD() / scalar, getZD() / scalar ); } @@ -160,9 +160,9 @@ public class ScriptBlockPos implements IPos { } public String toString() { - double xd = Math.floor(this.getXD() * 1000)/1000.0D; - double yd = Math.floor(this.getYD() * 1000)/1000.0D; - double zd = Math.floor(this.getZD() * 1000)/1000.0D; + double xd = Math.floor(this.getXD() * 1000) / 1000.0D; + double yd = Math.floor(this.getYD() * 1000) / 1000.0D; + double zd = Math.floor(this.getZD() * 1000) / 1000.0D; return "(" + xd + ", " + yd + ", " + zd + ")"; } diff --git a/src/main/java/noppes/npcs/scripted/ScriptContainer.java b/src/main/java/noppes/npcs/scripted/ScriptContainer.java index 1c30b3fde..cff43dabb 100644 --- a/src/main/java/noppes/npcs/scripted/ScriptContainer.java +++ b/src/main/java/noppes/npcs/scripted/ScriptContainer.java @@ -53,7 +53,7 @@ public class ScriptContainer implements IContainer { public int count(IItemStack item, boolean ignoreDamage, boolean ignoreNBT) { int count = 0; - for(int i = 0; i < this.getSize(); ++i) { + for (int i = 0; i < this.getSize(); ++i) { IItemStack toCompare = this.getSlot(i); if (NoppesUtilPlayer.compareItems(item.getMCItemStack(), toCompare.getMCItemStack(), ignoreDamage, ignoreNBT)) { count += toCompare.getStackSize(); @@ -74,7 +74,7 @@ public class ScriptContainer implements IContainer { public IItemStack[] getItems() { IItemStack[] items = new IItemStack[this.getSize()]; - for(int i = 0; i < this.getSize(); ++i) { + for (int i = 0; i < this.getSize(); ++i) { items[i] = this.getSlot(i); } @@ -89,7 +89,7 @@ public class ScriptContainer implements IContainer { container.detectAndSendChanges(); } - public boolean isPlayerNotUsingContainer(IPlayer player){ + public boolean isPlayerNotUsingContainer(IPlayer player) { return container.isPlayerNotUsingContainer((EntityPlayerMP) player.getMCEntity()); } } diff --git a/src/main/java/noppes/npcs/scripted/ScriptNbt.java b/src/main/java/noppes/npcs/scripted/ScriptNbt.java index 9aa613014..88471dc94 100644 --- a/src/main/java/noppes/npcs/scripted/ScriptNbt.java +++ b/src/main/java/noppes/npcs/scripted/ScriptNbt.java @@ -105,18 +105,18 @@ public class ScriptNbt implements INbt { NBTTagList list = this.compound.getTagList(key, type); Object[] nbts = new Object[list.tagCount()]; - for(int i = 0; i < list.tagCount(); ++i) { - if(list.func_150303_d() == 10) { + for (int i = 0; i < list.tagCount(); ++i) { + if (list.func_150303_d() == 10) { nbts[i] = new ScriptNbt(list.getCompoundTagAt(i)); - } else if(list.func_150303_d() == 8) { + } else if (list.func_150303_d() == 8) { nbts[i] = list.getStringTagAt(i); - } else if(list.func_150303_d() == 6) { + } else if (list.func_150303_d() == 6) { nbts[i] = Double.valueOf(list.func_150309_d(i)); - } else if(list.func_150303_d() == 5) { + } else if (list.func_150303_d() == 5) { nbts[i] = Float.valueOf(list.func_150308_e(i)); - } else if(list.func_150303_d() == 3) { + } else if (list.func_150303_d() == 3) { nbts[i] = Integer.valueOf(list.getStringTagAt(i)); - } else if(list.func_150303_d() == 11) { + } else if (list.func_150303_d() == 11) { nbts[i] = list.func_150306_c(i); } } @@ -126,12 +126,12 @@ public class ScriptNbt implements INbt { public int getListType(String key) { NBTBase b = this.compound.getTag(key); - if(b == null) { + if (b == null) { return 0; - } else if(b.getId() != 9) { + } else if (b.getId() != 9) { throw new CustomNPCsException("NBT tag " + key + " isn\'t a list", new Object[0]); } else { - return ((NBTTagList)b).func_150303_d(); + return ((NBTTagList) b).func_150303_d(); } } @@ -140,19 +140,19 @@ public class ScriptNbt implements INbt { Object[] var4 = value; int var5 = value.length; - for(int var6 = 0; var6 < var5; ++var6) { + for (int var6 = 0; var6 < var5; ++var6) { Object nbt = var4[var6]; - if(nbt instanceof INbt) { + if (nbt instanceof INbt) { list.appendTag(((INbt) nbt).getMCNBT()); - } else if(nbt instanceof String) { + } else if (nbt instanceof String) { list.appendTag(new NBTTagString((String) nbt)); - } else if(nbt instanceof Double) { + } else if (nbt instanceof Double) { list.appendTag(new NBTTagDouble(((Double) nbt).doubleValue())); - } else if(nbt instanceof Float) { + } else if (nbt instanceof Float) { list.appendTag(new NBTTagFloat(((Float) nbt).floatValue())); - } else if(nbt instanceof Integer) { + } else if (nbt instanceof Integer) { list.appendTag(new NBTTagInt(((Integer) nbt).intValue())); - } else if(nbt instanceof int[]) { + } else if (nbt instanceof int[]) { list.appendTag(new NBTTagIntArray((int[]) ((int[]) nbt))); } } @@ -165,7 +165,7 @@ public class ScriptNbt implements INbt { } public void setCompound(String key, INbt value) { - if(value == null) { + if (value == null) { throw new CustomNPCsException("Value cant be null", new Object[0]); } else { this.compound.setTag(key, value.getMCNBT()); @@ -173,7 +173,7 @@ public class ScriptNbt implements INbt { } public String[] getKeys() { - return (String[])this.compound.func_150296_c().toArray(new String[this.compound.func_150296_c().size()]); + return (String[]) this.compound.func_150296_c().toArray(new String[this.compound.func_150296_c().size()]); } public int getType(String key) { @@ -195,8 +195,8 @@ public class ScriptNbt implements INbt { public void clear() { Iterator var1 = this.compound.func_150296_c().iterator(); - while(var1.hasNext()) { - String name = (String)var1.next(); + while (var1.hasNext()) { + String name = (String) var1.next(); this.compound.removeTag(name); } diff --git a/src/main/java/noppes/npcs/scripted/ScriptParticle.java b/src/main/java/noppes/npcs/scripted/ScriptParticle.java index e6c89fb9e..11f8676be 100644 --- a/src/main/java/noppes/npcs/scripted/ScriptParticle.java +++ b/src/main/java/noppes/npcs/scripted/ScriptParticle.java @@ -19,12 +19,12 @@ public class ScriptParticle implements IParticle { public int amount = 1; public int maxAge = 20; - public double x = 0,y = 0,z = 0; - public double motionX = 0,motionY = 0,motionZ = 0; + public double x = 0, y = 0, z = 0; + public double motionX = 0, motionY = 0, motionZ = 0; public float gravity = 0; - public float scaleX1 = 20.0f,scaleX2 = 20.0f,scaleXRate = 0.0f; - public float scaleY1 = 20.0f,scaleY2 = 20.0f,scaleYRate = 0.0f; - public float alpha1 = 1.0f,alpha2 = 1.0f,alphaRate = 0.0f; + public float scaleX1 = 20.0f, scaleX2 = 20.0f, scaleXRate = 0.0f; + public float scaleY1 = 20.0f, scaleY2 = 20.0f, scaleYRate = 0.0f; + public float alpha1 = 1.0f, alpha2 = 1.0f, alphaRate = 0.0f; public int scaleXRateStart = 0, scaleYRateStart, alphaRateStart = 0; public float rotationX1 = 0; @@ -53,7 +53,7 @@ public class ScriptParticle implements IParticle { public boolean glows = true; public boolean noClip = true; - public ScriptParticle(String directory){ + public ScriptParticle(String directory) { this.directory = directory; } @@ -67,7 +67,8 @@ public class ScriptParticle implements IParticle { if (!field.get(this).equals(field.get(newParticle))) { compound = writeNBTTag(compound, field.getType(), field.getName(), field.get(this)); } - } catch (Exception ignored) {} + } catch (Exception ignored) { + } } return compound; @@ -120,18 +121,19 @@ public class ScriptParticle implements IParticle { for (Field field : ScriptParticle.class.getDeclaredFields()) { try { if (compound.hasKey(field.getName())) { - Object val = ScriptParticle.readNBTTag(compound,field.getName()); + Object val = ScriptParticle.readNBTTag(compound, field.getName()); if (val != null) { field.set(particle, val); } } - } catch (Exception ignored) {} + } catch (Exception ignored) { + } } return particle; } - public void spawn(IEntity entity){ + public void spawn(IEntity entity) { int entityID = entity.getMCEntity().getEntityId(); NBTTagCompound compound = this.writeToNBT(); @@ -140,12 +142,12 @@ public class ScriptParticle implements IParticle { NoppesUtilServer.spawnScriptedParticle(compound, entity.getWorld().getDimensionID()); } - public void spawn(IWorld world){ + public void spawn(IWorld world) { NBTTagCompound compound = this.writeToNBT(); NoppesUtilServer.spawnScriptedParticle(compound, world.getDimensionID()); } - public void spawn(IWorld world, double x, double y, double z){ + public void spawn(IWorld world, double x, double y, double z) { double prevX = this.x; double prevY = this.y; double prevZ = this.z; @@ -170,22 +172,38 @@ public class ScriptParticle implements IParticle { spawn(world); } - public void spawnInWorld(IWorld world, double x, double y, double z){ + public void spawnInWorld(IWorld world, double x, double y, double z) { spawn(world, x, y, z); } - public void setGlows(boolean glows) { this.glows = glows; } - public boolean getGlows() { return this.glows; } + public void setGlows(boolean glows) { + this.glows = glows; + } - public void setNoClip(boolean noClip) { this.noClip = noClip; } - public boolean getNoClip() { return this.noClip; } + public boolean getGlows() { + return this.glows; + } - public void setFacePlayer(boolean facePlayer) { this.facePlayer = facePlayer; } - public boolean getFacePlayer() { return facePlayer; } + public void setNoClip(boolean noClip) { + this.noClip = noClip; + } + + public boolean getNoClip() { + return this.noClip; + } + + public void setFacePlayer(boolean facePlayer) { + this.facePlayer = facePlayer; + } + + public boolean getFacePlayer() { + return facePlayer; + } public String getDirectory() { return directory; } + public void setDirectory(String directory) { this.directory = directory; } @@ -193,6 +211,7 @@ public class ScriptParticle implements IParticle { public void setAmount(int amount) { this.amount = amount; } + public int getAmount() { return amount; } @@ -200,72 +219,105 @@ public class ScriptParticle implements IParticle { public void setMaxAge(int maxAge) { this.maxAge = maxAge; } + public int getMaxAge() { return maxAge; } - public void setSize(int width, int height){ + public void setSize(int width, int height) { this.width = width; this.height = height; } - public int getWidth() { return width; } - public int getHeight() { return height; } - public void setOffset(int offsetX, int offsetY){ + public int getWidth() { + return width; + } + + public int getHeight() { + return height; + } + + public void setOffset(int offsetX, int offsetY) { this.offsetX = offsetX; this.offsetY = offsetY; } - public int getOffsetX() { return offsetX; } - public int getOffsetY() { return offsetY; } - public void setAnim(int animRate, boolean animLoop, int animStart, int animEnd){ + public int getOffsetX() { + return offsetX; + } + + public int getOffsetY() { + return offsetY; + } + + public void setAnim(int animRate, boolean animLoop, int animStart, int animEnd) { this.animRate = animRate; this.animLoop = animLoop; this.animStart = animStart; this.animEnd = animEnd; } - public int getAnimRate() { return animRate; } - public boolean getAnimLoop() { return animLoop; } - public int getAnimStart() { return animStart; } - public int getAnimEnd() { return animEnd; } - public void setPosition(double x, double y, double z){ + public int getAnimRate() { + return animRate; + } + + public boolean getAnimLoop() { + return animLoop; + } + + public int getAnimStart() { + return animStart; + } + + public int getAnimEnd() { + return animEnd; + } + + public void setPosition(double x, double y, double z) { this.x = x; this.y = y; this.z = z; } + public double getX() { return x; } + public double getY() { return y; } + public double getZ() { return z; } public void setPosition(IPos pos) { - this.setPosition(pos.getXD(),pos.getYD(),pos.getZD()); - } - public void getPos() { - NpcAPI.Instance().getIPos(x,y,z); + this.setPosition(pos.getXD(), pos.getYD(), pos.getZD()); } - public void setMotion(double motionX, double motionY, double motionZ, float gravity){ + public void getPos() { + NpcAPI.Instance().getIPos(x, y, z); + } + + public void setMotion(double motionX, double motionY, double motionZ, float gravity) { this.motionX = motionX; this.motionY = motionY; this.motionZ = motionZ; this.gravity = gravity; } + public double getMotionX() { return motionX; } + public double getMotionY() { return motionY; } + public double getMotionZ() { return motionZ; } + public float getGravity() { return gravity; } @@ -276,34 +328,42 @@ public class ScriptParticle implements IParticle { this.HEXColorRate = HEXColorRate; this.HEXColorStart = HEXColorStart; } + public int getHEXColor1() { return HEXColor; } + public int getHEXColor2() { return HEXColor2; } + public float getHEXColorRate() { return HEXColorRate; } + public int getHEXColorStart() { return HEXColorStart; } - public void setAlpha(float alpha1, float alpha2, float alphaRate, int alphaRateStart){ + public void setAlpha(float alpha1, float alpha2, float alphaRate, int alphaRateStart) { this.alpha1 = alpha1; this.alpha2 = alpha2; this.alphaRate = alphaRate; this.alphaRateStart = alphaRateStart; } + public float getAlpha1() { return alpha1; } + public float getAlpha2() { return alpha2; } + public float getAlphaRate() { return alphaRate; } + public int getAlphaRateStart() { return alphaRateStart; } @@ -315,81 +375,126 @@ public class ScriptParticle implements IParticle { this.scaleXRateStart = this.scaleYRateStart = scaleRateStart; } - public void setScaleX(float scale1, float scale2, float scaleRate, int scaleRateStart){ + public void setScaleX(float scale1, float scale2, float scaleRate, int scaleRateStart) { this.scaleX1 = scale1; this.scaleX2 = scale2; this.scaleXRate = scaleRate; this.scaleXRateStart = scaleRateStart; } + public float getScaleX1() { return scaleX1; } + public float getScaleX2() { return scaleX2; } + public float getScaleXRate() { return scaleXRate; } + public int getScaleXRateStart() { return scaleXRateStart; } - public void setScaleY(float scale1, float scale2, float scaleRate, int scaleRateStart){ + public void setScaleY(float scale1, float scale2, float scaleRate, int scaleRateStart) { this.scaleY1 = scale1; this.scaleY2 = scale2; this.scaleYRate = scaleRate; this.scaleYRateStart = scaleRateStart; } + public float getScaleY1() { return scaleY1; } + public float getScaleY2() { return scaleY2; } + public float getScaleYRate() { return scaleYRate; } + public int getScaleYRateStart() { return scaleYRateStart; } - public void setRotationX(float rotationX1, float rotationX2, float rotationXRate, int rotationXRateStart){ + public void setRotationX(float rotationX1, float rotationX2, float rotationXRate, int rotationXRateStart) { this.rotationX1 = rotationX1; this.rotationX2 = rotationX2; this.rotationXRate = rotationXRate; this.rotationXRateStart = rotationXRateStart; } - public float getRotationX1() {return rotationX1;} - public float getRotationX2() {return rotationX2;} - public float getRotationXRate() {return rotationXRate;} - public int getRotationXRateStart() {return rotationXRateStart;} - public void setRotationY(float rotationY1, float rotationY2, float rotationYRate, int rotationYRateStart){ + public float getRotationX1() { + return rotationX1; + } + + public float getRotationX2() { + return rotationX2; + } + + public float getRotationXRate() { + return rotationXRate; + } + + public int getRotationXRateStart() { + return rotationXRateStart; + } + + public void setRotationY(float rotationY1, float rotationY2, float rotationYRate, int rotationYRateStart) { this.rotationY1 = rotationY1; this.rotationY2 = rotationY2; this.rotationYRate = rotationYRate; this.rotationYRateStart = rotationYRateStart; } - public float getRotationY1() {return rotationY1;} - public float getRotationY2() {return rotationY2;} - public float getRotationYRate() {return rotationYRate;} - public int getRotationYRateStart() {return rotationYRateStart;} - public void setRotationZ(float rotationZ1, float rotationZ2, float rotationZRate, int rotationZRateStart){ + public float getRotationY1() { + return rotationY1; + } + + public float getRotationY2() { + return rotationY2; + } + + public float getRotationYRate() { + return rotationYRate; + } + + public int getRotationYRateStart() { + return rotationYRateStart; + } + + public void setRotationZ(float rotationZ1, float rotationZ2, float rotationZRate, int rotationZRateStart) { this.rotationZ1 = rotationZ1; this.rotationZ2 = rotationZ2; this.rotationZRate = rotationZRate; this.rotationZRateStart = rotationZRateStart; } - public float getRotationZ1() {return rotationZ1;} - public float getRotationZ2() {return rotationZ2;} - public float getRotationZRate() {return rotationZRate;} - public int getRotationZRateStart() {return rotationZRateStart;} + + public float getRotationZ1() { + return rotationZ1; + } + + public float getRotationZ2() { + return rotationZ2; + } + + public float getRotationZRate() { + return rotationZRate; + } + + public int getRotationZRateStart() { + return rotationZRateStart; + } @Deprecated public void setHEXColor(int HEXColor) { this.HEXColor = HEXColor; } + @Deprecated public int getHEXColor() { return HEXColor; diff --git a/src/main/java/noppes/npcs/scripted/ScriptPixelmonPlayerData.java b/src/main/java/noppes/npcs/scripted/ScriptPixelmonPlayerData.java index d454598b4..25e0914f3 100644 --- a/src/main/java/noppes/npcs/scripted/ScriptPixelmonPlayerData.java +++ b/src/main/java/noppes/npcs/scripted/ScriptPixelmonPlayerData.java @@ -8,20 +8,21 @@ import noppes.npcs.compat.PixelmonHelper; import noppes.npcs.scripted.entity.ScriptPixelmon; public class ScriptPixelmonPlayerData implements IPixelmonPlayerData { - private EntityPlayerMP player; - public ScriptPixelmonPlayerData(EntityPlayerMP player){ - this.player = player; - } - - public ScriptPixelmon getPartySlot(int slot){ - NBTTagCompound compound = PixelmonHelper.getPartySlot(slot, player); - if(compound == null) - return null; - EntityTameable pixelmon = PixelmonHelper.pixelmonFromNBT(compound, player); - return new ScriptPixelmon(pixelmon, compound); - } - - public int countPCPixelmon(){ - return PixelmonHelper.countPCPixelmon(player); - } + private EntityPlayerMP player; + + public ScriptPixelmonPlayerData(EntityPlayerMP player) { + this.player = player; + } + + public ScriptPixelmon getPartySlot(int slot) { + NBTTagCompound compound = PixelmonHelper.getPartySlot(slot, player); + if (compound == null) + return null; + EntityTameable pixelmon = PixelmonHelper.pixelmonFromNBT(compound, player); + return new ScriptPixelmon(pixelmon, compound); + } + + public int countPCPixelmon() { + return PixelmonHelper.countPCPixelmon(player); + } } diff --git a/src/main/java/noppes/npcs/scripted/ScriptSound.java b/src/main/java/noppes/npcs/scripted/ScriptSound.java index a2a46f201..6afbb494f 100644 --- a/src/main/java/noppes/npcs/scripted/ScriptSound.java +++ b/src/main/java/noppes/npcs/scripted/ScriptSound.java @@ -30,11 +30,12 @@ public class ScriptSound implements ISound { for (Field field : ScriptSound.class.getDeclaredFields()) { try { if (field.getName().equals("sourceEntity") && this.sourceEntity != null) { - compound.setInteger("EntityID",this.sourceEntity.getEntityId()); + compound.setInteger("EntityID", this.sourceEntity.getEntityId()); } else if (!field.get(this).equals(field.get(newSound))) { compound = writeNBTTag(compound, field.getType(), field.getName(), field.get(this)); } - } catch (Exception ignored) {} + } catch (Exception ignored) { + } } return compound; @@ -94,7 +95,8 @@ public class ScriptSound implements ISound { } } } - } catch (Exception ignored) {} + } catch (Exception ignored) { + } } return particle; @@ -128,8 +130,7 @@ public class ScriptSound implements ISound { this.volume = volume; } - public float getVolume() - { + public float getVolume() { return this.volume; } @@ -137,8 +138,7 @@ public class ScriptSound implements ISound { this.pitch = pitch; } - public float getPitch() - { + public float getPitch() { return this.pitch; } diff --git a/src/main/java/noppes/npcs/scripted/ScriptTileEntity.java b/src/main/java/noppes/npcs/scripted/ScriptTileEntity.java index 1d83bffa0..89dbbd2e3 100644 --- a/src/main/java/noppes/npcs/scripted/ScriptTileEntity.java +++ b/src/main/java/noppes/npcs/scripted/ScriptTileEntity.java @@ -13,11 +13,11 @@ public class ScriptTileEntity implements ITileEntity { this.world = NpcAPI.Instance().getIWorld(tileEntity.getWorldObj()); } - public int getBlockMetadata(){ + public int getBlockMetadata() { return tileEntity.getBlockMetadata(); } - public IWorld getWorld(){ + public IWorld getWorld() { return world; } @@ -30,32 +30,31 @@ public class ScriptTileEntity implements ITileEntity { return this.tileEntity; } - public void markDirty() - { + public void markDirty() { this.tileEntity.markDirty(); } - public void readFromNBT(INbt nbt){ + public void readFromNBT(INbt nbt) { this.tileEntity.readFromNBT(nbt.getMCNBT()); } - public double getDistanceFrom(double x, double y, double z){ - return this.tileEntity.getDistanceFrom(x,y,z); + public double getDistanceFrom(double x, double y, double z) { + return this.tileEntity.getDistanceFrom(x, y, z); } - public double getDistanceFrom(IPos pos){ - return this.getDistanceFrom(pos.getXD(),pos.getYD(),pos.getZD()); + public double getDistanceFrom(IPos pos) { + return this.getDistanceFrom(pos.getXD(), pos.getYD(), pos.getZD()); } - public IBlock getBlockType(){ + public IBlock getBlockType() { return NpcAPI.Instance().getIBlock(world, tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord); } - public boolean isInvalid(){ + public boolean isInvalid() { return tileEntity.isInvalid(); } - public void invalidate(){ + public void invalidate() { tileEntity.invalidate(); } @@ -63,7 +62,7 @@ public class ScriptTileEntity implements ITileEntity { tileEntity.validate(); } - public void updateContainingBlockInfo(){ + public void updateContainingBlockInfo() { tileEntity.updateContainingBlockInfo(); } diff --git a/src/main/java/noppes/npcs/scripted/ScriptWorld.java b/src/main/java/noppes/npcs/scripted/ScriptWorld.java index 9921cf226..a413910a3 100644 --- a/src/main/java/noppes/npcs/scripted/ScriptWorld.java +++ b/src/main/java/noppes/npcs/scripted/ScriptWorld.java @@ -33,1292 +33,1200 @@ import noppes.npcs.scripted.scoreboard.ScriptScoreboard; import java.util.*; public class ScriptWorld implements IWorld { - public WorldServer world; - public ScriptWorld(WorldServer world){ - this.world = world; - } - - public static ScriptWorld createNew(int dimensionId) { - WorldServer[] worlds = CustomNpcs.getServer().worldServers; - - WorldServer world = worlds[0]; - for (WorldServer w : worlds) { - if (w.provider.dimensionId == dimensionId) { - world = w; - } - } - return new ScriptWorld(world); - } - - /** - * @return The worlds time - */ - public long getTime(){ - return world.getWorldTime(); - } - - /** - * @return The total world time - */ - public long getTotalTime(){ - return world.getTotalWorldTime(); - } - - public boolean areAllPlayersAsleep(){ - return world.areAllPlayersAsleep(); - } - - /** - * @param x World position x - * @param y World position y - * @param z World position z - * @return The block at the given position. Returns null if there isn't a block - */ - public IBlock getBlock(int x, int y, int z){ - return NpcAPI.Instance().getIBlock(this, x,y,z); - } - - /** - * @param pos - * @return The block at the given position. Returns null if there isn't a block - */ - public IBlock getBlock(IPos pos){ - return NpcAPI.Instance().getIBlock(this, pos); - } - - public boolean isBlockFreezable(IPos pos) { - return this.isBlockFreezable(pos.getX(),pos.getY(),pos.getZ()); - } - - public boolean isBlockFreezable(int x, int y, int z){ - return world.isBlockFreezable(x,y,z); - } - - public boolean isBlockFreezableNaturally(IPos pos) { - return this.isBlockFreezableNaturally(pos.getX(),pos.getY(),pos.getZ()); - } - - public boolean isBlockFreezableNaturally(int x, int y, int z){ - return world.isBlockFreezableNaturally(x,y,z); - } - - public boolean canBlockFreeze(IPos pos, boolean adjacentToWater) { - return this.canBlockFreeze(pos.getX(),pos.getY(),pos.getZ(), adjacentToWater); - } - - public boolean canBlockFreeze(int x, int y, int z, boolean adjacentToWater){ - return world.canBlockFreeze(x,y,z,adjacentToWater); - } - - public boolean canBlockFreezeBody(IPos pos, boolean adjacentToWater) { - return this.canBlockFreezeBody(pos.getX(),pos.getY(),pos.getZ(), adjacentToWater); - } - - public boolean canBlockFreezeBody(int x, int y, int z, boolean adjacentToWater){ - return world.canBlockFreezeBody(x,y,z,adjacentToWater); - } - - public boolean canSnowAt(IPos pos, boolean checkLight) { - return this.canSnowAt(pos.getX(),pos.getY(),pos.getZ(), checkLight); - } - - public boolean canSnowAt(int x, int y, int z, boolean checkLight){ - return world.func_147478_e(x,y,z,checkLight); - } - - public boolean canSnowAtBody(IPos pos, boolean checkLight) { - return this.canSnowAtBody(pos.getX(),pos.getY(),pos.getZ(), checkLight); - } - - public boolean canSnowAtBody(int x, int y, int z, boolean checkLight){ - return world.canSnowAtBody(x,y,z,checkLight); - } - - public IBlock getTopBlock(int x, int z){ - return NpcAPI.Instance().getIBlock(this, x, world.getTopSolidOrLiquidBlock(x,z) ,z); - } - - public IBlock getTopBlock(IPos pos) { - return this.getTopBlock(pos.getX(),pos.getZ()); - } - - public int getHeightValue(int x, int z){ - return world.getHeightValue(x,z); - } - - public int getHeightValue(IPos pos) { - return this.getHeightValue(pos.getX(),pos.getZ()); - } - - public int getChunkHeightMapMinimum(int x, int z){ - return world.getChunkHeightMapMinimum(x,z); - } - - public int getChunkHeightMapMinimum(IPos pos){ - return this.getChunkHeightMapMinimum(pos.getX(),pos.getZ()); - } - - public int getBlockMetadata(int x, int y, int z){ - return world.getBlockMetadata(x,y,z); - } - - public int getBlockMetadata(IPos pos){ - return this.getBlockMetadata(pos.getX(),pos.getY(),pos.getZ()); - } - - public boolean setBlockMetadataWithNotify(int x, int y, int z, int metadata, int flag){ - return world.setBlockMetadataWithNotify(x,y,z,metadata,flag); - } - - public boolean setBlockMetadataWithNotify(IPos pos, int metadata, int flag){ - return this.setBlockMetadataWithNotify(pos.getX(),pos.getY(),pos.getZ(), metadata, flag); - } - - public boolean canSeeSky(int x, int y, int z) { - return world.canBlockSeeTheSky(x, y, z); - } - public boolean canSeeSky(IPos pos) { - return canSeeSky(pos.getX(), pos.getY(), pos.getZ()); - } - - public int getFullBlockLightValue(int x, int y, int z){ - return world.getFullBlockLightValue(x,y,z); - } - - public int getFullBlockLightValue(IPos pos){ - return this.getFullBlockLightValue(pos.getX(),pos.getY(),pos.getZ()); - } - - public int getBlockLightValue(int x, int y, int z){ - return world.getBlockLightValue(x,y,z); - } - - public int getBlockLightValue(IPos pos){ - return this.getBlockLightValue(pos.getX(),pos.getY(),pos.getZ()); - } - - public void playSoundAtEntity(IEntity entity, String sound, float volume, float pitch){ - world.playSoundAtEntity(entity.getMCEntity(), sound, volume, pitch); - } - - public void playSoundToNearExcept(IPlayer player, String sound, float volume, float pitch){ - world.playSoundToNearExcept((EntityPlayerMP) player.getMCEntity(), sound, volume, pitch); - } - - public void playSound(int id, ISound sound) { - IPlayer[] players = getAllServerPlayers(); - for (IPlayer player : players) { - if (player.getDimension() == this.getDimensionID()) { - player.playSound(id, sound); - } - } - } - - public void stopSound(int id) { - IPlayer[] players = getAllServerPlayers(); - for (IPlayer player : players) { - if (player.getDimension() == this.getDimensionID()) { - player.stopSound(id); - } - } - } - - public void pauseSounds() { - IPlayer[] players = getAllServerPlayers(); - for (IPlayer player : players) { - if (player.getDimension() == this.getDimensionID()) { - player.pauseSounds(); - } - } - } - - public void continueSounds() { - IPlayer[] players = getAllServerPlayers(); - for (IPlayer player : players) { - if (player.getDimension() == this.getDimensionID()) { - player.continueSounds(); - } - } - } - - public void stopSounds() { - IPlayer[] players = getAllServerPlayers(); - for (IPlayer player : players) { - if (player.getDimension() == this.getDimensionID()) { - player.stopSounds(); - } - } - } - - public IEntity getEntityByID(int id){ - return NpcAPI.Instance().getIEntity(world.getEntityByID(id)); - } - - public boolean spawnEntityInWorld(IEntity entity){ - return world.spawnEntityInWorld(entity.getMCEntity()); - } - - public boolean spawnEntityInWorld(IEntity entity, double x, double y, double z){ - entity.setPosition(x, y, z); - return this.spawnEntityInWorld(entity); - } - - public boolean spawnEntityInWorld(IEntity entity, IPos pos) { - return this.spawnEntityInWorld(entity, pos.getX(), pos.getY(), pos.getZ()); - } - - public IPlayer getClosestPlayerToEntity(IEntity entity, double range){ - return (IPlayer) NpcAPI.Instance().getIEntity(world.getClosestPlayerToEntity(entity.getMCEntity(), range)); - } - - public IPlayer getClosestPlayer(double x, double y, double z, double range){ - return (IPlayer) NpcAPI.Instance().getIEntity(world.getClosestPlayer(x,y,z, range)); - } - - public IPlayer getClosestPlayer(IPos pos, double range){ - return this.getClosestPlayer(pos.getX(),pos.getY(),pos.getZ(), range); - } - - public IPlayer getClosestVulnerablePlayerToEntity(IEntity entity, double range){ - return (IPlayer) NpcAPI.Instance().getIEntity(world.getClosestVulnerablePlayerToEntity(entity.getMCEntity(), range)); - } - - public IPlayer getClosestVulnerablePlayer(double x, double y, double z, double range){ - return (IPlayer) NpcAPI.Instance().getIEntity(world.getClosestVulnerablePlayer(x,y,z, range)); - } - - public IPlayer getClosestVulnerablePlayer(IPos pos, double range){ - return this.getClosestVulnerablePlayer(pos.getX(),pos.getY(),pos.getZ(), range); - } - - public int countEntities(IEntity entity){ - return world.countEntities(entity.getMCEntity().getClass()); - } - - public IEntity[] getLoadedEntities() { - ArrayList list = new ArrayList<>(); - for (Object obj : world.loadedEntityList) { - list.add(NpcAPI.Instance().getIEntity((Entity) obj)); - } - - return list.toArray(new IEntity[0]); - } - - public IEntity[] getEntitiesNear(IPos position, double range) { - ArrayList list = new ArrayList<>(); - - List entities = world.getEntitiesWithinAABB(Entity.class, AxisAlignedBB.getBoundingBox( - position.getX() - range, position.getY() - range, position.getZ() - range, - position.getX() + range, position.getY() + range, position.getZ() + range)); - for(Entity entity : entities){ - list.add(NpcAPI.Instance().getIEntity(entity)); - } - - list.sort((e1, e2) -> { - double dist1 = e1.getPosition().distanceTo(position); - double dist2 = e2.getPosition().distanceTo(position); - - if (dist1 > dist2) { - return 1; - } else if (dist1 < dist2) { - return -1; - } - return 0; - }); - - return list.toArray(new IEntity[0]); - } - - public IEntity[] getEntitiesNear(double x, double y, double z, double range) { - return getEntitiesNear(NpcAPI.Instance().getIPos(x,y,z), range); - } - - public void setTileEntity(int x, int y, int z, ITileEntity tileEntity){ - world.setTileEntity(x,y,z,tileEntity.getMCTileEntity()); - } - - public void setTileEntity(IPos pos, ITileEntity tileEntity){ - this.setTileEntity(pos.getX(),pos.getY(),pos.getZ(),tileEntity); - } - - public void removeTileEntity(int x, int y, int z){ - world.removeTileEntity(x,y,z); - } - - public void removeTileEntity(IPos pos){ - this.removeTileEntity(pos.getX(),pos.getY(),pos.getZ()); - } - - public boolean isBlockFullCube(int x, int y, int z){ - return world.func_147469_q(x,y,z); - } - - public boolean isBlockFullCube(IPos pos){ - return this.isBlockFullCube(pos.getX(),pos.getY(),pos.getZ()); - } - - public long getSeed(){ - return world.getSeed(); - } - - public void setSpawnLocation(int x, int y, int z){ - world.setSpawnLocation(x,y,z); - } - - public void setSpawnLocation(IPos pos){ - this.setSpawnLocation(pos.getX(),pos.getY(),pos.getZ()); - } - - public boolean canLightningStrikeAt(int x, int y, int z){ - return world.canLightningStrikeAt(x,y,z); - } - - public boolean canLightningStrikeAt(IPos pos){ - return this.canLightningStrikeAt(pos.getX(),pos.getY(),pos.getZ()); - } - - public boolean isBlockHighHumidity(int x, int y, int z){ - return world.isBlockHighHumidity(x,y,z); - } - - public boolean isBlockHighHumidity(IPos pos){ - return this.canLightningStrikeAt(pos.getX(),pos.getY(),pos.getZ()); - } - - /** - * @param x World position x - * @param y World position y - * @param z World position z - * @return Text from signs - * @since 1.7.10d - */ - public String getSignText(int x, int y, int z){ - TileEntity tile = world.getTileEntity(x, y, z); - - if(tile instanceof TileBigSign) - return ((TileBigSign)tile).getText(); - - if(tile instanceof TileEntitySign){ - TileEntitySign tileSign = (TileEntitySign)tile; - String s = tileSign.signText[0] + "\n"; - s += tileSign.signText[1] + "\n"; - s += tileSign.signText[2] + "\n"; - s += tileSign.signText[3]; - return s; - } - - return null; - } - public String getSignText(IPos pos) { - return this.getSignText(pos.getX(),pos.getY(),pos.getZ()); - } - - - public boolean setBlock(int x, int y, int z, IBlock block){ - if(block == null || block.getMCBlock().isAir(world, x, y, z)){ - this.removeBlock(x, y, z); - return false; - } - return world.setBlock(x, y, z, block.getMCBlock()); - } - - public boolean setBlock(IPos pos, IBlock block){ - return this.setBlock(pos.getX(),pos.getY(),pos.getZ(),block); - } - - /** - * @param x World position x - * @param y World position y - * @param z World position z - * @param item The block to be set - */ - public boolean setBlock(int x, int y, int z, IItemStack item){ - if(item == null){ - this.removeBlock(x, y, z); - return false; - } - Block block = Block.getBlockFromItem(item.getMCItemStack().getItem()); - if(block == null || block == Blocks.air) - return false; - - return world.setBlock(x, y, z, block); - } - - public boolean setBlock(IPos pos, IItemStack itemStack){ - return this.setBlock(pos.getX(),pos.getY(),pos.getZ(),itemStack); - } - - /** - * @param x World position x - * @param y World position y - * @param z World position z - */ - public void removeBlock(int x, int y, int z){ - world.setBlock(x, y, z, Blocks.air); - } - - public void removeBlock(IPos pos){ - this.removeBlock(pos.getX(),pos.getY(),pos.getZ()); - } - - public boolean isPlaceCancelled(int posX, int posY, int posZ) { - IBlock block = this.getBlock(posX,posY,posZ); - if (block == null) { - return false; - } - - Block mcBlock = block.getMCBlock(); - int metadata = this.getBlockMetadata(posX,posY,posZ); - - FakePlayer fakePlayer = new FakePlayer(this.world, EntityNPCInterface.chateventProfile); - IItemStack stack = NpcAPI.Instance().createItem("minecraft:stone",0,1); - fakePlayer.setCurrentItemOrArmor(0, stack.getMCItemStack()); - - final BlockEvent.PlaceEvent placeEvent = new BlockEvent.PlaceEvent( - new BlockSnapshot(this.world, (int)Math.floor(posX), (int)Math.floor(posY), (int)Math.floor(posZ), mcBlock, metadata), - Blocks.air, fakePlayer); - - MinecraftForge.EVENT_BUS.post(placeEvent); - - return placeEvent.isCanceled(); - } - - public boolean isPlaceCancelled(IPos pos) { - return this.isPlaceCancelled(pos.getX(),pos.getY(),pos.getZ()); - } - - public boolean isBreakCancelled(int posX, int posY, int posZ) { - IBlock block = this.getBlock(posX,posY,posZ); - if (block == null) { - return false; - } - - Block mcBlock = block.getMCBlock(); - int metadata = this.getBlockMetadata(posX,posY,posZ); - - FakePlayer fakePlayer = new FakePlayer(this.world, EntityNPCInterface.chateventProfile); - IItemStack stack = NpcAPI.Instance().createItem("minecraft:stone",0,1); - fakePlayer.setCurrentItemOrArmor(0, stack.getMCItemStack()); - - final BlockEvent.BreakEvent placeEvent = new BlockEvent.BreakEvent(posX, posY, posZ, world, - mcBlock, metadata, fakePlayer); - - MinecraftForge.EVENT_BUS.post(placeEvent); - - return placeEvent.isCanceled(); - } - - public boolean isBreakCancelled(IPos pos) { - return this.isBreakCancelled(pos.getX(),pos.getY(),pos.getZ()); - } - - public MovingObjectPosition rayCast(Vec3 startVec, Vec3 endVec, boolean stopOnBlock, boolean stopOnLiquid, boolean stopOnCollision) - { - if (!Double.isNaN(startVec.xCoord) && !Double.isNaN(startVec.yCoord) && !Double.isNaN(startVec.zCoord)) - { - if (!Double.isNaN(endVec.xCoord) && !Double.isNaN(endVec.yCoord) && !Double.isNaN(endVec.zCoord)) - { - int endX = MathHelper.floor_double(endVec.xCoord); - int endY = MathHelper.floor_double(endVec.yCoord); - int endZ = MathHelper.floor_double(endVec.zCoord); - int l = MathHelper.floor_double(startVec.xCoord); - int i1 = MathHelper.floor_double(startVec.yCoord); - int j1 = MathHelper.floor_double(startVec.zCoord); - Block block = this.world.getBlock(l, i1, j1); - int k1 = this.world.getBlockMetadata(l, i1, j1); - - if (block.canCollideCheck(k1, false)) - { - MovingObjectPosition movingobjectposition = block.collisionRayTrace(this.world, l, i1, j1, startVec, endVec); - - if (movingobjectposition != null) - { - return movingobjectposition; - } - } - - k1 = 200; - - while (k1-- >= 0) - { - if (Double.isNaN(startVec.xCoord) || Double.isNaN(startVec.yCoord) || Double.isNaN(startVec.zCoord)) - { - return null; - } - - if (l == endX && i1 == endY && j1 == endZ) - { - return null; - } - - boolean flag6 = true; - boolean flag3 = true; - boolean flag4 = true; - double d0 = 999.0D; - double d1 = 999.0D; - double d2 = 999.0D; - - if (endX > l) - { - d0 = (double)l + 1.0D; - } - else if (endX < l) - { - d0 = (double)l + 0.0D; - } - else - { - flag6 = false; - } - - if (endY > i1) - { - d1 = (double)i1 + 1.0D; - } - else if (endY < i1) - { - d1 = (double)i1 + 0.0D; - } - else - { - flag3 = false; - } - - if (endZ > j1) - { - d2 = (double)j1 + 1.0D; - } - else if (endZ < j1) - { - d2 = (double)j1 + 0.0D; - } - else - { - flag4 = false; - } - - double d3 = 999.0D; - double d4 = 999.0D; - double d5 = 999.0D; - double d6 = endVec.xCoord - startVec.xCoord; - double d7 = endVec.yCoord - startVec.yCoord; - double d8 = endVec.zCoord - startVec.zCoord; - - if (flag6) - { - d3 = (d0 - startVec.xCoord) / d6; - } - - if (flag3) - { - d4 = (d1 - startVec.yCoord) / d7; - } - - if (flag4) - { - d5 = (d2 - startVec.zCoord) / d8; - } - - byte b0; - - if (d3 < d4 && d3 < d5) - { - if (endX > l) - { - b0 = 4; - } - else - { - b0 = 5; - } - - startVec.xCoord = d0; - startVec.yCoord += d7 * d3; - startVec.zCoord += d8 * d3; - } - else if (d4 < d5) - { - if (endY > i1) - { - b0 = 0; - } - else - { - b0 = 1; - } - - startVec.xCoord += d6 * d4; - startVec.yCoord = d1; - startVec.zCoord += d8 * d4; - } - else - { - if (endZ > j1) - { - b0 = 2; - } - else - { - b0 = 3; - } - - startVec.xCoord += d6 * d5; - startVec.yCoord += d7 * d5; - startVec.zCoord = d2; - } - - Vec3 vec32 = Vec3.createVectorHelper(startVec.xCoord, startVec.yCoord, startVec.zCoord); - l = (int)(vec32.xCoord = (double)MathHelper.floor_double(startVec.xCoord)); - - if (b0 == 5) - { - --l; - ++vec32.xCoord; - } - - i1 = (int)(vec32.yCoord = (double)MathHelper.floor_double(startVec.yCoord)); - - if (b0 == 1) - { - --i1; - ++vec32.yCoord; - } - - j1 = (int)(vec32.zCoord = (double)MathHelper.floor_double(startVec.zCoord)); - - if (b0 == 3) - { - --j1; - ++vec32.zCoord; - } - - Block block1 = this.world.getBlock(l, i1, j1); - int l1 = this.world.getBlockMetadata(l, i1, j1); - - MovingObjectPosition movingobjectposition1 = block1.collisionRayTrace(this.world, l, i1, j1, startVec, endVec); - if (movingobjectposition1 != null) - { - if (block1.canCollideCheck(l1, false) && stopOnBlock || - block1.getMaterial().isLiquid() && stopOnLiquid || - !(block1 instanceof BlockAir) && block1.getCollisionBoundingBoxFromPool(this.world,l,i1,j1) == null && !stopOnCollision) - { - return movingobjectposition1; - } - } - } - - return null; - } - else - { - return null; - } - } - else - { - return null; - } - } - - public IPos rayCastPos(double[] startPos, double[] lookVector, int maxDistance, boolean stopOnBlock, boolean stopOnLiquid, boolean stopOnCollision) { - if (startPos.length != 3 || lookVector.length != 3) { - return null; - } - - Vec3 startVec = Vec3.createVectorHelper(startPos[0], startPos[1], startPos[2]); - Vec3 endVec = startVec.addVector(lookVector[0]*maxDistance,lookVector[1]*maxDistance,lookVector[2]*maxDistance); - - IPos endPos = NpcAPI.Instance().getIPos(endVec.xCoord,endVec.yCoord,endVec.zCoord); - if (!stopOnBlock && !stopOnLiquid && !stopOnCollision) { - return endPos; - } - - MovingObjectPosition mob = this.rayCast(startVec,endVec,stopOnBlock,stopOnLiquid,stopOnCollision); - return mob != null ? NpcAPI.Instance().getIPos(mob.blockX,mob.blockY,mob.blockZ) : endPos; - } - - public IPos rayCastPos(double[] startPos, double[] lookVector, int maxDistance) { - return rayCastPos(startPos,lookVector,maxDistance,true, false, false); - } - - public IPos rayCastPos(IPos startPos, IPos lookVector, int maxDistance, boolean stopOnBlock, boolean stopOnLiquid, boolean stopOnCollision) { - return rayCastPos(new double[] {startPos.getX(), startPos.getY(), startPos.getZ()}, lookVector.normalizeDouble(), maxDistance, stopOnBlock, stopOnLiquid, stopOnCollision); - } - - public IPos rayCastPos(IPos startPos, IPos lookVector, int maxDistance) { - return rayCastPos(new double[] {startPos.getX(), startPos.getY(), startPos.getZ()}, lookVector.normalizeDouble(), maxDistance, true, false, false); - } - - public IBlock rayCastBlock(double[] startPos, double[] lookVector, int maxDistance, boolean stopOnBlock, boolean stopOnLiquid, boolean stopOnCollision) { - return getBlock(rayCastPos(startPos,lookVector,maxDistance,stopOnBlock,stopOnLiquid,stopOnCollision)); - } - - public IBlock rayCastBlock(double[] startPos, double[] lookVector, int maxDistance) { - return rayCastBlock(startPos, lookVector, maxDistance, true, false, false); - } - - public IBlock rayCastBlock(IPos startPos, IPos lookVector, int maxDistance, boolean stopOnBlock, boolean stopOnLiquid, boolean stopOnCollision) { - return rayCastBlock(new double[] {startPos.getX(), startPos.getY(), startPos.getZ()}, lookVector.normalizeDouble(), maxDistance, stopOnBlock, stopOnLiquid, stopOnCollision); - } - - public IBlock rayCastBlock(IPos startPos, IPos lookVector, int maxDistance) { - return rayCastBlock(new double[] {startPos.getX(), startPos.getY(), startPos.getZ()}, lookVector.normalizeDouble(), maxDistance); - } - - public IPos getNearestAir(IPos pos, int maxHeight) { - if (pos == null) return null; - IPos currentPos = pos; - IBlock block = null; int rep = 0; - while (rep++ < maxHeight) { - //check +x - currentPos = currentPos.add(1, 0, 0); - block = getBlock(currentPos); - if (block == null) break; - //check -x - currentPos = currentPos.add(-2, 0, 0); - block = getBlock(currentPos); - if (block == null) break; - //check +z - currentPos = currentPos.add(1, 0, 1); - block = getBlock(currentPos); - if (block == null) break; - //check -z - currentPos = currentPos.add(0, 0, -2); - block = getBlock(currentPos); - if (block == null) break; - //check up 1 - currentPos = currentPos.add(0, 1, 1); - block = getBlock(currentPos); - if (block == null) break; - } - return currentPos; - } - - public IEntity[] rayCastEntities(double[] startPos, double[] lookVector, - int maxDistance, double offset, double range, - boolean stopOnBlock, boolean stopOnLiquid, boolean stopOnCollision) { - return rayCastEntities(null,startPos,lookVector,maxDistance,offset,range,stopOnBlock,stopOnLiquid,stopOnCollision); - } - - public IEntity[] rayCastEntities(IEntity[] ignoreEntities, double[] startPos, double[] lookVector, - int maxDistance, double offset, double range, - boolean stopOnBlock, boolean stopOnLiquid, boolean stopOnCollision) { - if (ignoreEntities == null) { - ignoreEntities = new IEntity[0]; - } - - Vec3 startVec = Vec3.createVectorHelper(startPos[0], startPos[1], startPos[2]); - Vec3 endVec = startVec.addVector(lookVector[0]*maxDistance,lookVector[1]*maxDistance,lookVector[2]*maxDistance); - startVec = startVec.addVector(lookVector[0]*offset, lookVector[1]*offset, lookVector[2]*offset); - - LinkedHashSet ignoredEntitiesSet = new LinkedHashSet<>(); - Collections.addAll(ignoredEntitiesSet, ignoreEntities); - - Set> entities = this.rayCastEntities(ignoredEntitiesSet,startVec,endVec,range,stopOnBlock,stopOnLiquid,stopOnCollision); - return entities.toArray(new IEntity[0]); - } - - public Set> rayCastEntities(LinkedHashSet ignoredEntitiesSet, Vec3 startVec, Vec3 endVec, double range, boolean stopOnBlock, boolean stopOnLiquid, boolean stopOnCollision) - { - LinkedHashSet> entities = new LinkedHashSet<>(); - - if (!Double.isNaN(startVec.xCoord) && !Double.isNaN(startVec.yCoord) && !Double.isNaN(startVec.zCoord)) - { - if (!Double.isNaN(endVec.xCoord) && !Double.isNaN(endVec.yCoord) && !Double.isNaN(endVec.zCoord)) - { - int endX = MathHelper.floor_double(endVec.xCoord); - int endY = MathHelper.floor_double(endVec.yCoord); - int endZ = MathHelper.floor_double(endVec.zCoord); - int l = MathHelper.floor_double(startVec.xCoord); - int i1 = MathHelper.floor_double(startVec.yCoord); - int j1 = MathHelper.floor_double(startVec.zCoord); - Block block = this.world.getBlock(l, i1, j1); - int k1 = this.world.getBlockMetadata(l, i1, j1); - - IEntity[] surrounding = this.getEntitiesNear(l,i1,j1,range); - for (IEntity entity : surrounding) { - if (!ignoredEntitiesSet.contains(entity)) { - entities.add(entity); - } - } - - if (block.canCollideCheck(k1, false)) - { - MovingObjectPosition movingobjectposition = block.collisionRayTrace(this.world, l, i1, j1, startVec, endVec); - - if (movingobjectposition != null) - { - return entities; - } - } - - k1 = 200; - - while (k1-- >= 0) - { - if (Double.isNaN(startVec.xCoord) || Double.isNaN(startVec.yCoord) || Double.isNaN(startVec.zCoord)) - { - return entities; - } - - if (l == endX && i1 == endY && j1 == endZ) - { - return entities; - } - - boolean flag6 = true; - boolean flag3 = true; - boolean flag4 = true; - double d0 = 999.0D; - double d1 = 999.0D; - double d2 = 999.0D; - - if (endX > l) - { - d0 = (double)l + 1.0D; - } - else if (endX < l) - { - d0 = (double)l + 0.0D; - } - else - { - flag6 = false; - } - - if (endY > i1) - { - d1 = (double)i1 + 1.0D; - } - else if (endY < i1) - { - d1 = (double)i1 + 0.0D; - } - else - { - flag3 = false; - } - - if (endZ > j1) - { - d2 = (double)j1 + 1.0D; - } - else if (endZ < j1) - { - d2 = (double)j1 + 0.0D; - } - else - { - flag4 = false; - } - - double d3 = 999.0D; - double d4 = 999.0D; - double d5 = 999.0D; - double d6 = endVec.xCoord - startVec.xCoord; - double d7 = endVec.yCoord - startVec.yCoord; - double d8 = endVec.zCoord - startVec.zCoord; - - if (flag6) - { - d3 = (d0 - startVec.xCoord) / d6; - } - - if (flag3) - { - d4 = (d1 - startVec.yCoord) / d7; - } - - if (flag4) - { - d5 = (d2 - startVec.zCoord) / d8; - } - - byte b0; - - if (d3 < d4 && d3 < d5) - { - if (endX > l) - { - b0 = 4; - } - else - { - b0 = 5; - } - - startVec.xCoord = d0; - startVec.yCoord += d7 * d3; - startVec.zCoord += d8 * d3; - } - else if (d4 < d5) - { - if (endY > i1) - { - b0 = 0; - } - else - { - b0 = 1; - } - - startVec.xCoord += d6 * d4; - startVec.yCoord = d1; - startVec.zCoord += d8 * d4; - } - else - { - if (endZ > j1) - { - b0 = 2; - } - else - { - b0 = 3; - } - - startVec.xCoord += d6 * d5; - startVec.yCoord += d7 * d5; - startVec.zCoord = d2; - } - - Vec3 vec32 = Vec3.createVectorHelper(startVec.xCoord, startVec.yCoord, startVec.zCoord); - l = (int)(vec32.xCoord = (double)MathHelper.floor_double(startVec.xCoord)); - - if (b0 == 5) - { - --l; - ++vec32.xCoord; - } - - i1 = (int)(vec32.yCoord = (double)MathHelper.floor_double(startVec.yCoord)); - - if (b0 == 1) - { - --i1; - ++vec32.yCoord; - } - - j1 = (int)(vec32.zCoord = (double)MathHelper.floor_double(startVec.zCoord)); - - if (b0 == 3) - { - --j1; - ++vec32.zCoord; - } - - Block block1 = this.world.getBlock(l, i1, j1); - int l1 = this.world.getBlockMetadata(l, i1, j1); - - IEntity[] surroundingEntities = this.getEntitiesNear(l,i1,j1,range); - for (IEntity entity : surroundingEntities) { - if (!ignoredEntitiesSet.contains(entity)) { - entities.add(entity); - } - } - - MovingObjectPosition movingobjectposition1 = block1.collisionRayTrace(this.world, l, i1, j1, startVec, endVec); - if (movingobjectposition1 != null) - { - if (block1.canCollideCheck(l1, false) && stopOnBlock || - block1.getMaterial().isLiquid() && stopOnLiquid || - !(block1 instanceof BlockAir) && block1.getCollisionBoundingBoxFromPool(this.world,l,i1,j1) == null && !stopOnCollision) - { - return entities; - } - } - } - - return entities; - } - else - { - return entities; - } - } - else - { - return entities; - } - } - - public IEntity[] rayCastEntities(IPos startPos, IPos lookVector, - int maxDistance, double offset, double range, - boolean stopOnBlock, boolean stopOnLiquid, boolean stopOnCollision) { - return rayCastEntities(new double[] {startPos.getX(), startPos.getY(), startPos.getZ()}, lookVector.normalizeDouble(), maxDistance, offset, range, stopOnBlock, stopOnLiquid, stopOnCollision); - } - - public IEntity[] rayCastEntities(double[] startPos, double[] lookVector, - int maxDistance, double offset, double range) { - return rayCastEntities(startPos, lookVector, maxDistance, offset, range, true, false, true); - } - - public IEntity[] rayCastEntities(IPos startPos, IPos lookVector, - int maxDistance, double offset, double range) { - return rayCastEntities(new double[] {startPos.getX(), startPos.getY(), startPos.getZ()}, lookVector.normalizeDouble(), maxDistance, offset, range, true, false, true); - } - - @Deprecated - /** - * Deprecated. Use NpcAPI.Instance().getPlayer(name) instead. - */ - public IPlayer getPlayer(String name){ - EntityPlayer player = world.getPlayerEntityByName(name); - if(player == null) - return null; - return (IPlayer) NpcAPI.Instance().getIEntity(player); - } - - public IPlayer getPlayerByUUID(String uuid){ - return (IPlayer) NpcAPI.Instance().getIEntity(world.func_152378_a(UUID.fromString(uuid))); - } - - /** - * @param time The world time to be set - */ - public void setTime(long time){ - world.setWorldTime(time); - } - - /** - * @return Whether or not its daytime - */ - public boolean isDay(){ - return world.getWorldTime() % 24000 < 12000; - } - - /** - * @return Whether or not its currently raining - */ - public boolean isRaining(){ - return world.getWorldInfo().isRaining(); - } - - /** - * @param bo Set if it's raining - */ - public void setRaining(boolean bo){ - world.getWorldInfo().setRaining(bo); - } - - /** - * @param x The x position - * @param y The y position - * @param z The z position - */ - public void thunderStrike(double x, double y, double z){ + public WorldServer world; + + public ScriptWorld(WorldServer world) { + this.world = world; + } + + public static ScriptWorld createNew(int dimensionId) { + WorldServer[] worlds = CustomNpcs.getServer().worldServers; + + WorldServer world = worlds[0]; + for (WorldServer w : worlds) { + if (w.provider.dimensionId == dimensionId) { + world = w; + } + } + return new ScriptWorld(world); + } + + /** + * @return The worlds time + */ + public long getTime() { + return world.getWorldTime(); + } + + /** + * @return The total world time + */ + public long getTotalTime() { + return world.getTotalWorldTime(); + } + + public boolean areAllPlayersAsleep() { + return world.areAllPlayersAsleep(); + } + + /** + * @param x World position x + * @param y World position y + * @param z World position z + * @return The block at the given position. Returns null if there isn't a block + */ + public IBlock getBlock(int x, int y, int z) { + return NpcAPI.Instance().getIBlock(this, x, y, z); + } + + /** + * @param pos + * @return The block at the given position. Returns null if there isn't a block + */ + public IBlock getBlock(IPos pos) { + return NpcAPI.Instance().getIBlock(this, pos); + } + + public boolean isBlockFreezable(IPos pos) { + return this.isBlockFreezable(pos.getX(), pos.getY(), pos.getZ()); + } + + public boolean isBlockFreezable(int x, int y, int z) { + return world.isBlockFreezable(x, y, z); + } + + public boolean isBlockFreezableNaturally(IPos pos) { + return this.isBlockFreezableNaturally(pos.getX(), pos.getY(), pos.getZ()); + } + + public boolean isBlockFreezableNaturally(int x, int y, int z) { + return world.isBlockFreezableNaturally(x, y, z); + } + + public boolean canBlockFreeze(IPos pos, boolean adjacentToWater) { + return this.canBlockFreeze(pos.getX(), pos.getY(), pos.getZ(), adjacentToWater); + } + + public boolean canBlockFreeze(int x, int y, int z, boolean adjacentToWater) { + return world.canBlockFreeze(x, y, z, adjacentToWater); + } + + public boolean canBlockFreezeBody(IPos pos, boolean adjacentToWater) { + return this.canBlockFreezeBody(pos.getX(), pos.getY(), pos.getZ(), adjacentToWater); + } + + public boolean canBlockFreezeBody(int x, int y, int z, boolean adjacentToWater) { + return world.canBlockFreezeBody(x, y, z, adjacentToWater); + } + + public boolean canSnowAt(IPos pos, boolean checkLight) { + return this.canSnowAt(pos.getX(), pos.getY(), pos.getZ(), checkLight); + } + + public boolean canSnowAt(int x, int y, int z, boolean checkLight) { + return world.func_147478_e(x, y, z, checkLight); + } + + public boolean canSnowAtBody(IPos pos, boolean checkLight) { + return this.canSnowAtBody(pos.getX(), pos.getY(), pos.getZ(), checkLight); + } + + public boolean canSnowAtBody(int x, int y, int z, boolean checkLight) { + return world.canSnowAtBody(x, y, z, checkLight); + } + + public IBlock getTopBlock(int x, int z) { + return NpcAPI.Instance().getIBlock(this, x, world.getTopSolidOrLiquidBlock(x, z), z); + } + + public IBlock getTopBlock(IPos pos) { + return this.getTopBlock(pos.getX(), pos.getZ()); + } + + public int getHeightValue(int x, int z) { + return world.getHeightValue(x, z); + } + + public int getHeightValue(IPos pos) { + return this.getHeightValue(pos.getX(), pos.getZ()); + } + + public int getChunkHeightMapMinimum(int x, int z) { + return world.getChunkHeightMapMinimum(x, z); + } + + public int getChunkHeightMapMinimum(IPos pos) { + return this.getChunkHeightMapMinimum(pos.getX(), pos.getZ()); + } + + public int getBlockMetadata(int x, int y, int z) { + return world.getBlockMetadata(x, y, z); + } + + public int getBlockMetadata(IPos pos) { + return this.getBlockMetadata(pos.getX(), pos.getY(), pos.getZ()); + } + + public boolean setBlockMetadataWithNotify(int x, int y, int z, int metadata, int flag) { + return world.setBlockMetadataWithNotify(x, y, z, metadata, flag); + } + + public boolean setBlockMetadataWithNotify(IPos pos, int metadata, int flag) { + return this.setBlockMetadataWithNotify(pos.getX(), pos.getY(), pos.getZ(), metadata, flag); + } + + public boolean canSeeSky(int x, int y, int z) { + return world.canBlockSeeTheSky(x, y, z); + } + + public boolean canSeeSky(IPos pos) { + return canSeeSky(pos.getX(), pos.getY(), pos.getZ()); + } + + public int getFullBlockLightValue(int x, int y, int z) { + return world.getFullBlockLightValue(x, y, z); + } + + public int getFullBlockLightValue(IPos pos) { + return this.getFullBlockLightValue(pos.getX(), pos.getY(), pos.getZ()); + } + + public int getBlockLightValue(int x, int y, int z) { + return world.getBlockLightValue(x, y, z); + } + + public int getBlockLightValue(IPos pos) { + return this.getBlockLightValue(pos.getX(), pos.getY(), pos.getZ()); + } + + public void playSoundAtEntity(IEntity entity, String sound, float volume, float pitch) { + world.playSoundAtEntity(entity.getMCEntity(), sound, volume, pitch); + } + + public void playSoundToNearExcept(IPlayer player, String sound, float volume, float pitch) { + world.playSoundToNearExcept((EntityPlayerMP) player.getMCEntity(), sound, volume, pitch); + } + + public void playSound(int id, ISound sound) { + IPlayer[] players = getAllServerPlayers(); + for (IPlayer player : players) { + if (player.getDimension() == this.getDimensionID()) { + player.playSound(id, sound); + } + } + } + + public void stopSound(int id) { + IPlayer[] players = getAllServerPlayers(); + for (IPlayer player : players) { + if (player.getDimension() == this.getDimensionID()) { + player.stopSound(id); + } + } + } + + public void pauseSounds() { + IPlayer[] players = getAllServerPlayers(); + for (IPlayer player : players) { + if (player.getDimension() == this.getDimensionID()) { + player.pauseSounds(); + } + } + } + + public void continueSounds() { + IPlayer[] players = getAllServerPlayers(); + for (IPlayer player : players) { + if (player.getDimension() == this.getDimensionID()) { + player.continueSounds(); + } + } + } + + public void stopSounds() { + IPlayer[] players = getAllServerPlayers(); + for (IPlayer player : players) { + if (player.getDimension() == this.getDimensionID()) { + player.stopSounds(); + } + } + } + + public IEntity getEntityByID(int id) { + return NpcAPI.Instance().getIEntity(world.getEntityByID(id)); + } + + public boolean spawnEntityInWorld(IEntity entity) { + return world.spawnEntityInWorld(entity.getMCEntity()); + } + + public boolean spawnEntityInWorld(IEntity entity, double x, double y, double z) { + entity.setPosition(x, y, z); + return this.spawnEntityInWorld(entity); + } + + public boolean spawnEntityInWorld(IEntity entity, IPos pos) { + return this.spawnEntityInWorld(entity, pos.getX(), pos.getY(), pos.getZ()); + } + + public IPlayer getClosestPlayerToEntity(IEntity entity, double range) { + return (IPlayer) NpcAPI.Instance().getIEntity(world.getClosestPlayerToEntity(entity.getMCEntity(), range)); + } + + public IPlayer getClosestPlayer(double x, double y, double z, double range) { + return (IPlayer) NpcAPI.Instance().getIEntity(world.getClosestPlayer(x, y, z, range)); + } + + public IPlayer getClosestPlayer(IPos pos, double range) { + return this.getClosestPlayer(pos.getX(), pos.getY(), pos.getZ(), range); + } + + public IPlayer getClosestVulnerablePlayerToEntity(IEntity entity, double range) { + return (IPlayer) NpcAPI.Instance().getIEntity(world.getClosestVulnerablePlayerToEntity(entity.getMCEntity(), range)); + } + + public IPlayer getClosestVulnerablePlayer(double x, double y, double z, double range) { + return (IPlayer) NpcAPI.Instance().getIEntity(world.getClosestVulnerablePlayer(x, y, z, range)); + } + + public IPlayer getClosestVulnerablePlayer(IPos pos, double range) { + return this.getClosestVulnerablePlayer(pos.getX(), pos.getY(), pos.getZ(), range); + } + + public int countEntities(IEntity entity) { + return world.countEntities(entity.getMCEntity().getClass()); + } + + public IEntity[] getLoadedEntities() { + ArrayList list = new ArrayList<>(); + for (Object obj : world.loadedEntityList) { + list.add(NpcAPI.Instance().getIEntity((Entity) obj)); + } + + return list.toArray(new IEntity[0]); + } + + public IEntity[] getEntitiesNear(IPos position, double range) { + ArrayList list = new ArrayList<>(); + + List entities = world.getEntitiesWithinAABB(Entity.class, AxisAlignedBB.getBoundingBox( + position.getX() - range, position.getY() - range, position.getZ() - range, + position.getX() + range, position.getY() + range, position.getZ() + range)); + for (Entity entity : entities) { + list.add(NpcAPI.Instance().getIEntity(entity)); + } + + list.sort((e1, e2) -> { + double dist1 = e1.getPosition().distanceTo(position); + double dist2 = e2.getPosition().distanceTo(position); + + if (dist1 > dist2) { + return 1; + } else if (dist1 < dist2) { + return -1; + } + return 0; + }); + + return list.toArray(new IEntity[0]); + } + + public IEntity[] getEntitiesNear(double x, double y, double z, double range) { + return getEntitiesNear(NpcAPI.Instance().getIPos(x, y, z), range); + } + + public void setTileEntity(int x, int y, int z, ITileEntity tileEntity) { + world.setTileEntity(x, y, z, tileEntity.getMCTileEntity()); + } + + public void setTileEntity(IPos pos, ITileEntity tileEntity) { + this.setTileEntity(pos.getX(), pos.getY(), pos.getZ(), tileEntity); + } + + public void removeTileEntity(int x, int y, int z) { + world.removeTileEntity(x, y, z); + } + + public void removeTileEntity(IPos pos) { + this.removeTileEntity(pos.getX(), pos.getY(), pos.getZ()); + } + + public boolean isBlockFullCube(int x, int y, int z) { + return world.func_147469_q(x, y, z); + } + + public boolean isBlockFullCube(IPos pos) { + return this.isBlockFullCube(pos.getX(), pos.getY(), pos.getZ()); + } + + public long getSeed() { + return world.getSeed(); + } + + public void setSpawnLocation(int x, int y, int z) { + world.setSpawnLocation(x, y, z); + } + + public void setSpawnLocation(IPos pos) { + this.setSpawnLocation(pos.getX(), pos.getY(), pos.getZ()); + } + + public boolean canLightningStrikeAt(int x, int y, int z) { + return world.canLightningStrikeAt(x, y, z); + } + + public boolean canLightningStrikeAt(IPos pos) { + return this.canLightningStrikeAt(pos.getX(), pos.getY(), pos.getZ()); + } + + public boolean isBlockHighHumidity(int x, int y, int z) { + return world.isBlockHighHumidity(x, y, z); + } + + public boolean isBlockHighHumidity(IPos pos) { + return this.canLightningStrikeAt(pos.getX(), pos.getY(), pos.getZ()); + } + + /** + * @param x World position x + * @param y World position y + * @param z World position z + * @return Text from signs + * @since 1.7.10d + */ + public String getSignText(int x, int y, int z) { + TileEntity tile = world.getTileEntity(x, y, z); + + if (tile instanceof TileBigSign) + return ((TileBigSign) tile).getText(); + + if (tile instanceof TileEntitySign) { + TileEntitySign tileSign = (TileEntitySign) tile; + String s = tileSign.signText[0] + "\n"; + s += tileSign.signText[1] + "\n"; + s += tileSign.signText[2] + "\n"; + s += tileSign.signText[3]; + return s; + } + + return null; + } + + public String getSignText(IPos pos) { + return this.getSignText(pos.getX(), pos.getY(), pos.getZ()); + } + + + public boolean setBlock(int x, int y, int z, IBlock block) { + if (block == null || block.getMCBlock().isAir(world, x, y, z)) { + this.removeBlock(x, y, z); + return false; + } + return world.setBlock(x, y, z, block.getMCBlock()); + } + + public boolean setBlock(IPos pos, IBlock block) { + return this.setBlock(pos.getX(), pos.getY(), pos.getZ(), block); + } + + /** + * @param x World position x + * @param y World position y + * @param z World position z + * @param item The block to be set + */ + public boolean setBlock(int x, int y, int z, IItemStack item) { + if (item == null) { + this.removeBlock(x, y, z); + return false; + } + Block block = Block.getBlockFromItem(item.getMCItemStack().getItem()); + if (block == null || block == Blocks.air) + return false; + + return world.setBlock(x, y, z, block); + } + + public boolean setBlock(IPos pos, IItemStack itemStack) { + return this.setBlock(pos.getX(), pos.getY(), pos.getZ(), itemStack); + } + + /** + * @param x World position x + * @param y World position y + * @param z World position z + */ + public void removeBlock(int x, int y, int z) { + world.setBlock(x, y, z, Blocks.air); + } + + public void removeBlock(IPos pos) { + this.removeBlock(pos.getX(), pos.getY(), pos.getZ()); + } + + public boolean isPlaceCancelled(int posX, int posY, int posZ) { + IBlock block = this.getBlock(posX, posY, posZ); + if (block == null) { + return false; + } + + Block mcBlock = block.getMCBlock(); + int metadata = this.getBlockMetadata(posX, posY, posZ); + + FakePlayer fakePlayer = new FakePlayer(this.world, EntityNPCInterface.chateventProfile); + IItemStack stack = NpcAPI.Instance().createItem("minecraft:stone", 0, 1); + fakePlayer.setCurrentItemOrArmor(0, stack.getMCItemStack()); + + final BlockEvent.PlaceEvent placeEvent = new BlockEvent.PlaceEvent( + new BlockSnapshot(this.world, (int) Math.floor(posX), (int) Math.floor(posY), (int) Math.floor(posZ), mcBlock, metadata), + Blocks.air, fakePlayer); + + MinecraftForge.EVENT_BUS.post(placeEvent); + + return placeEvent.isCanceled(); + } + + public boolean isPlaceCancelled(IPos pos) { + return this.isPlaceCancelled(pos.getX(), pos.getY(), pos.getZ()); + } + + public boolean isBreakCancelled(int posX, int posY, int posZ) { + IBlock block = this.getBlock(posX, posY, posZ); + if (block == null) { + return false; + } + + Block mcBlock = block.getMCBlock(); + int metadata = this.getBlockMetadata(posX, posY, posZ); + + FakePlayer fakePlayer = new FakePlayer(this.world, EntityNPCInterface.chateventProfile); + IItemStack stack = NpcAPI.Instance().createItem("minecraft:stone", 0, 1); + fakePlayer.setCurrentItemOrArmor(0, stack.getMCItemStack()); + + final BlockEvent.BreakEvent placeEvent = new BlockEvent.BreakEvent(posX, posY, posZ, world, + mcBlock, metadata, fakePlayer); + + MinecraftForge.EVENT_BUS.post(placeEvent); + + return placeEvent.isCanceled(); + } + + public boolean isBreakCancelled(IPos pos) { + return this.isBreakCancelled(pos.getX(), pos.getY(), pos.getZ()); + } + + public MovingObjectPosition rayCast(Vec3 startVec, Vec3 endVec, boolean stopOnBlock, boolean stopOnLiquid, boolean stopOnCollision) { + if (!Double.isNaN(startVec.xCoord) && !Double.isNaN(startVec.yCoord) && !Double.isNaN(startVec.zCoord)) { + if (!Double.isNaN(endVec.xCoord) && !Double.isNaN(endVec.yCoord) && !Double.isNaN(endVec.zCoord)) { + int endX = MathHelper.floor_double(endVec.xCoord); + int endY = MathHelper.floor_double(endVec.yCoord); + int endZ = MathHelper.floor_double(endVec.zCoord); + int l = MathHelper.floor_double(startVec.xCoord); + int i1 = MathHelper.floor_double(startVec.yCoord); + int j1 = MathHelper.floor_double(startVec.zCoord); + Block block = this.world.getBlock(l, i1, j1); + int k1 = this.world.getBlockMetadata(l, i1, j1); + + if (block.canCollideCheck(k1, false)) { + MovingObjectPosition movingobjectposition = block.collisionRayTrace(this.world, l, i1, j1, startVec, endVec); + + if (movingobjectposition != null) { + return movingobjectposition; + } + } + + k1 = 200; + + while (k1-- >= 0) { + if (Double.isNaN(startVec.xCoord) || Double.isNaN(startVec.yCoord) || Double.isNaN(startVec.zCoord)) { + return null; + } + + if (l == endX && i1 == endY && j1 == endZ) { + return null; + } + + boolean flag6 = true; + boolean flag3 = true; + boolean flag4 = true; + double d0 = 999.0D; + double d1 = 999.0D; + double d2 = 999.0D; + + if (endX > l) { + d0 = (double) l + 1.0D; + } else if (endX < l) { + d0 = (double) l + 0.0D; + } else { + flag6 = false; + } + + if (endY > i1) { + d1 = (double) i1 + 1.0D; + } else if (endY < i1) { + d1 = (double) i1 + 0.0D; + } else { + flag3 = false; + } + + if (endZ > j1) { + d2 = (double) j1 + 1.0D; + } else if (endZ < j1) { + d2 = (double) j1 + 0.0D; + } else { + flag4 = false; + } + + double d3 = 999.0D; + double d4 = 999.0D; + double d5 = 999.0D; + double d6 = endVec.xCoord - startVec.xCoord; + double d7 = endVec.yCoord - startVec.yCoord; + double d8 = endVec.zCoord - startVec.zCoord; + + if (flag6) { + d3 = (d0 - startVec.xCoord) / d6; + } + + if (flag3) { + d4 = (d1 - startVec.yCoord) / d7; + } + + if (flag4) { + d5 = (d2 - startVec.zCoord) / d8; + } + + byte b0; + + if (d3 < d4 && d3 < d5) { + if (endX > l) { + b0 = 4; + } else { + b0 = 5; + } + + startVec.xCoord = d0; + startVec.yCoord += d7 * d3; + startVec.zCoord += d8 * d3; + } else if (d4 < d5) { + if (endY > i1) { + b0 = 0; + } else { + b0 = 1; + } + + startVec.xCoord += d6 * d4; + startVec.yCoord = d1; + startVec.zCoord += d8 * d4; + } else { + if (endZ > j1) { + b0 = 2; + } else { + b0 = 3; + } + + startVec.xCoord += d6 * d5; + startVec.yCoord += d7 * d5; + startVec.zCoord = d2; + } + + Vec3 vec32 = Vec3.createVectorHelper(startVec.xCoord, startVec.yCoord, startVec.zCoord); + l = (int) (vec32.xCoord = (double) MathHelper.floor_double(startVec.xCoord)); + + if (b0 == 5) { + --l; + ++vec32.xCoord; + } + + i1 = (int) (vec32.yCoord = (double) MathHelper.floor_double(startVec.yCoord)); + + if (b0 == 1) { + --i1; + ++vec32.yCoord; + } + + j1 = (int) (vec32.zCoord = (double) MathHelper.floor_double(startVec.zCoord)); + + if (b0 == 3) { + --j1; + ++vec32.zCoord; + } + + Block block1 = this.world.getBlock(l, i1, j1); + int l1 = this.world.getBlockMetadata(l, i1, j1); + + MovingObjectPosition movingobjectposition1 = block1.collisionRayTrace(this.world, l, i1, j1, startVec, endVec); + if (movingobjectposition1 != null) { + if (block1.canCollideCheck(l1, false) && stopOnBlock || + block1.getMaterial().isLiquid() && stopOnLiquid || + !(block1 instanceof BlockAir) && block1.getCollisionBoundingBoxFromPool(this.world, l, i1, j1) == null && !stopOnCollision) { + return movingobjectposition1; + } + } + } + + return null; + } else { + return null; + } + } else { + return null; + } + } + + public IPos rayCastPos(double[] startPos, double[] lookVector, int maxDistance, boolean stopOnBlock, boolean stopOnLiquid, boolean stopOnCollision) { + if (startPos.length != 3 || lookVector.length != 3) { + return null; + } + + Vec3 startVec = Vec3.createVectorHelper(startPos[0], startPos[1], startPos[2]); + Vec3 endVec = startVec.addVector(lookVector[0] * maxDistance, lookVector[1] * maxDistance, lookVector[2] * maxDistance); + + IPos endPos = NpcAPI.Instance().getIPos(endVec.xCoord, endVec.yCoord, endVec.zCoord); + if (!stopOnBlock && !stopOnLiquid && !stopOnCollision) { + return endPos; + } + + MovingObjectPosition mob = this.rayCast(startVec, endVec, stopOnBlock, stopOnLiquid, stopOnCollision); + return mob != null ? NpcAPI.Instance().getIPos(mob.blockX, mob.blockY, mob.blockZ) : endPos; + } + + public IPos rayCastPos(double[] startPos, double[] lookVector, int maxDistance) { + return rayCastPos(startPos, lookVector, maxDistance, true, false, false); + } + + public IPos rayCastPos(IPos startPos, IPos lookVector, int maxDistance, boolean stopOnBlock, boolean stopOnLiquid, boolean stopOnCollision) { + return rayCastPos(new double[]{startPos.getX(), startPos.getY(), startPos.getZ()}, lookVector.normalizeDouble(), maxDistance, stopOnBlock, stopOnLiquid, stopOnCollision); + } + + public IPos rayCastPos(IPos startPos, IPos lookVector, int maxDistance) { + return rayCastPos(new double[]{startPos.getX(), startPos.getY(), startPos.getZ()}, lookVector.normalizeDouble(), maxDistance, true, false, false); + } + + public IBlock rayCastBlock(double[] startPos, double[] lookVector, int maxDistance, boolean stopOnBlock, boolean stopOnLiquid, boolean stopOnCollision) { + return getBlock(rayCastPos(startPos, lookVector, maxDistance, stopOnBlock, stopOnLiquid, stopOnCollision)); + } + + public IBlock rayCastBlock(double[] startPos, double[] lookVector, int maxDistance) { + return rayCastBlock(startPos, lookVector, maxDistance, true, false, false); + } + + public IBlock rayCastBlock(IPos startPos, IPos lookVector, int maxDistance, boolean stopOnBlock, boolean stopOnLiquid, boolean stopOnCollision) { + return rayCastBlock(new double[]{startPos.getX(), startPos.getY(), startPos.getZ()}, lookVector.normalizeDouble(), maxDistance, stopOnBlock, stopOnLiquid, stopOnCollision); + } + + public IBlock rayCastBlock(IPos startPos, IPos lookVector, int maxDistance) { + return rayCastBlock(new double[]{startPos.getX(), startPos.getY(), startPos.getZ()}, lookVector.normalizeDouble(), maxDistance); + } + + public IPos getNearestAir(IPos pos, int maxHeight) { + if (pos == null) return null; + IPos currentPos = pos; + IBlock block = null; + int rep = 0; + while (rep++ < maxHeight) { + //check +x + currentPos = currentPos.add(1, 0, 0); + block = getBlock(currentPos); + if (block == null) break; + //check -x + currentPos = currentPos.add(-2, 0, 0); + block = getBlock(currentPos); + if (block == null) break; + //check +z + currentPos = currentPos.add(1, 0, 1); + block = getBlock(currentPos); + if (block == null) break; + //check -z + currentPos = currentPos.add(0, 0, -2); + block = getBlock(currentPos); + if (block == null) break; + //check up 1 + currentPos = currentPos.add(0, 1, 1); + block = getBlock(currentPos); + if (block == null) break; + } + return currentPos; + } + + public IEntity[] rayCastEntities(double[] startPos, double[] lookVector, + int maxDistance, double offset, double range, + boolean stopOnBlock, boolean stopOnLiquid, boolean stopOnCollision) { + return rayCastEntities(null, startPos, lookVector, maxDistance, offset, range, stopOnBlock, stopOnLiquid, stopOnCollision); + } + + public IEntity[] rayCastEntities(IEntity[] ignoreEntities, double[] startPos, double[] lookVector, + int maxDistance, double offset, double range, + boolean stopOnBlock, boolean stopOnLiquid, boolean stopOnCollision) { + if (ignoreEntities == null) { + ignoreEntities = new IEntity[0]; + } + + Vec3 startVec = Vec3.createVectorHelper(startPos[0], startPos[1], startPos[2]); + Vec3 endVec = startVec.addVector(lookVector[0] * maxDistance, lookVector[1] * maxDistance, lookVector[2] * maxDistance); + startVec = startVec.addVector(lookVector[0] * offset, lookVector[1] * offset, lookVector[2] * offset); + + LinkedHashSet ignoredEntitiesSet = new LinkedHashSet<>(); + Collections.addAll(ignoredEntitiesSet, ignoreEntities); + + Set> entities = this.rayCastEntities(ignoredEntitiesSet, startVec, endVec, range, stopOnBlock, stopOnLiquid, stopOnCollision); + return entities.toArray(new IEntity[0]); + } + + public Set> rayCastEntities(LinkedHashSet ignoredEntitiesSet, Vec3 startVec, Vec3 endVec, double range, boolean stopOnBlock, boolean stopOnLiquid, boolean stopOnCollision) { + LinkedHashSet> entities = new LinkedHashSet<>(); + + if (!Double.isNaN(startVec.xCoord) && !Double.isNaN(startVec.yCoord) && !Double.isNaN(startVec.zCoord)) { + if (!Double.isNaN(endVec.xCoord) && !Double.isNaN(endVec.yCoord) && !Double.isNaN(endVec.zCoord)) { + int endX = MathHelper.floor_double(endVec.xCoord); + int endY = MathHelper.floor_double(endVec.yCoord); + int endZ = MathHelper.floor_double(endVec.zCoord); + int l = MathHelper.floor_double(startVec.xCoord); + int i1 = MathHelper.floor_double(startVec.yCoord); + int j1 = MathHelper.floor_double(startVec.zCoord); + Block block = this.world.getBlock(l, i1, j1); + int k1 = this.world.getBlockMetadata(l, i1, j1); + + IEntity[] surrounding = this.getEntitiesNear(l, i1, j1, range); + for (IEntity entity : surrounding) { + if (!ignoredEntitiesSet.contains(entity)) { + entities.add(entity); + } + } + + if (block.canCollideCheck(k1, false)) { + MovingObjectPosition movingobjectposition = block.collisionRayTrace(this.world, l, i1, j1, startVec, endVec); + + if (movingobjectposition != null) { + return entities; + } + } + + k1 = 200; + + while (k1-- >= 0) { + if (Double.isNaN(startVec.xCoord) || Double.isNaN(startVec.yCoord) || Double.isNaN(startVec.zCoord)) { + return entities; + } + + if (l == endX && i1 == endY && j1 == endZ) { + return entities; + } + + boolean flag6 = true; + boolean flag3 = true; + boolean flag4 = true; + double d0 = 999.0D; + double d1 = 999.0D; + double d2 = 999.0D; + + if (endX > l) { + d0 = (double) l + 1.0D; + } else if (endX < l) { + d0 = (double) l + 0.0D; + } else { + flag6 = false; + } + + if (endY > i1) { + d1 = (double) i1 + 1.0D; + } else if (endY < i1) { + d1 = (double) i1 + 0.0D; + } else { + flag3 = false; + } + + if (endZ > j1) { + d2 = (double) j1 + 1.0D; + } else if (endZ < j1) { + d2 = (double) j1 + 0.0D; + } else { + flag4 = false; + } + + double d3 = 999.0D; + double d4 = 999.0D; + double d5 = 999.0D; + double d6 = endVec.xCoord - startVec.xCoord; + double d7 = endVec.yCoord - startVec.yCoord; + double d8 = endVec.zCoord - startVec.zCoord; + + if (flag6) { + d3 = (d0 - startVec.xCoord) / d6; + } + + if (flag3) { + d4 = (d1 - startVec.yCoord) / d7; + } + + if (flag4) { + d5 = (d2 - startVec.zCoord) / d8; + } + + byte b0; + + if (d3 < d4 && d3 < d5) { + if (endX > l) { + b0 = 4; + } else { + b0 = 5; + } + + startVec.xCoord = d0; + startVec.yCoord += d7 * d3; + startVec.zCoord += d8 * d3; + } else if (d4 < d5) { + if (endY > i1) { + b0 = 0; + } else { + b0 = 1; + } + + startVec.xCoord += d6 * d4; + startVec.yCoord = d1; + startVec.zCoord += d8 * d4; + } else { + if (endZ > j1) { + b0 = 2; + } else { + b0 = 3; + } + + startVec.xCoord += d6 * d5; + startVec.yCoord += d7 * d5; + startVec.zCoord = d2; + } + + Vec3 vec32 = Vec3.createVectorHelper(startVec.xCoord, startVec.yCoord, startVec.zCoord); + l = (int) (vec32.xCoord = (double) MathHelper.floor_double(startVec.xCoord)); + + if (b0 == 5) { + --l; + ++vec32.xCoord; + } + + i1 = (int) (vec32.yCoord = (double) MathHelper.floor_double(startVec.yCoord)); + + if (b0 == 1) { + --i1; + ++vec32.yCoord; + } + + j1 = (int) (vec32.zCoord = (double) MathHelper.floor_double(startVec.zCoord)); + + if (b0 == 3) { + --j1; + ++vec32.zCoord; + } + + Block block1 = this.world.getBlock(l, i1, j1); + int l1 = this.world.getBlockMetadata(l, i1, j1); + + IEntity[] surroundingEntities = this.getEntitiesNear(l, i1, j1, range); + for (IEntity entity : surroundingEntities) { + if (!ignoredEntitiesSet.contains(entity)) { + entities.add(entity); + } + } + + MovingObjectPosition movingobjectposition1 = block1.collisionRayTrace(this.world, l, i1, j1, startVec, endVec); + if (movingobjectposition1 != null) { + if (block1.canCollideCheck(l1, false) && stopOnBlock || + block1.getMaterial().isLiquid() && stopOnLiquid || + !(block1 instanceof BlockAir) && block1.getCollisionBoundingBoxFromPool(this.world, l, i1, j1) == null && !stopOnCollision) { + return entities; + } + } + } + + return entities; + } else { + return entities; + } + } else { + return entities; + } + } + + public IEntity[] rayCastEntities(IPos startPos, IPos lookVector, + int maxDistance, double offset, double range, + boolean stopOnBlock, boolean stopOnLiquid, boolean stopOnCollision) { + return rayCastEntities(new double[]{startPos.getX(), startPos.getY(), startPos.getZ()}, lookVector.normalizeDouble(), maxDistance, offset, range, stopOnBlock, stopOnLiquid, stopOnCollision); + } + + public IEntity[] rayCastEntities(double[] startPos, double[] lookVector, + int maxDistance, double offset, double range) { + return rayCastEntities(startPos, lookVector, maxDistance, offset, range, true, false, true); + } + + public IEntity[] rayCastEntities(IPos startPos, IPos lookVector, + int maxDistance, double offset, double range) { + return rayCastEntities(new double[]{startPos.getX(), startPos.getY(), startPos.getZ()}, lookVector.normalizeDouble(), maxDistance, offset, range, true, false, true); + } + + @Deprecated + /** + * Deprecated. Use NpcAPI.Instance().getPlayer(name) instead. + */ + public IPlayer getPlayer(String name) { + EntityPlayer player = world.getPlayerEntityByName(name); + if (player == null) + return null; + return (IPlayer) NpcAPI.Instance().getIEntity(player); + } + + public IPlayer getPlayerByUUID(String uuid) { + return (IPlayer) NpcAPI.Instance().getIEntity(world.func_152378_a(UUID.fromString(uuid))); + } + + /** + * @param time The world time to be set + */ + public void setTime(long time) { + world.setWorldTime(time); + } + + /** + * @return Whether or not its daytime + */ + public boolean isDay() { + return world.getWorldTime() % 24000 < 12000; + } + + /** + * @return Whether or not its currently raining + */ + public boolean isRaining() { + return world.getWorldInfo().isRaining(); + } + + /** + * @param bo Set if it's raining + */ + public void setRaining(boolean bo) { + world.getWorldInfo().setRaining(bo); + } + + /** + * @param x The x position + * @param y The y position + * @param z The z position + */ + public void thunderStrike(double x, double y, double z) { world.addWeatherEffect(new EntityLightningBolt(world, x, y, z)); - } + } - public void thunderStrike(IPos pos){ - this.thunderStrike(pos.getX(),pos.getY(),pos.getZ()); - } + public void thunderStrike(IPos pos) { + this.thunderStrike(pos.getX(), pos.getY(), pos.getZ()); + } - /** - * Sends a packet from the server to the client everytime its called. Probably should not use this too much. - * @param particle Particle name. Particle name list: http://minecraft.wiki/w/Particles - * @param x The x position - * @param y The y position - * @param z The z position - * @param dx Usually used for the x motion - * @param dy Usually used for the y motion - * @param dz Usually used for the z motion - * @param speed Speed of the particles, usually between 0 and 1 - * @param count Particle count - */ - public void spawnParticle(String particle, double x, double y, double z, double dx, double dy, double dz, double speed, int count){ - world.func_147487_a(particle, x, y, z, count, dx, dy, dz, speed); - } + /** + * Sends a packet from the server to the client everytime its called. Probably should not use this too much. + * + * @param particle Particle name. Particle name list: http://minecraft.wiki/w/Particles + * @param x The x position + * @param y The y position + * @param z The z position + * @param dx Usually used for the x motion + * @param dy Usually used for the y motion + * @param dz Usually used for the z motion + * @param speed Speed of the particles, usually between 0 and 1 + * @param count Particle count + */ + public void spawnParticle(String particle, double x, double y, double z, double dx, double dy, double dz, double speed, int count) { + world.func_147487_a(particle, x, y, z, count, dx, dy, dz, speed); + } - public void spawnParticle(String particle, IPos pos, double dx, double dy, double dz, double speed, int count){ - this.spawnParticle(particle, pos.getX(), pos.getY(), pos.getZ(), dx, dy, dz, speed, count); - } + public void spawnParticle(String particle, IPos pos, double dx, double dy, double dz, double speed, int count) { + this.spawnParticle(particle, pos.getX(), pos.getY(), pos.getZ(), dx, dy, dz, speed, count); + } - /** - * @param id The items name - * @param damage The damage value - * @param size The number of items in the item - * @return Returns the item - */ - public IItemStack createItem(String id, int damage, int size){ - return NpcAPI.Instance().createItem(id,damage,size); - } + /** + * @param id The items name + * @param damage The damage value + * @param size The number of items in the item + * @return Returns the item + */ + public IItemStack createItem(String id, int damage, int size) { + return NpcAPI.Instance().createItem(id, damage, size); + } - /** - * @param directory The particle's texture directory. Use only forward slashes when writing a directory. Example: "customnpcs:textures/particle/bubble.png" - * @return Returns ScriptParticle object - */ - @Deprecated - public IParticle createEntityParticle(String directory){ - return NpcAPI.Instance().createEntityParticle(directory); - } + /** + * @param directory The particle's texture directory. Use only forward slashes when writing a directory. Example: "customnpcs:textures/particle/bubble.png" + * @return Returns ScriptParticle object + */ + @Deprecated + public IParticle createEntityParticle(String directory) { + return NpcAPI.Instance().createEntityParticle(directory); + } @Deprecated - public Object getTempData(String key){ - return NpcAPI.Instance().getTempData(key); - } + public Object getTempData(String key) { + return NpcAPI.Instance().getTempData(key); + } @Deprecated - public void setTempData(String key, Object value){ + public void setTempData(String key, Object value) { NpcAPI.Instance().setTempData(key, value); - } + } @Deprecated - public boolean hasTempData(String key){ - return NpcAPI.Instance().hasTempData(key); - } + public boolean hasTempData(String key) { + return NpcAPI.Instance().hasTempData(key); + } @Deprecated - public void removeTempData(String key){ + public void removeTempData(String key) { NpcAPI.Instance().removeTempData(key); - } + } @Deprecated - public void clearTempData(){ + public void clearTempData() { NpcAPI.Instance().clearTempData(); - } + } @Deprecated - public String[] getTempDataKeys() { - return NpcAPI.Instance().getTempDataKeys(); - } + public String[] getTempDataKeys() { + return NpcAPI.Instance().getTempDataKeys(); + } @Deprecated - public Object getStoredData(String key){ + public Object getStoredData(String key) { return NpcAPI.Instance().getStoredData(key); - } + } @Deprecated - public void setStoredData(String key, Object value){ + public void setStoredData(String key, Object value) { NpcAPI.Instance().setStoredData(key, value); - } + } @Deprecated - public boolean hasStoredData(String key){ + public boolean hasStoredData(String key) { return NpcAPI.Instance().hasStoredData(key); - } + } @Deprecated - public void removeStoredData(String key){ + public void removeStoredData(String key) { NpcAPI.Instance().removeStoredData(key); - } + } @Deprecated - public void clearStoredData(){ + public void clearStoredData() { NpcAPI.Instance().clearStoredData(); - } + } @Deprecated - public String[] getStoredDataKeys() { + public String[] getStoredDataKeys() { return NpcAPI.Instance().getStoredDataKeys(); - } + } - /** - * @param x Position x - * @param y Position y - * @param z Position z - * @param range Range of the explosion - * @param fire Whether or not the explosion does fire damage - * @param grief Whether or not the explosion does damage to blocks - */ - public void explode(double x, double y, double z, float range, boolean fire, boolean grief){ - world.newExplosion(null, x, y, z, range, fire, grief); - } + /** + * @param x Position x + * @param y Position y + * @param z Position z + * @param range Range of the explosion + * @param fire Whether or not the explosion does fire damage + * @param grief Whether or not the explosion does damage to blocks + */ + public void explode(double x, double y, double z, float range, boolean fire, boolean grief) { + world.newExplosion(null, x, y, z, range, fire, grief); + } - public void explode(IPos pos, float range, boolean fire, boolean grief){ - this.explode(pos.getX(),pos.getY(),pos.getZ(),range,fire,grief); - } + public void explode(IPos pos, float range, boolean fire, boolean grief) { + this.explode(pos.getX(), pos.getY(), pos.getZ(), range, fire, grief); + } - @Deprecated - public IPlayer[] getAllServerPlayers(){ - List list = MinecraftServer.getServer().getConfigurationManager().playerEntityList; - IPlayer[] arr = new IPlayer[list.size()]; - for(int i = 0; i < list.size(); i++){ - arr[i] = (IPlayer) NpcAPI.Instance().getIEntity(list.get(i)); - } + @Deprecated + public IPlayer[] getAllServerPlayers() { + List list = MinecraftServer.getServer().getConfigurationManager().playerEntityList; + IPlayer[] arr = new IPlayer[list.size()]; + for (int i = 0; i < list.size(); i++) { + arr[i] = (IPlayer) NpcAPI.Instance().getIEntity(list.get(i)); + } - return arr; - } + return arr; + } - @Deprecated - public String[] getPlayerNames() { - IPlayer[] players = getAllServerPlayers(); - String[] names = new String[players.length]; - for (int i = 0; i < names.length; ++i) names[i] = players[i].getDisplayName(); - return names; - } + @Deprecated + public String[] getPlayerNames() { + IPlayer[] players = getAllServerPlayers(); + String[] names = new String[players.length]; + for (int i = 0; i < names.length; ++i) names[i] = players[i].getDisplayName(); + return names; + } - /** - * @since 1.7.10c - * @param x Position x - * @param z Position z - * @return Returns the name of the biome - */ - public String getBiomeName(int x, int z){ - return world.getBiomeGenForCoords(x, z).biomeName; - } + /** + * @param x Position x + * @param z Position z + * @return Returns the name of the biome + * @since 1.7.10c + */ + public String getBiomeName(int x, int z) { + return world.getBiomeGenForCoords(x, z).biomeName; + } - public String getBiomeName(IPos pos){ - return this.getBiomeName(pos.getX(),pos.getZ()); - } + public String getBiomeName(IPos pos) { + return this.getBiomeName(pos.getX(), pos.getZ()); + } - /** - * Lets you spawn a server side cloned entity - * @param x The x position the clone will be spawned at - * @param y The y position the clone will be spawned at - * @param z The z position the clone will be spawned at - * @param tab The tab in which the clone is - * @param name Name of the cloned entity - * @return Returns the entity which was spawned - */ - public IEntity spawnClone(int x, int y, int z, int tab, String name, boolean ignoreProtection){ - NBTTagCompound compound = ServerCloneController.Instance.getCloneData(null, name, tab); - if(compound == null) - return null; - Entity entity; - if (!ignoreProtection) { - entity = NoppesUtilServer.spawnCloneWithProtection(compound, x, y, z, world); - } else { - entity = NoppesUtilServer.spawnClone(compound, x, y, z, world); - } - return entity == null ? null : NpcAPI.Instance().getIEntity(entity); - } + /** + * Lets you spawn a server side cloned entity + * + * @param x The x position the clone will be spawned at + * @param y The y position the clone will be spawned at + * @param z The z position the clone will be spawned at + * @param tab The tab in which the clone is + * @param name Name of the cloned entity + * @return Returns the entity which was spawned + */ + public IEntity spawnClone(int x, int y, int z, int tab, String name, boolean ignoreProtection) { + NBTTagCompound compound = ServerCloneController.Instance.getCloneData(null, name, tab); + if (compound == null) + return null; + Entity entity; + if (!ignoreProtection) { + entity = NoppesUtilServer.spawnCloneWithProtection(compound, x, y, z, world); + } else { + entity = NoppesUtilServer.spawnClone(compound, x, y, z, world); + } + return entity == null ? null : NpcAPI.Instance().getIEntity(entity); + } - public IEntity spawnClone(IPos pos, int tab, String name, boolean ignoreProtection) { - return this.spawnClone(pos.getX(),pos.getY(),pos.getZ(),tab,name,ignoreProtection); - } + public IEntity spawnClone(IPos pos, int tab, String name, boolean ignoreProtection) { + return this.spawnClone(pos.getX(), pos.getY(), pos.getZ(), tab, name, ignoreProtection); + } - public IEntity spawnClone(int x, int y, int z, int tab, String name) { - return this.spawnClone(x,y,z,tab,name,true); - } + public IEntity spawnClone(int x, int y, int z, int tab, String name) { + return this.spawnClone(x, y, z, tab, name, true); + } - public IEntity spawnClone(IPos pos, int tab, String name) { - return this.spawnClone(pos.getX(),pos.getY(),pos.getZ(),tab,name); - } + public IEntity spawnClone(IPos pos, int tab, String name) { + return this.spawnClone(pos.getX(), pos.getY(), pos.getZ(), tab, name); + } - public IScoreboard getScoreboard(){ - return new ScriptScoreboard(); - } + public IScoreboard getScoreboard() { + return new ScriptScoreboard(); + } - /** - * @since 1.7.10c - * Expert use only - * @return Returns minecraft world object - */ - public WorldServer getMCWorld(){ - return this.world; - } + /** + * @return Returns minecraft world object + * @since 1.7.10c + * Expert use only + */ + public WorldServer getMCWorld() { + return this.world; + } - public int getDimensionID(){ - return world.provider.dimensionId; - } + public int getDimensionID() { + return world.provider.dimensionId; + } - public String toString() { - return "DIM" + this.getDimensionID(); - } + public String toString() { + return "DIM" + this.getDimensionID(); + } @Override - public void broadcast(String message){ + public void broadcast(String message) { world.func_73046_m().getConfigurationManager().sendChatMsg(new ChatComponentText(message)); } } diff --git a/src/main/java/noppes/npcs/scripted/constants/AnimationType.java b/src/main/java/noppes/npcs/scripted/constants/AnimationType.java index a5ce8a8cd..a72255558 100644 --- a/src/main/java/noppes/npcs/scripted/constants/AnimationType.java +++ b/src/main/java/noppes/npcs/scripted/constants/AnimationType.java @@ -1,10 +1,10 @@ package noppes.npcs.scripted.constants; public class AnimationType { - public static final int NORMAL = 0; - public static final int SITTING = 1; - public static final int LYING = 2; - public static final int HUGGING = 3; - public static final int SNEAKING = 4; - public static final int DANCING = 5; + public static final int NORMAL = 0; + public static final int SITTING = 1; + public static final int LYING = 2; + public static final int HUGGING = 3; + public static final int SNEAKING = 4; + public static final int DANCING = 5; } diff --git a/src/main/java/noppes/npcs/scripted/constants/EntityType.java b/src/main/java/noppes/npcs/scripted/constants/EntityType.java index 76c21de71..c14aa6786 100644 --- a/src/main/java/noppes/npcs/scripted/constants/EntityType.java +++ b/src/main/java/noppes/npcs/scripted/constants/EntityType.java @@ -1,14 +1,14 @@ package noppes.npcs.scripted.constants; public class EntityType { - public static final int UNKNOWN = 0; - public static final int PLAYER = 1; - public static final int NPC = 2; - public static final int MONSTER = 3; - public static final int ANIMAL = 4; - public static final int LIVING = 5; - public static final int ITEM = 6; - public static final int PROJECTILE = 7; + public static final int UNKNOWN = 0; + public static final int PLAYER = 1; + public static final int NPC = 2; + public static final int MONSTER = 3; + public static final int ANIMAL = 4; + public static final int LIVING = 5; + public static final int ITEM = 6; + public static final int PROJECTILE = 7; public static final int PIXELMON = 8; public static final int VILLAGER = 9; } diff --git a/src/main/java/noppes/npcs/scripted/constants/JobType.java b/src/main/java/noppes/npcs/scripted/constants/JobType.java index 27ace8d47..d51c9632c 100644 --- a/src/main/java/noppes/npcs/scripted/constants/JobType.java +++ b/src/main/java/noppes/npcs/scripted/constants/JobType.java @@ -1,13 +1,13 @@ package noppes.npcs.scripted.constants; public class JobType { - public static final int UNKNOWN = 0; - public static final int BARD = 1; - public static final int HEALER = 2; - public static final int GUARD = 3; - public static final int FOLLOWER = 4; - public static final int ITEMGIVER = 5; - public static final int SPAWNER = 6; - public static final int CONVERSATION = 7; - public static final int PUPPET = 8; + public static final int UNKNOWN = 0; + public static final int BARD = 1; + public static final int HEALER = 2; + public static final int GUARD = 3; + public static final int FOLLOWER = 4; + public static final int ITEMGIVER = 5; + public static final int SPAWNER = 6; + public static final int CONVERSATION = 7; + public static final int PUPPET = 8; } diff --git a/src/main/java/noppes/npcs/scripted/constants/RoleType.java b/src/main/java/noppes/npcs/scripted/constants/RoleType.java index c06b501cb..fd1c40443 100644 --- a/src/main/java/noppes/npcs/scripted/constants/RoleType.java +++ b/src/main/java/noppes/npcs/scripted/constants/RoleType.java @@ -1,11 +1,11 @@ package noppes.npcs.scripted.constants; public class RoleType { - public static final int UNKNOWN = 0; - public static final int TRADER = 1; - public static final int FOLLOWER = 2; - public static final int BANK = 3; - public static final int TRANSPORTER = 4; - public static final int POSTMAN = 5; - public static final int COMPANION = 6; + public static final int UNKNOWN = 0; + public static final int TRADER = 1; + public static final int FOLLOWER = 2; + public static final int BANK = 3; + public static final int TRANSPORTER = 4; + public static final int POSTMAN = 5; + public static final int COMPANION = 6; } diff --git a/src/main/java/noppes/npcs/scripted/entity/ScriptAnimal.java b/src/main/java/noppes/npcs/scripted/entity/ScriptAnimal.java index 8dce61eba..f29e1d0cc 100644 --- a/src/main/java/noppes/npcs/scripted/entity/ScriptAnimal.java +++ b/src/main/java/noppes/npcs/scripted/entity/ScriptAnimal.java @@ -9,54 +9,54 @@ import noppes.npcs.scripted.NpcAPI; import noppes.npcs.scripted.constants.EntityType; public class ScriptAnimal extends ScriptLiving implements IAnimal { - protected T entity; + protected T entity; - public ScriptAnimal(T entity) { - super(entity); - this.entity = entity; - } - - @Override - public int getType(){ - return EntityType.ANIMAL; - } + public ScriptAnimal(T entity) { + super(entity); + this.entity = entity; + } - /** - * Checks if the parameter is an item which this animal can be fed to breed it (wheat, carrots or seeds depending on - * the animal type) - */ - public boolean isBreedingItem(IItemStack itemStack) { - return this.entity.isBreedingItem(itemStack.getMCItemStack()); - } + @Override + public int getType() { + return EntityType.ANIMAL; + } - /** - * Called when a player interacts with a mob. e.g. gets milk from a cow, gets into the saddle on a pig. - */ - public boolean interact(IPlayer player) { - return this.entity.interact((EntityPlayer) player.getMCEntity()); - } + /** + * Checks if the parameter is an item which this animal can be fed to breed it (wheat, carrots or seeds depending on + * the animal type) + */ + public boolean isBreedingItem(IItemStack itemStack) { + return this.entity.isBreedingItem(itemStack.getMCItemStack()); + } - public void setFollowPlayer(IPlayer player) { - this.entity.func_146082_f((EntityPlayer) player.getMCEntity()); - } + /** + * Called when a player interacts with a mob. e.g. gets milk from a cow, gets into the saddle on a pig. + */ + public boolean interact(IPlayer player) { + return this.entity.interact((EntityPlayer) player.getMCEntity()); + } - public IPlayer followingPlayer() { - return (IPlayer) NpcAPI.Instance().getIEntity(this.entity.func_146083_cb()); - } + public void setFollowPlayer(IPlayer player) { + this.entity.func_146082_f((EntityPlayer) player.getMCEntity()); + } - public boolean isInLove() { - return this.entity.isInLove(); - } + public IPlayer followingPlayer() { + return (IPlayer) NpcAPI.Instance().getIEntity(this.entity.func_146083_cb()); + } - public void resetInLove() { - this.entity.resetInLove(); - } + public boolean isInLove() { + return this.entity.isInLove(); + } - public boolean canMateWith(IAnimal animal) { - return this.entity.canMateWith((EntityAnimal) animal.getMCEntity()); - } + public void resetInLove() { + this.entity.resetInLove(); + } - public boolean typeOf(int type){ - return type == EntityType.ANIMAL || super.typeOf(type); - } + public boolean canMateWith(IAnimal animal) { + return this.entity.canMateWith((EntityAnimal) animal.getMCEntity()); + } + + public boolean typeOf(int type) { + return type == EntityType.ANIMAL || super.typeOf(type); + } } diff --git a/src/main/java/noppes/npcs/scripted/entity/ScriptDBCPlayer.java b/src/main/java/noppes/npcs/scripted/entity/ScriptDBCPlayer.java index 473e0bd00..b6909b889 100644 --- a/src/main/java/noppes/npcs/scripted/entity/ScriptDBCPlayer.java +++ b/src/main/java/noppes/npcs/scripted/entity/ScriptDBCPlayer.java @@ -12,7 +12,7 @@ import noppes.npcs.scripted.NpcAPI; public class ScriptDBCPlayer extends ScriptPlayer implements IDBCPlayer { public T player; - public ScriptDBCPlayer(T player){ + public ScriptDBCPlayer(T player) { super(player); this.player = player; } @@ -71,7 +71,7 @@ public class ScriptDBCPlayer extends ScriptPlayer i } throw new CustomNPCsException("Invalid stat name: " + stat + "\nValid stat names are:" + - "\nstr, dex, con, wil, mnd, spi\nstrength, dexterity, constitution, willpower, mind, spirit",new Object[0]); + "\nstr, dex, con, wil, mnd, spi\nstrength, dexterity, constitution, willpower, mind, spirit", new Object[0]); } private double applyOperator(String method, double n1, double n2) { @@ -90,33 +90,39 @@ public class ScriptDBCPlayer extends ScriptPlayer i return n1; } - public void addBonusAttribute(String stat, String bonusID, String operation, double attributeValue){ - addBonusAttribute(stat,bonusID,operation,attributeValue,true); + public void addBonusAttribute(String stat, String bonusID, String operation, double attributeValue) { + addBonusAttribute(stat, bonusID, operation, attributeValue, true); } - public void addBonusAttribute(String stat, String bonusID, String operation, double attributeValue, boolean endOfTheList){ - bonusAttribute("add",stat,bonusID,operation,attributeValue,endOfTheList); + + public void addBonusAttribute(String stat, String bonusID, String operation, double attributeValue, boolean endOfTheList) { + bonusAttribute("add", stat, bonusID, operation, attributeValue, endOfTheList); } - public void addToBonusAttribute(String stat, String bonusID, String operation, double attributeValue){ - bonusAttribute("addto",stat,bonusID,operation,attributeValue,true); + + public void addToBonusAttribute(String stat, String bonusID, String operation, double attributeValue) { + bonusAttribute("addto", stat, bonusID, operation, attributeValue, true); } - public void setBonusAttribute(String stat, String bonusID, String operation, double attributeValue){ - bonusAttribute("set",stat,bonusID,operation,attributeValue,true); + + public void setBonusAttribute(String stat, String bonusID, String operation, double attributeValue) { + bonusAttribute("set", stat, bonusID, operation, attributeValue, true); } - public void getBonusAttribute(String stat, String bonusID){ - bonusAttribute("get",stat,bonusID,"*",1.0,true); + + public void getBonusAttribute(String stat, String bonusID) { + bonusAttribute("get", stat, bonusID, "*", 1.0, true); } - public void removeBonusAttribute(String stat, String bonusID){ - bonusAttribute("remove",stat,bonusID,"*",1.0,true); + + public void removeBonusAttribute(String stat, String bonusID) { + bonusAttribute("remove", stat, bonusID, "*", 1.0, true); } - public void clearBonusAttribute(String stat){ - bonusAttribute("clear",stat,"","*",1.0,true); + + public void clearBonusAttribute(String stat) { + bonusAttribute("clear", stat, "", "*", 1.0, true); } public String bonusAttribute(String action, String stat, String bonusID) { String[] actions = new String[]{"get", "remove", "clear"}; boolean valid = false; - for(String s : actions){ - if(s.equals(action.toLowerCase())){ + for (String s : actions) { + if (s.equals(action.toLowerCase())) { valid = true; } } @@ -124,7 +130,7 @@ public class ScriptDBCPlayer extends ScriptPlayer i throw new CustomNPCsException("Action can be: get/remove/clear", new Object[0]); } - return bonusAttribute(action,stat,bonusID,"*",1.0,false); + return bonusAttribute(action, stat, bonusID, "*", 1.0, false); } public String bonusAttribute(String action, String stat, String bonusID, String operation, double attributeValue, boolean endOfTheList) { @@ -132,8 +138,8 @@ public class ScriptDBCPlayer extends ScriptPlayer i String[] operations = new String[]{"+", "-", "*", "/", "%"}; boolean valid = false; - for(String s : actions){ - if(s.equals(action.toLowerCase())){ + for (String s : actions) { + if (s.equals(action.toLowerCase())) { valid = true; } } @@ -141,7 +147,7 @@ public class ScriptDBCPlayer extends ScriptPlayer i throw new CustomNPCsException("Action can be: add/addTo/set/get/remove/clear", new Object[0]); } - if(!action.equals("remove") && !action.equals("get") && !action.equals("clear")) { + if (!action.equals("remove") && !action.equals("get") && !action.equals("clear")) { valid = false; for (String s : operations) { if (s.equals(operation)) { @@ -174,16 +180,16 @@ public class ScriptDBCPlayer extends ScriptPlayer i stat = "spi"; break; } - if(!(stat.equals("str") || stat.equals("dex") || stat.equals("con") || stat.equals("wil") || stat.equals("mnd") || stat.equals("spi"))) + if (!(stat.equals("str") || stat.equals("dex") || stat.equals("con") || stat.equals("wil") || stat.equals("mnd") || stat.equals("spi"))) throw new CustomNPCsException("Invalid stat name: " + stat + "\nValid stat names are:" + - "\nstr, dex, con, wil, mnd, spi\nstrength, dexterity, constitution, willpower, mind, spirit",new Object[0]); + "\nstr, dex, con, wil, mnd, spi\nstrength, dexterity, constitution, willpower, mind, spirit", new Object[0]); String bonusValueString = operation + attributeValue; - String bonus = player.getEntityData().getCompoundTag("PlayerPersisted").getString("jrmcAttrBonus"+stat); + String bonus = player.getEntityData().getCompoundTag("PlayerPersisted").getString("jrmcAttrBonus" + stat); String bonuses[] = bonus.split("\\|"); String[][] bonusValues = new String[bonuses.length][2]; if (bonuses.length > 0 && bonuses[0].length() > 0) { - for(int i = 0; i < bonuses.length; ++i) { + for (int i = 0; i < bonuses.length; ++i) { String[] bonusValue = bonuses[i].split("\\;"); bonusValues[i][0] = bonusValue[0]; bonusValues[i][1] = bonusValue[1]; @@ -192,7 +198,7 @@ public class ScriptDBCPlayer extends ScriptPlayer i switch (action) { case "get": - if(player.getEntityData().getCompoundTag("PlayerPersisted").hasKey("jrmcAttrBonus"+stat)) { + if (player.getEntityData().getCompoundTag("PlayerPersisted").hasKey("jrmcAttrBonus" + stat)) { for (String[] s : bonusValues) { if (s[0].equals(bonusID)) return s[1]; @@ -200,12 +206,12 @@ public class ScriptDBCPlayer extends ScriptPlayer i } return ""; case "clear": - if(player.getEntityData().getCompoundTag("PlayerPersisted").hasKey("jrmcAttrBonus"+stat)) - player.getEntityData().getCompoundTag("PlayerPersisted").setString("jrmcAttrBonus"+stat, ""); + if (player.getEntityData().getCompoundTag("PlayerPersisted").hasKey("jrmcAttrBonus" + stat)) + player.getEntityData().getCompoundTag("PlayerPersisted").setString("jrmcAttrBonus" + stat, ""); break; case "remove": String newBonusString = ""; - if(player.getEntityData().getCompoundTag("PlayerPersisted").hasKey("jrmcAttrBonus"+stat)) { + if (player.getEntityData().getCompoundTag("PlayerPersisted").hasKey("jrmcAttrBonus" + stat)) { int num = -1; boolean number; boolean run = false; @@ -218,7 +224,7 @@ public class ScriptDBCPlayer extends ScriptPlayer i number = false; } - for(int i = 0; i < bonuses.length; ++i) { + for (int i = 0; i < bonuses.length; ++i) { bonusValue = bonuses[i].split("\\;"); bonusValues[i][0] = bonusValue[0]; if (number && i == num || !number && bonusValues[i][0].equals(bonusID)) { @@ -237,7 +243,7 @@ public class ScriptDBCPlayer extends ScriptPlayer i } } - player.getEntityData().getCompoundTag("PlayerPersisted").setString("jrmcAttrBonus"+stat, startString); + player.getEntityData().getCompoundTag("PlayerPersisted").setString("jrmcAttrBonus" + stat, startString); } } break; @@ -267,7 +273,7 @@ public class ScriptDBCPlayer extends ScriptPlayer i bonus = bonusID + ";" + bonusValueString + "|" + bonus; } } - player.getEntityData().getCompoundTag("PlayerPersisted").setString("jrmcAttrBonus"+stat, bonus); + player.getEntityData().getCompoundTag("PlayerPersisted").setString("jrmcAttrBonus" + stat, bonus); } break; case "set": { @@ -307,7 +313,7 @@ public class ScriptDBCPlayer extends ScriptPlayer i } } - player.getEntityData().getCompoundTag("PlayerPersisted").setString("jrmcAttrBonus"+stat, startString); + player.getEntityData().getCompoundTag("PlayerPersisted").setString("jrmcAttrBonus" + stat, startString); } break; } @@ -349,7 +355,7 @@ public class ScriptDBCPlayer extends ScriptPlayer i } } - player.getEntityData().getCompoundTag("PlayerPersisted").setString("jrmcAttrBonus"+stat, startString); + player.getEntityData().getCompoundTag("PlayerPersisted").setString("jrmcAttrBonus" + stat, startString); } break; } @@ -358,80 +364,88 @@ public class ScriptDBCPlayer extends ScriptPlayer i return ""; } - public void setRelease(byte release){ - player.getEntityData().getCompoundTag("PlayerPersisted").setByte("jrmcRelease",release); + public void setRelease(byte release) { + player.getEntityData().getCompoundTag("PlayerPersisted").setByte("jrmcRelease", release); } - public byte getRelease(){ + + public byte getRelease() { return player.getEntityData().getCompoundTag("PlayerPersisted").getByte("jrmcRelease"); } - public void setBody(int body){ - player.getEntityData().getCompoundTag("PlayerPersisted").setInteger("jrmcBdy",body); + public void setBody(int body) { + player.getEntityData().getCompoundTag("PlayerPersisted").setInteger("jrmcBdy", body); } - public int getBody(){ + + public int getBody() { return player.getEntityData().getCompoundTag("PlayerPersisted").getInteger("jrmcBdy"); } - public void setHP(int hp){ + public void setHP(int hp) { setBody(hp); } - public int getHP() - { + + public int getHP() { return getBody(); } - public void setStamina(int stamina){ - player.getEntityData().getCompoundTag("PlayerPersisted").setInteger("jrmcStamina",stamina); + public void setStamina(int stamina) { + player.getEntityData().getCompoundTag("PlayerPersisted").setInteger("jrmcStamina", stamina); } - public int getStamina(){ + + public int getStamina() { return player.getEntityData().getCompoundTag("PlayerPersisted").getInteger("jrmcStamina"); } - public void setKi(int ki){ - player.getEntityData().getCompoundTag("PlayerPersisted").setInteger("jrmcEnrgy",ki); + public void setKi(int ki) { + player.getEntityData().getCompoundTag("PlayerPersisted").setInteger("jrmcEnrgy", ki); } - public int getKi(){ + + public int getKi() { return player.getEntityData().getCompoundTag("PlayerPersisted").getInteger("jrmcEnrgy"); } - public void setTP(int tp){ - player.getEntityData().getCompoundTag("PlayerPersisted").setInteger("jrmcTpint",tp); + public void setTP(int tp) { + player.getEntityData().getCompoundTag("PlayerPersisted").setInteger("jrmcTpint", tp); } - public int getTP(){ + + public int getTP() { return player.getEntityData().getCompoundTag("PlayerPersisted").getInteger("jrmcTpint"); } - public void setGravity(float gravity){ - player.getEntityData().getCompoundTag("PlayerPersisted").setFloat("jrmcGravForce",gravity); + public void setGravity(float gravity) { + player.getEntityData().getCompoundTag("PlayerPersisted").setFloat("jrmcGravForce", gravity); } - public float getGravity(){ + + public float getGravity() { return player.getEntityData().getCompoundTag("PlayerPersisted").getFloat("jrmcGravForce"); } - public boolean isBlocking(){ + public boolean isBlocking() { NBTTagCompound compound = new NBTTagCompound(); this.player.writeToNBT(compound); return compound.getCompoundTag("JRMCEP").getInteger("blocking") == 1; } - public void setHairCode(String hairCode){ + public void setHairCode(String hairCode) { NBTTagCompound compound = new NBTTagCompound(); this.player.writeToNBT(compound); - compound.getCompoundTag("JRMCEP").setString("haircode",hairCode); + compound.getCompoundTag("JRMCEP").setString("haircode", hairCode); } - public String getHairCode(){ + + public String getHairCode() { NBTTagCompound compound = new NBTTagCompound(); this.player.writeToNBT(compound); return compound.getCompoundTag("JRMCEP").getString("haircode"); } - public void setExtraCode(String extraCode){ + public void setExtraCode(String extraCode) { NBTTagCompound compound = new NBTTagCompound(); this.player.writeToNBT(compound); - compound.getCompoundTag("JRMCEP").setString("extracode",extraCode); + compound.getCompoundTag("JRMCEP").setString("extracode", extraCode); } - public String getExtraCode(){ + + public String getExtraCode() { NBTTagCompound compound = new NBTTagCompound(); this.player.writeToNBT(compound); return compound.getCompoundTag("JRMCEP").getString("extracode"); @@ -444,7 +458,7 @@ public class ScriptDBCPlayer extends ScriptPlayer i byte offset = (byte) (vanity ? 10 : 2); NBTTagList newList = new NBTTagList(); - NBTTagList list = compound.getCompoundTag("JRMCEP").getTagList("dbcExtraInvTag",10); + NBTTagList list = compound.getCompoundTag("JRMCEP").getTagList("dbcExtraInvTag", 10); for (int i = 0; i < list.tagCount(); i++) { if (offset - list.getCompoundTagAt(i).getByte("Slot") != slot) { newList.appendTag(list.getCompoundTagAt(i)); @@ -468,7 +482,7 @@ public class ScriptDBCPlayer extends ScriptPlayer i byte offset = (byte) (vanity ? 10 : 2); - NBTTagList list = compound.getCompoundTag("JRMCEP").getTagList("dbcExtraInvTag",10); + NBTTagList list = compound.getCompoundTag("JRMCEP").getTagList("dbcExtraInvTag", 10); for (int i = 0; i < list.tagCount(); i++) { if (offset - list.getCompoundTagAt(i).getByte("Slot") == slot) { return NpcAPI.Instance().getIItemStack(ItemStack.loadItemStackFromNBT(list.getCompoundTagAt(i))); @@ -478,11 +492,11 @@ public class ScriptDBCPlayer extends ScriptPlayer i return null; } - public IItemStack[] getInventory(){ + public IItemStack[] getInventory() { NBTTagCompound compound = new NBTTagCompound(); this.player.writeToNBT(compound); - NBTTagList list = compound.getCompoundTag("JRMCEP").getTagList("dbcExtraInvTag",10); + NBTTagList list = compound.getCompoundTag("JRMCEP").getTagList("dbcExtraInvTag", 10); IItemStack[] itemList = new IItemStack[list.tagCount()]; for (int i = 0; i < list.tagCount(); i++) { ItemStack itemStack = ItemStack.loadItemStackFromNBT(list.getCompoundTagAt(i)); @@ -492,36 +506,39 @@ public class ScriptDBCPlayer extends ScriptPlayer i return itemList; } - public void setForm(byte form){ - if(form < 0) + public void setForm(byte form) { + if (form < 0) return; - switch(getRace()){ + switch (getRace()) { case 0: case 3: - if(form > 3) + if (form > 3) return; break; case 1: case 2: - if(form > 15) + if (form > 15) return; break; case 4: - if(form > 7) + if (form > 7) return; break; } - player.getEntityData().getCompoundTag("PlayerPersisted").setByte("jrmcState",form); + player.getEntityData().getCompoundTag("PlayerPersisted").setByte("jrmcState", form); } - public byte getForm(){ + + public byte getForm() { return player.getEntityData().getCompoundTag("PlayerPersisted").getByte("jrmcState"); } - public void setForm2(byte form2){ - player.getEntityData().getCompoundTag("PlayerPersisted").setByte("jrmcState2",form2); + + public void setForm2(byte form2) { + player.getEntityData().getCompoundTag("PlayerPersisted").setByte("jrmcState2", form2); } - public byte getForm2(){ + + public byte getForm2() { return player.getEntityData().getCompoundTag("PlayerPersisted").getByte("jrmcState2"); } @@ -530,11 +547,12 @@ public class ScriptDBCPlayer extends ScriptPlayer i String formTree = this.getRacialTreeName(); if (player.getEntityData().getCompoundTag("PlayerPersisted").hasKey("jrmcFormMastery" + formTree)) { String[] formMasteries = player.getEntityData().getCompoundTag("PlayerPersisted"). - getString("jrmcFormMastery" + formTree).split(";"); + getString("jrmcFormMastery" + formTree).split(";"); String masteryString = formMasteries[form]; return Double.parseDouble(masteryString.split(",")[1]); } - } catch (Exception ignored) {} + } catch (Exception ignored) { + } return 0.0D; } @@ -543,7 +561,7 @@ public class ScriptDBCPlayer extends ScriptPlayer i String formTree = this.getRacialTreeName(); if (player.getEntityData().getCompoundTag("PlayerPersisted").hasKey("jrmcFormMastery" + formTree)) { String[] formMasteries = player.getEntityData().getCompoundTag("PlayerPersisted"). - getString("jrmcFormMastery" + formTree).split(";"); + getString("jrmcFormMastery" + formTree).split(";"); if (form >= formMasteries.length) return; @@ -558,9 +576,10 @@ public class ScriptDBCPlayer extends ScriptPlayer i } player.getEntityData().getCompoundTag("PlayerPersisted"). - setString("jrmcFormMastery" + formTree, String.valueOf(masteryString)); + setString("jrmcFormMastery" + formTree, String.valueOf(masteryString)); } - } catch (Exception ignored) {} + } catch (Exception ignored) { + } } public void addRacialFormMastery(byte form, double value) { @@ -568,7 +587,7 @@ public class ScriptDBCPlayer extends ScriptPlayer i String formTree = this.getRacialTreeName(); if (player.getEntityData().getCompoundTag("PlayerPersisted").hasKey("jrmcFormMastery" + formTree)) { String[] formMasteries = player.getEntityData().getCompoundTag("PlayerPersisted"). - getString("jrmcFormMastery" + formTree).split(";"); + getString("jrmcFormMastery" + formTree).split(";"); if (form >= formMasteries.length) return; @@ -584,9 +603,10 @@ public class ScriptDBCPlayer extends ScriptPlayer i } player.getEntityData().getCompoundTag("PlayerPersisted"). - setString("jrmcFormMastery" + formTree, String.valueOf(masteryString)); + setString("jrmcFormMastery" + formTree, String.valueOf(masteryString)); } - } catch (Exception ignored) {} + } catch (Exception ignored) { + } } private String getRacialTreeName() { @@ -611,7 +631,7 @@ public class ScriptDBCPlayer extends ScriptPlayer i try { if (player.getEntityData().getCompoundTag("PlayerPersisted").hasKey("jrmcFormMasteryNonRacial")) { String masteryData = player.getEntityData().getCompoundTag("PlayerPersisted"). - getString("jrmcFormMasteryNonRacial"); + getString("jrmcFormMasteryNonRacial"); if (!masteryData.contains(formName)) { return 0.0D; } @@ -623,7 +643,8 @@ public class ScriptDBCPlayer extends ScriptPlayer i } } } - } catch (Exception ignored) {} + } catch (Exception ignored) { + } return 0.0D; } @@ -631,7 +652,7 @@ public class ScriptDBCPlayer extends ScriptPlayer i try { if (player.getEntityData().getCompoundTag("PlayerPersisted").hasKey("jrmcFormMasteryNonRacial")) { String masteryData = player.getEntityData().getCompoundTag("PlayerPersisted"). - getString("jrmcFormMasteryNonRacial"); + getString("jrmcFormMasteryNonRacial"); if (!masteryData.contains(formName)) { return; } @@ -653,16 +674,17 @@ public class ScriptDBCPlayer extends ScriptPlayer i } player.getEntityData().getCompoundTag("PlayerPersisted"). - setString("jrmcFormMasteryNonRacial", String.valueOf(masteryString)); + setString("jrmcFormMasteryNonRacial", String.valueOf(masteryString)); } - } catch (Exception ignored) {} + } catch (Exception ignored) { + } } public void addOtherFormMastery(String formName, double value) { try { if (player.getEntityData().getCompoundTag("PlayerPersisted").hasKey("jrmcFormMasteryNonRacial")) { String masteryData = player.getEntityData().getCompoundTag("PlayerPersisted"). - getString("jrmcFormMasteryNonRacial"); + getString("jrmcFormMasteryNonRacial"); if (!masteryData.contains(formName)) { return; } @@ -685,62 +707,69 @@ public class ScriptDBCPlayer extends ScriptPlayer i } player.getEntityData().getCompoundTag("PlayerPersisted"). - setString("jrmcFormMasteryNonRacial", String.valueOf(masteryString)); + setString("jrmcFormMasteryNonRacial", String.valueOf(masteryString)); } - } catch (Exception ignored) {} + } catch (Exception ignored) { + } } - public void setPowerPoints(int points){ - player.getEntityData().getCompoundTag("PlayerPersisted").setInteger("jrmcArcRsrv",points); + public void setPowerPoints(int points) { + player.getEntityData().getCompoundTag("PlayerPersisted").setInteger("jrmcArcRsrv", points); } - public int getPowerPoints(){ + + public int getPowerPoints() { return player.getEntityData().getCompoundTag("PlayerPersisted").getInteger("jrmcArcRsrv"); } - public void setAuraColor(int color){ - player.getEntityData().getCompoundTag("PlayerPersisted").setInteger("jrmcAuraColor",color); + public void setAuraColor(int color) { + player.getEntityData().getCompoundTag("PlayerPersisted").setInteger("jrmcAuraColor", color); } - public int getAuraColor(){ + + public int getAuraColor() { return player.getEntityData().getCompoundTag("PlayerPersisted").getInteger("jrmcAuraColor"); } - public void setFormLevel(int level){ - player.getEntityData().getCompoundTag("PlayerPersisted").setString("jrmcSSltX","TR"+level); + public void setFormLevel(int level) { + player.getEntityData().getCompoundTag("PlayerPersisted").setString("jrmcSSltX", "TR" + level); } - public int getFormLevel(){ + + public int getFormLevel() { String formString = player.getEntityData().getCompoundTag("PlayerPersisted").getString("jrmcSSltX"); - if(formString.length() < 1) + if (formString.length() < 1) return 0; StringBuilder digitString = new StringBuilder(); - for(char c : formString.toCharArray()){ - if(Character.isDigit(c)) + for (char c : formString.toCharArray()) { + if (Character.isDigit(c)) digitString.append(c); } - if(digitString.length() < 1) + if (digitString.length() < 1) return 0; return Integer.parseInt(digitString.toString()); } - public void setSkills(String skills){ - player.getEntityData().getCompoundTag("PlayerPersisted").setString("jrmcSSlts",skills); + public void setSkills(String skills) { + player.getEntityData().getCompoundTag("PlayerPersisted").setString("jrmcSSlts", skills); } - public String getSkills(){ + + public String getSkills() { return player.getEntityData().getCompoundTag("PlayerPersisted").getString("jrmcSSlts"); } - public void setJRMCSE(String statusEffects){ - player.getEntityData().getCompoundTag("PlayerPersisted").setString("jrmcStatusEff",statusEffects); + public void setJRMCSE(String statusEffects) { + player.getEntityData().getCompoundTag("PlayerPersisted").setString("jrmcStatusEff", statusEffects); } - public String getJRMCSE(){ + + public String getJRMCSE() { return player.getEntityData().getCompoundTag("PlayerPersisted").getString("jrmcStatusEff"); } - public byte getDBCClass(){ + public byte getDBCClass() { return player.getEntityData().getCompoundTag("PlayerPersisted").getByte("jrmcClass"); } + public void setDBCClass(byte dbcClass) { if (dbcClass < 0 || dbcClass > 2) return; @@ -748,9 +777,10 @@ public class ScriptDBCPlayer extends ScriptPlayer i player.getEntityData().getCompoundTag("PlayerPersisted").setByte("jrmcClass", dbcClass); } - public int getRace(){ + public int getRace() { return player.getEntityData().getCompoundTag("PlayerPersisted").getByte("jrmcRace"); } + public void setRace(byte race) { if (race < 0 || race > 1) return; @@ -758,9 +788,10 @@ public class ScriptDBCPlayer extends ScriptPlayer i player.getEntityData().getCompoundTag("PlayerPersisted").setByte("jrmcRace", race); } - public int getPowerType(){ + public int getPowerType() { return player.getEntityData().getCompoundTag("PlayerPersisted").getByte("jrmcPwrtyp"); } + public void setPowerType(byte powerType) { if (powerType < 0 || powerType > 1) return; @@ -768,7 +799,7 @@ public class ScriptDBCPlayer extends ScriptPlayer i player.getEntityData().getCompoundTag("PlayerPersisted").setByte("jrmcPwrtyp", powerType); } - public int getKillCount(String type){ + public int getKillCount(String type) { type = type.toLowerCase().trim(); int evilKills = player.getEntityData().getCompoundTag("PlayerPersisted").getInteger("jrmcKillCountEvil"); diff --git a/src/main/java/noppes/npcs/scripted/entity/ScriptEntity.java b/src/main/java/noppes/npcs/scripted/entity/ScriptEntity.java index 58342e8f0..86ba08dfa 100644 --- a/src/main/java/noppes/npcs/scripted/entity/ScriptEntity.java +++ b/src/main/java/noppes/npcs/scripted/entity/ScriptEntity.java @@ -32,486 +32,494 @@ import noppes.npcs.scripted.constants.EntityType; import java.util.*; public class ScriptEntity implements IEntity { - protected T entity; - private Map tempData = new HashMap<>(); - - public ScriptEntity(T entity){ - this.entity = entity; - } - - @Deprecated - public void spawnParticle(String directory, int HEXColor, int amount, int maxAge, - double x, double y, double z, - double motionX, double motionY, double motionZ, float gravity, - float scale1, float scale2, float scaleRate, int scaleRateStart, - float alpha1, float alpha2, float alphaRate, int alphaRateStart, - float rotation1, float rotation2, float rotationRate, int rotationRateStart, - float rotationX1, float rotationX2, float rotationXRate, int rotationXRateStart, - float rotationY1, float rotationY2, float rotationYRate, int rotationYRateStart, - float rotationZ1, float rotationZ2, float rotationZRate, int rotationZRateStart - ) { - int entityID = entity.getEntityId(); - ScriptParticle particle = new ScriptParticle(directory); - - particle.HEXColor = HEXColor; - particle.HEXColor2 = HEXColor; - particle.HEXColorRate = 0; - particle.HEXColorStart = 0; - - particle.amount = amount; - particle.maxAge = maxAge; - - particle.x = x; - particle.y = y; - particle.z = z; - particle.motionX = motionX; - particle.motionY = motionY; - particle.motionZ = motionZ; - particle.gravity = gravity; - - particle.scaleX1 = particle.scaleY1 = scale1; - particle.scaleX2 = particle.scaleY2 = scale2; - particle.scaleXRate = particle.scaleYRate = scaleRate; - particle.scaleXRateStart = particle.scaleYRateStart = scaleRateStart; - - particle.alpha1 = alpha1; - particle.alpha2 = alpha2; - particle.alphaRate = alphaRate; - particle.alphaRateStart = alphaRateStart; - - particle.rotationX1 = rotationX1; - particle.rotationX2 = rotationX2; - particle.rotationXRate = rotationXRate; - particle.rotationXRateStart = rotationXRateStart; - - particle.rotationY1 = rotationY1; - particle.rotationY2 = rotationY2; - particle.rotationYRate = rotationYRate; - particle.rotationYRateStart = rotationYRateStart; - - particle.rotationZ1 = rotationZ1; - particle.rotationZ2 = rotationZ2; - particle.rotationZRate = rotationZRate; - particle.rotationZRateStart = rotationZRateStart; - - NBTTagCompound compound = particle.writeToNBT(); - compound.setInteger("EntityID", entityID); - NoppesUtilServer.spawnScriptedParticle(compound, this.getWorld().getDimensionID()); - } - - @Deprecated - public void spawnParticle(String directory, int HEXColor, int amount, int maxAge, - double x, double y, double z, - double motionX, double motionY, double motionZ, float gravity, - float scale1, float scale2, float scaleRate, int scaleRateStart, - float alpha1, float alpha2, float alphaRate, int alphaRateStart - ) { - int entityID = entity.getEntityId(); - ScriptParticle particle = new ScriptParticle(directory); - - particle.HEXColor = HEXColor; - particle.HEXColor2 = HEXColor; - particle.HEXColorRate = 0; - particle.HEXColorStart = 0; - - particle.amount = amount; - particle.maxAge = maxAge; - - particle.x = x; - particle.y = y; - particle.z = z; - particle.motionX = motionX; - particle.motionY = motionY; - particle.motionZ = motionZ; - particle.gravity = gravity; - - particle.scaleX1 = particle.scaleY1 = scale1; - particle.scaleX2 = particle.scaleY2 = scale2; - particle.scaleXRate = particle.scaleYRate = scaleRate; - particle.scaleXRateStart = particle.scaleYRateStart = scaleRateStart; - - particle.alpha1 = alpha1; - particle.alpha2 = alpha2; - particle.alphaRate = alphaRate; - particle.alphaRateStart = alphaRateStart; - - NBTTagCompound compound = particle.writeToNBT(); - compound.setInteger("EntityID", entityID); - NoppesUtilServer.spawnScriptedParticle(compound, this.getWorld().getDimensionID()); - } - - @Deprecated - public void spawnParticle(String directory, int HEXColor, int amount, int maxAge, - double x, double y, double z, - double motionX, double motionY, double motionZ, float gravity, - float scale1, float scale2, float scaleRate, int scaleRateStart - ) { - int entityID = entity.getEntityId(); - ScriptParticle particle = new ScriptParticle(directory); - - particle.HEXColor = HEXColor; - particle.HEXColor2 = HEXColor; - particle.HEXColorRate = 0; - particle.HEXColorStart = 0; - - particle.amount = amount; - particle.maxAge = maxAge; - - particle.x = x; - particle.y = y; - particle.z = z; - particle.motionX = motionX; - particle.motionY = motionY; - particle.motionZ = motionZ; - particle.gravity = gravity; - - particle.scaleX1 = particle.scaleY1 = scale1; - particle.scaleX2 = particle.scaleY2 = scale2; - particle.scaleXRate = particle.scaleYRate = scaleRate; - particle.scaleXRateStart = particle.scaleYRateStart = scaleRateStart; - - NBTTagCompound compound = particle.writeToNBT(); - compound.setInteger("EntityID", entityID); - NoppesUtilServer.spawnScriptedParticle(compound, this.getWorld().getDimensionID()); - } - - @Deprecated - public void spawnParticle(String directory, int HEXColor, int amount, int maxAge, - double x, double y, double z, - double motionX, double motionY, double motionZ, float gravity - ) { - int entityID = entity.getEntityId(); - ScriptParticle particle = new ScriptParticle(directory); - - particle.HEXColor = HEXColor; - particle.HEXColor2 = HEXColor; - particle.HEXColorRate = 0; - particle.HEXColorStart = 0; - - particle.amount = amount; - particle.maxAge = maxAge; - - particle.x = x; - particle.y = y; - particle.z = z; - particle.motionX = motionX; - particle.motionY = motionY; - particle.motionZ = motionZ; - particle.gravity = gravity; - - NBTTagCompound compound = particle.writeToNBT(); - compound.setInteger("EntityID", entityID); - NoppesUtilServer.spawnScriptedParticle(compound, this.getWorld().getDimensionID()); - } - - @Deprecated - public void spawnParticle(String directory, int HEXColor, int amount, int maxAge, - double x, double y, double z - ) { - int entityID = entity.getEntityId(); - ScriptParticle particle = new ScriptParticle(directory); - - particle.HEXColor = HEXColor; - particle.HEXColor2 = HEXColor; - particle.HEXColorRate = 0; - particle.HEXColorStart = 0; - - particle.amount = amount; - particle.maxAge = maxAge; - - particle.x = x; - particle.y = y; - particle.z = z; - - NBTTagCompound compound = particle.writeToNBT(); - compound.setInteger("EntityID", entityID); - NoppesUtilServer.spawnScriptedParticle(compound, this.getWorld().getDimensionID()); - } - - @Deprecated - public void spawnParticle(String directory, int HEXColor, int amount, int maxAge - ) { - int entityID = entity.getEntityId(); - ScriptParticle particle = new ScriptParticle(directory); - - particle.HEXColor = HEXColor; - particle.HEXColor2 = HEXColor; - particle.HEXColorRate = 0; - particle.HEXColorStart = 0; - - particle.amount = amount; - particle.maxAge = maxAge; - - NBTTagCompound compound = particle.writeToNBT(); - compound.setInteger("EntityID", entityID); - NoppesUtilServer.spawnScriptedParticle(compound, this.getWorld().getDimensionID()); - } - - public void spawnParticle(IParticle entityParticle) { entityParticle.spawn(this); } - - public int getEntityId(){ - return entity.getEntityId(); - } - - public String getUniqueID(){ - return entity.getUniqueID().toString(); - } - - public double getYOffset() { return entity.getYOffset(); } - - /** - * @return The entities width - */ - public double getWidth(){ return entity.width; } - - /** - * @return The entities height - */ - public double getHeight(){ return entity.height; } - - /** - * @return The entities x position - */ - public double getX(){ - return entity.posX; - } - - /** - * @param x The entities x position - */ - public void setX(double x){ - entity.setPosition(x, entity.posY, entity.posZ);; - } - - /** - * @return The entities y position - */ - public double getY(){ - return entity.posY; - } - - /** - * @param y The entities y position - */ - public void setY(double y){ - entity.setPosition(entity.posX, y, entity.posZ); - } - - /** - * @return The entities x position - */ - public double getZ(){ - return entity.posZ; - } - - /** - * @param z The entities x position - */ - public void setZ(double z){ - entity.setPosition(entity.posX, entity.posY, z);; - } - - /** - * @return The entities z motion - */ - public double getMotionX(){ - return entity.motionX; - } - - /** - * @param x The entities x motion - */ - public void setMotionX(double x){ - entity.motionX = x; - entity.velocityChanged = true; - } - - /** - * @return The entities x motion - */ - public double getMotionY(){ - return entity.motionY; - } - - /** - * @param y The entities y motion - */ - public void setMotionY(double y){ - entity.motionY = y; - entity.velocityChanged = true; - } - - /** - * @return The entities y motion - */ - public double getMotionZ(){ - return entity.motionZ; - } - - /** - * @param z The entities z motion - */ - public void setMotionZ(double z){ - entity.motionZ = z; - entity.velocityChanged = true; - } - - public void setMotion(double x, double y, double z){ - this.setMotionX(x); - this.setMotionY(y); - this.setMotionZ(z); - } - - public void setMotion(IPos pos) { - this.setMotion(pos.getXD(),pos.getYD(),pos.getZD()); - } - - public IPos getMotion() { - return NpcAPI.Instance().getIPos(entity.motionX,entity.motionY,entity.motionZ); - } - - public boolean isAirborne(){ - return entity.isAirBorne; - } - - /** - * @return The block x position - */ - public int getBlockX(){ - return MathHelper.floor_double(entity.posX); - } - - /** - * @return The block y position - */ - public int getBlockY(){ - return MathHelper.floor_double(entity.posY); - } - - /** - * @return The block z position - */ - public int getBlockZ(){ - return MathHelper.floor_double(entity.posZ); - } - - /** - * @param x The x position - * @param y The y position - * @param z The z position - */ - public void setPosition(double x, double y, double z){ - entity.setPosition(x, y, z); - } - - public IPos getPos() { - return NpcAPI.Instance().getIPos(entity.posX, entity.posY, entity.posZ); - } - - public IPos getPosition() { - return getPos(); - } - - public void setPos(IPos pos) { - this.entity.setPosition(pos.getXD(), pos.getYD(), pos.getZD()); - } - - public void setPosition(IPos pos) { - this.setPos(pos); - } - - public int getDimension(){ - return entity.dimension; - } - - public void setDimension(int dimensionId) { - IWorld world = NpcAPI.Instance().getIWorld(dimensionId); - if (world != null) { - WorldServer mcWorld = world.getMCWorld(); - if (this.entity.riddenByEntity != null) - { - this.entity.riddenByEntity.mountEntity((Entity)null); - } - if (this.entity.ridingEntity != null) - { - this.entity.mountEntity((Entity)null); - } - WorldServer prevWorld = ((WorldServer)this.entity.worldObj); - prevWorld.unloadEntities(new ArrayList(Collections.singleton(this.entity))); - prevWorld.resetUpdateEntityTick(); - prevWorld.onEntityRemoved(this.entity); - - this.entity.worldObj = mcWorld; - this.entity.dimension = dimensionId; - mcWorld.addLoadedEntities(new ArrayList(Collections.singleton(this.entity))); - mcWorld.resetUpdateEntityTick(); - - mcWorld.updateEntityWithOptionalForce(this.entity, false); - if (this.entity instanceof EntityNPCInterface) { - ((EntityNPCInterface) this.entity).updateClient(); - } - - mcWorld.spawnEntityInWorld(this.entity); - this.entity.velocityChanged = true; - } - } - - /** - * @param range The search range for entities around this entity - * @return Array of entities within range - */ - public IEntity[] getSurroundingEntities(int range){ - List entities = entity.worldObj.getEntitiesWithinAABB(Entity.class, entity.boundingBox.expand(range, range, range)); - List list = new ArrayList(); - for(Entity living : entities){ - if(living != entity) - list.add(NpcAPI.Instance().getIEntity(living)); - } - return list.toArray(new IEntity[list.size()]); - } - - /** - * @param range The search range for entities around this entity - * @param type The EntityType you want to find - * @return Array of entities within range - */ - public IEntity[] getSurroundingEntities(int range, int type){ - Class cls = Entity.class; - if(type == EntityType.LIVING) - cls = EntityLivingBase.class; - else if(type == EntityType.PLAYER) - cls = EntityPlayer.class; - else if(type == EntityType.ANIMAL) - cls = EntityAnimal.class; - else if(type == EntityType.MONSTER) - cls = EntityMob.class; - else if(type == EntityType.NPC) - cls = EntityNPCInterface.class; - - List entities = entity.worldObj.getEntitiesWithinAABB(cls, entity.boundingBox.expand(range, range, range)); - List list = new ArrayList(); - for(Entity living : entities){ - if(living != entity) - list.add(NpcAPI.Instance().getIEntity(living)); - } - return list.toArray(new IEntity[list.size()]); - } - - - /** - * @return Whether the entity is alive or not - */ - public boolean isAlive(){ - return entity.isEntityAlive(); - } - - /** - * @param key Get temp data for this key - * @return Returns the stored temp data - */ - public Object getTempData(String key){ - return tempData.get(key); - } + protected T entity; + private Map tempData = new HashMap<>(); + + public ScriptEntity(T entity) { + this.entity = entity; + } + + @Deprecated + public void spawnParticle(String directory, int HEXColor, int amount, int maxAge, + double x, double y, double z, + double motionX, double motionY, double motionZ, float gravity, + float scale1, float scale2, float scaleRate, int scaleRateStart, + float alpha1, float alpha2, float alphaRate, int alphaRateStart, + float rotation1, float rotation2, float rotationRate, int rotationRateStart, + float rotationX1, float rotationX2, float rotationXRate, int rotationXRateStart, + float rotationY1, float rotationY2, float rotationYRate, int rotationYRateStart, + float rotationZ1, float rotationZ2, float rotationZRate, int rotationZRateStart + ) { + int entityID = entity.getEntityId(); + ScriptParticle particle = new ScriptParticle(directory); + + particle.HEXColor = HEXColor; + particle.HEXColor2 = HEXColor; + particle.HEXColorRate = 0; + particle.HEXColorStart = 0; + + particle.amount = amount; + particle.maxAge = maxAge; + + particle.x = x; + particle.y = y; + particle.z = z; + particle.motionX = motionX; + particle.motionY = motionY; + particle.motionZ = motionZ; + particle.gravity = gravity; + + particle.scaleX1 = particle.scaleY1 = scale1; + particle.scaleX2 = particle.scaleY2 = scale2; + particle.scaleXRate = particle.scaleYRate = scaleRate; + particle.scaleXRateStart = particle.scaleYRateStart = scaleRateStart; + + particle.alpha1 = alpha1; + particle.alpha2 = alpha2; + particle.alphaRate = alphaRate; + particle.alphaRateStart = alphaRateStart; + + particle.rotationX1 = rotationX1; + particle.rotationX2 = rotationX2; + particle.rotationXRate = rotationXRate; + particle.rotationXRateStart = rotationXRateStart; + + particle.rotationY1 = rotationY1; + particle.rotationY2 = rotationY2; + particle.rotationYRate = rotationYRate; + particle.rotationYRateStart = rotationYRateStart; + + particle.rotationZ1 = rotationZ1; + particle.rotationZ2 = rotationZ2; + particle.rotationZRate = rotationZRate; + particle.rotationZRateStart = rotationZRateStart; + + NBTTagCompound compound = particle.writeToNBT(); + compound.setInteger("EntityID", entityID); + NoppesUtilServer.spawnScriptedParticle(compound, this.getWorld().getDimensionID()); + } + + @Deprecated + public void spawnParticle(String directory, int HEXColor, int amount, int maxAge, + double x, double y, double z, + double motionX, double motionY, double motionZ, float gravity, + float scale1, float scale2, float scaleRate, int scaleRateStart, + float alpha1, float alpha2, float alphaRate, int alphaRateStart + ) { + int entityID = entity.getEntityId(); + ScriptParticle particle = new ScriptParticle(directory); + + particle.HEXColor = HEXColor; + particle.HEXColor2 = HEXColor; + particle.HEXColorRate = 0; + particle.HEXColorStart = 0; + + particle.amount = amount; + particle.maxAge = maxAge; + + particle.x = x; + particle.y = y; + particle.z = z; + particle.motionX = motionX; + particle.motionY = motionY; + particle.motionZ = motionZ; + particle.gravity = gravity; + + particle.scaleX1 = particle.scaleY1 = scale1; + particle.scaleX2 = particle.scaleY2 = scale2; + particle.scaleXRate = particle.scaleYRate = scaleRate; + particle.scaleXRateStart = particle.scaleYRateStart = scaleRateStart; + + particle.alpha1 = alpha1; + particle.alpha2 = alpha2; + particle.alphaRate = alphaRate; + particle.alphaRateStart = alphaRateStart; + + NBTTagCompound compound = particle.writeToNBT(); + compound.setInteger("EntityID", entityID); + NoppesUtilServer.spawnScriptedParticle(compound, this.getWorld().getDimensionID()); + } + + @Deprecated + public void spawnParticle(String directory, int HEXColor, int amount, int maxAge, + double x, double y, double z, + double motionX, double motionY, double motionZ, float gravity, + float scale1, float scale2, float scaleRate, int scaleRateStart + ) { + int entityID = entity.getEntityId(); + ScriptParticle particle = new ScriptParticle(directory); + + particle.HEXColor = HEXColor; + particle.HEXColor2 = HEXColor; + particle.HEXColorRate = 0; + particle.HEXColorStart = 0; + + particle.amount = amount; + particle.maxAge = maxAge; + + particle.x = x; + particle.y = y; + particle.z = z; + particle.motionX = motionX; + particle.motionY = motionY; + particle.motionZ = motionZ; + particle.gravity = gravity; + + particle.scaleX1 = particle.scaleY1 = scale1; + particle.scaleX2 = particle.scaleY2 = scale2; + particle.scaleXRate = particle.scaleYRate = scaleRate; + particle.scaleXRateStart = particle.scaleYRateStart = scaleRateStart; + + NBTTagCompound compound = particle.writeToNBT(); + compound.setInteger("EntityID", entityID); + NoppesUtilServer.spawnScriptedParticle(compound, this.getWorld().getDimensionID()); + } + + @Deprecated + public void spawnParticle(String directory, int HEXColor, int amount, int maxAge, + double x, double y, double z, + double motionX, double motionY, double motionZ, float gravity + ) { + int entityID = entity.getEntityId(); + ScriptParticle particle = new ScriptParticle(directory); + + particle.HEXColor = HEXColor; + particle.HEXColor2 = HEXColor; + particle.HEXColorRate = 0; + particle.HEXColorStart = 0; + + particle.amount = amount; + particle.maxAge = maxAge; + + particle.x = x; + particle.y = y; + particle.z = z; + particle.motionX = motionX; + particle.motionY = motionY; + particle.motionZ = motionZ; + particle.gravity = gravity; + + NBTTagCompound compound = particle.writeToNBT(); + compound.setInteger("EntityID", entityID); + NoppesUtilServer.spawnScriptedParticle(compound, this.getWorld().getDimensionID()); + } + + @Deprecated + public void spawnParticle(String directory, int HEXColor, int amount, int maxAge, + double x, double y, double z + ) { + int entityID = entity.getEntityId(); + ScriptParticle particle = new ScriptParticle(directory); + + particle.HEXColor = HEXColor; + particle.HEXColor2 = HEXColor; + particle.HEXColorRate = 0; + particle.HEXColorStart = 0; + + particle.amount = amount; + particle.maxAge = maxAge; + + particle.x = x; + particle.y = y; + particle.z = z; + + NBTTagCompound compound = particle.writeToNBT(); + compound.setInteger("EntityID", entityID); + NoppesUtilServer.spawnScriptedParticle(compound, this.getWorld().getDimensionID()); + } + + @Deprecated + public void spawnParticle(String directory, int HEXColor, int amount, int maxAge + ) { + int entityID = entity.getEntityId(); + ScriptParticle particle = new ScriptParticle(directory); + + particle.HEXColor = HEXColor; + particle.HEXColor2 = HEXColor; + particle.HEXColorRate = 0; + particle.HEXColorStart = 0; + + particle.amount = amount; + particle.maxAge = maxAge; + + NBTTagCompound compound = particle.writeToNBT(); + compound.setInteger("EntityID", entityID); + NoppesUtilServer.spawnScriptedParticle(compound, this.getWorld().getDimensionID()); + } + + public void spawnParticle(IParticle entityParticle) { + entityParticle.spawn(this); + } + + public int getEntityId() { + return entity.getEntityId(); + } + + public String getUniqueID() { + return entity.getUniqueID().toString(); + } + + public double getYOffset() { + return entity.getYOffset(); + } + + /** + * @return The entities width + */ + public double getWidth() { + return entity.width; + } + + /** + * @return The entities height + */ + public double getHeight() { + return entity.height; + } + + /** + * @return The entities x position + */ + public double getX() { + return entity.posX; + } + + /** + * @param x The entities x position + */ + public void setX(double x) { + entity.setPosition(x, entity.posY, entity.posZ); + ; + } + + /** + * @return The entities y position + */ + public double getY() { + return entity.posY; + } + + /** + * @param y The entities y position + */ + public void setY(double y) { + entity.setPosition(entity.posX, y, entity.posZ); + } + + /** + * @return The entities x position + */ + public double getZ() { + return entity.posZ; + } + + /** + * @param z The entities x position + */ + public void setZ(double z) { + entity.setPosition(entity.posX, entity.posY, z); + ; + } + + /** + * @return The entities z motion + */ + public double getMotionX() { + return entity.motionX; + } + + /** + * @param x The entities x motion + */ + public void setMotionX(double x) { + entity.motionX = x; + entity.velocityChanged = true; + } + + /** + * @return The entities x motion + */ + public double getMotionY() { + return entity.motionY; + } + + /** + * @param y The entities y motion + */ + public void setMotionY(double y) { + entity.motionY = y; + entity.velocityChanged = true; + } + + /** + * @return The entities y motion + */ + public double getMotionZ() { + return entity.motionZ; + } + + /** + * @param z The entities z motion + */ + public void setMotionZ(double z) { + entity.motionZ = z; + entity.velocityChanged = true; + } + + public void setMotion(double x, double y, double z) { + this.setMotionX(x); + this.setMotionY(y); + this.setMotionZ(z); + } + + public void setMotion(IPos pos) { + this.setMotion(pos.getXD(), pos.getYD(), pos.getZD()); + } + + public IPos getMotion() { + return NpcAPI.Instance().getIPos(entity.motionX, entity.motionY, entity.motionZ); + } + + public boolean isAirborne() { + return entity.isAirBorne; + } + + /** + * @return The block x position + */ + public int getBlockX() { + return MathHelper.floor_double(entity.posX); + } + + /** + * @return The block y position + */ + public int getBlockY() { + return MathHelper.floor_double(entity.posY); + } + + /** + * @return The block z position + */ + public int getBlockZ() { + return MathHelper.floor_double(entity.posZ); + } + + /** + * @param x The x position + * @param y The y position + * @param z The z position + */ + public void setPosition(double x, double y, double z) { + entity.setPosition(x, y, z); + } + + public IPos getPos() { + return NpcAPI.Instance().getIPos(entity.posX, entity.posY, entity.posZ); + } + + public IPos getPosition() { + return getPos(); + } + + public void setPos(IPos pos) { + this.entity.setPosition(pos.getXD(), pos.getYD(), pos.getZD()); + } + + public void setPosition(IPos pos) { + this.setPos(pos); + } + + public int getDimension() { + return entity.dimension; + } + + public void setDimension(int dimensionId) { + IWorld world = NpcAPI.Instance().getIWorld(dimensionId); + if (world != null) { + WorldServer mcWorld = world.getMCWorld(); + if (this.entity.riddenByEntity != null) { + this.entity.riddenByEntity.mountEntity((Entity) null); + } + if (this.entity.ridingEntity != null) { + this.entity.mountEntity((Entity) null); + } + WorldServer prevWorld = ((WorldServer) this.entity.worldObj); + prevWorld.unloadEntities(new ArrayList(Collections.singleton(this.entity))); + prevWorld.resetUpdateEntityTick(); + prevWorld.onEntityRemoved(this.entity); + + this.entity.worldObj = mcWorld; + this.entity.dimension = dimensionId; + mcWorld.addLoadedEntities(new ArrayList(Collections.singleton(this.entity))); + mcWorld.resetUpdateEntityTick(); + + mcWorld.updateEntityWithOptionalForce(this.entity, false); + if (this.entity instanceof EntityNPCInterface) { + ((EntityNPCInterface) this.entity).updateClient(); + } + + mcWorld.spawnEntityInWorld(this.entity); + this.entity.velocityChanged = true; + } + } + + /** + * @param range The search range for entities around this entity + * @return Array of entities within range + */ + public IEntity[] getSurroundingEntities(int range) { + List entities = entity.worldObj.getEntitiesWithinAABB(Entity.class, entity.boundingBox.expand(range, range, range)); + List list = new ArrayList(); + for (Entity living : entities) { + if (living != entity) + list.add(NpcAPI.Instance().getIEntity(living)); + } + return list.toArray(new IEntity[list.size()]); + } + + /** + * @param range The search range for entities around this entity + * @param type The EntityType you want to find + * @return Array of entities within range + */ + public IEntity[] getSurroundingEntities(int range, int type) { + Class cls = Entity.class; + if (type == EntityType.LIVING) + cls = EntityLivingBase.class; + else if (type == EntityType.PLAYER) + cls = EntityPlayer.class; + else if (type == EntityType.ANIMAL) + cls = EntityAnimal.class; + else if (type == EntityType.MONSTER) + cls = EntityMob.class; + else if (type == EntityType.NPC) + cls = EntityNPCInterface.class; + + List entities = entity.worldObj.getEntitiesWithinAABB(cls, entity.boundingBox.expand(range, range, range)); + List list = new ArrayList(); + for (Entity living : entities) { + if (living != entity) + list.add(NpcAPI.Instance().getIEntity(living)); + } + return list.toArray(new IEntity[list.size()]); + } + + + /** + * @return Whether the entity is alive or not + */ + public boolean isAlive() { + return entity.isEntityAlive(); + } + + /** + * @param key Get temp data for this key + * @return Returns the stored temp data + */ + public Object getTempData(String key) { + return tempData.get(key); + } public void copyTempData(IEntity scriptEntity) { if (scriptEntity != null) { @@ -519,409 +527,416 @@ public class ScriptEntity implements IEntity { } } - /** - * Tempdata gets cleared when the entity gets unloaded or the world restarts - * @param key The key for the data stored - * @param value The data stored - */ - public void setTempData(String key, Object value){ - tempData.put(key, value); - } + /** + * Tempdata gets cleared when the entity gets unloaded or the world restarts + * + * @param key The key for the data stored + * @param value The data stored + */ + public void setTempData(String key, Object value) { + tempData.put(key, value); + } - /** - * @param key The key thats going to be tested against the temp data - * @return Whether or not temp data containes the key - */ - public boolean hasTempData(String key){ - return tempData.containsKey(key); - } + /** + * @param key The key thats going to be tested against the temp data + * @return Whether or not temp data containes the key + */ + public boolean hasTempData(String key) { + return tempData.containsKey(key); + } - /** - * @param key The key for the temp data to be removed - */ - public void removeTempData(String key){ - tempData.remove(key); - } + /** + * @param key The key for the temp data to be removed + */ + public void removeTempData(String key) { + tempData.remove(key); + } - /** - * Remove all tempdata - */ - public void clearTempData(){ - tempData.clear(); - } + /** + * Remove all tempdata + */ + public void clearTempData() { + tempData.clear(); + } - public String[] getTempDataKeys() { - return tempData.keySet().toArray(new String[0]); - } + public String[] getTempDataKeys() { + return tempData.keySet().toArray(new String[0]); + } - /** - * @param key The key of the data to be returned - * @return Returns the stored data - */ - public Object getStoredData(String key){ - NBTTagCompound compound = getStoredCompound(); - if(!compound.hasKey(key)) - return null; - NBTBase base = compound.getTag(key); - if(base instanceof NBTPrimitive) - return ((NBTPrimitive)base).func_150286_g(); - else if (base instanceof NBTTagIntArray) - return ((NBTTagIntArray)base).func_150302_c(); - return ((NBTTagString)base).func_150285_a_(); - } + /** + * @param key The key of the data to be returned + * @return Returns the stored data + */ + public Object getStoredData(String key) { + NBTTagCompound compound = getStoredCompound(); + if (!compound.hasKey(key)) + return null; + NBTBase base = compound.getTag(key); + if (base instanceof NBTPrimitive) + return ((NBTPrimitive) base).func_150286_g(); + else if (base instanceof NBTTagIntArray) + return ((NBTTagIntArray) base).func_150302_c(); + return ((NBTTagString) base).func_150285_a_(); + } - /** - * Stored data persists through world restart. Unlike tempdata only Strings and Numbers can be saved - * @param key The key for the data stored - * @param value The data stored. This data can be either a Number or a String. Other data is not stored - */ - public void setStoredData(String key, Object value){ - NBTTagCompound compound = getStoredCompound(); - if(value instanceof Number){ - compound.setDouble(key, ((Number) value).doubleValue()); - } - else if(value instanceof String) - compound.setString(key, (String)value); - saveStoredCompound(compound); - } + /** + * Stored data persists through world restart. Unlike tempdata only Strings and Numbers can be saved + * + * @param key The key for the data stored + * @param value The data stored. This data can be either a Number or a String. Other data is not stored + */ + public void setStoredData(String key, Object value) { + NBTTagCompound compound = getStoredCompound(); + if (value instanceof Number) { + compound.setDouble(key, ((Number) value).doubleValue()); + } else if (value instanceof String) + compound.setString(key, (String) value); + saveStoredCompound(compound); + } - public void setStoredData(String key, int[] array){ - NBTTagCompound compound = getStoredCompound(); - compound.setIntArray(key, array); - saveStoredCompound(compound); - } + public void setStoredData(String key, int[] array) { + NBTTagCompound compound = getStoredCompound(); + compound.setIntArray(key, array); + saveStoredCompound(compound); + } - /** - * @param key The key of the data to be checked - * @return Returns whether or not the stored data contains the key - */ - public boolean hasStoredData(String key){ - return getStoredCompound().hasKey(key); - } + /** + * @param key The key of the data to be checked + * @return Returns whether or not the stored data contains the key + */ + public boolean hasStoredData(String key) { + return getStoredCompound().hasKey(key); + } - /** - * @param key The key of the data to be removed - */ - public void removeStoredData(String key){ - NBTTagCompound compound = getStoredCompound(); - compound.removeTag(key); - saveStoredCompound(compound); - } + /** + * @param key The key of the data to be removed + */ + public void removeStoredData(String key) { + NBTTagCompound compound = getStoredCompound(); + compound.removeTag(key); + saveStoredCompound(compound); + } - /** - * Remove all stored data - */ - public void clearStoredData(){ - entity.getEntityData().removeTag("CNPCStoredData"); - } + /** + * Remove all stored data + */ + public void clearStoredData() { + entity.getEntityData().removeTag("CNPCStoredData"); + } - public String[] getStoredDataKeys() { - NBTTagCompound compound = getStoredCompound(); - Set strings = compound.func_150296_c(); - ArrayList stringList = new ArrayList<>(); - for (Object o : strings) { - stringList.add((String)o); - } - return stringList.toArray(new String[0]); - } + public String[] getStoredDataKeys() { + NBTTagCompound compound = getStoredCompound(); + Set strings = compound.func_150296_c(); + ArrayList stringList = new ArrayList<>(); + for (Object o : strings) { + stringList.add((String) o); + } + return stringList.toArray(new String[0]); + } - private NBTTagCompound getStoredCompound(){ - NBTTagCompound compound = entity.getEntityData().getCompoundTag("CNPCStoredData"); - if(compound == null) - entity.getEntityData().setTag("CNPCStoredData", compound = new NBTTagCompound()); - return compound; - } + private NBTTagCompound getStoredCompound() { + NBTTagCompound compound = entity.getEntityData().getCompoundTag("CNPCStoredData"); + if (compound == null) + entity.getEntityData().setTag("CNPCStoredData", compound = new NBTTagCompound()); + return compound; + } - private void saveStoredCompound(NBTTagCompound compound){ - entity.getEntityData().setTag("CNPCStoredData", compound); - } + private void saveStoredCompound(NBTTagCompound compound) { + entity.getEntityData().setTag("CNPCStoredData", compound); + } - /** - * @return The age of this entity in ticks - */ - public long getAge(){ - return entity.ticksExisted; - } + /** + * @return The age of this entity in ticks + */ + public long getAge() { + return entity.ticksExisted; + } - /** - * Despawns this entity. Removes it permanently - */ - public void despawn(){ - entity.isDead = true; - } + /** + * Despawns this entity. Removes it permanently + */ + public void despawn() { + entity.isDead = true; + } - /** - * @return Return whether or not this entity is standing in water - */ - public boolean inWater(){ - return entity.isInsideOfMaterial(Material.water); - } + /** + * @return Return whether or not this entity is standing in water + */ + public boolean inWater() { + return entity.isInsideOfMaterial(Material.water); + } - /** - * @return Return whether or not this entity is standing in lava - */ - public boolean inLava(){ - return entity.isInsideOfMaterial(Material.lava); - } + /** + * @return Return whether or not this entity is standing in lava + */ + public boolean inLava() { + return entity.isInsideOfMaterial(Material.lava); + } - /** - * @return Return whether or not this entity is standing in fire - */ - public boolean inFire(){ - return entity.isInsideOfMaterial(Material.fire); - } + /** + * @return Return whether or not this entity is standing in fire + */ + public boolean inFire() { + return entity.isInsideOfMaterial(Material.fire); + } - /** - * @return Return whether or not this entity is on fire - */ - public boolean isBurning(){ - return entity.isBurning(); - } + /** + * @return Return whether or not this entity is on fire + */ + public boolean isBurning() { + return entity.isBurning(); + } - /** - * @param ticks Amount of world ticks this entity will burn. 20 ticks equals 1 second - */ - public void setBurning(int ticks){ - entity.setFire(ticks); - } + /** + * @param ticks Amount of world ticks this entity will burn. 20 ticks equals 1 second + */ + public void setBurning(int ticks) { + entity.setFire(ticks); + } - /** - * Removes fire from this entity - */ - public void extinguish(){ - entity.extinguish(); - } + /** + * Removes fire from this entity + */ + public void extinguish() { + entity.extinguish(); + } - /** - * @return Name as which it's registered in minecraft - */ - public String getTypeName(){ - return EntityList.getEntityString(entity); - } + /** + * @return Name as which it's registered in minecraft + */ + public String getTypeName() { + return EntityList.getEntityString(entity); + } - public void playSound(String name, float volume, float pitch) { - entity.playSound(name, volume, pitch); - } + public void playSound(String name, float volume, float pitch) { + entity.playSound(name, volume, pitch); + } - /** - * @param item Item to be dropped - */ - public void dropItem(IItemStack item){ - entity.entityDropItem(item.getMCItemStack(), 0); - } + /** + * @param item Item to be dropped + */ + public void dropItem(IItemStack item) { + entity.entityDropItem(item.getMCItemStack(), 0); + } - /** - * @return Return the rider - */ - public IEntity getRider(){ - return NpcAPI.Instance().getIEntity(entity.riddenByEntity); - } + /** + * @return Return the rider + */ + public IEntity getRider() { + return NpcAPI.Instance().getIEntity(entity.riddenByEntity); + } - /** - * @param entity The entity to ride this entity - */ - public void setRider(IEntity entity){ - if(entity != null){ - entity.getMCEntity().mountEntity(this.entity);; - } - else if(this.entity.riddenByEntity != null) - this.entity.riddenByEntity.mountEntity(null); - } + /** + * @param entity The entity to ride this entity + */ + public void setRider(IEntity entity) { + if (entity != null) { + entity.getMCEntity().mountEntity(this.entity); + ; + } else if (this.entity.riddenByEntity != null) + this.entity.riddenByEntity.mountEntity(null); + } - /** - * @return Return the entity, this entity is riding - */ - public IEntity getMount(){ - return NpcAPI.Instance().getIEntity(entity.ridingEntity); - } + /** + * @return Return the entity, this entity is riding + */ + public IEntity getMount() { + return NpcAPI.Instance().getIEntity(entity.ridingEntity); + } - /** - * @param entity The entity this entity will mount - */ - public void setMount(IEntity entity){ - if(entity == null) - this.entity.mountEntity(null); - else - this.entity.mountEntity(entity.getMCEntity()); - } + /** + * @param entity The entity this entity will mount + */ + public void setMount(IEntity entity) { + if (entity == null) + this.entity.mountEntity(null); + else + this.entity.mountEntity(entity.getMCEntity()); + } - /** - * @see noppes.npcs.scripted.constants.EntityType - * @return Returns the EntityType of this entity - */ - public int getType(){ - return EntityType.UNKNOWN; - } + /** + * @return Returns the EntityType of this entity + * @see noppes.npcs.scripted.constants.EntityType + */ + public int getType() { + return EntityType.UNKNOWN; + } - /** - * @since 1.7.10c - * @param type @EntityType to check - * @return Returns whether the entity is type of the given @EntityType - */ - public boolean typeOf(int type){ - return type == EntityType.UNKNOWN; - } + /** + * @param type @EntityType to check + * @return Returns whether the entity is type of the given @EntityType + * @since 1.7.10c + */ + public boolean typeOf(int type) { + return type == EntityType.UNKNOWN; + } - /** - * @param rotation The rotation to be set (0-360) - */ - public void setRotation(float rotation){ - entity.rotationYaw = rotation; - } + /** + * @param rotation The rotation to be set (0-360) + */ + public void setRotation(float rotation) { + entity.rotationYaw = rotation; + } - public void setRotation(float rotationYaw, float rotationPitch) { - entity.rotationYaw = rotationYaw; - entity.rotationPitch = rotationPitch; - } + public void setRotation(float rotationYaw, float rotationPitch) { + entity.rotationYaw = rotationYaw; + entity.rotationPitch = rotationPitch; + } - /** - * @return Current rotation of the entity - */ - public float getRotation(){ - return entity.rotationYaw; - } + /** + * @return Current rotation of the entity + */ + public float getRotation() { + return entity.rotationYaw; + } - public void setPitch(float pitch){entity.rotationPitch = pitch;} + public void setPitch(float pitch) { + entity.rotationPitch = pitch; + } - public float getPitch(){return entity.rotationPitch;} + public float getPitch() { + return entity.rotationPitch; + } - /** - * @param power How strong the knockback is - * @param direction The direction in which he flies back (0-360). Usually based on getRotation() - */ - @Override - public void knockback(int power, float direction){ - float v = direction * (float)Math.PI / 180.0F; - entity.addVelocity(-MathHelper.sin(v) * (float)power, power, MathHelper.cos(v) * (float)power); - entity.velocityChanged = true; - } + /** + * @param power How strong the knockback is + * @param direction The direction in which he flies back (0-360). Usually based on getRotation() + */ + @Override + public void knockback(int power, float direction) { + float v = direction * (float) Math.PI / 180.0F; + entity.addVelocity(-MathHelper.sin(v) * (float) power, power, MathHelper.cos(v) * (float) power); + entity.velocityChanged = true; + } - public void knockback(double xpower, double ypower, double zpower, float direction){ - float v = direction * (float)Math.PI / 180.0F; - entity.addVelocity(-MathHelper.sin(v) * xpower, ypower, MathHelper.cos(v) * zpower); - entity.velocityChanged = true; - } + public void knockback(double xpower, double ypower, double zpower, float direction) { + float v = direction * (float) Math.PI / 180.0F; + entity.addVelocity(-MathHelper.sin(v) * xpower, ypower, MathHelper.cos(v) * zpower); + entity.velocityChanged = true; + } - public void knockback(IPos pos, float direction){ - this.knockback(pos.getXD(),pos.getYD(),pos.getZD(),direction); - } + public void knockback(IPos pos, float direction) { + this.knockback(pos.getXD(), pos.getYD(), pos.getZD(), direction); + } - public void setImmune(int ticks) { - entity.hurtResistantTime = ticks; - }; + public void setImmune(int ticks) { + entity.hurtResistantTime = ticks; + } - public void setInvisible(boolean invisible){ - entity.setInvisible(invisible); - } + ; - public void setSneaking(boolean sneaking){ - entity.setSneaking(sneaking); - } + public void setInvisible(boolean invisible) { + entity.setInvisible(invisible); + } - public void setSprinting(boolean sprinting){ - entity.setSprinting(sprinting); - } + public void setSneaking(boolean sneaking) { + entity.setSneaking(sneaking); + } - public boolean hasCollided() { - return entity.isCollided; - } + public void setSprinting(boolean sprinting) { + entity.setSprinting(sprinting); + } - public boolean hasCollidedVertically() { - return entity.isCollidedVertically; - } + public boolean hasCollided() { + return entity.isCollided; + } - public boolean hasCollidedHorizontally() { - return entity.isCollidedHorizontally; - } + public boolean hasCollidedVertically() { + return entity.isCollidedVertically; + } - public boolean capturesDrops() { - return entity.captureDrops; - } + public boolean hasCollidedHorizontally() { + return entity.isCollidedHorizontally; + } - public void setCapturesDrops(boolean capture) { - entity.captureDrops = capture; - } + public boolean capturesDrops() { + return entity.captureDrops; + } - public void setCapturedDrops(IEntity[] capturedDrops) { - entity.capturedDrops.clear(); - for (IEntity iEntity : capturedDrops) { - if (iEntity.getMCEntity() instanceof EntityItem) { - entity.capturedDrops.add((EntityItem) iEntity.getMCEntity()); - } - } - } + public void setCapturesDrops(boolean capture) { + entity.captureDrops = capture; + } - public IEntity[] getCapturedDrops() { - ArrayList> iEntityList = new ArrayList<>(); - for (EntityItem entityItem : entity.capturedDrops) { - iEntityList.add(NpcAPI.Instance().getIEntity(entityItem)); - } - return iEntityList.toArray(new IEntity[0]); - } + public void setCapturedDrops(IEntity[] capturedDrops) { + entity.capturedDrops.clear(); + for (IEntity iEntity : capturedDrops) { + if (iEntity.getMCEntity() instanceof EntityItem) { + entity.capturedDrops.add((EntityItem) iEntity.getMCEntity()); + } + } + } - /** - * @since 1.7.10c - * @return Returns whether or not this entity is sneaking - */ - public boolean isSneaking(){ - return entity.isSneaking(); - } + public IEntity[] getCapturedDrops() { + ArrayList> iEntityList = new ArrayList<>(); + for (EntityItem entityItem : entity.capturedDrops) { + iEntityList.add(NpcAPI.Instance().getIEntity(entityItem)); + } + return iEntityList.toArray(new IEntity[0]); + } - /** - * @since 1.7.10c - * @return Returns whether or not this entity is sprinting - */ - public boolean isSprinting(){ - return entity.isSprinting(); - } + /** + * @return Returns whether or not this entity is sneaking + * @since 1.7.10c + */ + public boolean isSneaking() { + return entity.isSneaking(); + } - /** - * @since 1.7.10c - * Expert users only - * @return Returns minecrafts entity - */ - public T getMCEntity(){ - return entity; - } + /** + * @return Returns whether or not this entity is sprinting + * @since 1.7.10c + */ + public boolean isSprinting() { + return entity.isSprinting(); + } - public INbt getNbt() { - return NpcAPI.Instance().getINbt(this.entity.getEntityData()); - } + /** + * @return Returns minecrafts entity + * @since 1.7.10c + * Expert users only + */ + public T getMCEntity() { + return entity; + } - public INbt getAllNbt() { - NBTTagCompound compound = new NBTTagCompound(); - this.entity.writeToNBT(compound); - return NpcAPI.Instance().getINbt(compound); - } + public INbt getNbt() { + return NpcAPI.Instance().getINbt(this.entity.getEntityData()); + } - public void setNbt(INbt nbt) { - this.entity.readFromNBT(nbt.getMCNBT()); - } + public INbt getAllNbt() { + NBTTagCompound compound = new NBTTagCompound(); + this.entity.writeToNBT(compound); + return NpcAPI.Instance().getINbt(compound); + } - public INbt getNbtOptional() { - NBTTagCompound compound = new NBTTagCompound(); - return this.entity.writeToNBTOptional(compound) ? NpcAPI.Instance().getINbt(compound) : null; - } + public void setNbt(INbt nbt) { + this.entity.readFromNBT(nbt.getMCNBT()); + } - public void storeAsClone(int tab, String name) { - NBTTagCompound compound = new NBTTagCompound(); - if (!this.entity.writeToNBTOptional(compound)) { - throw new CustomNPCsException("Cannot store dead entities", new Object[0]); - } else { - ServerCloneController.Instance.addClone(compound, name, tab); - } - } + public INbt getNbtOptional() { + NBTTagCompound compound = new NBTTagCompound(); + return this.entity.writeToNBTOptional(compound) ? NpcAPI.Instance().getINbt(compound) : null; + } - public IWorld getWorld() { - return NpcAPI.Instance().getIWorld(entity.worldObj); - } + public void storeAsClone(int tab, String name) { + NBTTagCompound compound = new NBTTagCompound(); + if (!this.entity.writeToNBTOptional(compound)) { + throw new CustomNPCsException("Cannot store dead entities", new Object[0]); + } else { + ServerCloneController.Instance.addClone(compound, name, tab); + } + } - public boolean equals(Object object) { - return object instanceof IEntity && ((IEntity)object).getMCEntity().equals(this.entity); - } + public IWorld getWorld() { + return NpcAPI.Instance().getIWorld(entity.worldObj); + } - public void updateEntity() { - IWorld world = NpcAPI.Instance().getIWorld(entity.worldObj); - entity.dimension = world.getDimensionID(); - } + public boolean equals(Object object) { + return object instanceof IEntity && ((IEntity) object).getMCEntity().equals(this.entity); + } + + public void updateEntity() { + IWorld world = NpcAPI.Instance().getIWorld(entity.worldObj); + entity.dimension = world.getDimensionID(); + } } diff --git a/src/main/java/noppes/npcs/scripted/entity/ScriptEntityItem.java b/src/main/java/noppes/npcs/scripted/entity/ScriptEntityItem.java index e55aa98b9..c086d996c 100644 --- a/src/main/java/noppes/npcs/scripted/entity/ScriptEntityItem.java +++ b/src/main/java/noppes/npcs/scripted/entity/ScriptEntityItem.java @@ -49,7 +49,7 @@ public class ScriptEntityItem extends ScriptEntity impl public void setAge(long age) { age = Math.max(Math.min(age, Integer.MAX_VALUE), Integer.MIN_VALUE); - this.entity.age = (int)age; + this.entity.age = (int) age; } public int getLifeSpawn() { @@ -65,7 +65,7 @@ public class ScriptEntityItem extends ScriptEntity impl } public void setItem(IItemStack item) { - ItemStack stack = item == null? null : item.getMCItemStack(); + ItemStack stack = item == null ? null : item.getMCItemStack(); this.entity.setEntityItemStack(stack); } } diff --git a/src/main/java/noppes/npcs/scripted/entity/ScriptLiving.java b/src/main/java/noppes/npcs/scripted/entity/ScriptLiving.java index 2d7f904e4..e5ef639eb 100644 --- a/src/main/java/noppes/npcs/scripted/entity/ScriptLiving.java +++ b/src/main/java/noppes/npcs/scripted/entity/ScriptLiving.java @@ -8,156 +8,145 @@ import noppes.npcs.scripted.NpcAPI; public class ScriptLiving extends ScriptLivingBase implements IEntityLiving { - public ScriptLiving(T entity) { - super(entity); - } - - @Override - public boolean isAttacking(){ - return super.isAttacking() || entity.getAttackTarget() != null; - } - - @Override - public void setAttackTarget(IEntityLivingBase living){ - if(living == null) - entity.setAttackTarget(null); - else - entity.setAttackTarget(living.getMCEntity()); - super.setAttackTarget(living); - } - - @Override - public IEntityLivingBase getAttackTarget(){ - IEntityLivingBase base = (IEntityLivingBase) NpcAPI.Instance().getIEntity(entity.getAttackTarget()); - return (base != null)? base: super.getAttackTarget(); - } - - /** - * Start path finding toward this target - * @param x Destination x position - * @param y Destination x position - * @param z Destination x position - * @param speed Walking speed of the entity 0.7 is default - */ - public void navigateTo(double x, double y, double z, double speed){ - entity.getNavigator().tryMoveToXYZ(x, y, z, speed); - } - - /** - * Stop navigating wherever this npc was walking to - */ - public void clearNavigation(){ - entity.getNavigator().clearPathEntity(); - } - - /** - * @return Whether or not this entity is navigating somewhere - */ - public boolean isNavigating(){ - return !entity.getNavigator().noPath(); - } - - @Override - public boolean canSeeEntity(IEntity entity){ - return this.entity.getEntitySenses().canSee(entity.getMCEntity()); - } - - public void playLivingSound() { - this.entity.playLivingSound(); - } - - public void spawnExplosionParticle() - { - this.entity.spawnExplosionParticle(); - } - - public void setMoveForward(float speed) - { - this.entity.setMoveForward(speed); - } - - public void faceEntity(IEntity entity, float pitch, float yaw) - { - this.entity.faceEntity(entity.getMCEntity(), pitch, yaw); - } - - public boolean canPickUpLoot() - { - return this.entity.canPickUpLoot(); - } - - public void setCanPickUpLoot(boolean pickUp) - { - this.entity.setCanPickUpLoot(pickUp); - } - - public boolean isPersistent() - { - return this.entity.isNoDespawnRequired(); - } - - public void enablePersistence() { - this.entity.func_110163_bv(); - } - - public void setCustomNameTag(String text) - { - this.entity.setCustomNameTag(text); - } - - public String getCustomNameTag() - { - return this.entity.getCustomNameTag(); - } - - public boolean hasCustomNameTag() - { - return this.entity.hasCustomNameTag(); - } - - public void setAlwaysRenderNameTag(boolean alwaysRender) - { - this.entity.setAlwaysRenderNameTag(alwaysRender); - } - - public boolean getAlwaysRenderNameTag() - { - return this.entity.getAlwaysRenderNameTag(); - } - - public void clearLeashed(boolean sendPacket, boolean dropLeash) - { - this.entity.clearLeashed(sendPacket,dropLeash); - } - - public boolean allowLeashing() { - return this.entity.allowLeashing(); - } - - public boolean getLeashed() { - return this.entity.getLeashed(); - } - - public IEntity getLeashedTo() { - return NpcAPI.Instance().getIEntity(entity.getLeashedToEntity()); - } - - public void setLeashedTo(IEntity entity, boolean sendPacket) { - this.entity.setLeashedToEntity(entity.getMCEntity(), sendPacket); - } - - public boolean canBeSteered() { - return this.entity.canBeSteered(); - } + public ScriptLiving(T entity) { + super(entity); + } @Override - public void setRotation(float rotation){ + public boolean isAttacking() { + return super.isAttacking() || entity.getAttackTarget() != null; + } + + @Override + public void setAttackTarget(IEntityLivingBase living) { + if (living == null) + entity.setAttackTarget(null); + else + entity.setAttackTarget(living.getMCEntity()); + super.setAttackTarget(living); + } + + @Override + public IEntityLivingBase getAttackTarget() { + IEntityLivingBase base = (IEntityLivingBase) NpcAPI.Instance().getIEntity(entity.getAttackTarget()); + return (base != null) ? base : super.getAttackTarget(); + } + + /** + * Start path finding toward this target + * + * @param x Destination x position + * @param y Destination x position + * @param z Destination x position + * @param speed Walking speed of the entity 0.7 is default + */ + public void navigateTo(double x, double y, double z, double speed) { + entity.getNavigator().tryMoveToXYZ(x, y, z, speed); + } + + /** + * Stop navigating wherever this npc was walking to + */ + public void clearNavigation() { + entity.getNavigator().clearPathEntity(); + } + + /** + * @return Whether or not this entity is navigating somewhere + */ + public boolean isNavigating() { + return !entity.getNavigator().noPath(); + } + + @Override + public boolean canSeeEntity(IEntity entity) { + return this.entity.getEntitySenses().canSee(entity.getMCEntity()); + } + + public void playLivingSound() { + this.entity.playLivingSound(); + } + + public void spawnExplosionParticle() { + this.entity.spawnExplosionParticle(); + } + + public void setMoveForward(float speed) { + this.entity.setMoveForward(speed); + } + + public void faceEntity(IEntity entity, float pitch, float yaw) { + this.entity.faceEntity(entity.getMCEntity(), pitch, yaw); + } + + public boolean canPickUpLoot() { + return this.entity.canPickUpLoot(); + } + + public void setCanPickUpLoot(boolean pickUp) { + this.entity.setCanPickUpLoot(pickUp); + } + + public boolean isPersistent() { + return this.entity.isNoDespawnRequired(); + } + + public void enablePersistence() { + this.entity.func_110163_bv(); + } + + public void setCustomNameTag(String text) { + this.entity.setCustomNameTag(text); + } + + public String getCustomNameTag() { + return this.entity.getCustomNameTag(); + } + + public boolean hasCustomNameTag() { + return this.entity.hasCustomNameTag(); + } + + public void setAlwaysRenderNameTag(boolean alwaysRender) { + this.entity.setAlwaysRenderNameTag(alwaysRender); + } + + public boolean getAlwaysRenderNameTag() { + return this.entity.getAlwaysRenderNameTag(); + } + + public void clearLeashed(boolean sendPacket, boolean dropLeash) { + this.entity.clearLeashed(sendPacket, dropLeash); + } + + public boolean allowLeashing() { + return this.entity.allowLeashing(); + } + + public boolean getLeashed() { + return this.entity.getLeashed(); + } + + public IEntity getLeashedTo() { + return NpcAPI.Instance().getIEntity(entity.getLeashedToEntity()); + } + + public void setLeashedTo(IEntity entity, boolean sendPacket) { + this.entity.setLeashedToEntity(entity.getMCEntity(), sendPacket); + } + + public boolean canBeSteered() { + return this.entity.canBeSteered(); + } + + @Override + public void setRotation(float rotation) { super.setRotation(rotation); entity.getLookHelper().setLookPosition(getX(), getY(), getZ(), rotation, getPitch()); } @Override - public void setPitch(float rotation){ + public void setPitch(float rotation) { super.setPitch(rotation); entity.getLookHelper().setLookPosition(getX(), getY(), getZ(), getRotation(), rotation); } diff --git a/src/main/java/noppes/npcs/scripted/entity/ScriptLivingBase.java b/src/main/java/noppes/npcs/scripted/entity/ScriptLivingBase.java index f49e8f213..cf2859b76 100644 --- a/src/main/java/noppes/npcs/scripted/entity/ScriptLivingBase.java +++ b/src/main/java/noppes/npcs/scripted/entity/ScriptLivingBase.java @@ -21,357 +21,357 @@ import java.util.Collections; public class ScriptLivingBase extends ScriptEntity implements IEntityLivingBase { - public ScriptLivingBase(T entity){ - super(entity); - } + public ScriptLivingBase(T entity) { + super(entity); + } - /** - * @return The entity's current health - */ - public float getHealth(){ - return entity.getHealth(); - } + /** + * @return The entity's current health + */ + public float getHealth() { + return entity.getHealth(); + } - /** - * @param health The new health of this entity - */ - public void setHealth(float health){ - entity.setHealth(health); - } + /** + * @param health The new health of this entity + */ + public void setHealth(float health) { + entity.setHealth(health); + } - public void hurt(float damage){ - entity.attackEntityFrom(DamageSource.generic,damage); - } + public void hurt(float damage) { + entity.attackEntityFrom(DamageSource.generic, damage); + } - public void hurt(float damage, IEntity source) { - if(source.getType() == 1)//if player - entity.attackEntityFrom(new EntityDamageSource("player",source.getMCEntity()),damage); - else - entity.attackEntityFrom(new EntityDamageSource(source.getTypeName(),source.getMCEntity()),damage); - } + public void hurt(float damage, IEntity source) { + if (source.getType() == 1)//if player + entity.attackEntityFrom(new EntityDamageSource("player", source.getMCEntity()), damage); + else + entity.attackEntityFrom(new EntityDamageSource(source.getTypeName(), source.getMCEntity()), damage); + } - public void hurt(float damage, IDamageSource damageSource) { - entity.attackEntityFrom(damageSource.getMCDamageSource(),damage); - } + public void hurt(float damage, IDamageSource damageSource) { + entity.attackEntityFrom(damageSource.getMCDamageSource(), damage); + } - public void setMaxHurtTime(int time) { - entity.maxHurtResistantTime = time; - } + public void setMaxHurtTime(int time) { + entity.maxHurtResistantTime = time; + } - public int setMaxHurtTime() { - return entity.maxHurtResistantTime; - } + public int setMaxHurtTime() { + return entity.maxHurtResistantTime; + } - public double getMaxHealth(){ - return entity.getEntityAttribute(SharedMonsterAttributes.maxHealth).getAttributeValue(); - } + public double getMaxHealth() { + return entity.getEntityAttribute(SharedMonsterAttributes.maxHealth).getAttributeValue(); + } - public double getFollowRange() { - return entity.getEntityAttribute(SharedMonsterAttributes.followRange).getAttributeValue(); - } + public double getFollowRange() { + return entity.getEntityAttribute(SharedMonsterAttributes.followRange).getAttributeValue(); + } - public double getKnockbackResistance() { - return entity.getEntityAttribute(SharedMonsterAttributes.knockbackResistance).getAttributeValue(); - } + public double getKnockbackResistance() { + return entity.getEntityAttribute(SharedMonsterAttributes.knockbackResistance).getAttributeValue(); + } - public double getSpeed() { - return entity.getEntityAttribute(SharedMonsterAttributes.movementSpeed).getAttributeValue(); - } + public double getSpeed() { + return entity.getEntityAttribute(SharedMonsterAttributes.movementSpeed).getAttributeValue(); + } - public double getMeleeStrength() { - return entity.getEntityAttribute(SharedMonsterAttributes.attackDamage).getAttributeValue(); - } + public double getMeleeStrength() { + return entity.getEntityAttribute(SharedMonsterAttributes.attackDamage).getAttributeValue(); + } - public void setMaxHealth(double health){ - entity.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(health); - } + public void setMaxHealth(double health) { + entity.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(health); + } - public void setFollowRange(double range) { - entity.getEntityAttribute(SharedMonsterAttributes.followRange).setBaseValue(range); - } + public void setFollowRange(double range) { + entity.getEntityAttribute(SharedMonsterAttributes.followRange).setBaseValue(range); + } - public void setKnockbackResistance(double knockbackResistance) { - entity.getEntityAttribute(SharedMonsterAttributes.knockbackResistance).setBaseValue(knockbackResistance); - } + public void setKnockbackResistance(double knockbackResistance) { + entity.getEntityAttribute(SharedMonsterAttributes.knockbackResistance).setBaseValue(knockbackResistance); + } - public void setSpeed(double speed) { - entity.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(speed); - } + public void setSpeed(double speed) { + entity.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(speed); + } - public void setMeleeStrength(double attackDamage) { - entity.getEntityAttribute(SharedMonsterAttributes.attackDamage).setBaseValue(attackDamage); - } + public void setMeleeStrength(double attackDamage) { + entity.getEntityAttribute(SharedMonsterAttributes.attackDamage).setBaseValue(attackDamage); + } - /** - * @return Whether or not this entity is attacking something - */ - public boolean isAttacking(){ - return entity.getAITarget() != null; - } + /** + * @return Whether or not this entity is attacking something + */ + public boolean isAttacking() { + return entity.getAITarget() != null; + } - /** - * @param living Entity which this entity will attack - */ - public void setAttackTarget(IEntityLivingBase living){ - if(living == null) - entity.setRevengeTarget(null); - else - entity.setRevengeTarget(living.getMCEntity()); - } + /** + * @param living Entity which this entity will attack + */ + public void setAttackTarget(IEntityLivingBase living) { + if (living == null) + entity.setRevengeTarget(null); + else + entity.setRevengeTarget(living.getMCEntity()); + } - /** - * @return The entity which this entity is attacking - */ - public IEntityLivingBase getAttackTarget(){ - return (IEntityLivingBase)NpcAPI.Instance().getIEntity(entity.getAITarget()); - } + /** + * @return The entity which this entity is attacking + */ + public IEntityLivingBase getAttackTarget() { + return (IEntityLivingBase) NpcAPI.Instance().getIEntity(entity.getAITarget()); + } - public int getAttackTargetTime() { - return this.entity.func_142015_aE(); - } + public int getAttackTargetTime() { + return this.entity.func_142015_aE(); + } - public void setLastAttacker(IEntity p_130011_1_) { - this.entity.setLastAttacker(p_130011_1_.getMCEntity()); - } + public void setLastAttacker(IEntity p_130011_1_) { + this.entity.setLastAttacker(p_130011_1_.getMCEntity()); + } - public IEntity getLastAttacker() { - return NpcAPI.Instance().getIEntity(this.entity.getLastAttacker()); - } + public IEntity getLastAttacker() { + return NpcAPI.Instance().getIEntity(this.entity.getLastAttacker()); + } - public int getLastAttackerTime() - { - return this.entity.getLastAttackerTime(); - } + public int getLastAttackerTime() { + return this.entity.getLastAttackerTime(); + } - public boolean canBreatheUnderwater() { - return this.entity.canBreatheUnderwater(); - } - - @Override - public int getType(){ - return EntityType.LIVING; - } - - - @Override - public boolean typeOf(int type){ - return type == EntityType.LIVING || super.typeOf(type); - } - /** - * @param entity Entity to check - * @return Whether or not this entity can see the given entity - */ - public boolean canSeeEntity(IEntity entity){ - return this.entity.canEntityBeSeen(entity.getMCEntity()); - } - - public IPos getLookVector() { - Vec3 lookVec = entity.getLookVec(); - return NpcAPI.Instance().getIPos(lookVec.xCoord,lookVec.yCoord,lookVec.zCoord); - } - - public IBlock getLookingAtBlock(int maxDistance, boolean stopOnBlock, boolean stopOnLiquid, boolean stopOnCollision) { - return NpcAPI.Instance().getIBlock(getWorld(),getLookingAtPos(maxDistance, stopOnBlock, stopOnLiquid, stopOnCollision)); - } - - public IBlock getLookingAtBlock(int maxDistance) { - return getLookingAtBlock(maxDistance, true, false, false); - } - - public IPos getLookingAtPos(int maxDistance, boolean stopOnBlock, boolean stopOnLiquid, boolean stopOnCollision) { - Vec3 lookVec = entity.getLookVec(); - return getWorld().rayCastPos( - new double[] {entity.posX, entity.posY + entity.getEyeHeight(), entity.posZ}, - new double[] {lookVec.xCoord, lookVec.yCoord, lookVec.zCoord}, - maxDistance, stopOnBlock, stopOnLiquid, stopOnCollision); - } - - public IPos getLookingAtPos(int maxDistance) { - return getLookingAtPos(maxDistance, true, false, false); - } - - public IEntity[] getLookingAtEntities(IEntity[] ignoreEntities, int maxDistance, double offset, double range, boolean stopOnBlock, boolean stopOnLiquid, boolean stopOnCollision) { - Vec3 lookVec = entity.getLookVec(); - double[] startPos = new double[] {entity.posX, entity.posY+entity.getEyeHeight(), entity.posZ}; - double[] lookVector = new double[] {lookVec.xCoord, lookVec.yCoord, lookVec.zCoord}; - - if (ignoreEntities == null) { - ignoreEntities = new IEntity[0]; - } - ArrayList entities = new ArrayList<>(); - entities.add(this); - Collections.addAll(entities, ignoreEntities); - - return getWorld().rayCastEntities(entities.toArray(new IEntity[0]),startPos,lookVector,maxDistance,offset,range,stopOnBlock,stopOnLiquid,stopOnCollision); - } - - public IEntity[] getLookingAtEntities(int maxDistance, double offset, double range, boolean stopOnBlock, boolean stopOnLiquid, boolean stopOnCollision) { - return this.getLookingAtEntities(null,maxDistance,offset,range,stopOnBlock,stopOnLiquid,stopOnCollision); - } - - public IEntity[] getLookingAtEntities(int maxDistance, double offset, double range) { - return getLookingAtEntities(maxDistance,offset,range,true,false,true); - } - - /** - * Expert use only - * @return Returns the minecraft entity object - */ - public T getMCEntity(){ - return entity; - } - - public T getMinecraftEntity(){ - return getMCEntity(); - } + public boolean canBreatheUnderwater() { + return this.entity.canBreatheUnderwater(); + } @Override - public float getRotation(){ + public int getType() { + return EntityType.LIVING; + } + + + @Override + public boolean typeOf(int type) { + return type == EntityType.LIVING || super.typeOf(type); + } + + /** + * @param entity Entity to check + * @return Whether or not this entity can see the given entity + */ + public boolean canSeeEntity(IEntity entity) { + return this.entity.canEntityBeSeen(entity.getMCEntity()); + } + + public IPos getLookVector() { + Vec3 lookVec = entity.getLookVec(); + return NpcAPI.Instance().getIPos(lookVec.xCoord, lookVec.yCoord, lookVec.zCoord); + } + + public IBlock getLookingAtBlock(int maxDistance, boolean stopOnBlock, boolean stopOnLiquid, boolean stopOnCollision) { + return NpcAPI.Instance().getIBlock(getWorld(), getLookingAtPos(maxDistance, stopOnBlock, stopOnLiquid, stopOnCollision)); + } + + public IBlock getLookingAtBlock(int maxDistance) { + return getLookingAtBlock(maxDistance, true, false, false); + } + + public IPos getLookingAtPos(int maxDistance, boolean stopOnBlock, boolean stopOnLiquid, boolean stopOnCollision) { + Vec3 lookVec = entity.getLookVec(); + return getWorld().rayCastPos( + new double[]{entity.posX, entity.posY + entity.getEyeHeight(), entity.posZ}, + new double[]{lookVec.xCoord, lookVec.yCoord, lookVec.zCoord}, + maxDistance, stopOnBlock, stopOnLiquid, stopOnCollision); + } + + public IPos getLookingAtPos(int maxDistance) { + return getLookingAtPos(maxDistance, true, false, false); + } + + public IEntity[] getLookingAtEntities(IEntity[] ignoreEntities, int maxDistance, double offset, double range, boolean stopOnBlock, boolean stopOnLiquid, boolean stopOnCollision) { + Vec3 lookVec = entity.getLookVec(); + double[] startPos = new double[]{entity.posX, entity.posY + entity.getEyeHeight(), entity.posZ}; + double[] lookVector = new double[]{lookVec.xCoord, lookVec.yCoord, lookVec.zCoord}; + + if (ignoreEntities == null) { + ignoreEntities = new IEntity[0]; + } + ArrayList entities = new ArrayList<>(); + entities.add(this); + Collections.addAll(entities, ignoreEntities); + + return getWorld().rayCastEntities(entities.toArray(new IEntity[0]), startPos, lookVector, maxDistance, offset, range, stopOnBlock, stopOnLiquid, stopOnCollision); + } + + public IEntity[] getLookingAtEntities(int maxDistance, double offset, double range, boolean stopOnBlock, boolean stopOnLiquid, boolean stopOnCollision) { + return this.getLookingAtEntities(null, maxDistance, offset, range, stopOnBlock, stopOnLiquid, stopOnCollision); + } + + public IEntity[] getLookingAtEntities(int maxDistance, double offset, double range) { + return getLookingAtEntities(maxDistance, offset, range, true, false, true); + } + + /** + * Expert use only + * + * @return Returns the minecraft entity object + */ + public T getMCEntity() { + return entity; + } + + public T getMinecraftEntity() { + return getMCEntity(); + } + + @Override + public float getRotation() { return entity.renderYawOffset; } @Override - public void setRotation(float rotation){ + public void setRotation(float rotation) { entity.renderYawOffset = rotation; } - /** - * Makes the entity swing its hand - */ - public void swingHand(){ - entity.swingItem(); - } + /** + * Makes the entity swing its hand + */ + public void swingHand() { + entity.swingItem(); + } - /** - * Works the same as the /effect command - * @param effect - * @param duration The duration in seconds - * @param strength The amplifier of the potion effect - * @param hideParticles Whether or not you want to hide potion particles - */ - public void addPotionEffect(int effect, int duration, int strength, boolean hideParticles){ + /** + * Works the same as the /effect command + * + * @param effect + * @param duration The duration in seconds + * @param strength The amplifier of the potion effect + * @param hideParticles Whether or not you want to hide potion particles + */ + public void addPotionEffect(int effect, int duration, int strength, boolean hideParticles) { if (effect < 0 || effect >= Potion.potionTypes.length || Potion.potionTypes[effect] == null) - return; + return; - if(strength < 0) - strength = 0; + if (strength < 0) + strength = 0; - if(duration < 0) - duration = 0; + if (duration < 0) + duration = 0; - if(!Potion.potionTypes[effect].isInstant()) - duration *= 20; + if (!Potion.potionTypes[effect].isInstant()) + duration *= 20; - if(duration == 0) - entity.removePotionEffect(effect); - else - entity.addPotionEffect(new PotionEffect(effect, duration, strength)); - //TODO in 1.8 add hideParticles option - } + if (duration == 0) + entity.removePotionEffect(effect); + else + entity.addPotionEffect(new PotionEffect(effect, duration, strength)); + //TODO in 1.8 add hideParticles option + } - /** - * Clears all potion effects - */ - public void clearPotionEffects(){ - entity.clearActivePotions(); - } + /** + * Clears all potion effects + */ + public void clearPotionEffects() { + entity.clearActivePotions(); + } - /** - * @since 1.7.10c - * @param effect Potion effect to check - * @return Returns -1 if its not active. Otherwise returns the strenght of the potion - */ - public int getPotionEffect(int effect){ - PotionEffect pf = entity.getActivePotionEffect(Potion.potionTypes[effect]); - if(pf == null) - return -1; - return pf.getAmplifier(); - } + /** + * @param effect Potion effect to check + * @return Returns -1 if its not active. Otherwise returns the strenght of the potion + * @since 1.7.10c + */ + public int getPotionEffect(int effect) { + PotionEffect pf = entity.getActivePotionEffect(Potion.potionTypes[effect]); + if (pf == null) + return -1; + return pf.getAmplifier(); + } - /** - * Note not all Living Entities support this - * @since 1.7.10c - * @return The item the entity is holding - */ - public IItemStack getHeldItem(){ - return NpcAPI.Instance().getIItemStack(entity.getHeldItem()); - } + /** + * Note not all Living Entities support this + * + * @return The item the entity is holding + * @since 1.7.10c + */ + public IItemStack getHeldItem() { + return NpcAPI.Instance().getIItemStack(entity.getHeldItem()); + } - /** - * Note not all Living Entities support this - * @since 1.7.10c - * @param item The item to be set - */ - public void setHeldItem(IItemStack item){ - entity.setCurrentItemOrArmor(0, item == null?null:item.getMCItemStack()); - } + /** + * Note not all Living Entities support this + * + * @param item The item to be set + * @since 1.7.10c + */ + public void setHeldItem(IItemStack item) { + entity.setCurrentItemOrArmor(0, item == null ? null : item.getMCItemStack()); + } - /** - * Note not all Living Entities support this - * @param slot Slot of what armor piece to get, 0:boots, 1:pants, 2:body, 3:head - * @return The item in the given slot - */ - public IItemStack getArmor(int slot){ - return NpcAPI.Instance().getIItemStack(entity.getEquipmentInSlot(slot + 1)); - } + /** + * Note not all Living Entities support this + * + * @param slot Slot of what armor piece to get, 0:boots, 1:pants, 2:body, 3:head + * @return The item in the given slot + */ + public IItemStack getArmor(int slot) { + return NpcAPI.Instance().getIItemStack(entity.getEquipmentInSlot(slot + 1)); + } - /** - * Note not all Living Entities support this - * @since 1.7.10c - * @param slot Slot of what armor piece to set, 0:boots, 1:pants, 2:body, 3:head - * @param item Item to be set - */ - public void setArmor(int slot, IItemStack item){ - entity.setCurrentItemOrArmor(slot + 1, item == null?null:item.getMCItemStack()); - } + /** + * Note not all Living Entities support this + * + * @param slot Slot of what armor piece to set, 0:boots, 1:pants, 2:body, 3:head + * @param item Item to be set + * @since 1.7.10c + */ + public void setArmor(int slot, IItemStack item) { + entity.setCurrentItemOrArmor(slot + 1, item == null ? null : item.getMCItemStack()); + } - public boolean isChild() { - return this.entity.isChild(); - } + public boolean isChild() { + return this.entity.isChild(); + } - public void renderBrokenItemStack(IItemStack itemStack) - { - this.entity.renderBrokenItemStack(itemStack.getMCItemStack()); - } + public void renderBrokenItemStack(IItemStack itemStack) { + this.entity.renderBrokenItemStack(itemStack.getMCItemStack()); + } - public boolean isOnLadder() - { - return this.entity.isOnLadder(); - } + public boolean isOnLadder() { + return this.entity.isOnLadder(); + } - public int getTotalArmorValue() - { - return this.entity.getTotalArmorValue(); - } + public int getTotalArmorValue() { + return this.entity.getTotalArmorValue(); + } - public int getArrowCountInEntity() { - return this.entity.getArrowCountInEntity(); - } + public int getArrowCountInEntity() { + return this.entity.getArrowCountInEntity(); + } - public void setArrowCountInEntity(int count) - { - this.entity.setArrowCountInEntity(count); - } + public void setArrowCountInEntity(int count) { + this.entity.setArrowCountInEntity(count); + } - public void dismountEntity(IEntity entity) { - this.entity.dismountEntity(entity.getMCEntity()); - } + public void dismountEntity(IEntity entity) { + this.entity.dismountEntity(entity.getMCEntity()); + } - public void setAIMoveSpeed(float speed) - { - this.entity.setAIMoveSpeed(speed); - } + public void setAIMoveSpeed(float speed) { + this.entity.setAIMoveSpeed(speed); + } - public float getAIMoveSpeed() { - return this.entity.getAIMoveSpeed(); - } + public float getAIMoveSpeed() { + return this.entity.getAIMoveSpeed(); + } - public void setAbsorptionAmount(float amount) - { - this.entity.setAbsorptionAmount(amount); - } + public void setAbsorptionAmount(float amount) { + this.entity.setAbsorptionAmount(amount); + } - public float getAbsorptionAmount() { - return this.entity.getAbsorptionAmount(); - } + public float getAbsorptionAmount() { + return this.entity.getAbsorptionAmount(); + } } diff --git a/src/main/java/noppes/npcs/scripted/entity/ScriptMonster.java b/src/main/java/noppes/npcs/scripted/entity/ScriptMonster.java index 5856cbc08..e01b6c86c 100644 --- a/src/main/java/noppes/npcs/scripted/entity/ScriptMonster.java +++ b/src/main/java/noppes/npcs/scripted/entity/ScriptMonster.java @@ -6,18 +6,18 @@ import noppes.npcs.scripted.constants.EntityType; public class ScriptMonster extends ScriptLiving implements IMonster { - public ScriptMonster(T entity) { - super(entity); - } - - @Override - public int getType(){ - return EntityType.MONSTER; - } + public ScriptMonster(T entity) { + super(entity); + } - @Override - public boolean typeOf(int type){ - return type == EntityType.MONSTER?true:super.typeOf(type); - } + @Override + public int getType() { + return EntityType.MONSTER; + } + + @Override + public boolean typeOf(int type) { + return type == EntityType.MONSTER ? true : super.typeOf(type); + } } diff --git a/src/main/java/noppes/npcs/scripted/entity/ScriptNpc.java b/src/main/java/noppes/npcs/scripted/entity/ScriptNpc.java index a64c626c4..85830225b 100644 --- a/src/main/java/noppes/npcs/scripted/entity/ScriptNpc.java +++ b/src/main/java/noppes/npcs/scripted/entity/ScriptNpc.java @@ -32,1351 +32,1370 @@ import java.util.ArrayList; import java.util.UUID; public class ScriptNpc extends ScriptLiving implements ICustomNpc { - public EntityNPCInterface npc; + public EntityNPCInterface npc; - public ScriptNpc(T npc){ - super(npc); - this.npc = npc; - } + public ScriptNpc(T npc) { + super(npc); + this.npc = npc; + } - /** - * @return Returns the current npcs size - */ - public int getSize(){ - return npc.display.modelSize; - } + /** + * @return Returns the current npcs size + */ + public int getSize() { + return npc.display.modelSize; + } - /** - * @param size The size of the npc. Default is 5 - */ - public void setSize(int size){ - if(size < 1) - size = 1; - if(size > ConfigMain.NpcSizeLimit) - size = ConfigMain.NpcSizeLimit; + /** + * @param size The size of the npc. Default is 5 + */ + public void setSize(int size) { + if (size < 1) + size = 1; + if (size > ConfigMain.NpcSizeLimit) + size = ConfigMain.NpcSizeLimit; - npc.display.modelSize = size; - npc.script.clientNeedsUpdate = true; - } + npc.display.modelSize = size; + npc.script.clientNeedsUpdate = true; + } - /** - * @return Returns the current npcs modelType of the NPC - */ - public int getModelType(){ - return npc.display.modelType; - } + /** + * @return Returns the current npcs modelType of the NPC + */ + public int getModelType() { + return npc.display.modelType; + } - /** - * @param modelType The modelType of the NPC. 0: Steve, 1: Steve64, 2: Alex - */ - public void setModelType(int modelType){ - if(modelType > 2) - modelType = 2; - else if(modelType < 0) - modelType = 0; - npc.display.modelType = modelType; - npc.script.clientNeedsUpdate = true; - } + /** + * @param modelType The modelType of the NPC. 0: Steve, 1: Steve64, 2: Alex + */ + public void setModelType(int modelType) { + if (modelType > 2) + modelType = 2; + else if (modelType < 0) + modelType = 0; + npc.display.modelType = modelType; + npc.script.clientNeedsUpdate = true; + } - /** - * @return The npcs name - */ - public String getName(){ - return npc.display.name; - } + /** + * @return The npcs name + */ + public String getName() { + return npc.display.name; + } - public void setRotation(float rotationYaw, float rotationPitch) { - this.setRotation(rotationYaw); - npc.rotationPitch = rotationPitch; - } + public void setRotation(float rotationYaw, float rotationPitch) { + this.setRotation(rotationYaw); + npc.rotationPitch = rotationPitch; + } - public void setRotation(float rotation){ + public void setRotation(float rotation) { super.setRotation(rotation); int r = (int) rotation; - if(npc.ais.orientation != r) { + if (npc.ais.orientation != r) { npc.updateClient = true; npc.rotationYawHead = npc.rotationYaw = npc.renderYawOffset = npc.ais.orientation = r; npc.prevRenderYawOffset = r; npc.prevRotationYaw = r; npc.prevRotationYawHead = r; } - } + } - public void setRotationType(int rotationType){ - for (EnumStandingType e : EnumStandingType.values()) { - if (e.ordinal() == rotationType) { - npc.ais.standingType = e; - break; - } - } - } + public void setRotationType(int rotationType) { + for (EnumStandingType e : EnumStandingType.values()) { + if (e.ordinal() == rotationType) { + npc.ais.standingType = e; + break; + } + } + } - public int getRotationType(){ - return npc.ais.standingType.ordinal(); - } + public int getRotationType() { + return npc.ais.standingType.ordinal(); + } - /** - * @param movingType The moving type of the npc. 0 = standing, 1 = wandering, 2 = moving path - */ - public void setMovingType(int movingType){ - for(EnumMovingType e : EnumMovingType.values()) { - if (e.ordinal() == movingType) { - npc.ais.movingType = e; - break; - } - } - } + /** + * @param movingType The moving type of the npc. 0 = standing, 1 = wandering, 2 = moving path + */ + public void setMovingType(int movingType) { + for (EnumMovingType e : EnumMovingType.values()) { + if (e.ordinal() == movingType) { + npc.ais.movingType = e; + break; + } + } + } - /** - * @return The moving type of the npc. 0 = standing, 1 = wandering, 2 = moving path - */ - public int getMovingType(){ - return npc.ais.movingType.ordinal(); - } + /** + * @return The moving type of the npc. 0 = standing, 1 = wandering, 2 = moving path + */ + public int getMovingType() { + return npc.ais.movingType.ordinal(); + } - /** - * @param name The name of the npc - */ - public void setName(String name){ - npc.display.name = name; - npc.script.clientNeedsUpdate = true; - } + /** + * @param name The name of the npc + */ + public void setName(String name) { + npc.display.name = name; + npc.script.clientNeedsUpdate = true; + } - /** - * @since 1.7.10 - * @return The npcs title - */ - public String getTitle(){ - return npc.display.title; - } + /** + * @return The npcs title + * @since 1.7.10 + */ + public String getTitle() { + return npc.display.title; + } - /** - * @since 1.7.10 - * @param title The title of the npc - */ - public void setTitle(String title){ - npc.display.title = title; - npc.script.clientNeedsUpdate = true; - } + /** + * @param title The title of the npc + * @since 1.7.10 + */ + public void setTitle(String title) { + npc.display.title = title; + npc.script.clientNeedsUpdate = true; + } - /** - * @return The npcs texture - */ - public String getTexture(){ - return npc.display.texture; - } + /** + * @return The npcs texture + */ + public String getTexture() { + return npc.display.texture; + } - /** - * @param texture The texture of the npc - */ - public void setTexture(String texture){ - npc.display.texture = texture; - npc.script.clientNeedsUpdate = true; - } + /** + * @param texture The texture of the npc + */ + public void setTexture(String texture) { + npc.display.texture = texture; + npc.script.clientNeedsUpdate = true; + } - public IPos getHome() { - return NpcAPI.Instance().getIPos(npc.ais.startPos[0],npc.ais.startPos[1],npc.ais.startPos[2]); - } + public IPos getHome() { + return NpcAPI.Instance().getIPos(npc.ais.startPos[0], npc.ais.startPos[1], npc.ais.startPos[2]); + } - /** - * @return Home position x - */ - public int getHomeX(){ - return npc.getStartPos()[0]; - } + /** + * @return Home position x + */ + public int getHomeX() { + return npc.getStartPos()[0]; + } - /** - * @param x The home x position - */ - public void setHomeX(int x){ - npc.ais.startPos[0] = x; - } + /** + * @param x The home x position + */ + public void setHomeX(int x) { + npc.ais.startPos[0] = x; + } - /** - * @return Home position x - */ - public int getHomeY(){ - return npc.getStartPos()[1]; - } + /** + * @return Home position x + */ + public int getHomeY() { + return npc.getStartPos()[1]; + } - /** - * @param y The home y position - */ - public void setHomeY(int y){ - npc.ais.startPos[1] = y; - } + /** + * @param y The home y position + */ + public void setHomeY(int y) { + npc.ais.startPos[1] = y; + } - /** - * @return Home position x - */ - public int getHomeZ(){ - return npc.getStartPos()[2]; - } + /** + * @return Home position x + */ + public int getHomeZ() { + return npc.getStartPos()[2]; + } - /** - * @param z The home x position - */ - public void setHomeZ(int z){ - npc.ais.startPos[2] = z; - } + /** + * @param z The home x position + */ + public void setHomeZ(int z) { + npc.ais.startPos[2] = z; + } - /** - * @param x The home x position - * @param y The home y position - * @param z The home z position - */ - public void setHome(int x, int y, int z){ - npc.ais.startPos = new int[]{x, y, z}; - } + /** + * @param x The home x position + * @param y The home y position + * @param z The home z position + */ + public void setHome(int x, int y, int z) { + npc.ais.startPos = new int[]{x, y, z}; + } - public void setHome(IPos pos){ - npc.ais.startPos = new int[]{pos.getX(), pos.getY(), pos.getZ()}; - } + public void setHome(IPos pos) { + npc.ais.startPos = new int[]{pos.getX(), pos.getY(), pos.getZ()}; + } - /** - * @param health New max health - */ - public void setMaxHealth(double health){ - npc.stats.setMaxHealth(health); - npc.script.clientNeedsUpdate = true; - } + /** + * @param health New max health + */ + public void setMaxHealth(double health) { + npc.stats.setMaxHealth(health); + npc.script.clientNeedsUpdate = true; + } - /** - * @param bo Whether or not the npc will try to return to his home position - */ - public void setReturnToHome(boolean bo){ - npc.ais.returnToStart = bo; - } + /** + * @param bo Whether or not the npc will try to return to his home position + */ + public void setReturnToHome(boolean bo) { + npc.ais.returnToStart = bo; + } - /** - * @return Whether or not the npc returns home - */ - public boolean getReturnToHome(){ - return npc.ais.returnToStart; - } + /** + * @return Whether or not the npc returns home + */ + public boolean getReturnToHome() { + return npc.ais.returnToStart; + } - /** - * @return The faction of the npc - */ - public IFaction getFaction(){ - return FactionController.getInstance().get(this.npc.faction.id); - } + /** + * @return The faction of the npc + */ + public IFaction getFaction() { + return FactionController.getInstance().get(this.npc.faction.id); + } - /** - * @param id The id of the new faction - */ - public void setFaction(int id){ - npc.setFaction(id); - } + /** + * @param id The id of the new faction + */ + public void setFaction(int id) { + npc.setFaction(id); + } - public void setAttackFactions(boolean attackOtherFactions){ - npc.advanced.attackOtherFactions = attackOtherFactions; - } + public void setAttackFactions(boolean attackOtherFactions) { + npc.advanced.attackOtherFactions = attackOtherFactions; + } - public boolean getAttackFactions(){ - return npc.advanced.attackOtherFactions; - } + public boolean getAttackFactions() { + return npc.advanced.attackOtherFactions; + } - public void setDefendFaction(boolean defendFaction){ - npc.advanced.defendFaction = defendFaction; - } + public void setDefendFaction(boolean defendFaction) { + npc.advanced.defendFaction = defendFaction; + } - public boolean getDefendFaction(){ - return npc.advanced.defendFaction; - } + public boolean getDefendFaction() { + return npc.advanced.defendFaction; + } - @Override - public int getType(){ - return EntityType.NPC; - } + @Override + public int getType() { + return EntityType.NPC; + } - @Override - public boolean typeOf(int type){ - return type == EntityType.NPC?true:super.typeOf(type); - } + @Override + public boolean typeOf(int type) { + return type == EntityType.NPC ? true : super.typeOf(type); + } - /** - * @param target The targeted npc - * @param item The item you want to shoot - * @param accuracy Accuracy of the shot (0-100) - */ - public void shootItem(IEntityLivingBase target, IItemStack item, int accuracy){ - if(item == null) - return; - if(accuracy < 0) - accuracy = 0; - else if(accuracy > 100) - accuracy = 100; - npc.shoot(target.getMCEntity(), accuracy, item.getMCItemStack(), false); - } + /** + * @param target The targeted npc + * @param item The item you want to shoot + * @param accuracy Accuracy of the shot (0-100) + */ + public void shootItem(IEntityLivingBase target, IItemStack item, int accuracy) { + if (item == null) + return; + if (accuracy < 0) + accuracy = 0; + else if (accuracy > 100) + accuracy = 100; + npc.shoot(target.getMCEntity(), accuracy, item.getMCItemStack(), false); + } - public void setProjectilesKeepTerrain(boolean t) { - npc.stats.projectilesKeepTerrain = t; - } + public void setProjectilesKeepTerrain(boolean t) { + npc.stats.projectilesKeepTerrain = t; + } - public boolean getProjectilesKeepTerrain() { - return npc.stats.projectilesKeepTerrain; - } + public boolean getProjectilesKeepTerrain() { + return npc.stats.projectilesKeepTerrain; + } + /** + * @param message The message the npc will say + */ + public void say(String message) { + npc.saySurrounding(new Line(message)); + } - /** - * @param message The message the npc will say - */ - public void say(String message){ - npc.saySurrounding(new Line(message)); - } + /** + * @param message The message the npc will say + */ + public void say(IPlayer player, String message) { + if (player == null || message == null || message.isEmpty()) + return; + npc.say((EntityPlayer) player.getMCEntity(), new Line(message)); + } - /** - * @param message The message the npc will say - */ - public void say(IPlayer player, String message){ - if(player == null || message == null || message.isEmpty()) - return; - npc.say((EntityPlayer) player.getMCEntity(), new Line(message)); - } + public IDialog getDialog(int slot) { + return NpcAPI.Instance().getDialogs().get(this.getDialogId(slot)); + } - public IDialog getDialog(int slot) { - return NpcAPI.Instance().getDialogs().get(this.getDialogId(slot)); - } + public int getDialogId(int slot) { + if (npc.dialogs.containsKey(slot)) { + DialogOption option = npc.dialogs.get(slot); + if (option.hasDialog()) { + return option.dialogId; + } + } + return -1; + } - public int getDialogId(int slot) { - if (npc.dialogs.containsKey(slot)) { - DialogOption option = npc.dialogs.get(slot); - if (option.hasDialog()) { - return option.dialogId; - } - } - return -1; - } + public void setDialog(int slot, IDialog dialog) { + this.setDialog(slot, dialog.getId()); + } - public void setDialog(int slot, IDialog dialog) { - this.setDialog(slot, dialog.getId()); - } + public void setDialog(int slot, int dialogId) { + NoppesUtilServer.setNpcDialog(slot, dialogId, this.npc); + } - public void setDialog(int slot, int dialogId) { - NoppesUtilServer.setNpcDialog(slot,dialogId, this.npc); - } + public ILines getInteractLines() { + return this.npc.advanced.interactLines; + } - public ILines getInteractLines() { - return this.npc.advanced.interactLines; - } + public ILines getWorldLines() { + return this.npc.advanced.worldLines; + } - public ILines getWorldLines() { - return this.npc.advanced.worldLines; - } + public ILines getAttackLines() { + return this.npc.advanced.attackLines; + } - public ILines getAttackLines() { - return this.npc.advanced.attackLines; - } + public ILines getKilledLines() { + return this.npc.advanced.killedLines; + } - public ILines getKilledLines() { - return this.npc.advanced.killedLines; - } + public ILines getKillLines() { + return this.npc.advanced.killLines; + } - public ILines getKillLines() { - return this.npc.advanced.killLines; - } + /** + * Kill the npc, doesnt't despawn it + */ + public void kill() { + npc.setDead(); + } - /** - * Kill the npc, doesnt't despawn it - */ - public void kill(){ - npc.setDead(); - } + /** + * Basically completely resets the npc. This will also call the Init script + */ + public void reset() { + npc.reset(); + } - /** - * Basically completely resets the npc. This will also call the Init script - */ - public void reset(){ - npc.reset(); - } + public IAnimationData getAnimationData() { + return this.npc.display.animationData; + } - public IAnimationData getAnimationData() { - return this.npc.display.animationData; - } + /** + * @return Returns the npcs current role + */ + public IRole getRole() { + if (npc.advanced.role == EnumRoleType.Bank) + return new ScriptRoleBank(npc); + else if (npc.advanced.role == EnumRoleType.Follower) + return new ScriptRoleFollower(npc); + else if (npc.advanced.role == EnumRoleType.Postman) + return new ScriptRoleMailman(npc); + else if (npc.advanced.role == EnumRoleType.Trader) + return new ScriptRoleTrader(npc); + else if (npc.advanced.role == EnumRoleType.Transporter) + return new ScriptRoleTransporter(npc); + else if (npc.advanced.role == EnumRoleType.Companion) + return new ScriptRoleCompanion(npc); + return new ScriptRoleInterface(npc); + } - /** - * @return Returns the npcs current role - */ - public IRole getRole(){ - if(npc.advanced.role == EnumRoleType.Bank) - return new ScriptRoleBank(npc); - else if(npc.advanced.role == EnumRoleType.Follower) - return new ScriptRoleFollower(npc); - else if(npc.advanced.role == EnumRoleType.Postman) - return new ScriptRoleMailman(npc); - else if(npc.advanced.role == EnumRoleType.Trader) - return new ScriptRoleTrader(npc); - else if(npc.advanced.role == EnumRoleType.Transporter) - return new ScriptRoleTransporter(npc); - else if(npc.advanced.role == EnumRoleType.Companion) - return new ScriptRoleCompanion(npc); - return new ScriptRoleInterface(npc); - } + public void setRole(int role) { + for (EnumRoleType e : EnumRoleType.values()) { + if (e.ordinal() == role) { + npc.advanced.role = e; + npc.advanced.setRole(role); + break; + } + } + } - public void setRole(int role){ - for (EnumRoleType e : EnumRoleType.values()) { - if (e.ordinal() == role) { - npc.advanced.role = e; - npc.advanced.setRole(role); - break; - } - } - } + /** + * @return Returns the npcs current job + */ + public IJob getJob() { + if (npc.advanced.job == EnumJobType.Bard) + return new ScriptJobBard(npc); + else if (npc.advanced.job == EnumJobType.Conversation) + return new ScriptJobConversation(npc); + else if (npc.advanced.job == EnumJobType.Follower) + return new ScriptJobFollower(npc); + else if (npc.advanced.job == EnumJobType.Guard) + return new ScriptJobGuard(npc); + else if (npc.advanced.job == EnumJobType.Healer) + return new ScriptJobHealer(npc); + else if (npc.advanced.job == EnumJobType.ItemGiver) + return new ScriptJobItemGiver(npc); + else if (npc.advanced.job == EnumJobType.Spawner) + return new ScriptJobSpawner(npc); + return new ScriptJobInterface(npc); + } - /** - * @return Returns the npcs current job - */ - public IJob getJob(){ - if(npc.advanced.job == EnumJobType.Bard) - return new ScriptJobBard(npc); - else if(npc.advanced.job == EnumJobType.Conversation) - return new ScriptJobConversation(npc); - else if(npc.advanced.job == EnumJobType.Follower) - return new ScriptJobFollower(npc); - else if(npc.advanced.job == EnumJobType.Guard) - return new ScriptJobGuard(npc); - else if(npc.advanced.job == EnumJobType.Healer) - return new ScriptJobHealer(npc); - else if(npc.advanced.job == EnumJobType.ItemGiver) - return new ScriptJobItemGiver(npc); - else if(npc.advanced.job == EnumJobType.Spawner) - return new ScriptJobSpawner(npc); - return new ScriptJobInterface(npc); - } + public void setJob(int job) { + for (EnumJobType e : EnumJobType.values()) { + if (e.ordinal() == job) { + npc.advanced.job = e; + npc.advanced.setJob(job); + break; + } + } + } - public void setJob(int job){ - for (EnumJobType e : EnumJobType.values()) { - if (e.ordinal() == job) { - npc.advanced.job = e; - npc.advanced.setJob(job); - break; - } - } - } + /** + * @return The item held in the right hand + */ + public IItemStack getRightItem() { + return NpcAPI.Instance().getIItemStack(npc.inventory.getWeapon()); + } - /** - * @return The item held in the right hand - */ - public IItemStack getRightItem(){ - return NpcAPI.Instance().getIItemStack(npc.inventory.getWeapon()); - } + /** + * @param item Item to be held in the right hand + */ + public void setRightItem(IItemStack item) { + if (item == null) + npc.inventory.setWeapon(null); + else + npc.inventory.setWeapon(item.getMCItemStack()); + npc.script.clientNeedsUpdate = true; + } - /** - * @param item Item to be held in the right hand - */ - public void setRightItem(IItemStack item){ - if(item == null) - npc.inventory.setWeapon(null); - else - npc.inventory.setWeapon(item.getMCItemStack()); - npc.script.clientNeedsUpdate = true; - } - - /** + /** * Was an old typo - * @return The item held in the left hand - */ - public IItemStack getLefttItem(){ - return NpcAPI.Instance().getIItemStack(npc.getOffHand()); - } + * + * @return The item held in the left hand + */ + public IItemStack getLefttItem() { + return NpcAPI.Instance().getIItemStack(npc.getOffHand()); + } /** * @return The item held in the left hand */ - public IItemStack getLeftItem(){ + public IItemStack getLeftItem() { return getLefttItem(); } - /** - * @param item Item to be held in the left hand - */ - public void setLeftItem(IItemStack item){ - if(item == null) - npc.inventory.setOffHand(null); - else - npc.inventory.setOffHand(item.getMCItemStack()); - //npc.script.clientNeedsUpdate = true; - } + /** + * @param item Item to be held in the left hand + */ + public void setLeftItem(IItemStack item) { + if (item == null) + npc.inventory.setOffHand(null); + else + npc.inventory.setOffHand(item.getMCItemStack()); + //npc.script.clientNeedsUpdate = true; + } - /** - * @return Returns the projectile the npc uses - */ - public IItemStack getProjectileItem(){ - return NpcAPI.Instance().getIItemStack(npc.inventory.getProjectile()); - } + /** + * @return Returns the projectile the npc uses + */ + public IItemStack getProjectileItem() { + return NpcAPI.Instance().getIItemStack(npc.inventory.getProjectile()); + } - /** - * @param item Item to be used as projectile - */ - public void setProjectileItem(IItemStack item){ - if(item == null) - npc.inventory.setProjectile(null); - else - npc.inventory.setProjectile(item.getMCItemStack()); - npc.script.aiNeedsUpdate = true; - } + /** + * @param item Item to be used as projectile + */ + public void setProjectileItem(IItemStack item) { + if (item == null) + npc.inventory.setProjectile(null); + else + npc.inventory.setProjectile(item.getMCItemStack()); + npc.script.aiNeedsUpdate = true; + } - public boolean canAimWhileShooting() { - return !npc.stats.aimWhileShooting; - } + public boolean canAimWhileShooting() { + return !npc.stats.aimWhileShooting; + } - public void aimWhileShooting(boolean aimWhileShooting) { - npc.stats.aimWhileShooting = aimWhileShooting; - } + public void aimWhileShooting(boolean aimWhileShooting) { + npc.stats.aimWhileShooting = aimWhileShooting; + } - public void setMinProjectileDelay(int minDelay){ - npc.stats.minDelay = minDelay; - } - public int getMinProjectileDelay(){ - return npc.stats.minDelay; - } + public void setMinProjectileDelay(int minDelay) { + npc.stats.minDelay = minDelay; + } - public void setMaxProjectileDelay(int maxDelay){ - npc.stats.maxDelay = maxDelay; - } - public int getMaxProjectileDelay(){ - return npc.stats.maxDelay; - } + public int getMinProjectileDelay() { + return npc.stats.minDelay; + } - public void setRangedRange(int rangedRange) { - npc.stats.rangedRange = rangedRange; - } - public int getRangedRange() { - return npc.stats.rangedRange; - } - public void setRangedRage(int rangedRage) { this.setRangedRange(rangedRage); } - public int getRangedRage() { return this.getRangedRange(); } + public void setMaxProjectileDelay(int maxDelay) { + npc.stats.maxDelay = maxDelay; + } - public void setFireRate(int rate) { - npc.stats.fireRate = rate; - } - public int getFireRate() { - return npc.stats.fireRate; - } + public int getMaxProjectileDelay() { + return npc.stats.maxDelay; + } - public void setBurstCount(int burstCount) { - npc.stats.burstCount = burstCount; - } - public int getBurstCount() { - return npc.stats.burstCount; - } + public void setRangedRange(int rangedRange) { + npc.stats.rangedRange = rangedRange; + } - public void setShotCount(int shotCount) { - npc.stats.shotCount = shotCount; - } - public int getShotCount() { - return npc.stats.shotCount; - } + public int getRangedRange() { + return npc.stats.rangedRange; + } - public void setAccuracy(int accuracy) { - npc.stats.accuracy = accuracy; - } - public int getAccuracy() { - return npc.stats.accuracy; - } + public void setRangedRage(int rangedRage) { + this.setRangedRange(rangedRage); + } - public String getFireSound() { - return npc.stats.fireSound; - } + public int getRangedRage() { + return this.getRangedRange(); + } - public void setFireSound(String fireSound) { - npc.stats.fireSound = fireSound; - } + public void setFireRate(int rate) { + npc.stats.fireRate = rate; + } - /** - * @param slot The armor slot to return. 0:head, 1:body, 2:legs, 3:boots - * @return Returns the worn armor in slot - */ - @Override - public IItemStack getArmor(int slot){ - return NpcAPI.Instance().getIItemStack(npc.inventory.armor.get(slot)); - } + public int getFireRate() { + return npc.stats.fireRate; + } - /** - * @param slot The armor slot to set. 0:head, 1:body, 2:legs, 3:boots - * @param item Item to be set as armor - */ - @Override - public void setArmor(int slot, IItemStack item){ - if(item == null) - npc.inventory.armor.put(slot, null); - else - npc.inventory.armor.put(slot, item.getMCItemStack()); + public void setBurstCount(int burstCount) { + npc.stats.burstCount = burstCount; + } - npc.script.clientNeedsUpdate = true; - } + public int getBurstCount() { + return npc.stats.burstCount; + } - /** - * - * @param slot The slot from the NPC's drop list to return (0-8) - * @return - */ - public IItemStack getLootItem(int slot) { - return NpcAPI.Instance().getIItemStack(npc.inventory.getStackInSlot(slot+7)); - } + public void setShotCount(int shotCount) { + npc.stats.shotCount = shotCount; + } - /** - * - * @param slot The slot from the NPC's drop list to change - * @param item The item the drop list slot will be changed to - */ - public void setLootItem(int slot, IItemStack item) { - if(item == null || item.getMCItemStack() == null){ - npc.inventory.setInventorySlotContents(slot+7, (ItemStack) null); + public int getShotCount() { + return npc.stats.shotCount; + } + + public void setAccuracy(int accuracy) { + npc.stats.accuracy = accuracy; + } + + public int getAccuracy() { + return npc.stats.accuracy; + } + + public String getFireSound() { + return npc.stats.fireSound; + } + + public void setFireSound(String fireSound) { + npc.stats.fireSound = fireSound; + } + + /** + * @param slot The armor slot to return. 0:head, 1:body, 2:legs, 3:boots + * @return Returns the worn armor in slot + */ + @Override + public IItemStack getArmor(int slot) { + return NpcAPI.Instance().getIItemStack(npc.inventory.armor.get(slot)); + } + + /** + * @param slot The armor slot to set. 0:head, 1:body, 2:legs, 3:boots + * @param item Item to be set as armor + */ + @Override + public void setArmor(int slot, IItemStack item) { + if (item == null) + npc.inventory.armor.put(slot, null); + else + npc.inventory.armor.put(slot, item.getMCItemStack()); + + npc.script.clientNeedsUpdate = true; + } + + /** + * @param slot The slot from the NPC's drop list to return (0-8) + * @return + */ + public IItemStack getLootItem(int slot) { + return NpcAPI.Instance().getIItemStack(npc.inventory.getStackInSlot(slot + 7)); + } + + /** + * @param slot The slot from the NPC's drop list to change + * @param item The item the drop list slot will be changed to + */ + public void setLootItem(int slot, IItemStack item) { + if (item == null || item.getMCItemStack() == null) { + npc.inventory.setInventorySlotContents(slot + 7, (ItemStack) null); } else { - npc.inventory.setInventorySlotContents(slot+7, item.getMCItemStack()); + npc.inventory.setInventorySlotContents(slot + 7, item.getMCItemStack()); } - } - - /** - * - * @param slot The slot from the NPC's drop list to return (0-8) - * @return The chance of dropping the item in this slot. Returns 100 if the slot is not found. - */ - public double getLootChance(int slot) { - if(!npc.inventory.dropchance.containsKey(slot)) - return 100; - - return npc.inventory.dropchance.get(slot); - } - - /** - * - * @param slot The slot from the NPC's drop list to change - * @param chance The new chance of dropping the item in this slot - */ - public void setLootChance(int slot, double chance) { - if(!npc.inventory.dropchance.containsKey(slot)) - return; - - if(chance < 0) - chance = 0; - if(chance > 100) - chance = 100; - - npc.inventory.dropchance.put(slot,chance); - } - - public int getLootMode(){ - return npc.inventory.lootMode; - } - - public void setLootMode(int lootMode){ - if(lootMode < 0 || lootMode > 1) - return; - npc.inventory.lootMode = lootMode; - } - - public void setMinLootXP(int lootXP) { - if(lootXP > npc.inventory.maxExp) - lootXP = npc.inventory.maxExp; - if(lootXP < 0) - lootXP = 0; - if(lootXP > Short.MAX_VALUE) - lootXP = Short.MAX_VALUE; - - npc.inventory.minExp = lootXP; - } - public void setMaxLootXP(int lootXP) { - if(lootXP < npc.inventory.minExp) - lootXP = npc.inventory.minExp; - if(lootXP < 0) - lootXP = 0; - if(lootXP > Short.MAX_VALUE) - lootXP = Short.MAX_VALUE; - - npc.inventory.maxExp = lootXP; - } - - public int getMinLootXP(){ - return npc.inventory.minExp; - } - public int getMaxLootXP(){ - return npc.inventory.maxExp; - } - - /** - * @param type The AnimationType - */ - public void setAnimation(int type){ - if(type == AnimationType.NORMAL) - npc.ais.animationType = EnumAnimation.NONE; - else if(type == AnimationType.SITTING) - npc.ais.animationType = EnumAnimation.SITTING; - else if(type == AnimationType.DANCING) - npc.ais.animationType = EnumAnimation.DANCING; - else if(type == AnimationType.SNEAKING) - npc.ais.animationType = EnumAnimation.SNEAKING; - else if(type == AnimationType.LYING) - npc.ais.animationType = EnumAnimation.LYING; - else if(type == AnimationType.HUGGING) - npc.ais.animationType = EnumAnimation.HUG; - } - - public void setTacticalVariant(int variant){ - if(variant > EnumNavType.values().length-1 || variant < 0) - return; - - npc.ais.tacticalVariant = EnumNavType.values()[variant]; - npc.ais.directLOS = EnumNavType.values()[variant] != EnumNavType.Stalk && npc.ais.directLOS; - } - - public int getTacticalVariant(){ - return npc.ais.tacticalVariant.ordinal(); - } - - public void setTacticalVariant(String variant){ - boolean found = false; - for(String s : EnumNavType.names()){ - if(s.equals(variant)) - found = true; - } - - if(!found) - return; - - npc.ais.tacticalVariant = EnumNavType.valueOf(variant); - } - - public String getTacticalVariantName(){ - return npc.ais.tacticalVariant.name(); - } - - public void setCombatPolicy(int variant){ - if(variant > EnumCombatPolicy.values().length-1 || variant < 0) - return; - - npc.ais.combatPolicy = EnumCombatPolicy.values()[variant]; - } - - public int getCombatPolicy(){ - return npc.ais.combatPolicy.ordinal(); - } - - public void setCombatPolicy(String variant){ - boolean found = false; - for(String s : EnumCombatPolicy.names()){ - if(s.equals(variant)) - found = true; - } - - if(!found) - return; - - npc.ais.combatPolicy = EnumCombatPolicy.valueOf(variant); - } - - public String getCombatPolicyName(){ - return npc.ais.combatPolicy.name(); - } - - public void setTacticalRadius(int tacticalRadius){ - if(tacticalRadius < 0) - tacticalRadius = 0; - - npc.ais.tacticalRadius = tacticalRadius; - } - - public int getTacticalRadius(){ - return npc.ais.tacticalRadius; - } - - public void setIgnoreCobweb(boolean ignore){ - npc.stats.ignoreCobweb = ignore; - } - - public boolean getIgnoreCobweb(){ - return npc.stats.ignoreCobweb; - } - - public void setOnFoundEnemy(int onAttack){ - if(onAttack < 0 || onAttack > 3) - return; - npc.ais.onAttack = onAttack; - } - - public int onFoundEnemy(){ - return npc.ais.onAttack; - } - - public void setShelterFrom(int shelterFrom){ - if(shelterFrom < 0 || shelterFrom > 2) - return; - npc.ais.findShelter = shelterFrom; - } - - public int getShelterFrom(){ - return npc.ais.findShelter; - } - - public boolean hasLivingAnimation() { - return !npc.display.disableLivingAnimation; - } - - public void setLivingAnimation(boolean livingAnimation) { - npc.display.disableLivingAnimation = !livingAnimation; - } - - /** - * @param type The visibility type of the npc, 0:visible, 1:invisible, 2:semi-visible - */ - public void setVisibleType(int type){ - npc.display.visible = type; - npc.script.clientNeedsUpdate = true; - } - - /** - * @return The visibility type of the npc, 0:visible, 1:invisible, 2:semi-visible - */ - public int getVisibleType(){ - return npc.display.visible; - } - - public void setVisibleTo(IPlayer player, boolean visible) { - UUID uuid = player.getMCEntity().getPersistentID(); - ArrayList uuidList = npc.display.invisibleToList; - if(uuidList != null) { - if (!uuidList.contains(uuid)) { - if (!visible) - npc.display.invisibleToList.add(uuid); - } else if (visible) { - npc.display.invisibleToList.remove(uuid); - } - } - npc.script.clientNeedsUpdate = true; - } - - public boolean isVisibleTo(IPlayer player) { - return !npc.scriptInvisibleToPlayer((EntityPlayer) player.getMCEntity()); - } - - /** - * @param type The visibility type of the name, 0:visible, 1:invisible, 2:when-attacking - */ - public void setShowName(int type){ - npc.display.showName = type; - npc.script.clientNeedsUpdate = true; - } - - /** - * @return Returns the visibility type of the name, 0:visible, 1:invisible, 2:when-attacking - */ - public int getShowName(){ - return npc.display.showName; - } - - /** - * @return Returns the visiblity of the boss bar, 0:invisible, 1:visible, 2:when-attacking - */ - public int getShowBossBar(){ - return npc.display.showBossBar; - } - - /** - * @param type The visibility type of the boss bar, 0:invisible, 1:visible, 2:when-attacking - */ - public void setShowBossBar(int type){ - npc.display.showBossBar = (byte) type; - npc.script.clientNeedsUpdate = true; - } - - /** - * @return The melee strength - */ - public double getMeleeStrength(){ - return npc.stats.getAttackStrength(); - } - - /** - * @param strength The melee strength - */ - public void setMeleeStrength(double strength){ - npc.stats.setAttackStrength(strength); - } - - /** - * @return The melee speed - */ - public int getMeleeSpeed(){ - return npc.stats.attackSpeed; - } - - /** - * @param speed The melee speed - */ - public void setMeleeSpeed(int speed){ - npc.stats.attackSpeed = speed; - } - - /** - * @return The melee range - */ - public int getMeleeRange(){ - return npc.stats.attackRange; - } - - /** - * @param range The melee range - */ - public void setMeleeRange(int range){ - npc.stats.attackRange = range; - } - - /** - * @return The swing warmup time in ticks - */ - public int getSwingWarmup(){ - return npc.stats.swingWarmUp; - } - - /** - * @param ticks The amount of time before damage to swing arm - */ - public void setSwingWarmup(int ticks){ - npc.stats.swingWarmUp = ticks; - } - - /** - * @return The knockback strength - */ - public int getKnockback(){ - return npc.stats.knockback; - } - - /** - * @param knockback The melee range - */ - public void setKnockback(int knockback){ - npc.stats.knockback = knockback; - } - - /** - * @return The aggro range - */ - public int getAggroRange(){ - return npc.stats.aggroRange; - } - - /** - * @param aggroRange The new aggro range - */ - public void setAggroRange(int aggroRange){ - npc.stats.aggroRange = aggroRange; - } - - /** - * @return The ranged strength - */ - public float getRangedStrength(){ - return npc.stats.pDamage; - } - - /** - * @param strength The ranged strength - */ - public void setRangedStrength(float strength){ - npc.stats.pDamage = (float)(Math.floor(strength)); - } - - /** - * @return The ranged speed - */ - public int getRangedSpeed(){ - return npc.stats.pSpeed; - } - - /** - * @param speed The ranged speed - */ - public void setRangedSpeed(int speed){ - npc.stats.pSpeed = speed; - } - - /** - * @return The ranged burst count - */ - public int getRangedBurst(){ - return npc.stats.burstCount; - } - - /** - * @param count The ranged burst count - */ - public void setRangedBurst(int count){ - npc.stats.burstCount = count; - } - - public int getRespawnTime() { - return npc.stats.respawnTime; - } - - public void setRespawnTime(int time) { - npc.stats.respawnTime = time; - } - - public int getRespawnCycle() { - return npc.stats.spawnCycle; - } - - public void setRespawnCycle(int cycle) { - if(cycle < 0) - cycle = 0; - if(cycle > 3) - cycle = 3; - - npc.stats.spawnCycle = cycle; - } - - public boolean getHideKilledBody() { - return npc.stats.hideKilledBody; - } - - public void hideKilledBody(boolean hide) { - npc.stats.hideKilledBody = hide; - } - - public boolean naturallyDespawns() { - return npc.stats.canDespawn; - } - - public void setNaturallyDespawns(boolean canDespawn) { - npc.stats.canDespawn = canDespawn; - npc.stats.playerSetCanDespawn = canDespawn; - } - - public boolean spawnedFromSoulStone() { - return !npc.advanced.soulStonePlayerName.equals(""); - } - - public String getSoulStonePlayerName() { - return npc.advanced.soulStonePlayerName; - } - - public boolean getRefuseSoulStone() { - return npc.advanced.refuseSoulStone; - } - - public void setRefuseSoulStone(boolean refuse) { - npc.advanced.refuseSoulStone = refuse; - } - - public boolean isSoulStoneInit() { - return npc.advanced.soulStoneInit; - } - - public int getMinPointsToSoulStone() { - return npc.advanced.minFactionPointsToSoulStone; - } - - public void setMinPointsToSoulStone(int points) { - npc.advanced.minFactionPointsToSoulStone = points; - } - - public void giveItem(IPlayer player, IItemStack item){ - npc.givePlayerItem((EntityPlayer) player.getMCEntity(), item.getMCItemStack()); - } - - public void executeCommand(String command){ - NoppesUtilServer.runCommand(npc, npc.getCommandSenderName(), command, null); - } - - public IModelData getModelData() { - return npc instanceof EntityCustomNpc ? ((EntityCustomNpc) npc).modelData : null; - } - - public void setHeadScale(float x, float y, float z){ - if(npc instanceof EntityCustomNpc) { - ((EntityCustomNpc) this.npc).modelData.modelScale.head.scaleX = ValueUtil.clamp(x, 0.5f, 1.5f); - ((EntityCustomNpc) this.npc).modelData.modelScale.head.scaleY = ValueUtil.clamp(y, 0.5f, 1.5f); - ((EntityCustomNpc) this.npc).modelData.modelScale.head.scaleZ = ValueUtil.clamp(z, 0.5f, 1.5f); - - npc.script.clientNeedsUpdate = true; - } - } - - public void setBodyScale(float x, float y, float z){ - if(npc instanceof EntityCustomNpc) { - ((EntityCustomNpc) this.npc).modelData.modelScale.body.scaleX = ValueUtil.clamp(x, 0.5f, 1.5f); - ((EntityCustomNpc) this.npc).modelData.modelScale.body.scaleY = ValueUtil.clamp(y, 0.5f, 1.5f); - ((EntityCustomNpc) this.npc).modelData.modelScale.body.scaleZ = ValueUtil.clamp(z, 0.5f, 1.5f); - - npc.script.clientNeedsUpdate = true; - } - } - - public void setArmsScale(float x, float y, float z){ - if(npc instanceof EntityCustomNpc) { - ((EntityCustomNpc) this.npc).modelData.modelScale.arms.scaleX = ValueUtil.clamp(x, 0.5f, 1.5f); - ((EntityCustomNpc) this.npc).modelData.modelScale.arms.scaleY = ValueUtil.clamp(y, 0.5f, 1.5f); - ((EntityCustomNpc) this.npc).modelData.modelScale.arms.scaleZ = ValueUtil.clamp(z, 0.5f, 1.5f); - - npc.script.clientNeedsUpdate = true; - } - } - - public void setLegsScale(float x, float y, float z){ - if(npc instanceof EntityCustomNpc) { - ((EntityCustomNpc) this.npc).modelData.modelScale.legs.scaleX = ValueUtil.clamp(x, 0.5f, 1.5f); - ((EntityCustomNpc) this.npc).modelData.modelScale.legs.scaleY = ValueUtil.clamp(y, 0.5f, 1.5f); - ((EntityCustomNpc) this.npc).modelData.modelScale.legs.scaleZ = ValueUtil.clamp(z, 0.5f, 1.5f); - - npc.script.clientNeedsUpdate = true; - } - } + } + + /** + * @param slot The slot from the NPC's drop list to return (0-8) + * @return The chance of dropping the item in this slot. Returns 100 if the slot is not found. + */ + public double getLootChance(int slot) { + if (!npc.inventory.dropchance.containsKey(slot)) + return 100; + + return npc.inventory.dropchance.get(slot); + } + + /** + * @param slot The slot from the NPC's drop list to change + * @param chance The new chance of dropping the item in this slot + */ + public void setLootChance(int slot, double chance) { + if (!npc.inventory.dropchance.containsKey(slot)) + return; + + if (chance < 0) + chance = 0; + if (chance > 100) + chance = 100; + + npc.inventory.dropchance.put(slot, chance); + } + + public int getLootMode() { + return npc.inventory.lootMode; + } + + public void setLootMode(int lootMode) { + if (lootMode < 0 || lootMode > 1) + return; + npc.inventory.lootMode = lootMode; + } + + public void setMinLootXP(int lootXP) { + if (lootXP > npc.inventory.maxExp) + lootXP = npc.inventory.maxExp; + if (lootXP < 0) + lootXP = 0; + if (lootXP > Short.MAX_VALUE) + lootXP = Short.MAX_VALUE; + + npc.inventory.minExp = lootXP; + } + + public void setMaxLootXP(int lootXP) { + if (lootXP < npc.inventory.minExp) + lootXP = npc.inventory.minExp; + if (lootXP < 0) + lootXP = 0; + if (lootXP > Short.MAX_VALUE) + lootXP = Short.MAX_VALUE; + + npc.inventory.maxExp = lootXP; + } + + public int getMinLootXP() { + return npc.inventory.minExp; + } + + public int getMaxLootXP() { + return npc.inventory.maxExp; + } + + /** + * @param type The AnimationType + */ + public void setAnimation(int type) { + if (type == AnimationType.NORMAL) + npc.ais.animationType = EnumAnimation.NONE; + else if (type == AnimationType.SITTING) + npc.ais.animationType = EnumAnimation.SITTING; + else if (type == AnimationType.DANCING) + npc.ais.animationType = EnumAnimation.DANCING; + else if (type == AnimationType.SNEAKING) + npc.ais.animationType = EnumAnimation.SNEAKING; + else if (type == AnimationType.LYING) + npc.ais.animationType = EnumAnimation.LYING; + else if (type == AnimationType.HUGGING) + npc.ais.animationType = EnumAnimation.HUG; + } + + public void setTacticalVariant(int variant) { + if (variant > EnumNavType.values().length - 1 || variant < 0) + return; + + npc.ais.tacticalVariant = EnumNavType.values()[variant]; + npc.ais.directLOS = EnumNavType.values()[variant] != EnumNavType.Stalk && npc.ais.directLOS; + } + + public int getTacticalVariant() { + return npc.ais.tacticalVariant.ordinal(); + } + + public void setTacticalVariant(String variant) { + boolean found = false; + for (String s : EnumNavType.names()) { + if (s.equals(variant)) + found = true; + } + + if (!found) + return; + + npc.ais.tacticalVariant = EnumNavType.valueOf(variant); + } + + public String getTacticalVariantName() { + return npc.ais.tacticalVariant.name(); + } + + public void setCombatPolicy(int variant) { + if (variant > EnumCombatPolicy.values().length - 1 || variant < 0) + return; + + npc.ais.combatPolicy = EnumCombatPolicy.values()[variant]; + } + + public int getCombatPolicy() { + return npc.ais.combatPolicy.ordinal(); + } + + public void setCombatPolicy(String variant) { + boolean found = false; + for (String s : EnumCombatPolicy.names()) { + if (s.equals(variant)) + found = true; + } + + if (!found) + return; + + npc.ais.combatPolicy = EnumCombatPolicy.valueOf(variant); + } + + public String getCombatPolicyName() { + return npc.ais.combatPolicy.name(); + } + + public void setTacticalRadius(int tacticalRadius) { + if (tacticalRadius < 0) + tacticalRadius = 0; + + npc.ais.tacticalRadius = tacticalRadius; + } + + public int getTacticalRadius() { + return npc.ais.tacticalRadius; + } + + public void setIgnoreCobweb(boolean ignore) { + npc.stats.ignoreCobweb = ignore; + } + + public boolean getIgnoreCobweb() { + return npc.stats.ignoreCobweb; + } + + public void setOnFoundEnemy(int onAttack) { + if (onAttack < 0 || onAttack > 3) + return; + npc.ais.onAttack = onAttack; + } + + public int onFoundEnemy() { + return npc.ais.onAttack; + } + + public void setShelterFrom(int shelterFrom) { + if (shelterFrom < 0 || shelterFrom > 2) + return; + npc.ais.findShelter = shelterFrom; + } + + public int getShelterFrom() { + return npc.ais.findShelter; + } + + public boolean hasLivingAnimation() { + return !npc.display.disableLivingAnimation; + } + + public void setLivingAnimation(boolean livingAnimation) { + npc.display.disableLivingAnimation = !livingAnimation; + } + + /** + * @param type The visibility type of the npc, 0:visible, 1:invisible, 2:semi-visible + */ + public void setVisibleType(int type) { + npc.display.visible = type; + npc.script.clientNeedsUpdate = true; + } + + /** + * @return The visibility type of the npc, 0:visible, 1:invisible, 2:semi-visible + */ + public int getVisibleType() { + return npc.display.visible; + } + + public void setVisibleTo(IPlayer player, boolean visible) { + UUID uuid = player.getMCEntity().getPersistentID(); + ArrayList uuidList = npc.display.invisibleToList; + if (uuidList != null) { + if (!uuidList.contains(uuid)) { + if (!visible) + npc.display.invisibleToList.add(uuid); + } else if (visible) { + npc.display.invisibleToList.remove(uuid); + } + } + npc.script.clientNeedsUpdate = true; + } + + public boolean isVisibleTo(IPlayer player) { + return !npc.scriptInvisibleToPlayer((EntityPlayer) player.getMCEntity()); + } + + /** + * @param type The visibility type of the name, 0:visible, 1:invisible, 2:when-attacking + */ + public void setShowName(int type) { + npc.display.showName = type; + npc.script.clientNeedsUpdate = true; + } + + /** + * @return Returns the visibility type of the name, 0:visible, 1:invisible, 2:when-attacking + */ + public int getShowName() { + return npc.display.showName; + } + + /** + * @return Returns the visiblity of the boss bar, 0:invisible, 1:visible, 2:when-attacking + */ + public int getShowBossBar() { + return npc.display.showBossBar; + } + + /** + * @param type The visibility type of the boss bar, 0:invisible, 1:visible, 2:when-attacking + */ + public void setShowBossBar(int type) { + npc.display.showBossBar = (byte) type; + npc.script.clientNeedsUpdate = true; + } + + /** + * @return The melee strength + */ + public double getMeleeStrength() { + return npc.stats.getAttackStrength(); + } + + /** + * @param strength The melee strength + */ + public void setMeleeStrength(double strength) { + npc.stats.setAttackStrength(strength); + } + + /** + * @return The melee speed + */ + public int getMeleeSpeed() { + return npc.stats.attackSpeed; + } + + /** + * @param speed The melee speed + */ + public void setMeleeSpeed(int speed) { + npc.stats.attackSpeed = speed; + } + + /** + * @return The melee range + */ + public int getMeleeRange() { + return npc.stats.attackRange; + } + + /** + * @param range The melee range + */ + public void setMeleeRange(int range) { + npc.stats.attackRange = range; + } + + /** + * @return The swing warmup time in ticks + */ + public int getSwingWarmup() { + return npc.stats.swingWarmUp; + } + + /** + * @param ticks The amount of time before damage to swing arm + */ + public void setSwingWarmup(int ticks) { + npc.stats.swingWarmUp = ticks; + } + + /** + * @return The knockback strength + */ + public int getKnockback() { + return npc.stats.knockback; + } + + /** + * @param knockback The melee range + */ + public void setKnockback(int knockback) { + npc.stats.knockback = knockback; + } + + /** + * @return The aggro range + */ + public int getAggroRange() { + return npc.stats.aggroRange; + } + + /** + * @param aggroRange The new aggro range + */ + public void setAggroRange(int aggroRange) { + npc.stats.aggroRange = aggroRange; + } + + /** + * @return The ranged strength + */ + public float getRangedStrength() { + return npc.stats.pDamage; + } + + /** + * @param strength The ranged strength + */ + public void setRangedStrength(float strength) { + npc.stats.pDamage = (float) (Math.floor(strength)); + } + + /** + * @return The ranged speed + */ + public int getRangedSpeed() { + return npc.stats.pSpeed; + } + + /** + * @param speed The ranged speed + */ + public void setRangedSpeed(int speed) { + npc.stats.pSpeed = speed; + } + + /** + * @return The ranged burst count + */ + public int getRangedBurst() { + return npc.stats.burstCount; + } + + /** + * @param count The ranged burst count + */ + public void setRangedBurst(int count) { + npc.stats.burstCount = count; + } + + public int getRespawnTime() { + return npc.stats.respawnTime; + } + + public void setRespawnTime(int time) { + npc.stats.respawnTime = time; + } + + public int getRespawnCycle() { + return npc.stats.spawnCycle; + } + + public void setRespawnCycle(int cycle) { + if (cycle < 0) + cycle = 0; + if (cycle > 3) + cycle = 3; + + npc.stats.spawnCycle = cycle; + } + + public boolean getHideKilledBody() { + return npc.stats.hideKilledBody; + } + + public void hideKilledBody(boolean hide) { + npc.stats.hideKilledBody = hide; + } + + public boolean naturallyDespawns() { + return npc.stats.canDespawn; + } + + public void setNaturallyDespawns(boolean canDespawn) { + npc.stats.canDespawn = canDespawn; + npc.stats.playerSetCanDespawn = canDespawn; + } + + public boolean spawnedFromSoulStone() { + return !npc.advanced.soulStonePlayerName.equals(""); + } + + public String getSoulStonePlayerName() { + return npc.advanced.soulStonePlayerName; + } + + public boolean getRefuseSoulStone() { + return npc.advanced.refuseSoulStone; + } + + public void setRefuseSoulStone(boolean refuse) { + npc.advanced.refuseSoulStone = refuse; + } + + public boolean isSoulStoneInit() { + return npc.advanced.soulStoneInit; + } + + public int getMinPointsToSoulStone() { + return npc.advanced.minFactionPointsToSoulStone; + } + + public void setMinPointsToSoulStone(int points) { + npc.advanced.minFactionPointsToSoulStone = points; + } + + public void giveItem(IPlayer player, IItemStack item) { + npc.givePlayerItem((EntityPlayer) player.getMCEntity(), item.getMCItemStack()); + } + + public void executeCommand(String command) { + NoppesUtilServer.runCommand(npc, npc.getCommandSenderName(), command, null); + } + + public IModelData getModelData() { + return npc instanceof EntityCustomNpc ? ((EntityCustomNpc) npc).modelData : null; + } + + public void setHeadScale(float x, float y, float z) { + if (npc instanceof EntityCustomNpc) { + ((EntityCustomNpc) this.npc).modelData.modelScale.head.scaleX = ValueUtil.clamp(x, 0.5f, 1.5f); + ((EntityCustomNpc) this.npc).modelData.modelScale.head.scaleY = ValueUtil.clamp(y, 0.5f, 1.5f); + ((EntityCustomNpc) this.npc).modelData.modelScale.head.scaleZ = ValueUtil.clamp(z, 0.5f, 1.5f); + + npc.script.clientNeedsUpdate = true; + } + } + + public void setBodyScale(float x, float y, float z) { + if (npc instanceof EntityCustomNpc) { + ((EntityCustomNpc) this.npc).modelData.modelScale.body.scaleX = ValueUtil.clamp(x, 0.5f, 1.5f); + ((EntityCustomNpc) this.npc).modelData.modelScale.body.scaleY = ValueUtil.clamp(y, 0.5f, 1.5f); + ((EntityCustomNpc) this.npc).modelData.modelScale.body.scaleZ = ValueUtil.clamp(z, 0.5f, 1.5f); + + npc.script.clientNeedsUpdate = true; + } + } + + public void setArmsScale(float x, float y, float z) { + if (npc instanceof EntityCustomNpc) { + ((EntityCustomNpc) this.npc).modelData.modelScale.arms.scaleX = ValueUtil.clamp(x, 0.5f, 1.5f); + ((EntityCustomNpc) this.npc).modelData.modelScale.arms.scaleY = ValueUtil.clamp(y, 0.5f, 1.5f); + ((EntityCustomNpc) this.npc).modelData.modelScale.arms.scaleZ = ValueUtil.clamp(z, 0.5f, 1.5f); + + npc.script.clientNeedsUpdate = true; + } + } + + public void setLegsScale(float x, float y, float z) { + if (npc instanceof EntityCustomNpc) { + ((EntityCustomNpc) this.npc).modelData.modelScale.legs.scaleX = ValueUtil.clamp(x, 0.5f, 1.5f); + ((EntityCustomNpc) this.npc).modelData.modelScale.legs.scaleY = ValueUtil.clamp(y, 0.5f, 1.5f); + ((EntityCustomNpc) this.npc).modelData.modelScale.legs.scaleZ = ValueUtil.clamp(z, 0.5f, 1.5f); + + npc.script.clientNeedsUpdate = true; + } + } /** - * @since 1.7.10c * @param resistance Explosion resistance (0-2) default is 1 + * @since 1.7.10c */ - public void setExplosionResistance(float resistance){ - npc.stats.resistances.explosion = ValueUtil.clamp(resistance, 0, 2); - } + public void setExplosionResistance(float resistance) { + npc.stats.resistances.explosion = ValueUtil.clamp(resistance, 0, 2); + } /** - * @since 1.7.10c * @return Returns Explosion Resistance + * @since 1.7.10c */ - public float getExplosionResistance(){ - return npc.stats.resistances.explosion; - } + public float getExplosionResistance() { + return npc.stats.resistances.explosion; + } /** * @param resistance Melee resistance (0-2) default is 1 */ - public void setMeleeResistance(float resistance){ - npc.stats.resistances.playermelee = ValueUtil.clamp(resistance, 0, 2); - } + public void setMeleeResistance(float resistance) { + npc.stats.resistances.playermelee = ValueUtil.clamp(resistance, 0, 2); + } /** * @return Returns Melee Resistance */ - public float getMeleeResistance(){ - return npc.stats.resistances.playermelee; - } + public float getMeleeResistance() { + return npc.stats.resistances.playermelee; + } /** * @param resistance Arrow resistance (0-2) default is 1 */ - public void setArrowResistance(float resistance){ - npc.stats.resistances.arrow = ValueUtil.clamp(resistance, 0, 2); - } + public void setArrowResistance(float resistance) { + npc.stats.resistances.arrow = ValueUtil.clamp(resistance, 0, 2); + } /** * @return Returns Arrow Resistance */ - public float getArrowResistance(){ - return npc.stats.resistances.arrow; - } + public float getArrowResistance() { + return npc.stats.resistances.arrow; + } /** * @param resistance Knockback resistance (0-2) default is 1 */ - public void setKnockbackResistance(double resistance){ - npc.stats.resistances.knockback = ValueUtil.clamp((float) resistance, 0, 2); - } + public void setKnockbackResistance(double resistance) { + npc.stats.resistances.knockback = ValueUtil.clamp((float) resistance, 0, 2); + } /** * @return Returns Knockback Resistance */ - public double getKnockbackResistance(){ - return npc.stats.resistances.knockback; - } + public double getKnockbackResistance() { + return npc.stats.resistances.knockback; + } - /** - * @param type Retaliation type. 0:normal, 1:panic, 2:retreat, 3:nothing - */ - public void setRetaliateType(int type){ - if (type < 0) - type = 0; - if (type > 3) - type = 3; + /** + * @param type Retaliation type. 0:normal, 1:panic, 2:retreat, 3:nothing + */ + public void setRetaliateType(int type) { + if (type < 0) + type = 0; + if (type > 3) + type = 3; - npc.ais.onAttack = type; - npc.updateTasks(); - } + npc.ais.onAttack = type; + npc.updateTasks(); + } - /** - * @return Returns the combat health regen per second - */ - public float getCombatRegen(){ - return npc.stats.combatRegen; - } + /** + * @return Returns the combat health regen per second + */ + public float getCombatRegen() { + return npc.stats.combatRegen; + } - /** - * @param regen The combat health regen per second - */ - public void setCombatRegen(float regen){ - npc.stats.combatRegen = (float)(Math.floor(regen)); - } + /** + * @param regen The combat health regen per second + */ + public void setCombatRegen(float regen) { + npc.stats.combatRegen = (float) (Math.floor(regen)); + } - /** - * @return Returns the health regen per second when not in combat - */ - public float getHealthRegen(){ - return npc.stats.healthRegen; - } + /** + * @return Returns the health regen per second when not in combat + */ + public float getHealthRegen() { + return npc.stats.healthRegen; + } - /** - * @param regen The health regen per second when not in combat - */ - public void setHealthRegen(float regen){ - npc.stats.healthRegen = (float)(Math.floor(regen)); - } + /** + * @param regen The health regen per second when not in combat + */ + public void setHealthRegen(float regen) { + npc.stats.healthRegen = (float) (Math.floor(regen)); + } - public boolean getCanDrown() { - return npc.stats.drowningType > 0; - } - public void setCanDrown(boolean d) { - npc.stats.drowningType = d ? 1 : 0; - } + public boolean getCanDrown() { + return npc.stats.drowningType > 0; + } - public void setDrowningType(int type) { - if (type < 0) - type = 0; - if (type > 2) - type = 2; + public void setCanDrown(boolean d) { + npc.stats.drowningType = d ? 1 : 0; + } - npc.stats.drowningType = type; - } + public void setDrowningType(int type) { + if (type < 0) + type = 0; + if (type > 2) + type = 2; - public boolean canBreathe() { - return npc.canBreathe(); - } + npc.stats.drowningType = type; + } - @Override - public long getAge(){ - return npc.totalTicksAlive; - } + public boolean canBreathe() { + return npc.canBreathe(); + } - public ITimers getTimers() { - return ((EntityNPCInterface)this.npc).timers; - } + @Override + public long getAge() { + return npc.totalTicksAlive; + } - public void setFly(int fly){ - if(fly > 0) - fly = 1; - else fly = 0; + public ITimers getTimers() { + return ((EntityNPCInterface) this.npc).timers; + } - npc.ais.movementType = fly; - } + public void setFly(int fly) { + if (fly > 0) + fly = 1; + else fly = 0; - public boolean canFly(){ - return npc.ais.movementType == 1; - } + npc.ais.movementType = fly; + } - public void setFlySpeed(double flySpeed){ - if(flySpeed < 0.0D) - flySpeed = 0.0D; + public boolean canFly() { + return npc.ais.movementType == 1; + } - npc.ais.flySpeed = flySpeed; - } + public void setFlySpeed(double flySpeed) { + if (flySpeed < 0.0D) + flySpeed = 0.0D; - public double getFlySpeed(double flySpeed){ - return npc.ais.flySpeed; - } + npc.ais.flySpeed = flySpeed; + } - public void setFlyGravity(double flyGravity){ - if(flyGravity < 0.0D) - flyGravity = 0.0D; - if(flyGravity > 1.0D) - flyGravity = 1.0D; + public double getFlySpeed(double flySpeed) { + return npc.ais.flySpeed; + } - npc.ais.flyGravity = flyGravity; - } + public void setFlyGravity(double flyGravity) { + if (flyGravity < 0.0D) + flyGravity = 0.0D; + if (flyGravity > 1.0D) + flyGravity = 1.0D; - public double getFlyGravity(double flySpeed){ - return npc.ais.flyGravity; - } + npc.ais.flyGravity = flyGravity; + } - public void setFlyHeightLimit(int flyHeightLimit){ - if(flyHeightLimit < 0) - flyHeightLimit = 0; + public double getFlyGravity(double flySpeed) { + return npc.ais.flyGravity; + } - this.npc.ais.flyHeightLimit = flyHeightLimit; - } - public int getFlyHeightLimit(int flyHeightLimit){ - return this.npc.ais.flyHeightLimit; - } + public void setFlyHeightLimit(int flyHeightLimit) { + if (flyHeightLimit < 0) + flyHeightLimit = 0; - public void limitFlyHeight(boolean limit){ - this.npc.ais.hasFlyLimit = limit; - } - public boolean isFlyHeightLimited(boolean limit){ - return this.npc.ais.hasFlyLimit; - } + this.npc.ais.flyHeightLimit = flyHeightLimit; + } - public void setSpeed(double speed) { - npc.ais.setWalkingSpeed(speed); - } + public int getFlyHeightLimit(int flyHeightLimit) { + return this.npc.ais.flyHeightLimit; + } - public double getSpeed() { - return npc.ais.getWalkingSpeed(); - } + public void limitFlyHeight(boolean limit) { + this.npc.ais.hasFlyLimit = limit; + } - public void setSkinType(byte type) { - npc.display.skinType = type; - npc.script.clientNeedsUpdate = true; - } + public boolean isFlyHeightLimited(boolean limit) { + return this.npc.ais.hasFlyLimit; + } - public byte getSkinType() { - return npc.display.skinType; - } + public void setSpeed(double speed) { + npc.ais.setWalkingSpeed(speed); + } - public void setSkinUrl(String url){ - if(this.npc.display.url.equals(url)) - return; - this.npc.display.url = url; - npc.textureLocation = null; - if(npc.display.skinType < 2) + public double getSpeed() { + return npc.ais.getWalkingSpeed(); + } + + public void setSkinType(byte type) { + npc.display.skinType = type; + npc.script.clientNeedsUpdate = true; + } + + public byte getSkinType() { + return npc.display.skinType; + } + + public void setSkinUrl(String url) { + if (this.npc.display.url.equals(url)) + return; + this.npc.display.url = url; + npc.textureLocation = null; + if (npc.display.skinType < 2) npc.display.skinType = 2; - npc.script.clientNeedsUpdate = true; - } + npc.script.clientNeedsUpdate = true; + } - public String getSkinUrl() { - return this.npc.display.url; - } + public String getSkinUrl() { + return this.npc.display.url; + } - public void setCloakTexture(String cloakTexture) { - npc.display.cloakTexture = cloakTexture; - npc.script.clientNeedsUpdate = true; - } + public void setCloakTexture(String cloakTexture) { + npc.display.cloakTexture = cloakTexture; + npc.script.clientNeedsUpdate = true; + } - public String getCloakTexture() { - return npc.display.cloakTexture; - } + public String getCloakTexture() { + return npc.display.cloakTexture; + } - public void setOverlayTexture(String overlayTexture) { - if (this.getOverlays().size() >= ConfigMain.SkinOverlayLimit) { - return; - } + public void setOverlayTexture(String overlayTexture) { + if (this.getOverlays().size() >= ConfigMain.SkinOverlayLimit) { + return; + } - this.getOverlays().add(0, NpcAPI.Instance().createSkinOverlay(overlayTexture)); - npc.script.clientNeedsUpdate = true; - } + this.getOverlays().add(0, NpcAPI.Instance().createSkinOverlay(overlayTexture)); + npc.script.clientNeedsUpdate = true; + } - public String getOverlayTexture() { - if (!npc.display.skinOverlayData.overlayList.containsKey(0)) - return ""; + public String getOverlayTexture() { + if (!npc.display.skinOverlayData.overlayList.containsKey(0)) + return ""; - return npc.display.skinOverlayData.overlayList.get(0).getTexture(); - } + return npc.display.skinOverlayData.overlayList.get(0).getTexture(); + } - public IOverlayHandler getOverlays() { - return npc.display.skinOverlayData; - } + public IOverlayHandler getOverlays() { + return npc.display.skinOverlayData; + } - public void setCollisionType(int type){ - npc.stats.collidesWith = type; - } - public int getCollisionType(){ - return npc.stats.collidesWith; - } + public void setCollisionType(int type) { + npc.stats.collidesWith = type; + } - public void updateClient() { this.npc.updateClient(); } + public int getCollisionType() { + return npc.stats.collidesWith; + } - public void updateAI() { this.npc.updateTasks(); } + public void updateClient() { + this.npc.updateClient(); + } + + public void updateAI() { + this.npc.updateTasks(); + } public IActionManager getActionManager() { return npc.actionManager; diff --git a/src/main/java/noppes/npcs/scripted/entity/ScriptPixelmon.java b/src/main/java/noppes/npcs/scripted/entity/ScriptPixelmon.java index 702b9ad45..f8c585899 100644 --- a/src/main/java/noppes/npcs/scripted/entity/ScriptPixelmon.java +++ b/src/main/java/noppes/npcs/scripted/entity/ScriptPixelmon.java @@ -8,267 +8,268 @@ import noppes.npcs.scripted.constants.EntityType; import noppes.npcs.util.ValueUtil; public class ScriptPixelmon extends ScriptAnimal implements IPixelmon { - private T pixelmon; - private NBTTagCompound compound = null; - public ScriptPixelmon(T pixelmon){ - super(pixelmon); - this.pixelmon = pixelmon; - compound = new NBTTagCompound(); - pixelmon.writeEntityToNBT(compound); - } - public ScriptPixelmon(T pixelmon, NBTTagCompound compound){ - this(pixelmon); - this.compound = compound; - } + private T pixelmon; + private NBTTagCompound compound = null; - public boolean getIsShiny(){ - return compound.getBoolean("IsShiny"); - } + public ScriptPixelmon(T pixelmon) { + super(pixelmon); + this.pixelmon = pixelmon; + compound = new NBTTagCompound(); + pixelmon.writeEntityToNBT(compound); + } - public void setIsShiny(boolean bo){ - compound.setBoolean("IsShiny", bo); - pixelmon.readEntityFromNBT(compound); - } + public ScriptPixelmon(T pixelmon, NBTTagCompound compound) { + this(pixelmon); + this.compound = compound; + } - public int getLevel(){ - return compound.getInteger("Level"); - } + public boolean getIsShiny() { + return compound.getBoolean("IsShiny"); + } - public void setLevel(int level){ - compound.setInteger("Level", level); - pixelmon.readEntityFromNBT(compound); - } + public void setIsShiny(boolean bo) { + compound.setBoolean("IsShiny", bo); + pixelmon.readEntityFromNBT(compound); + } - /** - * @param type 0:HP, 1:Attack, 2:Defense, 3:SpAttack, 4:SpDefense, 5:Speed - */ - public int getIV(int type){ - if(type == 0) - return compound.getInteger("IVHP"); - if(type == 1) - return compound.getInteger("IVAttack"); - if(type == 2) - return compound.getInteger("IVDefence"); - if(type == 3) - return compound.getInteger("IVSpAtt"); - if(type == 4) - return compound.getInteger("IVSpDef"); - if(type == 5) - return compound.getInteger("IVSpeed"); + public int getLevel() { + return compound.getInteger("Level"); + } - return -1; - } + public void setLevel(int level) { + compound.setInteger("Level", level); + pixelmon.readEntityFromNBT(compound); + } + + /** + * @param type 0:HP, 1:Attack, 2:Defense, 3:SpAttack, 4:SpDefense, 5:Speed + */ + public int getIV(int type) { + if (type == 0) + return compound.getInteger("IVHP"); + if (type == 1) + return compound.getInteger("IVAttack"); + if (type == 2) + return compound.getInteger("IVDefence"); + if (type == 3) + return compound.getInteger("IVSpAtt"); + if (type == 4) + return compound.getInteger("IVSpDef"); + if (type == 5) + return compound.getInteger("IVSpeed"); + + return -1; + } - /** - * @param type 0:HP, 1:Attack, 2:Defense, 3:SpAttack, 4:SpDefense, 5:Speed - */ - public void setIV(int type, int value){ - if(type == 0) - compound.setInteger("IVHP", value); - else if(type == 1) - compound.setInteger("IVAttack", value); - else if(type == 2) - compound.setInteger("IVDefence", value); - else if(type == 3) - compound.setInteger("IVSpAtt", value); - else if(type == 4) - compound.setInteger("IVSpDef", value); - else if(type == 5) - compound.setInteger("IVSpeed", value); - pixelmon.readEntityFromNBT(compound); - } + /** + * @param type 0:HP, 1:Attack, 2:Defense, 3:SpAttack, 4:SpDefense, 5:Speed + */ + public void setIV(int type, int value) { + if (type == 0) + compound.setInteger("IVHP", value); + else if (type == 1) + compound.setInteger("IVAttack", value); + else if (type == 2) + compound.setInteger("IVDefence", value); + else if (type == 3) + compound.setInteger("IVSpAtt", value); + else if (type == 4) + compound.setInteger("IVSpDef", value); + else if (type == 5) + compound.setInteger("IVSpeed", value); + pixelmon.readEntityFromNBT(compound); + } - /** - * @param type 0:HP, 1:Attack, 2:Defense, 3:SpAttack, 4:SpDefense, 5:Speed - */ - public int getEV(int type){ - if(type == 0) - return compound.getInteger("EVHP"); - if(type == 1) - return compound.getInteger("EVAttack"); - if(type == 2) - return compound.getInteger("EVDefence"); - if(type == 3) - return compound.getInteger("EVSpecialAttack"); - if(type == 4) - return compound.getInteger("EVSpecialDefence"); - if(type == 5) - return compound.getInteger("EVSpeed"); + /** + * @param type 0:HP, 1:Attack, 2:Defense, 3:SpAttack, 4:SpDefense, 5:Speed + */ + public int getEV(int type) { + if (type == 0) + return compound.getInteger("EVHP"); + if (type == 1) + return compound.getInteger("EVAttack"); + if (type == 2) + return compound.getInteger("EVDefence"); + if (type == 3) + return compound.getInteger("EVSpecialAttack"); + if (type == 4) + return compound.getInteger("EVSpecialDefence"); + if (type == 5) + return compound.getInteger("EVSpeed"); - return -1; - } + return -1; + } - /** - * @param type 0:HP, 1:Attack, 2:Defense, 3:SpAttack, 4:SpDefense, 5:Speed - */ - public void setEV(int type, int value){ - if(type == 0) - compound.setInteger("EVHP", value); - else if(type == 1) - compound.setInteger("EVAttack", value); - else if(type == 2) - compound.setInteger("EVDefence", value); - else if(type == 3) - compound.setInteger("EVSpecialAttack", value); - else if(type == 4) - compound.setInteger("EVSpecialDefence", value); - else if(type == 5) - compound.setInteger("EVSpeed", value); - pixelmon.readEntityFromNBT(compound); - } + /** + * @param type 0:HP, 1:Attack, 2:Defense, 3:SpAttack, 4:SpDefense, 5:Speed + */ + public void setEV(int type, int value) { + if (type == 0) + compound.setInteger("EVHP", value); + else if (type == 1) + compound.setInteger("EVAttack", value); + else if (type == 2) + compound.setInteger("EVDefence", value); + else if (type == 3) + compound.setInteger("EVSpecialAttack", value); + else if (type == 4) + compound.setInteger("EVSpecialDefence", value); + else if (type == 5) + compound.setInteger("EVSpeed", value); + pixelmon.readEntityFromNBT(compound); + } - /** - * @param type 0:HP, 1:Attack, 2:Defense, 3:SpAttack, 4:SpDefense, 5:Speed - */ - public int getStat(int type){ - if(type == 0) - return compound.getInteger("StatsHP"); - if(type == 1) - return compound.getInteger("StatsAttack"); - if(type == 2) - return compound.getInteger("StatsDefence"); - if(type == 3) - return compound.getInteger("StatsSpecialAttack"); - if(type == 4) - return compound.getInteger("StatsSpecialDefence"); - if(type == 5) - return compound.getInteger("StatsSpeed"); + /** + * @param type 0:HP, 1:Attack, 2:Defense, 3:SpAttack, 4:SpDefense, 5:Speed + */ + public int getStat(int type) { + if (type == 0) + return compound.getInteger("StatsHP"); + if (type == 1) + return compound.getInteger("StatsAttack"); + if (type == 2) + return compound.getInteger("StatsDefence"); + if (type == 3) + return compound.getInteger("StatsSpecialAttack"); + if (type == 4) + return compound.getInteger("StatsSpecialDefence"); + if (type == 5) + return compound.getInteger("StatsSpeed"); - return -1; - } + return -1; + } - /** - * @param type 0:HP, 1:Attack, 2:Defense, 3:SpAttack, 4:SpDefense, 5:Speed - */ - public void setStat(int type, int value){ - if(type == 0) - compound.setInteger("StatsHP", value); - else if(type == 1) - compound.setInteger("StatsAttack", value); - else if(type == 2) - compound.setInteger("StatsDefence", value); - else if(type == 3) - compound.setInteger("StatsSpecialAttack", value); - else if(type == 4) - compound.setInteger("StatsSpecialDefence", value); - else if(type == 5) - compound.setInteger("StatsSpeed", value); - pixelmon.readEntityFromNBT(compound); - } + /** + * @param type 0:HP, 1:Attack, 2:Defense, 3:SpAttack, 4:SpDefense, 5:Speed + */ + public void setStat(int type, int value) { + if (type == 0) + compound.setInteger("StatsHP", value); + else if (type == 1) + compound.setInteger("StatsAttack", value); + else if (type == 2) + compound.setInteger("StatsDefence", value); + else if (type == 3) + compound.setInteger("StatsSpecialAttack", value); + else if (type == 4) + compound.setInteger("StatsSpecialDefence", value); + else if (type == 5) + compound.setInteger("StatsSpeed", value); + pixelmon.readEntityFromNBT(compound); + } - /** - * @return type 0:Pygmy, 1:Runt, 2:Small, 3:Normal, 4:Huge, 5:Giant, 6:Enormous, 7:Ginormous, 8:Microscopic - */ - public int getSize(){ - return compound.getShort("Growth"); - } + /** + * @return type 0:Pygmy, 1:Runt, 2:Small, 3:Normal, 4:Huge, 5:Giant, 6:Enormous, 7:Ginormous, 8:Microscopic + */ + public int getSize() { + return compound.getShort("Growth"); + } - /** - * @param type 0:Pygmy, 1:Runt, 2:Small, 3:Normal, 4:Huge, 5:Giant, 6:Enormous, 7:Ginormous, 8:Microscopic - */ - public void setSize(int type){ - compound.setShort("Growth", (short) type); - pixelmon.readEntityFromNBT(compound); - } + /** + * @param type 0:Pygmy, 1:Runt, 2:Small, 3:Normal, 4:Huge, 5:Giant, 6:Enormous, 7:Ginormous, 8:Microscopic + */ + public void setSize(int type) { + compound.setShort("Growth", (short) type); + pixelmon.readEntityFromNBT(compound); + } - /** - * @return 0-255 - */ - public int getHapiness(){ - return compound.getInteger("Friendship"); - } + /** + * @return 0-255 + */ + public int getHapiness() { + return compound.getInteger("Friendship"); + } - /** - * @param value 0-255 - */ - public void setHapiness(int value){ - value = ValueUtil.clamp(value, 0, 255); - compound.setInteger("Friendship", value); - pixelmon.readEntityFromNBT(compound); - } + /** + * @param value 0-255 + */ + public void setHapiness(int value) { + value = ValueUtil.clamp(value, 0, 255); + compound.setInteger("Friendship", value); + pixelmon.readEntityFromNBT(compound); + } - /** - * @return 0:Hardy, 1:Serious, 2:Docile, 3:Bashful, 4:Quirky, 5:Lonely, 6:Brave, 7:Adamant, 8:Naughty, 9:Bold, 10:Relaxed, 11:Impish, 12:Lax, 13:Timid, 14:Hasty, 15:Jolly, 16:Naive, 17:Modest, 18:Mild, 19:Quiet, 20:Rash, 21:Calm, 22:Gentle, 23:Sassy, 24:Careful - */ - public int getNature(){ - return compound.getShort("Nature"); - } + /** + * @return 0:Hardy, 1:Serious, 2:Docile, 3:Bashful, 4:Quirky, 5:Lonely, 6:Brave, 7:Adamant, 8:Naughty, 9:Bold, 10:Relaxed, 11:Impish, 12:Lax, 13:Timid, 14:Hasty, 15:Jolly, 16:Naive, 17:Modest, 18:Mild, 19:Quiet, 20:Rash, 21:Calm, 22:Gentle, 23:Sassy, 24:Careful + */ + public int getNature() { + return compound.getShort("Nature"); + } - /** - * @param type 0:Hardy, 1:Serious, 2:Docile, 3:Bashful, 4:Quirky, 5:Lonely, 6:Brave, 7:Adamant, 8:Naughty, 9:Bold, 10:Relaxed, 11:Impish, 12:Lax, 13:Timid, 14:Hasty, 15:Jolly, 16:Naive, 17:Modest, 18:Mild, 19:Quiet, 20:Rash, 21:Calm, 22:Gentle, 23:Sassy, 24:Careful - */ - public void setNature(int type){ - compound.setShort("Nature", (short) type); - pixelmon.readEntityFromNBT(compound); - } + /** + * @param type 0:Hardy, 1:Serious, 2:Docile, 3:Bashful, 4:Quirky, 5:Lonely, 6:Brave, 7:Adamant, 8:Naughty, 9:Bold, 10:Relaxed, 11:Impish, 12:Lax, 13:Timid, 14:Hasty, 15:Jolly, 16:Naive, 17:Modest, 18:Mild, 19:Quiet, 20:Rash, 21:Calm, 22:Gentle, 23:Sassy, 24:Careful + */ + public void setNature(int type) { + compound.setShort("Nature", (short) type); + pixelmon.readEntityFromNBT(compound); + } - /** - * @return -1:Uncaught, 0:Pokeball, 1:GreatBall, 2:UltraBall, 3:MasterBall, 4:LevelBall, 5:MoonBall, 6:FriendBall, 7:LoveBall, 8:SafariBall, 9:HeavyBall, 10:FastBall, 11:RepeatBall, 12:TimerBall, 13:NestBall, 14:NetBall, 15:DiveBall, 16:LuxuryBall, 17:HealBall, 18:DuskBall, 19:PremierBall, 20:SportBall, 21:QuickBall, 22:ParkBall, 23:LureBall, 24:CherishBall, 25:GSBall - */ - public int getPokeball(){ - if(compound.hasKey("CaughtBall")) - return -1; - return compound.getInteger("CaughtBall"); - } + /** + * @return -1:Uncaught, 0:Pokeball, 1:GreatBall, 2:UltraBall, 3:MasterBall, 4:LevelBall, 5:MoonBall, 6:FriendBall, 7:LoveBall, 8:SafariBall, 9:HeavyBall, 10:FastBall, 11:RepeatBall, 12:TimerBall, 13:NestBall, 14:NetBall, 15:DiveBall, 16:LuxuryBall, 17:HealBall, 18:DuskBall, 19:PremierBall, 20:SportBall, 21:QuickBall, 22:ParkBall, 23:LureBall, 24:CherishBall, 25:GSBall + */ + public int getPokeball() { + if (compound.hasKey("CaughtBall")) + return -1; + return compound.getInteger("CaughtBall"); + } - /** - * @param type -1:Uncaught, 0:Pokeball, 1:GreatBall, 2:UltraBall, 3:MasterBall, 4:LevelBall, 5:MoonBall, 6:FriendBall, 7:LoveBall, 8:SafariBall, 9:HeavyBall, 10:FastBall, 11:RepeatBall, 12:TimerBall, 13:NestBall, 14:NetBall, 15:DiveBall, 16:LuxuryBall, 17:HealBall, 18:DuskBall, 19:PremierBall, 20:SportBall, 21:QuickBall, 22:ParkBall, 23:LureBall, 24:CherishBall, 25:GSBall - */ - public void setPokeball(int type){ - compound.setInteger("CaughtBall", type); - pixelmon.readEntityFromNBT(compound); - } + /** + * @param type -1:Uncaught, 0:Pokeball, 1:GreatBall, 2:UltraBall, 3:MasterBall, 4:LevelBall, 5:MoonBall, 6:FriendBall, 7:LoveBall, 8:SafariBall, 9:HeavyBall, 10:FastBall, 11:RepeatBall, 12:TimerBall, 13:NestBall, 14:NetBall, 15:DiveBall, 16:LuxuryBall, 17:HealBall, 18:DuskBall, 19:PremierBall, 20:SportBall, 21:QuickBall, 22:ParkBall, 23:LureBall, 24:CherishBall, 25:GSBall + */ + public void setPokeball(int type) { + compound.setInteger("CaughtBall", type); + pixelmon.readEntityFromNBT(compound); + } - public String getNickname(){ - return compound.getString("Nickname"); - } + public String getNickname() { + return compound.getString("Nickname"); + } - public boolean hasNickname(){ - return !getNickname().isEmpty(); - } + public boolean hasNickname() { + return !getNickname().isEmpty(); + } - public void setNickname(String name){ - compound.setString("Nickname", name); - pixelmon.readEntityFromNBT(compound); - } + public void setNickname(String name) { + compound.setString("Nickname", name); + pixelmon.readEntityFromNBT(compound); + } - public String getMove(int slot){ - if(!compound.hasKey("PixelmonMoveID" + slot)) - return null; - return PixelmonHelper.getAttackName(compound.getInteger("PixelmonMoveID" + slot)); - } + public String getMove(int slot) { + if (!compound.hasKey("PixelmonMoveID" + slot)) + return null; + return PixelmonHelper.getAttackName(compound.getInteger("PixelmonMoveID" + slot)); + } - public void setMove(int slot, String move){ - slot = ValueUtil.clamp(slot, 0, 3); - int id = PixelmonHelper.getAttackID(move); - compound.removeTag("PixelmonMovePP" + slot); - compound.removeTag("PixelmonMovePPBase" + slot); - if(id < 0){ - compound.removeTag("PixelmonMoveID" + slot); - } - else{ - compound.setInteger("PixelmonMoveID" + slot, id); - } - int size = 0; - for(int i = 0; i < 4; i++){ - if(compound.hasKey("PixelmonMoveID" + i)) - size++; - } - compound.setInteger("PixelmonNumberMoves", size); + public void setMove(int slot, String move) { + slot = ValueUtil.clamp(slot, 0, 3); + int id = PixelmonHelper.getAttackID(move); + compound.removeTag("PixelmonMovePP" + slot); + compound.removeTag("PixelmonMovePPBase" + slot); + if (id < 0) { + compound.removeTag("PixelmonMoveID" + slot); + } else { + compound.setInteger("PixelmonMoveID" + slot, id); + } + int size = 0; + for (int i = 0; i < 4; i++) { + if (compound.hasKey("PixelmonMoveID" + i)) + size++; + } + compound.setInteger("PixelmonNumberMoves", size); - pixelmon.readEntityFromNBT(compound); - } + pixelmon.readEntityFromNBT(compound); + } @Override - public int getType(){ + public int getType() { return EntityType.PIXELMON; } @Override - public boolean typeOf(int type){ + public boolean typeOf(int type) { return type == EntityType.PIXELMON || super.typeOf(type); } } diff --git a/src/main/java/noppes/npcs/scripted/entity/ScriptPlayer.java b/src/main/java/noppes/npcs/scripted/entity/ScriptPlayer.java index f9ee9e999..5c637dc8c 100644 --- a/src/main/java/noppes/npcs/scripted/entity/ScriptPlayer.java +++ b/src/main/java/noppes/npcs/scripted/entity/ScriptPlayer.java @@ -50,434 +50,466 @@ import java.util.Iterator; import java.util.List; public class ScriptPlayer extends ScriptLivingBase implements IPlayer { - public T player; - private PlayerData data; + public T player; + private PlayerData data; - public ScriptPlayer(T player){ - super(player); - this.player = player; - } + public ScriptPlayer(T player) { + super(player); + this.player = player; + } - /** - * @return Returns the displayed name of the player - */ - public String getDisplayName(){ - return player.getDisplayName(); - } + /** + * @return Returns the displayed name of the player + */ + public String getDisplayName() { + return player.getDisplayName(); + } - /** - * @return Returns the players name - */ - public String getName(){ - return player.getCommandSenderName(); - } + /** + * @return Returns the players name + */ + public String getName() { + return player.getCommandSenderName(); + } - public void kick(String reason) { - player.playerNetServerHandler.kickPlayerFromServer(reason); - } + public void kick(String reason) { + player.playerNetServerHandler.kickPlayerFromServer(reason); + } - @Override - public void spawnParticle(IParticle entityParticle) { - entityParticle.spawnOnEntity(this); - } + @Override + public void spawnParticle(IParticle entityParticle) { + entityParticle.spawnOnEntity(this); + } - @Override - public void setPosition(double x, double y, double z){ - NoppesUtilPlayer.teleportPlayer(player, x, y, z, player.dimension); - } - public void setPos(double x, double y, double z) { - this.setPosition(x,y,z); - } + @Override + public void setPosition(double x, double y, double z) { + NoppesUtilPlayer.teleportPlayer(player, x, y, z, player.dimension); + } - public void setPosition(IPos pos) { - this.setPosition(pos.getXD(),pos.getYD(),pos.getZD()); - } - public void setPos(IPos pos) { - this.setPosition(pos); - } + public void setPos(double x, double y, double z) { + this.setPosition(x, y, z); + } - public void setPosition(double x, double y, double z, int dimensionId) { - if (NpcAPI.Instance().getIWorld(dimensionId) == null) - return; + public void setPosition(IPos pos) { + this.setPosition(pos.getXD(), pos.getYD(), pos.getZD()); + } - NoppesUtilPlayer.teleportPlayer(player, x, y, z, dimensionId); - } - public void setPos(double x, double y, double z, int dimensionId) { - this.setPosition(x,y,z,dimensionId); - } - public void setPosition(double x, double y, double z, IWorld world) { - this.setPosition(x,y,z,world.getDimensionID()); - } - public void setPos(double x, double y, double z, IWorld world) { - this.setPos(x,y,z,world.getDimensionID()); - } + public void setPos(IPos pos) { + this.setPosition(pos); + } - public void setPosition(IPos pos, int dimensionId) { - this.setPosition(pos.getXD(),pos.getYD(),pos.getZD(), dimensionId); - } - public void setPos(IPos pos, int dimensionId) { - this.setPosition(pos,dimensionId); - } - public void setPosition(IPos pos, IWorld world) { - this.setPosition(pos.getXD(),pos.getYD(),pos.getZD(),world.getDimensionID()); - } - public void setPos(IPos pos, IWorld world) { - this.setPosition(pos,world.getDimensionID()); - } + public void setPosition(double x, double y, double z, int dimensionId) { + if (NpcAPI.Instance().getIWorld(dimensionId) == null) + return; - public void setDimension(int dimension) { - this.setPosition(this.getPos(),dimension); - } - public void setDimension(IWorld world) { - this.setDimension(world.getDimensionID()); - } + NoppesUtilPlayer.teleportPlayer(player, x, y, z, dimensionId); + } - public int getHunger(){ - return player.getFoodStats().getFoodLevel(); - } + public void setPos(double x, double y, double z, int dimensionId) { + this.setPosition(x, y, z, dimensionId); + } - public void setHunger(int hunger){ - int prevHunger = this.getHunger(); - if(hunger < 0) - hunger = 0; + public void setPosition(double x, double y, double z, IWorld world) { + this.setPosition(x, y, z, world.getDimensionID()); + } - player.getFoodStats().addStats(hunger-prevHunger,0); - } + public void setPos(double x, double y, double z, IWorld world) { + this.setPos(x, y, z, world.getDimensionID()); + } - public float getSaturation(){ - return player.getFoodStats().getSaturationLevel(); - } + public void setPosition(IPos pos, int dimensionId) { + this.setPosition(pos.getXD(), pos.getYD(), pos.getZD(), dimensionId); + } - public void setSaturation(float saturation){ - float prevSaturation = this.getHunger(); - if(saturation < 0) - saturation = 0; + public void setPos(IPos pos, int dimensionId) { + this.setPosition(pos, dimensionId); + } - player.getFoodStats().addStats(0,saturation-prevSaturation); - } + public void setPosition(IPos pos, IWorld world) { + this.setPosition(pos.getXD(), pos.getYD(), pos.getZD(), world.getDimensionID()); + } - public void showDialog(IDialog dialog) { - if (dialog != null) { - showDialog(dialog.getId()); - } - } + public void setPos(IPos pos, IWorld world) { + this.setPosition(pos, world.getDimensionID()); + } - public boolean hasReadDialog(IDialog dialog) { - if (dialog != null) { - return hasReadDialog(dialog.getId()); - } - return false; - } + public void setDimension(int dimension) { + this.setPosition(this.getPos(), dimension); + } - public void readDialog(IDialog dialog) { - if (dialog != null) { - this.readDialog(dialog.getId()); - } - } + public void setDimension(IWorld world) { + this.setDimension(world.getDimensionID()); + } - public void unreadDialog(IDialog dialog) { - if (dialog != null) { - this.unreadDialog(dialog.getId()); - } - } + public int getHunger() { + return player.getFoodStats().getFoodLevel(); + } - public void showDialog(int id){ - Dialog dialog = (Dialog) DialogController.Instance.get(id); - if(dialog == null) - return; + public void setHunger(int hunger) { + int prevHunger = this.getHunger(); + if (hunger < 0) + hunger = 0; - NoppesUtilServer.openDialog(player, new EntityDialogNpc(this.player.worldObj), dialog, 0); - } + player.getFoodStats().addStats(hunger - prevHunger, 0); + } - public boolean hasReadDialog(int id){ - PlayerDialogData data = PlayerDataController.Instance.getPlayerData(player).dialogData; - return data.dialogsRead.contains(id); - } + public float getSaturation() { + return player.getFoodStats().getSaturationLevel(); + } - public void readDialog(int id) { + public void setSaturation(float saturation) { + float prevSaturation = this.getHunger(); + if (saturation < 0) + saturation = 0; + + player.getFoodStats().addStats(0, saturation - prevSaturation); + } + + public void showDialog(IDialog dialog) { + if (dialog != null) { + showDialog(dialog.getId()); + } + } + + public boolean hasReadDialog(IDialog dialog) { + if (dialog != null) { + return hasReadDialog(dialog.getId()); + } + return false; + } + + public void readDialog(IDialog dialog) { + if (dialog != null) { + this.readDialog(dialog.getId()); + } + } + + public void unreadDialog(IDialog dialog) { + if (dialog != null) { + this.unreadDialog(dialog.getId()); + } + } + + public void showDialog(int id) { + Dialog dialog = (Dialog) DialogController.Instance.get(id); + if (dialog == null) + return; + + NoppesUtilServer.openDialog(player, new EntityDialogNpc(this.player.worldObj), dialog, 0); + } + + public boolean hasReadDialog(int id) { + PlayerDialogData data = PlayerDataController.Instance.getPlayerData(player).dialogData; + return data.dialogsRead.contains(id); + } + + public void readDialog(int id) { PlayerData playerData = PlayerData.get(player); playerData.dialogData.dialogsRead.add(id); playerData.updateClient = true; - } + } - public void unreadDialog(int id) { + public void unreadDialog(int id) { PlayerData playerData = PlayerData.get(player); - playerData.dialogData.dialogsRead.remove(id); + playerData.dialogData.dialogsRead.remove(id); playerData.updateClient = true; - } + } - public boolean hasFinishedQuest(IQuest quest) { - if (quest == null) - return false; - return hasFinishedQuest(quest.getId()); - } + public boolean hasFinishedQuest(IQuest quest) { + if (quest == null) + return false; + return hasFinishedQuest(quest.getId()); + } - public boolean hasActiveQuest(IQuest quest) { - if (quest == null) - return false; - return hasActiveQuest(quest.getId()); - } + public boolean hasActiveQuest(IQuest quest) { + if (quest == null) + return false; + return hasActiveQuest(quest.getId()); + } - public void startQuest(IQuest quest) { - if (quest == null) - return; - startQuest(quest.getId()); - } + public void startQuest(IQuest quest) { + if (quest == null) + return; + startQuest(quest.getId()); + } - public void finishQuest(IQuest quest) { - if (quest == null) - return; - finishQuest(quest.getId()); - } + public void finishQuest(IQuest quest) { + if (quest == null) + return; + finishQuest(quest.getId()); + } - public void stopQuest(IQuest quest) { - if (quest == null) - return; - stopQuest(quest.getId()); - } + public void stopQuest(IQuest quest) { + if (quest == null) + return; + stopQuest(quest.getId()); + } - public void removeQuest(IQuest quest) { - if (quest == null) - return; - removeQuest(quest.getId()); - } + public void removeQuest(IQuest quest) { + if (quest == null) + return; + removeQuest(quest.getId()); + } - public boolean hasFinishedQuest(int id){ - PlayerQuestData data = PlayerDataController.Instance.getPlayerData(player).questData; - return data.finishedQuests.containsKey(id); - } + public boolean hasFinishedQuest(int id) { + PlayerQuestData data = PlayerDataController.Instance.getPlayerData(player).questData; + return data.finishedQuests.containsKey(id); + } - public boolean hasActiveQuest(int id){ - PlayerQuestData data = PlayerDataController.Instance.getPlayerData(player).questData; - return data.activeQuests.containsKey(id); - } + public boolean hasActiveQuest(int id) { + PlayerQuestData data = PlayerDataController.Instance.getPlayerData(player).questData; + return data.activeQuests.containsKey(id); + } - /** - * Add the quest from active quest list - * @param id The Quest ID - */ - public void startQuest(int id){ + /** + * Add the quest from active quest list + * + * @param id The Quest ID + */ + public void startQuest(int id) { Quest quest = QuestController.Instance.quests.get(id); if (quest == null) - return; - PlayerData data = PlayerDataController.Instance.getPlayerData(player); - if(data.questData.activeQuests.containsKey(id)) - return; + return; + PlayerData data = PlayerDataController.Instance.getPlayerData(player); + if (data.questData.activeQuests.containsKey(id)) + return; QuestData questdata = new QuestData(quest); data.questData.activeQuests.put(id, questdata); AchievementPacket.sendAchievement((EntityPlayerMP) player, false, "quest.newquest", quest.title); ChatAlertPacket.sendChatAlert((EntityPlayerMP) player, "quest.newquest", ": ", quest.title); data.updateClient = true; - } + } - /** - * Add the quest from finished quest list - * @param id The Quest ID - */ - public void finishQuest(int id){ + /** + * Add the quest from finished quest list + * + * @param id The Quest ID + */ + public void finishQuest(int id) { Quest quest = QuestController.Instance.quests.get(id); if (quest == null) - return; - PlayerData data = PlayerData.get(player); + return; + PlayerData data = PlayerData.get(player); PlayerQuestController.setQuestFinishedUtil(player, quest, data.questData); data.updateClient = true; - } + } - /** - * Removes the quest from active quest list - * @param id The Quest ID - */ - public void stopQuest(int id){ + /** + * Removes the quest from active quest list + * + * @param id The Quest ID + */ + public void stopQuest(int id) { Quest quest = QuestController.Instance.quests.get(id); if (quest == null) - return; - PlayerData data = PlayerDataController.Instance.getPlayerData(player); - data.questData.activeQuests.remove(id); + return; + PlayerData data = PlayerDataController.Instance.getPlayerData(player); + data.questData.activeQuests.remove(id); data.updateClient = true; - } + } - /** - * Removes the quest from active and finished quest list - * @param id The Quest ID - */ - public void removeQuest(int id){ + /** + * Removes the quest from active and finished quest list + * + * @param id The Quest ID + */ + public void removeQuest(int id) { Quest quest = QuestController.Instance.quests.get(id); if (quest == null) - return; - PlayerData data = PlayerData.get(player); - data.questData.activeQuests.remove(id); - data.questData.finishedQuests.remove(id); + return; + PlayerData data = PlayerData.get(player); + data.questData.activeQuests.remove(id); + data.questData.finishedQuests.remove(id); data.updateClient = true; - } + } - @Override - public int getType(){ - return EntityType.PLAYER; - } + @Override + public int getType() { + return EntityType.PLAYER; + } - @Override - public boolean typeOf(int type){ - return type == EntityType.PLAYER?true:super.typeOf(type); - } - /** - * @param faction The faction id - * @param points The points to increase. Use negative values to decrease - */ - public void addFactionPoints(int faction, int points){ - PlayerData data = PlayerDataController.Instance.getPlayerData(player); - data.factionData.increasePoints(faction, points, player); - } - /** - * @param faction The faction id - * @param points The new point value for this faction - */ - public void setFactionPoints(int faction, int points) { - PlayerData data = PlayerDataController.Instance.getPlayerData(player); - data.factionData.increasePoints(faction, points-getFactionPoints(faction), player); - } + @Override + public boolean typeOf(int type) { + return type == EntityType.PLAYER ? true : super.typeOf(type); + } /** * @param faction The faction id - * @return points + * @param points The points to increase. Use negative values to decrease */ - public int getFactionPoints(int faction) { - PlayerData data = PlayerDataController.Instance.getPlayerData(player); - return data.factionData.getFactionPoints(faction); - } + public void addFactionPoints(int faction, int points) { + PlayerData data = PlayerDataController.Instance.getPlayerData(player); + data.factionData.increasePoints(faction, points, player); + } - public void sendMessage(String message){ - player.addChatMessage(new ChatComponentTranslation(NoppesStringUtils.formatText(message,player))); - } + /** + * @param faction The faction id + * @param points The new point value for this faction + */ + public void setFactionPoints(int faction, int points) { + PlayerData data = PlayerDataController.Instance.getPlayerData(player); + data.factionData.increasePoints(faction, points - getFactionPoints(faction), player); + } - public void sendMessage(String message, String color, boolean bold, boolean italic, boolean underlined) { - sendMessage(message, color, bold, italic, underlined, false, false); - } + /** + * @param faction The faction id + * @return points + */ + public int getFactionPoints(int faction) { + PlayerData data = PlayerDataController.Instance.getPlayerData(player); + return data.factionData.getFactionPoints(faction); + } - public void sendMessage(String message, String color, boolean bold, boolean italic, boolean obfuscated, boolean strikethrough, boolean underlined) { - EnumChatFormatting c = getColor(color); + public void sendMessage(String message) { + player.addChatMessage(new ChatComponentTranslation(NoppesStringUtils.formatText(message, player))); + } - if (c == null) - return; + public void sendMessage(String message, String color, boolean bold, boolean italic, boolean underlined) { + sendMessage(message, color, bold, italic, underlined, false, false); + } - ChatComponentTranslation chat = new ChatComponentTranslation(NoppesStringUtils.formatText(message,player)); - ChatStyle style = new ChatStyle(); - style.setColor(c); - style.setBold(bold); - style.setItalic(italic); - style.setObfuscated(obfuscated); - style.setStrikethrough(strikethrough); - style.setUnderlined(underlined); - chat.setChatStyle(style); + public void sendMessage(String message, String color, boolean bold, boolean italic, boolean obfuscated, boolean strikethrough, boolean underlined) { + EnumChatFormatting c = getColor(color); - player.addChatMessage(chat); - } + if (c == null) + return; - private EnumChatFormatting getColor(String color) { - switch (color) { - case "black": return EnumChatFormatting.BLACK; - case "dark_blue": return EnumChatFormatting.DARK_BLUE; - case "dark_green": return EnumChatFormatting.DARK_GREEN; - case "dark_aqua": return EnumChatFormatting.DARK_AQUA; - case "dark_red": return EnumChatFormatting.DARK_RED; - case "dark_purple": return EnumChatFormatting.DARK_PURPLE; - case "gold": return EnumChatFormatting.GOLD; - case "gray": return EnumChatFormatting.GRAY; - case "dark_gray": return EnumChatFormatting.DARK_GRAY; - case "blue": return EnumChatFormatting.BLUE; - case "green": return EnumChatFormatting.GREEN; - case "aqua": return EnumChatFormatting.AQUA; - case "red": return EnumChatFormatting.RED; - case "light_purple": return EnumChatFormatting.LIGHT_PURPLE; - case "yellow": return EnumChatFormatting.YELLOW; - case "white": return EnumChatFormatting.WHITE; - default: return null; - } - } + ChatComponentTranslation chat = new ChatComponentTranslation(NoppesStringUtils.formatText(message, player)); + ChatStyle style = new ChatStyle(); + style.setColor(c); + style.setBold(bold); + style.setItalic(italic); + style.setObfuscated(obfuscated); + style.setStrikethrough(strikethrough); + style.setUnderlined(underlined); + chat.setChatStyle(style); - /** - * @return Return gamemode. 0: Survival, 1: Creative, 2: Adventure - */ - public int getMode(){ - return player.theItemInWorldManager.getGameType().getID(); - } + player.addChatMessage(chat); + } - /** - * @param type The gamemode type. 0:SURVIVAL, 1:CREATIVE, 2:ADVENTURE - */ - public void setMode(int type){ - player.setGameType(WorldSettings.getGameTypeById(type)); - } + private EnumChatFormatting getColor(String color) { + switch (color) { + case "black": + return EnumChatFormatting.BLACK; + case "dark_blue": + return EnumChatFormatting.DARK_BLUE; + case "dark_green": + return EnumChatFormatting.DARK_GREEN; + case "dark_aqua": + return EnumChatFormatting.DARK_AQUA; + case "dark_red": + return EnumChatFormatting.DARK_RED; + case "dark_purple": + return EnumChatFormatting.DARK_PURPLE; + case "gold": + return EnumChatFormatting.GOLD; + case "gray": + return EnumChatFormatting.GRAY; + case "dark_gray": + return EnumChatFormatting.DARK_GRAY; + case "blue": + return EnumChatFormatting.BLUE; + case "green": + return EnumChatFormatting.GREEN; + case "aqua": + return EnumChatFormatting.AQUA; + case "red": + return EnumChatFormatting.RED; + case "light_purple": + return EnumChatFormatting.LIGHT_PURPLE; + case "yellow": + return EnumChatFormatting.YELLOW; + case "white": + return EnumChatFormatting.WHITE; + default: + return null; + } + } - /** - * @since 1.7.10d - * @return Returns a IItemStack array size 36 - */ - public IItemStack[] getInventory(){ - IItemStack[] items = new IItemStack[36]; - for(int i = 0; i < player.inventory.mainInventory.length; i++){ - ItemStack item = player.inventory.mainInventory[i]; - if(item != null) - items[i] = NpcAPI.Instance().getIItemStack(item); - } - return items; - } + /** + * @return Return gamemode. 0: Survival, 1: Creative, 2: Adventure + */ + public int getMode() { + return player.theItemInWorldManager.getGameType().getID(); + } - public int inventoryItemCount(IItemStack item){ - return inventoryItemCount(item, true, true); - } + /** + * @param type The gamemode type. 0:SURVIVAL, 1:CREATIVE, 2:ADVENTURE + */ + public void setMode(int type) { + player.setGameType(WorldSettings.getGameTypeById(type)); + } - /** - * @param item The item to be checked - * @return How many of this item the player has - */ - public int inventoryItemCount(IItemStack item, boolean ignoreNBT, boolean ignoreDamage) { - int i = 0; - for(ItemStack is : player.inventory.mainInventory){ - if (is != null && NoppesUtilPlayer.compareItems(is, item.getMCItemStack(), ignoreDamage, ignoreNBT)) { - i += is.stackSize; - } - } - return i; - } + /** + * @return Returns a IItemStack array size 36 + * @since 1.7.10d + */ + public IItemStack[] getInventory() { + IItemStack[] items = new IItemStack[36]; + for (int i = 0; i < player.inventory.mainInventory.length; i++) { + ItemStack item = player.inventory.mainInventory[i]; + if (item != null) + items[i] = NpcAPI.Instance().getIItemStack(item); + } + return items; + } - /** - * @since 1.7.10c - * @param id The items name - * @param damage The damage value - * @param amount How many will be removed - * @return Returns true if the items were removed succesfully. Returns false incase a bigger amount than what the player has was given or item doesnt exist - */ - public boolean removeItem(String id, int damage, int amount){ - Item item = (Item)Item.itemRegistry.getObject(id); - if(item == null) - return false; - return removeItem(NpcAPI.Instance().getIItemStack(new ItemStack(item, 1, damage)), amount); - } + public int inventoryItemCount(IItemStack item) { + return inventoryItemCount(item, true, true); + } - public boolean removeItem(IItemStack item, int amount){ - return removeItem(item, amount, true, true); - } + /** + * @param item The item to be checked + * @return How many of this item the player has + */ + public int inventoryItemCount(IItemStack item, boolean ignoreNBT, boolean ignoreDamage) { + int i = 0; + for (ItemStack is : player.inventory.mainInventory) { + if (is != null && NoppesUtilPlayer.compareItems(is, item.getMCItemStack(), ignoreDamage, ignoreNBT)) { + i += is.stackSize; + } + } + return i; + } - /** - * @param item The Item type to be removed - * @param amount How many will be removed - * @return Returns true if the items were removed succesfully. Returns false incase a bigger amount than what the player has was given - */ - public boolean removeItem(IItemStack item, int amount, boolean ignoreNBT, boolean ignoreDamage) { - int count = inventoryItemCount(item,ignoreNBT,ignoreDamage); - if(amount > count) { + /** + * @param id The items name + * @param damage The damage value + * @param amount How many will be removed + * @return Returns true if the items were removed succesfully. Returns false incase a bigger amount than what the player has was given or item doesnt exist + * @since 1.7.10c + */ + public boolean removeItem(String id, int damage, int amount) { + Item item = (Item) Item.itemRegistry.getObject(id); + if (item == null) return false; - } else if(count == amount) { + return removeItem(NpcAPI.Instance().getIItemStack(new ItemStack(item, 1, damage)), amount); + } + + public boolean removeItem(IItemStack item, int amount) { + return removeItem(item, amount, true, true); + } + + /** + * @param item The Item type to be removed + * @param amount How many will be removed + * @return Returns true if the items were removed succesfully. Returns false incase a bigger amount than what the player has was given + */ + public boolean removeItem(IItemStack item, int amount, boolean ignoreNBT, boolean ignoreDamage) { + int count = inventoryItemCount(item, ignoreNBT, ignoreDamage); + if (amount > count) { + return false; + } else if (count == amount) { removeAllItems(item, ignoreNBT, ignoreDamage); } else { - for(int i = 0; i < player.inventory.mainInventory.length; i++) { + for (int i = 0; i < player.inventory.mainInventory.length; i++) { ItemStack is = player.inventory.mainInventory[i]; if (is != null && NoppesUtilPlayer.compareItems(is, item.getMCItemStack(), ignoreDamage, ignoreNBT)) { - if(amount > is.stackSize){ + if (amount > is.stackSize) { player.inventory.mainInventory[i] = null; amount -= is.stackSize; - } else{ + } else { is.splitStack(amount); break; } @@ -488,316 +520,318 @@ public class ScriptPlayer extends ScriptLivingBase return true; } - /** - * @param item The item to be removed from the players inventory - */ - public int removeAllItems(IItemStack item, boolean ignoreNBT, boolean ignoreDamage){ - int removed = 0; + /** + * @param item The item to be removed from the players inventory + */ + public int removeAllItems(IItemStack item, boolean ignoreNBT, boolean ignoreDamage) { + int removed = 0; - for(int i = 0; i < player.inventory.mainInventory.length; i++) { - ItemStack is = player.inventory.mainInventory[i]; - if (is != null && NoppesUtilPlayer.compareItems(is, item.getMCItemStack(), ignoreDamage, ignoreNBT)) { - player.inventory.mainInventory[i] = null; - removed++; - } - } - - return removed; - } - - /** - * @since 1.7.10c - * @param item Item to be added - * @param amount The amount of the item to be added - * @return Returns whether or not it gave the item succesfully - */ - public boolean giveItem(IItemStack item, int amount){ - if(item != null && item.getMCItemStack() != null) { - item.setStackSize(amount); - boolean bool = this.player.inventory.addItemStackToInventory(item.getMCItemStack()); - this.updatePlayerInventory(); - return bool; - } else { - return false; - } - } - - /** - * @since 1.7.10c - * @param id The items name - * @param damage The damage value - * @param amount The amount of the item to be added - * @return Returns whether or not it gave the item succesfully - */ - public boolean giveItem(String id, int damage, int amount){ - Item item = (Item)Item.itemRegistry.getObject(id); - if(item == null) - return false; - return player.inventory.addItemStackToInventory(new ItemStack(item, amount, damage)); - } - - /** - * Same as the /spawnpoint command - * @param x The x position - * @param y The y position - * @param z The z position - */ - public void setSpawnpoint(int x, int y, int z){ - x = ValueUtil.clamp(x, -30000000, 30000000); - z = ValueUtil.clamp(z, -30000000, 30000000); - y = ValueUtil.clamp(y, 0, 256); - player.setSpawnChunk(new ChunkCoordinates(x, y, z), true); - } - - public void setSpawnpoint(IPos pos){ - this.setSpawnpoint(pos.getX(),pos.getY(),pos.getZ()); - } - - public void resetSpawnpoint(){ - player.setSpawnChunk(null, false); - } - - public void clearInventory() { - for(int i = 0; i < player.inventory.mainInventory.length; i++) player.inventory.mainInventory[i] = null; - for(int i = 0; i < player.inventory.armorInventory.length; i++) player.inventory.armorInventory[i] = null; - } - - public void setRotation(float rotationYaw){ - NoppesUtilPlayer.teleportPlayer(player, player.posX, player.posY, player.posZ, rotationYaw, player.rotationPitch, player.dimension); - } - - public void setRotation(float rotationYaw, float rotationPitch){ - NoppesUtilPlayer.teleportPlayer(player, player.posX, player.posY, player.posZ, rotationYaw, rotationPitch, player.dimension); - } - - public void swingHand(){ - NoppesUtilPlayer.swingPlayerArm(player); - } - - public void disableMouseInput(long time, int... buttonIds) { - NoppesUtilPlayer.disableMouseInput(player ,time, buttonIds); - } - - public void stopUsingItem(){ - player.stopUsingItem(); - } - - public void clearItemInUse(){ - player.clearItemInUse(); - } - - public void playSound(String name, float volume, float pitch){ - player.playSound(name, volume, pitch); - } - - public void playSound(int id, ISound sound) { - NoppesUtilPlayer.playSoundTo(player, id, (ScriptSound) sound); - } - - public void playSound(ISound sound) { - NoppesUtilPlayer.playSoundTo(player, (ScriptSound) sound); - } - - public void stopSound(int id) { - NoppesUtilPlayer.stopSoundFor(player, id); - } - - public void pauseSounds() { - NoppesUtilPlayer.pauseSoundsFor(player); - } - - public void continueSounds() { - NoppesUtilPlayer.continueSoundsFor(player); - } - - public void stopSounds() { - NoppesUtilPlayer.stopSoundsFor(player); - } - - public void mountEntity(Entity ridingEntity){ - player.mountEntity(ridingEntity); - } - - public IEntity dropOneItem(boolean dropStack){ - return NpcAPI.Instance().getIEntity(player.dropOneItem(dropStack)); - } - - public boolean canHarvestBlock(IBlock block){ - return player.canHarvestBlock(block.getMCBlock()); - } - - public boolean interactWith(IEntity entity){ - return player.interactWith(entity.getMCEntity()); - } - - /** - * @param achievement The achievement id. For a complete list see http://minecraft.wiki/w/Achievements - * @return Returns whether or not the player has this achievement - */ - public boolean hasAchievement(String achievement){ - StatBase statbase = StatList.func_151177_a(achievement); - if(statbase == null || !(statbase instanceof Achievement)){ - return false; + for (int i = 0; i < player.inventory.mainInventory.length; i++) { + ItemStack is = player.inventory.mainInventory[i]; + if (is != null && NoppesUtilPlayer.compareItems(is, item.getMCItemStack(), ignoreDamage, ignoreNBT)) { + player.inventory.mainInventory[i] = null; + removed++; + } } - return player.func_147099_x().hasAchievementUnlocked((Achievement) statbase); - } - /** - * @param permission Bukkit/Cauldron permission - * @return Returns whether or not the player has the permission - */ - public boolean hasBukkitPermission(String permission){ - return CustomNpcsPermissions.hasPermissionString(player, permission); - } - - /** - * @since 1.7.10c - * @return Returns the exp level - */ - public int getExpLevel(){ - return player.experienceLevel; - } - - /** - * @since 1.7.10c - * @param level The new exp level you want to set - */ - public void setExpLevel(int level){ - player.experienceLevel = level; - player.addExperienceLevel(0); - } - - /** - * Requires pixelmon to be installed - * @since 1.7.10d - */ - public IPixelmonPlayerData getPixelmonData(){ - if(!PixelmonHelper.Enabled) - return null; - return new ScriptPixelmonPlayerData(player); - } - - public ITimers getTimers() { - return PlayerDataController.Instance.getPlayerData(player).timers; - } - - @Override - public IScreenSize getScreenSize() { - PlayerData data = PlayerDataController.Instance.getPlayerData(player); - return data.getScreenSize() ; - } - - public void updatePlayerInventory() { - ((EntityPlayerMP)this.entity).inventoryContainer.detectAndSendChanges(); - PlayerData playerData = PlayerDataController.Instance.getPlayerData(player); - PlayerQuestData questData = playerData.questData; - Party playerParty = playerData.getPlayerParty(); - if(playerParty != null) - PartyController.Instance().checkQuestCompletion(playerParty, EnumQuestType.Item); - - questData.checkQuestCompletion(playerData, EnumQuestType.Item); - } - - @Deprecated - public boolean checkGUIOpen() { - NoppesUtilPlayer.isGUIOpen(player); - PlayerData data = PlayerDataController.Instance.getPlayerData(player); - return data.getGUIOpen(); - } - - @Deprecated - public ScriptDBCPlayer getDBCPlayer() { - return this instanceof ScriptDBCPlayer ? (ScriptDBCPlayer) this : null; - } - - public boolean blocking() { - return player.isBlocking(); - } - - public PlayerData getData() { - if (this.data == null) { - this.data = PlayerDataController.Instance.getPlayerData(player); - } - - return this.data; - } - - public boolean isScriptingDev() { - return ConfigScript.isScriptDev(player); - } - - public IQuest[] getActiveQuests() { - PlayerQuestData data = (PlayerQuestData) this.getData().getQuestData(); - List quests = new ArrayList(); - Iterator var3 = data.activeQuests.keySet().iterator(); - - while(var3.hasNext()) { - int id = (Integer)var3.next(); - IQuest quest = (IQuest)QuestController.Instance.quests.get(id); - if (quest != null) { - quests.add(quest); - } - } - - return (IQuest[])quests.toArray(new IQuest[quests.size()]); - } - - public IContainer getOpenContainer() { - return NpcAPI.Instance().getIContainer(((EntityPlayerMP)this.entity).openContainer); - } - - public void showCustomGui(ICustomGui gui) { - CustomGuiController.openGui(this, (ScriptGui) gui); - } - - public ICustomGui getCustomGui() { - return ((EntityPlayerMP)this.entity).openContainer instanceof ContainerCustomGui ? ((ContainerCustomGui)((EntityPlayerMP)this.entity).openContainer).customGui : null; - } - - public void closeGui() { - ((EntityPlayerMP)this.entity).closeContainer(); - GuiClosePacket.closeGUI(player, -1 , new NBTTagCompound()); - } - - public void showCustomOverlay(ICustomOverlay overlay) { - CustomGuiController.openOverlay(this, (ScriptOverlay) overlay); - } - - public void closeOverlay(int id) { - PacketHandler.Instance.sendToPlayer(new ScriptOverlayClosePacket(id), (EntityPlayerMP)this.entity); + return removed; } - public IOverlayHandler getOverlays() { - return this.getData().skinOverlays; - } + /** + * @param item Item to be added + * @param amount The amount of the item to be added + * @return Returns whether or not it gave the item succesfully + * @since 1.7.10c + */ + public boolean giveItem(IItemStack item, int amount) { + if (item != null && item.getMCItemStack() != null) { + item.setStackSize(amount); + boolean bool = this.player.inventory.addItemStackToInventory(item.getMCItemStack()); + this.updatePlayerInventory(); + return bool; + } else { + return false; + } + } - public IAnimationData getAnimationData() { - return this.getData().animationData; - } + /** + * @param id The items name + * @param damage The damage value + * @param amount The amount of the item to be added + * @return Returns whether or not it gave the item succesfully + * @since 1.7.10c + */ + public boolean giveItem(String id, int damage, int amount) { + Item item = (Item) Item.itemRegistry.getObject(id); + if (item == null) + return false; + return player.inventory.addItemStackToInventory(new ItemStack(item, amount, damage)); + } - public IQuest[] getFinishedQuests() { - PlayerQuestData data = this.getData().questData; - List quests = new ArrayList(); - Iterator var3 = data.finishedQuests.keySet().iterator(); + /** + * Same as the /spawnpoint command + * + * @param x The x position + * @param y The y position + * @param z The z position + */ + public void setSpawnpoint(int x, int y, int z) { + x = ValueUtil.clamp(x, -30000000, 30000000); + z = ValueUtil.clamp(z, -30000000, 30000000); + y = ValueUtil.clamp(y, 0, 256); + player.setSpawnChunk(new ChunkCoordinates(x, y, z), true); + } - while(var3.hasNext()) { - int id = (Integer)var3.next(); - IQuest quest = (IQuest)QuestController.Instance.quests.get(id); - if (quest != null) { - quests.add(quest); - } - } + public void setSpawnpoint(IPos pos) { + this.setSpawnpoint(pos.getX(), pos.getY(), pos.getZ()); + } - return (IQuest[])quests.toArray(new IQuest[quests.size()]); - } + public void resetSpawnpoint() { + player.setSpawnChunk(null, false); + } - public void setConqueredEnd(boolean conqueredEnd) { - this.player.playerConqueredTheEnd = conqueredEnd; - } + public void clearInventory() { + for (int i = 0; i < player.inventory.mainInventory.length; i++) player.inventory.mainInventory[i] = null; + for (int i = 0; i < player.inventory.armorInventory.length; i++) player.inventory.armorInventory[i] = null; + } - public boolean conqueredEnd() { - return this.player.playerConqueredTheEnd; - } + public void setRotation(float rotationYaw) { + NoppesUtilPlayer.teleportPlayer(player, player.posX, player.posY, player.posZ, rotationYaw, player.rotationPitch, player.dimension); + } + + public void setRotation(float rotationYaw, float rotationPitch) { + NoppesUtilPlayer.teleportPlayer(player, player.posX, player.posY, player.posZ, rotationYaw, rotationPitch, player.dimension); + } + + public void swingHand() { + NoppesUtilPlayer.swingPlayerArm(player); + } + + public void disableMouseInput(long time, int... buttonIds) { + NoppesUtilPlayer.disableMouseInput(player, time, buttonIds); + } + + public void stopUsingItem() { + player.stopUsingItem(); + } + + public void clearItemInUse() { + player.clearItemInUse(); + } + + public void playSound(String name, float volume, float pitch) { + player.playSound(name, volume, pitch); + } + + public void playSound(int id, ISound sound) { + NoppesUtilPlayer.playSoundTo(player, id, (ScriptSound) sound); + } + + public void playSound(ISound sound) { + NoppesUtilPlayer.playSoundTo(player, (ScriptSound) sound); + } + + public void stopSound(int id) { + NoppesUtilPlayer.stopSoundFor(player, id); + } + + public void pauseSounds() { + NoppesUtilPlayer.pauseSoundsFor(player); + } + + public void continueSounds() { + NoppesUtilPlayer.continueSoundsFor(player); + } + + public void stopSounds() { + NoppesUtilPlayer.stopSoundsFor(player); + } + + public void mountEntity(Entity ridingEntity) { + player.mountEntity(ridingEntity); + } + + public IEntity dropOneItem(boolean dropStack) { + return NpcAPI.Instance().getIEntity(player.dropOneItem(dropStack)); + } + + public boolean canHarvestBlock(IBlock block) { + return player.canHarvestBlock(block.getMCBlock()); + } + + public boolean interactWith(IEntity entity) { + return player.interactWith(entity.getMCEntity()); + } + + /** + * @param achievement The achievement id. For a complete list see http://minecraft.wiki/w/Achievements + * @return Returns whether or not the player has this achievement + */ + public boolean hasAchievement(String achievement) { + StatBase statbase = StatList.func_151177_a(achievement); + if (statbase == null || !(statbase instanceof Achievement)) { + return false; + } + return player.func_147099_x().hasAchievementUnlocked((Achievement) statbase); + } + + /** + * @param permission Bukkit/Cauldron permission + * @return Returns whether or not the player has the permission + */ + public boolean hasBukkitPermission(String permission) { + return CustomNpcsPermissions.hasPermissionString(player, permission); + } + + /** + * @return Returns the exp level + * @since 1.7.10c + */ + public int getExpLevel() { + return player.experienceLevel; + } + + /** + * @param level The new exp level you want to set + * @since 1.7.10c + */ + public void setExpLevel(int level) { + player.experienceLevel = level; + player.addExperienceLevel(0); + } + + /** + * Requires pixelmon to be installed + * + * @since 1.7.10d + */ + public IPixelmonPlayerData getPixelmonData() { + if (!PixelmonHelper.Enabled) + return null; + return new ScriptPixelmonPlayerData(player); + } + + public ITimers getTimers() { + return PlayerDataController.Instance.getPlayerData(player).timers; + } + + @Override + public IScreenSize getScreenSize() { + PlayerData data = PlayerDataController.Instance.getPlayerData(player); + return data.getScreenSize(); + } + + public void updatePlayerInventory() { + ((EntityPlayerMP) this.entity).inventoryContainer.detectAndSendChanges(); + PlayerData playerData = PlayerDataController.Instance.getPlayerData(player); + PlayerQuestData questData = playerData.questData; + Party playerParty = playerData.getPlayerParty(); + if (playerParty != null) + PartyController.Instance().checkQuestCompletion(playerParty, EnumQuestType.Item); + + questData.checkQuestCompletion(playerData, EnumQuestType.Item); + } + + @Deprecated + public boolean checkGUIOpen() { + NoppesUtilPlayer.isGUIOpen(player); + PlayerData data = PlayerDataController.Instance.getPlayerData(player); + return data.getGUIOpen(); + } + + @Deprecated + public ScriptDBCPlayer getDBCPlayer() { + return this instanceof ScriptDBCPlayer ? (ScriptDBCPlayer) this : null; + } + + public boolean blocking() { + return player.isBlocking(); + } + + public PlayerData getData() { + if (this.data == null) { + this.data = PlayerDataController.Instance.getPlayerData(player); + } + + return this.data; + } + + public boolean isScriptingDev() { + return ConfigScript.isScriptDev(player); + } + + public IQuest[] getActiveQuests() { + PlayerQuestData data = (PlayerQuestData) this.getData().getQuestData(); + List quests = new ArrayList(); + Iterator var3 = data.activeQuests.keySet().iterator(); + + while (var3.hasNext()) { + int id = (Integer) var3.next(); + IQuest quest = (IQuest) QuestController.Instance.quests.get(id); + if (quest != null) { + quests.add(quest); + } + } + + return (IQuest[]) quests.toArray(new IQuest[quests.size()]); + } + + public IContainer getOpenContainer() { + return NpcAPI.Instance().getIContainer(((EntityPlayerMP) this.entity).openContainer); + } + + public void showCustomGui(ICustomGui gui) { + CustomGuiController.openGui(this, (ScriptGui) gui); + } + + public ICustomGui getCustomGui() { + return ((EntityPlayerMP) this.entity).openContainer instanceof ContainerCustomGui ? ((ContainerCustomGui) ((EntityPlayerMP) this.entity).openContainer).customGui : null; + } + + public void closeGui() { + ((EntityPlayerMP) this.entity).closeContainer(); + GuiClosePacket.closeGUI(player, -1, new NBTTagCompound()); + } + + public void showCustomOverlay(ICustomOverlay overlay) { + CustomGuiController.openOverlay(this, (ScriptOverlay) overlay); + } + + public void closeOverlay(int id) { + PacketHandler.Instance.sendToPlayer(new ScriptOverlayClosePacket(id), (EntityPlayerMP) this.entity); + } + + public IOverlayHandler getOverlays() { + return this.getData().skinOverlays; + } + + public IAnimationData getAnimationData() { + return this.getData().animationData; + } + + public IQuest[] getFinishedQuests() { + PlayerQuestData data = this.getData().questData; + List quests = new ArrayList(); + Iterator var3 = data.finishedQuests.keySet().iterator(); + + while (var3.hasNext()) { + int id = (Integer) var3.next(); + IQuest quest = (IQuest) QuestController.Instance.quests.get(id); + if (quest != null) { + quests.add(quest); + } + } + + return (IQuest[]) quests.toArray(new IQuest[quests.size()]); + } + + public void setConqueredEnd(boolean conqueredEnd) { + this.player.playerConqueredTheEnd = conqueredEnd; + } + + public boolean conqueredEnd() { + return this.player.playerConqueredTheEnd; + } public IMagicData getMagicData() { return this.getData().magicData; diff --git a/src/main/java/noppes/npcs/scripted/entity/ScriptProjectile.java b/src/main/java/noppes/npcs/scripted/entity/ScriptProjectile.java index b6b32db12..538b46f5e 100644 --- a/src/main/java/noppes/npcs/scripted/entity/ScriptProjectile.java +++ b/src/main/java/noppes/npcs/scripted/entity/ScriptProjectile.java @@ -23,7 +23,7 @@ public class ScriptProjectile extends ScriptEntity extends ScriptEntity extends ScriptEntity extends ScriptEntity extends ScriptEntity extends ScriptLiving implements IVillager { - public ScriptVillager(T entity) { - super(entity); - } + public ScriptVillager(T entity) { + super(entity); + } @Override public int getProfession() { @@ -23,18 +23,17 @@ public class ScriptVillager extends ScriptLiving im } @Override - public IEntityLivingBase getCustomer() - { + public IEntityLivingBase getCustomer() { return (IEntityLivingBase) NpcAPI.Instance().getPlayer(entity.getCustomer().getCommandSenderName()); } - @Override - public int getType(){ - return EntityType.VILLAGER; - } + @Override + public int getType() { + return EntityType.VILLAGER; + } @Override - public boolean typeOf(int type){ + public boolean typeOf(int type) { return type == EntityType.VILLAGER || super.typeOf(type); } diff --git a/src/main/java/noppes/npcs/scripted/event/AnimationEvent.java b/src/main/java/noppes/npcs/scripted/event/AnimationEvent.java index 1690f8e57..d5e7797c4 100644 --- a/src/main/java/noppes/npcs/scripted/event/AnimationEvent.java +++ b/src/main/java/noppes/npcs/scripted/event/AnimationEvent.java @@ -68,7 +68,7 @@ public abstract class AnimationEvent extends CustomNPCsEvent implements IAnimati public FrameEvent(IAnimation animation, IFrame frame) { super(animation); this.frame = frame; - this.index = ((Animation)this.getAnimation()).frames.indexOf((Frame) this.frame); + this.index = ((Animation) this.getAnimation()).frames.indexOf((Frame) this.frame); } @Override diff --git a/src/main/java/noppes/npcs/scripted/event/BlockEvent.java b/src/main/java/noppes/npcs/scripted/event/BlockEvent.java index 3367a1699..b554270d8 100644 --- a/src/main/java/noppes/npcs/scripted/event/BlockEvent.java +++ b/src/main/java/noppes/npcs/scripted/event/BlockEvent.java @@ -13,7 +13,8 @@ import noppes.npcs.scripted.NpcAPI; public class BlockEvent extends CustomNPCsEvent implements IBlockEvent { public IBlock block; - public BlockEvent(IBlock block){ + + public BlockEvent(IBlock block) { this.block = block; } @@ -26,10 +27,11 @@ public class BlockEvent extends CustomNPCsEvent implements IBlockEvent { * fallenUpon */ @Cancelable - public static class EntityFallenUponEvent extends BlockEvent implements IBlockEvent.EntityFallenUponEvent{ + public static class EntityFallenUponEvent extends BlockEvent implements IBlockEvent.EntityFallenUponEvent { public final IEntity entity; public float distanceFallen; - public EntityFallenUponEvent(IBlock block, Entity entity, float distance){ + + public EntityFallenUponEvent(IBlock block, Entity entity, float distance) { super(block); this.distanceFallen = distance; this.entity = NpcAPI.Instance().getIEntity(entity); @@ -55,7 +57,7 @@ public class BlockEvent extends CustomNPCsEvent implements IBlockEvent { * interact */ @Cancelable - public static class InteractEvent extends BlockEvent implements IBlockEvent.InteractEvent{ + public static class InteractEvent extends BlockEvent implements IBlockEvent.InteractEvent { public final IPlayer player; public final float hitX, hitY, hitZ; @@ -106,8 +108,9 @@ public class BlockEvent extends CustomNPCsEvent implements IBlockEvent { /** * redstone */ - public static class RedstoneEvent extends BlockEvent implements IBlockEvent.RedstoneEvent{ + public static class RedstoneEvent extends BlockEvent implements IBlockEvent.RedstoneEvent { public final int prevPower, power; + public RedstoneEvent(IBlock block, int prevPower, int power) { super(block); this.power = power; @@ -134,7 +137,7 @@ public class BlockEvent extends CustomNPCsEvent implements IBlockEvent { /** * broken */ - public static class BreakEvent extends BlockEvent implements IBlockEvent.BreakEvent{ + public static class BreakEvent extends BlockEvent implements IBlockEvent.BreakEvent { public BreakEvent(IBlock block) { super(block); } @@ -149,7 +152,7 @@ public class BlockEvent extends CustomNPCsEvent implements IBlockEvent { * exploded */ @Cancelable - public static class ExplodedEvent extends BlockEvent implements IBlockEvent.ExplodedEvent{ + public static class ExplodedEvent extends BlockEvent implements IBlockEvent.ExplodedEvent { public ExplodedEvent(IBlock block) { super(block); } @@ -163,7 +166,7 @@ public class BlockEvent extends CustomNPCsEvent implements IBlockEvent { /** * rainFilled */ - public static class RainFillEvent extends BlockEvent implements IBlockEvent.RainFillEvent{ + public static class RainFillEvent extends BlockEvent implements IBlockEvent.RainFillEvent { public RainFillEvent(IBlock block) { super(block); } @@ -177,8 +180,9 @@ public class BlockEvent extends CustomNPCsEvent implements IBlockEvent { /** * neighborChanged */ - public static class NeighborChangedEvent extends BlockEvent implements IBlockEvent.NeighborChangedEvent{ + public static class NeighborChangedEvent extends BlockEvent implements IBlockEvent.NeighborChangedEvent { public final IPos changedPos; + public NeighborChangedEvent(IBlock block, IPos changedPos) { super(block); this.changedPos = changedPos; @@ -198,7 +202,7 @@ public class BlockEvent extends CustomNPCsEvent implements IBlockEvent { /** * init */ - public static class InitEvent extends BlockEvent implements IBlockEvent.InitEvent{ + public static class InitEvent extends BlockEvent implements IBlockEvent.InitEvent { public InitEvent(IBlock block) { super(block); } @@ -212,7 +216,7 @@ public class BlockEvent extends CustomNPCsEvent implements IBlockEvent { /** * tick */ - public static class UpdateEvent extends BlockEvent implements IBlockEvent.UpdateEvent{ + public static class UpdateEvent extends BlockEvent implements IBlockEvent.UpdateEvent { public UpdateEvent(IBlock block) { super(block); } @@ -226,8 +230,9 @@ public class BlockEvent extends CustomNPCsEvent implements IBlockEvent { /** * clicked */ - public static class ClickedEvent extends BlockEvent implements IBlockEvent.ClickedEvent{ + public static class ClickedEvent extends BlockEvent implements IBlockEvent.ClickedEvent { public final IPlayer player; + public ClickedEvent(IBlock block, EntityPlayer player) { super(block); this.player = (IPlayer) NpcAPI.Instance().getIEntity(player); @@ -248,8 +253,9 @@ public class BlockEvent extends CustomNPCsEvent implements IBlockEvent { * harvested */ @Cancelable - public static class HarvestedEvent extends BlockEvent implements IBlockEvent.HarvestedEvent{ + public static class HarvestedEvent extends BlockEvent implements IBlockEvent.HarvestedEvent { public final IPlayer player; + public HarvestedEvent(IBlock block, EntityPlayer player) { super(block); this.player = (IPlayer) NpcAPI.Instance().getIEntity(player); @@ -269,8 +275,9 @@ public class BlockEvent extends CustomNPCsEvent implements IBlockEvent { /** * collide */ - public static class CollidedEvent extends BlockEvent implements IBlockEvent.CollidedEvent{ + public static class CollidedEvent extends BlockEvent implements IBlockEvent.CollidedEvent { public final IEntity entity; + public CollidedEvent(IBlock block, Entity entity) { super(block); this.entity = NpcAPI.Instance().getIEntity(entity); @@ -290,7 +297,7 @@ public class BlockEvent extends CustomNPCsEvent implements IBlockEvent { /** * timer */ - public static class TimerEvent extends BlockEvent implements IBlockEvent.TimerEvent{ + public static class TimerEvent extends BlockEvent implements IBlockEvent.TimerEvent { public final int id; public TimerEvent(IBlock block, int id) { diff --git a/src/main/java/noppes/npcs/scripted/event/CustomGuiEvent.java b/src/main/java/noppes/npcs/scripted/event/CustomGuiEvent.java index 130a6657c..3aaba5788 100644 --- a/src/main/java/noppes/npcs/scripted/event/CustomGuiEvent.java +++ b/src/main/java/noppes/npcs/scripted/event/CustomGuiEvent.java @@ -151,7 +151,7 @@ public class CustomGuiEvent extends CustomNPCsEvent implements ICustomGuiEvent { public final int clickType; public SlotClickEvent(IPlayer player, ICustomGui gui, int slotId, IItemSlot slot, IItemStack stack, int dragType, int clickType) { - super(player,gui); + super(player, gui); this.slotId = slotId; this.stack = stack; this.dragType = dragType; diff --git a/src/main/java/noppes/npcs/scripted/event/CustomNPCsEvent.java b/src/main/java/noppes/npcs/scripted/event/CustomNPCsEvent.java index 1f95ec760..d5f40a29a 100644 --- a/src/main/java/noppes/npcs/scripted/event/CustomNPCsEvent.java +++ b/src/main/java/noppes/npcs/scripted/event/CustomNPCsEvent.java @@ -22,11 +22,13 @@ public class CustomNPCsEvent extends Event implements ICustomNPCsEvent { public CustomNPCsEvent() { } - public void setCancelled(boolean bo){ + public void setCancelled(boolean bo) { this.setCanceled(bo); } - public boolean isCancelled(){return this.isCanceled();} + public boolean isCancelled() { + return this.isCanceled(); + } @Cancelable public static class CNPCNaturalSpawnEvent extends CustomNPCsEvent implements ICustomNPCsEvent.CNPCNaturalSpawnEvent { @@ -95,7 +97,7 @@ public class CustomNPCsEvent extends Event implements ICustomNPCsEvent { public String[] args; public String replyMessage = ""; - public ScriptedCommandEvent(IWorld world, IPos pos, String senderName, String id, String[] args){ + public ScriptedCommandEvent(IWorld world, IPos pos, String senderName, String id, String[] args) { this.world = world; this.pos = pos; this.senderName = senderName; diff --git a/src/main/java/noppes/npcs/scripted/event/DialogEvent.java b/src/main/java/noppes/npcs/scripted/event/DialogEvent.java index 84ace0ee7..0d489279d 100644 --- a/src/main/java/noppes/npcs/scripted/event/DialogEvent.java +++ b/src/main/java/noppes/npcs/scripted/event/DialogEvent.java @@ -10,7 +10,7 @@ public class DialogEvent extends CustomNPCsEvent implements IDialogEvent { public final IDialog dialog; public final IPlayer player; - public DialogEvent(IPlayer player, IDialog dialog){ + public DialogEvent(IPlayer player, IDialog dialog) { this.dialog = dialog; this.player = player; } @@ -51,7 +51,7 @@ public class DialogEvent extends CustomNPCsEvent implements IDialogEvent { } public static class DialogClosed extends DialogEvent implements IDialogEvent.DialogClosed { - public DialogClosed(IPlayer player, IDialog dialog){ + public DialogClosed(IPlayer player, IDialog dialog) { super(player, dialog); } diff --git a/src/main/java/noppes/npcs/scripted/event/FactionEvent.java b/src/main/java/noppes/npcs/scripted/event/FactionEvent.java index 2741b669b..5898e37f5 100644 --- a/src/main/java/noppes/npcs/scripted/event/FactionEvent.java +++ b/src/main/java/noppes/npcs/scripted/event/FactionEvent.java @@ -10,7 +10,7 @@ public class FactionEvent extends CustomNPCsEvent implements IFactionEvent { public final IFaction faction; public final IPlayer player; - public FactionEvent(IPlayer player, IFaction faction){ + public FactionEvent(IPlayer player, IFaction faction) { this.faction = faction; this.player = player; } diff --git a/src/main/java/noppes/npcs/scripted/event/ForgeEvent.java b/src/main/java/noppes/npcs/scripted/event/ForgeEvent.java index 8caf450f6..a4704f5f1 100644 --- a/src/main/java/noppes/npcs/scripted/event/ForgeEvent.java +++ b/src/main/java/noppes/npcs/scripted/event/ForgeEvent.java @@ -61,7 +61,7 @@ public class ForgeEvent extends CustomNPCsEvent implements IForgeEvent { public static class InitEvent extends ForgeEvent implements IForgeEvent.InitEvent { public InitEvent() { - super((Event)null); + super((Event) null); } public String getHookName() { diff --git a/src/main/java/noppes/npcs/scripted/event/ItemEvent.java b/src/main/java/noppes/npcs/scripted/event/ItemEvent.java index 31d620583..78e562a9a 100644 --- a/src/main/java/noppes/npcs/scripted/event/ItemEvent.java +++ b/src/main/java/noppes/npcs/scripted/event/ItemEvent.java @@ -95,7 +95,7 @@ public class ItemEvent extends CustomNPCsEvent implements IItemEvent { public static class SpawnEvent extends ItemEvent implements IItemEvent.SpawnEvent { public final IEntity entity; - public SpawnEvent(IItemCustomizable item, IEntity entity){ + public SpawnEvent(IItemCustomizable item, IEntity entity) { super(item); this.entity = entity; } @@ -208,7 +208,7 @@ public class ItemEvent extends CustomNPCsEvent implements IItemEvent { public final IPlayer player; public final int duration; - public StartUsingItem(IItemCustomizable item, IPlayer player, int duration){ + public StartUsingItem(IItemCustomizable item, IPlayer player, int duration) { super(item); this.player = player; this.duration = duration; @@ -232,7 +232,7 @@ public class ItemEvent extends CustomNPCsEvent implements IItemEvent { public final IPlayer player; public final int duration; - public UsingItem(IItemCustomizable item, IPlayer player, int duration){ + public UsingItem(IItemCustomizable item, IPlayer player, int duration) { super(item); this.player = player; this.duration = duration; @@ -256,7 +256,7 @@ public class ItemEvent extends CustomNPCsEvent implements IItemEvent { public final IPlayer player; public final int duration; - public StopUsingItem(IItemCustomizable item, IPlayer player, int duration){ + public StopUsingItem(IItemCustomizable item, IPlayer player, int duration) { super(item); this.player = player; this.duration = duration; @@ -280,7 +280,7 @@ public class ItemEvent extends CustomNPCsEvent implements IItemEvent { public final IPlayer player; public final int duration; - public FinishUsingItem(IItemCustomizable item, IPlayer player, int duration){ + public FinishUsingItem(IItemCustomizable item, IPlayer player, int duration) { super(item); this.player = player; this.duration = duration; diff --git a/src/main/java/noppes/npcs/scripted/event/NpcEvent.java b/src/main/java/noppes/npcs/scripted/event/NpcEvent.java index 3533fb95f..0cc75792d 100644 --- a/src/main/java/noppes/npcs/scripted/event/NpcEvent.java +++ b/src/main/java/noppes/npcs/scripted/event/NpcEvent.java @@ -43,7 +43,7 @@ public class NpcEvent extends CustomNPCsEvent implements INpcEvent { return EnumScriptType.TIMER.function; } - public int getId(){ + public int getId() { return id; } } @@ -92,38 +92,38 @@ public class NpcEvent extends CustomNPCsEvent implements INpcEvent { /** * @return The source of the damage */ - public IEntity getSource(){ + public IEntity getSource() { return source; } - public IDamageSource getDamageSource(){ + public IDamageSource getDamageSource() { return damageSource; } /** * @return Returns the damage value */ - public float getDamage(){ + public float getDamage() { return damage; } /** * @param damage The new damage value */ - public void setDamage(float damage){ + public void setDamage(float damage) { this.damage = damage; } - public void setClearTarget(boolean bo){ + public void setClearTarget(boolean bo) { this.clearTarget = bo; this.clear = bo; } - public boolean getClearTarget(){ + public boolean getClearTarget() { return clearTarget && clear; } - public String getType(){ + public String getType() { return damageSource.getMCDamageSource().damageType; } } @@ -135,7 +135,7 @@ public class NpcEvent extends CustomNPCsEvent implements INpcEvent { public RangedLaunchedEvent(ICustomNpc npc, float damage, EntityLivingBase target) { super(npc); - this.target = (IEntityLivingBase)NpcAPI.Instance().getIEntity(target); + this.target = (IEntityLivingBase) NpcAPI.Instance().getIEntity(target); this.damage = damage; } @@ -147,14 +147,14 @@ public class NpcEvent extends CustomNPCsEvent implements INpcEvent { * @return The source of the damage * @deprecated */ - public IEntityLivingBase getTarget(){ + public IEntityLivingBase getTarget() { return target; } /** * @param damage The new damage value */ - public void setDamage(float damage){ + public void setDamage(float damage) { this.damage = damage; } @@ -162,14 +162,14 @@ public class NpcEvent extends CustomNPCsEvent implements INpcEvent { /** * @return Returns the damage value */ - public float getDamage(){ + public float getDamage() { return damage; } /** * @return Returns the damage type */ - public boolean isRange(){ + public boolean isRange() { return true; } } @@ -181,7 +181,7 @@ public class NpcEvent extends CustomNPCsEvent implements INpcEvent { public MeleeAttackEvent(ICustomNpc npc, float damage, EntityLivingBase target) { super(npc); - this.target = (IEntityLivingBase)NpcAPI.Instance().getIEntity(target); + this.target = (IEntityLivingBase) NpcAPI.Instance().getIEntity(target); this.damage = damage; } @@ -193,7 +193,7 @@ public class NpcEvent extends CustomNPCsEvent implements INpcEvent { * @return The source of the damage * @deprecated */ - public IEntityLivingBase getTarget(){ + public IEntityLivingBase getTarget() { return target; } @@ -201,21 +201,21 @@ public class NpcEvent extends CustomNPCsEvent implements INpcEvent { /** * @return Returns the damage value */ - public float getDamage(){ + public float getDamage() { return damage; } /** * @param damage The new damage value */ - public void setDamage(float damage){ + public void setDamage(float damage) { this.damage = damage; } /** * @return Returns the damage type */ - public boolean isRange(){ + public boolean isRange() { return false; } } @@ -226,7 +226,7 @@ public class NpcEvent extends CustomNPCsEvent implements INpcEvent { public SwingEvent(ICustomNpc npc, ItemStack itemStack) { super(npc); - this.itemStack = itemStack == null ? null : (IItemStack)NpcAPI.Instance().getIItemStack(itemStack); + this.itemStack = itemStack == null ? null : (IItemStack) NpcAPI.Instance().getIItemStack(itemStack); } public String getHookName() { @@ -246,7 +246,7 @@ public class NpcEvent extends CustomNPCsEvent implements INpcEvent { public KilledEntityEvent(ICustomNpc npc, EntityLivingBase entity) { super(npc); - this.entity = (IEntityLivingBase)NpcAPI.Instance().getIEntity(entity); + this.entity = (IEntityLivingBase) NpcAPI.Instance().getIEntity(entity); } public String getHookName() { @@ -288,16 +288,18 @@ public class NpcEvent extends CustomNPCsEvent implements INpcEvent { /** * @return The source of the damage */ - public IEntity getSource(){ + public IEntity getSource() { return source; } - public IDamageSource getDamageSource() { return damageSource; } + public IDamageSource getDamageSource() { + return damageSource; + } /** * @return Returns the damage type */ - public String getType(){ + public String getType() { return damageSource.getMCDamageSource().damageType; } @@ -324,7 +326,7 @@ public class NpcEvent extends CustomNPCsEvent implements INpcEvent { public InteractEvent(ICustomNpc npc, EntityPlayer player) { super(npc); - this.player = (IPlayer)NpcAPI.Instance().getIEntity(player); + this.player = (IPlayer) NpcAPI.Instance().getIEntity(player); } public String getHookName() { @@ -345,7 +347,7 @@ public class NpcEvent extends CustomNPCsEvent implements INpcEvent { public DialogEvent(ICustomNpc npc, EntityPlayer player, int id, int optionId, Dialog dialog) { super(npc); - this.player = (IPlayer)NpcAPI.Instance().getIEntity(player); + this.player = (IPlayer) NpcAPI.Instance().getIEntity(player); this.id = id; this.optionId = optionId; this.dialogObj = dialog; @@ -374,7 +376,7 @@ public class NpcEvent extends CustomNPCsEvent implements INpcEvent { /** * @deprecated */ - public boolean isClosing(){ + public boolean isClosing() { return true; } } @@ -387,7 +389,7 @@ public class NpcEvent extends CustomNPCsEvent implements INpcEvent { public DialogClosedEvent(ICustomNpc npc, EntityPlayer player, int id, int optionId, Dialog dialog) { super(npc); - this.player = (IPlayer)NpcAPI.Instance().getIEntity(player); + this.player = (IPlayer) NpcAPI.Instance().getIEntity(player); this.id = id; this.optionId = optionId; this.dialogObj = dialog; @@ -416,7 +418,7 @@ public class NpcEvent extends CustomNPCsEvent implements INpcEvent { /** * @deprecated */ - public boolean isClosing(){ + public boolean isClosing() { return true; } } @@ -458,14 +460,14 @@ public class NpcEvent extends CustomNPCsEvent implements INpcEvent { return EnumScriptType.TARGET.function; } - public void setTarget(IEntityLivingBase entity){ + public void setTarget(IEntityLivingBase entity) { this.entity = entity; } /** * @return The target source */ - public IEntityLivingBase getTarget(){ + public IEntityLivingBase getTarget() { return entity; } } diff --git a/src/main/java/noppes/npcs/scripted/event/PlayerEvent.java b/src/main/java/noppes/npcs/scripted/event/PlayerEvent.java index 24cc9a7e9..d8eb52158 100644 --- a/src/main/java/noppes/npcs/scripted/event/PlayerEvent.java +++ b/src/main/java/noppes/npcs/scripted/event/PlayerEvent.java @@ -117,7 +117,7 @@ public class PlayerEvent extends CustomNPCsEvent implements IPlayerEvent { public final int mouseWheel; public final boolean buttonDown; - public MouseClickedEvent(IPlayer player, int button, int mouseWheel, boolean buttonDown, boolean isCtrlPressed, boolean isAltPressed, boolean isShiftPressed, boolean isMetaPressed, int[] heldKeys){ + public MouseClickedEvent(IPlayer player, int button, int mouseWheel, boolean buttonDown, boolean isCtrlPressed, boolean isAltPressed, boolean isShiftPressed, boolean isMetaPressed, int[] heldKeys) { super(player); this.button = button; this.mouseWheel = mouseWheel; @@ -234,7 +234,7 @@ public class PlayerEvent extends CustomNPCsEvent implements IPlayerEvent { public final int fromDim; public final int toDim; - public ChangedDimension(IPlayer player, int fromDim, int toDim){ + public ChangedDimension(IPlayer player, int fromDim, int toDim) { super(player); this.fromDim = fromDim; this.toDim = toDim; @@ -376,7 +376,7 @@ public class PlayerEvent extends CustomNPCsEvent implements IPlayerEvent { public static class FallEvent extends PlayerEvent implements IPlayerEvent.FallEvent { public final float distance; - public FallEvent(IPlayer player, float distance){ + public FallEvent(IPlayer player, float distance) { super(player); this.distance = distance; } @@ -391,7 +391,7 @@ public class PlayerEvent extends CustomNPCsEvent implements IPlayerEvent { } public static class JumpEvent extends PlayerEvent implements IPlayerEvent.JumpEvent { - public JumpEvent(IPlayer player){ + public JumpEvent(IPlayer player) { super(player); } @@ -667,7 +667,7 @@ public class PlayerEvent extends CustomNPCsEvent implements IPlayerEvent { public final IItemStack item; public final int duration; - public StartUsingItem(IPlayer player, ItemStack item, int duration){ + public StartUsingItem(IPlayer player, ItemStack item, int duration) { super(player); this.item = NpcAPI.Instance().getIItemStack(item); @@ -692,7 +692,7 @@ public class PlayerEvent extends CustomNPCsEvent implements IPlayerEvent { public final IItemStack item; public final int duration; - public UsingItem(IPlayer player, ItemStack item, int duration){ + public UsingItem(IPlayer player, ItemStack item, int duration) { super(player); this.item = NpcAPI.Instance().getIItemStack(item); @@ -717,7 +717,7 @@ public class PlayerEvent extends CustomNPCsEvent implements IPlayerEvent { public final IItemStack item; public final int duration; - public StopUsingItem(IPlayer player, ItemStack item, int duration){ + public StopUsingItem(IPlayer player, ItemStack item, int duration) { super(player); this.item = NpcAPI.Instance().getIItemStack(item); @@ -741,7 +741,7 @@ public class PlayerEvent extends CustomNPCsEvent implements IPlayerEvent { public final IItemStack item; public final int duration; - public FinishUsingItem(IPlayer player, ItemStack item, int duration){ + public FinishUsingItem(IPlayer player, ItemStack item, int duration) { super(player); this.item = NpcAPI.Instance().getIItemStack(item); @@ -973,6 +973,7 @@ public class PlayerEvent extends CustomNPCsEvent implements IPlayerEvent { } } + public static class Ticked extends PlayerEvent.EffectEvent implements IPlayerEvent.EffectEvent.Ticked { public Ticked(IPlayer player, IPlayerEffect statusEffect) { @@ -980,6 +981,7 @@ public class PlayerEvent extends CustomNPCsEvent implements IPlayerEvent { } } + public static class Removed extends PlayerEvent.EffectEvent implements IPlayerEvent.EffectEvent.Removed { private final ExpirationType type; diff --git a/src/main/java/noppes/npcs/scripted/event/ProjectileEvent.java b/src/main/java/noppes/npcs/scripted/event/ProjectileEvent.java index e485396b5..3dd6e64f1 100644 --- a/src/main/java/noppes/npcs/scripted/event/ProjectileEvent.java +++ b/src/main/java/noppes/npcs/scripted/event/ProjectileEvent.java @@ -34,7 +34,7 @@ public class ProjectileEvent extends CustomNPCsEvent implements IProjectileEvent /** * projectileImpact */ - public static class ImpactEvent extends ProjectileEvent implements IProjectileEvent.ImpactEvent { + public static class ImpactEvent extends ProjectileEvent implements IProjectileEvent.ImpactEvent { /** * 0:entity, 1:block */ @@ -52,13 +52,13 @@ public class ProjectileEvent extends CustomNPCsEvent implements IProjectileEvent } public IEntity getEntity() { - if(type == 0) + if (type == 0) return (IEntity) target; return null; } public IBlock getBlock() { - if(type == 1) + if (type == 1) return (IBlock) target; return null; } diff --git a/src/main/java/noppes/npcs/scripted/gui/ScriptGuiButton.java b/src/main/java/noppes/npcs/scripted/gui/ScriptGuiButton.java index b0331658e..0dfcd7ac2 100644 --- a/src/main/java/noppes/npcs/scripted/gui/ScriptGuiButton.java +++ b/src/main/java/noppes/npcs/scripted/gui/ScriptGuiButton.java @@ -135,8 +135,8 @@ public class ScriptGuiButton extends ScriptGuiComponent implements IButton { nbt.setIntArray("size", new int[]{this.width, this.height}); } - nbt.setFloat("scale",this.scale); - nbt.setBoolean("enabled",this.enabled); + nbt.setFloat("scale", this.scale); + nbt.setBoolean("enabled", this.enabled); nbt.setString("label", this.label); if (this.hasTexture()) { diff --git a/src/main/java/noppes/npcs/scripted/gui/ScriptGuiComponent.java b/src/main/java/noppes/npcs/scripted/gui/ScriptGuiComponent.java index e992fadfc..8c6303875 100644 --- a/src/main/java/noppes/npcs/scripted/gui/ScriptGuiComponent.java +++ b/src/main/java/noppes/npcs/scripted/gui/ScriptGuiComponent.java @@ -90,14 +90,14 @@ public abstract class ScriptGuiComponent implements ICustomGuiComponent { nbt.setInteger("id", this.id); nbt.setIntArray("pos", new int[]{this.posX, this.posY}); nbt.setInteger("color", this.color); - nbt.setFloat("alpha",this.alpha); - nbt.setFloat("rotation",this.rotation); + nbt.setFloat("alpha", this.alpha); + nbt.setFloat("rotation", this.rotation); if (this.hoverText != null) { NBTTagList list = new NBTTagList(); String[] var3 = this.hoverText; int var4 = var3.length; - for(int var5 = 0; var5 < var4; ++var5) { + for (int var5 = 0; var5 < var4; ++var5) { String s = var3[var5]; if (s != null && !s.isEmpty()) { list.appendTag(new NBTTagString(s)); @@ -123,7 +123,7 @@ public abstract class ScriptGuiComponent implements ICustomGuiComponent { NBTTagList list = nbt.getTagList("hover", 8); String[] hoverText = new String[list.tagCount()]; - for(int i = 0; i < list.tagCount(); ++i) { + for (int i = 0; i < list.tagCount(); ++i) { hoverText[i] = list.getStringTagAt(i); } @@ -134,7 +134,7 @@ public abstract class ScriptGuiComponent implements ICustomGuiComponent { } public static ScriptGuiComponent createFromNBT(NBTTagCompound nbt) { - switch(nbt.getInteger("type")) { + switch (nbt.getInteger("type")) { case 0: return (new ScriptGuiButton()).fromNBT(nbt); case 1: diff --git a/src/main/java/noppes/npcs/scripted/gui/ScriptGuiLabel.java b/src/main/java/noppes/npcs/scripted/gui/ScriptGuiLabel.java index 8df58dc9a..eca84caeb 100644 --- a/src/main/java/noppes/npcs/scripted/gui/ScriptGuiLabel.java +++ b/src/main/java/noppes/npcs/scripted/gui/ScriptGuiLabel.java @@ -60,11 +60,11 @@ public class ScriptGuiLabel extends ScriptGuiComponent implements ILabel { return this; } - public boolean getShadow(){ + public boolean getShadow() { return this.shadow; } - public void setShadow(boolean shadow){ + public void setShadow(boolean shadow) { this.shadow = shadow; } @@ -77,7 +77,7 @@ public class ScriptGuiLabel extends ScriptGuiComponent implements ILabel { nbt.setString("label", this.label); nbt.setIntArray("size", new int[]{this.width, this.height}); nbt.setFloat("scale", this.scale); - nbt.setBoolean("shadow",this.shadow); + nbt.setBoolean("shadow", this.shadow); return nbt; } diff --git a/src/main/java/noppes/npcs/scripted/gui/ScriptGuiLine.java b/src/main/java/noppes/npcs/scripted/gui/ScriptGuiLine.java index b43482b91..037b0bda9 100644 --- a/src/main/java/noppes/npcs/scripted/gui/ScriptGuiLine.java +++ b/src/main/java/noppes/npcs/scripted/gui/ScriptGuiLine.java @@ -10,10 +10,10 @@ public class ScriptGuiLine extends ScriptGuiComponent implements ILine { int y2; int thickness = 2; - public ScriptGuiLine(){ + public ScriptGuiLine() { } - public ScriptGuiLine(int id, int x1, int y1, int x2, int y2){ + public ScriptGuiLine(int id, int x1, int y1, int x2, int y2) { this.setPos(x1, y1); this.setID(id); this.hoverText = new String[]{""}; @@ -24,7 +24,7 @@ public class ScriptGuiLine extends ScriptGuiComponent implements ILine { this.y2 = y2; } - public ScriptGuiLine(int id, int x1, int y1, int x2, int y2, int color, int thickness){ + public ScriptGuiLine(int id, int x1, int y1, int x2, int y2, int color, int thickness) { this.setPos(x1, y1); this.setID(id); this.hoverText = new String[]{""}; @@ -44,11 +44,11 @@ public class ScriptGuiLine extends ScriptGuiComponent implements ILine { public NBTTagCompound toNBT(NBTTagCompound nbt) { super.toNBT(nbt); - nbt.setInteger("X1",x1); - nbt.setInteger("Y1",y1); - nbt.setInteger("X2",x2); - nbt.setInteger("Y2",y2); - nbt.setInteger("Thickness",thickness); + nbt.setInteger("X1", x1); + nbt.setInteger("Y1", y1); + nbt.setInteger("X2", x2); + nbt.setInteger("Y2", y2); + nbt.setInteger("Thickness", thickness); return nbt; } @@ -64,35 +64,43 @@ public class ScriptGuiLine extends ScriptGuiComponent implements ILine { return this; } - public int getX1(){ + public int getX1() { return this.x1; } - public int getY1(){ + + public int getY1() { return this.y1; } - public int getX2(){ + + public int getX2() { return this.x2; } - public int getY2(){ + + public int getY2() { return this.y2; } - public int getThickness(){ + + public int getThickness() { return this.thickness; } - public void setX1(int x1){ + public void setX1(int x1) { this.x1 = x1; } - public void setY1(int y1){ + + public void setY1(int y1) { this.y1 = y1; } - public void setX2(int x2){ + + public void setX2(int x2) { this.x2 = x2; } - public void setY2(int y2){ + + public void setY2(int y2) { this.y2 = y2; } - public void setThickness(int thickness){ + + public void setThickness(int thickness) { this.thickness = thickness; } } diff --git a/src/main/java/noppes/npcs/scripted/gui/ScriptGuiScroll.java b/src/main/java/noppes/npcs/scripted/gui/ScriptGuiScroll.java index e6f39ab53..4f187b107 100644 --- a/src/main/java/noppes/npcs/scripted/gui/ScriptGuiScroll.java +++ b/src/main/java/noppes/npcs/scripted/gui/ScriptGuiScroll.java @@ -78,7 +78,7 @@ public class ScriptGuiScroll extends ScriptGuiComponent implements IScroll { String[] var3 = this.list; int var4 = var3.length; - for(int var5 = 0; var5 < var4; ++var5) { + for (int var5 = 0; var5 < var4; ++var5) { String s = var3[var5]; list.appendTag(new NBTTagString(s)); } @@ -98,7 +98,7 @@ public class ScriptGuiScroll extends ScriptGuiComponent implements IScroll { NBTTagList tagList = nbt.getTagList("list", 8); String[] list = new String[tagList.tagCount()]; - for(int i = 0; i < tagList.tagCount(); ++i) { + for (int i = 0; i < tagList.tagCount(); ++i) { list[i] = tagList.getStringTagAt(i); } diff --git a/src/main/java/noppes/npcs/scripted/item/ScriptCustomItem.java b/src/main/java/noppes/npcs/scripted/item/ScriptCustomItem.java index 1457302d8..7a3e2fdbf 100644 --- a/src/main/java/noppes/npcs/scripted/item/ScriptCustomItem.java +++ b/src/main/java/noppes/npcs/scripted/item/ScriptCustomItem.java @@ -79,10 +79,10 @@ public class ScriptCustomItem extends ScriptCustomizableItem implements IItemCus this.loaded = true; } - if(!this.isEnabled()) + if (!this.isEnabled()) return; - if(ScriptController.Instance.lastLoaded > lastInited){ + if (ScriptController.Instance.lastLoaded > lastInited) { lastInited = ScriptController.Instance.lastLoaded; if (!Objects.equals(hookName, EnumScriptType.INIT.function)) { EventHooks.onScriptItemInit(this); @@ -92,7 +92,7 @@ public class ScriptCustomItem extends ScriptCustomizableItem implements IItemCus for (int i = 0; i < this.scripts.size(); i++) { ScriptContainer script = this.scripts.get(i); if (!this.errored.contains(i)) { - if(script == null || script.errored || !script.hasCode()) + if (script == null || script.errored || !script.hasCode()) continue; script.run(hookName, event); @@ -152,35 +152,35 @@ public class ScriptCustomItem extends ScriptCustomizableItem implements IItemCus saveItemData(); } - public int getArmorType(){ + public int getArmorType() { return this.armorType; } - public void setIsTool(boolean isTool){ + public void setIsTool(boolean isTool) { this.isTool = isTool; saveItemData(); } - public boolean isTool(){ + public boolean isTool() { return this.isTool; } - public void setIsNormalItem(boolean normalItem){ + public void setIsNormalItem(boolean normalItem) { this.isNormalItem = normalItem; saveItemData(); } - public boolean isNormalItem(){ + public boolean isNormalItem() { return this.isNormalItem; } - public void setDigSpeed(int digSpeed){ + public void setDigSpeed(int digSpeed) { this.digSpeed = digSpeed; saveItemData(); } - public int getDigSpeed(){ + public int getDigSpeed() { return this.digSpeed; } @@ -198,11 +198,11 @@ public class ScriptCustomItem extends ScriptCustomizableItem implements IItemCus } public void setDurabilityValue(float value) { - this.durabilityValue = (double)value; + this.durabilityValue = (double) value; saveItemData(); } - public int getMaxItemUseDuration(){ + public int getMaxItemUseDuration() { return this.maxItemUseDuration; } @@ -220,11 +220,11 @@ public class ScriptCustomItem extends ScriptCustomizableItem implements IItemCus return this.itemUseAction; } - public int getEnchantability(){ + public int getEnchantability() { return this.enchantability; } - public void setEnchantability(int enchantability){ + public void setEnchantability(int enchantability) { this.enchantability = enchantability; saveItemData(); } @@ -258,8 +258,8 @@ public class ScriptCustomItem extends ScriptCustomizableItem implements IItemCus public NBTTagCompound getItemNBT(NBTTagCompound compound) { super.getItemNBT(compound); - compound.setDouble("DurabilityValue",this.durabilityValue); - compound.setInteger("MaxStackSize",this.stackSize); + compound.setDouble("DurabilityValue", this.durabilityValue); + compound.setInteger("MaxStackSize", this.stackSize); compound.setBoolean("IsTool", this.isTool); compound.setBoolean("IsNormalItem", this.isNormalItem); diff --git a/src/main/java/noppes/npcs/scripted/item/ScriptCustomizableItem.java b/src/main/java/noppes/npcs/scripted/item/ScriptCustomizableItem.java index c440d7b0a..224427c12 100644 --- a/src/main/java/noppes/npcs/scripted/item/ScriptCustomizableItem.java +++ b/src/main/java/noppes/npcs/scripted/item/ScriptCustomizableItem.java @@ -35,8 +35,8 @@ public abstract class ScriptCustomizableItem extends ScriptItemStack implements return this.itemDisplay.texture == null ? "" : this.itemDisplay.texture; } - public void setTexture(String texture){ - if(texture == null) + public void setTexture(String texture) { + if (texture == null) texture = ""; this.itemDisplay.texture = texture; saveItemData(); @@ -70,28 +70,28 @@ public abstract class ScriptCustomizableItem extends ScriptItemStack implements } - public void setRotation(Float rotationX, Float rotationY, Float rotationZ){ + public void setRotation(Float rotationX, Float rotationY, Float rotationZ) { this.itemDisplay.rotationX = rotationX; this.itemDisplay.rotationY = rotationY; this.itemDisplay.rotationZ = rotationZ; saveItemData(); } - public void setRotationRate(Float rotationXRate, Float rotationYRate, Float rotationZRate){ + public void setRotationRate(Float rotationXRate, Float rotationYRate, Float rotationZRate) { this.itemDisplay.rotationXRate = rotationXRate; this.itemDisplay.rotationYRate = rotationYRate; this.itemDisplay.rotationZRate = rotationZRate; saveItemData(); } - public void setScale(Float scaleX, Float scaleY, Float scaleZ){ + public void setScale(Float scaleX, Float scaleY, Float scaleZ) { this.itemDisplay.scaleX = scaleX; this.itemDisplay.scaleY = scaleY; this.itemDisplay.scaleZ = scaleZ; saveItemData(); } - public void setTranslate(Float translateX, Float translateY, Float translateZ){ + public void setTranslate(Float translateX, Float translateY, Float translateZ) { this.itemDisplay.translateX = translateX; this.itemDisplay.translateY = translateY; this.itemDisplay.translateZ = translateZ; @@ -167,7 +167,7 @@ public abstract class ScriptCustomizableItem extends ScriptItemStack implements public void loadItemData() { NBTTagCompound c = this.item.getTagCompound(); - if (c != null && !c.getCompoundTag("ItemData").hasNoTags()){ + if (c != null && !c.getCompoundTag("ItemData").hasNoTags()) { this.setItemNBT(c.getCompoundTag("ItemData")); } } diff --git a/src/main/java/noppes/npcs/scripted/item/ScriptItemBook.java b/src/main/java/noppes/npcs/scripted/item/ScriptItemBook.java index 3a43dda9e..06f5dfd3f 100644 --- a/src/main/java/noppes/npcs/scripted/item/ScriptItemBook.java +++ b/src/main/java/noppes/npcs/scripted/item/ScriptItemBook.java @@ -19,11 +19,11 @@ public class ScriptItemBook extends ScriptItemStack implements IItemBook { List list = new ArrayList(); NBTTagList pages = this.getTag().getTagList("pages", 8); - for(int i = 0; i < pages.tagCount(); ++i) { + for (int i = 0; i < pages.tagCount(); ++i) { list.add(pages.getStringTagAt(i)); } - return (String[])list.toArray(new String[list.size()]); + return (String[]) list.toArray(new String[list.size()]); } public void setText(String[] pages) { @@ -32,7 +32,7 @@ public class ScriptItemBook extends ScriptItemStack implements IItemBook { String[] var3 = pages; int var4 = pages.length; - for(int var5 = 0; var5 < var4; ++var5) { + for (int var5 = 0; var5 < var4; ++var5) { String page = var3[var5]; list.appendTag(new NBTTagString(page)); } @@ -46,7 +46,7 @@ public class ScriptItemBook extends ScriptItemStack implements IItemBook { } public void setAuthor(String author) { - this.getTag().setString("author",author); + this.getTag().setString("author", author); } public String getTitle() { @@ -54,7 +54,7 @@ public class ScriptItemBook extends ScriptItemStack implements IItemBook { } public void setTitle(String title) { - this.getTag().setString("title",title); + this.getTag().setString("title", title); } private NBTTagCompound getTag() { diff --git a/src/main/java/noppes/npcs/scripted/item/ScriptItemStack.java b/src/main/java/noppes/npcs/scripted/item/ScriptItemStack.java index 11920d809..1ec97af1f 100644 --- a/src/main/java/noppes/npcs/scripted/item/ScriptItemStack.java +++ b/src/main/java/noppes/npcs/scripted/item/ScriptItemStack.java @@ -28,301 +28,301 @@ import java.util.List; import java.util.Map; public class ScriptItemStack implements IItemStack { - public ItemStack item; + public ItemStack item; - public ScriptItemStack(ItemStack item){ - this.item = item; - } + public ScriptItemStack(ItemStack item) { + this.item = item; + } - public int getType() { - if (this.item.getItem() instanceof IPlantable) { - return 5; - } else { - return this.item.getItem() instanceof ItemSword ? 4 : 0; - } - } + public int getType() { + if (this.item.getItem() instanceof IPlantable) { + return 5; + } else { + return this.item.getItem() instanceof ItemSword ? 4 : 0; + } + } - /** - * @return The minecraft name for this item - */ - public String getName(){ - return Item.itemRegistry.getNameForObject(item.getItem()); - } + /** + * @return The minecraft name for this item + */ + public String getName() { + return Item.itemRegistry.getNameForObject(item.getItem()); + } - /** - * @return Returns the stacksize - */ - public int getStackSize(){ - return item.stackSize; - } + /** + * @return Returns the stacksize + */ + public int getStackSize() { + return item.stackSize; + } - /** - * @return Return whether or not the item has a custom name - */ - public boolean hasCustomName(){ - return item.hasDisplayName(); - } + /** + * @return Return whether or not the item has a custom name + */ + public boolean hasCustomName() { + return item.hasDisplayName(); + } - /** - * @param name The custom name this item will get - */ - public void setCustomName(String name){ - item.setStackDisplayName(name); - } + /** + * @param name The custom name this item will get + */ + public void setCustomName(String name) { + item.setStackDisplayName(name); + } - /** - * @return Return the ingame displayed name. This is either the item name or the custom name if it has one. - */ - public String getDisplayName(){ - return item.getDisplayName(); - } + /** + * @return Return the ingame displayed name. This is either the item name or the custom name if it has one. + */ + public String getDisplayName() { + return item.getDisplayName(); + } - /** - * @return Get the items ingame name. Use this incase the item ingame has custom name and you want the original name. - */ - public String getItemName(){ - return item.getItem().getItemStackDisplayName(item); - } + /** + * @return Get the items ingame name. Use this incase the item ingame has custom name and you want the original name. + */ + public String getItemName() { + return item.getItem().getItemStackDisplayName(item); + } - public int getMaxStackSize() { - return this.item.getMaxStackSize(); - } + public int getMaxStackSize() { + return this.item.getMaxStackSize(); + } - /** - * @param size The size of the itemstack. A number between 1 and 64 - */ - public void setStackSize(int size){ - if(size < 0) - size = 1; - else if(size > 64) - size = 64; - item.stackSize = size; - } + /** + * @param size The size of the itemstack. A number between 1 and 64 + */ + public void setStackSize(int size) { + if (size < 0) + size = 1; + else if (size > 64) + size = 64; + item.stackSize = size; + } - /** - * @return Returns the item damage of this item. For tools this is the durability for other items the color and more. - */ - public int getItemDamage(){ - return item.getItemDamage(); - } + /** + * @return Returns the item damage of this item. For tools this is the durability for other items the color and more. + */ + public int getItemDamage() { + return item.getItemDamage(); + } - /** - * @param value The value to be set as item damage. For tools this is the durability for other items the color and more. - */ - public void setItemDamage(int value){ - item.setItemDamage(value); - } + /** + * @param value The value to be set as item damage. For tools this is the durability for other items the color and more. + */ + public void setItemDamage(int value) { + item.setItemDamage(value); + } - /** - * @param key The key of this NBTTag - * @param value The value to be stored. Can be a Number or String - */ - public void setTag(String key, Object value){ - if(value instanceof Number) - getTag().setDouble(key, ((Number) value).doubleValue()); - else if(value instanceof String) - getTag().setString(key, (String) value); + /** + * @param key The key of this NBTTag + * @param value The value to be stored. Can be a Number or String + */ + public void setTag(String key, Object value) { + if (value instanceof Number) + getTag().setDouble(key, ((Number) value).doubleValue()); + else if (value instanceof String) + getTag().setString(key, (String) value); - } + } - /** - * @param key The key of the NBTTag - * @return Returns whether or not the key exists - */ - public boolean hasTag(String key){ - if(item.stackTagCompound == null) - return false; - return getTag().hasKey(key); - } + /** + * @param key The key of the NBTTag + * @return Returns whether or not the key exists + */ + public boolean hasTag(String key) { + if (item.stackTagCompound == null) + return false; + return getTag().hasKey(key); + } - /** - * @param key The key of the NBTTag - * @return Returns the value associated with the key. Returns null of it doesnt exist - */ - public Object getTag(String key){ - if(item.stackTagCompound == null) - return null; + /** + * @param key The key of the NBTTag + * @return Returns the value associated with the key. Returns null of it doesnt exist + */ + public Object getTag(String key) { + if (item.stackTagCompound == null) + return null; - NBTBase tag = getTag().getTag(key); - if(tag == null) - return null; - if(tag instanceof NBTPrimitive) - return ((NBTPrimitive)tag).func_150286_g(); - if(tag instanceof NBTTagString) - return ((NBTTagString)tag).func_150285_a_(); - return tag; - } + NBTBase tag = getTag().getTag(key); + if (tag == null) + return null; + if (tag instanceof NBTPrimitive) + return ((NBTPrimitive) tag).func_150286_g(); + if (tag instanceof NBTTagString) + return ((NBTTagString) tag).func_150285_a_(); + return tag; + } - public INbt removeTags() { - ScriptNbt nbt = (ScriptNbt) NpcAPI.Instance().getINbt(item.stackTagCompound); - item.stackTagCompound = null; - return nbt; - } + public INbt removeTags() { + ScriptNbt nbt = (ScriptNbt) NpcAPI.Instance().getINbt(item.stackTagCompound); + item.stackTagCompound = null; + return nbt; + } - public boolean isEnchanted(){ - return item.isItemEnchanted(); - } + public boolean isEnchanted() { + return item.isItemEnchanted(); + } - /** - * @since 1.7.10d - * @param id The enchantment id - * @return - */ - public boolean hasEnchant(int id){ - if(!isEnchanted()) - return false; - NBTTagList list = item.getEnchantmentTagList(); - for(int i = 0; i < list.tagCount(); i++){ - NBTTagCompound compound = list.getCompoundTagAt(i); - if(compound.getShort("id") == id) - return true; - } - return false; - } + /** + * @param id The enchantment id + * @return + * @since 1.7.10d + */ + public boolean hasEnchant(int id) { + if (!isEnchanted()) + return false; + NBTTagList list = item.getEnchantmentTagList(); + for (int i = 0; i < list.tagCount(); i++) { + NBTTagCompound compound = list.getCompoundTagAt(i); + if (compound.getShort("id") == id) + return true; + } + return false; + } - public void addEnchant(int id, int strength) { - Enchantment ench = Enchantment.enchantmentsList[id]; - if (ench == null) { - throw new CustomNPCsException("Unknown enchant id:" + id, new Object[0]); - } else { - this.item.addEnchantment(ench, strength); - } - } + public void addEnchant(int id, int strength) { + Enchantment ench = Enchantment.enchantmentsList[id]; + if (ench == null) { + throw new CustomNPCsException("Unknown enchant id:" + id, new Object[0]); + } else { + this.item.addEnchantment(ench, strength); + } + } - public void setAttribute(String name, double value) { - NBTTagCompound compound = this.item.getTagCompound(); - if (compound == null) { - this.item.setTagCompound(compound = new NBTTagCompound()); - } + public void setAttribute(String name, double value) { + NBTTagCompound compound = this.item.getTagCompound(); + if (compound == null) { + this.item.setTagCompound(compound = new NBTTagCompound()); + } - NBTTagList nbttaglist = compound.getTagList("AttributeModifiers", 10); - NBTTagList newList = new NBTTagList(); + NBTTagList nbttaglist = compound.getTagList("AttributeModifiers", 10); + NBTTagList newList = new NBTTagList(); - NBTTagCompound nbttagcompound; - for(int i = 0; i < nbttaglist.tagCount(); ++i) { - nbttagcompound = nbttaglist.getCompoundTagAt(i); - if (!nbttagcompound.getString("AttributeName").equals(name)) { - newList.appendTag(nbttagcompound); - } - } + NBTTagCompound nbttagcompound; + for (int i = 0; i < nbttaglist.tagCount(); ++i) { + nbttagcompound = nbttaglist.getCompoundTagAt(i); + if (!nbttagcompound.getString("AttributeName").equals(name)) { + newList.appendTag(nbttagcompound); + } + } - if (value != 0.0D) { - AttributeModifier attributeModifier = new AttributeModifier(name, value, 0); - nbttagcompound = new NBTTagCompound(); - nbttagcompound.setString("Name", attributeModifier.getName()); - nbttagcompound.setDouble("Amount", attributeModifier.getAmount()); - nbttagcompound.setInteger("Operation", attributeModifier.getOperation()); - nbttagcompound.setLong("UUIDMost", attributeModifier.getID().getMostSignificantBits()); - nbttagcompound.setLong("UUIDLeast", attributeModifier.getID().getLeastSignificantBits()); - nbttagcompound.setString("AttributeName", name); - newList.appendTag(nbttagcompound); - } + if (value != 0.0D) { + AttributeModifier attributeModifier = new AttributeModifier(name, value, 0); + nbttagcompound = new NBTTagCompound(); + nbttagcompound.setString("Name", attributeModifier.getName()); + nbttagcompound.setDouble("Amount", attributeModifier.getAmount()); + nbttagcompound.setInteger("Operation", attributeModifier.getOperation()); + nbttagcompound.setLong("UUIDMost", attributeModifier.getID().getMostSignificantBits()); + nbttagcompound.setLong("UUIDLeast", attributeModifier.getID().getLeastSignificantBits()); + nbttagcompound.setString("AttributeName", name); + newList.appendTag(nbttagcompound); + } - compound.setTag("AttributeModifiers", newList); - } + compound.setTag("AttributeModifiers", newList); + } - public double getAttribute(String name) { - NBTTagCompound compound = this.item.getTagCompound(); - if (compound == null) { - return 0.0D; - } else { - Multimap map = this.item.getAttributeModifiers(); - Iterator var4 = map.entries().iterator(); + public double getAttribute(String name) { + NBTTagCompound compound = this.item.getTagCompound(); + if (compound == null) { + return 0.0D; + } else { + Multimap map = this.item.getAttributeModifiers(); + Iterator var4 = map.entries().iterator(); - while(var4.hasNext()) { - Map.Entry entry = (Map.Entry)var4.next(); - if (((String)entry.getKey()).equals(name)) { - AttributeModifier mod = (AttributeModifier)entry.getValue(); - return mod.getAmount(); - } - } + while (var4.hasNext()) { + Map.Entry entry = (Map.Entry) var4.next(); + if (((String) entry.getKey()).equals(name)) { + AttributeModifier mod = (AttributeModifier) entry.getValue(); + return mod.getAmount(); + } + } - return 0.0D; - } - } + return 0.0D; + } + } - public String[] getLore() { - if (this.item.getTagCompound() != null) { - NBTTagCompound compound = this.item.getTagCompound().getCompoundTag("display"); - if(compound != null && compound.func_150299_b("Lore") == 9) { - NBTTagList nbttaglist = compound.getTagList("Lore", 8); - if (nbttaglist.tagCount() > 0) { - List lore = new ArrayList(); + public String[] getLore() { + if (this.item.getTagCompound() != null) { + NBTTagCompound compound = this.item.getTagCompound().getCompoundTag("display"); + if (compound != null && compound.func_150299_b("Lore") == 9) { + NBTTagList nbttaglist = compound.getTagList("Lore", 8); + if (nbttaglist.tagCount() > 0) { + List lore = new ArrayList(); - for (int i = 0; i < nbttaglist.tagCount(); ++i) { - lore.add(nbttaglist.getStringTagAt(i)); - } + for (int i = 0; i < nbttaglist.tagCount(); ++i) { + lore.add(nbttaglist.getStringTagAt(i)); + } - return (String[]) ((String[]) lore.toArray(new String[lore.size()])); - } - } - } - return new String[0]; - } + return (String[]) ((String[]) lore.toArray(new String[lore.size()])); + } + } + } + return new String[0]; + } - public boolean hasLore() { - if (this.item.getTagCompound() != null) { - NBTTagCompound compound = this.item.getTagCompound().getCompoundTag("display"); - if (compound != null && compound.func_150299_b("Lore") == 9) { - NBTTagList nbttaglist = compound.getTagList("Lore", 8); - return nbttaglist.tagCount() > 0; - } - } - return false; - } + public boolean hasLore() { + if (this.item.getTagCompound() != null) { + NBTTagCompound compound = this.item.getTagCompound().getCompoundTag("display"); + if (compound != null && compound.func_150299_b("Lore") == 9) { + NBTTagList nbttaglist = compound.getTagList("Lore", 8); + return nbttaglist.tagCount() > 0; + } + } + return false; + } - public void setLore(String[] lore) { - NBTTagCompound compound = this.item.getTagCompound(); - if (compound == null) { - this.item.setTagCompound(compound = new NBTTagCompound()); - } + public void setLore(String[] lore) { + NBTTagCompound compound = this.item.getTagCompound(); + if (compound == null) { + this.item.setTagCompound(compound = new NBTTagCompound()); + } NBTTagCompound display = compound.getCompoundTag("display"); - if(lore == null || lore.length == 0) { + if (lore == null || lore.length == 0) { display.removeTag("Lore"); return; } NBTTagList nbtlist = new NBTTagList(); - for(String s : lore) { + for (String s : lore) { nbtlist.appendTag(new NBTTagString(s)); } display.setTag("Lore", nbtlist); compound.setTag("display", display); - } + } - public boolean hasAttribute(String name) { - NBTTagCompound compound = this.item.getTagCompound(); - if (compound == null) { - return false; - } else { - NBTTagList nbttaglist = compound.getTagList("AttributeModifiers", 10); + public boolean hasAttribute(String name) { + NBTTagCompound compound = this.item.getTagCompound(); + if (compound == null) { + return false; + } else { + NBTTagList nbttaglist = compound.getTagList("AttributeModifiers", 10); - for(int i = 0; i < nbttaglist.tagCount(); ++i) { - NBTTagCompound c = nbttaglist.getCompoundTagAt(i); - if (c.getString("AttributeName").equals(name)) { - return true; - } - } + for (int i = 0; i < nbttaglist.tagCount(); ++i) { + NBTTagCompound c = nbttaglist.getCompoundTagAt(i); + if (c.getString("AttributeName").equals(name)) { + return true; + } + } - return false; - } - } + return false; + } + } - private static ScriptItemStack createNew(ItemStack item){ - if(item == null) + private static ScriptItemStack createNew(ItemStack item) { + if (item == null) return null; if (item.getItem() instanceof ItemLinked) { return new ScriptLinkedItem(item); } - if(item.getItem() instanceof ItemScripted) { + if (item.getItem() instanceof ItemScripted) { return new ScriptCustomItem(item); } - if(item.getItem() == Items.written_book || item.getItem() == Items.writable_book || item.getItem() instanceof ItemWritableBook || item.getItem() instanceof ItemEditableBook) + if (item.getItem() == Items.written_book || item.getItem() == Items.writable_book || item.getItem() instanceof ItemWritableBook || item.getItem() instanceof ItemEditableBook) return new ScriptItemBook(item); - if(item.getItem() instanceof ItemArmor) + if (item.getItem() instanceof ItemArmor) return new ScriptItemArmor(item); if (item.getItem() instanceof ItemBlock) return new ScriptItemBlock(item); @@ -336,112 +336,114 @@ public class ScriptItemStack implements IItemStack { } @Override - public int getMaxItemDamage(){ + public int getMaxItemDamage() { return item.getMaxDamage(); } - /** - * @since 1.7.10d - * @return Returns whether this item is a book - */ - public boolean isWrittenBook(){ - return item.getItem() == Items.written_book || item.getItem() == Items.writable_book; - } + /** + * @return Returns whether this item is a book + * @since 1.7.10d + */ + public boolean isWrittenBook() { + return item.getItem() == Items.written_book || item.getItem() == Items.writable_book; + } - /** - * @since 1.7.10d - * @return Returns the books title - */ - public String getBookTitle(){ - return item.getTagCompound().getString("title"); - } + /** + * @return Returns the books title + * @since 1.7.10d + */ + public String getBookTitle() { + return item.getTagCompound().getString("title"); + } - /** - * @since 1.7.10d - * @return Returns the books author - */ - public String getBookAuthor(){ - return item.getTagCompound().getString("author"); - } + /** + * @return Returns the books author + * @since 1.7.10d + */ + public String getBookAuthor() { + return item.getTagCompound().getString("author"); + } - /** - * @since 1.7.10d - * @return If the item is a book, returns a string array with book pages - */ - public String[] getBookText(){ - if(!isWrittenBook()) - return null; - List list = new ArrayList(); + /** + * @return If the item is a book, returns a string array with book pages + * @since 1.7.10d + */ + public String[] getBookText() { + if (!isWrittenBook()) + return null; + List list = new ArrayList(); NBTTagList pages = item.getTagCompound().getTagList("pages", 8); - for (int i = 0; i < pages.tagCount(); ++i){ - list.add(pages.getStringTagAt(i)); + for (int i = 0; i < pages.tagCount(); ++i) { + list.add(pages.getStringTagAt(i)); } return list.toArray(new String[list.size()]); - } + } - private NBTTagCompound getTag(){ - if(item.stackTagCompound == null) - item.stackTagCompound = new NBTTagCompound(); - return item.stackTagCompound; - } + private NBTTagCompound getTag() { + if (item.stackTagCompound == null) + item.stackTagCompound = new NBTTagCompound(); + return item.stackTagCompound; + } - /** - * @return Returns whether or not this item is a block - */ - public boolean isBlock(){ - Block block = Block.getBlockFromItem(item.getItem()); - if(block == null || block == Blocks.air) - return false; - return true; - } + /** + * @return Returns whether or not this item is a block + */ + public boolean isBlock() { + Block block = Block.getBlockFromItem(item.getItem()); + if (block == null || block == Blocks.air) + return false; + return true; + } - public boolean isFood() { - return item.getItem() instanceof ItemFood; - } + public boolean isFood() { + return item.getItem() instanceof ItemFood; + } - public int getFoodPoints() { - if (isFood()) return ((ItemFood)item.getItem()).func_150905_g(item); - return -1; - } + public int getFoodPoints() { + if (isFood()) return ((ItemFood) item.getItem()).func_150905_g(item); + return -1; + } - public INbt getNbt() { - NBTTagCompound compound = this.item.getTagCompound(); - if(compound == null) { - this.item.setTagCompound(compound = new NBTTagCompound()); - } + public INbt getNbt() { + NBTTagCompound compound = this.item.getTagCompound(); + if (compound == null) { + this.item.setTagCompound(compound = new NBTTagCompound()); + } - return NpcAPI.Instance().getINbt(compound); - } + return NpcAPI.Instance().getINbt(compound); + } - public INbt getItemNbt() { - NBTTagCompound compound = new NBTTagCompound(); - this.item.writeToNBT(compound); - return NpcAPI.Instance().getINbt(compound); - } + public INbt getItemNbt() { + NBTTagCompound compound = new NBTTagCompound(); + this.item.writeToNBT(compound); + return NpcAPI.Instance().getINbt(compound); + } - public NBTTagCompound getMCNbt() { - NBTTagCompound compound = new NBTTagCompound(); - this.item.writeToNBT(compound); - return compound; - } + public NBTTagCompound getMCNbt() { + NBTTagCompound compound = new NBTTagCompound(); + this.item.writeToNBT(compound); + return compound; + } - public void setMCNbt(NBTTagCompound compound) {} + public void setMCNbt(NBTTagCompound compound) { + } - /** - * No support is given for this method. Dont use if you dont know what you are doing. - * @return Minecraft ItemStack - */ - public ItemStack getMCItemStack() { - return item; - } + /** + * No support is given for this method. Dont use if you dont know what you are doing. + * + * @return Minecraft ItemStack + */ + public ItemStack getMCItemStack() { + return item; + } - public int itemHash() { - return item.hashCode(); - } + public int itemHash() { + return item.hashCode(); + } - public boolean equals(Object object) { - return object instanceof ScriptItemStack && ((ScriptItemStack) object).getMCItemStack().equals(this.getMCItemStack()); - } + public boolean equals(Object object) { + return object instanceof ScriptItemStack && ((ScriptItemStack) object).getMCItemStack().equals(this.getMCItemStack()); + } @Override public boolean compare(IItemStack item, boolean ignoreNBT) { diff --git a/src/main/java/noppes/npcs/scripted/item/ScriptLinkedItem.java b/src/main/java/noppes/npcs/scripted/item/ScriptLinkedItem.java index 41c63da15..82491f231 100644 --- a/src/main/java/noppes/npcs/scripted/item/ScriptLinkedItem.java +++ b/src/main/java/noppes/npcs/scripted/item/ScriptLinkedItem.java @@ -11,6 +11,7 @@ public class ScriptLinkedItem extends ScriptCustomizableItem implements IItemLin public LinkedItem linkedItem = new LinkedItem(); public double durabilityValue = 1.0D; public int linkedVersion = 1; + public ScriptLinkedItem(ItemStack item) { super(item); setDefaults(); @@ -26,7 +27,7 @@ public class ScriptLinkedItem extends ScriptCustomizableItem implements IItemLin saveItemData(); } - public void setDefaults(){ + public void setDefaults() { this.itemDisplay.texture = null; this.itemDisplay.translateX = null; this.itemDisplay.translateY = null; @@ -51,7 +52,7 @@ public class ScriptLinkedItem extends ScriptCustomizableItem implements IItemLin @Override public INpcScriptHandler getScriptHandler() { - if(this.getLinkedItem() == null) + if (this.getLinkedItem() == null) return null; return this.getLinkedItem().getScriptHandler(); } @@ -192,7 +193,7 @@ public class ScriptLinkedItem extends ScriptCustomizableItem implements IItemLin public void loadItemData() { NBTTagCompound c = this.item.getTagCompound(); - if (c != null && !c.getCompoundTag("ItemData").hasNoTags()){ + if (c != null && !c.getCompoundTag("ItemData").hasNoTags()) { this.setItemNBT(c.getCompoundTag("ItemData")); } } diff --git a/src/main/java/noppes/npcs/scripted/overlay/ScriptOverlay.java b/src/main/java/noppes/npcs/scripted/overlay/ScriptOverlay.java index bbeb26b12..7da5ade14 100644 --- a/src/main/java/noppes/npcs/scripted/overlay/ScriptOverlay.java +++ b/src/main/java/noppes/npcs/scripted/overlay/ScriptOverlay.java @@ -16,10 +16,10 @@ public class ScriptOverlay implements ICustomOverlay { int defaultAlignment = 0; List components = new ArrayList(); - public ScriptOverlay(){ + public ScriptOverlay() { } - public ScriptOverlay(int id){ + public ScriptOverlay(int id) { this.id = id; } @@ -31,7 +31,7 @@ public class ScriptOverlay implements ICustomOverlay { return this.components; } - public int getDefaultAlignment(){ + public int getDefaultAlignment() { return this.defaultAlignment; } @@ -42,25 +42,25 @@ public class ScriptOverlay implements ICustomOverlay { public IOverlayTexturedRect addTexturedRect(int id, String texture, int x, int y, int width, int height) { ScriptOverlayTexturedRect component = new ScriptOverlayTexturedRect(id, texture, x, y, width, height); this.components.add(component); - return (IOverlayTexturedRect)this.components.get(this.components.size() - 1); + return (IOverlayTexturedRect) this.components.get(this.components.size() - 1); } public IOverlayTexturedRect addTexturedRect(int id, String texture, int x, int y, int width, int height, int textureX, int textureY) { ScriptOverlayTexturedRect component = new ScriptOverlayTexturedRect(id, texture, x, y, width, height, textureX, textureY); this.components.add(component); - return (IOverlayTexturedRect)this.components.get(this.components.size() - 1); + return (IOverlayTexturedRect) this.components.get(this.components.size() - 1); } public IOverlayLabel addLabel(int id, String label, int x, int y, int width, int height) { ScriptOverlayLabel component = new ScriptOverlayLabel(id, label, x, y, width, height); this.components.add(component); - return (IOverlayLabel)this.components.get(this.components.size() - 1); + return (IOverlayLabel) this.components.get(this.components.size() - 1); } public IOverlayLabel addLabel(int id, String label, int x, int y, int width, int height, int color) { ScriptOverlayLabel component = new ScriptOverlayLabel(id, label, x, y, width, height, color); this.components.add(component); - return (IOverlayLabel)this.components.get(this.components.size() - 1); + return (IOverlayLabel) this.components.get(this.components.size() - 1); } public IOverlayLine addLine(int id, int x1, int y1, int x2, int y2, int color, int thickness) { @@ -84,15 +84,15 @@ public class ScriptOverlay implements ICustomOverlay { return null; } - component = (ICustomOverlayComponent)var2.next(); - } while(component.getID() != componentID); + component = (ICustomOverlayComponent) var2.next(); + } while (component.getID() != componentID); return component; } public void removeComponent(int componentID) { - for(int i = 0; i < this.components.size(); ++i) { - if (((ICustomOverlayComponent)this.components.get(i)).getID() == componentID) { + for (int i = 0; i < this.components.size(); ++i) { + if (((ICustomOverlayComponent) this.components.get(i)).getID() == componentID) { this.components.remove(i); return; } @@ -101,8 +101,8 @@ public class ScriptOverlay implements ICustomOverlay { } public void updateComponent(ICustomOverlayComponent component) { - for(int i = 0; i < this.components.size(); ++i) { - ICustomOverlayComponent c = (ICustomOverlayComponent)this.components.get(i); + for (int i = 0; i < this.components.size(); ++i) { + ICustomOverlayComponent c = (ICustomOverlayComponent) this.components.get(i); if (c.getID() == component.getID()) { this.components.set(i, component); return; @@ -120,9 +120,9 @@ public class ScriptOverlay implements ICustomOverlay { List components = new ArrayList(); NBTTagList list = tag.getTagList("components", 10); - for(int i = 0; i < list.tagCount(); i++){ + for (int i = 0; i < list.tagCount(); i++) { NBTBase b = list.getCompoundTagAt(i); - ScriptOverlayComponent component = ScriptOverlayComponent.createFromNBT((NBTTagCompound)b); + ScriptOverlayComponent component = ScriptOverlayComponent.createFromNBT((NBTTagCompound) b); components.add(component); } @@ -139,9 +139,9 @@ public class ScriptOverlay implements ICustomOverlay { Iterator var3 = this.components.iterator(); ICustomOverlayComponent c; - while(var3.hasNext()) { - c = (ICustomOverlayComponent)var3.next(); - list.appendTag(((ScriptOverlayComponent)c).toNBT(new NBTTagCompound())); + while (var3.hasNext()) { + c = (ICustomOverlayComponent) var3.next(); + list.appendTag(((ScriptOverlayComponent) c).toNBT(new NBTTagCompound())); } tag.setTag("components", list); diff --git a/src/main/java/noppes/npcs/scripted/overlay/ScriptOverlayComponent.java b/src/main/java/noppes/npcs/scripted/overlay/ScriptOverlayComponent.java index 5d5fdc4d4..6a94e845a 100644 --- a/src/main/java/noppes/npcs/scripted/overlay/ScriptOverlayComponent.java +++ b/src/main/java/noppes/npcs/scripted/overlay/ScriptOverlayComponent.java @@ -19,7 +19,7 @@ public abstract class ScriptOverlayComponent implements ICustomOverlayComponent 6 7 8 */ - public ScriptOverlayComponent(){ + public ScriptOverlayComponent() { } public int getID() { @@ -83,10 +83,10 @@ public abstract class ScriptOverlayComponent implements ICustomOverlayComponent public NBTTagCompound toNBT(NBTTagCompound nbt) { nbt.setInteger("id", this.id); nbt.setIntArray("pos", new int[]{this.posX, this.posY}); - nbt.setInteger("alignment",this.alignment); + nbt.setInteger("alignment", this.alignment); nbt.setInteger("color", this.color); - nbt.setFloat("alpha",this.alpha); - nbt.setFloat("rotation",this.rotation); + nbt.setFloat("alpha", this.alpha); + nbt.setFloat("rotation", this.rotation); nbt.setInteger("type", this.getType()); return nbt; @@ -104,7 +104,7 @@ public abstract class ScriptOverlayComponent implements ICustomOverlayComponent } public static ScriptOverlayComponent createFromNBT(NBTTagCompound nbt) { - switch(nbt.getInteger("type")) { + switch (nbt.getInteger("type")) { case 0: return (new ScriptOverlayTexturedRect()).fromNBT(nbt); case 1: diff --git a/src/main/java/noppes/npcs/scripted/overlay/ScriptOverlayLabel.java b/src/main/java/noppes/npcs/scripted/overlay/ScriptOverlayLabel.java index 7b165dcfd..ee43e1cc1 100644 --- a/src/main/java/noppes/npcs/scripted/overlay/ScriptOverlayLabel.java +++ b/src/main/java/noppes/npcs/scripted/overlay/ScriptOverlayLabel.java @@ -62,11 +62,11 @@ public class ScriptOverlayLabel extends ScriptOverlayComponent implements IOverl return this; } - public boolean getShadow(){ + public boolean getShadow() { return this.shadow; } - public void setShadow(boolean shadow){ + public void setShadow(boolean shadow) { this.shadow = shadow; } @@ -80,7 +80,7 @@ public class ScriptOverlayLabel extends ScriptOverlayComponent implements IOverl nbt.setString("label", this.label); nbt.setIntArray("size", new int[]{this.width, this.height}); nbt.setFloat("scale", this.scale); - nbt.setBoolean("shadow",this.shadow); + nbt.setBoolean("shadow", this.shadow); return nbt; } diff --git a/src/main/java/noppes/npcs/scripted/overlay/ScriptOverlayLine.java b/src/main/java/noppes/npcs/scripted/overlay/ScriptOverlayLine.java index 5ed6e966a..af933e2cd 100644 --- a/src/main/java/noppes/npcs/scripted/overlay/ScriptOverlayLine.java +++ b/src/main/java/noppes/npcs/scripted/overlay/ScriptOverlayLine.java @@ -10,10 +10,10 @@ public class ScriptOverlayLine extends ScriptOverlayComponent implements IOverla int y2; int thickness = 2; - public ScriptOverlayLine(){ + public ScriptOverlayLine() { } - public ScriptOverlayLine(int id, int x1, int y1, int x2, int y2){ + public ScriptOverlayLine(int id, int x1, int y1, int x2, int y2) { this.setPos(x1, y1); this.setID(id); @@ -23,7 +23,7 @@ public class ScriptOverlayLine extends ScriptOverlayComponent implements IOverla this.y2 = y2; } - public ScriptOverlayLine(int id, int x1, int y1, int x2, int y2, int color, int thickness){ + public ScriptOverlayLine(int id, int x1, int y1, int x2, int y2, int color, int thickness) { this.setPos(x1, y1); this.setID(id); @@ -42,11 +42,11 @@ public class ScriptOverlayLine extends ScriptOverlayComponent implements IOverla public NBTTagCompound toNBT(NBTTagCompound nbt) { super.toNBT(nbt); - nbt.setInteger("X1",x1); - nbt.setInteger("Y1",y1); - nbt.setInteger("X2",x2); - nbt.setInteger("Y2",y2); - nbt.setInteger("Thickness",thickness); + nbt.setInteger("X1", x1); + nbt.setInteger("Y1", y1); + nbt.setInteger("X2", x2); + nbt.setInteger("Y2", y2); + nbt.setInteger("Thickness", thickness); return nbt; } @@ -62,35 +62,43 @@ public class ScriptOverlayLine extends ScriptOverlayComponent implements IOverla return this; } - public int getX1(){ + public int getX1() { return this.x1; } - public int getY1(){ + + public int getY1() { return this.y1; } - public int getX2(){ + + public int getX2() { return this.x2; } - public int getY2(){ + + public int getY2() { return this.y2; } - public int getThickness(){ + + public int getThickness() { return this.thickness; } - public void setX1(int x1){ + public void setX1(int x1) { this.x1 = x1; } - public void setY1(int y1){ + + public void setY1(int y1) { this.y1 = y1; } - public void setX2(int x2){ + + public void setX2(int x2) { this.x2 = x2; } - public void setY2(int y2){ + + public void setY2(int y2) { this.y2 = y2; } - public void setThickness(int thickness){ + + public void setThickness(int thickness) { this.thickness = thickness; } } diff --git a/src/main/java/noppes/npcs/scripted/roles/ScriptJobBard.java b/src/main/java/noppes/npcs/scripted/roles/ScriptJobBard.java index 6a421e975..a45514c46 100644 --- a/src/main/java/noppes/npcs/scripted/roles/ScriptJobBard.java +++ b/src/main/java/noppes/npcs/scripted/roles/ScriptJobBard.java @@ -6,74 +6,79 @@ import noppes.npcs.roles.JobBard; import noppes.npcs.scripted.constants.JobType; public class ScriptJobBard extends ScriptJobInterface implements IJobBard { - private JobBard job; - public ScriptJobBard(EntityNPCInterface npc){ - super(npc); - this.job = (JobBard) npc.jobInterface; - } - @Override - public int getType(){ - return JobType.BARD; - } - - /** - * @return The song the bard is playing - */ - public String getSong(){ - return job.song; - } - - /** - * @param song The song you want the bard to play - */ - public void setSong(String song){ - job.song = song; - npc.script.clientNeedsUpdate = true; - } + private JobBard job; - /** - * - * @param i The id of the instrument. IDs: - * 0 - None, - * 1 - Banjo, - * 2 - Violin, - * 3 - Guitar, - * 4 - Harp, - * 5 - FrenchHorn - */ - public void setInstrument(int i) { - this.job.setInstrument(i); - } + public ScriptJobBard(EntityNPCInterface npc) { + super(npc); + this.job = (JobBard) npc.jobInterface; + } - public int getInstrumentId() { - return this.job.getInstrument().ordinal(); - } + @Override + public int getType() { + return JobType.BARD; + } - public void setMinRange(int range) { - this.job.minRange = range; - } - public int getMinRange() { - return this.job.minRange; - } + /** + * @return The song the bard is playing + */ + public String getSong() { + return job.song; + } - public void setMaxRange(int range) { - this.job.maxRange = range; - } - public int getMaxRange() { - return this.job.maxRange; - } + /** + * @param song The song you want the bard to play + */ + public void setSong(String song) { + job.song = song; + npc.script.clientNeedsUpdate = true; + } - public void setStreaming(boolean streaming) { - this.job.isStreamer = streaming; - } - public boolean getStreaming() { - return this.job.isStreamer; - } + /** + * @param i The id of the instrument. IDs: + * 0 - None, + * 1 - Banjo, + * 2 - Violin, + * 3 - Guitar, + * 4 - Harp, + * 5 - FrenchHorn + */ + public void setInstrument(int i) { + this.job.setInstrument(i); + } - public void hasOffRange(boolean value) { - this.job.hasOffRange = value; - } - public boolean hasOffRange() { - return this.job.hasOffRange; - } + public int getInstrumentId() { + return this.job.getInstrument().ordinal(); + } + + public void setMinRange(int range) { + this.job.minRange = range; + } + + public int getMinRange() { + return this.job.minRange; + } + + public void setMaxRange(int range) { + this.job.maxRange = range; + } + + public int getMaxRange() { + return this.job.maxRange; + } + + public void setStreaming(boolean streaming) { + this.job.isStreamer = streaming; + } + + public boolean getStreaming() { + return this.job.isStreamer; + } + + public void hasOffRange(boolean value) { + this.job.hasOffRange = value; + } + + public boolean hasOffRange() { + return this.job.hasOffRange; + } } diff --git a/src/main/java/noppes/npcs/scripted/roles/ScriptJobConversation.java b/src/main/java/noppes/npcs/scripted/roles/ScriptJobConversation.java index 2a94a0bb6..0b39da342 100644 --- a/src/main/java/noppes/npcs/scripted/roles/ScriptJobConversation.java +++ b/src/main/java/noppes/npcs/scripted/roles/ScriptJobConversation.java @@ -6,15 +6,16 @@ import noppes.npcs.roles.JobConversation; import noppes.npcs.scripted.constants.JobType; public class ScriptJobConversation extends ScriptJobInterface implements IJobConversation { - private JobConversation job; - public ScriptJobConversation(EntityNPCInterface npc){ - super(npc); - this.job = (JobConversation) npc.jobInterface; - } - - @Override - public int getType(){ - return JobType.SPAWNER; - } - + private JobConversation job; + + public ScriptJobConversation(EntityNPCInterface npc) { + super(npc); + this.job = (JobConversation) npc.jobInterface; + } + + @Override + public int getType() { + return JobType.SPAWNER; + } + } diff --git a/src/main/java/noppes/npcs/scripted/roles/ScriptJobFollower.java b/src/main/java/noppes/npcs/scripted/roles/ScriptJobFollower.java index ea0b33298..3ce52b061 100644 --- a/src/main/java/noppes/npcs/scripted/roles/ScriptJobFollower.java +++ b/src/main/java/noppes/npcs/scripted/roles/ScriptJobFollower.java @@ -7,33 +7,34 @@ import noppes.npcs.roles.JobFollower; import noppes.npcs.scripted.constants.JobType; public class ScriptJobFollower extends ScriptJobInterface implements IJobFollower { - private JobFollower job; - public ScriptJobFollower(EntityNPCInterface npc){ - super(npc); - this.job = (JobFollower) npc.jobInterface; - } - - public String getFollowingName(){ - return job.name; - } - - public void setFollowingName(String name){ - job.name = name; - } - - public ICustomNpc getFollowingNpc() { - if(!isFollowing()) - return null; - return job.following.script.dummyNpc; - } - - public boolean isFollowing(){ - return job.isFollowing(); - } - - @Override - public int getType(){ - return JobType.FOLLOWER; - } - + private JobFollower job; + + public ScriptJobFollower(EntityNPCInterface npc) { + super(npc); + this.job = (JobFollower) npc.jobInterface; + } + + public String getFollowingName() { + return job.name; + } + + public void setFollowingName(String name) { + job.name = name; + } + + public ICustomNpc getFollowingNpc() { + if (!isFollowing()) + return null; + return job.following.script.dummyNpc; + } + + public boolean isFollowing() { + return job.isFollowing(); + } + + @Override + public int getType() { + return JobType.FOLLOWER; + } + } diff --git a/src/main/java/noppes/npcs/scripted/roles/ScriptJobGuard.java b/src/main/java/noppes/npcs/scripted/roles/ScriptJobGuard.java index 33cfbc426..32b0ea77b 100644 --- a/src/main/java/noppes/npcs/scripted/roles/ScriptJobGuard.java +++ b/src/main/java/noppes/npcs/scripted/roles/ScriptJobGuard.java @@ -6,36 +6,40 @@ import noppes.npcs.roles.JobGuard; import noppes.npcs.scripted.constants.JobType; public class ScriptJobGuard extends ScriptJobInterface implements IJobGuard { - private JobGuard job; - public ScriptJobGuard(EntityNPCInterface npc){ - super(npc); - this.job = (JobGuard) npc.jobInterface; - } + private JobGuard job; - public boolean attackCreepers() { - return job.attackCreepers; - } - public void attackCreepers(boolean value) { - job.attackCreepers = value; - } + public ScriptJobGuard(EntityNPCInterface npc) { + super(npc); + this.job = (JobGuard) npc.jobInterface; + } - public boolean attacksAnimals() { - return job.attacksAnimals; - } - public void attacksAnimals(boolean value) { - job.attacksAnimals = value; - } + public boolean attackCreepers() { + return job.attackCreepers; + } + + public void attackCreepers(boolean value) { + job.attackCreepers = value; + } + + public boolean attacksAnimals() { + return job.attacksAnimals; + } + + public void attacksAnimals(boolean value) { + job.attacksAnimals = value; + } + + public boolean attackHostileMobs() { + return job.attackHostileMobs; + } + + public void attackHostileMobs(boolean value) { + job.attackHostileMobs = value; + } + + @Override + public int getType() { + return JobType.GUARD; + } - public boolean attackHostileMobs() { - return job.attackHostileMobs; - } - public void attackHostileMobs(boolean value) { - job.attackHostileMobs = value; - } - - @Override - public int getType(){ - return JobType.GUARD; - } - } diff --git a/src/main/java/noppes/npcs/scripted/roles/ScriptJobHealer.java b/src/main/java/noppes/npcs/scripted/roles/ScriptJobHealer.java index 23fffa75f..827047ea6 100644 --- a/src/main/java/noppes/npcs/scripted/roles/ScriptJobHealer.java +++ b/src/main/java/noppes/npcs/scripted/roles/ScriptJobHealer.java @@ -7,33 +7,36 @@ import noppes.npcs.roles.JobHealer; import noppes.npcs.scripted.constants.JobType; public class ScriptJobHealer extends ScriptJobInterface implements IJobHealer { - private JobHealer job; - public ScriptJobHealer(EntityNPCInterface npc){ - super(npc); - this.job = (JobHealer) npc.jobInterface; - } - - public void heal(IEntityLivingBase entity, float amount){ - job.heal(entity.getMCEntity(), amount); - } + private JobHealer job; - public void setRange(int range) { - this.job.range = range; - } - public int getRange() { - return this.job.range; - } + public ScriptJobHealer(EntityNPCInterface npc) { + super(npc); + this.job = (JobHealer) npc.jobInterface; + } + + public void heal(IEntityLivingBase entity, float amount) { + job.heal(entity.getMCEntity(), amount); + } + + public void setRange(int range) { + this.job.range = range; + } + + public int getRange() { + return this.job.range; + } + + public void setSpeed(int speed) { + this.job.speed = speed; + } + + public int getSpeed() { + return this.job.speed; + } + + @Override + public int getType() { + return JobType.HEALER; + } - public void setSpeed(int speed) { - this.job.speed = speed; - } - public int getSpeed() { - return this.job.speed; - } - - @Override - public int getType(){ - return JobType.HEALER; - } - } diff --git a/src/main/java/noppes/npcs/scripted/roles/ScriptJobInterface.java b/src/main/java/noppes/npcs/scripted/roles/ScriptJobInterface.java index 4377f88ce..ed2a45e88 100644 --- a/src/main/java/noppes/npcs/scripted/roles/ScriptJobInterface.java +++ b/src/main/java/noppes/npcs/scripted/roles/ScriptJobInterface.java @@ -8,32 +8,33 @@ import noppes.npcs.scripted.NpcAPI; import noppes.npcs.scripted.constants.JobType; public class ScriptJobInterface implements IJob { - public final EntityNPCInterface npc; - public final JobInterface jobInterface; + public final EntityNPCInterface npc; + public final JobInterface jobInterface; - public ScriptJobInterface(JobInterface jobInterface) { - this.npc = null; - this.jobInterface = jobInterface; - } + public ScriptJobInterface(JobInterface jobInterface) { + this.npc = null; + this.jobInterface = jobInterface; + } - public ScriptJobInterface(EntityNPCInterface npc){ - this.npc = npc; - this.jobInterface = npc.jobInterface; - } - /** - * @see noppes.npcs.scripted.constants.JobType - * @return Returns the JobType - */ - public int getType(){ - return JobType.UNKNOWN; - } + public ScriptJobInterface(EntityNPCInterface npc) { + this.npc = npc; + this.jobInterface = npc.jobInterface; + } - public JobInterface getJobInterface() { - return jobInterface; - } + /** + * @return Returns the JobType + * @see noppes.npcs.scripted.constants.JobType + */ + public int getType() { + return JobType.UNKNOWN; + } - public ICustomNpc getNpc() { - return (ICustomNpc) NpcAPI.Instance().getIEntity(npc); - } + public JobInterface getJobInterface() { + return jobInterface; + } + + public ICustomNpc getNpc() { + return (ICustomNpc) NpcAPI.Instance().getIEntity(npc); + } } diff --git a/src/main/java/noppes/npcs/scripted/roles/ScriptJobItemGiver.java b/src/main/java/noppes/npcs/scripted/roles/ScriptJobItemGiver.java index 0e4972915..6a0c41c67 100644 --- a/src/main/java/noppes/npcs/scripted/roles/ScriptJobItemGiver.java +++ b/src/main/java/noppes/npcs/scripted/roles/ScriptJobItemGiver.java @@ -16,97 +16,97 @@ import java.util.ArrayList; import java.util.Arrays; public class ScriptJobItemGiver extends ScriptJobInterface implements IJobItemGiver { - private JobItemGiver job; + private JobItemGiver job; - public ScriptJobItemGiver(JobItemGiver job) { - super(job); - this.job = job; - } + public ScriptJobItemGiver(JobItemGiver job) { + super(job); + this.job = job; + } - public ScriptJobItemGiver(EntityNPCInterface npc){ - super(npc); - this.job = (JobItemGiver) npc.jobInterface; - } - - @Override - public int getType(){ - return JobType.ITEMGIVER; - } + public ScriptJobItemGiver(EntityNPCInterface npc) { + super(npc); + this.job = (JobItemGiver) npc.jobInterface; + } - public void setCooldown(int cooldown) { - if (cooldown < 0) - cooldown = 0; + @Override + public int getType() { + return JobType.ITEMGIVER; + } - job.cooldown = cooldown; - } + public void setCooldown(int cooldown) { + if (cooldown < 0) + cooldown = 0; - public void setCooldownType(int type) { - if (type < 0) { - type = 0; - } else if (type > 2) { - type = 2; - } - job.cooldownType = type; - } + job.cooldown = cooldown; + } - public int getCooldownType() { - return job.cooldownType; - } + public void setCooldownType(int type) { + if (type < 0) { + type = 0; + } else if (type > 2) { + type = 2; + } + job.cooldownType = type; + } - public void setGivingMethod(int method) { - if (method < 0) { - method = 0; - } else if (method > 4) { - method = 4; - } - job.givingMethod = method; - } + public int getCooldownType() { + return job.cooldownType; + } - public int getGivingMethod() { - return job.givingMethod; - } + public void setGivingMethod(int method) { + if (method < 0) { + method = 0; + } else if (method > 4) { + method = 4; + } + job.givingMethod = method; + } - public void setLines(String[] lines) { - job.lines = new ArrayList<>(Arrays.asList(lines)); - } + public int getGivingMethod() { + return job.givingMethod; + } - public String[] getLines() { - return job.lines.toArray(new String[0]); - } + public void setLines(String[] lines) { + job.lines = new ArrayList<>(Arrays.asList(lines)); + } - public void setAvailability(IAvailability availability) { - job.availability = (Availability) availability; - } + public String[] getLines() { + return job.lines.toArray(new String[0]); + } - public IAvailability getAvailability() { - return job.availability; - } + public void setAvailability(IAvailability availability) { + job.availability = (Availability) availability; + } - public void setItem(int slot, IItemStack item) { - if (slot < 0) { - slot = 0; - } else if (slot > 8) { - slot = 8; - } + public IAvailability getAvailability() { + return job.availability; + } - job.inventory.items.put(slot, item.getMCItemStack()); - } + public void setItem(int slot, IItemStack item) { + if (slot < 0) { + slot = 0; + } else if (slot > 8) { + slot = 8; + } - public IItemStack[] getItems() { - ArrayList items = new ArrayList<>(); + job.inventory.items.put(slot, item.getMCItemStack()); + } - for (int i = 0; i < job.inventory.getSizeInventory(); i++) { - items.add(NpcAPI.Instance().getIItemStack(job.inventory.getStackInSlot(i))); - } + public IItemStack[] getItems() { + ArrayList items = new ArrayList<>(); - return items.toArray(new IItemStack[0]); - } + for (int i = 0; i < job.inventory.getSizeInventory(); i++) { + items.add(NpcAPI.Instance().getIItemStack(job.inventory.getStackInSlot(i))); + } - public boolean giveItems(IPlayer player) { - return job.giveItems((EntityPlayer) player.getMCEntity()); - } + return items.toArray(new IItemStack[0]); + } - public boolean canPlayerInteract(IPlayer player) { - return job.canPlayerInteract((PlayerItemGiverData) player.getData().getItemGiverData()); - } + public boolean giveItems(IPlayer player) { + return job.giveItems((EntityPlayer) player.getMCEntity()); + } + + public boolean canPlayerInteract(IPlayer player) { + return job.canPlayerInteract((PlayerItemGiverData) player.getData().getItemGiverData()); + } } diff --git a/src/main/java/noppes/npcs/scripted/roles/ScriptJobSpawner.java b/src/main/java/noppes/npcs/scripted/roles/ScriptJobSpawner.java index da7f49e9b..ede844764 100644 --- a/src/main/java/noppes/npcs/scripted/roles/ScriptJobSpawner.java +++ b/src/main/java/noppes/npcs/scripted/roles/ScriptJobSpawner.java @@ -20,80 +20,82 @@ import java.util.ArrayList; import java.util.List; public class ScriptJobSpawner extends ScriptJobInterface implements IJobSpawner { - private final JobSpawner job; - public ScriptJobSpawner(EntityNPCInterface npc){ - super(npc); - this.job = (JobSpawner) npc.jobInterface; - } - - @Override - public int getType(){ - return JobType.SPAWNER; - } - - /** - * Npc needs to be attacking something or be set to Despawn Spawns On Target Lost: No, otherwise it will despawn right away - * @param number The entity going to be spawned (1-6) - * @return Returns spawned entity - */ - public IEntityLivingBase spawnEntity(int number){ - EntityLivingBase base = job.spawnEntity(number); - if(base == null) - return null; - - return (IEntityLivingBase) NpcAPI.Instance().getIEntity(base); - } + private final JobSpawner job; - public IEntityLivingBase getEntity(int number, int x, int y, int z, IWorld world) { - NBTTagCompound compound = this.job.getCompound(number); - if(compound == null || !compound.hasKey("id")) - return null; - Entity entity = NoppesUtilServer.getEntityFromNBT(compound,x,y,z,world.getMCWorld()); - if (!(entity instanceof EntityLivingBase)) { - return null; - } - return (IEntityLivingBase) NpcAPI.Instance().getIEntity(entity); - } + public ScriptJobSpawner(EntityNPCInterface npc) { + super(npc); + this.job = (JobSpawner) npc.jobInterface; + } - public IEntityLivingBase getEntity(int number, IPos pos, IWorld world) { - return this.getEntity(number,pos.getX(),pos.getY(),pos.getZ(),world); - } + @Override + public int getType() { + return JobType.SPAWNER; + } - public void setEntity(int number, IEntityLivingBase entityLivingBase){ - INbt nbt = entityLivingBase.getNbtOptional(); - if (nbt == null) - return; - this.job.setJobCompound(number,nbt.getMCNBT()); - } + /** + * Npc needs to be attacking something or be set to Despawn Spawns On Target Lost: No, otherwise it will despawn right away + * + * @param number The entity going to be spawned (1-6) + * @return Returns spawned entity + */ + public IEntityLivingBase spawnEntity(int number) { + EntityLivingBase base = job.spawnEntity(number); + if (base == null) + return null; - /** - * Removes all spawned entities - */ - public void removeAllSpawned(){ - for(EntityLivingBase entity : job.spawned){ - entity.isDead = true; - } - job.spawned = new ArrayList<>(); - } + return (IEntityLivingBase) NpcAPI.Instance().getIEntity(base); + } - public IEntityLivingBase[] getNearbySpawned() { - List nearbySpawned = this.job.getNearbySpawned(); - List> list = new ArrayList<>(); - for (EntityLivingBase entity : nearbySpawned) { - list.add((IEntityLivingBase) NpcAPI.Instance().getIEntity(entity)); - } - return list.toArray(new IEntityLivingBase[0]); - } + public IEntityLivingBase getEntity(int number, int x, int y, int z, IWorld world) { + NBTTagCompound compound = this.job.getCompound(number); + if (compound == null || !compound.hasKey("id")) + return null; + Entity entity = NoppesUtilServer.getEntityFromNBT(compound, x, y, z, world.getMCWorld()); + if (!(entity instanceof EntityLivingBase)) { + return null; + } + return (IEntityLivingBase) NpcAPI.Instance().getIEntity(entity); + } - public boolean hasPixelmon() { - return this.job.hasPixelmon(); - } + public IEntityLivingBase getEntity(int number, IPos pos, IWorld world) { + return this.getEntity(number, pos.getX(), pos.getY(), pos.getZ(), world); + } - public boolean isEmpty() { - return this.job.isEmpty(); - } + public void setEntity(int number, IEntityLivingBase entityLivingBase) { + INbt nbt = entityLivingBase.getNbtOptional(); + if (nbt == null) + return; + this.job.setJobCompound(number, nbt.getMCNBT()); + } - public boolean isOnCooldown(IPlayer player) { - return this.job.isOnCooldown(player.getName()); - } + /** + * Removes all spawned entities + */ + public void removeAllSpawned() { + for (EntityLivingBase entity : job.spawned) { + entity.isDead = true; + } + job.spawned = new ArrayList<>(); + } + + public IEntityLivingBase[] getNearbySpawned() { + List nearbySpawned = this.job.getNearbySpawned(); + List> list = new ArrayList<>(); + for (EntityLivingBase entity : nearbySpawned) { + list.add((IEntityLivingBase) NpcAPI.Instance().getIEntity(entity)); + } + return list.toArray(new IEntityLivingBase[0]); + } + + public boolean hasPixelmon() { + return this.job.hasPixelmon(); + } + + public boolean isEmpty() { + return this.job.isEmpty(); + } + + public boolean isOnCooldown(IPlayer player) { + return this.job.isOnCooldown(player.getName()); + } } diff --git a/src/main/java/noppes/npcs/scripted/roles/ScriptRoleBank.java b/src/main/java/noppes/npcs/scripted/roles/ScriptRoleBank.java index 3cfabd529..9bfde7074 100644 --- a/src/main/java/noppes/npcs/scripted/roles/ScriptRoleBank.java +++ b/src/main/java/noppes/npcs/scripted/roles/ScriptRoleBank.java @@ -6,12 +6,12 @@ import noppes.npcs.scripted.constants.RoleType; public class ScriptRoleBank extends ScriptRoleInterface implements IRoleBank { - public ScriptRoleBank(EntityNPCInterface npc) { - super(npc); - } + public ScriptRoleBank(EntityNPCInterface npc) { + super(npc); + } - @Override - public int getType(){ - return RoleType.BANK; - } + @Override + public int getType() { + return RoleType.BANK; + } } diff --git a/src/main/java/noppes/npcs/scripted/roles/ScriptRoleCompanion.java b/src/main/java/noppes/npcs/scripted/roles/ScriptRoleCompanion.java index db20a3d4f..ff1bd6f74 100644 --- a/src/main/java/noppes/npcs/scripted/roles/ScriptRoleCompanion.java +++ b/src/main/java/noppes/npcs/scripted/roles/ScriptRoleCompanion.java @@ -6,12 +6,12 @@ import noppes.npcs.scripted.constants.RoleType; public class ScriptRoleCompanion extends ScriptRoleInterface implements IRoleMailman { - public ScriptRoleCompanion(EntityNPCInterface npc) { - super(npc); - } + public ScriptRoleCompanion(EntityNPCInterface npc) { + super(npc); + } - @Override - public int getType(){ - return RoleType.COMPANION; - } + @Override + public int getType() { + return RoleType.COMPANION; + } } diff --git a/src/main/java/noppes/npcs/scripted/roles/ScriptRoleFollower.java b/src/main/java/noppes/npcs/scripted/roles/ScriptRoleFollower.java index 8cd7eab19..0bc6f57d5 100644 --- a/src/main/java/noppes/npcs/scripted/roles/ScriptRoleFollower.java +++ b/src/main/java/noppes/npcs/scripted/roles/ScriptRoleFollower.java @@ -9,111 +9,112 @@ import noppes.npcs.scripted.NpcAPI; import noppes.npcs.scripted.constants.RoleType; public class ScriptRoleFollower extends ScriptRoleInterface implements IRoleFollower { - private RoleFollower role; - public ScriptRoleFollower(EntityNPCInterface npc) { - super(npc); - role = (RoleFollower) npc.roleInterface; - } + private RoleFollower role; - public void setOwner(IPlayer player){ - if(player == null || player.getMCEntity() == null){ - role.setOwner(null); - return; - } - EntityPlayer mcplayer = (EntityPlayer) player.getMCEntity(); - role.setOwner(mcplayer); - } + public ScriptRoleFollower(EntityNPCInterface npc) { + super(npc); + role = (RoleFollower) npc.roleInterface; + } - public IPlayer getOwner(){ - if(role.owner == null) - return null; - - return (IPlayer) NpcAPI.Instance().getIEntity(role.owner); - } + public void setOwner(IPlayer player) { + if (player == null || player.getMCEntity() == null) { + role.setOwner(null); + return; + } + EntityPlayer mcplayer = (EntityPlayer) player.getMCEntity(); + role.setOwner(mcplayer); + } - public boolean hasOwner(){ - return role.owner != null; - } - - public boolean isFollowing() { - return role.isFollowing(); - } - - public void setIsFollowing(boolean following) { - if (role.owner != null && role.getDaysLeft() > 0) role.isFollowing = following; - } + public IPlayer getOwner() { + if (role.owner == null) + return null; - public int getDaysLeft(){ - return role.getDaysLeft(); - } + return (IPlayer) NpcAPI.Instance().getIEntity(role.owner); + } - public void addDaysLeft(int days){ - role.addDays(days); - } + public boolean hasOwner() { + return role.owner != null; + } - public boolean getInfiniteDays(){ - return role.infiniteDays; - } + public boolean isFollowing() { + return role.isFollowing(); + } - public void setInfiniteDays(boolean infinite){ - role.infiniteDays = infinite; - } + public void setIsFollowing(boolean following) { + if (role.owner != null && role.getDaysLeft() > 0) role.isFollowing = following; + } - public boolean getGuiDisabled(){ - return role.disableGui; - } + public int getDaysLeft() { + return role.getDaysLeft(); + } - public void setGuiDisabled(boolean disabled){ - role.disableGui = disabled; - } + public void addDaysLeft(int days) { + role.addDays(days); + } + + public boolean getInfiniteDays() { + return role.infiniteDays; + } + + public void setInfiniteDays(boolean infinite) { + role.infiniteDays = infinite; + } + + public boolean getGuiDisabled() { + return role.disableGui; + } + + public void setGuiDisabled(boolean disabled) { + role.disableGui = disabled; + } - /** - * @param index Index of Rate [0 - 2] - * @param amount Amount hired for - */ - public void setRate(int index, int amount){ - role.setRate(index, amount); - } + /** + * @param index Index of Rate [0 - 2] + * @param amount Amount hired for + */ + public void setRate(int index, int amount) { + role.setRate(index, amount); + } - /** - * @param index Index of Rate [0 - 2] - * @return amount fired for - */ - public int getRate(int index){ - return role.getRate(index); - } + /** + * @param index Index of Rate [0 - 2] + * @return amount fired for + */ + public int getRate(int index) { + return role.getRate(index); + } - /** - * @param dialogHire New dialog hire string - */ - public void setDialogHire(String dialogHire){ - role.setDialogHire(dialogHire); - } + /** + * @param dialogHire New dialog hire string + */ + public void setDialogHire(String dialogHire) { + role.setDialogHire(dialogHire); + } - /** - * @return dialog hire string - */ - public String getDialogHire(){ - return role.getDialogHire(); - } + /** + * @return dialog hire string + */ + public String getDialogHire() { + return role.getDialogHire(); + } - /** - * @param dialogFarewell New dialog farewell string - */ - public void setDialogFarewell(String dialogFarewell){ - role.setDialogFarewell(dialogFarewell); - } + /** + * @param dialogFarewell New dialog farewell string + */ + public void setDialogFarewell(String dialogFarewell) { + role.setDialogFarewell(dialogFarewell); + } - /** - * @return dialog farewell string - */ - public String getDialogFarewell(){ - return role.getDialogFarewell(); - } + /** + * @return dialog farewell string + */ + public String getDialogFarewell() { + return role.getDialogFarewell(); + } - @Override - public int getType(){ - return RoleType.FOLLOWER; - } + @Override + public int getType() { + return RoleType.FOLLOWER; + } } diff --git a/src/main/java/noppes/npcs/scripted/roles/ScriptRoleInterface.java b/src/main/java/noppes/npcs/scripted/roles/ScriptRoleInterface.java index de97c693c..2fa1657dd 100644 --- a/src/main/java/noppes/npcs/scripted/roles/ScriptRoleInterface.java +++ b/src/main/java/noppes/npcs/scripted/roles/ScriptRoleInterface.java @@ -8,23 +8,23 @@ import noppes.npcs.scripted.NpcAPI; import noppes.npcs.scripted.constants.RoleType; public class ScriptRoleInterface implements IRole { - public final EntityNPCInterface npc; - public final RoleInterface role; + public final EntityNPCInterface npc; + public final RoleInterface role; - public ScriptRoleInterface(EntityNPCInterface npc){ - this.npc = npc; - this.role = npc.roleInterface; - } + public ScriptRoleInterface(EntityNPCInterface npc) { + this.npc = npc; + this.role = npc.roleInterface; + } - public INpc getNpc() { - return (INpc) NpcAPI.Instance().getIEntity(npc); - } + public INpc getNpc() { + return (INpc) NpcAPI.Instance().getIEntity(npc); + } - /** - * @see noppes.npcs.scripted.constants.RoleType - * @return The RoleType of this role - */ - public int getType(){ - return RoleType.UNKNOWN; - } + /** + * @return The RoleType of this role + * @see noppes.npcs.scripted.constants.RoleType + */ + public int getType() { + return RoleType.UNKNOWN; + } } diff --git a/src/main/java/noppes/npcs/scripted/roles/ScriptRoleMailman.java b/src/main/java/noppes/npcs/scripted/roles/ScriptRoleMailman.java index 5f6c3199e..5e8c09685 100644 --- a/src/main/java/noppes/npcs/scripted/roles/ScriptRoleMailman.java +++ b/src/main/java/noppes/npcs/scripted/roles/ScriptRoleMailman.java @@ -6,12 +6,12 @@ import noppes.npcs.scripted.constants.RoleType; public class ScriptRoleMailman extends ScriptRoleInterface implements IRoleMailman { - public ScriptRoleMailman(EntityNPCInterface npc) { - super(npc); - } + public ScriptRoleMailman(EntityNPCInterface npc) { + super(npc); + } - @Override - public int getType(){ - return RoleType.POSTMAN; - } + @Override + public int getType() { + return RoleType.POSTMAN; + } } diff --git a/src/main/java/noppes/npcs/scripted/roles/ScriptRoleTrader.java b/src/main/java/noppes/npcs/scripted/roles/ScriptRoleTrader.java index 5fcc54821..825c2e46b 100644 --- a/src/main/java/noppes/npcs/scripted/roles/ScriptRoleTrader.java +++ b/src/main/java/noppes/npcs/scripted/roles/ScriptRoleTrader.java @@ -10,125 +10,126 @@ import noppes.npcs.scripted.NpcAPI; import noppes.npcs.scripted.constants.RoleType; public class ScriptRoleTrader extends ScriptRoleInterface implements IRoleTrader { - private RoleTrader role; - public ScriptRoleTrader(EntityNPCInterface npc) { - super(npc); - role = (RoleTrader) npc.roleInterface; - } + private RoleTrader role; - public void setSellOption(int slot, IItemStack currency, IItemStack currency2, IItemStack sold){ - if(sold == null || slot >= 18 || slot < 0) - return; - if(currency == null) - currency = currency2; + public ScriptRoleTrader(EntityNPCInterface npc) { + super(npc); + role = (RoleTrader) npc.roleInterface; + } - if(currency != null) - role.inventoryCurrency.items.put(slot, currency.getMCItemStack()); - else - role.inventoryCurrency.items.remove(slot); - if(currency2 != null) - role.inventoryCurrency.items.put(slot + 18, currency2.getMCItemStack()); - else - role.inventoryCurrency.items.remove(slot + 18); + public void setSellOption(int slot, IItemStack currency, IItemStack currency2, IItemStack sold) { + if (sold == null || slot >= 18 || slot < 0) + return; + if (currency == null) + currency = currency2; - role.inventorySold.items.put(slot, sold.getMCItemStack()); - } + if (currency != null) + role.inventoryCurrency.items.put(slot, currency.getMCItemStack()); + else + role.inventoryCurrency.items.remove(slot); + if (currency2 != null) + role.inventoryCurrency.items.put(slot + 18, currency2.getMCItemStack()); + else + role.inventoryCurrency.items.remove(slot + 18); - public void setSellOption(int slot, IItemStack currency, IItemStack sold){ - setSellOption(slot, currency, null, sold); - } + role.inventorySold.items.put(slot, sold.getMCItemStack()); + } - public IItemStack getSellOption(int slot) { - if (slot >= 18 || slot < 0) return null; - if (role.inventorySold.items.get(slot) == null) return null; - return NpcAPI.Instance().getIItemStack(role.inventoryCurrency.items.get(slot)); - } + public void setSellOption(int slot, IItemStack currency, IItemStack sold) { + setSellOption(slot, currency, null, sold); + } - public IItemStack[] getCurrency(int slot) { - if (slot >= 18 || slot < 0) return null; - IItemStack[] currency = new IItemStack[2]; - if (role.inventoryCurrency.items.get(slot) != null) { - currency[0] = NpcAPI.Instance().getIItemStack(role.inventoryCurrency.items.get(slot)); - } - if (role.inventoryCurrency.items.get(slot + 18) != null) { - currency[1] = NpcAPI.Instance().getIItemStack(role.inventoryCurrency.items.get(slot + 18)); - } - return currency; - } + public IItemStack getSellOption(int slot) { + if (slot >= 18 || slot < 0) return null; + if (role.inventorySold.items.get(slot) == null) return null; + return NpcAPI.Instance().getIItemStack(role.inventoryCurrency.items.get(slot)); + } + + public IItemStack[] getCurrency(int slot) { + if (slot >= 18 || slot < 0) return null; + IItemStack[] currency = new IItemStack[2]; + if (role.inventoryCurrency.items.get(slot) != null) { + currency[0] = NpcAPI.Instance().getIItemStack(role.inventoryCurrency.items.get(slot)); + } + if (role.inventoryCurrency.items.get(slot + 18) != null) { + currency[1] = NpcAPI.Instance().getIItemStack(role.inventoryCurrency.items.get(slot + 18)); + } + return currency; + } - public void removeSellOption(int slot){ - if(slot >= 18 || slot < 0) return; - role.inventoryCurrency.items.remove(slot); - role.inventoryCurrency.items.remove(slot + 18); - role.inventorySold.items.remove(slot); - } + public void removeSellOption(int slot) { + if (slot >= 18 || slot < 0) return; + role.inventoryCurrency.items.remove(slot); + role.inventoryCurrency.items.remove(slot + 18); + role.inventorySold.items.remove(slot); + } - public void setMarket(String name){ - role.marketName = name; - Market.getMarket(role, name); - } + public void setMarket(String name) { + role.marketName = name; + Market.getMarket(role, name); + } - public String getMarket(){ - return role.marketName; - } + public String getMarket() { + return role.marketName; + } - public int getPurchaseNum(int slot) { - if(slot >= 18 || slot < 0) return -1; - return role.purchases[slot]; - } + public int getPurchaseNum(int slot) { + if (slot >= 18 || slot < 0) return -1; + return role.purchases[slot]; + } - public int getPurchaseNum(int slot, IPlayer player) { - if(slot >= 18 || slot < 0) return -1; - return role.getArrayByName(player.getDisplayName(), role.playerPurchases)[slot]; - } + public int getPurchaseNum(int slot, IPlayer player) { + if (slot >= 18 || slot < 0) return -1; + return role.getArrayByName(player.getDisplayName(), role.playerPurchases)[slot]; + } - public void resetPurchaseNum() { - for (int i = 0; i < role.purchases.length; ++i) role.purchases[i] = 0; - } + public void resetPurchaseNum() { + for (int i = 0; i < role.purchases.length; ++i) role.purchases[i] = 0; + } - public void resetPurchaseNum(int slot) { - if(slot >= 18 || slot < 0) return; - role.purchases[slot] = 0; - } + public void resetPurchaseNum(int slot) { + if (slot >= 18 || slot < 0) return; + role.purchases[slot] = 0; + } - public void resetPurchaseNum(int slot, IPlayer player) { - if(slot >= 18 || slot < 0) return; - role.getArrayByName(player.getDisplayName(), role.playerPurchases)[slot] = 0; - } + public void resetPurchaseNum(int slot, IPlayer player) { + if (slot >= 18 || slot < 0) return; + role.getArrayByName(player.getDisplayName(), role.playerPurchases)[slot] = 0; + } - public boolean isSlotEnabled(int slot) { - if(slot >= 18 || slot < 0) return false; - return role.disableSlot[slot] > 0; - } + public boolean isSlotEnabled(int slot) { + if (slot >= 18 || slot < 0) return false; + return role.disableSlot[slot] > 0; + } - public boolean isSlotEnabled(int slot, IPlayer player) { - if(slot >= 18 || slot < 0) return false; - return role.isSlotEnabled(slot, player.getDisplayName()); - } + public boolean isSlotEnabled(int slot, IPlayer player) { + if (slot >= 18 || slot < 0) return false; + return role.isSlotEnabled(slot, player.getDisplayName()); + } - public void disableSlot(int slot) { - if(slot >= 18 || slot < 0) return; - role.disableSlot[slot] = 1; - } + public void disableSlot(int slot) { + if (slot >= 18 || slot < 0) return; + role.disableSlot[slot] = 1; + } - public void disableSlot(int slot, IPlayer player) { - if(slot >= 18 || slot < 0) return; - role.getArrayByName(player.getDisplayName(), role.playerDisableSlot)[slot] = 1; - } + public void disableSlot(int slot, IPlayer player) { + if (slot >= 18 || slot < 0) return; + role.getArrayByName(player.getDisplayName(), role.playerDisableSlot)[slot] = 1; + } - public void enableSlot(int slot) { - if(slot >= 18 || slot < 0) return; - role.disableSlot[slot] = 0; - } + public void enableSlot(int slot) { + if (slot >= 18 || slot < 0) return; + role.disableSlot[slot] = 0; + } - public void enableSlot(int slot, IPlayer player) { - if(slot >= 18 || slot < 0) return; - role.getArrayByName(player.getDisplayName(), role.playerDisableSlot)[slot] = 0; - } + public void enableSlot(int slot, IPlayer player) { + if (slot >= 18 || slot < 0) return; + role.getArrayByName(player.getDisplayName(), role.playerDisableSlot)[slot] = 0; + } - @Override - public int getType(){ - return RoleType.TRADER; - } + @Override + public int getType() { + return RoleType.TRADER; + } } diff --git a/src/main/java/noppes/npcs/scripted/roles/ScriptRoleTransporter.java b/src/main/java/noppes/npcs/scripted/roles/ScriptRoleTransporter.java index fb06b3ef7..f3d7dfe60 100644 --- a/src/main/java/noppes/npcs/scripted/roles/ScriptRoleTransporter.java +++ b/src/main/java/noppes/npcs/scripted/roles/ScriptRoleTransporter.java @@ -9,40 +9,40 @@ import noppes.npcs.roles.RoleTransporter; import noppes.npcs.scripted.constants.RoleType; public class ScriptRoleTransporter extends ScriptRoleInterface implements IRoleTransporter { - private final RoleTransporter role; + private final RoleTransporter role; - public ScriptRoleTransporter(EntityNPCInterface npc) { - super(npc); - role = (RoleTransporter) npc.roleInterface; + public ScriptRoleTransporter(EntityNPCInterface npc) { + super(npc); + role = (RoleTransporter) npc.roleInterface; - } + } - public String getName() { - return role.name; - } + public String getName() { + return role.name; + } - public int getTransportId() { - return role.transportId; - } + public int getTransportId() { + return role.transportId; + } - public void unlock(IPlayer player, ITransportLocation location) { - this.role.unlock(player.getMCEntity(), location); - } + public void unlock(IPlayer player, ITransportLocation location) { + this.role.unlock(player.getMCEntity(), location); + } - public ITransportLocation getTransport(){ - return this.role.getLocation(); - } + public ITransportLocation getTransport() { + return this.role.getLocation(); + } - public boolean hasTransport(){ - return this.role.hasTransport(); - } + public boolean hasTransport() { + return this.role.hasTransport(); + } - public void setTransport(ITransportLocation location) { - this.role.setTransport(location); - } + public void setTransport(ITransportLocation location) { + this.role.setTransport(location); + } - @Override - public int getType(){ - return RoleType.TRANSPORTER; - } + @Override + public int getType() { + return RoleType.TRANSPORTER; + } } diff --git a/src/main/java/noppes/npcs/scripted/scoreboard/ScriptScoreboard.java b/src/main/java/noppes/npcs/scripted/scoreboard/ScriptScoreboard.java index 75b9f7055..8ab5de0b1 100644 --- a/src/main/java/noppes/npcs/scripted/scoreboard/ScriptScoreboard.java +++ b/src/main/java/noppes/npcs/scripted/scoreboard/ScriptScoreboard.java @@ -14,190 +14,190 @@ import java.util.List; * @author Karel */ public class ScriptScoreboard implements IScoreboard { - private Scoreboard board; + private Scoreboard board; - public ScriptScoreboard(){ - board = MinecraftServer.getServer().worldServerForDimension(0).getScoreboard(); - } - - /** - * @return Returns an array with all ScoreboardObjectives - */ - public IScoreboardObjective[] getObjectives(){ + public ScriptScoreboard() { + board = MinecraftServer.getServer().worldServerForDimension(0).getScoreboard(); + } + + /** + * @return Returns an array with all ScoreboardObjectives + */ + public IScoreboardObjective[] getObjectives() { List collection = new ArrayList(board.getScoreObjectives()); - IScoreboardObjective[] objectives = new IScoreboardObjective[collection.size()]; - for(int i = 0; i < collection.size(); i++){ - objectives[i] = new ScriptScoreboardObjective(collection.get(i)); + IScoreboardObjective[] objectives = new IScoreboardObjective[collection.size()]; + for (int i = 0; i < collection.size(); i++) { + objectives[i] = new ScriptScoreboardObjective(collection.get(i)); } return objectives; - } - - /** - * @param name Name of the objective - * @return Returns the ScoreboardObjective - */ - public IScoreboardObjective getObjective(String name){ - ScoreObjective obj = board.getObjective(name); - if(obj == null) - return null; - return new ScriptScoreboardObjective(obj); - } - - /** - * @param objective Objective to check - * @return Returns whether or not the objective exists - */ - public boolean hasObjective(String objective){ + } + + /** + * @param name Name of the objective + * @return Returns the ScoreboardObjective + */ + public IScoreboardObjective getObjective(String name) { + ScoreObjective obj = board.getObjective(name); + if (obj == null) + return null; + return new ScriptScoreboardObjective(obj); + } + + /** + * @param objective Objective to check + * @return Returns whether or not the objective exists + */ + public boolean hasObjective(String objective) { return board.getObjective(objective) != null; - } - - /** - * @param objective Objective to remove - */ - public void removeObjective(String objective){ - ScoreObjective obj = board.getObjective(objective); - if(obj != null) - board.func_96519_k(obj); - } - - /** - * @version 1.8 - * @param objective Scoreboard objective name (1-16 chars) - * @param criteria The criteria see http://minecraft.wiki/w/Scoreboard#Objectives - * @return Returns the created ScoreboardObjective, returns null if it failed to create - */ - public IScoreboardObjective addObjective(String objective, String criteria){ - if(hasObjective(objective)) - return null; - - IScoreObjectiveCriteria icriteria = (IScoreObjectiveCriteria)IScoreObjectiveCriteria.field_96643_a.get(criteria); - if(icriteria == null) - return null; - - if(objective.length() == 0 || objective.length() > 16) - return null; - + } + + /** + * @param objective Objective to remove + */ + public void removeObjective(String objective) { + ScoreObjective obj = board.getObjective(objective); + if (obj != null) + board.func_96519_k(obj); + } + + /** + * @param objective Scoreboard objective name (1-16 chars) + * @param criteria The criteria see http://minecraft.wiki/w/Scoreboard#Objectives + * @return Returns the created ScoreboardObjective, returns null if it failed to create + * @version 1.8 + */ + public IScoreboardObjective addObjective(String objective, String criteria) { + if (hasObjective(objective)) + return null; + + IScoreObjectiveCriteria icriteria = (IScoreObjectiveCriteria) IScoreObjectiveCriteria.field_96643_a.get(criteria); + if (icriteria == null) + return null; + + if (objective.length() == 0 || objective.length() > 16) + return null; + ScoreObjective obj = board.addScoreObjective(objective, icriteria); return new ScriptScoreboardObjective(obj); - } + } - /** - * @since 1.7.10c - * @param player Name of a player or non existing thing - * @param objective Scoreboard objective name - * @param score Score as integer between -2,147,483,648 and 2,147,483,647 - * @param datatag Optional tag to specify type, can be left empty - */ - public void setPlayerScore(String player, String objective, int score, String datatag){ - ScoreObjective objec = board.getObjective(objective); - if(objec == null || objec.getCriteria().isReadOnly() || - score < Integer.MIN_VALUE || score > Integer.MAX_VALUE) - return; + /** + * @param player Name of a player or non existing thing + * @param objective Scoreboard objective name + * @param score Score as integer between -2,147,483,648 and 2,147,483,647 + * @param datatag Optional tag to specify type, can be left empty + * @since 1.7.10c + */ + public void setPlayerScore(String player, String objective, int score, String datatag) { + ScoreObjective objec = board.getObjective(objective); + if (objec == null || objec.getCriteria().isReadOnly() || + score < Integer.MIN_VALUE || score > Integer.MAX_VALUE) + return; Score sco = board.func_96529_a(player, objec); sco.setScorePoints(score); - } + } - public void setPlayerScore(IPlayer player, String objective, int score, String datatag){ - this.setPlayerScore(player.getName(),objective,score,datatag); - } + public void setPlayerScore(IPlayer player, String objective, int score, String datatag) { + this.setPlayerScore(player.getName(), objective, score, datatag); + } - /** - * @since 1.7.10c - * @param player Name of a player or non existing thing - * @param objective Scoreboard objective name - * @param datatag Optional tag to specify type, can be left empty - * @return Returns score value - */ - public int getPlayerScore(String player, String objective, String datatag){ - ScoreObjective objec = board.getObjective(objective); - if(objec == null || objec.getCriteria().isReadOnly()) - return 0; + /** + * @param player Name of a player or non existing thing + * @param objective Scoreboard objective name + * @param datatag Optional tag to specify type, can be left empty + * @return Returns score value + * @since 1.7.10c + */ + public int getPlayerScore(String player, String objective, String datatag) { + ScoreObjective objec = board.getObjective(objective); + if (objec == null || objec.getCriteria().isReadOnly()) + return 0; - return board.func_96529_a(player, objec).getScorePoints(); - } + return board.func_96529_a(player, objec).getScorePoints(); + } - public int getPlayerScore(IPlayer player, String objective, String datatag){ - return this.getPlayerScore(player.getName(),objective,datatag); - } + public int getPlayerScore(IPlayer player, String objective, String datatag) { + return this.getPlayerScore(player.getName(), objective, datatag); + } - /** - * @version 1.8 - * @param player Name of a player or non existing thing - * @param objective Scoreboard objective name - * @param datatag Optional tag to specify type, can be left empty - * @return Returns whether or not the player has the objective - */ - public boolean hasPlayerObjective(String player, String objective, String datatag){ - ScoreObjective objec = board.getObjective(objective); - if(objec == null) - return false; - - return board.func_96510_d(player).get(objec) != null; - } + /** + * @param player Name of a player or non existing thing + * @param objective Scoreboard objective name + * @param datatag Optional tag to specify type, can be left empty + * @return Returns whether or not the player has the objective + * @version 1.8 + */ + public boolean hasPlayerObjective(String player, String objective, String datatag) { + ScoreObjective objec = board.getObjective(objective); + if (objec == null) + return false; - public boolean hasPlayerObjective(IPlayer player, String objective, String datatag){ - return this.hasPlayerObjective(player.getName(),objective,datatag); - } - - /** - * @version 1.8 - * @param player Name of a player or non existing thing - * @param objective Scoreboard objective name - * @param datatag Optional tag to specify type, can be left empty - */ - public void deletePlayerScore(String player, String objective, String datatag){ - ScoreObjective objec = board.getObjective(objective); - if(objec == null) - return; + return board.func_96510_d(player).get(objec) != null; + } - if(board.func_96510_d(player).remove(objec) != null) - board.func_96516_a(player); - } + public boolean hasPlayerObjective(IPlayer player, String objective, String datatag) { + return this.hasPlayerObjective(player.getName(), objective, datatag); + } - public void deletePlayerScore(IPlayer player, String objective, String datatag){ - this.deletePlayerScore(player.getName(),objective,datatag); - } - - public IScoreboardTeam[] getTeams(){ - List list = new ArrayList(board.getTeams()); - IScoreboardTeam[] teams = new IScoreboardTeam[list.size()]; - for(int i = 0; i < list.size(); i++){ - teams[i] = new ScriptScoreboardTeam(list.get(i), board); - } - return teams; - } - - public IScoreboardTeam getTeamByName(String name) { - IScoreboardTeam[] teams = getTeams(); - for (int i = 0; i < teams.length; i++) { - if (teams[i].getName().equals(name)) { - return teams[i]; - } - } - return null; - } - - public boolean hasTeam(String name){ - return board.getPlayersTeam(name) != null; - } - - public IScoreboardTeam addTeam(String name){ - if(hasTeam(name)) - return null; - return new ScriptScoreboardTeam(board.createTeam(name), board); - } - - public IScoreboardTeam getTeam(String name){ - ScorePlayerTeam team = board.getPlayersTeam(name); - if(team == null) - return null; - return new ScriptScoreboardTeam(team, board); - } - - public void removeTeam(String name){ - ScorePlayerTeam team = board.getPlayersTeam(name); - if(team != null) - board.removeTeam(team); - } + /** + * @param player Name of a player or non existing thing + * @param objective Scoreboard objective name + * @param datatag Optional tag to specify type, can be left empty + * @version 1.8 + */ + public void deletePlayerScore(String player, String objective, String datatag) { + ScoreObjective objec = board.getObjective(objective); + if (objec == null) + return; + + if (board.func_96510_d(player).remove(objec) != null) + board.func_96516_a(player); + } + + public void deletePlayerScore(IPlayer player, String objective, String datatag) { + this.deletePlayerScore(player.getName(), objective, datatag); + } + + public IScoreboardTeam[] getTeams() { + List list = new ArrayList(board.getTeams()); + IScoreboardTeam[] teams = new IScoreboardTeam[list.size()]; + for (int i = 0; i < list.size(); i++) { + teams[i] = new ScriptScoreboardTeam(list.get(i), board); + } + return teams; + } + + public IScoreboardTeam getTeamByName(String name) { + IScoreboardTeam[] teams = getTeams(); + for (int i = 0; i < teams.length; i++) { + if (teams[i].getName().equals(name)) { + return teams[i]; + } + } + return null; + } + + public boolean hasTeam(String name) { + return board.getPlayersTeam(name) != null; + } + + public IScoreboardTeam addTeam(String name) { + if (hasTeam(name)) + return null; + return new ScriptScoreboardTeam(board.createTeam(name), board); + } + + public IScoreboardTeam getTeam(String name) { + ScorePlayerTeam team = board.getPlayersTeam(name); + if (team == null) + return null; + return new ScriptScoreboardTeam(team, board); + } + + public void removeTeam(String name) { + ScorePlayerTeam team = board.getPlayersTeam(name); + if (team != null) + board.removeTeam(team); + } } diff --git a/src/main/java/noppes/npcs/scripted/scoreboard/ScriptScoreboardObjective.java b/src/main/java/noppes/npcs/scripted/scoreboard/ScriptScoreboardObjective.java index 164627baf..477bb5b4d 100644 --- a/src/main/java/noppes/npcs/scripted/scoreboard/ScriptScoreboardObjective.java +++ b/src/main/java/noppes/npcs/scripted/scoreboard/ScriptScoreboardObjective.java @@ -4,48 +4,48 @@ import net.minecraft.scoreboard.ScoreObjective; import noppes.npcs.api.scoreboard.IScoreboardObjective; public class ScriptScoreboardObjective implements IScoreboardObjective { - private ScoreObjective objective; - - public ScriptScoreboardObjective(ScoreObjective objective){ - this.objective = objective; - } - - /** - * @return Returns objective name - */ - public String getName(){ - return objective.getName(); - } - - /** - * @return Returns display name - */ - public String getDisplayName(){ - return objective.getDisplayName(); - } - - /** - * @since 1.7.10c - * @param name Name used for display (1-32 chars) - */ - public void setDisplayName(String name){ - if(name.length() > 0 && name.length() <= 32) - objective.setDisplayName(name); - } - - /** - * @since 1.7.10c - * @return Returns the criteria string - */ - public String getCriteria(){ - return objective.getCriteria().func_96636_a(); - } - - /** - * @return Return whether or not the objective value can be changed. E.g. player health can't be changed - */ - public boolean isReadyOnly(){ - return objective.getCriteria().isReadOnly(); - } - + private ScoreObjective objective; + + public ScriptScoreboardObjective(ScoreObjective objective) { + this.objective = objective; + } + + /** + * @return Returns objective name + */ + public String getName() { + return objective.getName(); + } + + /** + * @return Returns display name + */ + public String getDisplayName() { + return objective.getDisplayName(); + } + + /** + * @param name Name used for display (1-32 chars) + * @since 1.7.10c + */ + public void setDisplayName(String name) { + if (name.length() > 0 && name.length() <= 32) + objective.setDisplayName(name); + } + + /** + * @return Returns the criteria string + * @since 1.7.10c + */ + public String getCriteria() { + return objective.getCriteria().func_96636_a(); + } + + /** + * @return Return whether or not the objective value can be changed. E.g. player health can't be changed + */ + public boolean isReadyOnly() { + return objective.getCriteria().isReadOnly(); + } + } diff --git a/src/main/java/noppes/npcs/scripted/scoreboard/ScriptScoreboardTeam.java b/src/main/java/noppes/npcs/scripted/scoreboard/ScriptScoreboardTeam.java index af04c86f2..1af95fd58 100644 --- a/src/main/java/noppes/npcs/scripted/scoreboard/ScriptScoreboardTeam.java +++ b/src/main/java/noppes/npcs/scripted/scoreboard/ScriptScoreboardTeam.java @@ -10,101 +10,102 @@ import java.util.ArrayList; import java.util.List; public class ScriptScoreboardTeam implements IScoreboardTeam { - private ScorePlayerTeam team; - private Scoreboard board; - public ScriptScoreboardTeam(ScorePlayerTeam team, Scoreboard board){ - this.team = team; - this.board = board; - } - - public String getName(){ - return team.getRegisteredName(); - } - - public String getDisplayName(){ - return team.func_96669_c(); - } - - /** - * @param name Name used as display (1-32 chars) - */ - public void setDisplayName(String name){ - if(name.length() > 0 && name.length() <= 32) - team.setTeamName(name); - } - - public void addPlayer(String player){ - board.func_151392_a(player, getName()); - } + private ScorePlayerTeam team; + private Scoreboard board; - public void addPlayer(IPlayer player) { - this.addPlayer(player.getName()); - } - - public void removePlayer(String player){ - board.removePlayerFromTeam(player, team); - } + public ScriptScoreboardTeam(ScorePlayerTeam team, Scoreboard board) { + this.team = team; + this.board = board; + } - public void removePlayer(IPlayer player) { - this.removePlayer(player.getName()); - } - - public String[] getPlayers(){ - List list = new ArrayList(team.getMembershipCollection()); - return list.toArray(new String[list.size()]); - } - - public int getTeamsize() { - return team.getMembershipCollection().size(); - } - - public void clearPlayers(){ + public String getName() { + return team.getRegisteredName(); + } + + public String getDisplayName() { + return team.func_96669_c(); + } + + /** + * @param name Name used as display (1-32 chars) + */ + public void setDisplayName(String name) { + if (name.length() > 0 && name.length() <= 32) + team.setTeamName(name); + } + + public void addPlayer(String player) { + board.func_151392_a(player, getName()); + } + + public void addPlayer(IPlayer player) { + this.addPlayer(player.getName()); + } + + public void removePlayer(String player) { + board.removePlayerFromTeam(player, team); + } + + public void removePlayer(IPlayer player) { + this.removePlayer(player.getName()); + } + + public String[] getPlayers() { List list = new ArrayList(team.getMembershipCollection()); - for(String player : list){ - board.removePlayerFromTeam(player, team); + return list.toArray(new String[list.size()]); + } + + public int getTeamsize() { + return team.getMembershipCollection().size(); + } + + public void clearPlayers() { + List list = new ArrayList(team.getMembershipCollection()); + for (String player : list) { + board.removePlayerFromTeam(player, team); } - } - - public boolean getFriendlyFire(){ - return team.getAllowFriendlyFire(); - } - - public void setFriendlyFire(boolean bo){ - team.setAllowFriendlyFire(bo); - } - - /** - * @param color Valid color values are "black", "dark_blue", "dark_green", "dark_aqua", "dark_red", "dark_purple", "gold", "gray", "dark_gray", "blue", "green", "aqua", "red", "light_purple", "yellow", and "white". Or "reset" if you want default - */ - public void setColor(String color){ + } + + public boolean getFriendlyFire() { + return team.getAllowFriendlyFire(); + } + + public void setFriendlyFire(boolean bo) { + team.setAllowFriendlyFire(bo); + } + + /** + * @param color Valid color values are "black", "dark_blue", "dark_green", "dark_aqua", "dark_red", "dark_purple", "gold", "gray", "dark_gray", "blue", "green", "aqua", "red", "light_purple", "yellow", and "white". Or "reset" if you want default + */ + public void setColor(String color) { EnumChatFormatting enumchatformatting = EnumChatFormatting.getValueByName(color); if (enumchatformatting == null || enumchatformatting.isFancyStyling()) - return; + return; team.setNamePrefix(enumchatformatting.toString()); team.setNameSuffix(EnumChatFormatting.RESET.toString()); - } - - /** - * @return Returns color string. Returns null if no color was set - */ - public String getColor(){ - String prefix = team.getColorPrefix(); - if(prefix == null || prefix.isEmpty()) - return null; - for(EnumChatFormatting format : EnumChatFormatting.values()){ - if(prefix.equals(format.toString()) && format != EnumChatFormatting.RESET) - return format.getFriendlyName(); - } - return null; - } - - public void setSeeInvisibleTeamPlayers(boolean bo){ - team.setSeeFriendlyInvisiblesEnabled(bo); - } - - public boolean getSeeInvisibleTeamPlayers(){ - return team.func_98297_h(); - } + } + + /** + * @return Returns color string. Returns null if no color was set + */ + public String getColor() { + String prefix = team.getColorPrefix(); + if (prefix == null || prefix.isEmpty()) + return null; + for (EnumChatFormatting format : EnumChatFormatting.values()) { + if (prefix.equals(format.toString()) && format != EnumChatFormatting.RESET) + return format.getFriendlyName(); + } + return null; + } + + public void setSeeInvisibleTeamPlayers(boolean bo) { + team.setSeeFriendlyInvisiblesEnabled(bo); + } + + public boolean getSeeInvisibleTeamPlayers() { + return team.func_98297_h(); + } } diff --git a/src/main/java/noppes/npcs/util/CacheHashMap.java b/src/main/java/noppes/npcs/util/CacheHashMap.java index 12e682b61..6b326355e 100644 --- a/src/main/java/noppes/npcs/util/CacheHashMap.java +++ b/src/main/java/noppes/npcs/util/CacheHashMap.java @@ -22,9 +22,9 @@ public class CacheHashMap> extends Has V object = super.get(key); object.updateTimeAccessed(); - Iterator> iterator = this.entrySet().iterator(); + Iterator> iterator = this.entrySet().iterator(); while (iterator.hasNext()) { - Map.Entry entry = iterator.next(); + Map.Entry entry = iterator.next(); long lifeTimeDiff = entry.getValue().timeSinceAccessed(); if (lifeTimeDiff > this.maxCacheTime) { entry.getValue().save(); @@ -68,7 +68,8 @@ public class CacheHashMap> extends Has this.timeSaved = System.currentTimeMillis(); } - public void save(){} + public void save() { + } public T getObject() { return this.object; diff --git a/src/main/java/noppes/npcs/util/CustomNPCsThreader.java b/src/main/java/noppes/npcs/util/CustomNPCsThreader.java index b63b5fbf1..3019fb5b1 100644 --- a/src/main/java/noppes/npcs/util/CustomNPCsThreader.java +++ b/src/main/java/noppes/npcs/util/CustomNPCsThreader.java @@ -4,5 +4,5 @@ import java.util.concurrent.Executor; import java.util.concurrent.Executors; public class CustomNPCsThreader { - public static final Executor customNPCThread = Executors.newSingleThreadExecutor(); + public static final Executor customNPCThread = Executors.newSingleThreadExecutor(); } diff --git a/src/main/java/noppes/npcs/util/GameProfileAlt.java b/src/main/java/noppes/npcs/util/GameProfileAlt.java index 40403a1ab..a6f6f22a2 100644 --- a/src/main/java/noppes/npcs/util/GameProfileAlt.java +++ b/src/main/java/noppes/npcs/util/GameProfileAlt.java @@ -5,24 +5,25 @@ import noppes.npcs.entity.EntityNPCInterface; import java.util.UUID; -public class GameProfileAlt extends GameProfile{ - private static final UUID id = UUID.randomUUID(); - public EntityNPCInterface npc; - public GameProfileAlt() { - super(null, "customnpc"); - } +public class GameProfileAlt extends GameProfile { + private static final UUID id = UUID.randomUUID(); + public EntityNPCInterface npc; - @Override + public GameProfileAlt() { + super(null, "customnpc"); + } + + @Override public String getName() { - if(npc == null) - return super.getName(); + if (npc == null) + return super.getName(); return npc.getCommandSenderName(); } - + @Override - public UUID getId(){ - if(npc == null) - return id; - return npc.getPersistentID(); + public UUID getId() { + if (npc == null) + return id; + return npc.getPersistentID(); } } diff --git a/src/main/java/noppes/npcs/util/IProjectileCallback.java b/src/main/java/noppes/npcs/util/IProjectileCallback.java index 1a1b4e02f..08e465cee 100644 --- a/src/main/java/noppes/npcs/util/IProjectileCallback.java +++ b/src/main/java/noppes/npcs/util/IProjectileCallback.java @@ -6,7 +6,7 @@ import noppes.npcs.entity.EntityProjectile; public interface IProjectileCallback { - boolean onImpact(EntityProjectile entityProjectile, - EntityLivingBase entity, ItemStack itemstack); + boolean onImpact(EntityProjectile entityProjectile, + EntityLivingBase entity, ItemStack itemstack); } diff --git a/src/main/java/noppes/npcs/util/JsonException.java b/src/main/java/noppes/npcs/util/JsonException.java index 9358469af..f9d6583ca 100644 --- a/src/main/java/noppes/npcs/util/JsonException.java +++ b/src/main/java/noppes/npcs/util/JsonException.java @@ -2,8 +2,8 @@ package noppes.npcs.util; import noppes.npcs.util.NBTJsonUtil.JsonFile; -public class JsonException extends Exception{ - public JsonException(String message, JsonFile json){ - super(message + ": " + json.getCurrentPos()); - } +public class JsonException extends Exception { + public JsonException(String message, JsonFile json) { + super(message + ": " + json.getCurrentPos()); + } } diff --git a/src/main/java/noppes/npcs/util/MillisTimer.java b/src/main/java/noppes/npcs/util/MillisTimer.java index 82acb5c7f..ee1dc3381 100644 --- a/src/main/java/noppes/npcs/util/MillisTimer.java +++ b/src/main/java/noppes/npcs/util/MillisTimer.java @@ -12,8 +12,7 @@ public class MillisTimer { private long field_74285_i; private double timeSyncAdjustment = 1.0D; - public MillisTimer(float p_i1018_1_) - { + public MillisTimer(float p_i1018_1_) { this.ticksPerSecond = p_i1018_1_; this.lastSyncSysClock = this.getLastSyncSysClock(); this.lastSyncHRClock = System.nanoTime() / 1000000L; @@ -22,33 +21,27 @@ public class MillisTimer { /** * Updates all fields of the Timer using the current time */ - public void updateTimer() - { + public void updateTimer() { long i = this.getLastSyncSysClock(); long j = i - this.lastSyncSysClock; long k = System.nanoTime() / 1000000L; - double d0 = (double)k / 1000.0D; + double d0 = (double) k / 1000.0D; - if (j <= 1000L && j >= 0L) - { + if (j <= 1000L && j >= 0L) { this.field_74285_i += j; - if (this.field_74285_i > 1000L) - { + if (this.field_74285_i > 1000L) { long l = k - this.lastSyncHRClock; - double d1 = (double)this.field_74285_i / (double)l; + double d1 = (double) this.field_74285_i / (double) l; this.timeSyncAdjustment += (d1 - this.timeSyncAdjustment) * 0.20000000298023224D; this.lastSyncHRClock = k; this.field_74285_i = 0L; } - if (this.field_74285_i < 0L) - { + if (this.field_74285_i < 0L) { this.lastSyncHRClock = k; } - } - else - { + } else { this.lastHRTime = d0; } @@ -56,22 +49,19 @@ public class MillisTimer { double d2 = (d0 - this.lastHRTime) * this.timeSyncAdjustment; this.lastHRTime = d0; - if (d2 < 0.0D) - { + if (d2 < 0.0D) { d2 = 0.0D; } - if (d2 > 1.0D) - { + if (d2 > 1.0D) { d2 = 1.0D; } - this.elapsedPartialTicks = (float)((double)this.elapsedPartialTicks + d2 * (double)this.timerSpeed * (double)this.ticksPerSecond); - this.elapsedTicks = (int)this.elapsedPartialTicks; - this.elapsedPartialTicks -= (float)this.elapsedTicks; + this.elapsedPartialTicks = (float) ((double) this.elapsedPartialTicks + d2 * (double) this.timerSpeed * (double) this.ticksPerSecond); + this.elapsedTicks = (int) this.elapsedPartialTicks; + this.elapsedPartialTicks -= (float) this.elapsedTicks; - if (this.elapsedTicks > 10) - { + if (this.elapsedTicks > 10) { this.elapsedTicks = 10; } diff --git a/src/main/java/noppes/npcs/util/NBTJsonUtil.java b/src/main/java/noppes/npcs/util/NBTJsonUtil.java index ae8cbc7c2..6b6fd61c3 100644 --- a/src/main/java/noppes/npcs/util/NBTJsonUtil.java +++ b/src/main/java/noppes/npcs/util/NBTJsonUtil.java @@ -11,206 +11,201 @@ import java.util.ArrayList; import java.util.List; public class NBTJsonUtil { - public static String Convert(NBTTagCompound compound){ - List list = new ArrayList(); - JsonLine line = ReadTag("", compound, list); - line.removeComma(); - return ConvertList(list); - } + public static String Convert(NBTTagCompound compound) { + List list = new ArrayList(); + JsonLine line = ReadTag("", compound, list); + line.removeComma(); + return ConvertList(list); + } - public static NBTTagCompound Convert(String json) throws JsonException{ - json = json.trim(); - JsonFile file = new JsonFile(json); - if(!json.startsWith("{") || !json.endsWith("}")) - throw new JsonException("Not properly incapsulated between { }", file); + public static NBTTagCompound Convert(String json) throws JsonException { + json = json.trim(); + JsonFile file = new JsonFile(json); + if (!json.startsWith("{") || !json.endsWith("}")) + throw new JsonException("Not properly incapsulated between { }", file); - NBTTagCompound compound = new NBTTagCompound(); - FillCompound(compound, file); - return compound; - } + NBTTagCompound compound = new NBTTagCompound(); + FillCompound(compound, file); + return compound; + } - public static void FillCompound(NBTTagCompound compound, JsonFile json) throws JsonException{ - if(json.startsWith("{") || json.startsWith(",")) - json.cut(1); - if(json.startsWith("}")) - return; - int index = json.indexOf(":"); - if(index < 1) - throw new JsonException("Expected key after ," ,json); + public static void FillCompound(NBTTagCompound compound, JsonFile json) throws JsonException { + if (json.startsWith("{") || json.startsWith(",")) + json.cut(1); + if (json.startsWith("}")) + return; + int index = json.indexOf(":"); + if (index < 1) + throw new JsonException("Expected key after ,", json); - String key = json.substring(0, index); - json.cut(index + 1); + String key = json.substring(0, index); + json.cut(index + 1); - NBTBase base = ReadValue(json); + NBTBase base = ReadValue(json); - if(base == null) - base = new NBTTagString(); + if (base == null) + base = new NBTTagString(); - if(key.startsWith("\"")) - key = key.substring(1); - if(key.endsWith("\"")) - key = key.substring(0, key.length() - 1); + if (key.startsWith("\"")) + key = key.substring(1); + if (key.endsWith("\"")) + key = key.substring(0, key.length() - 1); - compound.setTag(key, base); - if(json.startsWith(",")) - FillCompound(compound, json); + compound.setTag(key, base); + if (json.startsWith(",")) + FillCompound(compound, json); - } + } - public static NBTBase ReadValue(JsonFile json) throws JsonException{ - if(json.startsWith("{")){ - NBTTagCompound compound = new NBTTagCompound(); - FillCompound(compound, json); - if(!json.startsWith("}")){ - throw new JsonException("Expected }", json); - } - json.cut(1); + public static NBTBase ReadValue(JsonFile json) throws JsonException { + if (json.startsWith("{")) { + NBTTagCompound compound = new NBTTagCompound(); + FillCompound(compound, json); + if (!json.startsWith("}")) { + throw new JsonException("Expected }", json); + } + json.cut(1); - return compound; - } - if(json.startsWith("[")){ - json.cut(1); - NBTTagList list = new NBTTagList(); + return compound; + } + if (json.startsWith("[")) { + json.cut(1); + NBTTagList list = new NBTTagList(); - NBTBase value = ReadValue(json); - while(value != null){ - list.appendTag(value); - if(!json.startsWith(",")) - break; - json.cut(1); - value = ReadValue(json); - } - if(!json.startsWith("]")){ - throw new JsonException("Expected ]", json); - } - json.cut(1); + NBTBase value = ReadValue(json); + while (value != null) { + list.appendTag(value); + if (!json.startsWith(",")) + break; + json.cut(1); + value = ReadValue(json); + } + if (!json.startsWith("]")) { + throw new JsonException("Expected ]", json); + } + json.cut(1); - if(list.func_150303_d() == 3){ - int[] arr = new int[list.tagCount()]; - for(int i = 0; list.tagCount() > 0 ; i++){ - arr[i] = ((NBTTagInt)list.removeTag(0)).func_150287_d(); - } - return new NBTTagIntArray(arr); - } - if(list.func_150303_d() == 1){ - byte[] arr = new byte[list.tagCount()]; - for(int i = 0; list.tagCount() > 0 ; i++){ - arr[i] = ((NBTTagByte)list.removeTag(0)).func_150290_f(); - } - return new NBTTagByteArray(arr); - } + if (list.func_150303_d() == 3) { + int[] arr = new int[list.tagCount()]; + for (int i = 0; list.tagCount() > 0; i++) { + arr[i] = ((NBTTagInt) list.removeTag(0)).func_150287_d(); + } + return new NBTTagIntArray(arr); + } + if (list.func_150303_d() == 1) { + byte[] arr = new byte[list.tagCount()]; + for (int i = 0; list.tagCount() > 0; i++) { + arr[i] = ((NBTTagByte) list.removeTag(0)).func_150290_f(); + } + return new NBTTagByteArray(arr); + } - return list; - } - if(json.startsWith("\"")){ - json.cut(1); - String s = ""; - boolean ignore = false; - while(!json.startsWith("\"") || ignore){ - String cut = json.cutDirty(1); - ignore = cut.equals("\\"); - s += cut; - } - json.cut(1); - return new NBTTagString(s.replace("\\\"", "\"")); - } - String s = ""; - while(!json.startsWith(",", "]", "}")){ - s += json.cut(1); - } - s = s.trim().toLowerCase(); - if(s.isEmpty() || s.contains("bytes]")) - return null; - try{ - if(s.endsWith("d")){ - return new NBTTagDouble(Double.parseDouble(s.substring(0, s.length() - 1))); - } - if(s.endsWith("f")){ - return new NBTTagFloat(Float.parseFloat(s.substring(0, s.length() - 1))); - } - if(s.endsWith("b")){ - return new NBTTagByte(Byte.parseByte(s.substring(0, s.length() - 1))); - } - if(s.endsWith("s")){ - return new NBTTagShort(Short.parseShort(s.substring(0, s.length() - 1))); - } - if(s.endsWith("l")){ - return new NBTTagLong(Long.parseLong(s.substring(0, s.length() - 1))); - } - if(s.contains(".")) - return new NBTTagDouble(Double.parseDouble(s)); - else - return new NBTTagInt(Integer.parseInt(s)); - } - catch(NumberFormatException ex){ - throw new JsonException("Unable to convert: "+ s +" to a number", json); - } - } + return list; + } + if (json.startsWith("\"")) { + json.cut(1); + String s = ""; + boolean ignore = false; + while (!json.startsWith("\"") || ignore) { + String cut = json.cutDirty(1); + ignore = cut.equals("\\"); + s += cut; + } + json.cut(1); + return new NBTTagString(s.replace("\\\"", "\"")); + } + String s = ""; + while (!json.startsWith(",", "]", "}")) { + s += json.cut(1); + } + s = s.trim().toLowerCase(); + if (s.isEmpty() || s.contains("bytes]")) + return null; + try { + if (s.endsWith("d")) { + return new NBTTagDouble(Double.parseDouble(s.substring(0, s.length() - 1))); + } + if (s.endsWith("f")) { + return new NBTTagFloat(Float.parseFloat(s.substring(0, s.length() - 1))); + } + if (s.endsWith("b")) { + return new NBTTagByte(Byte.parseByte(s.substring(0, s.length() - 1))); + } + if (s.endsWith("s")) { + return new NBTTagShort(Short.parseShort(s.substring(0, s.length() - 1))); + } + if (s.endsWith("l")) { + return new NBTTagLong(Long.parseLong(s.substring(0, s.length() - 1))); + } + if (s.contains(".")) + return new NBTTagDouble(Double.parseDouble(s)); + else + return new NBTTagInt(Integer.parseInt(s)); + } catch (NumberFormatException ex) { + throw new JsonException("Unable to convert: " + s + " to a number", json); + } + } - private static List getListData(NBTTagList list){ - return ObfuscationReflectionHelper.getPrivateValue(NBTTagList.class, list, 0); - } + private static List getListData(NBTTagList list) { + return ObfuscationReflectionHelper.getPrivateValue(NBTTagList.class, list, 0); + } - private static JsonLine ReadTag(String name, NBTBase base, List list){ - if(!name.isEmpty()) - name = "\"" + name + "\": "; - if(base.getId() == 8){//NBTTagString - String data = ((NBTTagString)base).func_150285_a_(); - data = data.replace("\"", "\\\""); //replace " with \" - list.add(new JsonLine(name + "\"" + data + "\"")); - } - else if(base.getId() == 9){//NBTTagList - list.add(new JsonLine(name + "[")); - NBTTagList tags = (NBTTagList) base; - JsonLine line = null; - List data = getListData(tags); - for(NBTBase b : data) - line = ReadTag("", b, list); - if(line != null) - line.removeComma(); - list.add(new JsonLine("]")); - } - else if(base.getId() == 10){ //NBTTagCompound - list.add(new JsonLine(name + "{")); - NBTTagCompound compound = (NBTTagCompound)base; - JsonLine line = null; - for(Object key : compound.func_150296_c()) - line = ReadTag(key.toString(), compound.getTag(key.toString()), list); + private static JsonLine ReadTag(String name, NBTBase base, List list) { + if (!name.isEmpty()) + name = "\"" + name + "\": "; + if (base.getId() == 8) {//NBTTagString + String data = ((NBTTagString) base).func_150285_a_(); + data = data.replace("\"", "\\\""); //replace " with \" + list.add(new JsonLine(name + "\"" + data + "\"")); + } else if (base.getId() == 9) {//NBTTagList + list.add(new JsonLine(name + "[")); + NBTTagList tags = (NBTTagList) base; + JsonLine line = null; + List data = getListData(tags); + for (NBTBase b : data) + line = ReadTag("", b, list); + if (line != null) + line.removeComma(); + list.add(new JsonLine("]")); + } else if (base.getId() == 10) { //NBTTagCompound + list.add(new JsonLine(name + "{")); + NBTTagCompound compound = (NBTTagCompound) base; + JsonLine line = null; + for (Object key : compound.func_150296_c()) + line = ReadTag(key.toString(), compound.getTag(key.toString()), list); - if(line != null) - line.removeComma(); + if (line != null) + line.removeComma(); - list.add(new JsonLine("}")); - } - else if(base.getId() == 11){//NBTTagList - list.add(new JsonLine(name + base.toString().replaceFirst(",]", "]"))); - } - else{ - list.add(new JsonLine(name + base)); - } - JsonLine line = list.get(list.size() - 1); - line.line += ","; - return line; - } + list.add(new JsonLine("}")); + } else if (base.getId() == 11) {//NBTTagList + list.add(new JsonLine(name + base.toString().replaceFirst(",]", "]"))); + } else { + list.add(new JsonLine(name + base)); + } + JsonLine line = list.get(list.size() - 1); + line.line += ","; + return line; + } - private static String ConvertList(List list) { - String json = ""; - int tab = 0; - for(JsonLine tag : list){ - if(tag.reduceTab()) - tab--; - for(int i = 0; i < tab; i++){ - json += " "; - } - json += tag + "\n"; + private static String ConvertList(List list) { + String json = ""; + int tab = 0; + for (JsonLine tag : list) { + if (tag.reduceTab()) + tab--; + for (int i = 0; i < tab; i++) { + json += " "; + } + json += tag + "\n"; - if(tag.increaseTab()) - tab++; - } - return json; - } + if (tag.increaseTab()) + tab++; + } + return json; + } - public static NBTTagCompound loadNBTData(File file){ + public static NBTTagCompound loadNBTData(File file) { try { return CompressedStreamTools.readCompressed(new FileInputStream(file)); } catch (Exception e) { @@ -219,105 +214,107 @@ public class NBTJsonUtil { return new NBTTagCompound(); } - static class JsonLine{ - private String line; - public JsonLine(String line){ - this.line = line; - } + static class JsonLine { + private String line; - public void removeComma(){ - if(line.endsWith(",")) - line = line.substring(0, line.length() - 1); - } + public JsonLine(String line) { + this.line = line; + } - public boolean reduceTab(){ - int length = line.length(); - return length == 1 && (line.endsWith("}") || line.endsWith("]")) - || length == 2 && (line.endsWith("},") ||line.endsWith("],")); - } + public void removeComma() { + if (line.endsWith(",")) + line = line.substring(0, line.length() - 1); + } - public boolean increaseTab(){ - return line.endsWith("{") || line.endsWith("["); - } + public boolean reduceTab() { + int length = line.length(); + return length == 1 && (line.endsWith("}") || line.endsWith("]")) + || length == 2 && (line.endsWith("},") || line.endsWith("],")); + } - @Override - public String toString(){ - return line; - } - } - static class JsonFile{ - private String original; - private String text; + public boolean increaseTab() { + return line.endsWith("{") || line.endsWith("["); + } - public JsonFile(String text){ - this.text = text; - this.original = text; - } + @Override + public String toString() { + return line; + } + } - public String cutDirty(int i) { - String s = text.substring(0, i); - text = text.substring(i); - return s; - } + static class JsonFile { + private String original; + private String text; - public String cut(int i) { - String s = text.substring(0, i); - text = text.substring(i).trim(); - return s; - } + public JsonFile(String text) { + this.text = text; + this.original = text; + } - public String substring(int beginIndex, int endIndex) { - return text.substring(beginIndex, endIndex); - } + public String cutDirty(int i) { + String s = text.substring(0, i); + text = text.substring(i); + return s; + } - public int indexOf(String s) { - return text.indexOf(s); - } + public String cut(int i) { + String s = text.substring(0, i); + text = text.substring(i).trim(); + return s; + } - public String getCurrentPos(){ - int lengthOr = original.length(); - int lengthCur = text.length(); - int currentPos = lengthOr - lengthCur; - String done = original.substring(0, currentPos); - String[] lines = done.split("\r\n|\r|\n"); + public String substring(int beginIndex, int endIndex) { + return text.substring(beginIndex, endIndex); + } - int pos = 0; - String line = ""; - if(lines.length > 0){ - pos = lines[lines.length - 1].length(); - line = original.split("\r\n|\r|\n")[lines.length - 1].trim(); - } + public int indexOf(String s) { + return text.indexOf(s); + } - return "Line: " + lines.length + ", Pos: " + pos + ", Text: " + line; - } + public String getCurrentPos() { + int lengthOr = original.length(); + int lengthCur = text.length(); + int currentPos = lengthOr - lengthCur; + String done = original.substring(0, currentPos); + String[] lines = done.split("\r\n|\r|\n"); - public boolean startsWith(String... ss) { - for(String s : ss) - if(text.startsWith(s)) - return true; - return false; - } - public boolean endsWith(String s) { - return text.endsWith(s); - } - } + int pos = 0; + String line = ""; + if (lines.length > 0) { + pos = lines[lines.length - 1].length(); + line = original.split("\r\n|\r|\n")[lines.length - 1].trim(); + } + + return "Line: " + lines.length + ", Pos: " + pos + ", Text: " + line; + } + + public boolean startsWith(String... ss) { + for (String s : ss) + if (text.startsWith(s)) + return true; + return false; + } + + public boolean endsWith(String s) { + return text.endsWith(s); + } + } - public static NBTTagCompound LoadFile(File file) throws IOException, JsonException { - return Convert(Files.toString(file, Charsets.UTF_8)); - } + public static NBTTagCompound LoadFile(File file) throws IOException, JsonException { + return Convert(Files.toString(file, Charsets.UTF_8)); + } - public static void SaveFile(File file, NBTTagCompound compound) throws IOException, JsonException { - String json = Convert(compound); - OutputStreamWriter writer = null; - try{ - writer = new OutputStreamWriter(new FileOutputStream(file), Charsets.UTF_8); - writer.write(json); + public static void SaveFile(File file, NBTTagCompound compound) throws IOException, JsonException { + String json = Convert(compound); + OutputStreamWriter writer = null; + try { + writer = new OutputStreamWriter(new FileOutputStream(file), Charsets.UTF_8); + writer.write(json); - } - finally{ - if(writer != null) - writer.close(); - } - } + } finally { + if (writer != null) + writer.close(); + } + } } diff --git a/src/main/java/noppes/npcs/util/ValueUtil.java b/src/main/java/noppes/npcs/util/ValueUtil.java index 1643accd2..48cd0b1a9 100644 --- a/src/main/java/noppes/npcs/util/ValueUtil.java +++ b/src/main/java/noppes/npcs/util/ValueUtil.java @@ -1,50 +1,50 @@ package noppes.npcs.util; public class ValueUtil { - public static float clamp(float given, float min, float max){ - if(given < min) - return min; - return Math.min(given, max); - } - - public static int clamp(int given, int min, int max) { - if(given < min) - return min; - return Math.min(given, max); - } - - public static byte clamp(byte given, byte min, byte max) { - if(given < min) - return min; - if(given > max) - return max; - return given; - } - - public static double clamp(double given, double min, double max) { - if(given < min) - return min; - return Math.min(given, max); - } - - public static long clamp(long given, long min, long max) { - if(given < min) - return min; - return Math.min(given, max); - } - - public static float correctFloat(float given, float min, float max){ - if(given < min) + public static float clamp(float given, float min, float max) { + if (given < min) return min; - if(given > max) + return Math.min(given, max); + } + + public static int clamp(int given, int min, int max) { + if (given < min) + return min; + return Math.min(given, max); + } + + public static byte clamp(byte given, byte min, byte max) { + if (given < min) + return min; + if (given > max) + return max; + return given; + } + + public static double clamp(double given, double min, double max) { + if (given < min) + return min; + return Math.min(given, max); + } + + public static long clamp(long given, long min, long max) { + if (given < min) + return min; + return Math.min(given, max); + } + + public static float correctFloat(float given, float min, float max) { + if (given < min) + return min; + if (given > max) return max; return given; } public static int CorrectInt(int given, int min, int max) { - if(given < min) + if (given < min) return min; - if(given > max) + if (given > max) return max; return given; } diff --git a/src/main/java/noppes/npcs/util/Vec3NPC.java b/src/main/java/noppes/npcs/util/Vec3NPC.java index 45b96e3ca..040936d28 100644 --- a/src/main/java/noppes/npcs/util/Vec3NPC.java +++ b/src/main/java/noppes/npcs/util/Vec3NPC.java @@ -2,8 +2,7 @@ package noppes.npcs.util; import net.minecraft.util.Vec3; -public class Vec3NPC extends Vec3 -{ +public class Vec3NPC extends Vec3 { public Vec3NPC(double p_i1108_1_, double p_i1108_3_, double p_i1108_5_) { super(p_i1108_1_, p_i1108_3_, p_i1108_5_); } diff --git a/src/main/java/overview.html b/src/main/java/overview.html index 790901c77..e5d47ef48 100644 --- a/src/main/java/overview.html +++ b/src/main/java/overview.html @@ -3,91 +3,91 @@

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
HookParamsDescription
Cancelable
Initevent(ScriptEvent), world, npcCalled when the npc spawns or respawns
Updateevent(ScriptEvent), world, npcCalled as update tick (once every 10 ticks)
Interactevent(ScriptEvent), world, npc, playerCalled when a player interacts with the npcyes
Dialogevent(ScriptEvent), world, npc, player, dialogCalled when a player opens a dialog from the npc
DialogClosedevent(ScriptEvent), world, npc, player, dialog, optionCalled when a player selects a dialog option or closes a dialog
Damagedevent(ScriptEventDamaged), world, npcCalled when an npc gets attacked. Can be cancelledyes
Killedevent(ScriptEventKilled), world, npcCalled when an npc gets killed
Attackevent(ScriptEventAttack), world, npcCalled when an npc is going to attackyes
Targetevent(ScriptEventTarget), world, npcCalled when an npc targets somethingyes
TargetLostevent(ScriptEventTarget), world, npc
Called when an npc looses his target
Killsevent(ScriptEvent), world, npc, target
Called when an npc kills something
Roleevent(ScriptEventRole), world, npc, player
Called by some roles
some
Collideevent(ScriptEvent), world, npc, entityCalled when an npc collides with an entity
HookParamsDescription
Cancelable
Initevent(ScriptEvent), world, npcCalled when the npc spawns or respawns
Updateevent(ScriptEvent), world, npcCalled as update tick (once every 10 ticks)
Interactevent(ScriptEvent), world, npc, playerCalled when a player interacts with the npcyes
Dialogevent(ScriptEvent), world, npc, player, dialogCalled when a player opens a dialog from the npc
DialogClosedevent(ScriptEvent), world, npc, player, dialog, optionCalled when a player selects a dialog option or closes a dialog
Damagedevent(ScriptEventDamaged), world, npcCalled when an npc gets attacked. Can be cancelledyes
Killedevent(ScriptEventKilled), world, npcCalled when an npc gets killed
Attackevent(ScriptEventAttack), world, npcCalled when an npc is going to attackyes
Targetevent(ScriptEventTarget), world, npcCalled when an npc targets somethingyes
TargetLostevent(ScriptEventTarget), world, npc
Called when an npc looses his target
Killsevent(ScriptEvent), world, npc, target
Called when an npc kills something
Roleevent(ScriptEventRole), world, npc, player
Called by some roles
some
Collideevent(ScriptEvent), world, npc, entityCalled when an npc collides with an entity
-

+

- \ No newline at end of file + diff --git a/src/main/java/tconstruct/client/tabs/AbstractTab.java b/src/main/java/tconstruct/client/tabs/AbstractTab.java index d4eff3982..b4a0986c6 100644 --- a/src/main/java/tconstruct/client/tabs/AbstractTab.java +++ b/src/main/java/tconstruct/client/tabs/AbstractTab.java @@ -10,57 +10,57 @@ import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; public abstract class AbstractTab extends GuiButton { - ResourceLocation texture = new ResourceLocation( - "textures/gui/container/creative_inventory/tabs.png"); - ItemStack renderStack; - RenderItem itemRenderer = new RenderItem(); + ResourceLocation texture = new ResourceLocation( + "textures/gui/container/creative_inventory/tabs.png"); + ItemStack renderStack; + RenderItem itemRenderer = new RenderItem(); - public AbstractTab(int id, int posX, int posY, ItemStack renderStack) { - super(id, posX, posY, 28, 32, ""); - this.renderStack = renderStack; - } + public AbstractTab(int id, int posX, int posY, ItemStack renderStack) { + super(id, posX, posY, 28, 32, ""); + this.renderStack = renderStack; + } - @Override - public void drawButton(Minecraft mc, int mouseX, int mouseY) { - if (this.visible) { - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - int yTexPos = this.enabled ? 3 : 32; - int ySize = this.enabled ? 25 : 32; - int xOffset = this.id == 2 ? 0 : 1; - int yPos = this.yPosition + (this.enabled ? 3 : 0); - mc.renderEngine.bindTexture(this.texture); - this.drawTexturedModalRect(this.xPosition, yPos, xOffset * 28, - yTexPos, 28, ySize); - RenderHelper.enableGUIStandardItemLighting(); - this.zLevel = 100.0F; - this.itemRenderer.zLevel = 100.0F; - GL11.glEnable(GL11.GL_LIGHTING); - GL11.glEnable(GL12.GL_RESCALE_NORMAL); - this.itemRenderer.renderItemAndEffectIntoGUI(mc.fontRenderer, - mc.renderEngine, renderStack, xPosition + 6, yPosition + 8); - this.itemRenderer.renderItemOverlayIntoGUI(mc.fontRenderer, - mc.renderEngine, renderStack, xPosition + 6, yPosition + 8); - GL11.glDisable(GL11.GL_LIGHTING); - GL11.glEnable(GL11.GL_BLEND); - this.itemRenderer.zLevel = 0.0F; - this.zLevel = 0.0F; - RenderHelper.disableStandardItemLighting(); - } - } + @Override + public void drawButton(Minecraft mc, int mouseX, int mouseY) { + if (this.visible) { + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + int yTexPos = this.enabled ? 3 : 32; + int ySize = this.enabled ? 25 : 32; + int xOffset = this.id == 2 ? 0 : 1; + int yPos = this.yPosition + (this.enabled ? 3 : 0); + mc.renderEngine.bindTexture(this.texture); + this.drawTexturedModalRect(this.xPosition, yPos, xOffset * 28, + yTexPos, 28, ySize); + RenderHelper.enableGUIStandardItemLighting(); + this.zLevel = 100.0F; + this.itemRenderer.zLevel = 100.0F; + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + this.itemRenderer.renderItemAndEffectIntoGUI(mc.fontRenderer, + mc.renderEngine, renderStack, xPosition + 6, yPosition + 8); + this.itemRenderer.renderItemOverlayIntoGUI(mc.fontRenderer, + mc.renderEngine, renderStack, xPosition + 6, yPosition + 8); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glEnable(GL11.GL_BLEND); + this.itemRenderer.zLevel = 0.0F; + this.zLevel = 0.0F; + RenderHelper.disableStandardItemLighting(); + } + } - @Override - public boolean mousePressed(Minecraft mc, int mouseX, int mouseY) { - boolean inWindow = this.enabled && this.visible - && mouseX >= this.xPosition && mouseY >= this.yPosition - && mouseX < this.xPosition + this.width - && mouseY < this.yPosition + this.height; - if (inWindow) { - this.onTabClicked(); - } - return inWindow; - } + @Override + public boolean mousePressed(Minecraft mc, int mouseX, int mouseY) { + boolean inWindow = this.enabled && this.visible + && mouseX >= this.xPosition && mouseY >= this.yPosition + && mouseX < this.xPosition + this.width + && mouseY < this.yPosition + this.height; + if (inWindow) { + this.onTabClicked(); + } + return inWindow; + } - public abstract void onTabClicked(); + public abstract void onTabClicked(); - public abstract boolean shouldAddToList(); + public abstract boolean shouldAddToList(); } diff --git a/src/main/java/tconstruct/client/tabs/InventoryTabCustomNpc.java b/src/main/java/tconstruct/client/tabs/InventoryTabCustomNpc.java index 983c2d495..e6e63b402 100644 --- a/src/main/java/tconstruct/client/tabs/InventoryTabCustomNpc.java +++ b/src/main/java/tconstruct/client/tabs/InventoryTabCustomNpc.java @@ -7,50 +7,50 @@ import noppes.npcs.CustomItems; import noppes.npcs.client.gui.player.inventory.*; public class InventoryTabCustomNpc extends AbstractTab { - public InventoryTabCustomNpc() { - super(0, 0, 0, new ItemStack(CustomItems.letter)); + public InventoryTabCustomNpc() { + super(0, 0, 0, new ItemStack(CustomItems.letter)); - if(CustomItems.letter == null) - renderStack = new ItemStack(Items.book); - } + if (CustomItems.letter == null) + renderStack = new ItemStack(Items.book); + } - @Override - public void onTabClicked() { - Thread t = new Thread(){ - @Override - public void run(){ - try { - Thread.sleep(100); - } catch (InterruptedException e) { - e.printStackTrace(); - } + @Override + public void onTabClicked() { + Thread t = new Thread() { + @Override + public void run() { + try { + Thread.sleep(100); + } catch (InterruptedException e) { + e.printStackTrace(); + } tabHelper(); - } - }; - t.start(); - } + } + }; + t.start(); + } - @Override - public boolean shouldAddToList() { - return true; - } + @Override + public boolean shouldAddToList() { + return true; + } - public static void tabHelper(){ + public static void tabHelper() { Minecraft mc = Minecraft.getMinecraft(); int tab = GuiCNPCInventory.activeTab; - if(tab == -100){ + if (tab == -100) { mc.displayGuiScreen(new GuiQuestLog()); } - if(tab == -101){ + if (tab == -101) { mc.displayGuiScreen(new GuiParty()); } - if(tab == -102){ + if (tab == -102) { mc.displayGuiScreen(new GuiFaction()); } - if(tab == -103){ + if (tab == -103) { mc.displayGuiScreen(new GuiSettings()); } - if(tab == -104){ + if (tab == -104) { mc.displayGuiScreen(new GuiProfiles()); } } diff --git a/src/main/java/tconstruct/client/tabs/InventoryTabVanilla.java b/src/main/java/tconstruct/client/tabs/InventoryTabVanilla.java index 8378c936c..ea3ffe5e4 100644 --- a/src/main/java/tconstruct/client/tabs/InventoryTabVanilla.java +++ b/src/main/java/tconstruct/client/tabs/InventoryTabVanilla.java @@ -4,17 +4,17 @@ import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; public class InventoryTabVanilla extends AbstractTab { - public InventoryTabVanilla() { - super(0, 0, 0, new ItemStack(Blocks.crafting_table)); - } + public InventoryTabVanilla() { + super(0, 0, 0, new ItemStack(Blocks.crafting_table)); + } - @Override - public void onTabClicked() { + @Override + public void onTabClicked() { TabRegistry.openInventoryGui(); - } + } - @Override - public boolean shouldAddToList() { - return true; - } + @Override + public boolean shouldAddToList() { + return true; + } } diff --git a/src/main/java/tconstruct/client/tabs/TabRegistry.java b/src/main/java/tconstruct/client/tabs/TabRegistry.java index ff3c87093..9d21a784c 100644 --- a/src/main/java/tconstruct/client/tabs/TabRegistry.java +++ b/src/main/java/tconstruct/client/tabs/TabRegistry.java @@ -14,88 +14,88 @@ import java.util.ArrayList; import java.util.List; public class TabRegistry { - private static ArrayList tabList = new ArrayList(); + private static ArrayList tabList = new ArrayList(); - public static void registerTab(AbstractTab tab) { - tabList.add(tab); - } + public static void registerTab(AbstractTab tab) { + tabList.add(tab); + } - public static ArrayList getTabList() { - return tabList; - } + public static ArrayList getTabList() { + return tabList; + } - @SideOnly(Side.CLIENT) - @SubscribeEvent - public void guiPostInit(GuiScreenEvent.InitGuiEvent.Post event) { - if ((event.gui instanceof GuiInventory)) { - int xSize = 176; - int ySize = 166; - int guiLeft = (event.gui.width - xSize) / 2; - int guiTop = (event.gui.height - ySize) / 2; - guiLeft += getPotionOffset(); - updateTabValues(guiLeft, guiTop, InventoryTabVanilla.class); - addTabsToList(event.buttonList); - } - } + @SideOnly(Side.CLIENT) + @SubscribeEvent + public void guiPostInit(GuiScreenEvent.InitGuiEvent.Post event) { + if ((event.gui instanceof GuiInventory)) { + int xSize = 176; + int ySize = 166; + int guiLeft = (event.gui.width - xSize) / 2; + int guiTop = (event.gui.height - ySize) / 2; + guiLeft += getPotionOffset(); + updateTabValues(guiLeft, guiTop, InventoryTabVanilla.class); + addTabsToList(event.buttonList); + } + } - private static Minecraft mc = FMLClientHandler.instance().getClient(); + private static Minecraft mc = FMLClientHandler.instance().getClient(); - public static void openInventoryGui() { - mc.thePlayer.sendQueue.addToSendQueue(new C0DPacketCloseWindow( - mc.thePlayer.openContainer.windowId)); - GuiInventory inventory = new GuiInventory(mc.thePlayer); - mc.displayGuiScreen(inventory); - } + public static void openInventoryGui() { + mc.thePlayer.sendQueue.addToSendQueue(new C0DPacketCloseWindow( + mc.thePlayer.openContainer.windowId)); + GuiInventory inventory = new GuiInventory(mc.thePlayer); + mc.displayGuiScreen(inventory); + } - public static void updateTabValues(int cornerX, int cornerY, - Class selectedButton) { - int count = 2; - for (int i = 0; i < tabList.size(); i++) { - AbstractTab t = tabList.get(i); - if (t.shouldAddToList()) { - t.id = count; - t.xPosition = cornerX + (count - 2) * 28; - t.yPosition = cornerY - 28; - t.enabled = !t.getClass().equals(selectedButton); - count++; - } - } - } + public static void updateTabValues(int cornerX, int cornerY, + Class selectedButton) { + int count = 2; + for (int i = 0; i < tabList.size(); i++) { + AbstractTab t = tabList.get(i); + if (t.shouldAddToList()) { + t.id = count; + t.xPosition = cornerX + (count - 2) * 28; + t.yPosition = cornerY - 28; + t.enabled = !t.getClass().equals(selectedButton); + count++; + } + } + } - public static void addTabsToList(List buttonList) { - for (AbstractTab tab : tabList) { - if (tab.shouldAddToList()) { - buttonList.add(tab); - } - } - } + public static void addTabsToList(List buttonList) { + for (AbstractTab tab : tabList) { + if (tab.shouldAddToList()) { + buttonList.add(tab); + } + } + } - public static int getPotionOffset() { - // If at least one potion is active... - if (!mc.thePlayer.getActivePotionEffects().isEmpty()) { - if (Loader.isModLoaded("NotEnoughItems")) { - try { - // Check whether NEI is hidden and enabled - Class c = Class - .forName("codechicken.nei.NEIClientConfig"); - Object hidden = c.getMethod("isHidden").invoke(null); - Object enabled = c.getMethod("isEnabled").invoke(null); - if (hidden != null && hidden instanceof Boolean - && enabled != null && enabled instanceof Boolean) { - if ((Boolean) hidden || !((Boolean) enabled)) { - // If NEI is disabled or hidden, offset the tabs by - // 60 - return 60; - } - } - } catch (Exception e) { - } - } else { - // If NEI is not installed, offset the tabs - return 60; - } - } - // No potions, no offset needed - return 0; - } + public static int getPotionOffset() { + // If at least one potion is active... + if (!mc.thePlayer.getActivePotionEffects().isEmpty()) { + if (Loader.isModLoaded("NotEnoughItems")) { + try { + // Check whether NEI is hidden and enabled + Class c = Class + .forName("codechicken.nei.NEIClientConfig"); + Object hidden = c.getMethod("isHidden").invoke(null); + Object enabled = c.getMethod("isEnabled").invoke(null); + if (hidden != null && hidden instanceof Boolean + && enabled != null && enabled instanceof Boolean) { + if ((Boolean) hidden || !((Boolean) enabled)) { + // If NEI is disabled or hidden, offset the tabs by + // 60 + return 60; + } + } + } catch (Exception e) { + } + } else { + // If NEI is not installed, offset the tabs + return 60; + } + } + // No potions, no offset needed + return 0; + } } diff --git a/src/main/resources/assets/customnpcs/sounds.json b/src/main/resources/assets/customnpcs/sounds.json index 9b90149fb..6725c8fe2 100644 --- a/src/main/resources/assets/customnpcs/sounds.json +++ b/src/main/resources/assets/customnpcs/sounds.json @@ -1,382 +1,608 @@ { "gun.empty": { "category": "player", - "sounds": ["gun/empty"] + "sounds": [ + "gun/empty" + ] }, "gun.ak47.load": { "category": "player", - "sounds": ["gun/ak47chamberround"] + "sounds": [ + "gun/ak47chamberround" + ] }, "gun.pistol.shot": { "category": "player", - "sounds": ["gun/pistolshot"] + "sounds": [ + "gun/pistolshot" + ] }, "gun.pistol.trigger": { "category": "player", - "sounds": ["gun/pistoltrigger"] + "sounds": [ + "gun/pistoltrigger" + ] }, "magic.charge": { "category": "player", - "sounds": ["magic/charge"] + "sounds": [ + "magic/charge" + ] }, "magic.shot": { "category": "player", - "sounds": ["magic/shot"] + "sounds": [ + "magic/shot" + ] }, "misc.old_explode": { "category": "player", - "sounds": ["misc/old_explode"] + "sounds": [ + "misc/old_explode" + ] }, "misc.swosh": { "category": "player", - "sounds": ["misc/swosh"] + "sounds": [ + "misc/swosh" + ] }, "songs.excalibur": { "category": "player", - "sounds": [{"name": "songs/Failboat103 - Excalibuuur", "stream": true}] + "sounds": [ + { + "name": "songs/Failboat103 - Excalibuuur", + "stream": true + } + ] }, "songs.kyleb_7by8": { "category": "player", - "sounds": [{"name": "songs/TheKyleb - 7 by 8", "stream": true}] + "sounds": [ + { + "name": "songs/TheKyleb - 7 by 8", + "stream": true + } + ] }, "songs.kyleb_bard": { "category": "player", - "sounds": [{"name": "songs/TheKyleb - Bard", "stream": true}] + "sounds": [ + { + "name": "songs/TheKyleb - Bard", + "stream": true + } + ] }, "human.female.evil.attack": { "category": "player", - "sounds": ["human/female/evil/Attack 1","human/female/evil/Attack 2"] + "sounds": [ + "human/female/evil/Attack 1", + "human/female/evil/Attack 2" + ] }, "human.female.evil.death": { "category": "player", - "sounds": ["human/female/evil/Death 1","human/female/evil/Death 2"] + "sounds": [ + "human/female/evil/Death 1", + "human/female/evil/Death 2" + ] }, "human.female.evil.hurt": { "category": "player", - "sounds": ["human/female/evil/Hurt 1","human/female/evil/Hurt 2"] + "sounds": [ + "human/female/evil/Hurt 1", + "human/female/evil/Hurt 2" + ] }, "human.female.evil.what_do_you_need": { "category": "player", - "sounds": ["human/female/evil/What Do You Need"] + "sounds": [ + "human/female/evil/What Do You Need" + ] }, "human.female.evil.what_do_you_want": { "category": "player", - "sounds": ["human/female/evil/What Do You Want"] + "sounds": [ + "human/female/evil/What Do You Want" + ] }, "human.female.evil.yes": { "category": "player", - "sounds": ["human/female/evil/Yes"] + "sounds": [ + "human/female/evil/Yes" + ] }, "human.female.evil.never_defeat_me": { "category": "player", - "sounds": ["human/female/evil/You Will Never Defeat Me"] + "sounds": [ + "human/female/evil/You Will Never Defeat Me" + ] }, "human.female.heroic.attack": { "category": "player", - "sounds": ["human/female/heroic/Attack 1","human/female/heroic/Attack 2"] + "sounds": [ + "human/female/heroic/Attack 1", + "human/female/heroic/Attack 2" + ] }, "human.female.heroic.death": { "category": "player", - "sounds": ["human/female/heroic/Death 1","human/female/heroic/Death 2"] + "sounds": [ + "human/female/heroic/Death 1", + "human/female/heroic/Death 2" + ] }, "human.female.heroic.hurt": { "category": "player", - "sounds": ["human/female/heroic/Hurt 1","human/female/heroic/Hurt 2"] + "sounds": [ + "human/female/heroic/Hurt 1", + "human/female/heroic/Hurt 2" + ] }, "human.female.heroic.honor_and_glory": { "category": "player", - "sounds": ["human/female/heroic/For Honor and Glory"] + "sounds": [ + "human/female/heroic/For Honor and Glory" + ] }, "human.female.heroic.cleanse_scourge": { "category": "player", - "sounds": ["human/female/heroic/I Shall Cleanse This Scourge"] + "sounds": [ + "human/female/heroic/I Shall Cleanse This Scourge" + ] }, "human.female.heroic.never_fall": { "category": "player", - "sounds": ["human/female/heroic/I Will Never Fall"] + "sounds": [ + "human/female/heroic/I Will Never Fall" + ] }, "human.female.heroic.justice_served": { "category": "player", - "sounds": ["human/female/heroic/Justice Served"] + "sounds": [ + "human/female/heroic/Justice Served" + ] }, "human.female.heroic.be_cleansed": { "category": "player", - "sounds": ["human/female/heroic/Thou Shall Be Cleansed"] + "sounds": [ + "human/female/heroic/Thou Shall Be Cleansed" + ] }, "human.female.heroic.not_much_time": { "category": "player", - "sounds": ["human/female/heroic/We Don't Have Much Time"] + "sounds": [ + "human/female/heroic/We Don't Have Much Time" + ] }, "human.female.villager.attack": { "category": "player", - "sounds": ["human/female/villager/Attack 1","human/female/villager/Attack 2"] + "sounds": [ + "human/female/villager/Attack 1", + "human/female/villager/Attack 2" + ] }, "human.female.villager.death": { "category": "player", - "sounds": ["human/female/villager/Death 1","human/female/villager/Death 2"] + "sounds": [ + "human/female/villager/Death 1", + "human/female/villager/Death 2" + ] }, "human.female.villager.hurt": { "category": "player", - "sounds": ["human/female/villager/Hurt 1","human/female/villager/Hurt 2"] + "sounds": [ + "human/female/villager/Hurt 1", + "human/female/villager/Hurt 2" + ] }, "human.female.villager.good_day": { "category": "player", - "sounds": ["human/female/villager/Good Day"] + "sounds": [ + "human/female/villager/Good Day" + ] }, "human.female.villager.heh": { "category": "player", - "sounds": ["human/female/villager/Heh"] + "sounds": [ + "human/female/villager/Heh" + ] }, "human.female.villager.help": { "category": "player", - "sounds": ["human/female/villager/Help"] + "sounds": [ + "human/female/villager/Help" + ] }, "human.female.villager.hm": { "category": "player", - "sounds": ["human/female/villager/Hm"] + "sounds": [ + "human/female/villager/Hm" + ] }, "human.female.villager.uhuh": { "category": "player", - "sounds": ["human/female/villager/Uhuh"] + "sounds": [ + "human/female/villager/Uhuh" + ] }, "human.female.villager.what_brings_you_here": { "category": "player", - "sounds": ["human/female/villager/What Brings You Here"] + "sounds": [ + "human/female/villager/What Brings You Here" + ] }, "human.female.villager.what_do_you_need": { "category": "player", - "sounds": ["human/female/villager/What Do You Need"] + "sounds": [ + "human/female/villager/What Do You Need" + ] }, "human.female.villager.trade": { "category": "player", - "sounds": ["human/female/villager/Would You Like To Trade"] + "sounds": [ + "human/female/villager/Would You Like To Trade" + ] }, "human.female.villager.yes": { "category": "player", - "sounds": ["human/female/villager/Yes"] + "sounds": [ + "human/female/villager/Yes" + ] }, "human.girl.evil.attack": { "category": "player", - "sounds": ["human/girl/evil/Attack 1","human/girl/evil/Attack 2"] + "sounds": [ + "human/girl/evil/Attack 1", + "human/girl/evil/Attack 2" + ] }, "human.girl.evil.death": { "category": "player", - "sounds": ["human/girl/evil/Death 1","human/girl/evil/Death 2"] + "sounds": [ + "human/girl/evil/Death 1", + "human/girl/evil/Death 2" + ] }, "human.girl.evil.hurt": { "category": "player", - "sounds": ["human/girl/evil/Hurt 1","human/girl/evil/Hurt 2"] + "sounds": [ + "human/girl/evil/Hurt 1", + "human/girl/evil/Hurt 2" + ] }, "human.girl.evil.what_do_you_need": { "category": "player", - "sounds": ["human/girl/evil/What Do You Need"] + "sounds": [ + "human/girl/evil/What Do You Need" + ] }, "human.girl.evil.what_do_you_want": { "category": "player", - "sounds": ["human/girl/evil/What Do You Want"] + "sounds": [ + "human/girl/evil/What Do You Want" + ] }, "human.girl.evil.yes": { "category": "player", - "sounds": ["human/girl/evil/Yes"] + "sounds": [ + "human/girl/evil/Yes" + ] }, "human.girl.evil.never_defeat_me": { "category": "player", - "sounds": ["human/girl/evil/You Will Never Defeat Me"] + "sounds": [ + "human/girl/evil/You Will Never Defeat Me" + ] }, "human.girl.heroic.attack": { "category": "player", - "sounds": ["human/girl/heroic/Attack 1","human/girl/heroic/Attack 2"] + "sounds": [ + "human/girl/heroic/Attack 1", + "human/girl/heroic/Attack 2" + ] }, "human.girl.heroic.death": { "category": "player", - "sounds": ["human/girl/heroic/Death 1","human/girl/heroic/Death 2"] + "sounds": [ + "human/girl/heroic/Death 1", + "human/girl/heroic/Death 2" + ] }, "human.girl.heroic.hurt": { "category": "player", - "sounds": ["human/girl/heroic/Hurt 1","human/girl/heroic/Hurt 2"] + "sounds": [ + "human/girl/heroic/Hurt 1", + "human/girl/heroic/Hurt 2" + ] }, "human.girl.heroic.honor_and_glory": { "category": "player", - "sounds": ["human/girl/heroic/For Honor and Glory"] + "sounds": [ + "human/girl/heroic/For Honor and Glory" + ] }, "human.girl.heroic.cleanse_scourge": { "category": "player", - "sounds": ["human/girl/heroic/I Shall Cleanse This Scourge"] + "sounds": [ + "human/girl/heroic/I Shall Cleanse This Scourge" + ] }, "human.girl.heroic.never_fall": { "category": "player", - "sounds": ["human/girl/heroic/I Will Never Fall"] + "sounds": [ + "human/girl/heroic/I Will Never Fall" + ] }, "human.girl.heroic.justice_served": { "category": "player", - "sounds": ["human/girl/heroic/Justice Served"] + "sounds": [ + "human/girl/heroic/Justice Served" + ] }, "human.girl.heroic.be_cleansed": { "category": "player", - "sounds": ["human/girl/heroic/Thou Shall Be Cleansed"] + "sounds": [ + "human/girl/heroic/Thou Shall Be Cleansed" + ] }, "human.girl.heroic.not_much_time": { "category": "player", - "sounds": ["human/girl/heroic/We Don't Have Much Time"] + "sounds": [ + "human/girl/heroic/We Don't Have Much Time" + ] }, "human.girl.villager.attack": { "category": "player", - "sounds": ["human/girl/villager/Attack 1","human/girl/villager/Attack 2"] + "sounds": [ + "human/girl/villager/Attack 1", + "human/girl/villager/Attack 2" + ] }, "human.girl.villager.death": { "category": "player", - "sounds": ["human/girl/villager/Death 1","human/girl/villager/Death 2"] + "sounds": [ + "human/girl/villager/Death 1", + "human/girl/villager/Death 2" + ] }, "human.girl.villager.hurt": { "category": "player", - "sounds": ["human/girl/villager/Hurt 1","human/girl/villager/Hurt 2"] + "sounds": [ + "human/girl/villager/Hurt 1", + "human/girl/villager/Hurt 2" + ] }, "human.girl.villager.good_day": { "category": "player", - "sounds": ["human/girl/villager/Good Day"] + "sounds": [ + "human/girl/villager/Good Day" + ] }, "human.girl.villager.heh": { "category": "player", - "sounds": ["human/girl/villager/Heh"] + "sounds": [ + "human/girl/villager/Heh" + ] }, "human.girl.villager.help": { "category": "player", - "sounds": ["human/girl/villager/Help"] + "sounds": [ + "human/girl/villager/Help" + ] }, "human.girl.villager.hm": { "category": "player", - "sounds": ["human/girl/villager/Hm"] + "sounds": [ + "human/girl/villager/Hm" + ] }, "human.girl.villager.uhuh": { "category": "player", - "sounds": ["human/girl/villager/Uhuh"] + "sounds": [ + "human/girl/villager/Uhuh" + ] }, "human.girl.villager.what_brings_you_here": { "category": "player", - "sounds": ["human/girl/villager/What Brings You Here"] + "sounds": [ + "human/girl/villager/What Brings You Here" + ] }, "human.girl.villager.what_do_you_need": { "category": "player", - "sounds": ["human/girl/villager/What Do You Need"] + "sounds": [ + "human/girl/villager/What Do You Need" + ] }, "human.girl.villager.trade": { "category": "player", - "sounds": ["human/girl/villager/Would You Like To Trade"] + "sounds": [ + "human/girl/villager/Would You Like To Trade" + ] }, "human.girl.villager.yes": { "category": "player", - "sounds": ["human/girl/villager/Yes"] + "sounds": [ + "human/girl/villager/Yes" + ] }, "human.male.evil.attack": { "category": "player", - "sounds": ["human/male/evil/Attack 1","human/male/evil/Attack 2"] + "sounds": [ + "human/male/evil/Attack 1", + "human/male/evil/Attack 2" + ] }, "human.male.evil.death": { "category": "player", - "sounds": ["human/male/evil/Death 1","human/male/evil/Death 2"] + "sounds": [ + "human/male/evil/Death 1", + "human/male/evil/Death 2" + ] }, "human.male.evil.hurt": { "category": "player", - "sounds": ["human/male/evil/Hurt 1","human/male/evil/Hurt 2"] + "sounds": [ + "human/male/evil/Hurt 1", + "human/male/evil/Hurt 2" + ] }, "human.male.evil.what_do_you_need": { "category": "player", - "sounds": ["human/male/evil/What Do You Need"] + "sounds": [ + "human/male/evil/What Do You Need" + ] }, "human.male.evil.what_do_you_want": { "category": "player", - "sounds": ["human/male/evil/What Do You Want"] + "sounds": [ + "human/male/evil/What Do You Want" + ] }, "human.male.evil.yes": { "category": "player", - "sounds": ["human/male/evil/Yes"] + "sounds": [ + "human/male/evil/Yes" + ] }, "human.male.evil.never_defeat_me": { "category": "player", - "sounds": ["human/male/evil/You Will Never Defeat Me"] + "sounds": [ + "human/male/evil/You Will Never Defeat Me" + ] }, "human.male.heroic.attack": { "category": "player", - "sounds": ["human/male/heroic/Attack 1","human/male/heroic/Attack 2"] + "sounds": [ + "human/male/heroic/Attack 1", + "human/male/heroic/Attack 2" + ] }, "human.male.heroic.death": { "category": "player", - "sounds": ["human/male/heroic/Death 1","human/male/heroic/Death 2"] + "sounds": [ + "human/male/heroic/Death 1", + "human/male/heroic/Death 2" + ] }, "human.male.heroic.hurt": { "category": "player", - "sounds": ["human/male/heroic/Hurt 1","human/male/heroic/Hurt 2"] + "sounds": [ + "human/male/heroic/Hurt 1", + "human/male/heroic/Hurt 2" + ] }, "human.male.heroic.honor_and_glory": { "category": "player", - "sounds": ["human/male/heroic/For Honor and Glory"] + "sounds": [ + "human/male/heroic/For Honor and Glory" + ] }, "human.male.heroic.cleanse_scourge": { "category": "player", - "sounds": ["human/male/heroic/I Shall Cleanse This Scourge"] + "sounds": [ + "human/male/heroic/I Shall Cleanse This Scourge" + ] }, "human.male.heroic.never_fall": { "category": "player", - "sounds": ["human/male/heroic/I Will Never Fall"] + "sounds": [ + "human/male/heroic/I Will Never Fall" + ] }, "human.male.heroic.justice_served": { "category": "player", - "sounds": ["human/male/heroic/Justice Served"] + "sounds": [ + "human/male/heroic/Justice Served" + ] }, "human.male.heroic.be_cleansed": { "category": "player", - "sounds": ["human/male/heroic/Thou Shall Be Cleansed"] + "sounds": [ + "human/male/heroic/Thou Shall Be Cleansed" + ] }, "human.male.heroic.not_much_time": { "category": "player", - "sounds": ["human/male/heroic/We Don't Have Much Time"] + "sounds": [ + "human/male/heroic/We Don't Have Much Time" + ] }, "human.male.villager.attack": { "category": "player", - "sounds": ["human/male/villager/Attack 1","human/male/villager/Attack 2"] + "sounds": [ + "human/male/villager/Attack 1", + "human/male/villager/Attack 2" + ] }, "human.male.villager.death": { "category": "player", - "sounds": ["human/male/villager/Death 1","human/male/villager/Death 2"] + "sounds": [ + "human/male/villager/Death 1", + "human/male/villager/Death 2" + ] }, "human.male.villager.hurt": { "category": "player", - "sounds": ["human/male/villager/Hurt 1","human/male/villager/Hurt 2"] + "sounds": [ + "human/male/villager/Hurt 1", + "human/male/villager/Hurt 2" + ] }, "human.male.villager.good_day": { "category": "player", - "sounds": ["human/male/villager/Good Day"] + "sounds": [ + "human/male/villager/Good Day" + ] }, "human.male.villager.heh": { "category": "player", - "sounds": ["human/male/villager/Heh"] + "sounds": [ + "human/male/villager/Heh" + ] }, "human.male.villager.help": { "category": "player", - "sounds": ["human/male/villager/Help"] + "sounds": [ + "human/male/villager/Help" + ] }, "human.male.villager.hm": { "category": "player", - "sounds": ["human/male/villager/Hm"] + "sounds": [ + "human/male/villager/Hm" + ] }, "human.male.villager.uhuh": { "category": "player", - "sounds": ["human/male/villager/Uhuh"] + "sounds": [ + "human/male/villager/Uhuh" + ] }, "human.male.villager.what_brings_you_here": { "category": "player", - "sounds": ["human/male/villager/What Brings You Here"] + "sounds": [ + "human/male/villager/What Brings You Here" + ] }, "human.male.villager.what_do_you_need": { "category": "player", - "sounds": ["human/male/villager/What Do You Need"] + "sounds": [ + "human/male/villager/What Do You Need" + ] }, "human.male.villager.trade": { "category": "player", - "sounds": ["human/male/villager/Would You Like To Trade"] + "sounds": [ + "human/male/villager/Would You Like To Trade" + ] }, "human.male.villager.yes": { "category": "player", - "sounds": ["human/male/villager/Yes"] + "sounds": [ + "human/male/villager/Yes" + ] } -} \ No newline at end of file +} diff --git a/src/main/resources/assets/customnpcs/textures/items/npcEarthElement.png.mcmeta b/src/main/resources/assets/customnpcs/textures/items/npcEarthElement.png.mcmeta index 71b657e59..cf1f79bd3 100644 --- a/src/main/resources/assets/customnpcs/textures/items/npcEarthElement.png.mcmeta +++ b/src/main/resources/assets/customnpcs/textures/items/npcEarthElement.png.mcmeta @@ -2,31 +2,38 @@ "animation": { "interpolate": true, "frames": [ - { - "index": 0, - "time": 60 - }, { - "index": 1, - "time": 2 - }, { - "index": 2, - "time": 2 - }, { - "index": 3, - "time": 2 - }, { - "index": 4, - "time": 2 - }, { - "index": 5, - "time": 2 - }, { - "index": 6, - "time": 2 - }, { - "index": 7, - "time": 2 - } - ] + { + "index": 0, + "time": 60 + }, + { + "index": 1, + "time": 2 + }, + { + "index": 2, + "time": 2 + }, + { + "index": 3, + "time": 2 + }, + { + "index": 4, + "time": 2 + }, + { + "index": 5, + "time": 2 + }, + { + "index": 6, + "time": 2 + }, + { + "index": 7, + "time": 2 + } + ] } } diff --git a/src/main/resources/assets/customnpcs/textures/items/npcIceSpell.png.mcmeta b/src/main/resources/assets/customnpcs/textures/items/npcIceSpell.png.mcmeta index 88e1ebb35..9861327d0 100644 --- a/src/main/resources/assets/customnpcs/textures/items/npcIceSpell.png.mcmeta +++ b/src/main/resources/assets/customnpcs/textures/items/npcIceSpell.png.mcmeta @@ -2,46 +2,58 @@ "animation": { "interpolate": true, "frames": [ - { - "index": 0, - "time": 2 - }, { - "index": 1, - "time": 2 - }, { - "index": 2, - "time": 2 - }, { - "index": 3, - "time": 2 - }, { - "index": 4, - "time": 2 - }, { - "index": 5, - "time": 2 - }, { - "index": 6, - "time": 2 - }, { - "index": 7, - "time": 2 - }, { - "index": 8, - "time": 2 - }, { - "index": 9, - "time": 2 - }, { - "index": 10, - "time": 2 - }, { - "index": 11, - "time": 2 - }, { - "index": 12, - "time": 2 - } - ] + { + "index": 0, + "time": 2 + }, + { + "index": 1, + "time": 2 + }, + { + "index": 2, + "time": 2 + }, + { + "index": 3, + "time": 2 + }, + { + "index": 4, + "time": 2 + }, + { + "index": 5, + "time": 2 + }, + { + "index": 6, + "time": 2 + }, + { + "index": 7, + "time": 2 + }, + { + "index": 8, + "time": 2 + }, + { + "index": 9, + "time": 2 + }, + { + "index": 10, + "time": 2 + }, + { + "index": 11, + "time": 2 + }, + { + "index": 12, + "time": 2 + } + ] } } diff --git a/src/main/resources/assets/customnpcs/textures/items/npcNatureSpell.png.mcmeta b/src/main/resources/assets/customnpcs/textures/items/npcNatureSpell.png.mcmeta index a14e88b0e..d4fce84b8 100644 --- a/src/main/resources/assets/customnpcs/textures/items/npcNatureSpell.png.mcmeta +++ b/src/main/resources/assets/customnpcs/textures/items/npcNatureSpell.png.mcmeta @@ -7,7 +7,7 @@ 1, 2, 3, - 4, + 4 ] } -} \ No newline at end of file +}